]> granicus.if.org Git - clang/commitdiff
Replace completely bogus ambiguous-compound-literal-in-C++ code with something
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 15 May 2014 02:51:15 +0000 (02:51 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 15 May 2014 02:51:15 +0000 (02:51 +0000)
that isn't always wrong.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208844 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExprCXX.cpp
test/Parser/compound_literal.c

index f1d6c8d64282d0178e12e1a32a48a7ebb0fbff3b..26ff273705b94798051d229bc4bddc1a478d9ddd 100644 (file)
@@ -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());
index 9a0e4a64a6547c64eb1020ac1d4764b306133ad7..00544996e3c1ac65cfdf09ce29b963e6b8b4a351 100644 (file)
@@ -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};
 }