]> granicus.if.org Git - clang/commitdiff
When adding the underlying declaration of a decl to a lookup-results
authorDouglas Gregor <dgregor@apple.com>
Sun, 15 Nov 2009 08:11:13 +0000 (08:11 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 15 Nov 2009 08:11:13 +0000 (08:11 +0000)
set, expand overloaded function declarations. Long-term, this should
actually be done by the name-lookup code rather than here, but this
part of the code (involving using declarations) is getting a makeover
now and the test-case is useful.

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

lib/Sema/Sema.h
test/SemaCXX/using-decl-1.cpp

index b412882b8549428c0294372d1bc166e5d8d21384..d736dfbac5a8fdff21304fe68e699d9db6b753d4 100644 (file)
@@ -1212,7 +1212,20 @@ public:
 
     /// \brief Add a declaration to these results.
     void addDecl(NamedDecl *D) {
-      Decls.push_back(D->getUnderlyingDecl());
+      // "Flatten" overloaded function declarations to get the underlying
+      // functions.
+      // FIXME: This may not be necessary with the impending using-declarations
+      // rewrite (11/09).
+      if (OverloadedFunctionDecl *Ovl 
+            = dyn_cast<OverloadedFunctionDecl>(D->getUnderlyingDecl())) {
+        for (OverloadedFunctionDecl::function_iterator 
+               F = Ovl->function_begin(),
+               FEnd = Ovl->function_end();
+             F != FEnd; ++F) {
+          Decls.push_back(*F);
+        }
+      } else
+        Decls.push_back(D->getUnderlyingDecl());
       Kind = Found;
     }
 
index 37e101e221ea3cc30a7ab5467042e01a7b3d92dc..42deb27027bf5d0f0d826b99054f7636c0012ef8 100644 (file)
@@ -17,3 +17,24 @@ namespace N {
   
   void f(int) { } // expected-error{{redefinition}}
 }
+
+namespace N {
+  void f(double);
+  void f(long);
+}
+
+struct X0 {
+  void operator()(int);
+  void operator()(long);
+};
+
+struct X1 : X0 {
+  // FIXME: give this operator() a 'float' parameter to test overloading
+  // behavior. It currently fails.
+  void operator()();
+  using X0::operator();
+  
+  void test() {
+    (*this)(1);
+  }
+};