Commit 79fe346e by Jason Merrill Committed by Jason Merrill

typeck.c (require_complete_type_sfinae): Add complain parm to...

	* typeck.c (require_complete_type_sfinae): Add complain parm to...
	(require_complete_type): ...this function.
	(cp_build_array_ref, convert_arguments): Use it.
	(convert_for_initialization, cp_build_modify_expr): Likewise.
	* cp-tree.h: Declare it.
	* call.c (build_over_call): Use it.

From-SVN: r164918
parent 82a1c2fe
2010-10-03 Jason Merrill <jason@redhat.com>
* typeck.c (require_complete_type_sfinae): Add complain parm to...
(require_complete_type): ...this function.
(cp_build_array_ref, convert_arguments): Use it.
(convert_for_initialization, cp_build_modify_expr): Likewise.
* cp-tree.h: Declare it.
* call.c (build_over_call): Use it.
2010-09-30 Iain Sandoe <iains@gcc.gnu.org> 2010-09-30 Iain Sandoe <iains@gcc.gnu.org>
merge from FSF 'apple/trunk' branch. merge from FSF 'apple/trunk' branch.
......
...@@ -5655,7 +5655,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain) ...@@ -5655,7 +5655,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
if (TREE_THIS_VOLATILE (fn) && cfun) if (TREE_THIS_VOLATILE (fn) && cfun)
current_function_returns_abnormally = 1; current_function_returns_abnormally = 1;
if (!VOID_TYPE_P (return_type)) if (!VOID_TYPE_P (return_type))
require_complete_type (return_type); require_complete_type_sfinae (return_type, complain);
return convert_from_reference (expr); return convert_from_reference (expr);
} }
......
...@@ -5432,6 +5432,7 @@ extern int string_conv_p (const_tree, const_tree, int); ...@@ -5432,6 +5432,7 @@ extern int string_conv_p (const_tree, const_tree, int);
extern tree cp_truthvalue_conversion (tree); extern tree cp_truthvalue_conversion (tree);
extern tree condition_conversion (tree); extern tree condition_conversion (tree);
extern tree require_complete_type (tree); extern tree require_complete_type (tree);
extern tree require_complete_type_sfinae (tree, tsubst_flags_t);
extern tree complete_type (tree); extern tree complete_type (tree);
extern tree complete_type_or_else (tree, tree); extern tree complete_type_or_else (tree, tree);
extern tree complete_type_or_maybe_complain (tree, tree, tsubst_flags_t); extern tree complete_type_or_maybe_complain (tree, tree, tsubst_flags_t);
......
...@@ -64,11 +64,11 @@ static int convert_arguments (tree, VEC(tree,gc) **, tree, int, ...@@ -64,11 +64,11 @@ static int convert_arguments (tree, VEC(tree,gc) **, tree, int,
/* Do `exp = require_complete_type (exp);' to make sure exp /* Do `exp = require_complete_type (exp);' to make sure exp
does not have an incomplete type. (That includes void types.) does not have an incomplete type. (That includes void types.)
Returns the error_mark_node if the VALUE does not have Returns error_mark_node if the VALUE does not have
complete type when this function returns. */ complete type when this function returns. */
tree tree
require_complete_type (tree value) require_complete_type_sfinae (tree value, tsubst_flags_t complain)
{ {
tree type; tree type;
...@@ -87,12 +87,18 @@ require_complete_type (tree value) ...@@ -87,12 +87,18 @@ require_complete_type (tree value)
if (COMPLETE_TYPE_P (type)) if (COMPLETE_TYPE_P (type))
return value; return value;
if (complete_type_or_else (type, value)) if (complete_type_or_maybe_complain (type, value, complain))
return value; return value;
else else
return error_mark_node; return error_mark_node;
} }
tree
require_complete_type (tree value)
{
return require_complete_type_sfinae (value, tf_warning_or_error);
}
/* Try to complete TYPE, if it is incomplete. For example, if TYPE is /* Try to complete TYPE, if it is incomplete. For example, if TYPE is
a template instantiation, do the instantiation. Returns TYPE, a template instantiation, do the instantiation. Returns TYPE,
whether or not it could be completed, unless something goes whether or not it could be completed, unless something goes
...@@ -3039,7 +3045,8 @@ cp_build_array_ref (location_t loc, tree array, tree idx, ...@@ -3039,7 +3045,8 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
|= (CP_TYPE_VOLATILE_P (type) | TREE_SIDE_EFFECTS (array)); |= (CP_TYPE_VOLATILE_P (type) | TREE_SIDE_EFFECTS (array));
TREE_THIS_VOLATILE (rval) TREE_THIS_VOLATILE (rval)
|= (CP_TYPE_VOLATILE_P (type) | TREE_THIS_VOLATILE (array)); |= (CP_TYPE_VOLATILE_P (type) | TREE_THIS_VOLATILE (array));
ret = require_complete_type (fold_if_not_in_template (rval)); ret = require_complete_type_sfinae (fold_if_not_in_template (rval),
complain);
protected_set_expr_location (ret, loc); protected_set_expr_location (ret, loc);
return ret; return ret;
} }
...@@ -3542,7 +3549,7 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl, ...@@ -3542,7 +3549,7 @@ convert_arguments (tree typelist, VEC(tree,gc) **values, tree fndecl,
/* Don't do ellipsis conversion for __built_in_constant_p /* Don't do ellipsis conversion for __built_in_constant_p
as this will result in spurious errors for non-trivial as this will result in spurious errors for non-trivial
types. */ types. */
val = require_complete_type (val); val = require_complete_type_sfinae (val, complain);
else else
val = convert_arg_to_ellipsis (val); val = convert_arg_to_ellipsis (val);
...@@ -6744,7 +6751,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs, ...@@ -6744,7 +6751,7 @@ cp_build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs,
} }
else else
{ {
lhs = require_complete_type (lhs); lhs = require_complete_type_sfinae (lhs, complain);
if (lhs == error_mark_node) if (lhs == error_mark_node)
return error_mark_node; return error_mark_node;
...@@ -7592,7 +7599,7 @@ convert_for_initialization (tree exp, tree type, tree rhs, int flags, ...@@ -7592,7 +7599,7 @@ convert_for_initialization (tree exp, tree type, tree rhs, int flags,
} }
if (exp != 0) if (exp != 0)
exp = require_complete_type (exp); exp = require_complete_type_sfinae (exp, complain);
if (exp == error_mark_node) if (exp == error_mark_node)
return error_mark_node; return error_mark_node;
......
2010-10-03 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/sfinae5.C: New.
2010-10-02 H.J. Lu <hongjiu.lu@intel.com> 2010-10-02 H.J. Lu <hongjiu.lu@intel.com>
PR tree-optimization/45720 PR tree-optimization/45720
......
// { dg-options -std=c++0x }
template<class T>
T&& create();
template <class T, class U,
class = decltype(create<T>() = create<U>())
>
char test(int);
template <class, class>
double test(...);
int main() {
test<int[], int[]>(0); // #1
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment