From: Paolo Carlini Date: Tue, 14 Jul 2015 16:20:47 +0000 (+0000) Subject: pt.c (check_template_shadow): Emit error + inform instead of two errors. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=87679b76c3469211fe25d876d717b64fcbd336c7;p=gcc.git pt.c (check_template_shadow): Emit error + inform instead of two errors. /cp 2015-07-14 Paolo Carlini * pt.c (check_template_shadow): Emit error + inform instead of two errors. /testsuite 2015-07-14 Paolo Carlini * g++.dg/template/crash81.C: Adjust for error + inform change. * g++.dg/template/pr58878.C: Likewise. * g++.dg/template/shadow1.C: Likewise. * g++.dg/template/shadow2.C: Likewise. * g++.old-deja/g++.benjamin/tem03.C: Likewise. * g++.old-deja/g++.benjamin/tem04.C: Likewise. * g++.old-deja/g++.brendan/crash7.C: Likewise. * g++.old-deja/g++.pt/shadow2.C: Likewise. From-SVN: r225783 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index df2e0b2fabf..d2e5502f4c8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-07-14 Paolo Carlini + + * pt.c (check_template_shadow): Emit error + inform instead of + two errors. + 2015-07-13 Patrick Palka PR c++/65186 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2097963ed69..718befd3f7b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3661,8 +3661,13 @@ check_template_shadow (tree decl) if (DECL_SELF_REFERENCE_P (decl)) return false; - error ("declaration of %q+#D", decl); - error (" shadows template parm %q+#D", olddecl); + if (DECL_TEMPLATE_PARM_P (decl)) + error ("declaration of template parameter %q+D shadows " + "template parameter", decl); + else + error ("declaration of %q+#D shadows template parameter", decl); + inform (DECL_SOURCE_LOCATION (olddecl), + "template parameter %qD declared here", olddecl); return false; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 198775602a9..c0932facf70 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2015-07-14 Paolo Carlini + + * g++.dg/template/crash81.C: Adjust for error + inform change. + * g++.dg/template/pr58878.C: Likewise. + * g++.dg/template/shadow1.C: Likewise. + * g++.dg/template/shadow2.C: Likewise. + * g++.old-deja/g++.benjamin/tem03.C: Likewise. + * g++.old-deja/g++.benjamin/tem04.C: Likewise. + * g++.old-deja/g++.brendan/crash7.C: Likewise. + * g++.old-deja/g++.pt/shadow2.C: Likewise. + 2015-07-14 Richard Biener PR tree-optimization/66863 diff --git a/gcc/testsuite/g++.dg/template/crash81.C b/gcc/testsuite/g++.dg/template/crash81.C index 849470a5e88..54efba65aa9 100644 --- a/gcc/testsuite/g++.dg/template/crash81.C +++ b/gcc/testsuite/g++.dg/template/crash81.C @@ -3,6 +3,5 @@ struct A { template struct X; // { dg-error "'T' has not been declared" "T" } - // { dg-error "declaration of 'template struct A::X'" "A::X" { target *-*-* } 5 } - // { dg-error "shadows template parm 'int X'" "shadow" { target *-*-* } 5 } + // { dg-bogus "declaration" "" { xfail *-*-* } 5 } }; diff --git a/gcc/testsuite/g++.dg/template/pr58878.C b/gcc/testsuite/g++.dg/template/pr58878.C index adad9fe5b07..79fcd84bebd 100644 --- a/gcc/testsuite/g++.dg/template/pr58878.C +++ b/gcc/testsuite/g++.dg/template/pr58878.C @@ -3,59 +3,59 @@ // Template-members of non-template class struct A { - template // { dg-error "shadows" } + template // { dg-message "template parameter" } void f() { - int t = 1; // { dg-error "declaration" } + int t = 1; // { dg-error "shadows" } } template void g(); }; -template // { dg-error "shadows" } +template // { dg-message "template parameter" } void A::g() { - int t = 2; // { dg-error "declaration" } + int t = 2; // { dg-error "shadows" } } // (Non-template) Members of template class -template // { dg-error "shadows" } +template // { dg-message "template parameter" } struct B { void f() { - int t = 3; // { dg-error "declaration" } + int t = 3; // { dg-error "shadows" } } void g(); }; -template // { dg-error "shadows" } +template // { dg-message "template parameter" } void B::g() { - int t = 4; // { dg-error "declaration" } + int t = 4; // { dg-error "shadows" } } // Template members of template class -template // { dg-error "shadows" } +template // { dg-message "template parameter" } struct C { - template // { dg-error "shadows" } + template // { dg-message "template parameter" } void f() { - int t = 5; // { dg-error "declaration" } - int s = 6; // { dg-error "declaration" } + int t = 5; // { dg-error "shadows" } + int s = 6; // { dg-error "shadows" } } template void g(); }; -template // { dg-error "shadows" } -template // { dg-error "shadows" } +template // { dg-message "template parameter" } +template // { dg-message "template parameter" } void C::g() { - int t = 7; // { dg-error "declaration" } - int s = 8; // { dg-error "declaration" } + int t = 7; // { dg-error "shadows" } + int s = 8; // { dg-error "shadows" } } diff --git a/gcc/testsuite/g++.dg/template/shadow1.C b/gcc/testsuite/g++.dg/template/shadow1.C index 6eb30d0945b..612570403b1 100644 --- a/gcc/testsuite/g++.dg/template/shadow1.C +++ b/gcc/testsuite/g++.dg/template/shadow1.C @@ -1,4 +1,4 @@ // PR c++/58632 -template class A> // { dg-message "shadows" } -class A {}; // { dg-error "declaration" } +template class A> // { dg-message "template parameter" } +class A {}; // { dg-error "shadows" } diff --git a/gcc/testsuite/g++.dg/template/shadow2.C b/gcc/testsuite/g++.dg/template/shadow2.C index 7f6a6dc1717..22d6a28e016 100644 --- a/gcc/testsuite/g++.dg/template/shadow2.C +++ b/gcc/testsuite/g++.dg/template/shadow2.C @@ -1,3 +1,3 @@ -template class B> // { dg-error "declaration of 'class A'" } +template class B> // { dg-error "declaration of template parameter 'A' shadows" } class X; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C index fb9830e689d..c68d5546fc5 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C @@ -18,7 +18,7 @@ // 01 // declared friend template -template // { dg-error "" } .* +template // { dg-message "" } .* class Xone { protected: T4* next; @@ -38,7 +38,7 @@ public: // 02 // nested template class -template // { dg-error "" } .* +template // { dg-message "" } .* class Xtwo { protected: T6* next; @@ -58,7 +58,7 @@ public: // 03 // member templates -template // { dg-error "" } .* +template // { dg-message "" } .* class Xthree { protected: T8* next; @@ -80,7 +80,7 @@ public: // 04 // local names (14.6.1 p 4) -template struct Xfour {// { dg-error "" } .* +template struct Xfour {// { dg-message "" } .* int T10; // { dg-error "" } .* void f(){ char T10; // { dg-error "declaration of 'char T10'" } @@ -94,7 +94,7 @@ template struct Xfive { void f(); }; -template void Xfive::f() {// { dg-error "" } .* +template void Xfive::f() {// { dg-message "" } .* int T13; // { dg-error "" } .* int T12; //should be ok } @@ -116,14 +116,14 @@ template class T12; // { dg-error "" } .* // 08 // with multiple template params, and second (third) one is redeclared -template class Xseven { // { dg-error "" } .* +template class Xseven { // { dg-message "" } .* private: char T161; // { dg-error "" } .* public: template friend bool fooy(U u); - template // { dg-error "declaration of 'class T161'" } + template // { dg-error "declaration of template parameter 'T161'" } friend bool foo(T161 u) { Xseven obj; @@ -158,14 +158,14 @@ struct S1 // 10 // check for non-type parameters, should still be able to redeclare? // local names (14.6.1 p 4) -template class Xten {// { dg-error "" } .* +template class Xten {// { dg-message "" } .* float i; // { dg-error "" } .* }; // 11 // declared friend template, non-type parameters -template // { dg-error "" } .* +template // { dg-message "" } .* class Xeleven { public: template friend bool isequal (Xeleven<5> lhs, Xeleven<5> rhs); // { dg-error "" } .* @@ -175,7 +175,7 @@ public: // 12 // nested template class, non-type parameters -template // { dg-error "" } .* +template // { dg-message "" } .* class Xtwelve { public: template class nested {// { dg-error "" } . @@ -188,7 +188,7 @@ public: // 13 // member templates, non-type parameters -template // { dg-error "" } .* +template // { dg-message "" } .* struct Xthirteen { template long comp_ge(long test) {// { dg-error "" } . long local_value; diff --git a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C index 7dd7462c334..1fd45bc3af5 100644 --- a/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C +++ b/gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C @@ -18,7 +18,7 @@ // 14 // declared friend template (v3, template type parameters) -template // { dg-error "" } .* +template // { dg-message "" } .* class Xfourteen { protected: T4 value; @@ -31,7 +31,7 @@ public: // 15 // nested template class (v3, template type parameters) -template // { dg-error "" } .* +template // { dg-message "" } .* class Xfifteen { protected: T6 value; @@ -48,7 +48,7 @@ public: // 16 // member templates (v3, template type parameters) -template // { dg-error "" } .* +template // { dg-message "" } .* class Xsixteen { protected: T8 value; @@ -88,7 +88,7 @@ public: // 18 // more template template redecl tests -template class C12>// { dg-error "" } .* +template class C12>// { dg-message "" } .* class Xeighteen { protected: C12 value; @@ -98,7 +98,7 @@ protected: // 19 // more template template redecl tests -template class C14>// { dg-error "" } .* +template class C14>// { dg-message "" } .* class Xnineteen{ protected: C14 value; @@ -137,7 +137,7 @@ template struct Xtwenty { // non-type template parameters v1: enum enum my_enum {my_A = 45, my_B, my_C}; -template class Xtwentyone {// { dg-error "" } .* +template class Xtwentyone {// { dg-message "" } .* float T18; // { dg-error "" } .* }; @@ -149,34 +149,29 @@ struct base { int ret_gcount() {return gcount;} }; -template class Xtwentytwo {// { dg-error "" } .* +template class Xtwentytwo {// { dg-message "" } .* float b; // { dg-error "" } .* }; // 23 // non-type template parameters v2: reference to object -template class Xtwentythree {// { dg-error "" } .* +template class Xtwentythree {// { dg-message "" } .* float b2; // { dg-error "" } .* }; // 24 // non-type template parameters v3: pointer to member -template class Xtwentyfour {// { dg-error "" } .* +template class Xtwentyfour {// { dg-message "" } .* float b3; // { dg-error "" } .* }; // 25 // non-type template parms that use push_class_level -template void f1() {// { dg-error "" } .* +template void f1() {// { dg-message "" } .* struct foo { enum T22 { un, du, toi }; // { dg-error "" } .* }; } - - - - - diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C b/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C index 44339ea2c7f..242277a6fe8 100644 --- a/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C +++ b/gcc/testsuite/g++.old-deja/g++.brendan/crash7.C @@ -13,7 +13,7 @@ public: int size () { return sz; } }; -template// { dg-error "" } previous definition of T +template// { dg-message "" } previous definition of T struct Comparator { typedef T T;// { dg-error "" } use of template type T in typedef to T diff --git a/gcc/testsuite/g++.old-deja/g++.pt/shadow2.C b/gcc/testsuite/g++.old-deja/g++.pt/shadow2.C index 11d6a9b0718..41c1bb2d01c 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/shadow2.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/shadow2.C @@ -1,7 +1,7 @@ // { dg-do assemble } // Origin: Jason Merrill -template struct A { // { dg-error "" } shadowed parameter +template struct A { // { dg-message "" } shadowed parameter struct B { void T(); // { dg-error "" } shadows template parameter };