PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / tc1 / dr147.C
blob6b656491e816495315bea8a961fd7b8dc308e587
1 // { dg-do compile }
2 // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
3 // DR147: Naming the constructor (PR 11764) 
5 namespace N1 {
7 struct A { A(); void f(); };
8 struct B: public A { B(); };
10 A::A() { }
11 B::B() { }
13 B::A ba;
14 A::A a; // { dg-error "constructor" "the injected-class-name can never be found through qualified lookup" }
16 void A::f()
18   A::A();                       // { dg-message "::A" "c++/42415" }
21 void f()
23   A::A a; // { dg-error "constructor" "constructor" }
24 } // { dg-error "" "error cascade" { target *-*-* } .-1 } error cascade
27 namespace N2 {
29 // This is nasty: if we allowed the injected-class-name to be looked as a 
30 //  qualified type, then the following code would be well-formed. Basically
31 //  the last line is defining the static member (with redundant parenthesis).
32 // Instead, it should be rejected as a malformed constructor declaration.
34 template <class T> struct A {
35   template <class T2> A(T2);
36   static A x;
38 template<> template <> A<char>::A<char>(char);
39 template<> A<int>::A<int>(A<int>::x);  // { dg-error "" "this is an invalid declaration of the constructor" }
43 // But DR 318 says that in situations where a type is syntactically
44 // required, lookup finds it.
46 struct C
48   C();
49   typedef int T;
51 struct C::C c;
52 C::C::T t;
53 struct D: C::C
55   D(): C::C() { }
58 // And if lookup doesn't find the injected-class-name, we aren't naming the
59 // constructor (c++/44401).
61 struct E
63   int E;
66 int E::*p = &E::E;