From: Kaelyn Takata Date: Mon, 24 Nov 2014 21:46:59 +0000 (+0000) Subject: Force the correction of delayed typos in casts in non-C++ code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ba90762ae771fc55cc99e6b5497f9469aaef1b7;p=clang Force the correction of delayed typos in casts in non-C++ code. 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 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index fd7c76121d..223e93e7c3 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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); diff --git a/test/Sema/typo-correction.c b/test/Sema/typo-correction.c index e98e5c0069..04cf0775f1 100644 --- a/test/Sema/typo-correction.c +++ b/test/Sema/typo-correction.c @@ -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'{{$}}}} +}