Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Clang][Sema] Fix crash when using name of UnresolvedUsingValueDecl with template arguments (#83842)" #84457

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

sdkrystian
Copy link
Member

@sdkrystian sdkrystian commented Mar 8, 2024

This reverts commit a642eb8 (see #83842)

…ueDecl with template arguments (llvm#83842)"

This reverts commit a642eb8.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Mar 8, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 8, 2024

@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)

Changes

This reverts commit a642eb8.


Full diff: https://github.com/llvm/llvm-project/pull/84457.diff

4 Files Affected:

  • (modified) clang/docs/ReleaseNotes.rst (-2)
  • (modified) clang/lib/Sema/SemaDecl.cpp (+1-4)
  • (modified) clang/lib/Sema/SemaTemplate.cpp (+4-6)
  • (removed) clang/test/SemaTemplate/unqual-unresolved-using-value.cpp (-30)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 225ca85e18115d..0ee2801766a9cc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -332,8 +332,6 @@ Bug Fixes to C++ Support
   our attention by an attempt to fix in (#GH77703). Fixes (#GH83385).
 - Fix evaluation of some immediate calls in default arguments.
   Fixes (#GH80630)
-- Fix a crash when an explicit template argument list is used with a name for which lookup
-  finds a non-template function and a dependent using declarator.
 - Fixed an issue where the ``RequiresExprBody`` was involved in the lambda dependency
   calculation. (#GH56556), (#GH82849).
 - Fix a bug where overload resolution falsely reported an ambiguity when it was comparing
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 910d0dfbf9f65f..1f4a041e88dfff 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1110,9 +1110,7 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS,
     //   unqualified-id followed by a < and name lookup finds either one
     //   or more functions or finds nothing.
     if (!IsFilteredTemplateName)
-      FilterAcceptableTemplateNames(Result,
-                                    /*AllowFunctionTemplates=*/true,
-                                    /*AllowDependent=*/true);
+      FilterAcceptableTemplateNames(Result);
 
     bool IsFunctionTemplate;
     bool IsVarTemplate;
@@ -1122,7 +1120,6 @@ Sema::NameClassification Sema::ClassifyName(Scope *S, CXXScopeSpec &SS,
       Template = Context.getOverloadedTemplateName(Result.begin(),
                                                    Result.end());
     } else if (!Result.empty()) {
-      assert(!Result.isUnresolvableResult());
       auto *TD = cast<TemplateDecl>(getAsTemplateNameDecl(
           *Result.begin(), /*AllowFunctionTemplates=*/true,
           /*AllowDependent=*/false));
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 7e91815c2d52a8..83eee83aa6cad8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -491,20 +491,18 @@ bool Sema::LookupTemplateName(LookupResult &Found,
     // To keep our behavior consistent, we apply the "finds nothing" part in
     // all language modes, and diagnose the empty lookup in ActOnCallExpr if we
     // successfully form a call to an undeclared template-id.
-    bool AnyFunctions =
-        getLangOpts().CPlusPlus20 && llvm::any_of(Found, [](NamedDecl *ND) {
+    bool AllFunctions =
+        getLangOpts().CPlusPlus20 && llvm::all_of(Found, [](NamedDecl *ND) {
           return isa<FunctionDecl>(ND->getUnderlyingDecl());
         });
-    if (AnyFunctions || (Found.empty() && !IsDependent)) {
+    if (AllFunctions || (Found.empty() && !IsDependent)) {
       // If lookup found any functions, or if this is a name that can only be
       // used for a function, then strongly assume this is a function
       // template-id.
       *ATK = (Found.empty() && Found.getLookupName().isIdentifier())
                  ? AssumedTemplateKind::FoundNothing
                  : AssumedTemplateKind::FoundFunctions;
-      FilterAcceptableTemplateNames(Found,
-                                    /*AllowFunctionTemplates*/ true,
-                                    /*AllowDependent*/ true);
+      Found.clear();
       return false;
     }
   }
diff --git a/clang/test/SemaTemplate/unqual-unresolved-using-value.cpp b/clang/test/SemaTemplate/unqual-unresolved-using-value.cpp
deleted file mode 100644
index 688e7a0a10b779..00000000000000
--- a/clang/test/SemaTemplate/unqual-unresolved-using-value.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
-
-template<typename T>
-struct A : T {
-  using T::f;
-  using T::g;
-  using T::h;
-
-  void f();
-  void g();
-
-  void i() {
-    f<int>();
-    g<int>(); // expected-error{{no member named 'g' in 'A<B>'}}
-    h<int>(); // expected-error{{expected '(' for function-style cast or type construction}}
-              // expected-error@-1{{expected expression}}
-  }
-};
-
-struct B {
-  template<typename T>
-  void f();
-
-  void g();
-
-  template<typename T>
-  void h();
-};
-
-template struct A<B>; // expected-note{{in instantiation of member function 'A<B>::i' requested here}}

@sdkrystian sdkrystian merged commit ee94bd2 into llvm:main Mar 8, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants