]> git.ipfire.org Git - thirdparty/gcc.git/commit
OpenMP: give error when variant is the same as the base function [PR118839]
authorSandra Loosemore <sloosemore@baylibre.com>
Mon, 25 Aug 2025 01:43:50 +0000 (01:43 +0000)
committerSandra Loosemore <sloosemore@baylibre.com>
Tue, 26 Aug 2025 23:39:23 +0000 (23:39 +0000)
commita43c30cb6f451d60b7e19be09da075ab0ff5830f
treed6623700f1eda033fe24e74de447067d5ae034bf
parent445ce984890282da6b71a08c593a40b2237e52af
OpenMP: give error when variant is the same as the base function [PR118839]

As noted in the issue, the C++ front end has deeper problems: it's
supposed to do the name lookup of the variant at the call site but is
instead doing it when parsing the "declare variant" construct, before
registering the decl for the base function.  The C++ part of the
patch is a band-aid to catch the case where there is a previous declaration
of the function and it doesn't give an undefined symbol error instead.
Some real solution ought to be included as part of fixing PR118791.

gcc/c/
PR middle-end/118839
* c-parser.cc (c_finish_omp_declare_variant): Error if variant
is the same as base.

gcc/cp/
PR middle-end/118839
* decl.cc (omp_declare_variant_finalize_one): Error if variant
is the same as base.

gcc/fortran/
PR middle-end/118839
* trans-openmp.cc (gfc_trans_omp_declare_variant): Error if variant
is the same as base.

gcc/testsuite/
PR middle-end/118839
* gcc.dg/gomp/declare-variant-3.c: New.
* gfortran.dg/gomp/declare-variant-22.f90: New.
gcc/c/c-parser.cc
gcc/cp/decl.cc
gcc/fortran/trans-openmp.cc
gcc/testsuite/gcc.dg/gomp/declare-variant-3.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/declare-variant-22.f90 [new file with mode: 0644]