[cfe-commits] r114820 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/compound-literal.c
Abramo Bagnara
abramo.bagnara at gmail.com
Mon Sep 27 00:13:33 PDT 2010
Author: abramo
Date: Mon Sep 27 02:13:32 2010
New Revision: 114820
URL: http://llvm.org/viewvc/llvm-project?rev=114820&view=rev
Log:
Fixed isConstantInitializer for __builtin_choose_expr.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/Sema/compound-literal.c
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=114820&r1=114819&r2=114820&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Sep 27 02:13:32 2010
@@ -1764,6 +1764,9 @@
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)
Modified: cfe/trunk/test/Sema/compound-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/compound-literal.c?rev=114820&r1=114819&r2=114820&view=diff
==============================================================================
--- cfe/trunk/test/Sema/compound-literal.c (original)
+++ cfe/trunk/test/Sema/compound-literal.c Mon Sep 27 02:13:32 2010
@@ -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}}
More information about the cfe-commits
mailing list