From: Kaelyn Takata Date: Fri, 1 May 2015 19:36:25 +0000 (+0000) Subject: Eagerly correct typos in ParenExprs that may be type casts for non-C++ code. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=850c9f6e8fc9ce6815154015de03eede3812b8a6;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236337 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index e889085b82..5116991c0f 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/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/test/Sema/typo-correction.c b/test/Sema/typo-correction.c index be9a1f3e48..d457257b3c 100644 --- a/test/Sema/typo-correction.c +++ b/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'}} +}