<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57643>57643</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Frontend crashes when generating warnings
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          glandir
      </td>
    </tr>
</table>

<pre>
    I encountered this with `std=c++20 -Weverything`, of course `-Wc++98-compat` is nonsense here.

`clang++ -std=c++20 -Wc++98-compat test.cpp` crashes on the following input:

```cpp
// test.cpp
template<unsigned N>
struct Str {
        constexpr Str(char const (&str)[N]) {}
};

template<Str s>
auto test() {}
```

```
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 -Wc++98-compat -emit-llvm -Xclang -disable-llvm-passes <source>
1.      <source>:6:15: current parser token '>'
 #0 0x000055ed84f7ee14 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #1 0x000055ed84f7cc7c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x395cc7c)
 #2 0x000055ed84eba588 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fb4bf7d3420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x000055ed8810b29d ConvertTypeToDiagnosticString(clang::ASTContext&, clang::QualType, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>>, llvm::ArrayRef<long>) ASTDiagnostic.cpp:0:0
 #5 0x000055ed8810c28c clang::FormatASTNodeDiagnosticArgument(clang::DiagnosticsEngine::ArgumentKind, long, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<std::pair<clang::DiagnosticsEngine::ArgumentKind, long>>, llvm::SmallVectorImpl<char>&, void*, llvm::ArrayRef<long>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6aec28c)
 #6 0x000055ed852cac07 clang::Diagnostic::FormatDiagnostic(char const*, char const*, llvm::SmallVectorImpl<char>&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3caac07)
 #7 0x000055ed85b456c4 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45256c4)
 #8 0x000055ed852d0ca1 clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cb0ca1)
 #9 0x000055ed852c534b clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3ca534b)
#10 0x000055ed875278fb clang::Sema::EmitCurrentDiagnostic(unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f078fb)
#11 0x000055ed8752827f clang::Sema::ImmediateDiagBuilder::~ImmediateDiagBuilder() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f0827f)
#12 0x000055ed87528aab clang::Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5f08aab)
#13 0x000055ed87ce23b0 clang::Sema::ActOnNonTypeTemplateParameter(clang::Scope*, clang::Declarator&, unsigned int, unsigned int, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x66c23b0)
#14 0x000055ed874ccbdd clang::Parser::ParseNonTypeTemplateParameter(unsigned int, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5eacbdd)
#15 0x000055ed874d5a19 clang::Parser::ParseTemplateParameter(unsigned int, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5eb5a19)
#16 0x000055ed874d6769 clang::Parser::ParseTemplateParameterList(unsigned int, llvm::SmallVectorImpl<clang::NamedDecl*>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5eb6769)
#17 0x000055ed874d6c06 clang::Parser::ParseTemplateParameters(clang::Parser::MultiParseScope&, unsigned int, llvm::SmallVectorImpl<clang::NamedDecl*>&, clang::SourceLocation&, clang::SourceLocation&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5eb6c06)
#18 0x000055ed874d96a6 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5eb96a6)
#19 0x000055ed874d9ad3 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5eb9ad3)
#20 0x000055ed8740a328 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5dea328)
#21 0x000055ed873db986 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5dbb986)
#22 0x000055ed873dd70a clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5dbd70a)
#23 0x000055ed873cd0aa clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5dad0aa)
#24 0x000055ed861e43b5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4bc43b5)
#25 0x000055ed85ae9011 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x44c9011)
#26 0x000055ed85a6fb63 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x444fb63)
#27 0x000055ed85bcc1db clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45ac1db)
#28 0x000055ed8288b204 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x126b204)
#29 0x000055ed828847fb ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#30 0x000055ed858dbe99 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#31 0x000055ed84ebacf7 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x389acf7)
#32 0x000055ed858dc0cc clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#33 0x000055ed858a7719 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4287719)
#34 0x000055ed858a810d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x428810d)
#35 0x000055ed858b285c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x429285c)
#36 0x000055ed82888f29 clang_main(int, char**) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1268f29)
#37 0x00007fb4bf281083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#38 0x000055ed8288440e _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x126440e)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWtty47gR_Rr5hUUX75cHPciyvXEy63FGrkzeVCAISsxQBAOCtrxfn26QlAhalu1d7qQqmZFlEgAbp083Gs2GE56-zO8MVlLelJIJlhpym9fGcy63xiywapnO3Gs6c67g41iG-Z09MfECY8oNdM-cpcEzAx4WNcPx5vdubByZlO8qIqHRAIElL2sGH2MLk1zOrOuZtei-A4sWBMSp5wzz9ZRjkYZktbykVYWyqSD1ltUGLwE5MzJeFPwZ0Bl5WTVy5i5Gc7UffLhtcW7hc5SoGiXbVQWRbOYum7LONyXQcj9zb9reWoqGSmMlhTELr3rxMQUNJdtXAntmTkS3RBiq0YC7mRPU2BzP_Kv7mX8NV-rp8LoTABfu1RDrAAROVR_mJ43kCrASOxLTK3hS6_Z2JQn9YaTNrjqwY4FF4gfBN4LsDCI2zY6VEmZcAPRbXsFMt0h9XjBhgooFF0xgG9rNBDrKH3CX5GXf1ttykz4TkZkeXBkmR2EEOAaRjQTjXNaGuSuKp51hmvsoMEm9M-uXUpI9OEAO7lgY5gr6NpSakvMCGIUp3OuzmHBwXZKq3nJpmBnl0GGmOdmUvJY5hSmzkpvKa_TmD_idyXa5NFvE_1SKGiCjJknBVKtZkboGXwST1bAkKDvYzEaCtWZ3EcCP7SPJtBECCDcqAstIGJL_YCWQFeI4-FYS4N61DGtvwT_fZ2nkZSFjtmc8CKBK2fRREMpW4K6k-Asp0wL5iJ54ns6cBTpK21UrP3cXlvo5yLZHsikNqYFKoZO4i_qlbi-WBSNlU30tW2kww2GJFBwtH7fu_vvdBj7W3o19RIAL5gDR0SCyhPhRZCzRkt8Y5RiXxsoDMwhIG7Pk4Fl7eZoFt5sizBIvycLU9cAT1msBqw3Ar0W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