aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2013-04-03 16:20:51 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2013-04-03 16:20:51 +0000
commitc42a832a952a7634e777751eb88c5e9cd518f624 (patch)
treec519bdaa935db516232aa912df01d0aa458527b8 /gcc
parent71c581e77d0da68c1364fa14ae06402bd8f44cc8 (diff)
downloadgcc-c42a832a952a7634e777751eb88c5e9cd518f624.zip
gcc-c42a832a952a7634e777751eb88c5e9cd518f624.tar.gz
gcc-c42a832a952a7634e777751eb88c5e9cd518f624.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/typeck.c13
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/g++.dg/gomp/for-19.C4
-rw-r--r--gcc/testsuite/g++.dg/warn/Wpointer-arith-1.C13
5 files changed, 34 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 93a2273..9020dad 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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>
PR debug/56819
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 043d52f..4a577e2 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5574,15 +5574,16 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
else
return error_mark_node;
}
- else if ((pedantic || warn_pointer_arith)
- && !TYPE_PTROB_P (argtype))
+ else if (!TYPE_PTROB_P (argtype))
{
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)
- ? G_("ISO C++ forbids incrementing a pointer of type %qT")
- : G_("ISO C++ forbids decrementing a pointer of type %qT"),
- argtype);
+ ? G_("ISO C++ forbids incrementing a pointer of type %qT")
+ : G_("ISO C++ forbids decrementing a pointer of type %qT"),
+ argtype);
else
return error_mark_node;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b5530fe..2cc5fa8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+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>
PR sanitizer/55702
diff --git a/gcc/testsuite/g++.dg/gomp/for-19.C b/gcc/testsuite/g++.dg/gomp/for-19.C
index 966ad96..7da74a7 100644
--- a/gcc/testsuite/g++.dg/gomp/for-19.C
+++ b/gcc/testsuite/g++.dg/gomp/for-19.C
@@ -9,7 +9,7 @@ void
f1 (void)
{
#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
f3 (void)
{
#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" }
;
}
diff --git a/gcc/testsuite/g++.dg/warn/Wpointer-arith-1.C b/gcc/testsuite/g++.dg/warn/Wpointer-arith-1.C
new file mode 100644
index 0000000..a4aa696
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wpointer-arith-1.C
@@ -0,0 +1,13 @@
+// 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" }
+}