On 14/10/2021 1:47 pm, Jakub Jelinek wrote:
What I still miss is tests for the (proc_name : variant_name) syntax
in places where proc_name : is optional, but is supplied and is valid, like
e.g. in interface, or in subroutine/function and where proc_name specifies
the name of the containing interface or subroutine/function.
I see that syntax tested in some places with dg-error on that line and
in spaces where it isn't optional (e.g. at module scope before contains).
But if you want, that can be added incrementally.

Do you mean something like these tests?

Thanks

Kwok
From 38733234024697d2144613c4a992e970f40afad8 Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <k...@codesourcery.com>
Date: Mon, 18 Oct 2021 13:56:59 -0700
Subject: [PATCH] openmp: Add additional tests for declare variant in Fortran

Add tests to check that explicitly specifying the containing procedure as the
base name for declare variant works.

2021-10-18  Kwok Cheung Yeung  <k...@codesourcery.com>

gcc/testsuite/

        * gfortran.dg/gomp/declare-variant-15.f90 (variant2, base2, test2):
        Add tests.
        * gfortran.dg/gomp/declare-variant-16.f90 (base2, variant2, test2):
        Add tests.
---
 .../gfortran.dg/gomp/declare-variant-15.f90        | 13 +++++++++++++
 .../gfortran.dg/gomp/declare-variant-16.f90        | 14 +++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-15.f90 
b/gcc/testsuite/gfortran.dg/gomp/declare-variant-15.f90
index b2ad96a8998..4a88e3e46c7 100644
--- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-15.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-15.f90
@@ -14,6 +14,13 @@ contains
   subroutine base ()
   end subroutine
 
+  subroutine variant2 ()
+  end subroutine
+
+  subroutine base2 ()
+    !$omp declare variant (base2: variant2) match (construct={parallel})
+  end subroutine
+
   subroutine test1 ()
     !$omp target
       !$omp parallel
@@ -21,4 +28,10 @@ contains
       !$omp end parallel
     !$omp end target
   end subroutine
+
+  subroutine test2 ()
+    !$omp parallel
+       call base2 ()   ! { dg-final { scan-tree-dump-times "variant2 
\\\(\\\);" 1 "gimple" } }
+    !$omp end parallel
+  end subroutine
 end module
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-variant-16.f90 
b/gcc/testsuite/gfortran.dg/gomp/declare-variant-16.f90
index fc97322e667..5e34d474da4 100644
--- a/gcc/testsuite/gfortran.dg/gomp/declare-variant-16.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/declare-variant-16.f90
@@ -10,15 +10,27 @@ module main
     subroutine base ()
       !$omp declare variant (variant) match (construct={parallel})
     end subroutine
+    
+    subroutine base2 ()
+      !$omp declare variant (base2: variant2) match (construct={target})
+    end subroutine
   end interface
-
 contains
   subroutine variant ()
   end subroutine
 
+  subroutine variant2 ()
+  end subroutine
+
   subroutine test ()
     !$omp parallel
       call base ()  ! { dg-final { scan-tree-dump-times "variant \\\(\\\);" 1 
"gimple" } }
     !$omp end parallel
   end subroutine
+
+  subroutine test2 ()
+    !$omp target
+      call base2 ()  ! { dg-final { scan-tree-dump-times "variant2 \\\(\\\);" 
1 "gimple" } }
+    !$omp end target
+  end subroutine
 end module
-- 
2.30.0.335.ge636282

Reply via email to