Author: Qizhi Hu Date: 2024-01-29T06:42:52+08:00 New Revision: c34aa784f8867517315d8ef32a8038ee9dbb7165
URL: https://github.com/llvm/llvm-project/commit/c34aa784f8867517315d8ef32a8038ee9dbb7165 DIFF: https://github.com/llvm/llvm-project/commit/c34aa784f8867517315d8ef32a8038ee9dbb7165.diff LOG: [Clang][Sema] fix deducing auto& from const int in template parameters is impossible in partial specializations (#79733) Fix [issue](https://github.com/llvm/llvm-project/issues/77189) AutoType is possible cv qualified. Co-authored-by: huqizhi <836744...@qq.com> Added: clang/test/SemaTemplate/PR77189.cpp Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaTemplateDeduction.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 254e0a9cb72979d..2aa8fea4ad67c02 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 <https://github.com/llvm/llvm-project/issues/73418>`_) +- Fixed deducing auto& from const int in template parameters of partial + specializations. + (`#77189 <https://github.com/llvm/llvm-project/issues/77189>`_) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ 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 000000000000000..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 <auto& Value, int> +struct test : false_type {}; + +template <auto& Value> +struct test<Value, 0> : true_type {}; + +int main() { + static constexpr int v = 42; + static_assert(test<v, 0>::value); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits