Commit c42a832a by Paolo Carlini Committed by Paolo Carlini

re PR c++/56815 (void pointer arithmetic)

/cp
2013-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56815
	* typeck.c (cp_build_unary_op): Change -Wpointer-arith permerror to
	pedwarn.

/testsuite
2013-04-03  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56815
	* g++.dg/warn/Wpointer-arith-1.C: New.
	* g++.dg/gomp/for-19.C: Adjust.

From-SVN: r197433
parent 71c581e7
2013-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56815
* typeck.c (cp_build_unary_op): Change -Wpointer-arith permerror to
pedwarn.
2013-04-03 Jakub Jelinek <jakub@redhat.com> 2013-04-03 Jakub Jelinek <jakub@redhat.com>
PR debug/56819 PR debug/56819
......
...@@ -5574,15 +5574,16 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert, ...@@ -5574,15 +5574,16 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
else else
return error_mark_node; return error_mark_node;
} }
else if ((pedantic || warn_pointer_arith) else if (!TYPE_PTROB_P (argtype))
&& !TYPE_PTROB_P (argtype))
{ {
if (complain & tf_error) if (complain & tf_error)
permerror (input_location, (code == PREINCREMENT_EXPR pedwarn (input_location,
pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
(code == PREINCREMENT_EXPR
|| code == POSTINCREMENT_EXPR) || code == POSTINCREMENT_EXPR)
? G_("ISO C++ forbids incrementing a pointer of type %qT") ? G_("ISO C++ forbids incrementing a pointer of type %qT")
: G_("ISO C++ forbids decrementing a pointer of type %qT"), : G_("ISO C++ forbids decrementing a pointer of type %qT"),
argtype); argtype);
else else
return error_mark_node; return error_mark_node;
} }
......
2013-04-03 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56815
* g++.dg/warn/Wpointer-arith-1.C: New.
* g++.dg/gomp/for-19.C: Adjust.
2013-04-03 Marek Polacek <polacek@redhat.com> 2013-04-03 Marek Polacek <polacek@redhat.com>
PR sanitizer/55702 PR sanitizer/55702
......
...@@ -9,7 +9,7 @@ void ...@@ -9,7 +9,7 @@ void
f1 (void) f1 (void)
{ {
#pragma omp for #pragma omp for
for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" } for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-warning "forbids incrementing a pointer of type" }
; ;
} }
...@@ -27,7 +27,7 @@ void ...@@ -27,7 +27,7 @@ void
f3 (void) f3 (void)
{ {
#pragma omp for #pragma omp for
for (T q = T (p); q < T (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" } for (T q = T (p); q < T (p + 4); q++) // { dg-warning "forbids incrementing a pointer of type" }
; ;
} }
......
// PR c++/56815
// { dg-options "-Wpointer-arith" }
int main()
{
void *pv = 0;
pv++; // { dg-warning "forbids incrementing a pointer" }
typedef void (*pft) ();
pft pf = 0;
pf++; // { dg-warning "forbids incrementing a pointer" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment