r222694 - Force the correction of delayed typos in casts in non-C++ code.
Kaelyn Takata
rikka at google.com
Mon Nov 24 13:46:59 PST 2014
Author: rikka
Date: Mon Nov 24 15:46:59 2014
New Revision: 222694
URL: http://llvm.org/viewvc/llvm-project?rev=222694&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/typo-correction.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=222694&r1=222693&r2=222694&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Nov 24 15:46:59 2014
@@ -5299,6 +5299,12 @@ Sema::ActOnCastExpr(Scope *S, SourceLoca
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);
Modified: cfe/trunk/test/Sema/typo-correction.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/typo-correction.c?rev=222694&r1=222693&r2=222694&view=diff
==============================================================================
--- cfe/trunk/test/Sema/typo-correction.c (original)
+++ cfe/trunk/test/Sema/typo-correction.c Mon Nov 24 15:46:59 2014
@@ -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'{{$}}}}
+}
More information about the cfe-commits
mailing list