]> granicus.if.org Git - clang/commitdiff
Don't put too much thought into whether or not to capture a
authorJohn McCall <rjmccall@apple.com>
Tue, 16 Apr 2013 22:32:04 +0000 (22:32 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 16 Apr 2013 22:32:04 +0000 (22:32 +0000)
type-dependent intermediate result in a postfix ++ pseudo-
object operation.

Test case by Tong Shen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179637 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaPseudoObject.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index 560efa5a4ef7e51bb5c303cec63fd7ea83044be8..795cfbacfba8498fd6f9d722309542168c681396 100644 (file)
@@ -441,7 +441,8 @@ PseudoOpBuilder::buildIncDecOperation(Scope *Sc, SourceLocation opcLoc,
   QualType resultType = result.get()->getType();
 
   // That's the postfix result.
-  if (UnaryOperator::isPostfix(opcode) && CanCaptureValueOfType(resultType)) {
+  if (UnaryOperator::isPostfix(opcode) &&
+      (result.get()->isTypeDependent() || CanCaptureValueOfType(resultType))) {
     result = capture(result.take());
     setResultToLastSemantic();
   }
index 07b93face9592547763a5bc2d0d3b0620d3b954d..ab3ff69f27be0a442d7f983ed047f41f789ef8b5 100644 (file)
@@ -302,13 +302,14 @@ struct SP9 {
   T GetV() { return 0; }
   void SetV(T v) {}
   void f() { V = this->V; V < this->V; }
-  //void g() { V++; }
-  //void h() { V*=2; }
+  void g() { V++; }
+  void h() { V*=2; }
 };
 struct SP10 {
   SP10(int v) {}
   bool operator<(const SP10& v) { return true; }
   SP10 operator*(int v) { return *this; }
+  SP10 operator+(int v) { return *this; }
   SP10& operator=(const SP10& v) { return *this; }
 };
 void TestSP9() {
@@ -329,6 +330,6 @@ void TestSP9() {
 
   SP9<SP10> c3;
   c3.f(); // Overloaded binary op operand
-  //c3.g(); // Overloaded incdec op operand
-  //c3.h(); // Overloaded unary op operand
+  c3.g(); // Overloaded incdec op operand
+  c3.h(); // Overloaded unary op operand
 }