c++: Fix ICE-on-invalid with -Wvexing-parse [PR97881]
authorMarek Polacek <polacek@redhat.com>
Tue, 17 Nov 2020 18:39:39 +0000 (13:39 -0500)
committerMarek Polacek <polacek@redhat.com>
Sat, 21 Nov 2020 20:48:15 +0000 (15:48 -0500)
commit0999f26098598fe0a499c5b79ad23678ccfe583a
tree0d73ecd35a9fa5570977301ba2b8b3597b7a2275
parent1cb50c0a0e1a535ad39da2708829ac78f0f154d8
c++: Fix ICE-on-invalid with -Wvexing-parse [PR97881]

This invalid (?) code broke my assumption that if decl_specifiers->type
is null, there must be any type-specifiers.  Turn the assert into an if
to fix this crash.

gcc/cp/ChangeLog:

PR c++/97881
* parser.c (warn_about_ambiguous_parse): Only assume "int" if we
actually saw any type-specifiers.

gcc/testsuite/ChangeLog:

PR c++/97881
* g++.dg/warn/Wvexing-parse9.C: New test.
gcc/cp/parser.c
gcc/testsuite/g++.dg/warn/Wvexing-parse9.C [new file with mode: 0644]