[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / unknown-type-name.cpp
blob602f8f9ec7d2910b1217ffab7a51918f57b6f32e
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 // PR3990
6 namespace N {
7 struct Wibble {
8 };
10 typedef Wibble foo;
12 int zeppelin; // expected-note{{declared here}}
14 using namespace N;
16 foo::bar x; // expected-error{{no type named 'bar' in 'N::Wibble'}}
18 void f() {
19 foo::bar = 4; // expected-error{{no member named 'bar' in 'N::Wibble'}}
22 int f(foo::bar); // expected-error{{no type named 'bar' in 'N::Wibble'}}
24 int f(doulbe); // expected-error{{did you mean 'double'?}}
26 int fun(zapotron); // expected-error{{unknown type name 'zapotron'}}
27 int var(zepelin); // expected-error{{did you mean 'zeppelin'?}}
29 template<typename T>
30 struct A {
31 typedef T type;
33 type f();
35 type g();
37 static int n;
38 static type m;
39 static int h(T::type, int); // expected-warning{{implicit 'typename' is a C++20 extension}}
40 static int h(T::type x, char); // expected-warning{{implicit 'typename' is a C++20 extension}}
43 template<typename T>
44 A<T>::type g(T t) { return t; } // expected-warning{{implicit 'typename' is a C++20 extension}}
46 template<typename T>
47 A<T>::type A<T>::f() { return type(); } // expected-warning{{implicit 'typename' is a C++20 extension}}
49 template<typename T>
50 void f(T::type) { } // expected-error{{missing 'typename'}}
52 template<typename T>
53 void g(T::type x) { } // expected-error{{missing 'typename'}}
55 template<typename T>
56 void f(T::type, int) { } // expected-error{{missing 'typename'}}
58 template<typename T>
59 void f(T::type x, char) { } // expected-error{{missing 'typename'}}
61 template<typename T>
62 void f(int, T::type) { } // expected-error{{missing 'typename'}}
64 template<typename T>
65 void f(char, T::type x) { } // expected-error{{missing 'typename'}}
67 template<typename T>
68 void f(int, T::type, int) { } // expected-error{{missing 'typename'}}
70 template<typename T>
71 void f(int, T::type x, char) { } // expected-error{{missing 'typename'}}
73 int *p;
75 int f1(undeclared, int); // expected-error{{unknown type name 'undeclared'}}
77 int f2(undeclared, 0); // expected-error{{undeclared identifier}}
79 int f3(undeclared *p, int); // expected-error{{unknown type name 'undeclared'}}
81 int f4(undeclared *p, 0); // expected-error{{undeclared identifier}}
83 int *test(UnknownType *fool) { return 0; } // expected-error{{unknown type name 'UnknownType'}}
85 template<typename T> int A<T>::n(T::value); // ok
86 template<typename T>
87 A<T>::type // expected-warning {{implicit 'typename' is a C++20 extension}}
88 A<T>::m(T::value, 0); // ok
90 template<typename T> int A<T>::h(T::type, int) {} // expected-warning{{implicit 'typename' is a C++20 extension}}
91 template<typename T> int A<T>::h(T::type x, char) {} // expected-warning{{implicit 'typename' is a C++20 extension}}
93 template<typename T> int h(T::type, int); // expected-error{{missing 'typename'}}
94 template<typename T> int h(T::type x, char); // expected-error{{missing 'typename'}}
96 template<typename T> int junk1(T::junk);
97 #if __cplusplus <= 201103L
98 // expected-warning@-2 {{variable templates are a C++14 extension}}
99 #endif
100 template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}}
101 template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}}
102 #if __cplusplus <= 199711L
103 //expected-warning@-2 {{deleted function definitions are a C++11 extension}}
104 #endif
106 template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}}
108 // FIXME: We can tell this was intended to be a function because it does not
109 // have a dependent nested name specifier.
110 template<typename T> int i(T::type, int());
111 #if __cplusplus <= 201103L
112 // expected-warning@-2 {{variable templates are a C++14 extension}}
113 #endif
116 // FIXME: We know which type specifier should have been specified here. Provide
117 // a fix-it to add 'typename A<T>::type'
118 template<typename T>
119 A<T>::g() { } // expected-error{{expected unqualified-id}}
120 // expected-warning@-1{{implicit 'typename' is a C++20 extension}}