aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c9
-rw-r--r--gcc/testsuite/ChangeLog11
-rw-r--r--gcc/testsuite/g++.dg/template/crash81.C3
-rw-r--r--gcc/testsuite/g++.dg/template/pr58878.C32
-rw-r--r--gcc/testsuite/g++.dg/template/shadow1.C4
-rw-r--r--gcc/testsuite/g++.dg/template/shadow2.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.benjamin/tem03.C22
-rw-r--r--gcc/testsuite/g++.old-deja/g++.benjamin/tem04.C25
-rw-r--r--gcc/testsuite/g++.old-deja/g++.brendan/crash7.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/shadow2.C2
11 files changed, 67 insertions, 52 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index df2e0b2..d2e5502 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-14 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * pt.c (check_template_shadow): Emit error + inform instead of
+ two errors.
+
2015-07-13 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/65186
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2097963..718befd 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 1987756..c0932fa 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2015-07-14 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * 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 <rguenther@suse.de>
PR tree-optimization/66863
diff --git a/gcc/testsuite/g++.dg/template/crash81.C b/gcc/testsuite/g++.dg/template/crash81.C
index 849470a..54efba6 100644
--- a/gcc/testsuite/g++.dg/template/crash81.C
+++ b/gcc/testsuite/g++.dg/template/crash81.C
@@ -3,6 +3,5 @@
struct A
{
template<T::X> struct X; // { dg-error "'T' has not been declared" "T" }
- // { dg-error "declaration of 'template<int X> 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 adad9fe..79fcd84 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 <typename t> // { dg-error "shadows" }
+ template <typename t> // { dg-message "template parameter" }
void f()
{
- int t = 1; // { dg-error "declaration" }
+ int t = 1; // { dg-error "shadows" }
}
template <typename t>
void g();
};
-template <typename t> // { dg-error "shadows" }
+template <typename t> // { 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 <typename t> // { dg-error "shadows" }
+template <typename t> // { dg-message "template parameter" }
struct B
{
void f()
{
- int t = 3; // { dg-error "declaration" }
+ int t = 3; // { dg-error "shadows" }
}
void g();
};
-template <typename t> // { dg-error "shadows" }
+template <typename t> // { dg-message "template parameter" }
void B<t>::g()
{
- int t = 4; // { dg-error "declaration" }
+ int t = 4; // { dg-error "shadows" }
}
// Template members of template class
-template <typename t> // { dg-error "shadows" }
+template <typename t> // { dg-message "template parameter" }
struct C
{
- template <typename s> // { dg-error "shadows" }
+ template <typename s> // { 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 <typename s>
void g();
};
-template <typename t> // { dg-error "shadows" }
-template <typename s> // { dg-error "shadows" }
+template <typename t> // { dg-message "template parameter" }
+template <typename s> // { dg-message "template parameter" }
void C<t>::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 6eb30d0..6125704 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<template<int I> class A> // { dg-message "shadows" }
-class A {}; // { dg-error "declaration" }
+template<template<int I> 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 7f6a6dc..22d6a28 100644
--- a/gcc/testsuite/g++.dg/template/shadow2.C
+++ b/gcc/testsuite/g++.dg/template/shadow2.C
@@ -1,3 +1,3 @@
-template <class A, // { dg-error "shadows template parm 'class A'" }
- template <class A> class B> // { dg-error "declaration of 'class A'" }
+template <class A, // { dg-message "template parameter 'A'" }
+ template <class A> 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 fb9830e..c68d554 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 <class T4>// { dg-error "" } .*
+template <class T4>// { dg-message "" } .*
class Xone {
protected:
T4* next;
@@ -38,7 +38,7 @@ public:
// 02
// nested template class
-template <class T6>// { dg-error "" } .*
+template <class T6>// { dg-message "" } .*
class Xtwo {
protected:
T6* next;
@@ -58,7 +58,7 @@ public:
// 03
// member templates
-template <class T8>// { dg-error "" } .*
+template <class T8>// { dg-message "" } .*
class Xthree {
protected:
T8* next;
@@ -80,7 +80,7 @@ public:
// 04
// local names (14.6.1 p 4)
-template <class T10, int i> struct Xfour {// { dg-error "" } .*
+template <class T10, int i> struct Xfour {// { dg-message "" } .*
int T10; // { dg-error "" } .*
void f(){
char T10; // { dg-error "declaration of 'char T10'" }
@@ -94,7 +94,7 @@ template <class T12, int i> struct Xfive {
void f();
};
-template <class T13, int i> void Xfive<T13,i>::f() {// { dg-error "" } .*
+template <class T13, int i> void Xfive<T13,i>::f() {// { dg-message "" } .*
int T13; // { dg-error "" } .*
int T12; //should be ok
}
@@ -116,14 +116,14 @@ template <class T12> class T12; // { dg-error "" } .*
// 08
// with multiple template params, and second (third) one is redeclared
-template <class T16, int i, class T161> class Xseven { // { dg-error "" } .*
+template <class T16, int i, class T161> class Xseven { // { dg-message "" } .*
private:
char T161; // { dg-error "" } .*
public:
template <class U>
friend bool fooy(U u);
- template <class T161> // { dg-error "declaration of 'class T161'" }
+ template <class T161> // { dg-error "declaration of template parameter 'T161'" }
friend bool foo(T161 u)
{
Xseven<T161, 5, int> 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 T18, int i> class Xten {// { dg-error "" } .*
+template <class T18, int i> class Xten {// { dg-message "" } .*
float i; // { dg-error "" } .*
};
// 11
// declared friend template, non-type parameters
-template <long l>// { dg-error "" } .*
+template <long l>// { dg-message "" } .*
class Xeleven {
public:
template <long l> friend bool isequal (Xeleven<5> lhs, Xeleven<5> rhs); // { dg-error "" } .*
@@ -175,7 +175,7 @@ public:
// 12
// nested template class, non-type parameters
-template <long l>// { dg-error "" } .*
+template <long l>// { dg-message "" } .*
class Xtwelve {
public:
template <long l> class nested {// { dg-error "" } .
@@ -188,7 +188,7 @@ public:
// 13
// member templates, non-type parameters
-template <long l>// { dg-error "" } .*
+template <long l>// { dg-message "" } .*
struct Xthirteen {
template <long l> 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 7dd7462..1fd45bc 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 <class T4>// { dg-error "" } .*
+template <class T4>// { dg-message "" } .*
class Xfourteen {
protected:
T4 value;
@@ -31,7 +31,7 @@ public:
// 15
// nested template class (v3, template type parameters)
-template <class T6>// { dg-error "" } .*
+template <class T6>// { dg-message "" } .*
class Xfifteen {
protected:
T6 value;
@@ -48,7 +48,7 @@ public:
// 16
// member templates (v3, template type parameters)
-template <class T8>// { dg-error "" } .*
+template <class T8>// { dg-message "" } .*
class Xsixteen {
protected:
T8 value;
@@ -88,7 +88,7 @@ public:
// 18
// more template template redecl tests
-template <typename T14, template <typename T15> class C12>// { dg-error "" } .*
+template <typename T14, template <typename T15> class C12>// { dg-message "" } .*
class Xeighteen {
protected:
C12<T14> value;
@@ -98,7 +98,7 @@ protected:
// 19
// more template template redecl tests
-template <typename T16, template <typename T17> class C14>// { dg-error "" } .*
+template <typename T16, template <typename T17> class C14>// { dg-message "" } .*
class Xnineteen{
protected:
C14<T16> value;
@@ -137,7 +137,7 @@ template <class T17, int i> struct Xtwenty {
// non-type template parameters v1: enum
enum my_enum {my_A = 45, my_B, my_C};
-template <my_enum T18> class Xtwentyone {// { dg-error "" } .*
+template <my_enum T18> class Xtwentyone {// { dg-message "" } .*
float T18; // { dg-error "" } .*
};
@@ -149,34 +149,29 @@ struct base {
int ret_gcount() {return gcount;}
};
-template <class T20, base* b> class Xtwentytwo {// { dg-error "" } .*
+template <class T20, base* b> class Xtwentytwo {// { dg-message "" } .*
float b; // { dg-error "" } .*
};
// 23
// non-type template parameters v2: reference to object
-template <class T20, base& b2> class Xtwentythree {// { dg-error "" } .*
+template <class T20, base& b2> class Xtwentythree {// { dg-message "" } .*
float b2; // { dg-error "" } .*
};
// 24
// non-type template parameters v3: pointer to member
-template <class T20, int base::* b3> class Xtwentyfour {// { dg-error "" } .*
+template <class T20, int base::* b3> class Xtwentyfour {// { dg-message "" } .*
float b3; // { dg-error "" } .*
};
// 25
// non-type template parms that use push_class_level
-template <class T22> void f1() {// { dg-error "" } .*
+template <class T22> 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 44339ea..242277a 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<class T>// { dg-error "" } previous definition of T
+template<class T>// { 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 11d6a9b..41c1bb2 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 <jason@cygnus.com>
-template <class T> struct A { // { dg-error "" } shadowed parameter
+template <class T> struct A { // { dg-message "" } shadowed parameter
struct B {
void T(); // { dg-error "" } shadows template parameter
};