]> granicus.if.org Git - clang/commitdiff
Force the correction of delayed typos in casts in non-C++ code.
authorKaelyn Takata <rikka@google.com>
Mon, 24 Nov 2014 21:46:59 +0000 (21:46 +0000)
committerKaelyn Takata <rikka@google.com>
Mon, 24 Nov 2014 21:46:59 +0000 (21:46 +0000)
Fixes PR21656, which is fallout from r222551 caused by an untested/missed
code path.

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

lib/Sema/SemaExpr.cpp
test/Sema/typo-correction.c

index fd7c76121db50ab1e887cbc50e93a16c4d4e0c43..223e93e7c3d15d70efaa313bf1ef9b14371f7f74 100644 (file)
@@ -5299,6 +5299,12 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
   if (getLangOpts().CPlusPlus) {
     // Check that there are no default arguments (C++ only).
     CheckExtraCXXDefaultArguments(D);
+  } else {
+    // Make sure any TypoExprs have been dealt with.
+    ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
+    if (!Res.isUsable())
+      return ExprError();
+    CastExpr = Res.get();
   }
 
   checkUnusedDeclAttributes(D);
index e98e5c0069715ec8b51baef52fbd2929b9c614bf..04cf0775f1da978d2033b971026af162fc84095c 100644 (file)
@@ -4,3 +4,8 @@
 // than in C++ and may exhibit different behavior as a result.
 
 __typeof__(struct F*) var[invalid];  // expected-error-re {{use of undeclared identifier 'invalid'{{$}}}}
+
+void PR21656() {
+  float x;
+  x = (float)arst;  // expected-error-re {{use of undeclared identifier 'arst'{{$}}}}
+}