Debian Codegraph @

clang/test/SemaCXX/typo-correction-crash.cpp

raw
1 // RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
2 auto check1() {
3 return 1;
4 return s; // expected-error {{use of undeclared identifier 's'}}
5 }
6
7 int test = 11; // expected-note 3 {{'test' declared here}}
8 auto 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
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
17 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");
20 auto L2 = [] { return tes; }; // expected-error {{use of undeclared identifier 'tes'}}
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
32 void cast_expr(int g) { +int(n)(g); } // expected-error {{undeclared identifier 'n'}}
33
34 void 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
37 namespace NoCrash {
38 class S {
39 void Function(int a) {
40 unknown1(unknown2, Function, unknown3); // expected-error 2{{use of undeclared identifier}}
41 }
42 };
43 }
44
45 namespace NoCrashOnCheckArgAlignment {
46 template <typename a> void b(a &);
47 void test() {
48 for (auto file_data :b(files_db_data)); // expected-error {{use of undeclared identifier 'files_db_data'}}
49 }
50 }