From b0e8e228ff080d01943381aa272655d0eb25bb90 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Fri, 12 Jun 2009 18:53:02 +0000 Subject: [PATCH] Fix PR4365. llvm-svn: 73240 --- clang/lib/Sema/SemaInherit.cpp | 6 ++++++ clang/test/SemaTemplate/dependent-names.cpp | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 clang/test/SemaTemplate/dependent-names.cpp diff --git a/clang/lib/Sema/SemaInherit.cpp b/clang/lib/Sema/SemaInherit.cpp index 1b968f0fbcce..28ca5f64ef59 100644 --- a/clang/lib/Sema/SemaInherit.cpp +++ b/clang/lib/Sema/SemaInherit.cpp @@ -138,6 +138,12 @@ bool Sema::LookupInBases(CXXRecordDecl *Class, // Find the record of the base class subobjects for this type. QualType BaseType = Context.getCanonicalType(BaseSpec->getType()); BaseType = BaseType.getUnqualifiedType(); + + // If a base class of the class template depends on a template-parameter, + // the base class scope is not examined during unqualified name lookup. + // [temp.dep]p3. + if (BaseType->isDependentType()) + continue; // Determine whether we need to visit this base class at all, // updating the count of subobjects appropriately. diff --git a/clang/test/SemaTemplate/dependent-names.cpp b/clang/test/SemaTemplate/dependent-names.cpp new file mode 100644 index 000000000000..95ee2d2b9d1f --- /dev/null +++ b/clang/test/SemaTemplate/dependent-names.cpp @@ -0,0 +1,16 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +typedef double A; +template class B { + typedef int A; +}; + +template struct X : B { + static A a; +}; + +int a0[sizeof(X::a) == sizeof(double) ? 1 : -1]; + +// PR4365. +template class Q; +template class R : Q {T current;};