1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wno-c++11-extensions %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
8 A fizbin
; // expected-note 2 {{declared here}}
9 A foobar
; // expected-note 2 {{declared here}}
10 B roxbin
; // expected-note 2 {{declared here}}
11 B toobad
; // expected-note 2 {{declared here}}
19 something(obj
.fixbin
, // expected-error {{did you mean 'fizbin'?}}
20 obj
.toobat
); // expected-error {{did you mean 'toobad'?}}
21 something(obj
.toobat
, // expected-error {{did you mean 'foobar'?}}
22 obj
.fixbin
); // expected-error {{did you mean 'roxbin'?}}
23 something(obj
.fixbin
, // expected-error {{did you mean 'fizbin'?}}
24 obj
.fixbin
); // expected-error {{did you mean 'roxbin'?}}
25 something(obj
.toobat
, // expected-error {{did you mean 'foobar'?}}
26 obj
.toobat
); // expected-error {{did you mean 'toobad'?}}
27 // Both members could be corrected to methods, but that isn't valid.
28 something(obj
.boohoo
, // expected-error-re {{no member named 'boohoo' in 'D'{{$}}}}
29 obj
.foxbox
); // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}}
30 // The first argument has a usable correction but the second doesn't.
31 something(obj
.boobar
, // expected-error-re {{no member named 'boobar' in 'D'{{$}}}}
32 obj
.foxbox
); // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}}
35 // Ensure the delayed typo correction does the right thing when trying to
36 // recover using a seemingly-valid correction for which a valid expression to
37 // replace the TypoExpr cannot be created (but which does have a second
38 // correction candidate that would be a valid and usable correction).
41 template <> void testIt(); // expected-error {{no function template matches}}
42 void textIt(); // expected-note {{'textIt' declared here}}
44 void testMemberExpr(Foo
*f
) {
45 f
->TestIt(); // expected-error {{no member named 'TestIt' in 'Foo'; did you mean 'textIt'?}}
48 void callee(double, double);
49 void testNoCandidates() {
50 callee(xxxxxx
, // expected-error-re {{use of undeclared identifier 'xxxxxx'{{$}}}}
51 zzzzzz
); // expected-error-re {{use of undeclared identifier 'zzzzzz'{{$}}}}
58 Item
* next(); // expected-note {{'next' declared here}}
60 void testExprFilter(Item
*i
) {
62 j
= i
->Next(); // expected-error {{no member named 'Next' in 'Item'; did you mean 'next'?}}
65 // Test that initializer expressions are handled correctly and that the type
66 // being initialized is taken into account when choosing a correction.
67 namespace initializerCorrections
{
70 // Node* Next() is not implemented yet
73 // text is only an edit distance of 1 from Next, but would trigger type
74 // conversion errors if used in this initialization expression.
75 Node
*next
= node
->Next(); // expected-error-re {{no member named 'Next' in 'initializerCorrections::Node'{{$}}}}
79 LinkedNode
* next(); // expected-note {{'next' declared here}}
82 void f(LinkedNode
*node
) {
83 // text and next are equidistant from Next, but only one results in a valid
84 // initialization expression.
85 LinkedNode
*next
= node
->Next(); // expected-error {{no member named 'Next' in 'initializerCorrections::LinkedNode'; did you mean 'next'?}}
93 void f(NestedNode
*node
) {
94 // There are two equidistant, usable corrections for Next: next and Nest
95 NestedNode
*next
= node
->Next(); // expected-error-re {{no member named 'Next' in 'initializerCorrections::NestedNode'{{$}}}}
101 // Check that arguments to a builtin with custom type checking are corrected
102 // properly, since calls to such builtins bypass much of the normal code path
103 // for building and checking the call.
104 __atomic_load(i
, i
, something_something
); // expected-error-re {{use of undeclared identifier 'something_something'{{$}}}}
108 const int DefaultArg
= 9; // expected-note {{'DefaultArg' declared here}}
109 template <int I
= defaultArg
> struct S
{}; // expected-error {{use of undeclared identifier 'defaultArg'; did you mean 'DefaultArg'?}}
113 void test_paren_suffix() {
114 foo::bar({5, 6}); // expected-error-re {{no member named 'bar' in namespace 'foo'{{$}}}}
115 #if __cplusplus <= 199711L
116 // expected-error@-2 {{expected expression}}
120 const int kNum
= 10; // expected-note {{'kNum' declared here}}
124 explicit SomeClass() : Kind(kSum
) {} // expected-error {{use of undeclared identifier 'kSum'; did you mean 'kNum'?}}
127 // There used to be an issue with typo resolution inside overloads.
128 struct AssertionResult
{ ~AssertionResult(); };
129 AssertionResult
Overload(const char *a
);
130 AssertionResult
Overload(int a
);
132 // expected-note@+1 {{'result' declared here}}
134 // expected-error@+1 {{use of undeclared identifier 'resulta'; did you mean 'result'?}}
140 int get() { return 7; } // expected-note {{'get' declared here}}
143 X variable
; // expected-note {{'variable' declared here}}
145 // expected-error@+2 {{use of undeclared identifier 'variableX'; did you mean 'variable'?}}
146 // expected-error@+1 {{no member named 'getX' in 'PR21925::X'; did you mean 'get'?}}
147 int x
= variableX
.getX();
152 int (*a
)() = (void)Z
; // expected-error-re {{use of undeclared identifier 'Z'{{$}}}} \
153 // expected-error {{cannot initialize a variable of type 'int (*)()' with an rvalue of type 'void'}}
157 int blue
; // expected-note {{'blue' declared here}}
158 __typeof blur y
; // expected-error {{use of undeclared identifier 'blur'; did you mean 'blue'?}}
162 a
= b
? : 0; // expected-error {{a type specifier is required for all declarations}} \
163 // expected-error-re {{use of undeclared identifier 'b'{{$}}}}
166 extern long clock (void);
171 void MovePointer(Pointer
&Click
, int x
, int y
) { // expected-note 2 {{'Click' declared here}}
172 click
.set_xpos(x
); // expected-error {{use of undeclared identifier 'click'; did you mean 'Click'?}}
173 click
.set_ypos(x
); // expected-error {{use of undeclared identifier 'click'; did you mean 'Click'?}}
177 // expected-error@+4 {{use of undeclared identifier 'size_t'; did you mean 'sizeof'?}}
178 // expected-error-re@+3 {{use of undeclared identifier 'y'{{$}}}}
179 // expected-error-re@+2 {{use of undeclared identifier 'z'{{$}}}}
180 // expected-error@+1 {{expected ';' after top level declarator}}
181 int getenv_s(size_t *y
, char(&z
)) {}
185 template <unsigned I
> void f() {
186 unsigned *prio_bits_array
; // expected-note {{'prio_bits_array' declared here}}
187 // expected-error@+1 {{use of undeclared identifier 'prio_op_array'; did you mean 'prio_bits_array'?}}
188 __atomic_store_n(prio_op_array
+ I
, false, __ATOMIC_RELAXED
);
193 double pow(double x
, double y
);
195 static void Now(); // expected-note {{'Now' declared here}}
198 TimeTicks::now(); // expected-error {{no member named 'now' in 'PR22297::TimeTicks'; did you mean 'Now'?}}
203 void f() { int a
= Unknown::b(c
); } // expected-error {{use of undeclared identifier 'Unknown'}}
204 // expected-error@-1 {{use of undeclared identifier 'c'}}
208 int z
= 1 ? N
: ; // expected-error {{expected expression}}
209 // expected-error-re@-1 {{use of undeclared identifier 'N'{{$}}}}
212 // PR 23285. This test must be at the end of the file to avoid additional,
213 // unwanted diagnostics.
214 // expected-error-re@+2 {{use of undeclared identifier 'uintmax_t'{{$}}}}
215 // expected-error@+1 {{expected ';' after top level declarator}}
216 unsigned int a
= 0(uintmax_t