xref: /llvm-project/clang/test/CXX/special/class.inhctor/elsewhere.cpp (revision 1dc2c1d27f3e609a6a14ab82b334a9aa24a11b21)
1 // RUN: true
2 // Disabled for 2.9
3 //%clang_cc1 -std=c++0x -fsyntax-only -verify %s
4 
5 // Tests related to constructor inheriting, but not specified in [class.inhctor]
6 
7 // [namespace.udecl]p8:
8 //   A using-declaration for a class member shall be a member-declaration.
9 
10 struct B1 {
11   B1(int);
12 };
13 
14 using B1::B1; // expected-error {{using declaration can not refer to class member}}
15 
16 // C++0x [namespace.udecl]p10:
17 //   A using-declaration is a declaration and can therefore be used repeatedly
18 //   where (and only where) multiple declarations are allowed.
19 
20 struct I1 : B1 {
21   using B1::B1; // expected-note {{previous using declaration}}
22   using B1::B1; // expected-error {{redeclaration of using decl}}
23 };
24 
25 // C++0x [namespace.udecl]p3:
26 //   In a using declaration used as a member-declaration, the nested-name-
27 //   specifier shall name a base class of the class being defined.
28 //   If such a using-declaration names a constructor, the nested-name-specifier
29 //   shall name a direct base class of the class being defined.
30 
31 struct D1 : I1 {
32   using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', can not inherit constructors}}
33 };
34