]> granicus.if.org Git - clang/commitdiff
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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224380 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 28fb0545ad26239c6fea5f87031483f86cf9992c..2d3d127618bd7e3e89a3898e5204c55724237a7d 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 7879d299d08b360ecf6c25314c0506a8b1b36a89..c91fb6ca65e3b35abc46d579ba9df7d7c1c2446d 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();
+}
+}