2 // Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
3 // DR147: Naming the constructor (PR 11764)
7 struct A { A(); void f(); };
8 struct B: public A { B(); };
14 A::A a; // { dg-error "constructor" "the injected-class-name can never be found through qualified lookup" }
18 A::A(); // { dg-message "::A" "c++/42415" }
23 A::A a; // { dg-error "constructor" }
24 } // { dg-error "" "" { target *-*-* } 23 } error cascade
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);
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.
58 // And if lookup doesn't find the injected-class-name, we aren't naming the
59 // constructor (c++/44401).