Hi!

While in C a constant expression can't start with 
score(constant-integral-expression),
in C++11 it can and so we need to do tentative parsing or skipping to the
closing ) to check if there is : to find out if it is trait-score or just
part of a constant expression.

The following patch adds a testcase for that, tested on x86_64-linux,
committed to trunk.

2019-10-30  Jakub Jelinek  <ja...@redhat.com>

        * g++.dg/gomp/declare-variant-6.C: New test.

--- gcc/testsuite/g++.dg/gomp/declare-variant-6.C.jj    2019-10-30 
13:11:36.534957481 +0100
+++ gcc/testsuite/g++.dg/gomp/declare-variant-6.C       2019-10-30 
13:12:14.797373585 +0100
@@ -0,0 +1,26 @@
+// Test parsing of #pragma omp declare variant
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fdump-tree-gimple" }
+
+constexpr int score (int x) { return x; }
+void f0 ();
+#pragma omp declare variant (f0) match (user={condition(score(1))})
+void f1 ();
+void f2 ();
+#pragma omp declare variant (f2) match (user={condition(score(1):1)})
+void f3 ();
+void f4 ();
+#pragma omp declare variant (f4) match (user={condition(score(1):score(1))})
+void f5 ();
+void f6 ();
+#pragma omp declare variant (f6) match (user={condition(score(1)==0)})
+void f7 ();
+
+void
+test ()
+{
+  f1 ();       // { dg-final { scan-tree-dump-times "f0 \\\(\\\);" 1 "gimple" 
} }
+  f3 ();       // { dg-final { scan-tree-dump-times "f2 \\\(\\\);" 1 "gimple" 
} }
+  f5 ();       // { dg-final { scan-tree-dump-times "f4 \\\(\\\);" 1 "gimple" 
} }
+  f7 ();       // { dg-final { scan-tree-dump-times "f7 \\\(\\\);" 1 "gimple" 
} }
+}

        Jakub

Reply via email to