diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index c4086a5bcbf36..6c40e48e2f49b 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -279,9 +279,6 @@ Resolutions to C++ Defect Reports by default. (`CWG2521: User-defined literals and reserved identifiers `_). -- Fix name lookup for a dependent base class that is the current instantiation. - (`CWG591: When a dependent base class is the current instantiation `_). - C Language Changes ------------------ diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index 10b8d524ff897..aefc06e9197cf 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -134,7 +134,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback BaseMatches) const { return false; CXXRecordDecl *Base = - cast_if_present(Ty->getDecl()->getDefinition()); + cast_or_null(Ty->getDecl()->getDefinition()); if (!Base || (Base->isDependentContext() && !Base->isCurrentInstantiation(Record))) { @@ -169,21 +169,13 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, QualType BaseType = Context.getCanonicalType(BaseSpec.getType()).getUnqualifiedType(); - bool isCurrentInstantiation = isa(BaseType); - if (!isCurrentInstantiation) { - if (auto *BaseRecord = cast_if_present( - BaseSpec.getType()->getAsRecordDecl())) - isCurrentInstantiation = BaseRecord->isDependentContext() && - BaseRecord->isCurrentInstantiation(Record); - } // C++ [temp.dep]p3: // In the definition of a class template or a member of a class template, // if a base class of the class template depends on a template-parameter, // the base class scope is not examined during unqualified name lookup // either at the point of definition of the class template or member or // during an instantiation of the class tem- plate or member. - if (!LookupInDependent && - (BaseType->isDependentType() && !isCurrentInstantiation)) + if (!LookupInDependent && BaseType->isDependentType()) continue; // Determine whether we need to visit this base class at all, @@ -251,8 +243,9 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, return FoundPath; } } else if (VisitBase) { - CXXRecordDecl *BaseRecord = nullptr; + CXXRecordDecl *BaseRecord; if (LookupInDependent) { + BaseRecord = nullptr; const TemplateSpecializationType *TST = BaseSpec.getType()->getAs(); if (!TST) { @@ -271,7 +264,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, BaseRecord = nullptr; } } else { - BaseRecord = cast(BaseSpec.getType()->getAsRecordDecl()); + BaseRecord = cast( + BaseSpec.getType()->castAs()->getDecl()); } if (BaseRecord && lookupInBases(Context, BaseRecord, BaseMatches, LookupInDependent)) { diff --git a/clang/test/CXX/drs/cwg5xx.cpp b/clang/test/CXX/drs/cwg5xx.cpp index 0d53a9d07d76d..ed0c7159dfc88 100644 --- a/clang/test/CXX/drs/cwg5xx.cpp +++ b/clang/test/CXX/drs/cwg5xx.cpp @@ -1178,61 +1178,17 @@ namespace cwg590 { // cwg590: yes template typename A::B::C A::B::C::f(A::B::C) {} } -namespace cwg591 { // cwg591: yes +namespace cwg591 { // cwg591: no template struct A { typedef int M; struct B { typedef void M; struct C; - struct D; - }; - }; - - template struct G { - struct B { - typedef int M; - struct C { - typedef void M; - struct D; - }; - }; - }; - - template struct H { - template struct B { - typedef int M; - template struct C { - typedef void M; - struct D; - struct P; - }; }; }; template struct A::B::C : A { - M m; - }; - - template struct G::B::C::D : B { - M m; - }; - - template - template - template - struct H::B::C::D : B { - M m; - }; - - template struct A::B::D : A { - M m; - // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}} - }; - - template - template - template - struct H::B::C::P : B { + // FIXME: Should find member of non-dependent base class A. M m; // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}} }; diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html index c773c58fac4d0..186f7cc0ace54 100755 --- a/clang/www/cxx_dr_status.html +++ b/clang/www/cxx_dr_status.html @@ -3599,7 +3599,7 @@

C++ defect report implementation status

591 CD4 When a dependent base class is the current instantiation - Yes + No 592