Look at whether TransformTypos returned a different Expr instead of looking at the...
authorNick Lewycky <nicholas@mxc.ca>
Tue, 16 Dec 2014 22:02:06 +0000 (22:02 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Tue, 16 Dec 2014 22:02:06 +0000 (22:02 +0000)
Fixes PR21925!

llvm-svn: 224380

clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/typo-correction-delayed.cpp

index 28fb054..2d3d127 100644 (file)
@@ -6208,10 +6208,11 @@ ExprResult Sema::CorrectDelayedTyposInExpr(
     auto TyposResolved = DelayedTypos.size();
     auto Result = TransformTypos(*this, Filter).Transform(E);
     TyposResolved -= DelayedTypos.size();
-    if (TyposResolved) {
+    if (Result.isInvalid() || Result.get() != E) {
       ExprEvalContexts.back().NumTypos -= TyposResolved;
       return Result;
     }
+    assert(TyposResolved == 0 && "Corrected typo but got same Expr back?");
   }
   return E;
 }
index 7879d29..c91fb6c 100644 (file)
@@ -130,3 +130,16 @@ void UseOverload() {
   // expected-error@+1 {{use of undeclared identifier 'resulta'; did you mean 'result'?}}
   Overload(resulta);
 }
+
+namespace PR21925 {
+struct X {
+  int get() { return 7; }  // expected-note {{'get' declared here}}
+};
+void test() {
+  X variable;  // expected-note {{'variable' declared here}}
+
+  // expected-error@+2 {{use of undeclared identifier 'variableX'; did you mean 'variable'?}}
+  // expected-error@+1 {{no member named 'getX' in 'PR21925::X'; did you mean 'get'?}}
+  int x = variableX.getX();
+}
+}