]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR89433] Refer to OpenACC 'routine' clauses from "omp declare target" attribute
authorThomas Schwinge <thomas@codesourcery.com>
Fri, 17 May 2019 19:13:04 +0000 (21:13 +0200)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Fri, 17 May 2019 19:13:04 +0000 (21:13 +0200)
gcc/c-family/
PR c/89433
* c-attribs.c (c_common_attribute_table): Set min_len to -1 for
"omp declare target".
gcc/c/
PR c/89433
* c-parser.c (c_finish_oacc_routine): Refer to OpenACC 'routine'
clauses from "omp declare target" attribute.
gcc/cp/
PR c++/89433
* parser.c (cp_finalize_oacc_routine): Refer to OpenACC 'routine'
clauses from "omp declare target" attribute.
gcc/fortran/
PR fortran/89433
* f95-lang.c (gfc_attribute_table): Set min_len to -1 for "omp
declare target".
* trans-decl.c (add_attributes_to_decl): Refer to OpenACC
'routine' clauses from "omp declare target" attribute.
gcc/testsuite/
PR testsuite/89433
* c-c++-common/goacc/classify-routine.c: Update.
* gfortran.dg/goacc/classify-routine.f95: Likewise.

From-SVN: r271343

12 files changed:
gcc/c-family/ChangeLog
gcc/c-family/c-attribs.c
gcc/c/ChangeLog
gcc/c/c-parser.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/goacc/classify-routine.c
gcc/testsuite/gfortran.dg/goacc/classify-routine.f95

index 47c1d3d51f50e7889bda3e2924f52fcb6e3c7ab5..50687764221bd442a1a762a1ed2bf76542a84154 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-17  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR c/89433
+       * c-attribs.c (c_common_attribute_table): Set min_len to -1 for
+       "omp declare target".
+
 2019-05-16  Martin Sebor  <msebor@redhat.com>
 
         * c-attribs.c (handle_no_sanitize_attribute): Quote identifiers,
index 12c0b9bfb54363398f1ecab84b22384583c53582..03203470955abccc1846485845a21fb9b0cda548 100644 (file)
@@ -437,7 +437,7 @@ const struct attribute_spec c_common_attribute_table[] =
                              handle_omp_declare_simd_attribute, NULL },
   { "simd",                  0, 1, true,  false, false, false,
                              handle_simd_attribute, NULL },
-  { "omp declare target",     0, 0, true, false, false, false,
+  { "omp declare target",     0, -1, true, false, false, false,
                              handle_omp_declare_target_attribute, NULL },
   { "omp declare target link", 0, 0, true, false, false, false,
                              handle_omp_declare_target_attribute, NULL },
index f558d28dc25911f03e568ef9a6b84529b80b7b79..f0cab2e65929fe8254b3f74a610158c43cc35cc3 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-17  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR c/89433
+       * c-parser.c (c_finish_oacc_routine): Refer to OpenACC 'routine'
+       clauses from "omp declare target" attribute.
+
 2019-05-16  Martin Sebor  <msebor@redhat.com>
 
         * c-decl.c (start_decl): Quote keywords, operators, and
index 993cfe05ecb0c9b7a87b2ff6bf05bace5790a10f..3cbbb199bddabcd5a589f42c596dfd2eeeadcf1a 100644 (file)
@@ -15904,7 +15904,7 @@ c_finish_oacc_routine (struct oacc_routine_data *data, tree fndecl,
   /* Add an "omp declare target" attribute.  */
   DECL_ATTRIBUTES (fndecl)
     = tree_cons (get_identifier ("omp declare target"),
-                NULL_TREE, DECL_ATTRIBUTES (fndecl));
+                data->clauses, DECL_ATTRIBUTES (fndecl));
 
   /* Remember that we've used this "#pragma acc routine".  */
   data->fndecl_seen = true;
index 08b7d5337071139a4f6df3da7d66fd4f5f9489b7..40622acc0ff224df32fdd0017f22f6de3d52beb6 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-17  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR c++/89433
+       * parser.c (cp_finalize_oacc_routine): Refer to OpenACC 'routine'
+       clauses from "omp declare target" attribute.
+
 2019-05-16  Martin Sebor  <msebor@redhat.com>
 
         * call.c (print_z_candidate): Wrap diagnostic text in a gettext
index e6ef5a9bc008e9084242ba98a6bdd083a9ccfd3f..15424b6b63372f85ddf8184aa54250d92215dc14 100644 (file)
@@ -40292,7 +40292,7 @@ cp_finalize_oacc_routine (cp_parser *parser, tree fndecl, bool is_defn)
       /* Add an "omp declare target" attribute.  */
       DECL_ATTRIBUTES (fndecl)
        = tree_cons (get_identifier ("omp declare target"),
-                    NULL_TREE, DECL_ATTRIBUTES (fndecl));
+                    parser->oacc_routine->clauses, DECL_ATTRIBUTES (fndecl));
 
       /* Don't unset parser->oacc_routine here: we may still need it to
         diagnose wrong usage.  But, remember that we've used this "#pragma acc
index b8851067cf3ee4e9d008fbabd25bcdccc6ee2c29..f09e715353bd935fcbe2fb064c1ebdb50a389b36 100644 (file)
@@ -1,3 +1,11 @@
+2019-05-17  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR fortran/89433
+       * f95-lang.c (gfc_attribute_table): Set min_len to -1 for "omp
+       declare target".
+       * trans-decl.c (add_attributes_to_decl): Refer to OpenACC
+       'routine' clauses from "omp declare target" attribute.
+
 2019-05-16  Martin Sebor  <msebor@redhat.com>
 
        * gfortranspec.c (append_arg): Spell out the word "argument."
index 3e3d3046bdb5147fafb0d4e2b050cd11ded5608e..6b9f490d2bbc41df168a6897d3f7c75367663a15 100644 (file)
@@ -91,7 +91,7 @@ static const struct attribute_spec gfc_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
        affects_type_identity, handler, exclude } */
-  { "omp declare target", 0, 0, true,  false, false, false,
+  { "omp declare target", 0, -1, true,  false, false, false,
     gfc_handle_omp_declare_target_attribute, NULL },
   { "omp declare target link", 0, 0, true,  false, false, false,
     gfc_handle_omp_declare_target_attribute, NULL },
index 07d1c33af72c05d813b244389f1b510003302773..8420870a6b782c9702ef9e45291d4b2789c1558a 100644 (file)
@@ -1400,12 +1400,7 @@ add_attributes_to_decl (symbol_attribute sym_attr, tree list)
        list = chainon (list, attr);
       }
 
-  if (sym_attr.omp_declare_target_link)
-    list = tree_cons (get_identifier ("omp declare target link"),
-                     NULL_TREE, list);
-  else if (sym_attr.omp_declare_target)
-    list = tree_cons (get_identifier ("omp declare target"),
-                     NULL_TREE, list);
+  tree clauses = NULL_TREE;
 
   if (sym_attr.oacc_routine_lop != OACC_ROUTINE_LOP_NONE)
     {
@@ -1430,11 +1425,20 @@ add_attributes_to_decl (symbol_attribute sym_attr, tree list)
          gcc_unreachable ();
        }
       tree c = build_omp_clause (UNKNOWN_LOCATION, code);
+      OMP_CLAUSE_CHAIN (c) = clauses;
+      clauses = c;
 
-      tree dims = oacc_build_routine_dims (c);
+      tree dims = oacc_build_routine_dims (clauses);
       list = oacc_replace_fn_attrib_attr (list, dims);
     }
 
+  if (sym_attr.omp_declare_target_link)
+    list = tree_cons (get_identifier ("omp declare target link"),
+                     NULL_TREE, list);
+  else if (sym_attr.omp_declare_target)
+    list = tree_cons (get_identifier ("omp declare target"),
+                     clauses, list);
+
   return list;
 }
 
index e1aa25736efb400a9ff965f1ac6b9995faa9360d..0f44c6d4ab0e32ae29c579e14fa5245401a25e60 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-17  Thomas Schwinge  <thomas@codesourcery.com>
+
+       PR testsuite/89433
+       * c-c++-common/goacc/classify-routine.c: Update.
+       * gfortran.dg/goacc/classify-routine.f95: Likewise.
+
 2019-05-16  Martin Sebor  <msebor@redhat.com>
 
         * c-c++-common/Wbool-operation-1.c: Adjust text of expected diagnostics.
index a723d2cdf513b6a3c3e808cc7d1caf467ba1cd5b..0b9ba6ea69fc31f1313372bb9fd7118dc0b6920d 100644 (file)
@@ -22,10 +22,10 @@ void ROUTINE ()
 }
 
 /* Check the offloaded function's attributes.
-   { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp declare target, oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "ompexp" } } */
+   { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp declare target \\(worker\\), oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "ompexp" } } */
 
 /* Check the offloaded function's classification and compute dimensions (will
    always be 1 x 1 x 1 for non-offloading compilation).
    { dg-final { scan-tree-dump-times "(?n)Function is OpenACC routine level 1" 1 "oaccdevlow" } }
    { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } }
-   { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 1, 1 1\\), omp declare target, oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "oaccdevlow" } } */
+   { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 1, 1 1\\), omp declare target \\(worker\\), oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "oaccdevlow" } } */
index e435f5d7eaef155cea172710cb3181f2cfa4a4b3..401d5270391e213a320a8d7e5c136a2beed89ff1 100644 (file)
@@ -21,10 +21,10 @@ subroutine ROUTINE
 end subroutine ROUTINE
 
 ! Check the offloaded function's attributes.
-! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(omp declare target, oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "ompexp" } }
+! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 0, 1 0\\), omp declare target \\(worker\\)\\)\\)" 1 "ompexp" } }
 
 ! Check the offloaded function's classification and compute dimensions (will
 ! always be 1 x 1 x 1 for non-offloading compilation).
 ! { dg-final { scan-tree-dump-times "(?n)Function is OpenACC routine level 1" 1 "oaccdevlow" } }
 ! { dg-final { scan-tree-dump-times "(?n)Compute dimensions \\\[1, 1, 1\\\]" 1 "oaccdevlow" } }
-! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 1, 1 1\\), omp declare target, oacc function \\(0 1, 1 0, 1 0\\)\\)\\)" 1 "oaccdevlow" } }
+! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc function \\(0 1, 1 1, 1 1\\), omp declare target \\(worker\\)\\)\\)" 1 "oaccdevlow" } }