blob: ce5972bf2dc504a96c1b400ce512d3fe8f9d35a5 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregora786fdb2009-10-13 23:27:22 +00002
3// PR3990
4namespace N {
5 struct Wibble {
6 };
7
8 typedef Wibble foo;
Richard Smith05766812012-08-18 00:55:03 +00009
10 int zeppelin; // expected-note{{declared here}}
Douglas Gregora786fdb2009-10-13 23:27:22 +000011}
12using namespace N;
13
John McCall7c2342d2010-03-10 11:27:22 +000014foo::bar x; // expected-error{{no type named 'bar' in 'N::Wibble'}}
Douglas Gregora786fdb2009-10-13 23:27:22 +000015
16void f() {
John McCall7c2342d2010-03-10 11:27:22 +000017 foo::bar = 4; // expected-error{{no member named 'bar' in 'N::Wibble'}}
Douglas Gregora786fdb2009-10-13 23:27:22 +000018}
19
Richard Smith05766812012-08-18 00:55:03 +000020int f(foo::bar); // expected-error{{no type named 'bar' in 'N::Wibble'}}
21
22int f(doulbe); // expected-error{{did you mean 'double'?}}
23
24int fun(zapotron); // expected-error{{unknown type name 'zapotron'}}
25int var(zepelin); // expected-error{{did you mean 'zeppelin'?}}
26
Douglas Gregora786fdb2009-10-13 23:27:22 +000027template<typename T>
28struct A {
29 typedef T type;
30
31 type f();
Richard Smith8f0a7e72012-05-15 21:29:55 +000032
33 type g();
Richard Smith25582fc2012-05-16 23:40:17 +000034
35 static int n;
36 static type m;
37 static int h(T::type, int); // expected-error{{missing 'typename'}}
38 static int h(T::type x, char); // expected-error{{missing 'typename'}}
Douglas Gregora786fdb2009-10-13 23:27:22 +000039};
40
41template<typename T>
42A<T>::type g(T t) { return t; } // expected-error{{missing 'typename'}}
43
44template<typename T>
45A<T>::type A<T>::f() { return type(); } // expected-error{{missing 'typename'}}
Richard Smith8f0a7e72012-05-15 21:29:55 +000046
47template<typename T>
Richard Smith25582fc2012-05-16 23:40:17 +000048void f(T::type) { } // expected-error{{missing 'typename'}}
49
50template<typename T>
51void g(T::type x) { } // expected-error{{missing 'typename'}}
52
53template<typename T>
54void f(T::type, int) { } // expected-error{{missing 'typename'}}
55
56template<typename T>
57void f(T::type x, char) { } // expected-error{{missing 'typename'}}
58
59template<typename T>
Richard Smith8f0a7e72012-05-15 21:29:55 +000060void f(int, T::type) { } // expected-error{{missing 'typename'}}
61
62template<typename T>
Richard Smith25582fc2012-05-16 23:40:17 +000063void f(char, T::type x) { } // expected-error{{missing 'typename'}}
64
65template<typename T>
Richard Smith8f0a7e72012-05-15 21:29:55 +000066void f(int, T::type, int) { } // expected-error{{missing 'typename'}}
67
Richard Smith25582fc2012-05-16 23:40:17 +000068template<typename T>
69void f(int, T::type x, char) { } // expected-error{{missing 'typename'}}
70
Richard Smith05766812012-08-18 00:55:03 +000071int *p;
72
73// FIXME: We should assume that 'undeclared' is a type, not a parameter name
74// here, and produce an 'unknown type name' diagnostic instead.
75int f1(undeclared, int); // expected-error{{requires a type specifier}}
76
77int f2(undeclared, 0); // expected-error{{undeclared identifier}}
78
79int f3(undeclared *p, int); // expected-error{{unknown type name 'undeclared'}}
80
81int f4(undeclared *p, 0); // expected-error{{undeclared identifier}}
82
83int *test(UnknownType *fool) { return 0; } // expected-error{{unknown type name 'UnknownType'}}
84
Richard Smith25582fc2012-05-16 23:40:17 +000085template<typename T> int A<T>::n(T::value); // ok
86template<typename T>
87A<T>::type // expected-error{{missing 'typename'}}
88A<T>::m(T::value, 0); // ok
89
90template<typename T> int A<T>::h(T::type, int) {} // expected-error{{missing 'typename'}}
91template<typename T> int A<T>::h(T::type x, char) {} // expected-error{{missing 'typename'}}
92
93template<typename T> int h(T::type, int); // expected-error{{missing 'typename'}}
94template<typename T> int h(T::type x, char); // expected-error{{missing 'typename'}}
95
96template<typename T> int junk1(T::junk); // expected-error{{declared as a template}}
97template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}}
98template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} expected-warning{{C++11}}
99template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}}
100
101// FIXME: We can tell this was intended to be a function because it does not
102// have a dependent nested name specifier.
103template<typename T> int i(T::type, int()); // expected-error{{variable 'i' declared as a template}}
104
Richard Smith8f0a7e72012-05-15 21:29:55 +0000105// FIXME: We know which type specifier should have been specified here. Provide
106// a fix-it to add 'typename A<T>::type'
107template<typename T>
108A<T>::g() { } // expected-error{{requires a type specifier}}