| 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 |
| 4 | |
| 5 | // PR3990 |
| 6 | namespace N { |
| 7 | struct Wibble { |
| 8 | }; |
| 9 | |
| 10 | typedef Wibble foo; |
| 11 | |
| 12 | int zeppelin; // expected-note{{declared here}} |
| 13 | } |
| 14 | using namespace N; |
| 15 | |
| 16 | foo::bar x; // expected-error{{no type named 'bar' in 'N::Wibble'}} |
| 17 | |
| 18 | void f() { |
| 19 | foo::bar = 4; // expected-error{{no member named 'bar' in 'N::Wibble'}} |
| 20 | } |
| 21 | |
| 22 | int f(foo::bar); // expected-error{{no type named 'bar' in 'N::Wibble'}} |
| 23 | |
| 24 | int f(doulbe); // expected-error{{did you mean 'double'?}} |
| 25 | |
| 26 | int fun(zapotron); // expected-error{{unknown type name 'zapotron'}} |
| 27 | int var(zepelin); // expected-error{{did you mean 'zeppelin'?}} |
| 28 | |
| 29 | template<typename T> |
| 30 | struct A { |
| 31 | typedef T type; |
| 32 | |
| 33 | type f(); |
| 34 | |
| 35 | type g(); |
| 36 | |
| 37 | static int n; |
| 38 | static type m; |
| 39 | static int h(T::type, int); // expected-error{{missing 'typename'}} |
| 40 | static int h(T::type x, char); // expected-error{{missing 'typename'}} |
| 41 | }; |
| 42 | |
| 43 | template<typename T> |
| 44 | A<T>::type g(T t) { return t; } // expected-error{{missing 'typename'}} |
| 45 | |
| 46 | template<typename T> |
| 47 | A<T>::type A<T>::f() { return type(); } // expected-error{{missing 'typename'}} |
| 48 | |
| 49 | template<typename T> |
| 50 | void f(T::type) { } // expected-error{{missing 'typename'}} |
| 51 | |
| 52 | template<typename T> |
| 53 | void g(T::type x) { } // expected-error{{missing 'typename'}} |
| 54 | |
| 55 | template<typename T> |
| 56 | void f(T::type, int) { } // expected-error{{missing 'typename'}} |
| 57 | |
| 58 | template<typename T> |
| 59 | void f(T::type x, char) { } // expected-error{{missing 'typename'}} |
| 60 | |
| 61 | template<typename T> |
| 62 | void f(int, T::type) { } // expected-error{{missing 'typename'}} |
| 63 | |
| 64 | template<typename T> |
| 65 | void f(char, T::type x) { } // expected-error{{missing 'typename'}} |
| 66 | |
| 67 | template<typename T> |
| 68 | void f(int, T::type, int) { } // expected-error{{missing 'typename'}} |
| 69 | |
| 70 | template<typename T> |
| 71 | void f(int, T::type x, char) { } // expected-error{{missing 'typename'}} |
| 72 | |
| 73 | int *p; |
| 74 | |
| 75 | // FIXME: We should assume that 'undeclared' is a type, not a parameter name |
| 76 | // here, and produce an 'unknown type name' diagnostic instead. |
| 77 | int f1(undeclared, int); // expected-error{{requires a type specifier}} |
| 78 | |
| 79 | int f2(undeclared, 0); // expected-error{{undeclared identifier}} |
| 80 | |
| 81 | int f3(undeclared *p, int); // expected-error{{unknown type name 'undeclared'}} |
| 82 | |
| 83 | int f4(undeclared *p, 0); // expected-error{{undeclared identifier}} |
| 84 | |
| 85 | int *test(UnknownType *fool) { return 0; } // expected-error{{unknown type name 'UnknownType'}} |
| 86 | |
| 87 | template<typename T> int A<T>::n(T::value); // ok |
| 88 | template<typename T> |
| 89 | A<T>::type // expected-error{{missing 'typename'}} |
| 90 | A<T>::m(T::value, 0); // ok |
| 91 | |
| 92 | template<typename T> int A<T>::h(T::type, int) {} // expected-error{{missing 'typename'}} |
| 93 | template<typename T> int A<T>::h(T::type x, char) {} // expected-error{{missing 'typename'}} |
| 94 | |
| 95 | template<typename T> int h(T::type, int); // expected-error{{missing 'typename'}} |
| 96 | template<typename T> int h(T::type x, char); // expected-error{{missing 'typename'}} |
| 97 | |
| 98 | template<typename T> int junk1(T::junk); |
| 99 | #if __cplusplus <= 201103L |
| 100 | // expected-warning@-2 {{variable templates are a C++14 extension}} |
| 101 | #endif |
| 102 | template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}} |
| 103 | template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} |
| 104 | #if __cplusplus <= 199711L |
| 105 | //expected-warning@-2 {{deleted function definitions are a C++11 extension}} |
| 106 | #endif |
| 107 | |
| 108 | template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}} |
| 109 | |
| 110 | // FIXME: We can tell this was intended to be a function because it does not |
| 111 | // have a dependent nested name specifier. |
| 112 | template<typename T> int i(T::type, int()); |
| 113 | #if __cplusplus <= 201103L |
| 114 | // expected-warning@-2 {{variable templates are a C++14 extension}} |
| 115 | #endif |
| 116 | |
| 117 | |
| 118 | // FIXME: We know which type specifier should have been specified here. Provide |
| 119 | // a fix-it to add 'typename A<T>::type' |
| 120 | template<typename T> |
| 121 | A<T>::g() { } // expected-error{{requires a type specifier}} |
| 122 | |