diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-09-18 19:38:38 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-09-18 19:38:38 +0000 |
commit | 1fb019bf42f5757c027edb56e5bb70233787a39c (patch) | |
tree | 9c0c0bd8c25faa70b59827d4dfaa216fbfeceb16 /lib/Sema/SemaExpr.cpp | |
parent | 97fe61ca1749110c28eb4570a710c8983711c7b3 (diff) |
Problem with gnu conditional extension with missing
LHS and when conditional expression is an array. Since
it will be decayed, saved expression must be saved with
decayed expression. This is necessary to preserve semantics
of this extension (and prevent an IRGen crash which expects
an array to always be decayed). I am sure there will be other
cases in c++ (aggregate conditionals for example) when saving of the
expression must happen after some transformation on conditional
expression has happened.
Doug, please review. Fixes // rdar://8446940
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114296 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index c65db7e835..4bd596b672 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4203,13 +4203,18 @@ ExprResult Sema::ActOnParenOrParenListExpr(SourceLocation L, /// In that case, lhs = cond. /// C99 6.5.15 QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, + Expr *&SAVE, SourceLocation QuestionLoc) { // C++ is sufficiently different to merit its own checker. if (getLangOptions().CPlusPlus) - return CXXCheckConditionalOperands(Cond, LHS, RHS, QuestionLoc); + return CXXCheckConditionalOperands(Cond, LHS, RHS, SAVE, QuestionLoc); UsualUnaryConversions(Cond); - UsualUnaryConversions(LHS); + if (SAVE) { + SAVE = LHS = Cond; + } + else + UsualUnaryConversions(LHS); UsualUnaryConversions(RHS); QualType CondTy = Cond->getType(); QualType LHSTy = LHS->getType(); @@ -4534,8 +4539,8 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc, LHSExpr = SAVEExpr = CondExpr; } - QualType result = CheckConditionalOperands(CondExpr, LHSExpr, - RHSExpr, QuestionLoc); + QualType result = CheckConditionalOperands(CondExpr, LHSExpr, RHSExpr, + SAVEExpr, QuestionLoc); if (result.isNull()) return ExprError(); |