aboutsummaryrefslogtreecommitdiff
path: root/gcc/function.cc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2024-10-31 09:28:15 -0400
committerMarek Polacek <polacek@redhat.com>2024-11-08 17:28:08 -0500
commit440be01b07941506d1c8819448bd17c8717d55f5 (patch)
tree97b5626cf8f6b0a45787392fde7add70f5857c20 /gcc/function.cc
parent7175fece7df50326703e4ca8b49d7cc93a5e8dfe (diff)
downloadgcc-440be01b07941506d1c8819448bd17c8717d55f5.zip
gcc-440be01b07941506d1c8819448bd17c8717d55f5.tar.gz
gcc-440be01b07941506d1c8819448bd17c8717d55f5.tar.bz2
c: Implement C2y N3356, if declarations [PR117019]
This patch implements C2y N3356, if declarations as described at <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3356.htm>. This feature is cognate with C++17 Selection statements with initializer <https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0305r1.html>, but they are not the same yet. For example, C++17 allows if (lock (); int i = getval ()) whereas C2y does not. The proposal adds new grammar productions. selection-header is handled in c_parser_selection_header which is the gist of the patch. simple-declaration is handled by c_parser_declaration_or_fndef, which gets a new parameter. PR c/117019 gcc/c/ChangeLog: * c-parser.cc (c_parser_declaration_or_fndef): Adjust declaration. (c_parser_external_declaration): Adjust a call to c_parser_declaration_or_fndef. (c_parser_declaration_or_fndef): New bool parameter. Return a tree instead of void. Adjust for N3356. Adjust a call to c_parser_declaration_or_fndef. (c_parser_compound_statement_nostart): Adjust calls to c_parser_declaration_or_fndef. (c_parser_selection_header): New. (c_parser_paren_selection_header): New. (c_parser_if_statement): Call c_parser_paren_selection_header instead of c_parser_paren_condition. (c_parser_switch_statement): Call c_parser_selection_header instead of c_parser_expression. (c_parser_for_statement): Adjust calls to c_parser_declaration_or_fndef. (c_parser_objc_methodprotolist): Likewise. (c_parser_oacc_routine): Likewise. (c_parser_omp_loop_nest): Likewise. (c_parser_omp_declare_simd): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/c23-if-decls-1.c: New test. * gcc.dg/c23-if-decls-2.c: New test. * gcc.dg/c2y-if-decls-1.c: New test. * gcc.dg/c2y-if-decls-2.c: New test. * gcc.dg/c2y-if-decls-3.c: New test. * gcc.dg/c2y-if-decls-4.c: New test. * gcc.dg/c2y-if-decls-5.c: New test. * gcc.dg/c2y-if-decls-6.c: New test. * gcc.dg/c2y-if-decls-7.c: New test. * gcc.dg/c2y-if-decls-8.c: New test. * gcc.dg/c2y-if-decls-9.c: New test. * gcc.dg/c2y-if-decls-10.c: New test. * gcc.dg/c2y-if-decls-11.c: New test. * gcc.dg/gnu2y-if-decls-1.c: New test. * gcc.dg/gnu99-if-decls-1.c: New test. * gcc.dg/gnu99-if-decls-2.c: New test.
Diffstat (limited to 'gcc/function.cc')
0 files changed, 0 insertions, 0 deletions