mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 06:10:12 +00:00
[Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()
Based on the changes introduced by 15361a21e0
it
looks like C++17 compatibility diagnostic should have been checking
getContainedAutoType().
This fixes: https://github.com/llvm/llvm-project/issues/57369
https://github.com/llvm/llvm-project/issues/57643
https://github.com/llvm/llvm-project/issues/57793
Differential Revision: https://reviews.llvm.org/D132990
This commit is contained in:
parent
d6498abc24
commit
f8a37a6ce6
@ -146,6 +146,11 @@ Bug Fixes
|
||||
- A SubstTemplateTypeParmType can now represent the pack index for a
|
||||
substitution from an expanded pack.
|
||||
`Issue 56099 <https://github.com/llvm/llvm-project/issues/56099>`_
|
||||
- Fix `-Wpre-c++17-compat` crashing Clang when compiling C++20 code which
|
||||
contains deduced template specializations. This Fixes
|
||||
`Issue 57369 <https://github.com/llvm/llvm-project/issues/57369>`_
|
||||
`Issue 57643 <https://github.com/llvm/llvm-project/issues/57643>`_
|
||||
`Issue 57793 <https://github.com/llvm/llvm-project/issues/57793>`_
|
||||
|
||||
|
||||
Improvements to Clang's diagnostics
|
||||
|
@ -1531,11 +1531,11 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
|
||||
|
||||
CheckValidDeclSpecifiers();
|
||||
|
||||
if (TInfo->getType()->isUndeducedType()) {
|
||||
Diag(D.getIdentifierLoc(),
|
||||
diag::warn_cxx14_compat_template_nontype_parm_auto_type)
|
||||
<< QualType(TInfo->getType()->getContainedAutoType(), 0);
|
||||
}
|
||||
if (const auto *T = TInfo->getType()->getContainedDeducedType())
|
||||
if (isa<AutoType>(T))
|
||||
Diag(D.getIdentifierLoc(),
|
||||
diag::warn_cxx14_compat_template_nontype_parm_auto_type)
|
||||
<< QualType(TInfo->getType()->getContainedAutoType(), 0);
|
||||
|
||||
assert(S->isTemplateParamScope() &&
|
||||
"Non-type template parameter not in template parameter scope!");
|
||||
|
10
clang/test/SemaTemplate/gh57362.cpp
Normal file
10
clang/test/SemaTemplate/gh57362.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
namespace GH57362 {
|
||||
template <int num>
|
||||
class TemplateClass {};
|
||||
|
||||
template <TemplateClass nttp> // ok, no diagnostic expected
|
||||
void func() {}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
|
||||
|
||||
template <decltype(auto) n> // expected-warning {{non-type template parameters declared with 'decltype(auto)' are incompatible with C++ standards before C++17}}
|
||||
struct B{};
|
||||
|
||||
template <auto n> // expected-warning {{non-type template parameters declared with 'auto' are incompatible with C++ standards before C++17}}
|
||||
struct A{};
|
Loading…
Reference in New Issue
Block a user