[clang] [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (PR #79733)

2024-01-27 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky created 
https://github.com/llvm/llvm-project/pull/79733

Fix [issue](https://github.com/llvm/llvm-project/issues/77189)
AutoType is possible cv qualified.

>From 35662b8929952af13eb31bc127144df2d7c1d003 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Sun, 28 Jan 2024 15:12:01 +0800
Subject: [PATCH] [Clang][Sema] fix deducing auto& from const int in template
 parameters is impossible in partial specializations

---
 clang/lib/Sema/SemaTemplateDeduction.cpp |  1 +
 clang/test/SemaTemplate/PR77189.cpp  | 22 ++
 2 files changed, 23 insertions(+)
 create mode 100644 clang/test/SemaTemplate/PR77189.cpp

diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 25e58f7bdd953d1..f08577febcd3e80 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -649,6 +649,7 @@ static bool IsPossiblyOpaquelyQualifiedTypeInternal(const 
Type *T) {
   case Type::PackIndexing:
   case Type::UnresolvedUsing:
   case Type::TemplateTypeParm:
+  case Type::Auto:
 return true;
 
   case Type::ConstantArray:
diff --git a/clang/test/SemaTemplate/PR77189.cpp 
b/clang/test/SemaTemplate/PR77189.cpp
new file mode 100644
index 000..dd2e4511a02cf70
--- /dev/null
+++ b/clang/test/SemaTemplate/PR77189.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+struct false_type {
+   static constexpr bool value = false;
+};
+
+struct true_type {
+   static constexpr bool value = true;
+};
+
+template 
+struct test : false_type {};
+
+template 
+struct test : true_type {};
+
+int main() {
+static constexpr int v = 42;
+static_assert(test::value);
+}
\ No newline at end of file

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (PR #79733)

2024-01-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Qizhi Hu (jcsxky)


Changes

Fix [issue](https://github.com/llvm/llvm-project/issues/77189)
AutoType is possible cv qualified.

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+1) 
- (added) clang/test/SemaTemplate/PR77189.cpp (+22) 


``diff
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 25e58f7bdd953d1..f08577febcd3e80 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -649,6 +649,7 @@ static bool IsPossiblyOpaquelyQualifiedTypeInternal(const 
Type *T) {
   case Type::PackIndexing:
   case Type::UnresolvedUsing:
   case Type::TemplateTypeParm:
+  case Type::Auto:
 return true;
 
   case Type::ConstantArray:
diff --git a/clang/test/SemaTemplate/PR77189.cpp 
b/clang/test/SemaTemplate/PR77189.cpp
new file mode 100644
index 000..dd2e4511a02cf70
--- /dev/null
+++ b/clang/test/SemaTemplate/PR77189.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+struct false_type {
+   static constexpr bool value = false;
+};
+
+struct true_type {
+   static constexpr bool value = true;
+};
+
+template 
+struct test : false_type {};
+
+template 
+struct test : true_type {};
+
+int main() {
+static constexpr int v = 42;
+static_assert(test::value);
+}
\ No newline at end of file

``




https://github.com/llvm/llvm-project/pull/79733
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (PR #79733)

2024-01-27 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/79733

>From 9834d065580a668f94f74adaf8507ca672e9118f Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Sun, 28 Jan 2024 15:12:01 +0800
Subject: [PATCH] [Clang][Sema] fix deducing auto& from const int in template
 parameters is impossible in partial specializations

---
 clang/lib/Sema/SemaTemplateDeduction.cpp |  1 +
 clang/test/SemaTemplate/PR77189.cpp  | 22 ++
 2 files changed, 23 insertions(+)
 create mode 100644 clang/test/SemaTemplate/PR77189.cpp

diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 25e58f7bdd953d1..f08577febcd3e80 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -649,6 +649,7 @@ static bool IsPossiblyOpaquelyQualifiedTypeInternal(const 
Type *T) {
   case Type::PackIndexing:
   case Type::UnresolvedUsing:
   case Type::TemplateTypeParm:
+  case Type::Auto:
 return true;
 
   case Type::ConstantArray:
diff --git a/clang/test/SemaTemplate/PR77189.cpp 
b/clang/test/SemaTemplate/PR77189.cpp
new file mode 100644
index 000..1e9cc7984163c06
--- /dev/null
+++ b/clang/test/SemaTemplate/PR77189.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+struct false_type {
+   static constexpr bool value = false;
+};
+
+struct true_type {
+   static constexpr bool value = true;
+};
+
+template 
+struct test : false_type {};
+
+template 
+struct test : true_type {};
+
+int main() {
+static constexpr int v = 42;
+static_assert(test::value);
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (PR #79733)

2024-01-27 Thread via cfe-commits

cor3ntin wrote:

Oh wow, thanks for this fix!
Does it fixes any of these issues? 
https://github.com/llvm/llvm-project/issues/68885

https://github.com/llvm/llvm-project/pull/79733
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (PR #79733)

2024-01-28 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/79733

>From af0b28a28f0bf46b22521c0b39d5200eb94838dd Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Sun, 28 Jan 2024 15:12:01 +0800
Subject: [PATCH] [Clang][Sema] fix deducing auto& from const int in template
 parameters is impossible in partial specializations

---
 clang/docs/ReleaseNotes.rst  |  3 +++
 clang/lib/Sema/SemaTemplateDeduction.cpp |  1 +
 clang/test/SemaTemplate/PR77189.cpp  | 22 ++
 3 files changed, 26 insertions(+)
 create mode 100644 clang/test/SemaTemplate/PR77189.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 254e0a9cb72979..2aa8fea4ad67c0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -130,6 +130,9 @@ Bug Fixes to C++ Support
 - Fixed a bug where variables referenced by requires-clauses inside
   nested generic lambdas were not properly injected into the constraint scope.
   (`#73418 `_)
+- Fixed deducing auto& from const int in template parameters of partial
+  specializations.
+  (`#77189 `_)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 25e58f7bdd953d..f08577febcd3e8 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -649,6 +649,7 @@ static bool IsPossiblyOpaquelyQualifiedTypeInternal(const 
Type *T) {
   case Type::PackIndexing:
   case Type::UnresolvedUsing:
   case Type::TemplateTypeParm:
+  case Type::Auto:
 return true;
 
   case Type::ConstantArray:
diff --git a/clang/test/SemaTemplate/PR77189.cpp 
b/clang/test/SemaTemplate/PR77189.cpp
new file mode 100644
index 00..1e9cc7984163c0
--- /dev/null
+++ b/clang/test/SemaTemplate/PR77189.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
+// expected-no-diagnostics
+
+struct false_type {
+   static constexpr bool value = false;
+};
+
+struct true_type {
+   static constexpr bool value = true;
+};
+
+template 
+struct test : false_type {};
+
+template 
+struct test : true_type {};
+
+int main() {
+static constexpr int v = 42;
+static_assert(test::value);
+}

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (PR #79733)

2024-01-28 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM, thanks!

https://github.com/llvm/llvm-project/pull/79733
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (PR #79733)

2024-01-28 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky closed https://github.com/llvm/llvm-project/pull/79733
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits