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