Hi,

I think that to avoid ICE-ing during error recovery when DECL_SAVED_TREE is NULL_TREE we want to simply bail out and return true to the caller. Tested x86_64-linux.

Thanks,
Paolo.

//////////////////
/cp
2014-12-12  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/59628
        * semantics.c (finish_omp_reduction_clause): Early return true
        if DECL_SAVED_TREE (id) is NULL_TREE.

/testsuite
2014-12-12  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/59628
        * g++.dg/gomp/pr59628.C: New.
Index: cp/semantics.c
===================================================================
--- cp/semantics.c      (revision 218683)
+++ cp/semantics.c      (working copy)
@@ -5138,6 +5138,8 @@ finish_omp_reduction_clause (tree c, bool *need_de
       id = OVL_CURRENT (id);
       mark_used (id);
       tree body = DECL_SAVED_TREE (id);
+      if (!body)
+       return true;
       if (TREE_CODE (body) == STATEMENT_LIST)
        {
          tree_stmt_iterator tsi;
Index: testsuite/g++.dg/gomp/pr59628.C
===================================================================
--- testsuite/g++.dg/gomp/pr59628.C     (revision 0)
+++ testsuite/g++.dg/gomp/pr59628.C     (working copy)
@@ -0,0 +1,13 @@
+// PR c++/59628
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+struct A { int i; };
+
+void foo()
+{
+  A a;
+  #pragma omp declare reduction (+: A: omp_out.i +: omp_in.i)  // { dg-error 
"expected" }
+  #pragma omp parallel reduction (+: a)
+  ;
+}

Reply via email to