From fee942d150f4e876ce9c64a018ef07b5060256a1 Mon Sep 17 00:00:00 2001 From: John McCall Date: Thu, 2 Dec 2010 02:07:15 +0000 Subject: [PATCH] Perform lvalue-to-rvalue at the end of an expression statement in C. llvm-svn: 120646 --- clang/lib/Sema/SemaExprCXX.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index f5d7170e5cda..f6bfee91eedc 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3515,6 +3515,18 @@ ExprResult Sema::ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation, ExprResult Sema::ActOnFinishFullExpr(Expr *FullExpr) { if (!FullExpr) return ExprError(); + // C99 6.3.2.1: + // [Except in specific positions,] an lvalue that does not have + // array type is converted to the value stored in the + // designated object (and is no longer an lvalue). + // This rule does not apply in C++; however, in ObjC++, we do want + // to do lvalue-to-rvalue conversion on top-level ObjCProperty + // l-values. + if (!FullExpr->isRValue() && + (!getLangOptions().CPlusPlus || + FullExpr->getObjectKind() == OK_ObjCProperty)) + DefaultFunctionArrayLvalueConversion(FullExpr); + CheckImplicitConversions(FullExpr); return MaybeCreateCXXExprWithTemporaries(FullExpr); }