diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-06 14:38:50 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-06 14:38:50 +0000 |
commit | 0a683683c5048a8a9c586809b0d6d319f259d1ac (patch) | |
tree | 9e55e9529dfd980d13308f393e59a58d99f1a5c1 /gcc/cp/parser.c | |
parent | a828b39f1f6478f8682c1e63481815d2839558bf (diff) | |
download | gcc-0a683683c5048a8a9c586809b0d6d319f259d1ac.tar.gz |
testsuite/
* g++.dg/parse/redef2.C: New.
cp/
* parser.c (make_pointer_declarator, make_reference_declarator,
make_call_declarator, make_array_declarator): Set declarator->id_loc.
(cp_parser_init_declarator): Adjust location of decl if appropriate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163920 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 769d7dcacad..db2073ba03f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -1068,6 +1068,7 @@ make_pointer_declarator (cp_cv_quals cv_qualifiers, cp_declarator *target) declarator->u.pointer.class_type = NULL_TREE; if (target) { + declarator->id_loc = target->id_loc; declarator->parameter_pack_p = target->parameter_pack_p; target->parameter_pack_p = false; } @@ -1091,6 +1092,7 @@ make_reference_declarator (cp_cv_quals cv_qualifiers, cp_declarator *target, declarator->u.reference.rvalue_ref = rvalue_ref; if (target) { + declarator->id_loc = target->id_loc; declarator->parameter_pack_p = target->parameter_pack_p; target->parameter_pack_p = false; } @@ -1147,6 +1149,7 @@ make_call_declarator (cp_declarator *target, declarator->u.function.late_return_type = late_return_type; if (target) { + declarator->id_loc = target->id_loc; declarator->parameter_pack_p = target->parameter_pack_p; target->parameter_pack_p = false; } @@ -1169,6 +1172,7 @@ make_array_declarator (cp_declarator *element, tree bounds) declarator->u.array.bounds = bounds; if (element) { + declarator->id_loc = element->id_loc; declarator->parameter_pack_p = element->parameter_pack_p; element->parameter_pack_p = false; } @@ -14010,6 +14014,13 @@ cp_parser_init_declarator (cp_parser* parser, decl = start_decl (declarator, decl_specifiers, is_initialized, attributes, prefix_attributes, &pushed_scope); + /* Adjust location of decl if declarator->id_loc is more appropriate: + set, and decl wasn't merged with another decl, in which case its + location would be different from input_location, and more accurate. */ + if (DECL_P (decl) + && declarator->id_loc != UNKNOWN_LOCATION + && DECL_SOURCE_LOCATION (decl) == input_location) + DECL_SOURCE_LOCATION (decl) = declarator->id_loc; } else if (scope) /* Enter the SCOPE. That way unqualified names appearing in the |