diff options
| author | Abramo Bagnara <abramo.bagnara@gmail.com> | 2010-09-27 07:13:32 +0000 |
|---|---|---|
| committer | Abramo Bagnara <abramo.bagnara@gmail.com> | 2010-09-27 07:13:32 +0000 |
| commit | b59a5b678442a54db3e3eef5b0d044e09386c3a5 (patch) | |
| tree | d35640d14c1bbec86b3e3985473fc47ad7fdef9f | |
| parent | 972c60d82129a94083317bb1babf122745b72f13 (diff) | |
| download | bcm5719-llvm-b59a5b678442a54db3e3eef5b0d044e09386c3a5.tar.gz bcm5719-llvm-b59a5b678442a54db3e3eef5b0d044e09386c3a5.zip | |
Fixed isConstantInitializer for __builtin_choose_expr.
llvm-svn: 114820
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 3 | ||||
| -rw-r--r-- | clang/test/Sema/compound-literal.c | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index b31ec2314dc..dbfe2d52b88 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1764,6 +1764,9 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef) const { case ParenExprClass: return cast<ParenExpr>(this)->getSubExpr() ->isConstantInitializer(Ctx, IsForRef); + case ChooseExprClass: + return cast<ChooseExpr>(this)->getChosenSubExpr(Ctx) + ->isConstantInitializer(Ctx, IsForRef); case UnaryOperatorClass: { const UnaryOperator* Exp = cast<UnaryOperator>(this); if (Exp->getOpcode() == UO_Extension) diff --git a/clang/test/Sema/compound-literal.c b/clang/test/Sema/compound-literal.c index aade4641ace..41307625999 100644 --- a/clang/test/Sema/compound-literal.c +++ b/clang/test/Sema/compound-literal.c @@ -3,9 +3,10 @@ struct foo { int a, b; }; static struct foo t = (struct foo){0,0}; -static struct foo t2 = {0,0}; +static struct foo t1 = __builtin_choose_expr(0, (struct foo){0,0}, (struct foo){0,0}); +static struct foo t2 = {0,0}; static struct foo t3 = t2; // -expected-error {{initializer element is not a compile-time constant}} -static int *p = (int []){2,4}; +static int *p = (int []){2,4}; static int x = (int){1}; static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not a compile-time constant}} |

