aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-12 08:25:50 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-12 08:25:50 +0000
commit9d35097bc0fefb2f77638be513cac72d1c09d840 (patch)
treead5b69bcbb3f896a7e7a52ded70a4e36ffae405f /lib/Sema/SemaDecl.cpp
parent5d46315ca3cbbfe0d0f5f65520b618fb05dd4446 (diff)
Enable out-of-line definitions of C++ constructors and destructors
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 29d636fabd..2c5e46afa0 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -246,6 +246,24 @@ Decl *Sema::LookupDecl(DeclarationName Name, unsigned NSI, Scope *S,
} else if (LookupCtx) {
assert(getLangOptions().CPlusPlus && "No qualified name lookup in C");
+ switch (Name.getNameKind()) {
+ case DeclarationName::CXXConstructorName:
+ if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(LookupCtx))
+ return const_cast<CXXRecordDecl *>(Record)->getConstructors();
+ else
+ return 0;
+
+ case DeclarationName::CXXDestructorName:
+ if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(LookupCtx))
+ return Record->getDestructor();
+ else
+ return 0;
+
+ default:
+ // Normal name lookup.
+ break;
+ }
+
// Perform qualified name lookup into the LookupCtx.
// FIXME: Will need to look into base classes and such.
DeclContext::lookup_const_iterator I, E;
@@ -932,6 +950,15 @@ Sema::ActOnDeclarator(Scope *S, Declarator &D, DeclTy *lastDecl) {
// after the point of declaration in a namespace that encloses the
// declarations namespace.
//
+ // FIXME: We need to perform this check later, once we know that
+ // we've actually found a redeclaration. Otherwise, just the fact
+ // that there is some entity with the same name will suppress this
+ // diagnostic, e.g., we fail to diagnose:
+ // class X {
+ // void f();
+ // };
+ //
+ // void X::f(int) { } // ill-formed, but we don't complain.
if (PrevDecl == 0) {
// No previous declaration in the qualifying scope.
Diag(D.getIdentifierLoc(), diag::err_typecheck_no_member)