r179637 - Don't put too much thought into whether or not to capture a
John McCall
rjmccall at apple.com
Tue Apr 16 15:32:04 PDT 2013
Author: rjmccall
Date: Tue Apr 16 17:32:04 2013
New Revision: 179637
URL: http://llvm.org/viewvc/llvm-project?rev=179637&view=rev
Log:
Don't put too much thought into whether or not to capture a
type-dependent intermediate result in a postfix ++ pseudo-
object operation.
Test case by Tong Shen.
Modified:
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
Modified: cfe/trunk/lib/Sema/SemaPseudoObject.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaPseudoObject.cpp?rev=179637&r1=179636&r2=179637&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/trunk/lib/Sema/SemaPseudoObject.cpp Tue Apr 16 17:32:04 2013
@@ -441,7 +441,8 @@ PseudoOpBuilder::buildIncDecOperation(Sc
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();
}
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=179637&r1=179636&r2=179637&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Tue Apr 16 17:32:04 2013
@@ -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
}
More information about the cfe-commits
mailing list