2012-04-30 Dodji Seketeli <dodji@redhat.com>
+ Fix va_arg type location
+ * cp-tree.h (build_x_va_arg): Take an additional location
+ parameter.
+ * call.c (build_x_va_arg): Take a loc parameter for the location
+ of the type of the va_arg expression.
+ * parser.c (cp_parser_primary_expression): Pass the type of the
+ type in the va_arg expression to build_x_va_arg.
+ * pt.c (tsubst_copy): Adjust calls to build_x_va_arg.
+
Make conversion warnings work on NULL with -ftrack-macro-expansion
* call.c (conversion_null_warnings): Use the new
expansion_point_location_if_in_system_header.
/* va_arg (EXPR, TYPE) is a builtin. Make sure it is not abused. */
tree
-build_x_va_arg (tree expr, tree type)
+build_x_va_arg (source_location loc, tree expr, tree type)
{
if (processing_template_decl)
return build_min (VA_ARG_EXPR, type, expr);
return expr;
}
- return build_va_arg (input_location, expr, type);
+ return build_va_arg (loc, expr, type);
}
/* TYPE has been given to va_arg. Apply the default conversions which
extern tree convert_default_arg (tree, tree, tree, int,
tsubst_flags_t);
extern tree convert_arg_to_ellipsis (tree, tsubst_flags_t);
-extern tree build_x_va_arg (tree, tree);
+extern tree build_x_va_arg (source_location, tree, tree);
extern tree cxx_type_promotes_to (tree);
extern tree type_passed_as (tree);
extern tree convert_for_arg_passing (tree, tree, tsubst_flags_t);
{
tree expression;
tree type;
+ source_location type_location;
/* The `__builtin_va_arg' construct is used to handle
`va_arg'. Consume the `__builtin_va_arg' token. */
/*cast_p=*/false, NULL);
/* Look for the `,'. */
cp_parser_require (parser, CPP_COMMA, RT_COMMA);
+ type_location = cp_lexer_peek_token (parser->lexer)->location;
/* Parse the type-id. */
type = cp_parser_type_id (parser);
/* Look for the closing `)'. */
if (cp_parser_non_integral_constant_expression (parser,
NIC_VA_ARG))
return error_mark_node;
- return build_x_va_arg (expression, type);
+ return build_x_va_arg (type_location, expression, type);
}
case RID_OFFSETOF:
gcc_unreachable ();
case VA_ARG_EXPR:
- return build_x_va_arg (tsubst_copy (TREE_OPERAND (t, 0), args, complain,
+ return build_x_va_arg (EXPR_LOCATION (t),
+ tsubst_copy (TREE_OPERAND (t, 0), args, complain,
in_decl),
tsubst (TREE_TYPE (t), args, complain, in_decl));
}
case VA_ARG_EXPR:
- return build_x_va_arg (RECUR (TREE_OPERAND (t, 0)),
+ return build_x_va_arg (EXPR_LOCATION (t),
+ RECUR (TREE_OPERAND (t, 0)),
tsubst (TREE_TYPE (t), args, complain, in_decl));
case OFFSETOF_EXPR: