Hello This patch adds support for the OpenMP 'declare variant' directive in Fortran (C/C++ support is already present). For most part, this is a straightforward port of the C frontend code. I have ported all the c-c++-common/gomp/declare-variant-*.c tests to Fortran in gfortran.dg/gomp/, skipping over any tests involving inline assembly. I have also ported libgomp.c/target-42.c to Fortran as libgomp.fortran/declare-variant-1.f90. I have moved the c_omp_check_context_selector and c_omp_mark_declare_variant functions from c-family/c-omp.c into omp-general.c and removed the 'c_' prefix, as these functions can be reused for Fortran. Since the Fortran FE parses code first before translating it into tree form, fatal parser errors in a source file will result in errors in the same source file that are detected at translation time not being displayed (as compilation does not reach that stage). I have therefore separated out the translation errors in declare-variant-2.f90 into declare-variant-2a.f90. In secion 2.3.1 of the OpenMP 5.0 spec, it says: 3. For functions within a declare target block, the target trait is added to the beginning of the set... But OpenMP in Fortran doesn't have the notion of a declare target _block_ (i.e. the #pragma omp declare target/#pragma omp end declare target form), only the !$omp declare target (extended-list)/[clause] form (which C/C++ also has). The C FE differentiates between the two (it applies an 'omp declare target block' attribute for the first, an 'omp declare target' for the second) but only the first matches against the 'target' construct in a context selector. I opted to match against 'omp declare target' for Fortran only, otherwise this functionality won't get exercised in Fortran at all. This difference is tested in test3 of declare-variant-8.f90, which I have XFAILed for now. The Fortran 'declare variant' directive can also optionally take the name of the base procedure - this is implemented by moving any 'declare variant' directives with a matching base name in the parent namespaces of a function into the function namespace itself, such that at translation time it appears as if the directive was placed in the base procedure. This is tested in declare-variant-15.f90. Bootstrapped on x86_64, and the gfortran testsuite and libgomp.fortran tests run with no regressions. Okay for trunk? Thanks Kwok Yeung