[cfe-commits] r88938 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-overloaded-arrow.cpp

Eli Friedman eli.friedman at gmail.com
Mon Nov 16 11:13:04 PST 2009


Author: efriedma
Date: Mon Nov 16 13:13:03 2009
New Revision: 88938

URL: http://llvm.org/viewvc/llvm-project?rev=88938&view=rev
Log:
Fix PR5488: special-case the overloaded arrow operator so that we don't try to
treat it as a unary operator.


Added:
    cfe/trunk/test/SemaTemplate/instantiate-overloaded-arrow.cpp
Modified:
    cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=88938&r1=88937&r2=88938&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Nov 16 13:13:03 2009
@@ -5390,6 +5390,9 @@
       return getSema().CreateBuiltinArraySubscriptExpr(move(First),
                                                        DRE->getLocStart(),
                                                        move(Second), OpLoc);
+  } else if (Op == OO_Arrow) {
+    // -> is never a builtin operation.
+    return SemaRef.BuildOverloadedArrowExpr(0, move(First), OpLoc);
   } else if (SecondExpr == 0 || isPostIncDec) {
     if (!FirstExpr->getType()->isOverloadableType()) {
       // The argument is not of overloadable type, so try to create a

Added: cfe/trunk/test/SemaTemplate/instantiate-overloaded-arrow.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-overloaded-arrow.cpp?rev=88938&view=auto

==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-overloaded-arrow.cpp (added)
+++ cfe/trunk/test/SemaTemplate/instantiate-overloaded-arrow.cpp Mon Nov 16 13:13:03 2009
@@ -0,0 +1,20 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+// PR5488
+
+struct X {
+  int x;
+};
+
+struct Iter {
+  X* operator->();
+};
+
+template <typename T>
+void Foo() {
+  (void)Iter()->x;
+}
+
+void Func() {
+  Foo<int>();
+}
+





More information about the cfe-commits mailing list