public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Thomas Schwinge <THOMAS_SCHWINGE@mentor.com>,
	Cesar Philippidis <cesar@codesourcery.com>
Subject: [gomp4] remove c++ reference restriction
Date: Thu, 12 Nov 2015 14:03:00 -0000	[thread overview]
Message-ID: <56449C3E.4040108@acm.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 398 bytes --]

I've applied this to gomp4 branch.  It removes the machinery concerning c++ 
references.  The openacc std makes no  mention of such a type, so originally we 
were not permitting the type. But,
(a) OpenMP supports them, which suggests openacc wishes to
(b) Fortran already has reference types that need supporting
(c) it's more work to not support them, by modifying the mappable_type hook.

nathan

[-- Attachment #2: gomp4-ref.patch --]
[-- Type: text/x-patch, Size: 9567 bytes --]

2015-11-12  Nathan Sidwell  <nathan@codesourcery.com>

	* langhooks-def.h (omp_mappable_type): Remove oacc arg.
	* langhooks.h (lhd_omp_mappable_type): Likewise.
	* langhooks.c (lhd_omp_mappable_type): Likswise.
	* gimplify.c (omp_notice_variable): Adjust omp_mappable_type call.

	c/
	* c-typeck.c (c_finish_omp_clauses): Adjust omp_mappable_type calls.
	* c-decl.c (c_decl_attributes): Likewise.

	testsuite/
	* g++.dg/goacc/reference.C: Adjust.

	cp/
	* semantics.c (finish_ommp_clauses): Adjust omp_mappable_type calls.
	* decl2.c (cp_omp_mappable_type): Remove oacc arg and processing.
	* cp-tree.h (cp_omp_mappable_type): Remove oacc arg.

oIndex: gimplify.c
===================================================================
--- gimplify.c	(revision 230177)
+++ gimplify.c	(working copy)
@@ -6106,9 +6106,7 @@ omp_notice_variable (struct gimplify_omp
 		&& lang_hooks.decls.omp_privatize_by_reference (decl))
 	      type = TREE_TYPE (type);
 	    if (nflags == flags
-		&& !lang_hooks.types.omp_mappable_type (type,
-							(ctx->region_type
-							 & ORT_ACC) != 0))
+		&& !lang_hooks.types.omp_mappable_type (type))
 	      {
 		error ("%qD referenced in target region does not have "
 		       "a mappable type", decl);
Index: langhooks.c
===================================================================
--- langhooks.c	(revision 230177)
+++ langhooks.c	(working copy)
@@ -525,7 +525,7 @@ lhd_omp_firstprivatize_type_sizes (struc
 /* Return true if TYPE is an OpenMP mappable type.  */
 
 bool
-lhd_omp_mappable_type (tree type, bool oacc ATTRIBUTE_UNUSED)
+lhd_omp_mappable_type (tree type)
 {
   /* Mappable type has to be complete.  */
   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
Index: langhooks.h
===================================================================
--- langhooks.h	(revision 230177)
+++ langhooks.h	(working copy)
@@ -112,7 +112,7 @@ struct lang_hooks_for_types
   void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree);
 
   /* Return true if TYPE is a mappable type.  */
-  bool (*omp_mappable_type) (tree type, bool oacc);
+  bool (*omp_mappable_type) (tree type);
 
   /* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes.
      Called only after doing all language independent checks.
Index: testsuite/g++.dg/goacc/reference.C
===================================================================
--- testsuite/g++.dg/goacc/reference.C	(revision 230177)
+++ testsuite/g++.dg/goacc/reference.C	(working copy)
@@ -4,7 +4,7 @@
 int
 test1 (int &ref)
 {
-#pragma acc kernels copy (ref) // { dg-error "reference types are not supported in OpenACC" }
+#pragma acc kernels copy (ref)
   {
     ref = 10;
   }
@@ -16,12 +16,12 @@ test2 (int &ref)
   int b;
 #pragma acc kernels copyout (b)
   {
-    b = ref + 10; // { dg-error "referenced in target region does not have a mappable type" }
+    b = ref + 10;
   }
 
 #pragma acc parallel copyout (b)
   {
-    b = ref + 10; // { dg-error "referenced in target region does not have a mappable type" }
+    b = ref + 10;
   }
 
   ref = b;
@@ -33,7 +33,7 @@ main()
   int a = 0;
   int &ref_a = a;
 
-  #pragma acc parallel copy (a, ref_a) // { dg-error "reference types are not supported in OpenACC" }
+  #pragma acc parallel copy (a, ref_a)
   {
     ref_a = 5;
   }
Index: c/c-typeck.c
===================================================================
--- c/c-typeck.c	(revision 230177)
+++ c/c-typeck.c	(working copy)
@@ -12863,8 +12863,7 @@ c_finish_omp_clauses (tree clauses, bool
 	      else
 		{
 		  t = OMP_CLAUSE_DECL (c);
-		  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t),
-							   is_oacc))
+		  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t)))
 		    {
 		      error_at (OMP_CLAUSE_LOCATION (c),
 				"array section does not have mappable type "
@@ -12916,8 +12915,7 @@ c_finish_omp_clauses (tree clauses, bool
 			    t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
 		  remove = true;
 		}
-	      else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t),
-							    is_oacc))
+	      else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t)))
 		{
 		  error_at (OMP_CLAUSE_LOCATION (c),
 			    "%qE does not have a mappable type in %qs clause",
@@ -12967,8 +12965,7 @@ c_finish_omp_clauses (tree clauses, bool
 			 || (OMP_CLAUSE_MAP_KIND (c)
 			     == GOMP_MAP_FORCE_DEVICEPTR)))
 		   && t == OMP_CLAUSE_DECL (c)
-		   && !lang_hooks.types.omp_mappable_type (TREE_TYPE (t),
-							   is_oacc))
+		   && !lang_hooks.types.omp_mappable_type (TREE_TYPE (t)))
 	    {
 	      error_at (OMP_CLAUSE_LOCATION (c),
 			"%qD does not have a mappable type in %qs clause", t,
@@ -13044,7 +13041,7 @@ c_finish_omp_clauses (tree clauses, bool
 			omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
 	      remove = true;
 	    }
-	  else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t), is_oacc))
+	  else if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t)))
 	    {
 	      error_at (OMP_CLAUSE_LOCATION (c),
 			"%qD does not have a mappable type in %qs clause", t,
Index: c/c-decl.c
===================================================================
--- c/c-decl.c	(revision 230177)
+++ c/c-decl.c	(working copy)
@@ -4411,7 +4411,7 @@ c_decl_attributes (tree *node, tree attr
 	  || TREE_CODE (*node) == FUNCTION_DECL))
     {
       if (VAR_P (*node)
-	  && !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node), false))
+	  && !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node)))
 	error ("%q+D in declare target directive does not have mappable type",
 	       *node);
       else
Index: langhooks-def.h
===================================================================
--- langhooks-def.h	(revision 230177)
+++ langhooks-def.h	(working copy)
@@ -79,7 +79,7 @@ extern void lhd_omp_finish_clause (tree,
 struct gimplify_omp_ctx;
 extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
 					       tree);
-extern bool lhd_omp_mappable_type (tree, bool);
+extern bool lhd_omp_mappable_type (tree);
 
 #define LANG_HOOKS_NAME			"GNU unknown"
 #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct lang_identifier)
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 230177)
+++ cp/semantics.c	(working copy)
@@ -6523,7 +6523,7 @@ finish_omp_clauses (tree clauses, bool i
 		  t = OMP_CLAUSE_DECL (c);
 		  if (TREE_CODE (t) != TREE_LIST
 		      && !type_dependent_expression_p (t)
-		      && !cp_omp_mappable_type (TREE_TYPE (t), is_oacc))
+		      && !cp_omp_mappable_type (TREE_TYPE (t)))
 		    {
 		      error_at (OMP_CLAUSE_LOCATION (c),
 				"array section does not have mappable type "
@@ -6588,7 +6588,7 @@ finish_omp_clauses (tree clauses, bool i
 			    t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
 		  remove = true;
 		}
-	      else if (!cp_omp_mappable_type (TREE_TYPE (t), is_oacc))
+	      else if (!cp_omp_mappable_type (TREE_TYPE (t)))
 		{
 		  error_at (OMP_CLAUSE_LOCATION (c),
 			    "%qE does not have a mappable type in %qs clause",
@@ -6658,7 +6658,7 @@ finish_omp_clauses (tree clauses, bool i
 		   && !cp_omp_mappable_type (((TREE_CODE (TREE_TYPE (t))
 					      == REFERENCE_TYPE)
 					     ? TREE_TYPE (TREE_TYPE (t))
-					     : TREE_TYPE (t)), is_oacc))
+					     : TREE_TYPE (t))))
 	    {
 	      error_at (OMP_CLAUSE_LOCATION (c),
 			"%qD does not have a mappable type in %qs clause", t,
@@ -6781,7 +6781,7 @@ finish_omp_clauses (tree clauses, bool i
 			omp_clause_code_name[OMP_CLAUSE_CODE (c)]);
 	      remove = true;
 	    }
-	  else if (!cp_omp_mappable_type (TREE_TYPE (t), is_oacc))
+	  else if (!cp_omp_mappable_type (TREE_TYPE (t)))
 	    {
 	      error_at (OMP_CLAUSE_LOCATION (c),
 			"%qD does not have a mappable type in %qs clause", t,
Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 230177)
+++ cp/decl2.c	(working copy)
@@ -1403,7 +1403,7 @@ cp_check_const_attributes (tree attribut
 
 /* Return true if TYPE is an OpenMP mappable type.  */
 bool
-cp_omp_mappable_type (tree type, bool oacc)
+cp_omp_mappable_type (tree type)
 {
   /* Mappable type has to be complete.  */
   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
@@ -1423,11 +1423,9 @@ cp_omp_mappable_type (tree type, bool oa
 	  return false;
 	/* All fields must have mappable types.  */
 	else if (TREE_CODE (field) == FIELD_DECL
-		 && !cp_omp_mappable_type (TREE_TYPE (field), oacc))
+		 && !cp_omp_mappable_type (TREE_TYPE (field)))
 	  return false;
     }
-  if (oacc && TREE_CODE (type) == REFERENCE_TYPE)
-    return false;
   return true;
 }
 
@@ -1452,7 +1450,7 @@ cplus_decl_attributes (tree *decl, tree
 	       *decl);
       else if (!processing_template_decl
 	       && VAR_P (*decl)
-	       && !cp_omp_mappable_type (TREE_TYPE (*decl), false))
+	       && !cp_omp_mappable_type (TREE_TYPE (*decl)))
 	error ("%q+D in declare target directive does not have mappable type",
 	       *decl);
       else
Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 230177)
+++ cp/cp-tree.h	(working copy)
@@ -5790,7 +5790,7 @@ extern bool possibly_inlined_p			(tree);
 extern int parm_index                           (tree);
 extern tree vtv_start_verification_constructor_init_function (void);
 extern tree vtv_finish_verification_constructor_init_function (tree);
-extern bool cp_omp_mappable_type		(tree, bool);
+extern bool cp_omp_mappable_type		(tree);
 
 /* in error.c */
 extern const char *type_as_string		(tree, int);

         reply	other threads:[~2015-11-12 14:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <55410685.3020603@mentor.com>
2015-05-13 21:01 ` [gomp4] Prohibit C++ reference types in OpenACC regions Thomas Schwinge
2015-11-12 14:03   ` Nathan Sidwell [this message]
2015-11-12 16:12     ` [gomp4] remove c++ reference restriction Thomas Schwinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56449C3E.4040108@acm.org \
    --to=nathan@acm.org \
    --cc=THOMAS_SCHWINGE@mentor.com \
    --cc=cesar@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).