Index: clang/lib/Sema/SemaTemplate.cpp =================================================================== --- clang/lib/Sema/SemaTemplate.cpp +++ clang/lib/Sema/SemaTemplate.cpp @@ -1531,7 +1531,7 @@ CheckValidDeclSpecifiers(); - if (TInfo->getType()->isUndeducedType()) { + if (TInfo->getType()->getContainedAutoType()) { Diag(D.getIdentifierLoc(), diag::warn_cxx14_compat_template_nontype_parm_auto_type) << QualType(TInfo->getType()->getContainedAutoType(), 0); Index: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx1z.cpp =================================================================== --- /dev/null +++ clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx1z.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s + +namespace GH57362 { +template +class TemplateClass {}; + +template // ok, no diagnostic expected +void func() {} + +template // expected-warning {{non-type template parameters declared with 'auto' are incompatible with C++ standards before C++17}} +struct A{}; + +template // expected-warning {{non-type template parameters declared with 'decltype(auto)' are incompatible with C++ standards before C++17}} +struct B{}; +}