]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP: Handle 'all' as category in defaultmap
authorTobias Burnus <tobias@codesourcery.com>
Tue, 22 Aug 2023 15:06:50 +0000 (17:06 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 22 Aug 2023 15:06:50 +0000 (17:06 +0200)
Both, specifying no category and specifying 'all', implies
that the implicit-behavior applies to all categories.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_clause_defaultmap): Parse
'all' as category.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_clause_defaultmap): Parse
'all' as category.

gcc/fortran/ChangeLog:

* gfortran.h (enum gfc_omp_defaultmap_category):
Add OMP_DEFAULTMAP_CAT_ALL.
* openmp.cc (gfc_match_omp_clauses): Parse
'all' as category.
* trans-openmp.cc (gfc_trans_omp_clauses): Handle it.

gcc/ChangeLog:

* tree-core.h (enum omp_clause_defaultmap_kind): Add
OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL.
* gimplify.cc (gimplify_scan_omp_clauses): Handle it.
* tree-pretty-print.cc (dump_omp_clause): Likewise.

libgomp/ChangeLog:

* libgomp.texi (OpenMP 5.2 status): Add depobj with
destroy-var argument as 'N'. Mark defaultmap with
'all' category as 'Y'.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/defaultmap-1.f90: Update dg-error.
* c-c++-common/gomp/defaultmap-5.c: New test.
* c-c++-common/gomp/defaultmap-6.c: New test.
* gfortran.dg/gomp/defaultmap-10.f90: New test.
* gfortran.dg/gomp/defaultmap-9.f90: New test.

14 files changed:
gcc/c/c-parser.cc
gcc/cp/parser.cc
gcc/fortran/gfortran.h
gcc/fortran/openmp.cc
gcc/fortran/trans-openmp.cc
gcc/gimplify.cc
gcc/testsuite/c-c++-common/gomp/defaultmap-5.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/defaultmap-6.c [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/defaultmap-1.f90
gcc/testsuite/gfortran.dg/gomp/defaultmap-10.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90 [new file with mode: 0644]
gcc/tree-core.h
gcc/tree-pretty-print.cc
libgomp/libgomp.texi

index 33fe7b115ffa138fde9820988c2e27887cc184bd..4a4820d792c7dea86eb1e7e800abcab4c62a2d5e 100644 (file)
@@ -15067,8 +15067,8 @@ c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
       if (!c_parser_next_token_is (parser, CPP_NAME))
        {
        invalid_category:
-         c_parser_error (parser, "expected %<scalar%>, %<aggregate%> or "
-                                 "%<pointer%>");
+         c_parser_error (parser, "expected %<scalar%>, %<aggregate%>, "
+                                 "%<pointer%> or %<all%>");
          goto out_err;
        }
       p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
@@ -15077,6 +15077,8 @@ c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
        case 'a':
          if (strcmp ("aggregate", p) == 0)
            category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE;
+         else if (strcmp ("all", p) == 0)
+           category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL;
          else
            goto invalid_category;
          break;
@@ -15106,13 +15108,19 @@ c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
   for (c = list; c ; c = OMP_CLAUSE_CHAIN (c))
     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEFAULTMAP
        && (category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+           || category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
            || OMP_CLAUSE_DEFAULTMAP_CATEGORY (c) == category
            || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
-               == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
+               == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+           || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+               == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL)))
       {
        enum omp_clause_defaultmap_kind cat = category;
        location_t loc = OMP_CLAUSE_LOCATION (c);
-       if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+       if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+           || (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
+               && (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+                   != OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
          cat = OMP_CLAUSE_DEFAULTMAP_CATEGORY (c);
        p = NULL;
        switch (cat)
@@ -15120,6 +15128,9 @@ c_parser_omp_clause_defaultmap (c_parser *parser, tree list)
          case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
            p = NULL;
            break;
+         case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
+           p = "all";
+           break;
          case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
            p = "aggregate";
            break;
index 774706ac6079fa71c91ab72b68a50e63f04457ff..eeb22e44fb4a08fd4d54d6c0dc0b15b2c07b41cf 100644 (file)
@@ -38810,8 +38810,8 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
       if (!cp_lexer_next_token_is (parser->lexer, CPP_NAME))
        {
        invalid_category:
-         cp_parser_error (parser, "expected %<scalar%>, %<aggregate%> or "
-                                  "%<pointer%>");
+         cp_parser_error (parser, "expected %<scalar%>, %<aggregate%>, "
+                                  "%<all%>");
          goto out_err;
        }
       id = cp_lexer_peek_token (parser->lexer)->u.value;
@@ -38822,6 +38822,8 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
        case 'a':
          if (strcmp ("aggregate", p) == 0)
            category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE;
+         else if (strcmp ("all", p) == 0)
+           category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL;
          else
            goto invalid_category;
          break;
@@ -38852,13 +38854,19 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
   for (c = list; c ; c = OMP_CLAUSE_CHAIN (c))
     if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEFAULTMAP
        && (category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+           || category == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
            || OMP_CLAUSE_DEFAULTMAP_CATEGORY (c) == category
            || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
-               == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
+               == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+           || (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+               == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL)))
       {
        enum omp_clause_defaultmap_kind cat = category;
        location_t loc = OMP_CLAUSE_LOCATION (c);
-       if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+       if (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED
+           || (cat == OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL
+               && (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c)
+                   != OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)))
          cat = OMP_CLAUSE_DEFAULTMAP_CATEGORY (c);
        p = NULL;
        switch (cat)
@@ -38866,6 +38874,9 @@ cp_parser_omp_clause_defaultmap (cp_parser *parser, tree list,
          case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
            p = NULL;
            break;
+         case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
+           p = "all";
+           break;
          case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
            p = "aggregate";
            break;
index fd47000a88efd00640ab3d43324f50c0614ddd59..cce9688ee6a5ba4c94baf63bbb009cc0553bad7b 100644 (file)
@@ -1334,6 +1334,7 @@ enum gfc_omp_defaultmap
 enum gfc_omp_defaultmap_category
 {
   OMP_DEFAULTMAP_CAT_UNCATEGORIZED,
+  OMP_DEFAULTMAP_CAT_ALL,
   OMP_DEFAULTMAP_CAT_SCALAR,
   OMP_DEFAULTMAP_CAT_AGGREGATE,
   OMP_DEFAULTMAP_CAT_ALLOCATABLE,
index bee3015e484fa80c7d263c9bbf1c51d954e5b26f..2ffbf6f5ef98f621ab208bc24ec36e046ead8a58 100644 (file)
@@ -2250,17 +2250,22 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
                    category = OMP_DEFAULTMAP_CAT_ALLOCATABLE;
                  else if (gfc_match ("pointer ") == MATCH_YES)
                    category = OMP_DEFAULTMAP_CAT_POINTER;
+                 else if (gfc_match ("all ") == MATCH_YES)
+                   category = OMP_DEFAULTMAP_CAT_ALL;
                  else
                    {
-                     gfc_error ("Expected SCALAR, AGGREGATE, ALLOCATABLE or "
-                                "POINTER at %C");
+                     gfc_error ("Expected SCALAR, AGGREGATE, ALLOCATABLE, "
+                                "POINTER or ALL at %C");
                      break;
                    }
                }
              for (int i = 0; i < OMP_DEFAULTMAP_CAT_NUM; ++i)
                {
                  if (i != category
-                     && category != OMP_DEFAULTMAP_CAT_UNCATEGORIZED)
+                     && category != OMP_DEFAULTMAP_CAT_UNCATEGORIZED
+                     && category != OMP_DEFAULTMAP_CAT_ALL
+                     && i != OMP_DEFAULTMAP_CAT_UNCATEGORIZED
+                     && i != OMP_DEFAULTMAP_CAT_ALL)
                    continue;
                  if (c->defaultmap[i] != OMP_DEFAULTMAP_UNSET)
                    {
@@ -2268,6 +2273,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
                      switch (i)
                        {
                        case OMP_DEFAULTMAP_CAT_UNCATEGORIZED: break;
+                       case OMP_DEFAULTMAP_CAT_ALL: pcategory = "ALL"; break;
                        case OMP_DEFAULTMAP_CAT_SCALAR: pcategory = "SCALAR"; break;
                        case OMP_DEFAULTMAP_CAT_AGGREGATE:
                          pcategory = "AGGREGATE";
index cf741cebf91b7596940c8656568b67276211fb90..2f116fd673808201517c3561260635601c6d0c11 100644 (file)
@@ -4443,6 +4443,9 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
        case OMP_DEFAULTMAP_CAT_UNCATEGORIZED:
          category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
          break;
+       case OMP_DEFAULTMAP_CAT_ALL:
+         category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL;
+         break;
        case OMP_DEFAULTMAP_CAT_SCALAR:
          category = OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR;
          break;
index 7549436944c369f690b01b13dbea90a62118f4f4..9a9919e2f2f5c85ca0fb4018e8a0904322a0099c 100644 (file)
@@ -12037,6 +12037,7 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
          switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (c))
            {
            case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
+           case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
              gdmkmin = GDMK_SCALAR;
              gdmkmax = GDMK_POINTER;
              break;
diff --git a/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c b/gcc/testsuite/c-c++-common/gomp/defaultmap-5.c
new file mode 100644 (file)
index 0000000..cc1a77f
--- /dev/null
@@ -0,0 +1,47 @@
+/* { dg-additional-options "-fdump-tree-original -fdump-tree-gimple" } */
+
+void f()
+{
+  struct s {
+    int i;
+  };
+  int scalar1 = 5;
+  int array1[5] = {1,2,3,4,5};
+  int *ptr1 = &scalar1;
+  struct s mystruct1 = {.i = 5};
+
+  /* firstprivate + unspecified modifer. */
+  #pragma omp target defaultmap(firstprivate)
+   {
+     scalar1 = 1;
+     array1[0] = 2;
+     if (ptr1 == 0L)
+       mystruct1.i = 3;
+   }
+
+  /* equivalent: firstprivate + ALL modifer. */
+  #pragma omp target defaultmap(firstprivate : all)
+   {
+     scalar1 = 1;
+     array1[0] = 2;
+     if (ptr1 == 0L)
+       mystruct1.i = 3;
+   }
+
+  /* tofrom + ALL modifer. */
+  #pragma omp target defaultmap(tofrom : all)
+   {
+     scalar1 = 1;
+     array1[0] = 2;
+     if (ptr1 == 0L)
+       mystruct1.i = 3;
+   }
+}
+
+/* { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(firstprivate\\)" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(firstprivate:all\\)" 1 "original" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(tofrom:all\\)" 1 "original" } } */
+
+/* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate\\) firstprivate\\(mystruct1\\) firstprivate\\(ptr1\\) firstprivate\\(array1\\) firstprivate\\(scalar1\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate:all\\) firstprivate\\(mystruct1\\) firstprivate\\(ptr1\\) firstprivate\\(array1\\) firstprivate\\(scalar1\\)" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(tofrom:all\\) map\\(tofrom:mystruct1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:ptr1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:array1 \\\[len: ..\\\]\\\[implicit\\\]\\) map\\(tofrom:scalar1 \\\[len: .\\\]\\\[implicit\\\]\\)" 1 "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/defaultmap-6.c b/gcc/testsuite/c-c++-common/gomp/defaultmap-6.c
new file mode 100644 (file)
index 0000000..45fce8b
--- /dev/null
@@ -0,0 +1,48 @@
+void f()
+{
+  struct s {
+    int i;
+  };
+  int scalar1 = 5;
+  int array1[5] = {1,2,3,4,5};
+  int *ptr1 = &scalar1;
+  struct s mystruct1 = {.i = 5};
+
+  #pragma omp target defaultmap(firstprivate ) defaultmap(firstprivate : aggregate)  /* { dg-error "too many 'defaultmap' clauses with 'aggregate' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+
+  #pragma omp target defaultmap(firstprivate : all ) defaultmap(alloc : pointer) /* { dg-error "too many 'defaultmap' clauses with 'pointer' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+
+
+  #pragma omp target defaultmap(firstprivate : aggregate)  defaultmap(firstprivate ) /* { dg-error "too many 'defaultmap' clauses with 'aggregate' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+
+  #pragma omp target defaultmap(alloc : pointer) defaultmap(firstprivate : all )  /* { dg-error "too many 'defaultmap' clauses with 'pointer' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+
+  #pragma omp target defaultmap(firstprivate :all ) defaultmap(firstprivate : all) /* { dg-error "too many 'defaultmap' clauses with 'all' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+  #pragma omp target defaultmap(firstprivate ) defaultmap(firstprivate) /* { dg-error "too many 'defaultmap' clauses with unspecified category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+  #pragma omp target defaultmap(firstprivate ) defaultmap(firstprivate : all) /* { dg-error "too many 'defaultmap' clauses with 'all' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+  #pragma omp target defaultmap(firstprivate : all) defaultmap(firstprivate) /* { dg-error "too many 'defaultmap' clauses with 'all' category" }  */
+   {
+     scalar1 = 1; array1[0] = 2; if (ptr1 == 0L) mystruct1.i = 3;
+   }
+}
index 1f1b8528aef012cec98f9c1248e9c4452ed336ee..5123e078e98df15f233aed92ea25b46ff0588e28 100644 (file)
@@ -4,7 +4,7 @@ implicit none
 
 !$omp target defaultmap(bar)  ! { dg-error "25: Expected ALLOC, TO, FROM, TOFROM, FIRSTPRIVATE, PRESENT, NONE or DEFAULT" }
 
-!$omp target defaultmap ( alloc: foo)  ! { dg-error "34: Expected SCALAR, AGGREGATE, ALLOCATABLE or POINTER" }
+!$omp target defaultmap ( alloc: foo)  ! { dg-error "34: Expected SCALAR, AGGREGATE, ALLOCATABLE, POINTER or ALL" }
 
 !$omp target defaultmap(alloc:scalar) defaultmap(none:Scalar)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category SCALAR" }
 
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-10.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-10.f90
new file mode 100644 (file)
index 0000000..7e230d8
--- /dev/null
@@ -0,0 +1,116 @@
+subroutine f
+  implicit none
+  type t
+    integer :: i
+  end type t
+  integer, target :: scalar
+  integer, target :: array(5)
+  integer, pointer :: ptr1, ptr2(:)
+  integer, allocatable :: alloc1, alloc2(:)
+  type(t) :: agg1, agg2(2)
+
+  scalar = 1
+  array = [1,2,3,4,5]
+  ptr1 => scalar
+  ptr2 => array
+  alloc1 = 5
+  alloc2 = [1,2]
+  agg1%i = 1
+  agg2(:)%i = [1,2]
+
+  !$omp target defaultmap(firstprivate ) defaultmap(firstprivate : aggregate)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP with unspecified category" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate : all ) defaultmap(alloc : pointer)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category ALL" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate : aggregate)  defaultmap(firstprivate )  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category AGGREGATE" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(alloc : pointer) defaultmap(firstprivate : all )   ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category POINTER" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate :all ) defaultmap(firstprivate : all)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category ALL" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate ) defaultmap(firstprivate)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP with unspecified category" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate ) defaultmap(firstprivate : all)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP with unspecified category" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  !$omp target defaultmap(firstprivate : all) defaultmap(firstprivate)  ! { dg-error "DEFAULTMAP at .1. but prior DEFAULTMAP for category ALL" }
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+end
diff --git a/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90 b/gcc/testsuite/gfortran.dg/gomp/defaultmap-9.f90
new file mode 100644 (file)
index 0000000..b24fc95
--- /dev/null
@@ -0,0 +1,71 @@
+! { dg-additional-options "-fdump-tree-original -fdump-tree-gimple" }
+
+subroutine f
+  implicit none
+  type t
+    integer :: i
+  end type t
+  integer, target :: scalar
+  integer, target :: array(5)
+  integer, pointer :: ptr1, ptr2(:)
+  integer, allocatable :: alloc1, alloc2(:)
+  type(t) :: agg1, agg2(2)
+
+  scalar = 1
+  array = [1,2,3,4,5]
+  ptr1 => scalar
+  ptr2 => array
+  alloc1 = 5
+  alloc2 = [1,2]
+  agg1%i = 1
+  agg2(:)%i = [1,2]
+
+  ! firstprivate + unspecified modifer.
+  !$omp target defaultmap(firstprivate)
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  ! equivalent: firstprivate + ALL modifer.
+  !$omp target defaultmap(firstprivate : all)
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+
+  ! tofrom + ALL modifer.
+  !$omp target defaultmap(tofrom : all)
+  block
+   scalar = 1;
+   array(1) = 2;
+   if (associated(ptr1)) &
+     agg1%i = 3;
+   if (associated(ptr2)) &
+     agg2(1)%i = 3;
+   if (allocated(alloc1)) &
+     alloc2(1) = 0
+  end block
+end subroutine
+
+! { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(firstprivate\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(firstprivate:all\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times "#pragma omp target defaultmap\\(tofrom:all\\)" 1 "original" } }
+
+! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate\\) firstprivate\\(scalar\\) firstprivate\\(ptr2\\) firstprivate\\(ptr1\\) firstprivate\\(array\\) firstprivate\\(alloc2\\) firstprivate\\(alloc1\\) firstprivate\\(agg2\\) firstprivate\\(agg1\\)" 1 "gimple" } }
+
+! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(firstprivate:all\\) firstprivate\\(scalar\\) firstprivate\\(ptr2\\) firstprivate\\(ptr1\\) firstprivate\\(array\\) firstprivate\\(alloc2\\) firstprivate\\(alloc1\\) firstprivate\\(agg2\\) firstprivate\\(agg1\\)" 1 "gimple" } }
+
+! { dg-final { scan-tree-dump-times "#pragma omp target.* defaultmap\\(tofrom:all\\) map\\(tofrom:scalar \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:.*ptr2.data \\\[len: .*\\\]\\\[implicit\\\]\\) map\\(to:ptr2 \\\[pointer set, len: ..\\\]\\) map\\(always_pointer:.*ptr2.data \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:\\*ptr1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(alloc:ptr1 \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:array \\\[len: ..\\\]\\\[implicit\\\]\\) map\\(tofrom:.*alloc2.data \\\[len: .*\\\]\\\[implicit\\\]\\) map\\(to:alloc2 \\\[pointer set, len: ..\\\]\\) map\\(alloc:.*alloc2.data \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:\\*alloc1 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(alloc:alloc1 \\\[pointer assign, bias: 0\\\]\\) map\\(tofrom:agg2 \\\[len: .\\\]\\\[implicit\\\]\\) map\\(tofrom:agg1 \\\[len: .\\\]\\\[implicit\\\]\\)" 1 "gimple" } }
index 668808a29d079aa0cc40e1ea50f15f3ae513b5a2..91551fde9002c04c487f743e841109c85c7d4b5a 100644 (file)
@@ -558,6 +558,7 @@ enum omp_clause_default_kind {
 
 enum omp_clause_defaultmap_kind {
   OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED,
+  OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL,
   OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR,
   OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE,
   OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE,
index 579037b32c2f381a409c8338b63298a3fa982c80..e6fbf94793f8c1c47e1eab1c9fd5b4b98922bf4b 100644 (file)
@@ -1248,6 +1248,9 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
        {
        case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
          break;
+       case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
+         pp_string (pp, ":all");
+         break;
        case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
          pp_string (pp, ":scalar");
          break;
index 073c181f62737ce03b13e115d69f800e1c9fc3fe..5c91163893f2ca725649b9844c462a460f107268 100644 (file)
@@ -378,6 +378,8 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
       sentinel is warned for with with @code{-Wsurprising} (enabled by
       @code{-Wall}).  Unknown clauses are always rejected with an error.}
 @item Clauses on @code{end} directive can be on directive @tab Y @tab
+@item @code{destroy} clause with destroy-var argument on @code{depobj}
+      @tab N @tab
 @item Deprecation of no-argument @code{destroy} clause on @code{depobj}
       @tab N @tab
 @item @code{linear} clause syntax changes and @code{step} modifier @tab Y @tab
@@ -426,7 +428,7 @@ to address of matching mapped list item per 5.1, Sect. 2.21.7.2 @tab N @tab
       @code{omp_invalid_device} enum/PARAMETER @tab Y @tab
 @item Initial value of @var{default-device-var} ICV with
       @code{OMP_TARGET_OFFLOAD=mandatory} @tab Y @tab
-@item @code{all} as @emph{implicit-behavior} for @code{defaultmap} @tab N @tab
+@item @code{all} as @emph{implicit-behavior} for @code{defaultmap} @tab Y @tab
 @item @emph{interop_types} in any position of the modifier list for the @code{init} clause
       of the @code{interop} construct @tab N @tab
 @end multitable