summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-31 19:06:08 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-10-31 19:06:08 +0000
commit23871d0cedfe77078bb09c3be41afd26e4a9f551 (patch)
treeb855c0f5f2b49779d10067e2ee590fb7d92a9ef8 /gcc
parent2b2b90a31143f386260cc41a9aeb05f6516c9538 (diff)
downloadppe42-gcc-23871d0cedfe77078bb09c3be41afd26e4a9f551.tar.gz
ppe42-gcc-23871d0cedfe77078bb09c3be41afd26e4a9f551.zip
* c-typeck.c (c_finish_omp_clauses): Diagnose aligned clause
with decl that is not pointer nor array. * semantics.c (finish_omp_clauses): Diagnose aligned clause with decl that is not pointer nor array nor reference to those. * g++.dg/gomp/simd-1.C: New test. * g++.dg/gomp/declare-simd-1.C (f32): Fix up aligned clause argument. * g++.dg/gomp/declare-simd-2.C (fn13, fn14): Add new tests. * gcc.dg/gomp/declare-simd-2.c (fn7, fn8, fn9, fn10, fn11): Likewise. * c-c++-common/gomp/simd6.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204273 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/c-typeck.c8
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/semantics.c13
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/c-c++-common/gomp/simd6.c27
-rw-r--r--gcc/testsuite/g++.dg/gomp/declare-simd-1.C2
-rw-r--r--gcc/testsuite/g++.dg/gomp/declare-simd-2.C18
-rw-r--r--gcc/testsuite/g++.dg/gomp/simd-1.C31
-rw-r--r--gcc/testsuite/gcc.dg/gomp/declare-simd-2.c17
10 files changed, 133 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index ed60988a150..8f8a245edcf 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-31 Jakub Jelinek <jakub@redhat.com>
+
+ * c-typeck.c (c_finish_omp_clauses): Diagnose aligned clause
+ with decl that is not pointer nor array.
+
2013-10-29 Balaji V. Iyer <balaji.v.iyer@intel.com>
* c-decl.c (finish_function): Added a call for insert_cilk_frame when
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 1034cee1fcc..5a23c843295 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -11504,6 +11504,14 @@ c_finish_omp_clauses (tree clauses)
"%qE is not a variable in %<aligned%> clause", t);
remove = true;
}
+ else if (!POINTER_TYPE_P (TREE_TYPE (t))
+ && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE in %<aligned%> clause is neither a pointer nor "
+ "an array", t);
+ remove = true;
+ }
else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
{
error_at (OMP_CLAUSE_LOCATION (c),
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c7a0e5d9dc9..e7b1e254318 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-31 Jakub Jelinek <jakub@redhat.com>
+
+ * semantics.c (finish_omp_clauses): Diagnose aligned clause
+ with decl that is not pointer nor array nor reference to those.
+
2013-10-31 Jason Merrill <jason@redhat.com>
* semantics.c (cxx_eval_call_expression): Handle trivial
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index de3e8e7dcb8..49097f7f1b3 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5467,6 +5467,19 @@ finish_omp_clauses (tree clauses)
error ("%qE is not a variable in %<aligned%> clause", t);
remove = true;
}
+ else if (!type_dependent_expression_p (t)
+ && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE
+ && (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE
+ || (!POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t)))
+ && (TREE_CODE (TREE_TYPE (TREE_TYPE (t)))
+ != ARRAY_TYPE))))
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%qE in %<aligned%> clause is neither a pointer nor "
+ "an array nor a reference to pointer or array", t);
+ remove = true;
+ }
else if (bitmap_bit_p (&aligned_head, DECL_UID (t)))
{
error ("%qD appears more than once in %<aligned%> clauses", t);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 68f93f4e027..b231dc89ebd 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2013-10-31 Jakub Jelinek <jakub@redhat.com>
+
+ * g++.dg/gomp/simd-1.C: New test.
+ * g++.dg/gomp/declare-simd-1.C (f32): Fix up aligned clause argument.
+ * g++.dg/gomp/declare-simd-2.C (fn13, fn14): Add new tests.
+ * gcc.dg/gomp/declare-simd-2.c (fn7, fn8, fn9, fn10, fn11): Likewise.
+ * c-c++-common/gomp/simd6.c: New test.
+
2013-10-31 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement C++14 digit separators.
diff --git a/gcc/testsuite/c-c++-common/gomp/simd6.c b/gcc/testsuite/c-c++-common/gomp/simd6.c
new file mode 100644
index 00000000000..3a90c225e9e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/simd6.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+extern int a[1024];
+
+struct S { int i; } s;
+
+void
+f1 (int x, float f, int *p)
+{
+ int i;
+ #pragma omp simd aligned(x : 32) /* { dg-error "neither a pointer nor an array" } */
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+ #pragma omp simd aligned(f) /* { dg-error "neither a pointer nor an array" } */
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+ #pragma omp simd aligned(s : 16) /* { dg-error "neither a pointer nor an array" } */
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+ #pragma omp simd aligned(a : 8)
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+ #pragma omp simd aligned(p : 8)
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+}
diff --git a/gcc/testsuite/g++.dg/gomp/declare-simd-1.C b/gcc/testsuite/g++.dg/gomp/declare-simd-1.C
index 1fd88b7efab..e9be161948e 100644
--- a/gcc/testsuite/g++.dg/gomp/declare-simd-1.C
+++ b/gcc/testsuite/g++.dg/gomp/declare-simd-1.C
@@ -205,7 +205,7 @@ f30 (int x)
template <int N>
struct C
{
- #pragma omp declare simd simdlen (N) aligned (a : N * sizeof (int)) linear (c : N) notinbranch
+ #pragma omp declare simd simdlen (N) aligned (b : N * sizeof (int)) linear (c : N) notinbranch
int f32 (int a, int *b, int c);
};
diff --git a/gcc/testsuite/g++.dg/gomp/declare-simd-2.C b/gcc/testsuite/g++.dg/gomp/declare-simd-2.C
index f64004fb012..e450a0241c7 100644
--- a/gcc/testsuite/g++.dg/gomp/declare-simd-2.C
+++ b/gcc/testsuite/g++.dg/gomp/declare-simd-2.C
@@ -64,4 +64,22 @@ struct D
int e;
};
+#pragma omp declare simd aligned (a, b, c, d)
+int fn13 (int *a, int b[64], int *&c, int (&d)[64]);
+
+#pragma omp declare simd aligned (a) // { dg-error "neither a pointer nor an array" }
+int fn14 (int a);
+
+#pragma omp declare simd aligned (b) // { dg-error "neither a pointer nor an array" }
+int fn14 (int &b);
+
+#pragma omp declare simd aligned (c) // { dg-error "neither a pointer nor an array" }
+int fn14 (float c);
+
+#pragma omp declare simd aligned (d) // { dg-error "neither a pointer nor an array" }
+int fn14 (double &d);
+
+#pragma omp declare simd aligned (e) // { dg-error "neither a pointer nor an array" }
+int fn14 (D e);
+
// { dg-error "has no member" "" { target *-*-* } 61 }
diff --git a/gcc/testsuite/g++.dg/gomp/simd-1.C b/gcc/testsuite/g++.dg/gomp/simd-1.C
new file mode 100644
index 00000000000..c9c2e73bb40
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/simd-1.C
@@ -0,0 +1,31 @@
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+extern int a[1024];
+int (&b)[1024] = a;
+
+struct S { int s; } s, &t = s;
+
+void
+f1 (int &x, float &f, int *&p)
+{
+ int i;
+ #pragma omp simd aligned(x : 32) // { dg-error "neither a pointer nor an array" }
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+ #pragma omp simd aligned(f) // { dg-error "neither a pointer nor an array" }
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+ #pragma omp simd aligned(t : 16) // { dg-error "neither a pointer nor an array" }
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+ #pragma omp simd aligned(a : 8)
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+ #pragma omp simd aligned(b : 8)
+ for (i = 0; i < 1024; i++)
+ b[i]++;
+ #pragma omp simd aligned(p : 8)
+ for (i = 0; i < 1024; i++)
+ a[i]++;
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/declare-simd-2.c b/gcc/testsuite/gcc.dg/gomp/declare-simd-2.c
index 118549be908..6c7de8b73f9 100644
--- a/gcc/testsuite/gcc.dg/gomp/declare-simd-2.c
+++ b/gcc/testsuite/gcc.dg/gomp/declare-simd-2.c
@@ -22,3 +22,20 @@ int fn5 (int a);
#pragma omp declare simd inbranch notinbranch /* { dg-error "clause is incompatible with" } */
int fn6 (int);
+
+#pragma omp declare simd aligned (a, b)
+int fn7 (int *a, int b[64]);
+
+#pragma omp declare simd aligned (a) /* { dg-error "neither a pointer nor an array" } */
+int fn8 (int a);
+
+#pragma omp declare simd aligned (c) /* { dg-error "neither a pointer nor an array" } */
+int fn9 (float c);
+
+#pragma omp declare simd aligned (d) /* { dg-error "neither a pointer nor an array" } */
+int fn10 (double d);
+
+struct D { int d; };
+
+#pragma omp declare simd aligned (e) /* { dg-error "neither a pointer nor an array" } */
+int fn11 (struct D e);
OpenPOWER on IntegriCloud