diff mbox

[C++] PR 56815

Message ID 515C5054.1050506@oracle.com
State New
Headers show

Commit Message

Paolo Carlini April 3, 2013, 3:52 p.m. UTC
Hi,

thus, as discussed in the audit trail, I'm simply changing the permerror 
in the C++ front-end to pedwarn.

Tested x86_64-linux.

Thanks,
Paolo.

PS: there is a couple of issues noticed while working on this - 
essentially, tweaks to c.opt and c-common.c - which I prefer to handle 
separately.

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

Comments

Jason Merrill April 3, 2013, 4:15 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 197414)
+++ cp/typeck.c	(working copy)
@@ -5574,15 +5574,16 @@  cp_build_unary_op (enum tree_code code, tree xarg,
                 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;
               }
Index: testsuite/g++.dg/gomp/for-19.C
===================================================================
--- testsuite/g++.dg/gomp/for-19.C	(revision 197414)
+++ testsuite/g++.dg/gomp/for-19.C	(working copy)
@@ -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" }
     ;
 }
 
Index: testsuite/g++.dg/warn/Wpointer-arith-1.C
===================================================================
--- testsuite/g++.dg/warn/Wpointer-arith-1.C	(revision 0)
+++ testsuite/g++.dg/warn/Wpointer-arith-1.C	(working copy)
@@ -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" }
+}