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
[c, openacc] Handle non-var-decl in mark_vars_oacc_gangprivate

2018-05-01  Tom de Vries  <t...@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;
+}

Reply via email to