From 9025ec2ee55bf8098f928c2f55e2316c861fcb55 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Mon, 21 Dec 2009 01:42:38 +0000 Subject: Fix for PR5840: fix the kind of name lookup used for classes in Sema::getTypeName. "LookupNestedNameSpecifierName" isn't quite the right kind of lookup, though; it doesn't ignore namespaces. Someone more familiar with the lookup code should fix this properly. llvm-svn: 91809 --- clang/lib/Sema/SemaDecl.cpp | 8 ++++++-- clang/test/CXX/class.derived/p2.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 clang/test/CXX/class.derived/p2.cpp (limited to 'clang') diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f087bcb95cf..d83f8527486 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -106,8 +106,12 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, if (!LookupCtx->isDependentContext() && RequireCompleteDeclContext(*SS)) return 0; } - - LookupResult Result(*this, &II, NameLoc, LookupOrdinaryName); + + // FIXME: LookupNestedNameSpecifierName isn't the right kind of + // lookup for class-names. + LookupNameKind Kind = isClassName ? LookupNestedNameSpecifierName : + LookupOrdinaryName; + LookupResult Result(*this, &II, NameLoc, Kind); if (LookupCtx) { // Perform "qualified" name lookup into the declaration context we // computed, which is either the type of the base of a member access diff --git a/clang/test/CXX/class.derived/p2.cpp b/clang/test/CXX/class.derived/p2.cpp new file mode 100644 index 00000000000..7ef53d36ab7 --- /dev/null +++ b/clang/test/CXX/class.derived/p2.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify + +// "During the lookup for a base class name, non-type names are ignored" +namespace PR5840 { + struct Base {}; + int Base = 10; + struct Derived : Base {}; +} -- cgit v1.2.3