1 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
check1()2 auto check1() {
3   return 1;
4   return s; // expected-error {{use of undeclared identifier 's'}}
5 }
6 
7 int test = 11; // expected-note 2 {{'test' declared here}}
check2()8 auto check2() {
9   return "s";
10   return tes; // expected-error {{use of undeclared identifier 'tes'; did you mean 'test'?}}
11               // expected-error@-1 {{deduced as 'int' here but deduced as 'const char *' in earlier}}
12 }
13 
14 template <class A, class B> struct is_same { static constexpr bool value = false; };
15 template <class A> struct is_same<A,A> { static constexpr bool value = true; };
16 
__anonb482f8f40102null17 auto L1 = [] { return s; }; // expected-error {{use of undeclared identifier 's'}}
18 using T1 = decltype(L1());
19 // FIXME: Suppress the 'undeclared identifier T1' diagnostic, the UsingDecl T1 is discarded because of an invalid L1().
20 static_assert(is_same<T1, void>::value, "Return statement should be discarded"); // expected-error {{use of undeclared identifier 'T1'}}
__anonb482f8f40202null21 auto L2 = [] { return tes; }; // expected-error {{use of undeclared identifier 'tes'; did you mean 'test'?}}
22 using T2 = decltype(L2());
23 static_assert(is_same<T2, int>::value, "Return statement was corrected");
24 
25 namespace BarNamespace {
26 namespace NestedNamespace { // expected-note {{'BarNamespace::NestedNamespace' declared here}}
27 typedef int type;
28 }
29 }
30 struct FooRecord { };
31 FooRecord::NestedNamespace::type x; // expected-error {{no member named 'NestedNamespace' in 'FooRecord'; did you mean 'BarNamespace::NestedNamespace'?}}
32 
cast_expr(int g)33 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared identifier 'n'}}
34 
bind()35 void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error {{undeclared identifier '_test_'}}
36 
37 namespace NoCrash {
38 class S {
Function(int a)39   void Function(int a) {
40     unknown1(unknown2, Function, unknown3); // expected-error 2{{use of undeclared identifier}} \
41                                                expected-error {{reference to non-static member function must be called}}
42   }
43 };
44 }
45 
46 namespace NoCrashOnCheckArgAlignment {
47 template <typename a> void b(a &);
test()48 void test() {
49   for (auto file_data :b(files_db_data)); // expected-error {{use of undeclared identifier 'files_db_data'; did you mean 'file_data'?}} \
50                                           // expected-note {{'file_data' declared here}} \
51                                           // expected-error {{cannot use type 'void' as a range}}
52 }
53 }
54