summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorKaelyn Takata <rikka@google.com>2015-05-01 19:36:25 +0000
committerKaelyn Takata <rikka@google.com>2015-05-01 19:36:25 +0000
commit5a5319062300166a747807339349766341a2c2b2 (patch)
treeeb7754fd23e4587b49e7c22831519d5201d7c9cf /clang
parent06b21daf008f0bb9426d06f819322a8709094838 (diff)
downloadbcm5719-llvm-5a5319062300166a747807339349766341a2c2b2.tar.gz
bcm5719-llvm-5a5319062300166a747807339349766341a2c2b2.zip
Eagerly correct typos in ParenExprs that may be type casts for non-C++ code.
This is needed to ensure the type casts are parsed properly. Fixes PR23101. llvm-svn: 236337
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp5
-rw-r--r--clang/test/Sema/typo-correction.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index e889085b829..5116991c0f7 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2285,6 +2285,11 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
InMessageExpressionRAIIObject InMessage(*this, false);
Result = ParseExpression(MaybeTypeCast);
+ if (!getLangOpts().CPlusPlus && MaybeTypeCast && Result.isUsable()) {
+ // Correct typos in non-C++ code earlier so that implicit-cast-like
+ // expressions are parsed correctly.
+ Result = Actions.CorrectDelayedTyposInExpr(Result);
+ }
ExprType = SimpleExpr;
if (isFoldOperator(Tok.getKind()) && NextToken().is(tok::ellipsis))
diff --git a/clang/test/Sema/typo-correction.c b/clang/test/Sema/typo-correction.c
index be9a1f3e482..d457257b3c3 100644
--- a/clang/test/Sema/typo-correction.c
+++ b/clang/test/Sema/typo-correction.c
@@ -34,3 +34,9 @@ int c11Generic(int arg) {
_Generic(hello, int : banana)(); // expected-error-re {{use of undeclared identifier 'hello'{{$}}}}
_Generic(arg, int : bandana)(); // expected-error {{use of undeclared identifier 'bandana'; did you mean 'banana'?}}
}
+
+typedef long long __m128i __attribute__((__vector_size__(16)));
+int PR23101(__m128i __x) {
+ return foo((__v2di)__x); // expected-warning {{implicit declaration of function 'foo'}} \
+ // expected-error {{use of undeclared identifier '__v2di'}}
+}
OpenPOWER on IntegriCloud