diff mbox series

[og7,c,openacc,PR85465,committed] Handle non-var-decl in mark_vars_oacc_gangprivate

Message ID 1fa1cbcc-74e5-0e2d-9b69-868c9e47aa3c@mentor.com
State New
Headers show
Series [og7,c,openacc,PR85465,committed] Handle non-var-decl in mark_vars_oacc_gangprivate | expand

Commit Message

Tom de Vries May 1, 2018, 6:40 p.m. UTC
Hi,

atm we run into an assert when compiling the test-case from the patch, 
because we encounter a non VAR_DECL (for foo) in this loop in 
mark_vars_oacc_gangprivate:
...
   if (TREE_CODE (*tp) == BIND_EXPR)
     {
       tree block = BIND_EXPR_BLOCK (*tp);
       for (tree var = BLOCK_VARS (block); var; var = DECL_CHAIN (var))
         {
           gcc_assert (TREE_CODE (var) == VAR_DECL);
           DECL_ATTRIBUTES (var)
             = tree_cons (get_identifier ("oacc gangprivate"),
                          NULL, DECL_ATTRIBUTES (var));
           c_mark_addressable (var);
         }
     }
...

Fixed by skipping over the non VAR_DECLs in the loop.

Build x86_64 with nvptx accelerator, ran libgomp testsuite.

Committed to og7 branch.

Thanks,
- Tom

Comments

Marek Polacek May 1, 2018, 6:44 p.m. UTC | #1
On Tue, May 01, 2018 at 08:40:59PM +0200, Tom de Vries wrote:
> @@ -14210,7 +14210,8 @@ mark_vars_oacc_gangprivate (tree *tp,
>        tree block = BIND_EXPR_BLOCK (*tp);
>        for (tree var = BLOCK_VARS (block); var; var = DECL_CHAIN (var))
>  	{
> -	  gcc_assert (TREE_CODE (var) == VAR_DECL);
> +	  if (TREE_CODE (var) != VAR_DECL)
> +	    continue;

Just FYI, we have VAR_P for this.

Marek
diff mbox series

Patch

[c, openacc] Handle non-var-decl in mark_vars_oacc_gangprivate

2018-05-01  Tom de Vries  <tom@codesourcery.com>

	PR target/85465
	* c-parser.c (mark_vars_oacc_gangprivate): Skip BLOCK_VARS that are not
	VAR_DECL.

	* testsuite/libgomp.oacc-c/pr85465.c: New test.

---
 gcc/c/c-parser.c                           |  3 ++-
 libgomp/testsuite/libgomp.oacc-c/pr85465.c | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 069d219..99e9c8b 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -14210,7 +14210,8 @@  mark_vars_oacc_gangprivate (tree *tp,
       tree block = BIND_EXPR_BLOCK (*tp);
       for (tree var = BLOCK_VARS (block); var; var = DECL_CHAIN (var))
 	{
-	  gcc_assert (TREE_CODE (var) == VAR_DECL);
+	  if (TREE_CODE (var) != VAR_DECL)
+	    continue;
 	  DECL_ATTRIBUTES (var)
 	    = tree_cons (get_identifier ("oacc gangprivate"),
 			 NULL, DECL_ATTRIBUTES (var));
diff --git a/libgomp/testsuite/libgomp.oacc-c/pr85465.c b/libgomp/testsuite/libgomp.oacc-c/pr85465.c
new file mode 100644
index 0000000..329e8a0
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c/pr85465.c
@@ -0,0 +1,11 @@ 
+/* { dg-do compile } */
+/* { dg-additional-options "-w" } */
+
+int
+main (void)
+{
+#pragma acc parallel
+  foo ();
+
+  return 0;
+}