[cfe-commits] r88846 - in /cfe/trunk: lib/Sema/Sema.h test/SemaCXX/using-decl-1.cpp
Douglas Gregor
dgregor at apple.com
Sun Nov 15 00:11:13 PST 2009
Author: dgregor
Date: Sun Nov 15 02:11:13 2009
New Revision: 88846
URL: http://llvm.org/viewvc/llvm-project?rev=88846&view=rev
Log:
When adding the underlying declaration of a decl to a lookup-results
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.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/test/SemaCXX/using-decl-1.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=88846&r1=88845&r2=88846&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Sun Nov 15 02:11:13 2009
@@ -1212,7 +1212,20 @@
/// \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;
}
Modified: cfe/trunk/test/SemaCXX/using-decl-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-1.cpp?rev=88846&r1=88845&r2=88846&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/using-decl-1.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-decl-1.cpp Sun Nov 15 02:11:13 2009
@@ -17,3 +17,24 @@
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);
+ }
+};
More information about the cfe-commits
mailing list