diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 254e0a9cb7297..2aa8fea4ad67c 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 25e58f7bdd953..f08577febcd3e 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 0000000000000..1e9cc7984163c --- /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); +}