For PR22870: produce an error rather than asserting if a designated initializer appears in a signature.

llvm-svn: 231892
This commit is contained in:
Richard Smith 2015-03-11 00:12:17 +00:00
parent e93bcd1752
commit ed1cb88c8a
2 changed files with 27 additions and 1 deletions

View 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:

View File

@ -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