Skip to content

Commit c34aa78

Browse files
authored
[Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (#79733)
Fix [issue](#77189) AutoType is possible cv qualified. Co-authored-by: huqizhi <[email protected]>
1 parent 2d0d65b commit c34aa78

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ Bug Fixes to C++ Support
130130
- Fixed a bug where variables referenced by requires-clauses inside
131131
nested generic lambdas were not properly injected into the constraint scope.
132132
(`#73418 <https://github.com/llvm/llvm-project/issues/73418>`_)
133+
- Fixed deducing auto& from const int in template parameters of partial
134+
specializations.
135+
(`#77189 <https://github.com/llvm/llvm-project/issues/77189>`_)
133136

134137
Bug Fixes to AST Handling
135138
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaTemplateDeduction.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ static bool IsPossiblyOpaquelyQualifiedTypeInternal(const Type *T) {
649649
case Type::PackIndexing:
650650
case Type::UnresolvedUsing:
651651
case Type::TemplateTypeParm:
652+
case Type::Auto:
652653
return true;
653654

654655
case Type::ConstantArray:

clang/test/SemaTemplate/PR77189.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s
2+
// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s
3+
// expected-no-diagnostics
4+
5+
struct false_type {
6+
static constexpr bool value = false;
7+
};
8+
9+
struct true_type {
10+
static constexpr bool value = true;
11+
};
12+
13+
template <auto& Value, int>
14+
struct test : false_type {};
15+
16+
template <auto& Value>
17+
struct test<Value, 0> : true_type {};
18+
19+
int main() {
20+
static constexpr int v = 42;
21+
static_assert(test<v, 0>::value);
22+
}

0 commit comments

Comments
 (0)