summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/gomp/delim-declare-variant-2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/gomp/delim-declare-variant-2.C')
-rw-r--r--gcc/testsuite/g++.dg/gomp/delim-declare-variant-2.C53
1 files changed, 53 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/gomp/delim-declare-variant-2.C b/gcc/testsuite/g++.dg/gomp/delim-declare-variant-2.C
new file mode 100644
index 00000000000..1784e14dfc3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/delim-declare-variant-2.C
@@ -0,0 +1,53 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+/* Check that "omp begin declare variant" works on methods in a
+ class declaration. */
+
+class test1 {
+
+ private:
+ int n;
+ static int m;
+
+ public:
+
+ #pragma omp begin declare variant match (implementation={vendor("gnu")})
+ int get_n (void) { return n * 2; }
+ static int get_m (void) { return m * 2; }
+ #pragma omp end declare variant
+
+ #pragma omp begin declare variant match (construct={target})
+ int get_n (void) { return this->n * 2; }
+ #pragma omp end declare variant
+
+ /* The base methods are deliberately declared after the variants in order
+ to check that the lookup can still find them. */
+ void set_n (int x) { n = x; }
+ int get_n (void) { return n; }
+
+ static void set_m (int x) { m = x; }
+ static int get_m (void) { return m; }
+};
+
+int test1::m;
+
+int main (void)
+{
+ test1 t1;
+ t1.set_n (10);
+ if (t1.get_n () != 20) __builtin_abort ();
+ test1::set_m (1);
+ if (test1::get_m () != 2) __builtin_abort ();
+}
+
+/* { dg-final { scan-tree-dump "test1::get_n\\.ompvariant. \\(&t1\\)" "gimple" } } */
+/* { dg-final { scan-tree-dump "test1::get_m\\.ompvariant. \\(\\)" "gimple" } } */
+
+/* The variants must have internal linkage, not .globl or .weak. */
+/* { dg-final { scan-assembler-not "\\.globl\[ \t\]*_?_ZN5test117get_n\\.ompvariant" } } */
+/* { dg-final { scan-assembler-not "\\.globl\[ \t\]*_?_ZN5test117get_m\\.ompvariant" } } */
+/* { dg-final { scan-assembler-not "\\.weak\[ \t\]*_?_ZN5test117get_n\\.ompvariant" } } */
+/* { dg-final { scan-assembler-not "\\.weak\[ \t\]*_?_ZN5test117get_m\\.ompvariant" } } */
+
+