Fznamznon updated this revision to Diff 538531. Fznamznon added a comment. Rebase, add tests for dependent NameInfo
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D154689/new/ https://reviews.llvm.org/D154689 Files: clang/docs/ReleaseNotes.rst clang/lib/AST/ComputeDependence.cpp clang/lib/AST/Expr.cpp clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp =================================================================== --- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp +++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp @@ -306,3 +306,22 @@ f<B>(A<B(0)>()); // OK } } + +namespace GH48731 { +template <int> using N = int; +struct X { template<typename T> void f(); }; +template<int ...Is> decltype((X().f<N<Is>>(), ...)) x; +template<int ...Is> decltype(((new X())->f<N<Is>>(), ...)) y; + +struct A {}; +template<int> using Tfoo = A; +template<int ...Ns> void foo(A a) { + (a.~Tfoo<Ns>(), ...); +} + +struct B { operator int(); }; +template<int> using Tbar = int; +template<int ...Ns> void bar(B b) { + (b.operator Tbar<Ns>(), ...); +} +} Index: clang/lib/AST/Expr.cpp =================================================================== --- clang/lib/AST/Expr.cpp +++ clang/lib/AST/Expr.cpp @@ -1759,16 +1759,7 @@ MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl, NameInfo, T, VK, OK, NOUR); - // FIXME: remove remaining dependence computation to computeDependence(). - auto Deps = E->getDependence(); if (HasQualOrFound) { - // FIXME: Wrong. We should be looking at the member declaration we found. - if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent()) - Deps |= ExprDependence::TypeValueInstantiation; - else if (QualifierLoc && - QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()) - Deps |= ExprDependence::Instantiation; - E->MemberExprBits.HasQualifierOrFoundDecl = true; MemberExprNameQualifier *NQ = @@ -1780,13 +1771,16 @@ E->MemberExprBits.HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid(); + // FIXME: remove remaining dependence computation to computeDependence(). + auto Deps = E->getDependence(); if (TemplateArgs) { auto TemplateArgDeps = TemplateArgumentDependence::None; E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom( TemplateKWLoc, *TemplateArgs, E->getTrailingObjects<TemplateArgumentLoc>(), TemplateArgDeps); - if (TemplateArgDeps & TemplateArgumentDependence::Instantiation) - Deps |= ExprDependence::Instantiation; + for (const TemplateArgumentLoc &ArgLoc : TemplateArgs->arguments()) { + Deps |= toExprDependence(ArgLoc.getArgument().getDependence()); + } } else if (TemplateKWLoc.isValid()) { E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom( TemplateKWLoc); Index: clang/lib/AST/ComputeDependence.cpp =================================================================== --- clang/lib/AST/ComputeDependence.cpp +++ clang/lib/AST/ComputeDependence.cpp @@ -611,9 +611,24 @@ return D; } +static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) { + auto D = ExprDependence::None; + if (Name.isInstantiationDependent()) + D |= ExprDependence::Instantiation; + if (Name.containsUnexpandedParameterPack()) + D |= ExprDependence::UnexpandedPack; + return D; +} + ExprDependence clang::computeDependence(MemberExpr *E) { - auto *MemberDecl = E->getMemberDecl(); auto D = E->getBase()->getDependence(); + D |= getDependenceInExpr(E->getMemberNameInfo()); + + if (auto *NNS = E->getQualifier()) + D |= toExprDependence(NNS->getDependence() & + ~NestedNameSpecifierDependence::Dependent); + + auto *MemberDecl = E->getMemberDecl(); if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) { DeclContext *DC = MemberDecl->getDeclContext(); // dyn_cast_or_null is used to handle objC variables which do not @@ -723,15 +738,6 @@ return D; } -static inline ExprDependence getDependenceInExpr(DeclarationNameInfo Name) { - auto D = ExprDependence::None; - if (Name.isInstantiationDependent()) - D |= ExprDependence::Instantiation; - if (Name.containsUnexpandedParameterPack()) - D |= ExprDependence::UnexpandedPack; - return D; -} - ExprDependence clang::computeDependence(OverloadExpr *E, bool KnownDependent, bool KnownInstantiationDependent, Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -573,6 +573,9 @@ - Stop evaluating a constant expression if the condition expression which in switch statement contains errors. (`#63453 <https://github.com/llvm/llvm-project/issues/63453>_`) +- Fixed false positive error diagnostic when pack expansion appears in template + parameters of a member expression. + (`#48731 <https://github.com/llvm/llvm-project/issues/48731>`_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits