diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-01-23 02:35:22 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-01-23 02:35:22 +0000 |
commit | 8c382060c9e6668a94f1485dd16f012cda526c5f (patch) | |
tree | 8507fd29444a1ec0fe03387af6facd168cb5100c | |
parent | 9366750a5a97c8aeae1df4898ea849b087865195 (diff) |
Make sure the AST correctly represents lvalue-to-rvalue conversions where appropriate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148673 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 19 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 2 |
4 files changed, 21 insertions, 9 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 06525a42e4..dbb0a0efaa 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -722,6 +722,12 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // casts here. // FIXME: We don't allow floating point scalars as input. Expr *FirstArg = TheCall->getArg(0); + ExprResult FirstArgResult = DefaultFunctionArrayLvalueConversion(FirstArg); + if (FirstArgResult.isInvalid()) + return ExprError(); + FirstArg = FirstArgResult.take(); + TheCall->setArg(0, FirstArg); + const PointerType *pointerType = FirstArg->getType()->getAs<PointerType>(); if (!pointerType) { Diag(DRE->getLocStart(), diag::err_atomic_builtin_must_be_pointer) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index d68c851d63..6a24d9e430 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2505,9 +2505,12 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, // Create a reference to the iteration variable. ExprResult IterationVarRef - = SemaRef.BuildDeclRefExpr(IterationVar, SizeType, VK_RValue, Loc); + = SemaRef.BuildDeclRefExpr(IterationVar, SizeType, VK_LValue, Loc); assert(!IterationVarRef.isInvalid() && "Reference to invented variable cannot fail!"); + IterationVarRef = SemaRef.DefaultLvalueConversion(IterationVarRef.take()); + assert(!IterationVarRef.isInvalid() && + "Conversion of invented variable cannot fail!"); // Subscript the array with this iteration variable. CtorArg = SemaRef.CreateBuiltinArraySubscriptExpr(CtorArg.take(), Loc, @@ -7630,9 +7633,11 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, // Create a reference to the iteration variable; we'll use this several // times throughout. Expr *IterationVarRef - = S.BuildDeclRefExpr(IterationVar, SizeType, VK_RValue, Loc).take(); + = S.BuildDeclRefExpr(IterationVar, SizeType, VK_LValue, Loc).take(); assert(IterationVarRef && "Reference to invented variable cannot fail!"); - + Expr *IterationVarRefRVal = S.DefaultLvalueConversion(IterationVarRef).take(); + assert(IterationVarRefRVal && "Conversion of invented variable cannot fail!"); + // Create the DeclStmt that holds the iteration variable. Stmt *InitStmt = new (S.Context) DeclStmt(DeclGroupRef(IterationVar),Loc,Loc); @@ -7640,7 +7645,7 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, llvm::APInt Upper = ArrayTy->getSize().zextOrTrunc(S.Context.getTypeSize(SizeType)); Expr *Comparison - = new (S.Context) BinaryOperator(IterationVarRef, + = new (S.Context) BinaryOperator(IterationVarRefRVal, IntegerLiteral::Create(S.Context, Upper, SizeType, Loc), BO_NE, S.Context.BoolTy, VK_RValue, OK_Ordinary, Loc); @@ -7652,9 +7657,11 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, // Subscript the "from" and "to" expressions with the iteration variable. From = AssertSuccess(S.CreateBuiltinArraySubscriptExpr(From, Loc, - IterationVarRef, Loc)); + IterationVarRefRVal, + Loc)); To = AssertSuccess(S.CreateBuiltinArraySubscriptExpr(To, Loc, - IterationVarRef, Loc)); + IterationVarRefRVal, + Loc)); if (!Copying) // Cast to rvalue From = CastForMoving(S, From); diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index f0b31fd0f1..edc5b08900 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -993,8 +993,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, // C++ 5.3.4p6: "The expression in a direct-new-declarator shall have integral // or enumeration type with a non-negative value." if (ArraySize && !ArraySize->isTypeDependent()) { - // Eliminate placeholders. - ExprResult ConvertedSize = CheckPlaceholderExpr(ArraySize); + ExprResult ConvertedSize = DefaultFunctionArrayLvalueConversion(ArraySize); if (ConvertedSize.isInvalid()) return ExprError(); ArraySize = ConvertedSize.take(); diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index b9b5b212c3..f741593736 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -495,7 +495,7 @@ Sema::ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, Expr *Cond, if (!Cond) return StmtError(); - CondResult = CheckPlaceholderExpr(Cond); + CondResult = DefaultFunctionArrayLvalueConversion(Cond); if (CondResult.isInvalid()) return StmtError(); |