зеркало из https://github.com/microsoft/clang-1.git
Fix rdar://6095061 - gcc allows __builtin_choose_expr as an lvalue
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60924 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
f345accce0
Коммит
670a62cd1d
|
@ -467,6 +467,13 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const {
|
|||
}
|
||||
case CompoundLiteralExprClass: // C99 6.5.2.5p5
|
||||
return LV_Valid;
|
||||
case ChooseExprClass:
|
||||
// __builtin_choose_expr is an lvalue if the selected operand is.
|
||||
if (cast<ChooseExpr>(this)->isConditionTrue(Ctx))
|
||||
return cast<ChooseExpr>(this)->getLHS()->isLvalue(Ctx);
|
||||
else
|
||||
return cast<ChooseExpr>(this)->getRHS()->isLvalue(Ctx);
|
||||
|
||||
case ExtVectorElementExprClass:
|
||||
if (cast<ExtVectorElementExpr>(this)->containsDuplicateElements())
|
||||
return LV_DuplicateVectorComponents;
|
||||
|
@ -476,7 +483,7 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const {
|
|||
case ObjCPropertyRefExprClass: // FIXME: check if read-only property.
|
||||
return LV_Valid;
|
||||
case ObjCKVCRefExprClass: // FIXME: check if read-only property.
|
||||
return LV_Valid;
|
||||
return LV_Valid;
|
||||
case PredefinedExprClass:
|
||||
return LV_Valid;
|
||||
case VAArgExprClass:
|
||||
|
@ -1213,8 +1220,7 @@ bool ChooseExpr::isConditionTrue(ASTContext &C) const {
|
|||
return getCond()->getIntegerConstantExprValue(C) != 0;
|
||||
}
|
||||
|
||||
static int64_t evaluateOffsetOf(ASTContext& C, const Expr *E)
|
||||
{
|
||||
static int64_t evaluateOffsetOf(ASTContext& C, const Expr *E) {
|
||||
if (const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
|
||||
QualType Ty = ME->getBase()->getType();
|
||||
|
||||
|
|
|
@ -146,6 +146,12 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
|
|||
case Expr::MemberExprClass: return EmitMemberExpr(cast<MemberExpr>(E));
|
||||
case Expr::CompoundLiteralExprClass:
|
||||
return EmitCompoundLiteralLValue(cast<CompoundLiteralExpr>(E));
|
||||
case Expr::ChooseExprClass:
|
||||
// __builtin_choose_expr is the lvalue of the selected operand.
|
||||
if (cast<ChooseExpr>(E)->isConditionTrue(getContext()))
|
||||
return EmitLValue(cast<ChooseExpr>(E)->getLHS());
|
||||
else
|
||||
return EmitLValue(cast<ChooseExpr>(E)->getRHS());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,3 +38,10 @@ void test7(int *P, _Complex float Gamma) {
|
|||
P = (P-42) + Gamma*4; // expected-error {{invalid operands to binary expression ('int *' and '_Complex float')}}
|
||||
}
|
||||
|
||||
|
||||
// rdar://6095061
|
||||
int test8(void) {
|
||||
int i;
|
||||
__builtin_choose_expr (0, 42, i) = 10;
|
||||
return i;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче