openmp: Provide fixit hints for -Wdeprecated-openmp diagnostics from C FE
I think especially the linear clause -Wdeprecated-openmp diagnostics
will be complete nightmare for users, when they have
linear (ref (x, y, z))
or
linear (uval (a, b, c) : 2)
they will have no clue what the new syntax is.
Here is a so far lightly tested attempt to provide fixit hints for most
of these warnings, and even -fdiagnostics-generate-patch can then be
useful for porting.
And so far I've done just the C FE.
Some issues:
1) I have no idea what to do about
or their attribute variants, for pragmas the location_t one gets is
the omp keyword, not master or declare, and there is no other location_t
easily available to add a fixit hint that master -> masked or
begin inserted before declare. And for attributes I have no idea what
location_t we get there. Note, for omp parallel master or omp parallel
master taskloop I do emit fixit hints.
2) I think there is a missing warning for
(similar case to reduction clause with - identifier)
3) I think the map clause diagnostics for missing comma separation
will not diagnose
just missing commas in between multiple modifiers (and I've fixed it
not to emit diagnostics multiple times if only one comma is missing,
e.g.
would I think diagnose missing comma twice.
2025-12-13 Jakub Jelinek <jakub@redhat.com>
* c-parser.cc (c_parser_omp_clause_reduction): Provide fixit hints
for -Wdeprecated-openmp diagnostics.
(c_parser_omp_clause_linear): Likewise.
(c_parser_omp_clause_depend): Likewise. Add HERE argument.
(c_parser_omp_clause_map): Provide fixit hints for -Wdeprecated-openmp
diagnostics. Reset num_commas after the diagnostics.
(c_parser_omp_clause_proc_bind): Provide fixit hints for
-Wdeprecated-openmp diagnostics.
(c_parser_omp_all_clauses): Move -Wdeprecated-openmp diagnostics
for to vs. enter here, add fixit hints for it. Adjust
c_parser_omp_clause_depend caller.
(c_parser_omp_depobj): Adjust c_parser_omp_clause_depend caller.
(c_parser_omp_master): Add MASTER_LOC argument. Provide fixit hints
for -Wdeprecated-openmp diagnostics.
(c_parser_omp_parallel): Adjust c_parser_omp_master caller.
(c_parser_omp_declare_target): Don't emit -Wdeprecated-openmp
warning for to vs. enter here.
(c_parser_omp_metadirective): Provide fixit hints for
-Wdeprecated-openmp diagnostics.
(c_parser_omp_construct): Adjust c_parser_omp_master caller.
* c-c++-common/gomp/52-deps.c: Change locations of 2 warnings for C.
* gcc.dg/gomp/deprecate-1.c: New test.