public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix use of declare'd vars by routine procedures.
@ 2016-01-17 23:01 James Norris
  2016-01-22 10:39 ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: James Norris @ 2016-01-17 23:01 UTC (permalink / raw)
  To: GCC Patches, Jakub Jelinek

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

Hi!

The attached patch addresses the failure of declare-4 in the libgomp testsuite.
The primary failure was the use a variable with a link clause for an OpenACC
routine function. The patch changes the test to use a create clause. The patch
also adds checking of those globals used within an OpenACC routine function.
Additional gcc testing is also included in the patch.

Regtested and bootstrapped on x86_64.

OK for trunk?

Thanks!

Jim

[-- Attachment #2: check.patch --]
[-- Type: text/x-patch, Size: 5063 bytes --]

Index: gcc/c/ChangeLog
===================================================================
--- gcc/c/ChangeLog	(revision 232340)
+++ gcc/c/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2016-01-XX  James Norris  <jnorris@codesourcery.com>
+
+	* c-parser.c (build_external_ref): Add usage check.
+
 2016-01-06  David Malcolm  <dmalcolm@redhat.com>
 
 	* c-parser.c (c_parser_unary_expression): For dereferences, build
Index: gcc/c/c-typeck.c
===================================================================
--- gcc/c/c-typeck.c	(revision 232340)
+++ gcc/c/c-typeck.c	(working copy)
@@ -2677,6 +2677,26 @@
   tree ref;
   tree decl = lookup_name (id);
 
+  if (decl
+      && decl != error_mark_node
+      && current_function_decl
+      && TREE_CODE (decl) == VAR_DECL
+      && is_global_var (decl)
+      && get_oacc_fn_attrib (current_function_decl))
+    {
+      /* Validate data type for use with routine directive.  */
+      if (lookup_attribute ("omp declare target link",
+			    DECL_ATTRIBUTES (decl))
+	  || ((!lookup_attribute ("omp declare target",
+				  DECL_ATTRIBUTES (decl))
+	       && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
+		   || (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))))
+	{
+	  error_at (loc, "invalid use in %<routine%> function");
+	  return error_mark_node;
+	}
+    }
+
   /* In Objective-C, an instance variable (ivar) may be preferred to
      whatever lookup_name() found.  */
   decl = objc_lookup_ivar (decl, id);
Index: gcc/cp/ChangeLog
===================================================================
--- gcc/cp/ChangeLog	(revision 232340)
+++ gcc/cp/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2016-01-XX  James Norris  <jnorris@codesourcery.com>
+
+	* semantics.c (finish_id_expression): Add usage check.
+
 2016-01-12  Marek Polacek  <polacek@redhat.com>
 
 	PR c++/68979
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c	(revision 232340)
+++ gcc/cp/semantics.c	(working copy)
@@ -3712,6 +3712,25 @@
 
 	  decl = convert_from_reference (decl);
 	}
+
+      if (decl != error_mark_node
+	  && current_function_decl
+	  && TREE_CODE (decl) == VAR_DECL
+	  && is_global_var (decl)
+	  && get_oacc_fn_attrib (current_function_decl))
+	{
+	  /* Validate data type for use with routine directive.  */
+	  if (lookup_attribute ("omp declare target link",
+				DECL_ATTRIBUTES (decl))
+	      || ((!lookup_attribute ("omp declare target",
+				  DECL_ATTRIBUTES (decl))
+		   && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
+			|| (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))))
+	    {
+	      *error_msg = "invalid use in %<routine%> function";
+	      return error_mark_node;
+	    }
+	}
     }
 
   return cp_expr (decl, location);
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(revision 232340)
+++ gcc/testsuite/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2016-01-XX  James Norris  <jnorris@codesourcery.com>
+
+	* c-c++-common/goacc/routine-5.c: Additional tests.
+
 2016-01-13  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* gcc.target/i386/pr69225-7.c: New test.
Index: gcc/testsuite/c-c++-common/goacc/routine-5.c
===================================================================
--- gcc/testsuite/c-c++-common/goacc/routine-5.c	(revision 232340)
+++ gcc/testsuite/c-c++-common/goacc/routine-5.c	(working copy)
@@ -45,3 +45,49 @@
 #pragma acc routine (a) /* { dg-error "does not refer to" } */
   
 #pragma acc routine (c) /* { dg-error "does not refer to" } */
+
+float vb1;
+
+#pragma acc routine
+int
+func1 (int a)
+{
+  vb1 = a + 1; /* { dg-error "invalid use in" } */
+
+  return vb1; /* { dg-error "invalid use in" } */
+}
+
+#pragma acc routine
+int
+func2 (int a)
+{
+  static int vb2;
+
+  vb2 = a + 1; /* { dg-error "invalid use in" } */
+
+  return vb2; /* { dg-error "invalid use in" } */
+}
+
+float vb3;
+#pragma acc declare link (vb3)
+
+#pragma acc routine
+int
+func3 (int a)
+{
+  vb3 = a + 1; /* { dg-error "invalid use in" } */
+
+  return vb3; /* { dg-error "invalid use in" } */
+}
+
+float vb4;
+#pragma acc declare create (vb4)
+
+#pragma acc routine
+int
+func4 (int a)
+{
+  vb4 = a + 1;
+
+  return vb4;
+}
Index: libgomp/ChangeLog
===================================================================
--- libgomp/ChangeLog	(revision 232341)
+++ libgomp/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2016-01-XX  James Norris  <jnorris@codesourcery.com>
+
+	* testsuite/libgomp.oacc-c-c++-common/declare-4.c: Fix test.
+
 2016-01-12  James Norris  <jnorris@codesourcery.com>
 
 	* libgomp.texi: Updates for OpenACC.
Index: libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c
===================================================================
--- libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c	(revision 232340)
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/declare-4.c	(working copy)
@@ -4,7 +4,7 @@
 #include <openacc.h>
 
 float b;
-#pragma acc declare link (b)
+#pragma acc declare create (b)
 
 #pragma acc routine
 int

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

* Re: [PATCH] Fix use of declare'd vars by routine procedures.
  2016-01-17 23:01 [PATCH] Fix use of declare'd vars by routine procedures James Norris
@ 2016-01-22 10:39 ` Jakub Jelinek
  2016-01-28 18:26   ` James Norris
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2016-01-22 10:39 UTC (permalink / raw)
  To: James Norris; +Cc: GCC Patches

On Sun, Jan 17, 2016 at 05:01:24PM -0600, James Norris wrote:
> The attached patch addresses the failure of declare-4 in the libgomp testsuite.
> The primary failure was the use a variable with a link clause for an OpenACC
> routine function. The patch changes the test to use a create clause. The patch
> also adds checking of those globals used within an OpenACC routine function.
> Additional gcc testing is also included in the patch.
> 
> Regtested and bootstrapped on x86_64.

The testcase change is obviously fine, please install it separately.

As for the extra error, I think it would be better to diagnose this during
gimplification, that way you do it for all FEs, plus you have the omp
context in there, etc.  The error wording is weird, the diagnostic
should make it clear use of what is invalid in what and why.

	Jakub

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

* Re: [PATCH] Fix use of declare'd vars by routine procedures.
  2016-01-22 10:39 ` Jakub Jelinek
@ 2016-01-28 18:26   ` James Norris
  2016-01-29  8:32     ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: James Norris @ 2016-01-28 18:26 UTC (permalink / raw)
  To: Jakub Jelinek, GCC Patches

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

Jakub,

On 01/22/2016 04:39 AM, Jakub Jelinek wrote:
>
> As for the extra error, I think it would be better to diagnose this during
> gimplification, that way you do it for all FEs, plus you have the omp
> context in there, etc.  The error wording is weird, the diagnostic
> should make it clear use of what is invalid in what and why.
>
> 	Jakub
>

I think the attached change is what you had in mind with
regard to doing the check at gimplification time.

OK?

Thanks for taking the time to review,
Jim


ChangeLog entries....

         gcc/
         * gimplify.c (gimplify_var_or_parm_decl): Add variable usage check.
         gcc/testsuite/
         * c-c++-common/goacc/routine-5.c: Add tests.


[-- Attachment #2: declare.patch --]
[-- Type: text/x-patch, Size: 3860 bytes --]

Index: gcc/ChangeLog
===================================================================
diff --git a/trunk/gcc/ChangeLog b/trunk/gcc/ChangeLog
--- a/trunk/gcc/ChangeLog	(revision 232802)
+++ b/trunk/gcc/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2016-01-XX  James Norris  <jnorris@codesourcery.com>
+
+	* gimplify.c (gimplify_var_or_parm_decl): Add usage check.
+
 2016-01-25  Jeff Law  <law@redhat.com>
 
 	PR tree-optimization/69196
Index: gcc/gimplify.c
===================================================================
diff --git a/trunk/gcc/gimplify.c b/trunk/gcc/gimplify.c
--- a/trunk/gcc/gimplify.c	(revision 232802)
+++ b/trunk/gcc/gimplify.c	(working copy)
@@ -1841,6 +1841,33 @@
       return GS_ERROR;
     }
 
+  /* Validate variable for use within routine function.  */
+  if (gimplify_omp_ctxp && gimplify_omp_ctxp->region_type == ORT_TARGET
+      && get_oacc_fn_attrib (current_function_decl)
+      && TREE_CODE (decl) == VAR_DECL
+      && is_global_var (decl)
+      && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
+	  || (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))
+    {
+      location_t loc = DECL_SOURCE_LOCATION (decl);
+
+      if (lookup_attribute ("omp declare target link", DECL_ATTRIBUTES (decl)))
+	{
+	  error_at (loc,
+		    "%qE with %<link%> clause used in %<routine%> function",
+		    DECL_NAME (decl));
+	  return GS_ERROR;
+	}
+      else if (!lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
+	{
+	  error_at (loc,
+		    "storage class of %qE cannot be ", DECL_NAME (decl));
+	  error_at (gimplify_omp_ctxp->location,
+		    "used in enclosing %<routine%> function");
+	  return GS_ERROR;
+	}
+    }
+
   /* When within an OMP context, notice uses of variables.  */
   if (gimplify_omp_ctxp && omp_notice_variable (gimplify_omp_ctxp, decl, true))
     return GS_ALL_DONE;
Index: gcc/testsuite/ChangeLog
===================================================================
diff --git a/trunk/gcc/testsuite/ChangeLog b/trunk/gcc/testsuite/ChangeLog
--- a/trunk/gcc/testsuite/ChangeLog	(revision 232802)
+++ b/trunk/gcc/testsuite/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2016-01-XX  James Norris  <jnorris@codesourcery.com>
+
+	* c-c++-common/goacc/routine-5.c: Add tests.
+
 2016-01-25  Jeff Law  <law@redhat.com>
 
 	PR tree-optimization/69196
Index: gcc/testsuite/c-c++-common/goacc/routine-5.c
===================================================================
diff --git a/trunk/gcc/testsuite/c-c++-common/goacc/routine-5.c b/trunk/gcc/testsuite/c-c++-common/goacc/routine-5.c
--- a/trunk/gcc/testsuite/c-c++-common/goacc/routine-5.c	(revision 232802)
+++ b/trunk/gcc/testsuite/c-c++-common/goacc/routine-5.c	(working copy)
@@ -45,3 +45,70 @@
 #pragma acc routine (a) /* { dg-error "does not refer to" } */
   
 #pragma acc routine (c) /* { dg-error "does not refer to" } */
+
+float vb1; /* { dg-error "storage class of" } */
+
+#pragma acc routine
+int
+func1 (int a)		/* { dg-error "used in enclosing" } */
+{
+  vb1 = a + 1;
+
+  return vb1;
+}
+
+#pragma acc routine
+int
+func2 (int a)		/* { dg-error "used in enclosing" } */
+{
+  static int vb2;	/* { dg-error "storage class of" } */
+
+  vb2 = a + 1;
+
+  return vb2;
+}
+
+float vb3;		/* { dg-error "'link' clause used" } */
+#pragma acc declare link (vb3)
+
+#pragma acc routine
+int
+func3 (int a)
+{
+  vb3 = a + 1;
+
+  return vb3;
+}
+
+float vb4;
+#pragma acc declare create (vb4)
+
+#pragma acc routine
+int
+func4 (int a)
+{
+  vb4 = a + 1;
+
+  return vb4;
+}
+
+extern float vb5;	/* { dg-error "storage class of" } */
+
+#pragma acc routine
+int
+func5 (int a)		/* { dg-error "used in enclosing" } */
+{
+  vb5 = a + 1;
+
+  return vb5;
+}
+
+#pragma acc routine
+int
+func6 (int a)		/* { dg-error "used in enclosing" } */
+{
+  extern float vb6;	/* { dg-error "storage class of" } */
+  vb6 = a + 1;
+
+  return vb6;
+}

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

* Re: [PATCH] Fix use of declare'd vars by routine procedures.
  2016-01-28 18:26   ` James Norris
@ 2016-01-29  8:32     ` Jakub Jelinek
  2016-02-01 16:00       ` James Norris
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2016-01-29  8:32 UTC (permalink / raw)
  To: James Norris; +Cc: GCC Patches

On Thu, Jan 28, 2016 at 12:26:38PM -0600, James Norris wrote:
> I think the attached change is what you had in mind with
> regard to doing the check at gimplification time.

Nope, this is still a wrong location for that.
If you look at the next line after the block you've added, you'll see
if (gimplify_omp_ctxp && omp_notice_variable (gimplify_omp_ctxp, decl, true))
And that function fairly early calls is_global_var (decl).  So you know
already gimplify_omp_ctxp && is_global_var (decl), just put the rest into
that block.
The TREE_CODE (decl) == VAR_DECL check is VAR_P (decl).
What do you want to achieve with

> +      && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))  
> +       || (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))

?  is_global_var already guarantees you that it is either TREE_STATIC
or DECL_EXTERNAL, why is that not good enough?

> diff --git a/trunk/gcc/gimplify.c b/trunk/gcc/gimplify.c
> --- a/trunk/gcc/gimplify.c	(revision 232802)
> +++ b/trunk/gcc/gimplify.c	(working copy)
> @@ -1841,6 +1841,33 @@
>        return GS_ERROR;
>      }
>  
> +  /* Validate variable for use within routine function.  */
> +  if (gimplify_omp_ctxp && gimplify_omp_ctxp->region_type == ORT_TARGET
> +      && get_oacc_fn_attrib (current_function_decl)

If you only care about the implicit target region of acc routine, I think
you also want to check that gimplify_omp_ctxp->outer_context == NULL.

> +      && TREE_CODE (decl) == VAR_DECL
> +      && is_global_var (decl)
> +      && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
> +	  || (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))
> +    {
> +      location_t loc = DECL_SOURCE_LOCATION (decl);
> +
> +      if (lookup_attribute ("omp declare target link", DECL_ATTRIBUTES (decl)))
> +	{
> +	  error_at (loc,
> +		    "%qE with %<link%> clause used in %<routine%> function",
> +		    DECL_NAME (decl));
> +	  return GS_ERROR;
> +	}
> +      else if (!lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)))
> +	{
> +	  error_at (loc,
> +		    "storage class of %qE cannot be ", DECL_NAME (decl));
> +	  error_at (gimplify_omp_ctxp->location,
> +		    "used in enclosing %<routine%> function");

And I'm really confused by this error message.  If you are complaining that
the variable is not listed in acc declare clauses, why don't you say that?
What does the error have to do with its storage class?
Also, splitting one error into two is weird, usually there would be one
error message and perhaps inform after it.

	Jakub

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

* Re: [PATCH] Fix use of declare'd vars by routine procedures.
  2016-01-29  8:32     ` Jakub Jelinek
@ 2016-02-01 16:00       ` James Norris
  2016-02-01 16:06         ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: James Norris @ 2016-02-01 16:00 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches

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

Hi!

On 01/29/2016 02:31 AM, Jakub Jelinek wrote:
> On Thu, Jan 28, 2016 at 12:26:38PM -0600, James Norris wrote:
>> I think the attached change is what you had in mind with
>> regard to doing the check at gimplification time.
>
> Nope, this is still a wrong location for that.
> If you look at the next line after the block you've added, you'll see
> if (gimplify_omp_ctxp && omp_notice_variable (gimplify_omp_ctxp, decl, true))
> And that function fairly early calls is_global_var (decl).  So you know
> already gimplify_omp_ctxp && is_global_var (decl), just put the rest into
> that block.

When said you said "rest into that block", I assumed you meant
the block in omp_notice_variable () that has the function call
to is_global_var () as the if condition.

> The TREE_CODE (decl) == VAR_DECL check is VAR_P (decl).

Fixed.

> What do you want to achieve with
>
>> +      && ((TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
>> +       || (!TREE_STATIC (decl) && DECL_EXTERNAL (decl))))
>
> ?  is_global_var already guarantees you that it is either TREE_STATIC
> or DECL_EXTERNAL, why is that not good enough?

As you pointed out above, the check is not necessary.

>
>> [snip snip]
>>
>> +  /* Validate variable for use within routine function.  */
>> +  if (gimplify_omp_ctxp && gimplify_omp_ctxp->region_type == ORT_TARGET
>> +      && get_oacc_fn_attrib (current_function_decl)
>
> If you only care about the implicit target region of acc routine, I think
> you also want to check that gimplify_omp_ctxp->outer_context == NULL.

Check added.

>
>> [snip snip]
>
> And I'm really confused by this error message.  If you are complaining that
> the variable is not listed in acc declare clauses, why don't you say that?
> What does the error have to do with its storage class?
> Also, splitting one error into two is weird, usually there would be one
> error message and perhaps inform after it.

Error messages re-written to make better sense.

Thanks!

Jim

===== ChangeLog entries....

         gcc/
         * gimplify.c (omp_notice_variable): Add variable usage check.
         gcc/testsuite/
         * c-c++-common/goacc/routine-5.c: Add tests.




[-- Attachment #2: declare.patch --]
[-- Type: text/x-patch, Size: 4452 bytes --]

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9f99842..41cd7a7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2016-01-XX  James Norris  <jnorris@codesourcery.com>
+
+	* gimplify.c (omp_notice_variable): Add usage check.
+
 2016-01-29  Jakub Jelinek  <jakub@redhat.com>
 
 	PR target/69551
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 32bc1fd..5833605 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6087,9 +6087,9 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
   if (ctx->region_type == ORT_NONE)
     return lang_hooks.decls.omp_disregard_value_expr (decl, false);
 
-  /* Threadprivate variables are predetermined.  */
   if (is_global_var (decl))
     {
+      /* Threadprivate variables are predetermined.  */
       if (DECL_THREAD_LOCAL_P (decl))
 	return omp_notice_threadprivate_variable (ctx, decl, NULL_TREE);
 
@@ -6100,6 +6100,30 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 	  if (value && DECL_P (value) && DECL_THREAD_LOCAL_P (value))
 	    return omp_notice_threadprivate_variable (ctx, decl, value);
 	}
+
+      if (gimplify_omp_ctxp->outer_context == NULL
+	  && VAR_P (decl)
+	  && get_oacc_fn_attrib (current_function_decl))
+	{
+	  location_t loc = DECL_SOURCE_LOCATION (decl);
+
+	  if (lookup_attribute ("omp declare target link",
+				DECL_ATTRIBUTES (decl)))
+	    {
+	      error_at (loc,
+			"%qE with %<link%> clause used in %<routine%> function",
+			DECL_NAME (decl));
+	      return false;
+	    }
+	  else if (!lookup_attribute ("omp declare target",
+				      DECL_ATTRIBUTES (decl)))
+	    {
+	      error_at (loc,
+			"%qE requires a %<declare%> directive for use "
+			"in a %<routine%> function", DECL_NAME (decl));
+	      return false;
+	    }
+	}
     }
 
   n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl);
@@ -8223,7 +8247,7 @@ gimplify_oacc_declare (tree *expr_p, gimple_seq *pre_p)
 	      if (oacc_declare_returns == NULL)
 		oacc_declare_returns = new hash_map<tree, tree>;
 
-	      oacc_declare_returns->put (decl, c);
+		oacc_declare_returns->put (decl, c);
 	    }
 	}
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 150ebc8..61003c2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-01-XX  James Norris  <jnorris@codesourcery.com>
+
+	* c-c++-common/goacc/routine-5.c: Add tests.
+
 2016-01-29  Jakub Jelinek  <jakub@redhat.com>
 
 	PR target/69551
diff --git a/gcc/testsuite/c-c++-common/goacc/routine-5.c b/gcc/testsuite/c-c++-common/goacc/routine-5.c
index ccda097..c34838f 100644
--- a/gcc/testsuite/c-c++-common/goacc/routine-5.c
+++ b/gcc/testsuite/c-c++-common/goacc/routine-5.c
@@ -45,3 +45,97 @@ using namespace g;
 #pragma acc routine (a) /* { dg-error "does not refer to" } */
   
 #pragma acc routine (c) /* { dg-error "does not refer to" } */
+
+int vb1;		/* { dg-error "directive for use" } */
+extern int vb2;		/* { dg-error "directive for use" } */
+static int vb3;		/* { dg-error "directive for use" } */
+
+#pragma acc routine
+int
+func1 (int a)
+{
+  vb1 = a + 1;
+  vb2 = vb1 + 1;
+  vb3 = vb2 + 1;
+
+  return vb3;
+}
+
+#pragma acc routine
+int
+func2 (int a)
+{
+  extern int vb4;	/* { dg-error "directive for use" } */
+  static int vb5;	/* { dg-error "directive for use" } */
+
+  vb4 = a + 1;
+  vb5 = vb4 + 1;
+
+  return vb5;
+}
+
+extern int vb6;			/* { dg-error "clause used in" } */
+#pragma acc declare link (vb6)
+static int vb7;			/* { dg-error "clause used in" } */
+#pragma acc declare link (vb7)
+
+#pragma acc routine
+int
+func3 (int a)
+{
+  vb6 = a + 1;
+  vb7 = vb6 + 1;
+
+  return vb7;
+}
+
+int vb8;
+#pragma acc declare create (vb8)
+extern int vb9;
+#pragma acc declare create (vb9)
+static int vb10;
+#pragma acc declare create (vb10)
+
+#pragma acc routine
+int
+func4 (int a)
+{
+  vb8 = a + 1;
+  vb9 = vb8 + 1;
+  vb10 = vb9 + 1;
+
+  return vb10;
+}
+
+int vb11;
+#pragma acc declare device_resident (vb11)
+extern int vb12;
+#pragma acc declare device_resident (vb12)
+extern int vb13;
+#pragma acc declare device_resident (vb13)
+
+#pragma acc routine
+int
+func5 (int a)
+{
+  vb11 = a + 1;
+  vb12 = vb11 + 1;
+  vb13 = vb12 + 1;
+
+  return vb13;
+}
+
+#pragma acc routine
+int
+func6 (int a)
+{
+  extern int vb14;
+#pragma acc declare create (vb14)
+  static int vb15;
+#pragma acc declare create (vb15)
+
+  vb14 = a + 1;
+  vb15 = vb14 + 1;
+
+  return vb15;
+}

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

* Re: [PATCH] Fix use of declare'd vars by routine procedures.
  2016-02-01 16:00       ` James Norris
@ 2016-02-01 16:06         ` Jakub Jelinek
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Jelinek @ 2016-02-01 16:06 UTC (permalink / raw)
  To: James Norris; +Cc: GCC Patches

On Mon, Feb 01, 2016 at 10:00:51AM -0600, James Norris wrote:
> +2016-01-XX  James Norris  <jnorris@codesourcery.com>

It is February now ;)

> @@ -8223,7 +8247,7 @@ gimplify_oacc_declare (tree *expr_p, gimple_seq *pre_p)
>  	      if (oacc_declare_returns == NULL)
>  		oacc_declare_returns = new hash_map<tree, tree>;
>  
> -	      oacc_declare_returns->put (decl, c);
> +		oacc_declare_returns->put (decl, c);
>  	    }
>  	}

This snippet looks wrong, I bet -Wmisleading-indentation will flag that (or should).

Ok for trunk with the bogus snippet removed.

	Jakub

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

end of thread, other threads:[~2016-02-01 16:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-17 23:01 [PATCH] Fix use of declare'd vars by routine procedures James Norris
2016-01-22 10:39 ` Jakub Jelinek
2016-01-28 18:26   ` James Norris
2016-01-29  8:32     ` Jakub Jelinek
2016-02-01 16:00       ` James Norris
2016-02-01 16:06         ` Jakub Jelinek

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