+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
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;
}
+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
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 }
};
// 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" }
}
// 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" }
-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;
// 01
// declared friend template
-template <class T4>// { dg-error "" } .*
+template <class T4>// { dg-message "" } .*
class Xone {
protected:
T4* next;
// 02
// nested template class
-template <class T6>// { dg-error "" } .*
+template <class T6>// { dg-message "" } .*
class Xtwo {
protected:
T6* next;
// 03
// member templates
-template <class T8>// { dg-error "" } .*
+template <class T8>// { dg-message "" } .*
class Xthree {
protected:
T8* next;
// 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'" }
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
}
// 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;
// 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 "" } .*
// 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 "" } .
// 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;
// 14
// declared friend template (v3, template type parameters)
-template <class T4>// { dg-error "" } .*
+template <class T4>// { dg-message "" } .*
class Xfourteen {
protected:
T4 value;
// 15
// nested template class (v3, template type parameters)
-template <class T6>// { dg-error "" } .*
+template <class T6>// { dg-message "" } .*
class Xfifteen {
protected:
T6 value;
// 16
// member templates (v3, template type parameters)
-template <class T8>// { dg-error "" } .*
+template <class T8>// { dg-message "" } .*
class Xsixteen {
protected:
T8 value;
// 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;
// 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;
// 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 "" } .*
};
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 "" } .*
};
}
-
-
-
-
-
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
// { 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
};