File: unknown-type-name.cpp

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,436 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (119 lines) | stat: -rw-r--r-- 3,792 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s

// PR3990
namespace N {
  struct Wibble {
  };

  typedef Wibble foo;

  int zeppelin; // expected-note{{declared here}}
}
using namespace N;

foo::bar x; // expected-error{{no type named 'bar' in 'N::Wibble'}}

void f() {
  foo::bar  = 4; // expected-error{{no member named 'bar' in 'N::Wibble'}}
}

int f(foo::bar); // expected-error{{no type named 'bar' in 'N::Wibble'}}

int f(doulbe); // expected-error{{did you mean 'double'?}}

int fun(zapotron); // expected-error{{unknown type name 'zapotron'}}
int var(zepelin); // expected-error{{did you mean 'zeppelin'?}}

template<typename T>
struct A {
  typedef T type;

  type f();

  type g();

  static int n;
  static type m;
  static int h(T::type, int); // expected-error{{missing 'typename'}}
  static int h(T::type x, char); // expected-error{{missing 'typename'}}
};

template<typename T>
A<T>::type g(T t) { return t; } // expected-error{{missing 'typename'}}

template<typename T>
A<T>::type A<T>::f() { return type(); } // expected-error{{missing 'typename'}}

template<typename T>
void f(T::type) { } // expected-error{{missing 'typename'}}

template<typename T>
void g(T::type x) { } // expected-error{{missing 'typename'}}

template<typename T>
void f(T::type, int) { } // expected-error{{missing 'typename'}}

template<typename T>
void f(T::type x, char) { } // expected-error{{missing 'typename'}}

template<typename T>
void f(int, T::type) { } // expected-error{{missing 'typename'}}

template<typename T>
void f(char, T::type x) { } // expected-error{{missing 'typename'}}

template<typename T>
void f(int, T::type, int) { } // expected-error{{missing 'typename'}}

template<typename T>
void f(int, T::type x, char) { } // expected-error{{missing 'typename'}}

int *p;

int f1(undeclared, int); // expected-error{{unknown type name 'undeclared'}}

int f2(undeclared, 0); // expected-error{{undeclared identifier}}

int f3(undeclared *p, int); // expected-error{{unknown type name 'undeclared'}}

int f4(undeclared *p, 0); // expected-error{{undeclared identifier}}

int *test(UnknownType *fool) { return 0; } // expected-error{{unknown type name 'UnknownType'}}

template<typename T> int A<T>::n(T::value); // ok
template<typename T>
A<T>::type // expected-error{{missing 'typename'}}
A<T>::m(T::value, 0); // ok

template<typename T> int A<T>::h(T::type, int) {} // expected-error{{missing 'typename'}}
template<typename T> int A<T>::h(T::type x, char) {} // expected-error{{missing 'typename'}}

template<typename T> int h(T::type, int); // expected-error{{missing 'typename'}}
template<typename T> int h(T::type x, char); // expected-error{{missing 'typename'}}

template<typename T> int junk1(T::junk);
#if __cplusplus <= 201103L
// expected-warning@-2 {{variable templates are a C++14 extension}}
#endif
template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}}
template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}}
#if __cplusplus <= 199711L
//expected-warning@-2 {{deleted function definitions are a C++11 extension}}
#endif

template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}}

// FIXME: We can tell this was intended to be a function because it does not
//        have a dependent nested name specifier.
template<typename T> int i(T::type, int());
#if __cplusplus <= 201103L
// expected-warning@-2 {{variable templates are a C++14 extension}}
#endif


// FIXME: We know which type specifier should have been specified here. Provide
//        a fix-it to add 'typename A<T>::type'
template<typename T>
A<T>::g() { } // expected-error{{requires a type specifier}}