From d4a2b4862344454ab42a57a6a4b50461d1fa6f81 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 6 Apr 2010 17:13:07 -0400 Subject: parser.c (cp_parser_class_specifier): Set class location to that of IDENTIFIER_NODE instead of '{' when possible. * parser.c (cp_parser_class_specifier): Set class location to that of IDENTIFIER_NODE instead of '{' when possible. * semantics.c (begin_class_definition): Do not overide locations with less precise ones. From-SVN: r158030 --- gcc/cp/ChangeLog | 8 +++++ gcc/cp/parser.c | 3 ++ gcc/cp/semantics.c | 3 -- gcc/testsuite/ChangeLog | 42 +++++++++++++++++++++++ gcc/testsuite/g++.dg/cpp0x/pr31437.C | 4 +-- gcc/testsuite/g++.dg/ext/attrib18.C | 4 +-- gcc/testsuite/g++.dg/ext/bitfield2.C | 4 +-- gcc/testsuite/g++.dg/ext/bitfield4.C | 4 +-- gcc/testsuite/g++.dg/ext/visibility/warn2.C | 4 +-- gcc/testsuite/g++.dg/ext/visibility/warn3.C | 4 +-- gcc/testsuite/g++.dg/gomp/pr26690-1.C | 4 +-- gcc/testsuite/g++.dg/inherit/covariant7.C | 4 +-- gcc/testsuite/g++.dg/init/synth2.C | 4 +-- gcc/testsuite/g++.dg/lookup/using7.C | 4 +-- gcc/testsuite/g++.dg/other/crash-4.C | 4 +-- gcc/testsuite/g++.dg/other/error13.C | 4 +-- gcc/testsuite/g++.dg/other/error20.C | 4 +-- gcc/testsuite/g++.dg/parse/crash31.C | 4 +-- gcc/testsuite/g++.dg/parse/error16.C | 2 +- gcc/testsuite/g++.dg/parse/error19.C | 4 +-- gcc/testsuite/g++.dg/parse/error27.C | 4 +-- gcc/testsuite/g++.dg/parse/error28.C | 2 +- gcc/testsuite/g++.dg/parse/fused-params1.C | 4 +-- gcc/testsuite/g++.dg/template/error2.C | 4 +-- gcc/testsuite/g++.dg/template/local6.C | 4 +-- gcc/testsuite/g++.dg/template/qualttp15.C | 4 +-- gcc/testsuite/g++.dg/warn/Wnvdtor-2.C | 24 ++++++------- gcc/testsuite/g++.dg/warn/anonymous-namespace-3.C | 4 +-- gcc/testsuite/g++.old-deja/g++.benjamin/15309-1.C | 4 +-- gcc/testsuite/g++.old-deja/g++.brendan/crash29.C | 4 +-- gcc/testsuite/g++.old-deja/g++.eh/spec6.C | 4 +-- gcc/testsuite/g++.old-deja/g++.jason/crash3.C | 4 +-- gcc/testsuite/g++.old-deja/g++.jason/destruct2.C | 4 +-- gcc/testsuite/g++.old-deja/g++.law/ctors5.C | 4 +-- gcc/testsuite/g++.old-deja/g++.law/ctors9.C | 4 +-- gcc/testsuite/g++.old-deja/g++.mike/p3538a.C | 4 +-- gcc/testsuite/g++.old-deja/g++.mike/p3538b.C | 4 +-- gcc/testsuite/g++.old-deja/g++.other/struct1.C | 20 +++++------ gcc/testsuite/g++.old-deja/g++.other/volatile1.C | 5 ++- gcc/testsuite/g++.old-deja/g++.pt/crash36.C | 4 +-- gcc/testsuite/g++.old-deja/g++.pt/derived3.C | 4 +-- gcc/testsuite/g++.old-deja/g++.robertl/eb109.C | 4 +-- gcc/testsuite/g++.old-deja/g++.robertl/eb4.C | 4 +-- 43 files changed, 147 insertions(+), 98 deletions(-) (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 59b0e40..782c674 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2010-04-06 Taras Glek + Jason Merrill + + * parser.c (cp_parser_class_specifier): Set class location to that + of IDENTIFIER_NODE instead of '{' when possible. + * semantics.c (begin_class_definition): Do not overide locations + with less precise ones. + 2010-04-06 Jason Merrill PR c++/43648 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8a1bb9f..e25c280 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -16395,6 +16395,9 @@ cp_parser_class_head (cp_parser* parser, end_specialization (); --parser->num_template_parameter_lists; } + + if (type) + DECL_SOURCE_LOCATION (TYPE_NAME (type)) = type_start_token->location; *attributes_p = attributes; return type; } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1c47ded..5cf4b69 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2409,9 +2409,6 @@ begin_class_definition (tree t, tree attributes) pushtag (make_anon_name (), t, /*tag_scope=*/ts_current); } - /* Update the location of the decl. */ - DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location; - if (TYPE_BEING_DEFINED (t)) { t = make_class_type (TREE_CODE (t)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 31103d1..c0b4618 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,45 @@ +2010-04-06 Jason Merrill + + * g++.dg/cpp0x/pr31437.C: Adjust error location. + * g++.dg/ext/attrib18.C: Likewise. + * g++.dg/ext/bitfield2.C: Likewise. + * g++.dg/ext/bitfield4.C: Likewise. + * g++.dg/ext/visibility/warn2.C: Likewise. + * g++.dg/ext/visibility/warn3.C: Likewise. + * g++.dg/gomp/pr26690-1.C: Likewise. + * g++.dg/inherit/covariant7.C: Likewise. + * g++.dg/init/synth2.C: Likewise. + * g++.dg/lookup/using7.C: Likewise. + * g++.dg/other/crash-4.C: Likewise. + * g++.dg/other/error13.C: Likewise. + * g++.dg/other/error20.C: Likewise. + * g++.dg/parse/crash31.C: Likewise. + * g++.dg/parse/error16.C: Likewise. + * g++.dg/parse/error19.C: Likewise. + * g++.dg/parse/error27.C: Likewise. + * g++.dg/parse/error28.C: Likewise. + * g++.dg/parse/fused-params1.C: Likewise. + * g++.dg/template/error2.C: Likewise. + * g++.dg/template/local6.C: Likewise. + * g++.dg/template/qualttp15.C: Likewise. + * g++.dg/warn/Wnvdtor-2.C: Likewise. + * g++.dg/warn/anonymous-namespace-3.C: Likewise. + * g++.old-deja/g++.benjamin/15309-1.C: Likewise. + * g++.old-deja/g++.brendan/crash29.C: Likewise. + * g++.old-deja/g++.eh/spec6.C: Likewise. + * g++.old-deja/g++.jason/crash3.C: Likewise. + * g++.old-deja/g++.jason/destruct2.C: Likewise. + * g++.old-deja/g++.law/ctors5.C: Likewise. + * g++.old-deja/g++.law/ctors9.C: Likewise. + * g++.old-deja/g++.mike/p3538a.C: Likewise. + * g++.old-deja/g++.mike/p3538b.C: Likewise. + * g++.old-deja/g++.other/struct1.C: Likewise. + * g++.old-deja/g++.other/volatile1.C: Likewise. + * g++.old-deja/g++.pt/crash36.C: Likewise. + * g++.old-deja/g++.pt/derived3.C: Likewise. + * g++.old-deja/g++.robertl/eb109.C: Likewise. + * g++.old-deja/g++.robertl/eb4.C: Likewise. + 2010-04-06 Sebastian Pop PR middle-end/43519 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr31437.C b/gcc/testsuite/g++.dg/cpp0x/pr31437.C index 0e1a888..812c695 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr31437.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr31437.C @@ -1,6 +1,6 @@ // { dg-options "-std=gnu++0x" } -template struct A -{ // { dg-error "candidates|A" } +template struct A // { dg-error "candidates|A" } +{ A(T* p) { // { dg-error "parameter packs|T" } (A*)(p); } diff --git a/gcc/testsuite/g++.dg/ext/attrib18.C b/gcc/testsuite/g++.dg/ext/attrib18.C index 0c3a072..ab9fea09 100644 --- a/gcc/testsuite/g++.dg/ext/attrib18.C +++ b/gcc/testsuite/g++.dg/ext/attrib18.C @@ -2,8 +2,8 @@ // Test that we warn when an attribute preceding the class-key is ignored. // { dg-do compile } -__attribute__ ((packed)) struct A -{ // { dg-warning "attribute" } +__attribute__ ((packed)) struct A // { dg-warning "attribute" } +{ char c; int x; void f(); diff --git a/gcc/testsuite/g++.dg/ext/bitfield2.C b/gcc/testsuite/g++.dg/ext/bitfield2.C index 3d89505..40effc7 100644 --- a/gcc/testsuite/g++.dg/ext/bitfield2.C +++ b/gcc/testsuite/g++.dg/ext/bitfield2.C @@ -3,8 +3,8 @@ /* { dg-options "" } */ /* { dg-options "-mno-ms-bitfields" { target i?86-*-netware } } */ -struct t -{ /* { dg-message "note: Offset of packed bit-field 't::b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */ +struct t /* { dg-message "note: Offset of packed bit-field 't::b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */ +{ char a:4; char b:8; char c:4; diff --git a/gcc/testsuite/g++.dg/ext/bitfield4.C b/gcc/testsuite/g++.dg/ext/bitfield4.C index f9858d7..8dacfaf 100644 --- a/gcc/testsuite/g++.dg/ext/bitfield4.C +++ b/gcc/testsuite/g++.dg/ext/bitfield4.C @@ -2,8 +2,8 @@ /* { dg-options "" } */ /* { dg-options "-mno-ms-bitfields" { target i?86-*-netware } } */ -struct t -{ /* { dg-message "note: Offset of packed bit-field 't::b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */ +struct t /* { dg-message "note: Offset of packed bit-field 't::b' has changed in GCC 4.4" "" { target pcc_bitfield_type_matters } } */ +{ char a:4; char b:8 __attribute__ ((packed)); char c:4; diff --git a/gcc/testsuite/g++.dg/ext/visibility/warn2.C b/gcc/testsuite/g++.dg/ext/visibility/warn2.C index 3a9637d..475179f 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/warn2.C +++ b/gcc/testsuite/g++.dg/ext/visibility/warn2.C @@ -8,8 +8,8 @@ namespace N __attribute ((__visibility__ ("hidden"))) struct A { }; } -struct B -{ // { dg-warning "visibility" } +struct B // { dg-warning "visibility" } +{ N::A a; }; diff --git a/gcc/testsuite/g++.dg/ext/visibility/warn3.C b/gcc/testsuite/g++.dg/ext/visibility/warn3.C index 2d4ec40..d1d3ba4 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/warn3.C +++ b/gcc/testsuite/g++.dg/ext/visibility/warn3.C @@ -14,8 +14,8 @@ void A::f() { } // This gets a warning because B objects might rely // on hidden symbols from A. -struct B -{ // { dg-warning "visibility" } +struct B // { dg-warning "visibility" } +{ A a; }; diff --git a/gcc/testsuite/g++.dg/gomp/pr26690-1.C b/gcc/testsuite/g++.dg/gomp/pr26690-1.C index 3b7a4f8..c49c8b7 100644 --- a/gcc/testsuite/g++.dg/gomp/pr26690-1.C +++ b/gcc/testsuite/g++.dg/gomp/pr26690-1.C @@ -1,8 +1,8 @@ // PR c++/26690 // { dg-do compile } -struct A -{ // { dg-message "A::A\\(const A&\\)" } +struct A // { dg-message "A::A\\(const A&\\)" } +{ A (int); // { dg-message "candidates" } }; diff --git a/gcc/testsuite/g++.dg/inherit/covariant7.C b/gcc/testsuite/g++.dg/inherit/covariant7.C index 596c679..cbd58bb 100644 --- a/gcc/testsuite/g++.dg/inherit/covariant7.C +++ b/gcc/testsuite/g++.dg/inherit/covariant7.C @@ -27,7 +27,7 @@ struct c4 : virtual c3, virtual c0, virtual c1 int m; }; -struct c6 : c0, c3, c4 -{ // { dg-warning "direct base" "" } +struct c6 : c0, c3, c4 // { dg-warning "direct base" "" } +{ virtual c1 &f2() volatile; }; diff --git a/gcc/testsuite/g++.dg/init/synth2.C b/gcc/testsuite/g++.dg/init/synth2.C index 795ce42..624f10b 100644 --- a/gcc/testsuite/g++.dg/init/synth2.C +++ b/gcc/testsuite/g++.dg/init/synth2.C @@ -5,8 +5,8 @@ struct G { G(G&); // { dg-message "" "candidate" } }; -class A -{ // { dg-error "no match" } +class A // { dg-error "no match" } +{ const G g; }; diff --git a/gcc/testsuite/g++.dg/lookup/using7.C b/gcc/testsuite/g++.dg/lookup/using7.C index b250c58..69e27da 100644 --- a/gcc/testsuite/g++.dg/lookup/using7.C +++ b/gcc/testsuite/g++.dg/lookup/using7.C @@ -3,8 +3,8 @@ template struct A int i; }; -template struct B : A -{ // { dg-error "incomplete" } +template struct B : A // { dg-error "incomplete" } +{ using A::i; // { dg-error "incomplete" "incomplete" } // { dg-error "using" "using" { target *-*-* } 8 } }; diff --git a/gcc/testsuite/g++.dg/other/crash-4.C b/gcc/testsuite/g++.dg/other/crash-4.C index bc2c457..d6247c4 100644 --- a/gcc/testsuite/g++.dg/other/crash-4.C +++ b/gcc/testsuite/g++.dg/other/crash-4.C @@ -14,8 +14,8 @@ struct a int m; a(const a&); }; -struct b -{ // { dg-error "cannot bind packed field" "" { target { ! default_packed } } } +struct b // { dg-error "cannot bind packed field" "" { target { ! default_packed } } } +{ char c; a aa __attribute__((packed)); // { dg-warning "attribute ignored" "" { target default_packed } } }; diff --git a/gcc/testsuite/g++.dg/other/error13.C b/gcc/testsuite/g++.dg/other/error13.C index d3b1eab..89e8847 100644 --- a/gcc/testsuite/g++.dg/other/error13.C +++ b/gcc/testsuite/g++.dg/other/error13.C @@ -1,7 +1,7 @@ //PR c++/28258 -struct A -{ // { dg-message "note" } +struct A // { dg-message "note" } +{ A(void x); // { dg-error "invalid use|incomplete type|candidates" } }; diff --git a/gcc/testsuite/g++.dg/other/error20.C b/gcc/testsuite/g++.dg/other/error20.C index 6033c0e..6f3f778 100644 --- a/gcc/testsuite/g++.dg/other/error20.C +++ b/gcc/testsuite/g++.dg/other/error20.C @@ -1,8 +1,8 @@ // PR c++/34275 // { dg-do compile } -struct A -{ // { dg-message "candidate is" } +struct A // { dg-message "candidate is" } +{ virtual A foo (); }; diff --git a/gcc/testsuite/g++.dg/parse/crash31.C b/gcc/testsuite/g++.dg/parse/crash31.C index c3fc679..0068846 100644 --- a/gcc/testsuite/g++.dg/parse/crash31.C +++ b/gcc/testsuite/g++.dg/parse/crash31.C @@ -1,5 +1,5 @@ -struct A -{ // { dg-error "forward declaration" } +struct A // { dg-error "forward declaration" } +{ A : A; // { dg-error "expected|incomplete" } A : B; // { dg-error "not declared|incomplete" } A : A(); // { dg-error "undefined type|incomplete" } diff --git a/gcc/testsuite/g++.dg/parse/error16.C b/gcc/testsuite/g++.dg/parse/error16.C index ba9aacc..3d9dcc3 100644 --- a/gcc/testsuite/g++.dg/parse/error16.C +++ b/gcc/testsuite/g++.dg/parse/error16.C @@ -3,7 +3,7 @@ struct A { - struct B {}; // { dg-error "12:previous definition of 'struct A::B'" } + struct B {}; // { dg-error "10:previous definition of 'struct A::B'" } }; struct A::B{}; // { dg-error "11:redefinition of 'struct A::B'" } diff --git a/gcc/testsuite/g++.dg/parse/error19.C b/gcc/testsuite/g++.dg/parse/error19.C index 39c2d78..0955e6a 100644 --- a/gcc/testsuite/g++.dg/parse/error19.C +++ b/gcc/testsuite/g++.dg/parse/error19.C @@ -1,8 +1,8 @@ // { dg-options "-fshow-column -fmessage-length=0 -ansi -pedantic-errors -Wno-long-long " } // PR C++/17867 -struct A -{ // { dg-message "1:candidate is:" } +struct A // { dg-message "8:candidate is:" } +{ A(int); }; diff --git a/gcc/testsuite/g++.dg/parse/error27.C b/gcc/testsuite/g++.dg/parse/error27.C index c07d1d3..90cb231 100644 --- a/gcc/testsuite/g++.dg/parse/error27.C +++ b/gcc/testsuite/g++.dg/parse/error27.C @@ -1,8 +1,8 @@ // { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" } // PR c++/20152 -struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "24:previous definition of 'struct KrSelectionMode'" } -struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "52:previous definition of 'struct KrKDESelectionMode'" } +struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "8:previous definition of 'struct KrSelectionMode'" } +struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "8:previous definition of 'struct KrKDESelectionMode'" } struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "8:redefinition of 'struct KrSelectionMode'" } struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "8:redefinition of 'struct KrKDESelectionMode'" } KrKDESelectionMode krKDESelectionMode; diff --git a/gcc/testsuite/g++.dg/parse/error28.C b/gcc/testsuite/g++.dg/parse/error28.C index 50ad960..7e235a1 100644 --- a/gcc/testsuite/g++.dg/parse/error28.C +++ b/gcc/testsuite/g++.dg/parse/error28.C @@ -2,7 +2,7 @@ // PR c++/21908 struct virt { virt () {} virt (int i) {} }; -struct der : public virtual virt { // { dg-message "34:der::der" } +struct der : public virtual virt { // { dg-message "8:der::der" } der (int i) : virt(i) {} // { dg-message "3:candidates are: der" } }; struct top : public der { diff --git a/gcc/testsuite/g++.dg/parse/fused-params1.C b/gcc/testsuite/g++.dg/parse/fused-params1.C index adb47a0..33732fc2 100644 --- a/gcc/testsuite/g++.dg/parse/fused-params1.C +++ b/gcc/testsuite/g++.dg/parse/fused-params1.C @@ -2,8 +2,8 @@ // Origin: Alexander Zvyagin // { dg-do compile } -template struct A -{ // { dg-error "" } +template struct A // { dg-error "" } +{ typedef T X; template void foo (const A&); }; diff --git a/gcc/testsuite/g++.dg/template/error2.C b/gcc/testsuite/g++.dg/template/error2.C index 86486a2..5bd9b870 100644 --- a/gcc/testsuite/g++.dg/template/error2.C +++ b/gcc/testsuite/g++.dg/template/error2.C @@ -15,8 +15,8 @@ template struct X template struct Derived { - class Nested : public X - { // { dg-message "instantiated" "" } + class Nested : public X // { dg-message "instantiated" "" } + { }; Nested m; // { dg-message "instantiated" "" } diff --git a/gcc/testsuite/g++.dg/template/local6.C b/gcc/testsuite/g++.dg/template/local6.C index c691c4c..6c5e8ac 100644 --- a/gcc/testsuite/g++.dg/template/local6.C +++ b/gcc/testsuite/g++.dg/template/local6.C @@ -1,5 +1,5 @@ -template struct PCVector2 -{ // { dg-message "candidate is" } +template struct PCVector2 // { dg-message "candidate is" } +{ template PCVector2(const PCVector2 &cv) ; PCVector2 operator- (const PCVector2 &ov) const diff --git a/gcc/testsuite/g++.dg/template/qualttp15.C b/gcc/testsuite/g++.dg/template/qualttp15.C index 0f97c32..b1c6119 100644 --- a/gcc/testsuite/g++.dg/template/qualttp15.C +++ b/gcc/testsuite/g++.dg/template/qualttp15.C @@ -12,8 +12,8 @@ template