]> granicus.if.org Git - clang/commitdiff
Fix PR5488: special-case the overloaded arrow operator so that we don't try to
authorEli Friedman <eli.friedman@gmail.com>
Mon, 16 Nov 2009 19:13:03 +0000 (19:13 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 16 Nov 2009 19:13:03 +0000 (19:13 +0000)
treat it as a unary operator.

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

lib/Sema/TreeTransform.h
test/SemaTemplate/instantiate-overloaded-arrow.cpp [new file with mode: 0644]

index e46f9c75d288f7282579641aaffce36448899212..d3dab4b8e132558bf68cc1683e4ea5adef20a9a7 100644 (file)
@@ -5390,6 +5390,9 @@ TreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
       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
diff --git a/test/SemaTemplate/instantiate-overloaded-arrow.cpp b/test/SemaTemplate/instantiate-overloaded-arrow.cpp
new file mode 100644 (file)
index 0000000..7f0ef0c
--- /dev/null
@@ -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>();
+}
+