[clang] [Clang][Sema] ASTContext::getUnconstrainedType propagates dependence (PR #92425)

Krystian Stasiowski via cfe-commits cfe-commits at lists.llvm.org
Thu May 16 10:58:49 PDT 2024


https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/92425

>From c26365ef78366b5c200d085ddc4211db1b2054e0 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Thu, 16 May 2024 10:59:03 -0400
Subject: [PATCH 1/3] [Clang][Sema] ASTContext::getUnconstrainedType propagates
 dependence

---
 clang/docs/ReleaseNotes.rst                           |  1 +
 clang/lib/AST/ASTContext.cpp                          |  3 ++-
 .../temp/temp.decls/temp.fct/temp.func.order/p2.cpp   | 11 +++++++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p2.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index be4cded276321..21f273cf8f54e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -723,6 +723,7 @@ Bug Fixes to C++ Support
 - Clang now ignores template parameters only used within the exception specification of candidate function
   templates during partial ordering when deducing template arguments from a function declaration or when
   taking the address of a function template.
+- Fix a bug with checking constrained non-type template parameters for equivalence.
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 4475f399a120b..8fc2bb8c401c2 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5910,7 +5910,8 @@ QualType ASTContext::getUnconstrainedType(QualType T) const {
   if (auto *AT = CanonT->getAs<AutoType>()) {
     if (!AT->isConstrained())
       return T;
-    return getQualifiedType(getAutoType(QualType(), AT->getKeyword(), false,
+    return getQualifiedType(getAutoType(QualType(), AT->getKeyword(),
+                                        AT->isDependentType(),
                                         AT->containsUnexpandedParameterPack()),
                             T.getQualifiers());
   }
diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p2.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p2.cpp
new file mode 100644
index 0000000000000..ca753ec0c2d06
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p2.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
+// expected-no-diagnostics
+
+template<typename T>
+concept C = sizeof(T) == sizeof(int);
+
+template<auto N>
+struct A;
+
+template<C auto N>
+struct A<N>;

>From 20554c70c5fc3e6f026bc6dcc9f6d8204d2e7a4a Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Thu, 16 May 2024 12:34:39 -0400
Subject: [PATCH 2/3] [FOLD] add issue number to release note

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 21f273cf8f54e..2d2928e418623 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -723,7 +723,7 @@ Bug Fixes to C++ Support
 - Clang now ignores template parameters only used within the exception specification of candidate function
   templates during partial ordering when deducing template arguments from a function declaration or when
   taking the address of a function template.
-- Fix a bug with checking constrained non-type template parameters for equivalence.
+- Fix a bug with checking constrained non-type template parameters for equivalence. Fixes (#GH77377).
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^

>From b472d4231a130671e7e32d8318f988c40b064eff Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski <sdkrystian at gmail.com>
Date: Thu, 16 May 2024 13:58:30 -0400
Subject: [PATCH 3/3] [FOLD] address review comments

---
 .../temp.decls/temp.fct/temp.func.order/p2.cpp     | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p2.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p2.cpp
index ca753ec0c2d06..df1bbd5fe8128 100644
--- a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p2.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p2.cpp
@@ -1,11 +1,13 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 // expected-no-diagnostics
 
-template<typename T>
-concept C = sizeof(T) == sizeof(int);
+namespace GH77377 {
+  template<typename T>
+  concept C = sizeof(T) == sizeof(int);
 
-template<auto N>
-struct A;
+  template<auto N>
+  struct A;
 
-template<C auto N>
-struct A<N>;
+  template<C auto N>
+  struct A<N>;
+}



More information about the cfe-commits mailing list