OSDN Git Service

PR c++/9050, DR 147, DR 318
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / tc1 / dr147.C
1 // { dg-do compile }
2 // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
3 // DR147: Naming the constructor (PR 11764) 
4
5 namespace N1 {
6
7 struct A { A(); };
8 struct B: public A { B(); };
9
10 A::A() { }
11 B::B() { }
12
13 B::A ba;
14 A::A a; // { dg-error "" "the injected-class-name can never be found through qualified lookup" }
15
16 }
17
18 namespace N2 {
19
20 // This is nasty: if we allowed the injected-class-name to be looked as a 
21 //  qualified type, then the following code would be well-formed. Basically
22 //  the last line is defining the static member (with redundant parenthesis).
23 // Instead, it should be rejected as a malformed constructor declaration.
24
25 template <class T> struct A {
26   template <class T2> A(T2);
27   static A x;
28 };
29 template<> A<int>::A<int>(A<int>::x);  // { dg-error "" "this is an invalid declaration of the constructor" }
30
31 }