public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gomp4] Prohibit C++ reference types in OpenACC regions
       [not found] <55410685.3020603@mentor.com>
@ 2015-05-13 21:01 ` Thomas Schwinge
  2015-11-12 14:03   ` [gomp4] remove c++ reference restriction Nathan Sidwell
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Schwinge @ 2015-05-13 21:01 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches; +Cc: Cesar Philippidis

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

Hi!

On Wed, 29 Apr 2015 09:27:49 -0700, Cesar Philippidis <cesar_philippidis@mentor.com> wrote:
> This patch teaches the c++ front end to error when reference typed
> variables are used in openacc parallel and kernels regions. The c++
> front end changes are pretty straightforward. I did, however, have to
> make omp_mappable_type langhook aware of openacc. That's because openmp
> apparently supports reference types, whereas openacc does not. I guess
> aliased mapping isn't a problem for non-openmp target regions.

Committed to gomp-4_0-branch in r223179:

commit ee20456534e0fd80333e50bab0821a0e20f065e5
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed May 13 20:56:31 2015 +0000

    Prohibit C++ reference types in OpenACC regions
    
    	gcc/
    	* langhooks-def.h (lhd_omp_mappable_type): Add bool argument.
    	* langhooks.c (lhd_omp_mappable_type): Likewise, for the
    	parameter.
    	* langhooks.h (struct lang_hooks_for_types): Add bool oacc
    	argument.
    	* gimplify.c (omp_notice_variable): Use it when calling the
    	omp_mappable_type langhook.
    	gcc/c/
    	* c-decl.c (c_decl_attributes): Update call to omp_mappable_type.
    	* c-typeck.c (c_finish_omp_clauses): Likewise.
    	gcc/cp/
    	* cp-tree.h (cp_omp_mappable_type): Add bool parameter.
    	* decl2.c (cp_check_const_attributes): Likewise. Use it.
    	(cp_omp_mappable_type): Update call to cp_omp_mappable_type.
    	(cplus_decl_attributes): Likewise.
    	* semantics.c (finish_omp_clauses): Likewise.
    	gcc/testsuite/
    	* g++.dg/goacc/reference.C: New test.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@223179 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.gomp                     | 10 ++++++++
 gcc/c/ChangeLog.gomp                   |  5 ++++
 gcc/c/c-decl.c                         |  3 ++-
 gcc/c/c-typeck.c                       |  6 +++--
 gcc/cp/ChangeLog.gomp                  |  8 +++++++
 gcc/cp/cp-tree.h                       |  2 +-
 gcc/cp/decl2.c                         |  8 ++++---
 gcc/cp/semantics.c                     | 11 ++++++---
 gcc/gimplify.c                         |  4 +++-
 gcc/langhooks-def.h                    |  2 +-
 gcc/langhooks.c                        |  2 +-
 gcc/langhooks.h                        |  2 +-
 gcc/testsuite/ChangeLog.gomp           |  4 ++++
 gcc/testsuite/g++.dg/goacc/reference.C | 42 ++++++++++++++++++++++++++++++++++
 14 files changed, 95 insertions(+), 14 deletions(-)

diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index 4901bf9..9e72962 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,3 +1,13 @@
+2015-05-13  Cesar Philippidis  <cesar@codesourcery.com>
+
+	* langhooks-def.h (lhd_omp_mappable_type): Add bool argument.
+	* langhooks.c (lhd_omp_mappable_type): Likewise, for the
+	parameter.
+	* langhooks.h (struct lang_hooks_for_types): Add bool oacc
+	argument.
+	* gimplify.c (omp_notice_variable): Use it when calling the
+	omp_mappable_type langhook.
+
 2015-05-13  Thomas Schwinge  <thomas@codesourcery.com>
 	    Bernd Schmidt  <bernds@codesourcery.com>
 	    Cesar Philippidis  <cesar@codesourcery.com>
diff --git gcc/c/ChangeLog.gomp gcc/c/ChangeLog.gomp
index 2e3cd13..08c8ed0 100644
--- gcc/c/ChangeLog.gomp
+++ gcc/c/ChangeLog.gomp
@@ -1,3 +1,8 @@
+2015-05-13  Cesar Philippidis  <cesar@codesourcery.com>
+
+	* c-decl.c (c_decl_attributes): Update call to omp_mappable_type.
+	* c-typeck.c (c_finish_omp_clauses): Likewise.
+
 2015-05-13  Thomas Schwinge  <thomas@codesourcery.com>
 	    Bernd Schmidt  <bernds@codesourcery.com>
 	    Cesar Philippidis  <cesar@codesourcery.com>
diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index 4f6761d..bf99a45 100644
--- gcc/c/c-decl.c
+++ gcc/c/c-decl.c
@@ -4414,7 +4414,8 @@ c_decl_attributes (tree *node, tree attributes, int flags)
 	error ("%q+D in block scope inside of declare target directive",
 	       *node);
       else if (TREE_CODE (*node) == VAR_DECL
-	       && !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node)))
+	       && !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node),
+						       false))
 	error ("%q+D in declare target directive does not have mappable type",
 	       *node);
       else
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 5ec04cc..974a3fc 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -12445,7 +12445,8 @@ c_finish_omp_clauses (tree clauses, bool oacc)
 	      else
 		{
 		  t = OMP_CLAUSE_DECL (c);
-		  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t)))
+		  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t),
+							   oacc))
 		    {
 		      error_at (OMP_CLAUSE_LOCATION (c),
 				"array section does not have mappable type "
@@ -12478,7 +12479,8 @@ c_finish_omp_clauses (tree clauses, bool oacc)
 		     && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER
 			 || (OMP_CLAUSE_MAP_KIND (c)
 			     == GOMP_MAP_FORCE_DEVICEPTR)))
-		   && !lang_hooks.types.omp_mappable_type (TREE_TYPE (t)))
+		   && !lang_hooks.types.omp_mappable_type (TREE_TYPE (t),
+							   oacc))
 	    {
 	      error_at (OMP_CLAUSE_LOCATION (c),
 			"%qD does not have a mappable type in %qs clause", t,
diff --git gcc/cp/ChangeLog.gomp gcc/cp/ChangeLog.gomp
index 33bd97c..529206a 100644
--- gcc/cp/ChangeLog.gomp
+++ gcc/cp/ChangeLog.gomp
@@ -1,3 +1,11 @@
+2015-05-13  Cesar Philippidis  <cesar@codesourcery.com>
+
+	* cp-tree.h (cp_omp_mappable_type): Add bool parameter.
+	* decl2.c (cp_check_const_attributes): Likewise. Use it.
+	(cp_omp_mappable_type): Update call to cp_omp_mappable_type.
+	(cplus_decl_attributes): Likewise.
+	* semantics.c (finish_omp_clauses): Likewise.
+
 2015-05-13  Thomas Schwinge  <thomas@codesourcery.com>
 	    Bernd Schmidt  <bernds@codesourcery.com>
 	    Cesar Philippidis  <cesar@codesourcery.com>
diff --git gcc/cp/cp-tree.h gcc/cp/cp-tree.h
index 302dfe2..0b52e8f 100644
--- gcc/cp/cp-tree.h
+++ gcc/cp/cp-tree.h
@@ -5501,7 +5501,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);
+extern bool cp_omp_mappable_type		(tree, bool);
 
 /* in error.c */
 extern void init_error				(void);
diff --git gcc/cp/decl2.c gcc/cp/decl2.c
index 0d47847..ff9d409 100644
--- gcc/cp/decl2.c
+++ gcc/cp/decl2.c
@@ -1403,7 +1403,7 @@ cp_check_const_attributes (tree attributes)
 
 /* Return true if TYPE is an OpenMP mappable type.  */
 bool
-cp_omp_mappable_type (tree type)
+cp_omp_mappable_type (tree type, bool oacc)
 {
   /* Mappable type has to be complete.  */
   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
@@ -1423,9 +1423,11 @@ cp_omp_mappable_type (tree type)
 	  return false;
 	/* All fields must have mappable types.  */
 	else if (TREE_CODE (field) == FIELD_DECL
-		 && !cp_omp_mappable_type (TREE_TYPE (field)))
+		 && !cp_omp_mappable_type (TREE_TYPE (field), oacc))
 	  return false;
     }
+  if (oacc && TREE_CODE (type) == REFERENCE_TYPE)
+    return false;
   return true;
 }
 
@@ -1455,7 +1457,7 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags)
 	       *decl);
       else if (!processing_template_decl
 	       && TREE_CODE (*decl) == VAR_DECL
-	       && !cp_omp_mappable_type (TREE_TYPE (*decl)))
+	       && !cp_omp_mappable_type (TREE_TYPE (*decl), false))
 	error ("%q+D in declare target directive does not have mappable type",
 	       *decl);
       else
diff --git gcc/cp/semantics.c gcc/cp/semantics.c
index 896bae5..19b8d0b 100644
--- gcc/cp/semantics.c
+++ gcc/cp/semantics.c
@@ -5866,7 +5866,7 @@ finish_omp_clauses (tree clauses, bool oacc)
 		  t = OMP_CLAUSE_DECL (c);
 		  if (TREE_CODE (t) != TREE_LIST
 		      && !type_dependent_expression_p (t)
-		      && !cp_omp_mappable_type (TREE_TYPE (t)))
+		      && !cp_omp_mappable_type (TREE_TYPE (t), oacc))
 		    {
 		      error_at (OMP_CLAUSE_LOCATION (c),
 				"array section does not have mappable type "
@@ -5877,6 +5877,11 @@ finish_omp_clauses (tree clauses, bool oacc)
 		}
 	      break;
 	    }
+	  if (oacc && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
+	    {
+	      error_at (OMP_CLAUSE_LOCATION (c),
+			"reference types are not supported in OpenACC");
+	    }
 	  if (t == error_mark_node)
 	    remove = true;
 	  else if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
@@ -5907,10 +5912,10 @@ finish_omp_clauses (tree clauses, bool oacc)
 	  else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
 		     && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER)
 		   && !type_dependent_expression_p (t)
-		   && !cp_omp_mappable_type ((TREE_CODE (TREE_TYPE (t))
+		   && !cp_omp_mappable_type (((TREE_CODE (TREE_TYPE (t))
 					      == REFERENCE_TYPE)
 					     ? TREE_TYPE (TREE_TYPE (t))
-					     : TREE_TYPE (t)))
+					     : TREE_TYPE (t)), oacc))
 	    {
 	      error_at (OMP_CLAUSE_LOCATION (c),
 			"%qD does not have a mappable type in %qs clause", t,
diff --git gcc/gimplify.c gcc/gimplify.c
index b7bc0c4..912b60f 100644
--- gcc/gimplify.c
+++ gcc/gimplify.c
@@ -5910,7 +5910,9 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 		}
 	    }
 
-	  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (decl)))
+	  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (decl),
+						   ctx->region_kind
+						   == ORK_OACC))
 	    {
 	      error ("%qD referenced in target region does not have "
 		     "a mappable type", decl);
diff --git gcc/langhooks-def.h gcc/langhooks-def.h
index 303b4b6..15b9896 100644
--- gcc/langhooks-def.h
+++ gcc/langhooks-def.h
@@ -79,7 +79,7 @@ extern void lhd_omp_finish_clause (tree, gimple_seq *);
 struct gimplify_omp_ctx;
 extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
 					       tree);
-extern bool lhd_omp_mappable_type (tree);
+extern bool lhd_omp_mappable_type (tree, bool);
 
 #define LANG_HOOKS_NAME			"GNU unknown"
 #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct lang_identifier)
diff --git gcc/langhooks.c gcc/langhooks.c
index 74f8351..031f158 100644
--- gcc/langhooks.c
+++ gcc/langhooks.c
@@ -555,7 +555,7 @@ lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED,
 /* Return true if TYPE is an OpenMP mappable type.  */
 
 bool
-lhd_omp_mappable_type (tree type)
+lhd_omp_mappable_type (tree type, bool oacc ATTRIBUTE_UNUSED)
 {
   /* Mappable type has to be complete.  */
   if (type == error_mark_node || !COMPLETE_TYPE_P (type))
diff --git gcc/langhooks.h gcc/langhooks.h
index 4039e8f..af02f27 100644
--- gcc/langhooks.h
+++ gcc/langhooks.h
@@ -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 (*omp_mappable_type) (tree type, bool oacc);
 
   /* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes.
      Called only after doing all language independent checks.
diff --git gcc/testsuite/ChangeLog.gomp gcc/testsuite/ChangeLog.gomp
index 9e5f114..e987031 100644
--- gcc/testsuite/ChangeLog.gomp
+++ gcc/testsuite/ChangeLog.gomp
@@ -1,3 +1,7 @@
+2015-05-13  Cesar Philippidis  <cesar@codesourcery.com>
+
+	* g++.dg/goacc/reference.C: New test.
+
 2015-05-13  Thomas Schwinge  <thomas@codesourcery.com>
 	    Bernd Schmidt  <bernds@codesourcery.com>
 	    Cesar Philippidis  <cesar@codesourcery.com>
diff --git gcc/testsuite/g++.dg/goacc/reference.C gcc/testsuite/g++.dg/goacc/reference.C
new file mode 100644
index 0000000..4a8d74a
--- /dev/null
+++ gcc/testsuite/g++.dg/goacc/reference.C
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// { dg-options "-fopenacc" }
+
+int
+test1 (int &ref)
+{
+#pragma acc kernels copy (ref) // { dg-error "reference types are not supported in OpenACC" }
+  {
+    ref = 10;
+  }
+}
+
+int
+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" }
+  }
+
+#pragma acc parallel copyout (b)
+  {
+    b = ref + 10; // { dg-error "referenced in target region does not have a mappable type" }
+  }
+
+  ref = b;
+}
+
+int
+main()
+{
+  int a = 0;
+  int &ref_a = a;
+
+  #pragma acc parallel copy (a, ref_a) // { dg-error "reference types are not supported in OpenACC" }
+  {
+    ref_a = 5;
+  }
+
+  return a;
+}


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gomp4] remove c++ reference restriction
@ 2015-11-12 14:03   ` Nathan Sidwell
  2015-11-12 16:12     ` Thomas Schwinge
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Sidwell @ 2015-11-12 14:03 UTC (permalink / raw)
  To: GCC Patches; +Cc: Thomas Schwinge, Cesar Philippidis

[-- 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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gomp4] remove c++ reference restriction
  2015-11-12 14:03   ` [gomp4] remove c++ reference restriction Nathan Sidwell
@ 2015-11-12 16:12     ` Thomas Schwinge
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Schwinge @ 2015-11-12 16:12 UTC (permalink / raw)
  To: Nathan Sidwell, GCC Patches; +Cc: Cesar Philippidis

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

Hi Nathan!

On Thu, 12 Nov 2015 09:03:42 -0500, Nathan Sidwell <nathan@acm.org> wrote:
> 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.

ACK.  "For reference", your and Cesar's original reasoning had been that
the OpenACC 2.0a specification doesn't talk about reference types
specifically, and they're non-POD, so not supported, which lead to
Cesar's patch that I applied to gomp-4_0-branch in r223179,
<http://news.gmane.org/find-root.php?message_id=%3C87sib0jivr.fsf%40schwinge.name%3E>.
Now, if they "just work", that's even better of course.

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

That was incomplete however, so we got a testsuite regression because of:

    [...]/gcc/testsuite/g++.dg/goacc/reference.C: In function 'int test1(int&)':
    [...]/gcc/testsuite/g++.dg/goacc/reference.C:7:27: error: reference types are not supported in OpenACC
    [...]/gcc/testsuite/g++.dg/goacc/reference.C: In function 'int main()':
    [...]/gcc/testsuite/g++.dg/goacc/reference.C:36:33: error: reference types are not supported in OpenACC

Fixed on gomp-4_0-branch in r230265:

commit 6ec26341420b3ced11af5adbe4643ff6cfaf99eb
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Nov 12 16:09:47 2015 +0000

    Complete reversion of "Prohibit C++ reference types in OpenACC regions"
    
    	gcc/cp/
    	* semantics.c (finish_omp_clauses): Remove "reference types are
    	not supported in OpenACC" diagnostic.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@230265 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/cp/ChangeLog.gomp | 5 +++++
 gcc/cp/semantics.c    | 9 ++-------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git gcc/cp/ChangeLog.gomp gcc/cp/ChangeLog.gomp
index 1f19b39..e4d000d 100644
--- gcc/cp/ChangeLog.gomp
+++ gcc/cp/ChangeLog.gomp
@@ -1,3 +1,8 @@
+2015-11-12  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* semantics.c (finish_omp_clauses): Remove "reference types are
+	not supported in OpenACC" diagnostic.
+
 2015-11-12  Nathan Sidwell  <nathan@codesourcery.com>
 
 	* semantics.c (finish_ommp_clauses): Adjust omp_mappable_type calls.
diff --git gcc/cp/semantics.c gcc/cp/semantics.c
index 34ccec6..ac3cb66 100644
--- gcc/cp/semantics.c
+++ gcc/cp/semantics.c
@@ -6552,11 +6552,6 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields,
 		}
 	      break;
 	    }
-	  if (is_oacc && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
-	    {
-	      error_at (OMP_CLAUSE_LOCATION (c),
-			"reference types are not supported in OpenACC");
-	    }
 	  if (t == error_mark_node)
 	    {
 	      remove = true;
@@ -6648,10 +6643,10 @@ finish_omp_clauses (tree clauses, bool is_oacc, bool allow_fields,
 			     == GOMP_MAP_FIRSTPRIVATE_POINTER)))
 		   && t == OMP_CLAUSE_DECL (c)
 		   && !type_dependent_expression_p (t)
-		   && !cp_omp_mappable_type (((TREE_CODE (TREE_TYPE (t))
+		   && !cp_omp_mappable_type ((TREE_CODE (TREE_TYPE (t))
 					      == REFERENCE_TYPE)
 					     ? TREE_TYPE (TREE_TYPE (t))
-					     : TREE_TYPE (t))))
+					     : TREE_TYPE (t)))
 	    {
 	      error_at (OMP_CLAUSE_LOCATION (c),
 			"%qD does not have a mappable type in %qs clause", t,


Grüße
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-12 16:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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   ` [gomp4] remove c++ reference restriction Nathan Sidwell
2015-11-12 16:12     ` Thomas Schwinge

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).