]> granicus.if.org Git - clang/commitdiff
For PR22870: produce an error rather than asserting if a designated initializer appea...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 11 Mar 2015 00:12:17 +0000 (00:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 11 Mar 2015 00:12:17 +0000 (00:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231892 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ItaniumMangle.cpp
test/CodeGenCXX/mangle-fail.cpp [new file with mode: 0644]

index 140cdd8b15e677fe2e1f4893d118350e76b63984..13136b36236482da371ec5653a8d20537b5b7e38 100644 (file)
@@ -2673,7 +2673,6 @@ recurse:
   // These all can only appear in local or variable-initialization
   // contexts and so should never appear in a mangling.
   case Expr::AddrLabelExprClass:
-  case Expr::DesignatedInitExprClass:
   case Expr::ImplicitValueInitExprClass:
   case Expr::ParenListExprClass:
   case Expr::LambdaExprClass:
@@ -2685,6 +2684,7 @@ recurse:
   case Expr::BlockExprClass:
   case Expr::ChooseExprClass:
   case Expr::CompoundLiteralExprClass:
+  case Expr::DesignatedInitExprClass:
   case Expr::ExtVectorElementExprClass:
   case Expr::GenericSelectionExprClass:
   case Expr::ObjCEncodeExprClass:
diff --git a/test/CodeGenCXX/mangle-fail.cpp b/test/CodeGenCXX/mangle-fail.cpp
new file mode 100644 (file)
index 0000000..e845bca
--- /dev/null
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -emit-llvm -x c++ -std=c++11 -verify %s -DN=1
+// RUN: %clang_cc1 -emit-llvm -x c++ -std=c++11 -verify %s -DN=2
+// RUN: %clang_cc1 -emit-llvm -x c++ -std=c++11 -verify %s -DN=3
+
+struct A { int a; };
+
+#if N == 1
+// ChooseExpr
+template<class T> void test(int (&)[sizeof(__builtin_choose_expr(true, 1, 1), T())]) {} // expected-error {{cannot yet mangle}}
+template void test<int>(int (&)[sizeof(int)]);
+
+#elif N == 2
+// CompoundLiteralExpr
+template<class T> void test(int (&)[sizeof((A){}, T())]) {} // expected-error {{cannot yet mangle}}
+template void test<int>(int (&)[sizeof(A)]);
+
+#elif N == 3
+// DesignatedInitExpr
+template<class T> void test(int (&)[sizeof(A{.a = 10}, T())]) {} // expected-error {{cannot yet mangle}}
+template void test<int>(int (&)[sizeof(A)]);
+
+// FIXME: There are several more cases we can't yet mangle.
+
+#else
+#error unknown N
+#endif