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 
__anonb3fd006a0102null17 auto L1 = [] { return s; }; // expected-error {{use of undeclared identifier 's'}}
18 using T1 = decltype(L1());
19 static_assert(is_same<T1, void>::value, "Return statement should be discarded");
__anonb3fd006a0202null20 auto L2 = [] { return tes; }; // expected-error {{use of undeclared identifier 'tes'; did you mean 'test'?}}
21 using T2 = decltype(L2());
22 static_assert(is_same<T2, int>::value, "Return statement was corrected");
23 
24 namespace BarNamespace {
25 namespace NestedNamespace { // expected-note {{'BarNamespace::NestedNamespace' declared here}}
26 typedef int type;
27 }
28 }
29 struct FooRecord { };
30 FooRecord::NestedNamespace::type x; // expected-error {{no member named 'NestedNamespace' in 'FooRecord'; did you mean 'BarNamespace::NestedNamespace'?}}
31 
cast_expr(int g)32 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared identifier 'n'}}
33 
bind()34 void bind() { for (const auto& [test,_] : _test_) { }; } // expected-error {{undeclared identifier '_test_'}}
35