From: Richard Smith Date: Thu, 15 May 2014 02:51:15 +0000 (+0000) Subject: Replace completely bogus ambiguous-compound-literal-in-C++ code with something X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=537ec10ebce2ac701473e89cefff99a637b22c6c;p=clang Replace completely bogus ambiguous-compound-literal-in-C++ code with something that isn't always wrong. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208844 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index f1d6c8d642..26ff273705 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -2998,8 +2998,10 @@ Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType, if (ParseAs == CompoundLiteral) { ExprType = CompoundLiteral; - // FIXME: This is entirely wrong. - TypeResult Ty = ParseTypeName(); + if (DeclaratorInfo.isInvalidType()) + return ExprError(); + + TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); return ParseCompoundLiteralExpression(Ty.get(), Tracker.getOpenLocation(), Tracker.getCloseLocation()); diff --git a/test/Parser/compound_literal.c b/test/Parser/compound_literal.c index 9a0e4a64a6..00544996e3 100644 --- a/test/Parser/compound_literal.c +++ b/test/Parser/compound_literal.c @@ -1,6 +1,8 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s // expected-no-diagnostics int main() { char *s; - s = (char []){"whatever"}; + s = (char []){"whatever"}; + s = (char(*)){s}; }