Commit 03b8c9bf by Jason Merrill Committed by Jason Merrill

pt.c (tsubst_default_argument): Indicate where the default argument is being instantiated for.

	* pt.c (tsubst_default_argument): Indicate where the default
	argument is being instantiated for.
	(tsubst_expr): Restore previous location.
	(tsubst_copy_and_build): Set and restore location.
	* call.c (build_new_method_call_1): Remember location of call.
	* semantics.c (finish_call_expr): Here too.
	* parser.c (cp_parser_omp_for_loop): Remember the location of the
	increment expression.

From-SVN: r190662
parent b21deb04
2012-08-24 Jason Merrill <jason@redhat.com> 2012-08-24 Jason Merrill <jason@redhat.com>
* pt.c (tsubst_default_argument): Indicate where the default
argument is being instantiated for.
(tsubst_expr): Restore previous location.
(tsubst_copy_and_build): Set and restore location.
* call.c (build_new_method_call_1): Remember location of call.
* semantics.c (finish_call_expr): Here too.
* parser.c (cp_parser_omp_for_loop): Remember the location of the
increment expression.
* pt.c (resolve_overloaded_unification): Use coerce_template_parms * pt.c (resolve_overloaded_unification): Use coerce_template_parms
instead of get_bindings. instead of get_bindings.
(resolve_nondeduced_context): Likewise. (resolve_nondeduced_context): Likewise.
......
...@@ -7537,6 +7537,7 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args, ...@@ -7537,6 +7537,7 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args,
build_min (COMPONENT_REF, TREE_TYPE (CALL_EXPR_FN (call)), build_min (COMPONENT_REF, TREE_TYPE (CALL_EXPR_FN (call)),
orig_instance, orig_fns, NULL_TREE), orig_instance, orig_fns, NULL_TREE),
orig_args)); orig_args));
SET_EXPR_LOCATION (call, input_location);
call = convert_from_reference (call); call = convert_from_reference (call);
if (cast_to_void) if (cast_to_void)
call = build_nop (void_type_node, call); call = build_nop (void_type_node, call);
......
...@@ -26603,6 +26603,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -26603,6 +26603,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
incr = cp_parser_omp_for_incr (parser, real_decl); incr = cp_parser_omp_for_incr (parser, real_decl);
else else
incr = cp_parser_expression (parser, false, NULL); incr = cp_parser_expression (parser, false, NULL);
if (CAN_HAVE_LOCATION_P (incr) && !EXPR_HAS_LOCATION (incr))
SET_EXPR_LOCATION (incr, input_location);
} }
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
......
...@@ -9609,6 +9609,7 @@ tsubst_default_argument (tree fn, tree type, tree arg) ...@@ -9609,6 +9609,7 @@ tsubst_default_argument (tree fn, tree type, tree arg)
{ {
tree saved_class_ptr = NULL_TREE; tree saved_class_ptr = NULL_TREE;
tree saved_class_ref = NULL_TREE; tree saved_class_ref = NULL_TREE;
int errs = errorcount + sorrycount;
/* This can happen in invalid code. */ /* This can happen in invalid code. */
if (TREE_CODE (arg) == DEFAULT_ARG) if (TREE_CODE (arg) == DEFAULT_ARG)
...@@ -9656,6 +9657,10 @@ tsubst_default_argument (tree fn, tree type, tree arg) ...@@ -9656,6 +9657,10 @@ tsubst_default_argument (tree fn, tree type, tree arg)
cp_function_chain->x_current_class_ref = saved_class_ref; cp_function_chain->x_current_class_ref = saved_class_ref;
} }
if (errorcount+sorrycount > errs)
inform (input_location,
" when instantiating default argument for call to %D", fn);
/* Make sure the default argument is reasonable. */ /* Make sure the default argument is reasonable. */
arg = check_default_argument (type, arg); arg = check_default_argument (type, arg);
...@@ -12496,15 +12501,19 @@ static tree ...@@ -12496,15 +12501,19 @@ static tree
tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
bool integral_constant_expression_p) bool integral_constant_expression_p)
{ {
#define RETURN(EXP) do { r = (EXP); goto out; } while(0)
#define RECUR(NODE) \ #define RECUR(NODE) \
tsubst_expr ((NODE), args, complain, in_decl, \ tsubst_expr ((NODE), args, complain, in_decl, \
integral_constant_expression_p) integral_constant_expression_p)
tree stmt, tmp; tree stmt, tmp;
tree r;
location_t loc;
if (t == NULL_TREE || t == error_mark_node) if (t == NULL_TREE || t == error_mark_node)
return t; return t;
loc = input_location;
if (EXPR_HAS_LOCATION (t)) if (EXPR_HAS_LOCATION (t))
input_location = EXPR_LOCATION (t); input_location = EXPR_LOCATION (t);
if (STATEMENT_CODE_P (TREE_CODE (t))) if (STATEMENT_CODE_P (TREE_CODE (t)))
...@@ -13016,42 +13025,46 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, ...@@ -13016,42 +13025,46 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
stmt = build_transaction_expr (EXPR_LOCATION (t), stmt = build_transaction_expr (EXPR_LOCATION (t),
RECUR (TRANSACTION_EXPR_BODY (t)), RECUR (TRANSACTION_EXPR_BODY (t)),
flags, NULL_TREE); flags, NULL_TREE);
return stmt; RETURN (stmt);
} }
} }
break; break;
case MUST_NOT_THROW_EXPR: case MUST_NOT_THROW_EXPR:
return build_must_not_throw_expr (RECUR (TREE_OPERAND (t, 0)), RETURN (build_must_not_throw_expr (RECUR (TREE_OPERAND (t, 0)),
RECUR (MUST_NOT_THROW_COND (t))); RECUR (MUST_NOT_THROW_COND (t))));
case EXPR_PACK_EXPANSION: case EXPR_PACK_EXPANSION:
error ("invalid use of pack expansion expression"); error ("invalid use of pack expansion expression");
return error_mark_node; RETURN (error_mark_node);
case NONTYPE_ARGUMENT_PACK: case NONTYPE_ARGUMENT_PACK:
error ("use %<...%> to expand argument pack"); error ("use %<...%> to expand argument pack");
return error_mark_node; RETURN (error_mark_node);
case COMPOUND_EXPR: case COMPOUND_EXPR:
tmp = RECUR (TREE_OPERAND (t, 0)); tmp = RECUR (TREE_OPERAND (t, 0));
if (tmp == NULL_TREE) if (tmp == NULL_TREE)
/* If the first operand was a statement, we're done with it. */ /* If the first operand was a statement, we're done with it. */
return RECUR (TREE_OPERAND (t, 1)); RETURN (RECUR (TREE_OPERAND (t, 1)));
return build_x_compound_expr (EXPR_LOCATION (t), tmp, RETURN (build_x_compound_expr (EXPR_LOCATION (t), tmp,
RECUR (TREE_OPERAND (t, 1)), RECUR (TREE_OPERAND (t, 1)),
complain); complain));
default: default:
gcc_assert (!STATEMENT_CODE_P (TREE_CODE (t))); gcc_assert (!STATEMENT_CODE_P (TREE_CODE (t)));
return tsubst_copy_and_build (t, args, complain, in_decl, RETURN (tsubst_copy_and_build (t, args, complain, in_decl,
/*function_p=*/false, /*function_p=*/false,
integral_constant_expression_p); integral_constant_expression_p));
} }
return NULL_TREE; RETURN (NULL_TREE);
out:
input_location = loc;
return r;
#undef RECUR #undef RECUR
#undef RETURN
} }
/* T is a postfix-expression that is not being used in a function /* T is a postfix-expression that is not being used in a function
...@@ -13084,16 +13097,22 @@ tsubst_copy_and_build (tree t, ...@@ -13084,16 +13097,22 @@ tsubst_copy_and_build (tree t,
bool function_p, bool function_p,
bool integral_constant_expression_p) bool integral_constant_expression_p)
{ {
#define RETURN(EXP) do { retval = (EXP); goto out; } while(0)
#define RECUR(NODE) \ #define RECUR(NODE) \
tsubst_copy_and_build (NODE, args, complain, in_decl, \ tsubst_copy_and_build (NODE, args, complain, in_decl, \
/*function_p=*/false, \ /*function_p=*/false, \
integral_constant_expression_p) integral_constant_expression_p)
tree op1; tree retval, op1;
location_t loc;
if (t == NULL_TREE || t == error_mark_node) if (t == NULL_TREE || t == error_mark_node)
return t; return t;
loc = input_location;
if (EXPR_HAS_LOCATION (t))
input_location = EXPR_LOCATION (t);
switch (TREE_CODE (t)) switch (TREE_CODE (t))
{ {
case USING_DECL: case USING_DECL:
...@@ -13139,7 +13158,7 @@ tsubst_copy_and_build (tree t, ...@@ -13139,7 +13158,7 @@ tsubst_copy_and_build (tree t,
unqualified_name_lookup_error (decl); unqualified_name_lookup_error (decl);
decl = error_mark_node; decl = error_mark_node;
} }
return decl; RETURN (decl);
} }
case TEMPLATE_ID_EXPR: case TEMPLATE_ID_EXPR:
...@@ -13161,10 +13180,10 @@ tsubst_copy_and_build (tree t, ...@@ -13161,10 +13180,10 @@ tsubst_copy_and_build (tree t,
templ = lookup_template_function (templ, targs); templ = lookup_template_function (templ, targs);
if (object) if (object)
return build3 (COMPONENT_REF, TREE_TYPE (templ), RETURN (build3 (COMPONENT_REF, TREE_TYPE (templ),
object, templ, NULL_TREE); object, templ, NULL_TREE));
else else
return baselink_for_fns (templ); RETURN (baselink_for_fns (templ));
} }
case INDIRECT_REF: case INDIRECT_REF:
...@@ -13181,13 +13200,13 @@ tsubst_copy_and_build (tree t, ...@@ -13181,13 +13200,13 @@ tsubst_copy_and_build (tree t,
} }
else else
r = build_x_indirect_ref (input_location, r, RO_UNARY_STAR, complain); r = build_x_indirect_ref (input_location, r, RO_UNARY_STAR, complain);
return r; RETURN (r);
} }
case NOP_EXPR: case NOP_EXPR:
return build_nop RETURN (build_nop
(tsubst (TREE_TYPE (t), args, complain, in_decl), (tsubst (TREE_TYPE (t), args, complain, in_decl),
RECUR (TREE_OPERAND (t, 0))); RECUR (TREE_OPERAND (t, 0))));
case IMPLICIT_CONV_EXPR: case IMPLICIT_CONV_EXPR:
{ {
...@@ -13196,15 +13215,15 @@ tsubst_copy_and_build (tree t, ...@@ -13196,15 +13215,15 @@ tsubst_copy_and_build (tree t,
int flags = LOOKUP_IMPLICIT; int flags = LOOKUP_IMPLICIT;
if (IMPLICIT_CONV_EXPR_DIRECT_INIT (t)) if (IMPLICIT_CONV_EXPR_DIRECT_INIT (t))
flags = LOOKUP_NORMAL; flags = LOOKUP_NORMAL;
return perform_implicit_conversion_flags (type, expr, complain, RETURN (perform_implicit_conversion_flags (type, expr, complain,
flags); flags));
} }
case CONVERT_EXPR: case CONVERT_EXPR:
return build1 RETURN (build1
(CONVERT_EXPR, (CONVERT_EXPR,
tsubst (TREE_TYPE (t), args, complain, in_decl), tsubst (TREE_TYPE (t), args, complain, in_decl),
RECUR (TREE_OPERAND (t, 0))); RECUR (TREE_OPERAND (t, 0))));
case CAST_EXPR: case CAST_EXPR:
case REINTERPRET_CAST_EXPR: case REINTERPRET_CAST_EXPR:
...@@ -13222,7 +13241,7 @@ tsubst_copy_and_build (tree t, ...@@ -13222,7 +13241,7 @@ tsubst_copy_and_build (tree t,
if (complain & tf_error) if (complain & tf_error)
error ("a cast to a type other than an integral or " error ("a cast to a type other than an integral or "
"enumeration type cannot appear in a constant-expression"); "enumeration type cannot appear in a constant-expression");
return error_mark_node; RETURN (error_mark_node);
} }
op = RECUR (TREE_OPERAND (t, 0)); op = RECUR (TREE_OPERAND (t, 0));
...@@ -13250,14 +13269,14 @@ tsubst_copy_and_build (tree t, ...@@ -13250,14 +13269,14 @@ tsubst_copy_and_build (tree t,
} }
--c_inhibit_evaluation_warnings; --c_inhibit_evaluation_warnings;
return r; RETURN (r);
} }
case POSTDECREMENT_EXPR: case POSTDECREMENT_EXPR:
case POSTINCREMENT_EXPR: case POSTINCREMENT_EXPR:
op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0), op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
args, complain, in_decl); args, complain, in_decl);
return build_x_unary_op (input_location, TREE_CODE (t), op1, complain); RETURN (build_x_unary_op (input_location, TREE_CODE (t), op1, complain));
case PREDECREMENT_EXPR: case PREDECREMENT_EXPR:
case PREINCREMENT_EXPR: case PREINCREMENT_EXPR:
...@@ -13268,25 +13287,25 @@ tsubst_copy_and_build (tree t, ...@@ -13268,25 +13287,25 @@ tsubst_copy_and_build (tree t,
case UNARY_PLUS_EXPR: /* Unary + */ case UNARY_PLUS_EXPR: /* Unary + */
case REALPART_EXPR: case REALPART_EXPR:
case IMAGPART_EXPR: case IMAGPART_EXPR:
return build_x_unary_op (input_location, TREE_CODE (t), RETURN (build_x_unary_op (input_location, TREE_CODE (t),
RECUR (TREE_OPERAND (t, 0)), complain); RECUR (TREE_OPERAND (t, 0)), complain));
case FIX_TRUNC_EXPR: case FIX_TRUNC_EXPR:
return cp_build_unary_op (FIX_TRUNC_EXPR, RECUR (TREE_OPERAND (t, 0)), RETURN (cp_build_unary_op (FIX_TRUNC_EXPR, RECUR (TREE_OPERAND (t, 0)),
0, complain); 0, complain));
case ADDR_EXPR: case ADDR_EXPR:
op1 = TREE_OPERAND (t, 0); op1 = TREE_OPERAND (t, 0);
if (TREE_CODE (op1) == LABEL_DECL) if (TREE_CODE (op1) == LABEL_DECL)
return finish_label_address_expr (DECL_NAME (op1), RETURN (finish_label_address_expr (DECL_NAME (op1),
EXPR_LOCATION (op1)); EXPR_LOCATION (op1)));
if (TREE_CODE (op1) == SCOPE_REF) if (TREE_CODE (op1) == SCOPE_REF)
op1 = tsubst_qualified_id (op1, args, complain, in_decl, op1 = tsubst_qualified_id (op1, args, complain, in_decl,
/*done=*/true, /*address_p=*/true); /*done=*/true, /*address_p=*/true);
else else
op1 = tsubst_non_call_postfix_expression (op1, args, complain, op1 = tsubst_non_call_postfix_expression (op1, args, complain,
in_decl); in_decl);
return build_x_unary_op (input_location, ADDR_EXPR, op1, complain); RETURN (build_x_unary_op (input_location, ADDR_EXPR, op1, complain));
case PLUS_EXPR: case PLUS_EXPR:
case MINUS_EXPR: case MINUS_EXPR:
...@@ -13341,21 +13360,21 @@ tsubst_copy_and_build (tree t, ...@@ -13341,21 +13360,21 @@ tsubst_copy_and_build (tree t,
--c_inhibit_evaluation_warnings; --c_inhibit_evaluation_warnings;
return r; RETURN (r);
} }
case SCOPE_REF: case SCOPE_REF:
return tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true, RETURN (tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true,
/*address_p=*/false); /*address_p=*/false));
case ARRAY_REF: case ARRAY_REF:
op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0), op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
args, complain, in_decl); args, complain, in_decl);
return build_x_array_ref (EXPR_LOCATION (t), op1, RETURN (build_x_array_ref (EXPR_LOCATION (t), op1,
RECUR (TREE_OPERAND (t, 1)), complain); RECUR (TREE_OPERAND (t, 1)), complain));
case SIZEOF_EXPR: case SIZEOF_EXPR:
if (PACK_EXPANSION_P (TREE_OPERAND (t, 0))) if (PACK_EXPANSION_P (TREE_OPERAND (t, 0)))
return tsubst_copy (t, args, complain, in_decl); RETURN (tsubst_copy (t, args, complain, in_decl));
/* Fall through */ /* Fall through */
case ALIGNOF_EXPR: case ALIGNOF_EXPR:
...@@ -13379,11 +13398,11 @@ tsubst_copy_and_build (tree t, ...@@ -13379,11 +13398,11 @@ tsubst_copy_and_build (tree t,
--c_inhibit_evaluation_warnings; --c_inhibit_evaluation_warnings;
} }
if (TYPE_P (op1)) if (TYPE_P (op1))
return cxx_sizeof_or_alignof_type (op1, TREE_CODE (t), RETURN (cxx_sizeof_or_alignof_type (op1, TREE_CODE (t),
complain & tf_error); complain & tf_error));
else else
return cxx_sizeof_or_alignof_expr (op1, TREE_CODE (t), RETURN (cxx_sizeof_or_alignof_expr (op1, TREE_CODE (t),
complain & tf_error); complain & tf_error));
case AT_ENCODE_EXPR: case AT_ENCODE_EXPR:
{ {
...@@ -13395,7 +13414,7 @@ tsubst_copy_and_build (tree t, ...@@ -13395,7 +13414,7 @@ tsubst_copy_and_build (tree t,
/*integral_constant_expression_p=*/false); /*integral_constant_expression_p=*/false);
--cp_unevaluated_operand; --cp_unevaluated_operand;
--c_inhibit_evaluation_warnings; --c_inhibit_evaluation_warnings;
return objc_build_encode_expr (op1); RETURN (objc_build_encode_expr (op1));
} }
case NOEXCEPT_EXPR: case NOEXCEPT_EXPR:
...@@ -13407,7 +13426,7 @@ tsubst_copy_and_build (tree t, ...@@ -13407,7 +13426,7 @@ tsubst_copy_and_build (tree t,
/*integral_constant_expression_p=*/false); /*integral_constant_expression_p=*/false);
--cp_unevaluated_operand; --cp_unevaluated_operand;
--c_inhibit_evaluation_warnings; --c_inhibit_evaluation_warnings;
return finish_noexcept_expr (op1, complain); RETURN (finish_noexcept_expr (op1, complain));
case MODOP_EXPR: case MODOP_EXPR:
{ {
...@@ -13425,7 +13444,7 @@ tsubst_copy_and_build (tree t, ...@@ -13425,7 +13444,7 @@ tsubst_copy_and_build (tree t,
here. */ here. */
if (TREE_NO_WARNING (t)) if (TREE_NO_WARNING (t))
TREE_NO_WARNING (r) = TREE_NO_WARNING (t); TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
return r; RETURN (r);
} }
case ARROW_EXPR: case ARROW_EXPR:
...@@ -13434,7 +13453,7 @@ tsubst_copy_and_build (tree t, ...@@ -13434,7 +13453,7 @@ tsubst_copy_and_build (tree t,
/* Remember that there was a reference to this entity. */ /* Remember that there was a reference to this entity. */
if (DECL_P (op1)) if (DECL_P (op1))
mark_used (op1); mark_used (op1);
return build_x_arrow (input_location, op1, complain); RETURN (build_x_arrow (input_location, op1, complain));
case NEW_EXPR: case NEW_EXPR:
{ {
...@@ -13485,22 +13504,22 @@ tsubst_copy_and_build (tree t, ...@@ -13485,22 +13504,22 @@ tsubst_copy_and_build (tree t,
if (init_vec != NULL) if (init_vec != NULL)
release_tree_vector (init_vec); release_tree_vector (init_vec);
return ret; RETURN (ret);
} }
case DELETE_EXPR: case DELETE_EXPR:
return delete_sanity RETURN (delete_sanity
(RECUR (TREE_OPERAND (t, 0)), (RECUR (TREE_OPERAND (t, 0)),
RECUR (TREE_OPERAND (t, 1)), RECUR (TREE_OPERAND (t, 1)),
DELETE_EXPR_USE_VEC (t), DELETE_EXPR_USE_VEC (t),
DELETE_EXPR_USE_GLOBAL (t), DELETE_EXPR_USE_GLOBAL (t),
complain); complain));
case COMPOUND_EXPR: case COMPOUND_EXPR:
return build_x_compound_expr (EXPR_LOCATION (t), RETURN (build_x_compound_expr (EXPR_LOCATION (t),
RECUR (TREE_OPERAND (t, 0)), RECUR (TREE_OPERAND (t, 0)),
RECUR (TREE_OPERAND (t, 1)), RECUR (TREE_OPERAND (t, 1)),
complain); complain));
case CALL_EXPR: case CALL_EXPR:
{ {
...@@ -13622,7 +13641,7 @@ tsubst_copy_and_build (tree t, ...@@ -13622,7 +13641,7 @@ tsubst_copy_and_build (tree t,
(function, args, complain, in_decl, true, (function, args, complain, in_decl, true,
integral_constant_expression_p)); integral_constant_expression_p));
if (unq == error_mark_node) if (unq == error_mark_node)
return error_mark_node; RETURN (error_mark_node);
if (unq != function) if (unq != function)
{ {
...@@ -13664,7 +13683,7 @@ tsubst_copy_and_build (tree t, ...@@ -13664,7 +13683,7 @@ tsubst_copy_and_build (tree t,
{ {
unqualified_name_lookup_error (function); unqualified_name_lookup_error (function);
release_tree_vector (call_args); release_tree_vector (call_args);
return error_mark_node; RETURN (error_mark_node);
} }
} }
...@@ -13707,7 +13726,7 @@ tsubst_copy_and_build (tree t, ...@@ -13707,7 +13726,7 @@ tsubst_copy_and_build (tree t,
release_tree_vector (call_args); release_tree_vector (call_args);
return ret; RETURN (ret);
} }
case COND_EXPR: case COND_EXPR:
...@@ -13738,22 +13757,22 @@ tsubst_copy_and_build (tree t, ...@@ -13738,22 +13757,22 @@ tsubst_copy_and_build (tree t,
exp2 = RECUR (TREE_OPERAND (t, 2)); exp2 = RECUR (TREE_OPERAND (t, 2));
} }
return build_x_conditional_expr (EXPR_LOCATION (t), RETURN (build_x_conditional_expr (EXPR_LOCATION (t),
cond, exp1, exp2, complain); cond, exp1, exp2, complain));
} }
case PSEUDO_DTOR_EXPR: case PSEUDO_DTOR_EXPR:
return finish_pseudo_destructor_expr RETURN (finish_pseudo_destructor_expr
(RECUR (TREE_OPERAND (t, 0)), (RECUR (TREE_OPERAND (t, 0)),
RECUR (TREE_OPERAND (t, 1)), RECUR (TREE_OPERAND (t, 1)),
tsubst (TREE_OPERAND (t, 2), args, complain, in_decl)); tsubst (TREE_OPERAND (t, 2), args, complain, in_decl)));
case TREE_LIST: case TREE_LIST:
{ {
tree purpose, value, chain; tree purpose, value, chain;
if (t == void_list_node) if (t == void_list_node)
return t; RETURN (t);
if ((TREE_PURPOSE (t) && PACK_EXPANSION_P (TREE_PURPOSE (t))) if ((TREE_PURPOSE (t) && PACK_EXPANSION_P (TREE_PURPOSE (t)))
|| (TREE_VALUE (t) && PACK_EXPANSION_P (TREE_VALUE (t)))) || (TREE_VALUE (t) && PACK_EXPANSION_P (TREE_VALUE (t))))
...@@ -13789,14 +13808,14 @@ tsubst_copy_and_build (tree t, ...@@ -13789,14 +13808,14 @@ tsubst_copy_and_build (tree t,
else else
{ {
/* Since we only performed a partial substitution into /* Since we only performed a partial substitution into
the argument pack, we only return a single list the argument pack, we only RETURN (a single list
node. */ node. */
if (purposevec == TREE_PURPOSE (t) if (purposevec == TREE_PURPOSE (t)
&& valuevec == TREE_VALUE (t) && valuevec == TREE_VALUE (t)
&& chain == TREE_CHAIN (t)) && chain == TREE_CHAIN (t))
return t; RETURN (t);
return tree_cons (purposevec, valuevec, chain); RETURN (tree_cons (purposevec, valuevec, chain));
} }
/* Convert the argument vectors into a TREE_LIST */ /* Convert the argument vectors into a TREE_LIST */
...@@ -13815,7 +13834,7 @@ tsubst_copy_and_build (tree t, ...@@ -13815,7 +13834,7 @@ tsubst_copy_and_build (tree t,
chain = tree_cons (purpose, value, chain); chain = tree_cons (purpose, value, chain);
} }
return chain; RETURN (chain);
} }
purpose = TREE_PURPOSE (t); purpose = TREE_PURPOSE (t);
...@@ -13830,8 +13849,8 @@ tsubst_copy_and_build (tree t, ...@@ -13830,8 +13849,8 @@ tsubst_copy_and_build (tree t,
if (purpose == TREE_PURPOSE (t) if (purpose == TREE_PURPOSE (t)
&& value == TREE_VALUE (t) && value == TREE_VALUE (t)
&& chain == TREE_CHAIN (t)) && chain == TREE_CHAIN (t))
return t; RETURN (t);
return tree_cons (purpose, value, chain); RETURN (tree_cons (purpose, value, chain));
} }
case COMPONENT_REF: case COMPONENT_REF:
...@@ -13855,7 +13874,7 @@ tsubst_copy_and_build (tree t, ...@@ -13855,7 +13874,7 @@ tsubst_copy_and_build (tree t,
else else
member = tsubst_copy (member, args, complain, in_decl); member = tsubst_copy (member, args, complain, in_decl);
if (member == error_mark_node) if (member == error_mark_node)
return error_mark_node; RETURN (error_mark_node);
if (type_dependent_expression_p (object)) if (type_dependent_expression_p (object))
/* We can't do much here. */; /* We can't do much here. */;
...@@ -13875,7 +13894,7 @@ tsubst_copy_and_build (tree t, ...@@ -13875,7 +13894,7 @@ tsubst_copy_and_build (tree t,
{ {
dtor = TREE_OPERAND (dtor, 0); dtor = TREE_OPERAND (dtor, 0);
if (TYPE_P (dtor)) if (TYPE_P (dtor))
return finish_pseudo_destructor_expr (object, s, dtor); RETURN (finish_pseudo_destructor_expr (object, s, dtor));
} }
} }
} }
...@@ -13903,7 +13922,7 @@ tsubst_copy_and_build (tree t, ...@@ -13903,7 +13922,7 @@ tsubst_copy_and_build (tree t,
{ {
qualified_name_lookup_error (scope, tmpl, member, qualified_name_lookup_error (scope, tmpl, member,
input_location); input_location);
return error_mark_node; RETURN (error_mark_node);
} }
} }
else if (TREE_CODE (member) == SCOPE_REF else if (TREE_CODE (member) == SCOPE_REF
...@@ -13919,19 +13938,19 @@ tsubst_copy_and_build (tree t, ...@@ -13919,19 +13938,19 @@ tsubst_copy_and_build (tree t,
error ("%qD is not a class or namespace", error ("%qD is not a class or namespace",
TREE_OPERAND (member, 0)); TREE_OPERAND (member, 0));
} }
return error_mark_node; RETURN (error_mark_node);
} }
else if (TREE_CODE (member) == FIELD_DECL) else if (TREE_CODE (member) == FIELD_DECL)
return finish_non_static_data_member (member, object, NULL_TREE); RETURN (finish_non_static_data_member (member, object, NULL_TREE));
return finish_class_member_access_expr (object, member, RETURN (finish_class_member_access_expr (object, member,
/*template_p=*/false, /*template_p=*/false,
complain); complain));
} }
case THROW_EXPR: case THROW_EXPR:
return build_throw RETURN (build_throw
(RECUR (TREE_OPERAND (t, 0))); (RECUR (TREE_OPERAND (t, 0))));
case CONSTRUCTOR: case CONSTRUCTOR:
{ {
...@@ -13945,11 +13964,11 @@ tsubst_copy_and_build (tree t, ...@@ -13945,11 +13964,11 @@ tsubst_copy_and_build (tree t,
tree r; tree r;
if (type == error_mark_node) if (type == error_mark_node)
return error_mark_node; RETURN (error_mark_node);
/* digest_init will do the wrong thing if we let it. */ /* digest_init will do the wrong thing if we let it. */
if (type && TYPE_PTRMEMFUNC_P (type)) if (type && TYPE_PTRMEMFUNC_P (type))
return t; RETURN (t);
/* We do not want to process the index of aggregate /* We do not want to process the index of aggregate
initializers as they are identifier nodes which will be initializers as they are identifier nodes which will be
...@@ -14011,10 +14030,10 @@ tsubst_copy_and_build (tree t, ...@@ -14011,10 +14030,10 @@ tsubst_copy_and_build (tree t,
CONSTRUCTOR_IS_DIRECT_INIT (r) = CONSTRUCTOR_IS_DIRECT_INIT (t); CONSTRUCTOR_IS_DIRECT_INIT (r) = CONSTRUCTOR_IS_DIRECT_INIT (t);
if (TREE_HAS_CONSTRUCTOR (t)) if (TREE_HAS_CONSTRUCTOR (t))
return finish_compound_literal (type, r, complain); RETURN (finish_compound_literal (type, r, complain));
TREE_TYPE (r) = type; TREE_TYPE (r) = type;
return r; RETURN (r);
} }
case TYPEID_EXPR: case TYPEID_EXPR:
...@@ -14023,18 +14042,18 @@ tsubst_copy_and_build (tree t, ...@@ -14023,18 +14042,18 @@ tsubst_copy_and_build (tree t,
if (TYPE_P (operand_0)) if (TYPE_P (operand_0))
{ {
operand_0 = tsubst (operand_0, args, complain, in_decl); operand_0 = tsubst (operand_0, args, complain, in_decl);
return get_typeid (operand_0); RETURN (get_typeid (operand_0));
} }
else else
{ {
operand_0 = RECUR (operand_0); operand_0 = RECUR (operand_0);
return build_typeid (operand_0); RETURN (build_typeid (operand_0));
} }
} }
case VAR_DECL: case VAR_DECL:
if (!args) if (!args)
return t; RETURN (t);
/* Fall through */ /* Fall through */
case PARM_DECL: case PARM_DECL:
...@@ -14045,16 +14064,16 @@ tsubst_copy_and_build (tree t, ...@@ -14045,16 +14064,16 @@ tsubst_copy_and_build (tree t,
/* If the original type was a reference, we'll be wrapped in /* If the original type was a reference, we'll be wrapped in
the appropriate INDIRECT_REF. */ the appropriate INDIRECT_REF. */
r = convert_from_reference (r); r = convert_from_reference (r);
return r; RETURN (r);
} }
case VA_ARG_EXPR: case VA_ARG_EXPR:
return build_x_va_arg (EXPR_LOCATION (t), RETURN (build_x_va_arg (EXPR_LOCATION (t),
RECUR (TREE_OPERAND (t, 0)), RECUR (TREE_OPERAND (t, 0)),
tsubst (TREE_TYPE (t), args, complain, in_decl)); tsubst (TREE_TYPE (t), args, complain, in_decl)));
case OFFSETOF_EXPR: case OFFSETOF_EXPR:
return finish_offsetof (RECUR (TREE_OPERAND (t, 0))); RETURN (finish_offsetof (RECUR (TREE_OPERAND (t, 0))));
case TRAIT_EXPR: case TRAIT_EXPR:
{ {
...@@ -14065,7 +14084,7 @@ tsubst_copy_and_build (tree t, ...@@ -14065,7 +14084,7 @@ tsubst_copy_and_build (tree t,
if (type2) if (type2)
type2 = tsubst_copy (type2, args, complain, in_decl); type2 = tsubst_copy (type2, args, complain, in_decl);
return finish_trait_expr (TRAIT_EXPR_KIND (t), type1, type2); RETURN (finish_trait_expr (TRAIT_EXPR_KIND (t), type1, type2));
} }
case STMT_EXPR: case STMT_EXPR:
...@@ -14084,7 +14103,7 @@ tsubst_copy_and_build (tree t, ...@@ -14084,7 +14103,7 @@ tsubst_copy_and_build (tree t,
if (empty_expr_stmt_p (stmt_expr)) if (empty_expr_stmt_p (stmt_expr))
stmt_expr = void_zero_node; stmt_expr = void_zero_node;
return stmt_expr; RETURN (stmt_expr);
} }
case LAMBDA_EXPR: case LAMBDA_EXPR:
...@@ -14121,7 +14140,7 @@ tsubst_copy_and_build (tree t, ...@@ -14121,7 +14140,7 @@ tsubst_copy_and_build (tree t,
LAMBDA_EXPR_CAPTURE_LIST (r) LAMBDA_EXPR_CAPTURE_LIST (r)
= RECUR (LAMBDA_EXPR_CAPTURE_LIST (t)); = RECUR (LAMBDA_EXPR_CAPTURE_LIST (t));
return build_lambda_object (r); RETURN (build_lambda_object (r));
} }
case TARGET_EXPR: case TARGET_EXPR:
...@@ -14131,12 +14150,12 @@ tsubst_copy_and_build (tree t, ...@@ -14131,12 +14150,12 @@ tsubst_copy_and_build (tree t,
{ {
tree r = get_target_expr (RECUR (TARGET_EXPR_INITIAL (t))); tree r = get_target_expr (RECUR (TARGET_EXPR_INITIAL (t)));
TREE_CONSTANT (r) = true; TREE_CONSTANT (r) = true;
return r; RETURN (r);
} }
case TRANSACTION_EXPR: case TRANSACTION_EXPR:
return tsubst_expr(t, args, complain, in_decl, RETURN (tsubst_expr(t, args, complain, in_decl,
integral_constant_expression_p); integral_constant_expression_p));
default: default:
/* Handle Objective-C++ constructs, if appropriate. */ /* Handle Objective-C++ constructs, if appropriate. */
...@@ -14145,12 +14164,16 @@ tsubst_copy_and_build (tree t, ...@@ -14145,12 +14164,16 @@ tsubst_copy_and_build (tree t,
= objcp_tsubst_copy_and_build (t, args, complain, = objcp_tsubst_copy_and_build (t, args, complain,
in_decl, /*function_p=*/false); in_decl, /*function_p=*/false);
if (subst) if (subst)
return subst; RETURN (subst);
} }
return tsubst_copy (t, args, complain, in_decl); RETURN (tsubst_copy (t, args, complain, in_decl));
} }
#undef RECUR #undef RECUR
#undef RETURN
out:
input_location = loc;
return retval;
} }
/* Verify that the instantiated ARGS are valid. For type arguments, /* Verify that the instantiated ARGS are valid. For type arguments,
......
...@@ -2062,6 +2062,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, ...@@ -2062,6 +2062,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
&& type_dependent_expression_p (current_class_ref))) && type_dependent_expression_p (current_class_ref)))
{ {
result = build_nt_call_vec (fn, *args); result = build_nt_call_vec (fn, *args);
SET_EXPR_LOCATION (result, EXPR_LOC_OR_HERE (fn));
KOENIG_LOOKUP_P (result) = koenig_p; KOENIG_LOOKUP_P (result) = koenig_p;
if (cfun) if (cfun)
{ {
......
...@@ -8,8 +8,8 @@ template <class F, int N> ...@@ -8,8 +8,8 @@ template <class F, int N>
void ft (F f, typename enable_if<N!=0, int>::type) {} void ft (F f, typename enable_if<N!=0, int>::type) {}
template< class F, int N > template< class F, int N >
decltype(ft<F, N-1> (F(), 0)) decltype(ft<F, N-1> (F(), 0)) // { dg-error "depth" }
ft (F f, typename enable_if<N==0, int>::type) {} // { dg-error "depth" } ft (F f, typename enable_if<N==0, int>::type) {}
int main() { int main() {
ft<struct a*, 2> (0, 0); // { dg-message "from here" } ft<struct a*, 2> (0, 0); // { dg-message "from here" }
......
...@@ -9,8 +9,8 @@ typename enable_if<x==0,int>::type ...@@ -9,8 +9,8 @@ typename enable_if<x==0,int>::type
ft() {} ft() {}
template<class F, int N> template<class F, int N>
decltype (ft<F> (F())) decltype (ft<F> (F())) // { dg-error "depth" }
ft() {} // { dg-error "depth" } ft() {}
int main() { int main() {
ft<struct a*, 0>(); // { dg-error "no match|wrong number" } ft<struct a*, 0>(); // { dg-error "no match|wrong number" }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// { dg-options -std=c++0x } // { dg-options -std=c++0x }
template <typename T> template <typename T>
auto make_array(const T& il) -> // { dg-error "not declared" } auto make_array(const T& il) ->
decltype(make_array(il)) decltype(make_array(il)) // { dg-error "not declared" }
{ } { }
int main() int main()
......
...@@ -24,3 +24,5 @@ int main() ...@@ -24,3 +24,5 @@ int main()
{ {
g({1}); // { dg-warning "deduc" } g({1}); // { dg-warning "deduc" }
} }
// { dg-prune-output "-fno-deduce-init-list" }
...@@ -10,15 +10,15 @@ template <class T> decltype(g1(T())) f1() ...@@ -10,15 +10,15 @@ template <class T> decltype(g1(T())) f1()
{ return g1(T()); } { return g1(T()); }
int i1 = f1<int>(); // OK, g1(int) was declared before the first f1 int i1 = f1<int>(); // OK, g1(int) was declared before the first f1
template <class T> decltype(g2(T())) f2(); template <class T> decltype(g2(T())) f2(); // { dg-error "g2. was not declared" }
int g2(int); int g2(int);
template <class T> decltype(g2(T())) f2() // { dg-error "g2. was not declared" } template <class T> decltype(g2(T())) f2()
{ return g2(T()); } { return g2(T()); }
int i2 = f2<int>(); // { dg-error "no match" } int i2 = f2<int>(); // { dg-error "no match" }
int g3(); int g3();
template <class T> decltype(g3(T())) f3(); template <class T> decltype(g3(T())) f3(); // { dg-error "too many arguments" }
int g3(int); int g3(int);
template <class T> decltype(g3(T())) f3() // { dg-error "too many arguments" } template <class T> decltype(g3(T())) f3()
{ return g3(T()); } { return g3(T()); }
int i3 = f3<int>(); // { dg-error "no match" } int i3 = f3<int>(); // { dg-error "no match" }
...@@ -19,8 +19,8 @@ struct Bind ...@@ -19,8 +19,8 @@ struct Bind
R f(); R f();
template<typename R template<typename R
= decltype( val<const F>()( ) )> = decltype( val<const F>()( ) )> // { dg-error "no match" }
R f() const; // { dg-error "no match" } R f() const;
}; };
int main() int main()
......
...@@ -8,7 +8,7 @@ template <typename T> ...@@ -8,7 +8,7 @@ template <typename T>
void void
f1 (void) f1 (void)
{ {
#pragma omp for // { dg-error "forbids incrementing a pointer of type" } #pragma omp for
for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" } for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" }
; ;
} }
......
// PR c++/5247 // PR c++/5247
template<typename T> template<typename T>
int foo (T t, int = foo(T())); int foo (T t, int = foo(T())); // { dg-error "recursive" }
struct A { }; struct A { };
int main() int main()
{ {
foo(A()); // { dg-error "default argument" } foo(A()); // { dg-message "default argument" }
} }
...@@ -26,7 +26,7 @@ template<bool> struct S { ...@@ -26,7 +26,7 @@ template<bool> struct S {
S(unsigned int = BBB::foo()->AAA::get()); /* { dg-error "is not a base of" } */ S(unsigned int = BBB::foo()->AAA::get()); /* { dg-error "is not a base of" } */
}; };
template<bool> struct SS { template<bool> struct SS {
SS(unsigned int = BBB::foo()->get()); SS(unsigned int = BBB::foo()->get()); /* { dg-error "within this context" } */
}; };
void bar() void bar()
...@@ -38,5 +38,5 @@ void bar() ...@@ -38,5 +38,5 @@ void bar()
i.C::foo<0>(); /* { dg-error "which is of non-class type" } */ i.C::foo<0>(); /* { dg-error "which is of non-class type" } */
S<false> s; /* { dg-error "default argument" } */ S<false> s; /* { dg-error "default argument" } */
SS<false> ss; /* { dg-error "within this context" } */ SS<false> ss;
} }
// PR c++/50861 // PR c++/50861
template<class T> struct A {A(int b=k(0));}; // { dg-error "arguments" } template<class T> struct A {A(int b=k(0));}; // { dg-error "parameter|arguments" }
void f(int k){A<int> a;} // // { dg-error "parameter|declared" } void f(int k){A<int> a;} // // { dg-error "declared" }
// { dg-message "note" "note" { target *-*-* } 3 } // { dg-message "note" "note" { target *-*-* } 3 }
// PR c++/34397 // PR c++/34397
template<typename T, int = T()[0]> struct A // { dg-error "subscripted|template" } template<typename T, int = T()[0]> struct A // { dg-error "subscripted" }
{ {
typedef A<T> B; typedef A<T> B;
}; };
A<int> a; // { dg-error "declaration" } A<int> a; // { dg-error "declaration" }
// { dg-prune-output "template argument 2 is invalid" }
...@@ -30,10 +30,10 @@ void test01() ...@@ -30,10 +30,10 @@ void test01()
{ {
const int dummy = 0; const int dummy = 0;
std::bind(&inc, _1)(0); // { dg-error "no match" } std::bind(&inc, _1)(0); // { dg-error "no match" }
// { dg-error "rvalue|const" "" { target *-*-* } 1206 } // { dg-error "rvalue|const" "" { target *-*-* } 1207 }
// { dg-error "rvalue|const" "" { target *-*-* } 1219 } // { dg-error "rvalue|const" "" { target *-*-* } 1221 }
// { dg-error "rvalue|const" "" { target *-*-* } 1233 } // { dg-error "rvalue|const" "" { target *-*-* } 1235 }
// { dg-error "rvalue|const" "" { target *-*-* } 1247 } // { dg-error "rvalue|const" "" { target *-*-* } 1249 }
std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" } std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" }
} }
......
...@@ -51,5 +51,5 @@ test04() ...@@ -51,5 +51,5 @@ test04()
// { dg-error "required from here" "" { target *-*-* } 46 } // { dg-error "required from here" "" { target *-*-* } 46 }
// { dg-error "denominator cannot be zero" "" { target *-*-* } 265 } // { dg-error "denominator cannot be zero" "" { target *-*-* } 265 }
// { dg-error "out of range" "" { target *-*-* } 266 } // { dg-error "out of range" "" { target *-*-* } 266 }
// { dg-error "overflow in constant expression" "" { target *-*-* } 62 } // { dg-error "overflow in constant expression" "" { target *-*-* } 61 }
// { dg-prune-output "not a member" } // { dg-prune-output "not a member" }
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