1 // RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
3 // RUN: not %clang_cc1 -fsyntax-only -std=c++98 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefix=CXX98 %s
4 // RUN: not %clang_cc1 -fsyntax-only -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefix=CXX11 %s
5 // C++0x N2914.
6 
7 struct X {
8   int i;
9   static int a;
10 };
11 
12 using X::i; // expected-error{{using declaration cannot refer to class member}}
13 using X::s; // expected-error{{using declaration cannot refer to class member}}
14 
f()15 void f() {
16   using X::i; // expected-error{{using declaration cannot refer to class member}}
17   using X::s; // expected-error{{using declaration cannot refer to class member}}
18 }
19 
20 template <typename T>
21 struct PR21933 : T {
StaticFunPR2193322   static void StaticFun() { using T::member; } // expected-error{{using declaration cannot refer to class member}}
23 };
24 
25 struct S {
26   static int n;
27   struct Q {};
28   enum E {};
29   typedef Q T;
30   void f();
31   static void g();
32 };
33 
34 using S::n; // expected-error{{class member}} expected-note {{use a reference instead}}
35 #if __cplusplus < 201103L
36 // CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-2]]
37 #else
38 // CXX11: fix-it:"{{.*}}":{[[@LINE-4]]:1-[[@LINE-4]]:6}:"auto &n = "
39 #endif
40 
41 using S::Q; // expected-error{{class member}}
42 #if __cplusplus < 201103L
43 // expected-note@-2 {{use a typedef declaration instead}}
44 // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef"
45 // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" Q"
46 #else
47 // expected-note@-6 {{use an alias declaration instead}}
48 // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"Q = "
49 #endif
50 
51 using S::E; // expected-error{{class member}}
52 #if __cplusplus < 201103L
53 // expected-note@-2 {{use a typedef declaration instead}}
54 // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef"
55 // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" E"
56 #else
57 // expected-note@-6 {{use an alias declaration instead}}
58 // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"E = "
59 #endif
60 
61 using S::T; // expected-error{{class member}}
62 #if __cplusplus < 201103L
63 // expected-note@-2 {{use a typedef declaration instead}}
64 // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef"
65 // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" T"
66 #else
67 // expected-note@-6 {{use an alias declaration instead}}
68 // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"T = "
69 #endif
70 
71 using S::f; // expected-error{{class member}}
72 using S::g; // expected-error{{class member}}
73 
h()74 void h() {
75   using S::n; // expected-error{{class member}} expected-note {{use a reference instead}}
76 #if __cplusplus < 201103L
77   // CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-2]]
78 #else
79   // CXX11: fix-it:"{{.*}}":{[[@LINE-4]]:3-[[@LINE-4]]:8}:"auto &n = "
80 #endif
81 
82   using S::Q; // expected-error{{class member}}
83 #if __cplusplus < 201103L
84   // expected-note@-2 {{use a typedef declaration instead}}
85   // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef"
86   // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" Q"
87 #else
88   // expected-note@-6 {{use an alias declaration instead}}
89   // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"Q = "
90 #endif
91 
92   using S::E; // expected-error{{class member}}
93 #if __cplusplus < 201103L
94   // expected-note@-2 {{use a typedef declaration instead}}
95   // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef"
96   // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" E"
97 #else
98   // expected-note@-6 {{use an alias declaration instead}}
99   // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"E = "
100 #endif
101 
102   using S::T; // expected-error{{class member}}
103 #if __cplusplus < 201103L
104   // expected-note@-2 {{use a typedef declaration instead}}
105   // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef"
106   // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" T"
107 #else
108   // expected-note@-6 {{use an alias declaration instead}}
109   // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"T = "
110 #endif
111 
112   using S::f; // expected-error{{class member}}
113   using S::g; // expected-error{{class member}}
114 }
115