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

    <tr>
        <th>Summary</th>
        <td>
            Clang crash for C++ in clang::Parser::isCXXDeclarationSpecifier
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++,
            clang:frontend
      </td>
    </tr>

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

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

<pre>
    I found a compiler crash when compiling a C++ file. I was using Clang 15 but have reproduced a similar but not exactly the same failure in Clang 17, built from main.

The test_parse.cpp.ii.gz is the compressed preprocessed file. I have reduced it using clang-15 and clang-17 and both end up with:

```
namespace std {
template <_Tp> class optional; C_A_T_C_H_T_E_S_T_0(std:optional.
```

This segfaults in clang-15 and aborts in clang-17 with:
```
clang-17: /home/pmatos/dev/llvm-project/clang/lib/Parse/ParseTentative.cpp:1672: Parser::TPResult clang::Parser::isCXXDeclarationSpecifier
```

File: [test_parse.cpp.ii.gz](https://github.com/llvm/llvm-project/files/11622789/test_parse.cpp.ii.gz)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVEFvnDwQ_TXmMgoCO8By4LDLBn25RV_2kBsyeABXBiPbbJr--sqwtEkbVYq0C5oZ8-a957G5tbKfEAuSnEhyDvjiBm2KeeRO26DR4q14hE4vkwAOrR5nqdBAa7gd4HXA6ZaTUw8cSkJPhJ6gkwpDeIRXbmGxvlYqPvUQJ9AsDgZ-RTA4Gy2WFj2wlaNU3KzVSTvA77x16g3cgGD5iNBxqRaDIKcdKiO0hGaRykFn9Agjl1NIojOJjtvzMiA4tK6eubEYtvMcShn2P0DaFdcTN2gtCphXMu0W7ORvLDeK0t2EtL77XZwAn8QeZGvQaDcATgKWGV6lGwg7vqdD0uj2W8OJj2hn3iJYJ4Bkpy3tcJwVdwiElfVlJuzBN7EW9Oyknrgi7ARlfawvdVn_V1_qh_q5vtQRoQfrBGHHfV34adfdGWnBYt_xRTnrPf2gijfafEhnf-j5iLkvIuwIhFaDHpHQahsgQiuBV0Irpa7j3Wz0N2wdodX6jU_LhtDqyW_Q_r7g5LiT13XHCDvGaUY99Fo0ngQ7Xp7-R7sotxHccu_r0pYvL2dsFTfc2_E8Yys7ieYfplRS4SohOX02NSQ5E3oYnJut70ErQqteumFpwlaPN4V_C_XD5F2I45TS7JATWn2KTvNAFEzkLOcBFnF6SNI4ijIWDMU9Tbock5S3hyxNWJc1IhUsPtCk4VnXHAJZ0IiyKI3iKPf_MKEpjXMWxyKPBWMxuY9w5FKFnlyoTR9IaxcsUhYlNFC8QWXX809pu51gQimhpY9vBndGTw4n4QvJOTDFqrNZekvuIyWts7_BnXQKi-2YbhdFp82vu2Efqy_sWrAYVXzZ-lWj936V-TMAAP__Vx6MzA">