Hi!

Apparently with -std=c++11 and higher, if in a template we call
finish_expr_stmt on a DECL_EXPR (as cp_parser_omp_declare_reduction_exprs
does) and the omp_priv var in there is not type dependent, it ICEs during:
      else if (!type_dependent_expression_p (expr))
        convert_to_void (build_non_dependent_expr (expr), ICV_STATEMENT,
                         tf_warning_or_error);
So, the patch in that case just does the rest of what finish_expr_stmt
performs.

Jason, do you have better ideas how to fix this?

The patch has been bootstrapped/regtested on x86_64-linux and i686-linux.

2014-03-18  Jakub Jelinek  <ja...@redhat.com>

        PR c++/60331
        * parser.c (cp_parser_omp_declare_reduction_exprs): Avoid calling
        finish_expr_stmt on DECL_EXPRs in templates.

        * testsuite/libgomp.c++/udr-11.C: New test.
        * testsuite/libgomp.c++/udr-12.C: New test.
        * testsuite/libgomp.c++/udr-13.C: New test.
        * testsuite/libgomp.c++/udr-14.C: New test.
        * testsuite/libgomp.c++/udr-15.C: New test.
        * testsuite/libgomp.c++/udr-16.C: New test.
        * testsuite/libgomp.c++/udr-17.C: New test.
        * testsuite/libgomp.c++/udr-18.C: New test.
        * testsuite/libgomp.c++/udr-19.C: New test.

--- gcc/cp/parser.c.jj  2014-03-18 10:04:14.000000000 +0100
+++ gcc/cp/parser.c     2014-03-18 11:18:44.511571459 +0100
@@ -30698,7 +30698,22 @@ cp_parser_omp_declare_reduction_exprs (t
 
       block = finish_omp_structured_block (block);
       cp_walk_tree (&block, cp_remove_omp_priv_cleanup_stmt, omp_priv, NULL);
-      finish_expr_stmt (block);
+      if (block
+         && TREE_CODE (block) == DECL_EXPR
+         && processing_template_decl)
+       {
+         if (check_for_bare_parameter_packs (block))
+           block = error_mark_node;
+         if (TREE_CODE (block) != CLEANUP_POINT_EXPR)
+           {
+             if (TREE_CODE (block) != EXPR_STMT)
+               block = build_stmt (input_location, EXPR_STMT, block);
+             block = maybe_cleanup_point_expr_void (block);
+           }
+         add_stmt (block);
+       }
+      else
+       finish_expr_stmt (block);
 
       if (ctor)
        add_decl_expr (omp_orig);
--- libgomp/testsuite/libgomp.c++/udr-11.C.jj   2014-03-18 11:47:43.326846415 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-11.C      2014-03-18 11:47:43.329846576 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-1.C"
--- libgomp/testsuite/libgomp.c++/udr-12.C.jj   2014-03-18 11:47:43.330846623 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-12.C      2014-03-18 11:47:43.331846666 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-2.C"
--- libgomp/testsuite/libgomp.c++/udr-13.C.jj   2014-03-18 11:47:43.332846707 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-13.C      2014-03-18 11:47:43.332846707 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-3.C"
--- libgomp/testsuite/libgomp.c++/udr-14.C.jj   2014-03-18 11:47:43.333846744 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-14.C      2014-03-18 11:47:43.334846777 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-4.C"
--- libgomp/testsuite/libgomp.c++/udr-15.C.jj   2014-03-18 11:47:43.334846777 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-15.C      2014-03-18 11:47:43.335846809 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-5.C"
--- libgomp/testsuite/libgomp.c++/udr-16.C.jj   2014-03-18 11:47:43.336846840 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-16.C      2014-03-18 11:47:43.336846840 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-6.C"
--- libgomp/testsuite/libgomp.c++/udr-17.C.jj   2014-03-18 11:47:43.337846867 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-17.C      2014-03-18 11:47:43.337846867 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-7.C"
--- libgomp/testsuite/libgomp.c++/udr-18.C.jj   2014-03-18 11:47:43.338846892 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-18.C      2014-03-18 11:47:43.338846892 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-8.C"
--- libgomp/testsuite/libgomp.c++/udr-19.C.jj   2014-03-18 11:47:43.339846916 
+0100
+++ libgomp/testsuite/libgomp.c++/udr-19.C      2014-03-18 11:47:43.339846916 
+0100
@@ -0,0 +1,4 @@
+// { dg-do run }
+// { dg-options "-fopenmp -std=c++11" }
+
+#include "udr-9.C"

        Jakub

Reply via email to