summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-30 11:42:50 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-30 11:42:50 +0000
commit346b240d6c22e13b7a9bbbad566c6c4c9a5199f3 (patch)
tree47c7277c13e9785e5257a0e7d0c6373cf70ffd13 /gcc
parentdb30b35189c3090d0739f86df53e954125cf90b9 (diff)
downloadppe42-gcc-346b240d6c22e13b7a9bbbad566c6c4c9a5199f3.tar.gz
ppe42-gcc-346b240d6c22e13b7a9bbbad566c6c4c9a5199f3.zip
Fix va_arg type location
Now that diagnostics first point to the spelling location of tokens coming from macro expansion, the test case gcc/testsuite/g++.old-deja/g++.other/vaarg3.C shows that when I write va_args (args, some_type), the location that is recorded for "some_type" is not correct. We wrongly record a location that is in the system header where the va_args macro is defined. This patch changes that to correctly record the location for the type operand of the va_arg expression. With this patch applied, the gcc/testsuite/g++.old-deja/g++.other/vaarg3.C test PASSes with and without -ftrack-macro-expansion. Tested on x86_64-unknown-linux-gnu against trunk. Note that the bootstrap with -ftrack-macro-expansion exhibits other separate issues that are addressed in subsequent patches. This patch just fixes one class of problems. The patch does pass bootstrap with -ftrack-macro-expansion turned off, though. gcc/cp/ * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186973 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/call.c4
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/cp/pt.c6
5 files changed, 19 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 67dd067e867..06edc5007b0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,14 @@
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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 98d32c347e1..e072891f927 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -6133,7 +6133,7 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain)
/* 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);
@@ -6159,7 +6159,7 @@ build_x_va_arg (tree expr, tree type)
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
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index e046069182c..5a7ebaed993 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4891,7 +4891,7 @@ extern void pop_defarg_context (void);
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);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3b5a476cdd0..f0f7e987efb 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -4168,6 +4168,7 @@ cp_parser_primary_expression (cp_parser *parser,
{
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. */
@@ -4179,6 +4180,7 @@ cp_parser_primary_expression (cp_parser *parser,
/*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 `)'. */
@@ -4188,7 +4190,7 @@ cp_parser_primary_expression (cp_parser *parser,
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:
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 409e6b9cd52..b720d4a3161 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12480,7 +12480,8 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
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));
@@ -14313,7 +14314,8 @@ tsubst_copy_and_build (tree t,
}
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:
OpenPOWER on IntegriCloud