-
- Downloads
openmp: Allow optional comma after directive-specifier in C/C++
Previously we've been allowing that comma only in C++ when in attribute form (which was the reason why it has been allowed), but 5.1 allows that even in pragma form in C/C++ (with clarifications in 5.2) and 5.2 also in Fortran (which this patch doesn't implement). Note, for directives which take an argument (== unnamed clause), comma is not allowed in between the directive name and the argument, like the directive-1.c testcase shows. 2022-10-28 Jakub Jelinek <jakub@redhat.com> gcc/c/ * c-parser.cc (c_parser_omp_all_clauses): Allow optional comma before the first clause. (c_parser_omp_allocate, c_parser_omp_atomic, c_parser_omp_depobj, c_parser_omp_flush, c_parser_omp_scan_loop_body, c_parser_omp_ordered, c_finish_omp_declare_variant, c_parser_omp_declare_target, c_parser_omp_declare_reduction, c_parser_omp_requires, c_parser_omp_error, c_parser_omp_assumption_clauses): Likewise. gcc/cp/ * parser.cc (cp_parser_omp_all_clauses): Allow optional comma before the first clause even in pragma syntax. (cp_parser_omp_allocate, cp_parser_omp_atomic, cp_parser_omp_depobj, cp_parser_omp_flush, cp_parser_omp_scan_loop_body, cp_parser_omp_ordered, cp_parser_omp_assumption_clauses, cp_finish_omp_declare_variant, cp_parser_omp_declare_target, cp_parser_omp_declare_reduction_exprs, cp_parser_omp_requires, cp_parser_omp_error): Likewise. gcc/testsuite/ * c-c++-common/gomp/directive-1.c: New test. * c-c++-common/gomp/clauses-6.c: New test. * c-c++-common/gomp/declare-variant-2.c (f75a): Declare. (f75): Use f75a as variant instead of f1 and don't expect error. * g++.dg/gomp/clause-4.C (foo): Don't expect error on comma before first clause. * gcc.dg/gomp/clause-2.c (foo): Likewise.
Showing
- gcc/c/c-parser.cc 37 additions, 27 deletionsgcc/c/c-parser.cc
- gcc/cp/parser.cc 14 additions, 59 deletionsgcc/cp/parser.cc
- gcc/testsuite/c-c++-common/gomp/clauses-6.c 604 additions, 0 deletionsgcc/testsuite/c-c++-common/gomp/clauses-6.c
- gcc/testsuite/c-c++-common/gomp/declare-variant-2.c 2 additions, 1 deletiongcc/testsuite/c-c++-common/gomp/declare-variant-2.c
- gcc/testsuite/c-c++-common/gomp/directive-1.c 28 additions, 0 deletionsgcc/testsuite/c-c++-common/gomp/directive-1.c
- gcc/testsuite/g++.dg/gomp/clause-4.C 1 addition, 1 deletiongcc/testsuite/g++.dg/gomp/clause-4.C
- gcc/testsuite/gcc.dg/gomp/clause-2.c 1 addition, 1 deletiongcc/testsuite/gcc.dg/gomp/clause-2.c
Loading
Please register or sign in to comment