Hi!

As can be seen on the testcase, apparently it is a bad idea to call
maybe_constant_value when processing_template_decl, e.g. the 2 && 2
is at that point still 2 && 2 rather than true && true and constexpr
code is unhappy about that.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk so far.

2017-03-22  Jakub Jelinek  <ja...@redhat.com>

        PR c++/80141
        * semantics.c (finish_omp_clause) <case OMP_CLAUSE_SIMDLEN,
        case OMP_CLAUSE_ALIGNED>: Call maybe_constant_value only when not
        processing_template_decl.

        * g++.dg/gomp/pr80141.C: New test.

--- gcc/cp/semantics.c.jj       2017-02-27 15:19:14.000000000 +0100
+++ gcc/cp/semantics.c  2017-03-22 15:46:34.003442833 +0100
@@ -6416,9 +6416,9 @@ finish_omp_clauses (tree clauses, enum c
          else
            {
              t = mark_rvalue_use (t);
-             t = maybe_constant_value (t);
              if (!processing_template_decl)
                {
+                 t = maybe_constant_value (t);
                  if (TREE_CODE (t) != INTEGER_CST
                      || tree_int_cst_sgn (t) != 1)
                    {
@@ -6586,9 +6586,9 @@ finish_omp_clauses (tree clauses, enum c
          else
            {
              t = mark_rvalue_use (t);
-             t = maybe_constant_value (t);
              if (!processing_template_decl)
                {
+                 t = maybe_constant_value (t);
                  if (TREE_CODE (t) != INTEGER_CST
                      || tree_int_cst_sgn (t) != 1)
                    {
--- gcc/testsuite/g++.dg/gomp/pr80141.C.jj      2017-03-22 17:37:52.445284214 
+0100
+++ gcc/testsuite/g++.dg/gomp/pr80141.C 2017-03-22 17:35:53.000000000 +0100
@@ -0,0 +1,8 @@
+// PR c++/80141
+// { dg-do compile }
+
+#pragma omp declare simd aligned (p : 2 && 2)
+template<int> void foo (int *p);
+
+#pragma omp declare simd simdlen (2 && 2)
+template<int> void bar (int *p);

        Jakub

Reply via email to