aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/jit.dg/test-sized-float.c
diff options
context:
space:
mode:
authorJoseph Myers <josmyers@redhat.com>2025-10-24 00:47:54 +0000
committerJoseph Myers <josmyers@redhat.com>2025-10-24 00:47:54 +0000
commit81a7f4fef35542a5daac8dbd12597c0428fdd43c (patch)
treef5aa5961eb8dd242aafd717c91b6f314d4d63a94 /gcc/testsuite/jit.dg/test-sized-float.c
parent5abeecf68ed5a76a81854dcc3a5bfcb7c8752fa9 (diff)
downloadgcc-master.zip
gcc-master.tar.gz
gcc-master.tar.bz2
c: Implement C2y static assertions in expressionsHEADtrunkmaster
C2y has added support for static assertions as void expressions, in addition to use as declarations (N3715 was accepted in an online vote between meetings). Implement the feature in GCC. There is a syntactic ambiguity between a static assertion as a declaration and one as an expression statement, which the accepted feature resolves by making such a usage a declaration (this only affects the sequence of syntax productions by which the code is parsed, not the actual semantics of the assertion); I've raised the similar ambiguity in for loops on the WG14 reflector. If just concerned with C2y, and not with diagnosing the use of a feature not supported in older standard versions, the feature might be simpler to implement by defaulting to treating static assertions in ambiguous contexts as expressions rather than declarations, but that would make it hard to diagnose exactly the cases that are new in C2y (those depend on the static assertion either not being the whole expression statement, or being in a context where an expression statement is allowed but a declaration is not, e.g. the body of an if statement). Instead, to support such diagnostics, the implementation follows the standard in what is considered a declaration and what is considered an expression, by looking ahead to what follows the closing parenthesis when a static assertion starts in a context where a declaration is permitted. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-parser.cc (c_parser_next_tokens_start_typename) (c_parser_next_tokens_start_declaration): Add argument for token to start from (c_parser_next_tokens_start_declaration): Check for whether static assertion followed by semicolon. (c_parser_check_balanced_raw_token_sequence): Declare earlier. (c_parser_compound_statement_nostart, c_parser_for_statement): Use c_parser_next_tokens_start_declaration not c_token_starts_declaration on second token. (c_parser_unary_expression): Handle static assertions. * c-parser.h (c_parser_next_tokens_start_declaration): Add argument. gcc/testsuite/ * gcc.dg/c23-static-assert-5.c, gcc.dg/c23-static-assert-6.c, gcc.dg/c23-static-assert-7.c, gcc.dg/c23-static-assert-8.c, gcc.dg/c2y-static-assert-2.c, gcc.dg/c2y-static-assert-3.c, gcc.dg/c2y-static-assert-4.c: New tests.
Diffstat (limited to 'gcc/testsuite/jit.dg/test-sized-float.c')
0 files changed, 0 insertions, 0 deletions