Clang Project

clang_source_code/test/SemaCXX/typo-correction-cxx11.cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2
3namespace PR23186 {
4decltype(ned);  // expected-error-re {{use of undeclared identifier 'ned'{{$}}}}
5// The code below was triggering an UNREACHABLE in ASTContext::getTypeInfoImpl
6// once the above code failed to recover properly after making the bogus
7// correction of 'ned' to 'new'.
8template <typename>
9struct S {
10  enum { V };
11  void f() {
12    switch (0)
13    case V:
14      ;
15  }
16};
17}
18
19namespace PR23140 {
20auto lneed = gned.*[] {};  // expected-error-re {{use of undeclared identifier 'gned'{{$}}}}
21
22void test(int aaa, int bbb, int thisvar) {  // expected-note {{'thisvar' declared here}}
23  int thatval = aaa * (bbb + thatvar);  // expected-error {{use of undeclared identifier 'thatvar'; did you mean 'thisvar'?}}
24}
25}
26
27namespace PR18854 {
28void f() {
29  for (auto&& x : e) {  // expected-error-re {{use of undeclared identifier 'e'{{$}}}}
30    auto Functor = [x]() {};
31    long Alignment = __alignof__(Functor);
32  }
33}
34}
35
36namespace NewTypoExprFromResolvingTypoAmbiguity {
37struct A {
38  void Swap(A *other);
39};
40
41struct pair {
42  int first;
43  A *second;
44};
45
46struct map {
47public:
48  void swap(map &x);
49  pair find(int x);
50};
51
52void run(A *annotations) {
53  map new_annotations;
54
55  auto &annotation = *annotations;
56  auto new_it = new_annotations.find(5);
57  auto &new_anotation = new_it.second;  // expected-note {{'new_anotation' declared here}}
58  new_annotation->Swap(&annotation);  // expected-error {{use of undeclared identifier 'new_annotation'; did you mean 'new_anotation'?}}
59}
60}
61