From 4714fcc86a8bb646a4dff0f5b6aa98b1c024b6f7 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 11 Mar 2015 00:12:17 +0000 Subject: [PATCH] For PR22870: produce an error rather than asserting if a designated initializer appears in a signature. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231892 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ItaniumMangle.cpp | 2 +- test/CodeGenCXX/mangle-fail.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/CodeGenCXX/mangle-fail.cpp diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index 140cdd8b15..13136b3623 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -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 index 0000000000..e845bcab8a --- /dev/null +++ b/test/CodeGenCXX/mangle-fail.cpp @@ -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 void test(int (&)[sizeof(__builtin_choose_expr(true, 1, 1), T())]) {} // expected-error {{cannot yet mangle}} +template void test(int (&)[sizeof(int)]); + +#elif N == 2 +// CompoundLiteralExpr +template void test(int (&)[sizeof((A){}, T())]) {} // expected-error {{cannot yet mangle}} +template void test(int (&)[sizeof(A)]); + +#elif N == 3 +// DesignatedInitExpr +template void test(int (&)[sizeof(A{.a = 10}, T())]) {} // expected-error {{cannot yet mangle}} +template void test(int (&)[sizeof(A)]); + +// FIXME: There are several more cases we can't yet mangle. + +#else +#error unknown N +#endif -- 2.40.0