]> granicus.if.org Git - clang/commitdiff
Slight code reorganization to allow instantiating post-inc/dec.
authorEli Friedman <eli.friedman@gmail.com>
Wed, 22 Jul 2009 22:25:00 +0000 (22:25 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Wed, 22 Jul 2009 22:25:00 +0000 (22:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76807 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaTemplate/instantiate-expr-5.cpp [new file with mode: 0644]

index 8c780296a7da4b843c81aef39d529687b990043b..bb3f21a21266efc6c34c9a8930901d12f3ffeece 100644 (file)
@@ -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/test/SemaTemplate/instantiate-expr-5.cpp b/test/SemaTemplate/instantiate-expr-5.cpp
new file mode 100644 (file)
index 0000000..b42c0fb
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: clang-cc -fsyntax-only %s
+
+template <class A> int x(A x) { return x++; }
+int y() { return x<int>(1); }