c++: Fix ICE-on-invalid with broken attribute [PR93684]
authorMarek Polacek <polacek@redhat.com>
Tue, 11 Feb 2020 20:29:24 +0000 (15:29 -0500)
committerMarek Polacek <polacek@redhat.com>
Wed, 12 Feb 2020 15:39:40 +0000 (10:39 -0500)
commite428a9cf85a8bdde9d031a215e10bd96eb3b789a
treef1114cb0ec663b33cfd430fac74b4857059c98ff
parent62fc0a6ce28c502fc6a7b7c09157840bf98f945f
c++: Fix ICE-on-invalid with broken attribute [PR93684]

We crash when parsing

  [[a::

because we see a CPP_SCOPE and then we're trying to consume a CPP_EOF
token.  So peek before consuming it.

PR c++/93684 - ICE-on-invalid with broken attribute.
* parser.c (cp_parser_std_attribute): Peek a token first before
consuming it.

* g++.dg/parse/attr4.C: New test.
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/attr4.C [new file with mode: 0644]