[llvm-branch-commits] [cfe-branch] r168830 - in /cfe/branches/release_32: ./ lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-overload-candidates.cpp

Pawel Wodnicki pawel at 32bitmicro.com
Wed Nov 28 15:44:46 PST 2012


Author: pawel
Date: Wed Nov 28 17:44:46 2012
New Revision: 168830

URL: http://llvm.org/viewvc/llvm-project?rev=168830&view=rev
Log:
Merging r168818: into the 3.2 release branch.

PR13098: If we're instantiating an overloaded binary operator and we could
determine which member function would be the callee from within the template
definition, don't pass that function as a "non-member function" to
CreateOverloadedBinOp. Instead, just rely on it to select the member function
for itself.

Modified:
    cfe/branches/release_32/   (props changed)
    cfe/branches/release_32/lib/Sema/TreeTransform.h
    cfe/branches/release_32/test/SemaTemplate/instantiate-overload-candidates.cpp

Propchange: cfe/branches/release_32/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 28 17:44:46 2012
@@ -1,3 +1,3 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:167749,167762,167780,167788,167790,167813-167814,167868,167884,167920,167925,167935,168024,168063,168124,168269,168277-168278,168297,168303,168355,168379,168674
+/cfe/trunk:167749,167762,167780,167788,167790,167813-167814,167868,167884,167920,167925,167935,168024,168063,168124,168269,168277-168278,168297,168303,168355,168379,168674,168818
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_32/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/lib/Sema/TreeTransform.h?rev=168830&r1=168829&r2=168830&view=diff
==============================================================================
--- cfe/branches/release_32/lib/Sema/TreeTransform.h (original)
+++ cfe/branches/release_32/lib/Sema/TreeTransform.h Wed Nov 28 17:44:46 2012
@@ -9179,7 +9179,12 @@
     // IsAcceptableNonMemberOperatorCandidate for each of these?
     Functions.append(ULE->decls_begin(), ULE->decls_end());
   } else {
-    Functions.addDecl(cast<DeclRefExpr>(Callee)->getDecl());
+    // If we've resolved this to a particular non-member function, just call
+    // that function. If we resolved it to a member function,
+    // CreateOverloaded* will find that function for us.
+    NamedDecl *ND = cast<DeclRefExpr>(Callee)->getDecl();
+    if (!isa<CXXMethodDecl>(ND))
+      Functions.addDecl(ND);
   }
 
   // Add any functions found via argument-dependent lookup.

Modified: cfe/branches/release_32/test/SemaTemplate/instantiate-overload-candidates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/test/SemaTemplate/instantiate-overload-candidates.cpp?rev=168830&r1=168829&r2=168830&view=diff
==============================================================================
--- cfe/branches/release_32/test/SemaTemplate/instantiate-overload-candidates.cpp (original)
+++ cfe/branches/release_32/test/SemaTemplate/instantiate-overload-candidates.cpp Wed Nov 28 17:44:46 2012
@@ -19,3 +19,34 @@
 void test(int x) {
   f(&x, 0);
 }
+
+// Ensure that we instantiate an overloaded function if it's selected by
+// overload resolution when initializing a function pointer.
+template<typename T> struct X {
+  static T f() { T::error; } // expected-error {{has no members}}
+  static T f(bool);
+};
+void (*p)() = &X<void>().f; // expected-note {{instantiation of}}
+
+namespace PR13098 {
+  struct A {
+    A(int);
+    void operator++() {}
+    void operator+(int) {}
+    void operator+(A) {}
+    void operator[](int) {}
+    void operator[](A) {}
+  };
+  struct B : A {
+    using A::operator++;
+    using A::operator+;
+    using A::operator[];
+  };
+  template<typename T> void f(B b) {
+    ++b;
+    b + 0;
+    b[0];
+  }
+  template void f<void>(B);
+}
+





More information about the llvm-branch-commits mailing list