1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // Check the following typo correction behavior:
4 // - multiple typos in a single member call chain are all diagnosed
5 // - no typos are diagnosed for multiple typos in an expression when not all
6 // typos can be corrected
11 void trigger() const; // expected-note {{'trigger' declared here}}
17 const DeepClass
& getX() const { return m_deepInstance
; } // expected-note {{'getX' declared here}}
19 DeepClass m_deepInstance
;
26 const Y
& getY0() const { return m_y0
; } // expected-note {{'getY0' declared here}}
27 const Y
& getActiveY() const { return m_y0
; }
36 void testMultipleCorrections()
38 z_obj
.getY2(). // expected-error {{no member named 'getY2' in 'Z'; did you mean 'getY0'}}
39 getM(). // expected-error {{no member named 'getM' in 'Y'; did you mean 'getX'}}
40 triggee(); // expected-error {{no member named 'triggee' in 'DeepClass'; did you mean 'trigger'}}
43 void testNoCorrections()
45 z_obj
.getY2(). // expected-error {{no member named 'getY2' in 'Z'}}
47 thisDoesntSeemToMakeSense();
51 struct D
{ int value
; };
56 D
get_me_a_D(); // expected-note {{'get_me_a_D' declared here}}
61 B
make_a_B(); // expected-note {{'make_a_B' declared here}}
66 int testDiscardedCorrections() {
67 return scope_obj
.make_an_E(). // expected-error {{no member named 'make_an_E' in 'Scope'; did you mean 'make_a_B'}}
68 get_me_a_Z().value
; // expected-error {{no member named 'get_me_a_Z' in 'B'; did you mean 'get_me_a_D'}}
71 class AmbiguousHelper
{
81 AmbiguousHelper
getHelp1();
82 AmbiguousHelper
getHelp2();
85 Ambiguous ambiguous_obj
;
87 int testDirectAmbiguousCorrection() {
88 return ambiguous_obj
.calculateZ(); // expected-error {{no member named 'calculateZ' in 'Ambiguous'}}
91 int testRecursiveAmbiguousCorrection() {
92 return ambiguous_obj
.getHelp3(). // expected-error {{no member named 'getHelp3' in 'Ambiguous'}}
97 class DeepAmbiguityHelper
{
99 DeepAmbiguityHelper
& help1();
100 DeepAmbiguityHelper
& help2();
102 DeepAmbiguityHelper
& methodA();
103 DeepAmbiguityHelper
& somethingMethodB();
104 DeepAmbiguityHelper
& functionC();
105 DeepAmbiguityHelper
& deepMethodD();
106 DeepAmbiguityHelper
& asDeepAsItGets();
109 DeepAmbiguityHelper deep_obj
;
111 int testDeepAmbiguity() {
113 methodB(). // expected-error {{no member named 'methodB' in 'DeepAmbiguityHelper'}}
123 int age
; //expected-note{{'age' declared here}}
124 int size
; //expected-note{{'size' declared here}}
127 int from_dog_years(int DogYears
, int DogSize
);
128 int get_dog_years() {
130 return from_dog_years(doggo
.agee
, //expected-error{{no member named 'agee' in 'Dog'; did you mean 'age'}}
131 doggo
.sizee
); //expected-error{{no member named 'sizee' in 'Dog'; did you mean 'size'}}