From 6aea57560fa50112f1d2be10de0650ce1eca6854 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 22 Jul 2009 22:25:00 +0000 Subject: [PATCH] Slight code reorganization to allow instantiating post-inc/dec. llvm-svn: 76807 --- clang/lib/Sema/SemaExpr.cpp | 14 +++++--------- clang/test/SemaTemplate/instantiate-expr-5.cpp | 4 ++++ 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 clang/test/SemaTemplate/instantiate-expr-5.cpp diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 8c780296a7da..bb3f21a21266 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1703,12 +1703,7 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, // build a built-in operation. } - QualType result = CheckIncrementDecrementOperand(Arg, OpLoc, - Opc == UnaryOperator::PostInc); - if (result.isNull()) - return ExprError(); - Input.release(); - return Owned(new (Context) UnaryOperator(Arg, Opc, result, OpLoc)); + return CreateBuiltinUnaryOp(OpLoc, Opc, move(Input)); } Action::OwningExprResult @@ -5014,16 +5009,17 @@ Action::OwningExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, Expr *Input = (Expr *)InputArg.get(); QualType resultType; switch (Opc) { - case UnaryOperator::PostInc: - case UnaryOperator::PostDec: case UnaryOperator::OffsetOf: assert(false && "Invalid unary operator"); break; case UnaryOperator::PreInc: case UnaryOperator::PreDec: + case UnaryOperator::PostInc: + case UnaryOperator::PostDec: resultType = CheckIncrementDecrementOperand(Input, OpLoc, - Opc == UnaryOperator::PreInc); + Opc == UnaryOperator::PreInc || + Opc == UnaryOperator::PostInc); break; case UnaryOperator::AddrOf: resultType = CheckAddressOfOperand(Input, OpLoc); diff --git a/clang/test/SemaTemplate/instantiate-expr-5.cpp b/clang/test/SemaTemplate/instantiate-expr-5.cpp new file mode 100644 index 000000000000..b42c0fb2aaf8 --- /dev/null +++ b/clang/test/SemaTemplate/instantiate-expr-5.cpp @@ -0,0 +1,4 @@ +// RUN: clang-cc -fsyntax-only %s + +template int x(A x) { return x++; } +int y() { return x(1); }