re PR c++/59628 (ICE with invalid OpenMP "declare reduction" clause)
authorPaolo Carlini <paolo.carlini@oracle.com>
Fri, 12 Dec 2014 21:50:12 +0000 (21:50 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Fri, 12 Dec 2014 21:50:12 +0000 (21:50 +0000)
/cp
2014-12-12  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

PR c++/59628
* g++.dg/gomp/pr59628.C: New.

From-SVN: r218692

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr59628.C [new file with mode: 0644]

index 4fb8a13c3224f7b83018eba08e918d7ca89adb9b..576610deed0d5c103cf3f82d5abd0d94d2eb5179 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-12  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/59628
+       * semantics.c (finish_omp_reduction_clause): Early return true
+       if DECL_SAVED_TREE (id) is NULL_TREE.
+
 2014-12-12  Jason Merrill  <jason@redhat.com>
 
        N3922
index 8a1de7e095c97fc92063cfaf9e5d4f8ae79d64b9..5ad391eda5beeedc42e16f5b51566152d93d215e 100644 (file)
@@ -5138,6 +5138,8 @@ finish_omp_reduction_clause (tree c, bool *need_default_ctor, bool *need_dtor)
       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 378f30973f3211f6d5cd906d4bf582d82029ed85..767617798ab7ef7cd88f20ed0f30b3b5aba200ca 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-12  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/59628
+       * g++.dg/gomp/pr59628.C: New.
+
 2014-12-12  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/61924
diff --git a/gcc/testsuite/g++.dg/gomp/pr59628.C b/gcc/testsuite/g++.dg/gomp/pr59628.C
new file mode 100644 (file)
index 0000000..518200b
--- /dev/null
@@ -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)
+  ;
+}