re PR c++/38348 (ICE from c_finish_omp_for)
PR c++/38348 * c-omp.c (c_finish_omp_for): Only transform pointer ++ or -- into MODIFY_EXPR if second argument is non-NULL. * g++.dg/gomp/for-19.C: New test. * testsuite/libgomp.c++/for-6.C: New test. From-SVN: r142318
This commit is contained in:
parent
193a36816e
commit
956adfaf9f
6 changed files with 164 additions and 1 deletions
|
@ -1,5 +1,9 @@
|
|||
2008-12-01 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/38348
|
||||
* c-omp.c (c_finish_omp_for): Only transform pointer
|
||||
++ or -- into MODIFY_EXPR if second argument is non-NULL.
|
||||
|
||||
PR rtl-optimization/38245
|
||||
* tree-vrp.c (abs_extent_range): New function.
|
||||
(extract_range_from_binary_expr): Compute range
|
||||
|
|
|
@ -357,7 +357,8 @@ c_finish_omp_for (location_t locus, tree declv, tree initv, tree condv,
|
|||
break;
|
||||
|
||||
incr_ok = true;
|
||||
if (POINTER_TYPE_P (TREE_TYPE (decl)))
|
||||
if (POINTER_TYPE_P (TREE_TYPE (decl))
|
||||
&& TREE_OPERAND (incr, 1))
|
||||
{
|
||||
tree t = fold_convert (sizetype, TREE_OPERAND (incr, 1));
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
2008-12-01 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/38348
|
||||
* g++.dg/gomp/for-19.C: New test.
|
||||
|
||||
PR rtl-optimization/38245
|
||||
* gcc.dg/pr38245-1.c: New test.
|
||||
* gcc.dg/pr38245-2.c: New test.
|
||||
|
|
41
gcc/testsuite/g++.dg/gomp/for-19.C
Normal file
41
gcc/testsuite/g++.dg/gomp/for-19.C
Normal file
|
@ -0,0 +1,41 @@
|
|||
// PR c++/38348
|
||||
// { dg-do compile }
|
||||
// { dg-options "-fopenmp" }
|
||||
|
||||
const char *p = "abcde";
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
f1 (void)
|
||||
{
|
||||
#pragma omp for // { dg-error "forbids incrementing a pointer of type" }
|
||||
for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" }
|
||||
;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
f2 (void)
|
||||
{
|
||||
#pragma omp for
|
||||
for (const char *q = p; q < p + 4; q++)
|
||||
;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
f3 (void)
|
||||
{
|
||||
#pragma omp for // { dg-error "forbids incrementing a pointer of type" }
|
||||
for (T q = T (p); q < T (p + 4); q++)
|
||||
;
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
f1 <int> (); // { dg-message "instantiated from here" }
|
||||
f2 <int> ();
|
||||
f3 <const char *> ();
|
||||
f3 <void *> (); // { dg-message "instantiated from here" }
|
||||
}
|
|
@ -1,3 +1,8 @@
|
|||
2008-12-01 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/38348
|
||||
* testsuite/libgomp.c++/for-6.C: New test.
|
||||
|
||||
2008-11-26 Janis Johnson <janis187@us.ibm.com>
|
||||
|
||||
PR testsuite/28870
|
||||
|
|
109
libgomp/testsuite/libgomp.c++/for-6.C
Normal file
109
libgomp/testsuite/libgomp.c++/for-6.C
Normal file
|
@ -0,0 +1,109 @@
|
|||
// PR c++/38348
|
||||
// { dg-do run }
|
||||
|
||||
extern "C" void abort ();
|
||||
int cnt;
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
f0 (T, int)
|
||||
{
|
||||
abort ();
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
f0<int> (int, int type)
|
||||
{
|
||||
if (type != 0)
|
||||
abort ();
|
||||
#pragma omp atomic
|
||||
cnt++;
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
f0<const char *> (const char *, int type)
|
||||
{
|
||||
if (type != 1)
|
||||
abort ();
|
||||
#pragma omp atomic
|
||||
cnt++;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
f1 ()
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < 10; i++)
|
||||
f0 (i, 0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
f2 ()
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (T i = T (0); i < T (10); i += T (1))
|
||||
f0 (i, 0);
|
||||
}
|
||||
|
||||
void
|
||||
f3 ()
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < 10; i++)
|
||||
f0 (i, 0);
|
||||
}
|
||||
|
||||
const char *p = "abcdefghij";
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
f4 ()
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (const char *i = p; i < p + 10; i += 1)
|
||||
f0 (i, 1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
f5 ()
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (T i = T (p); i < T (p + 10); i += 1)
|
||||
f0 (i, 1);
|
||||
}
|
||||
|
||||
void
|
||||
f6 ()
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for (const char *i = p; i < p + 10; i++)
|
||||
f0 (i, 1);
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
f1<int> ();
|
||||
if (cnt != 10)
|
||||
abort ();
|
||||
f2<int> ();
|
||||
if (cnt != 20)
|
||||
abort ();
|
||||
f3 ();
|
||||
if (cnt != 30)
|
||||
abort ();
|
||||
f4<int> ();
|
||||
if (cnt != 40)
|
||||
abort ();
|
||||
f5<const char *> ();
|
||||
if (cnt != 50)
|
||||
abort ();
|
||||
f6 ();
|
||||
if (cnt != 60)
|
||||
abort ();
|
||||
}
|
Loading…
Add table
Reference in a new issue