[cfe-commits] r128806 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/operator-arrow-temporary.cpp

Eli Friedman eli.friedman at gmail.com
Sun Apr 3 18:18:25 PDT 2011


Author: efriedma
Date: Sun Apr  3 20:18:25 2011
New Revision: 128806

URL: http://llvm.org/viewvc/llvm-project?rev=128806&view=rev
Log:
PR9615: make sure we destroy any temporaries returned by operator->.

I'm pretty sure this is the right fix, but I would appreciate it if someone
else would double-check.


Added:
    cfe/trunk/test/SemaCXX/operator-arrow-temporary.cpp
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=128806&r1=128805&r2=128806&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Sun Apr  3 20:18:25 2011
@@ -8934,7 +8934,8 @@
   if (CheckCallReturnType(Method->getResultType(), OpLoc, TheCall,
                           Method))
           return ExprError();
-  return Owned(TheCall);
+
+  return MaybeBindToTemporary(TheCall);
 }
 
 /// FixOverloadedFunctionReference - E is an expression that refers to

Added: cfe/trunk/test/SemaCXX/operator-arrow-temporary.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/operator-arrow-temporary.cpp?rev=128806&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/operator-arrow-temporary.cpp (added)
+++ cfe/trunk/test/SemaCXX/operator-arrow-temporary.cpp Sun Apr  3 20:18:25 2011
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR9615
+
+struct Resource {
+  void doit();
+};
+
+template<int x> struct Lock {
+  ~Lock() { int a[x]; } // expected-error {{declared as an array with a negative size}}
+  Resource* operator->() { return 0; }
+};
+
+struct Accessor {
+  Lock<-1> operator->();
+};
+
+// Make sure we try to instantiate the destructor for Lock here
+void f() { Accessor acc; acc->doit(); } // expected-note {{requested here}}
+





More information about the cfe-commits mailing list