c-typeck.c (c_finish_omp_clauses): Diagnose aligned clause with decl that is not pointer nor array.

* 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.

From-SVN: r204273
This commit is contained in:
Jakub Jelinek 2013-10-31 20:06:08 +01:00 committed by Jakub Jelinek
parent e5ccdfcd51
commit 5a9785fb4c
10 changed files with 133 additions and 1 deletions

View File

@ -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

View File

@ -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),

View File

@ -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

View File

@ -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);

View File

@ -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.

View File

@ -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]++;
}

View File

@ -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);
};

View File

@ -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 }

View File

@ -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]++;
}

View File

@ -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);