https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121657
Gabriel Ravier <gabravier at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gabravier at gmail dot com
--- Comment #3 from Gabriel Ravier <gabravier at gmail dot com> ---
I encountered what I believe to be the same issue as the A{}.z issue (not the
get() one) on this code:
#include <cstddef>
alignas(int(16)) char buf[16];
struct alignas(std::size_t(64)) S {};
(which Clang parses fine) with error:
<source>:3:12: error: expected ')' before '(' token
3 | alignas(int(16)) char buf[16];
| ~ ^
| )
[etc.]
<source>:4:27: error: expected ')' before '(' token
4 | struct alignas(std::size_t(64)) S {};
| ~ ^
| )
[etc.]
...looks to be the same all the way down to GCC 4.8, too :) (GCC 4.7 didn't
parse alignas).
My reading of the code is that cp_parser_std_attribute_spec just won't back out
of parsing a type-id even if the parse would fail after that:
cp_parser_parse_tentatively (parser);
alignas_expr = cp_parser_type_id (parser);
if (!cp_parser_parse_definitely (parser))
{
alignas_expr = cp_parser_assignment_expression (parser);
if (alignas_expr == error_mark_node)
cp_parser_skip_to_end_of_statement (parser);
if (alignas_expr == NULL_TREE
|| alignas_expr == error_mark_node)
return alignas_expr;
}
...My understanding is that type-id here is only valid if it's followed by `)`
or `...` ? I assume it could check for those and simulate error if neither of
those are present (I have not tested that) - I believe
cp_parser_template_argument already does something of the sort.