c++: Fix -Wvexing-parse ICE with omitted int [PR97762]
authorMarek Polacek <polacek@redhat.com>
Mon, 9 Nov 2020 15:19:07 +0000 (10:19 -0500)
committerMarek Polacek <polacek@redhat.com>
Mon, 9 Nov 2020 19:39:36 +0000 (14:39 -0500)
commit3a5f8d745f8e26d973218b088788f22ad197ca67
treeb6db6efcdffa3c475dbc13854f1e5f6a7e586917
parent6624075e7e996d61143bf5fc106fa2cb61c614f6
c++: Fix -Wvexing-parse ICE with omitted int [PR97762]

For declarations like

  long f();

decl_specifiers->type will be NULL, but I neglected to handle this case,
therefore we ICE.  So handle this case by pretending we've seen 'int',
which is good enough for -Wvexing-parse's purposes.

gcc/cp/ChangeLog:

PR c++/97762
* parser.c (warn_about_ambiguous_parse): Handle the case when
there is no type in the decl-specifiers.

gcc/testsuite/ChangeLog:

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