From 13da33fdfe480ac6ecbddf95524cc870dc9bd4ef Mon Sep 17 00:00:00 2001 From: Kaelyn Takata Date: Mon, 24 Nov 2014 21:46:59 +0000 Subject: [PATCH] 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. llvm-svn: 222694 --- clang/lib/Sema/SemaExpr.cpp | 6 ++++++ clang/test/Sema/typo-correction.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index fd7c76121db5..223e93e7c3d1 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/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/clang/test/Sema/typo-correction.c b/clang/test/Sema/typo-correction.c index e98e5c006971..04cf0775f1da 100644 --- a/clang/test/Sema/typo-correction.c +++ b/clang/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'{{$}}}} +}