c.opt ([Wpointer-arith]): Enabled by -Wpedantic, as documented.
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 24 Apr 2013 16:35:17 +0000 (16:35 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 24 Apr 2013 16:35:17 +0000 (16:35 +0000)
/c-family
2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
            Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

* c.opt ([Wpointer-arith]): Enabled by -Wpedantic, as documented.
* c-common.c (pointer_int_sum): Change -Wpointer-arith pedwarns
to simply use OPT_Wpointer_arith.
(c_sizeof_or_alignof_type): Likewise.

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

* typeck.c (cxx_sizeof_or_alignof_type): Change -Wpointer-arith
pedwarn to simply use OPT_Wpointer_arith.
(cp_build_unary_op): Likewise.

/c
2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>

* c-typeck.c (pointer_diff): Change -Wpointer-arith pedwarns
to simply use OPT_Wpointer_arith.
(build_unary_op): Likewise.

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

* c-c++-common/Wpointer-arith-1.c: New.

Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org>
From-SVN: r198256

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c.opt
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wpointer-arith-1.c [new file with mode: 0644]

index a768499..275b20d 100644 (file)
@@ -1,4 +1,12 @@
 2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
+            Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       * c.opt ([Wpointer-arith]): Enabled by -Wpedantic, as documented.
+       * c-common.c (pointer_int_sum): Change -Wpointer-arith pedwarns
+       to simply use OPT_Wpointer_arith.
+       (c_sizeof_or_alignof_type): Likewise.
+
+2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * c-cppbuiltin.c (c_cpp_builtins): Define __GXX_EXPERIMENTAL_CXX1Y__.
 
index dd94ff1..b29f5fa 100644 (file)
@@ -4280,13 +4280,13 @@ pointer_int_sum (location_t loc, enum tree_code resultcode,
 
   if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
     {
-      pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+      pedwarn (loc, OPT_Wpointer_arith,
               "pointer of type %<void *%> used in arithmetic");
       size_exp = integer_one_node;
     }
   else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE)
     {
-      pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+      pedwarn (loc, OPT_Wpointer_arith,
               "pointer to a function used in arithmetic");
       size_exp = integer_one_node;
     }
@@ -4864,8 +4864,8 @@ c_sizeof_or_alignof_type (location_t loc,
     {
       if (is_sizeof)
        {
-         if (complain && (pedantic || warn_pointer_arith))
-           pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+         if (complain && warn_pointer_arith)
+           pedwarn (loc, OPT_Wpointer_arith,
                     "invalid application of %<sizeof%> to a function type");
           else if (!complain)
             return error_mark_node;
@@ -4888,8 +4888,8 @@ c_sizeof_or_alignof_type (location_t loc,
   else if (type_code == VOID_TYPE || type_code == ERROR_MARK)
     {
       if (type_code == VOID_TYPE
-         && complain && (pedantic || warn_pointer_arith))
-       pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+         && complain && warn_pointer_arith)
+       pedwarn (loc, OPT_Wpointer_arith,
                 "invalid application of %qs to a void type", op_name);
       else if (!complain)
         return error_mark_node;
index 10ae84d..124c139 100644 (file)
@@ -614,7 +614,7 @@ C++ ObjC++ Var(warn_pmf2ptr) Init(1) Warning
 Warn when converting the type of pointers to member functions
 
 Wpointer-arith
-C ObjC C++ ObjC++ Var(warn_pointer_arith) Warning
+C ObjC C++ ObjC++ Var(warn_pointer_arith) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
 Warn about function pointer arithmetic
 
 Wpointer-sign
index 771a557..cdcd416 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * c-typeck.c (pointer_diff): Change -Wpointer-arith pedwarns
+       to simply use OPT_Wpointer_arith.
+       (build_unary_op): Likewise.
+
 2013-04-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/19449
index ddb6d39..5a29f7c 100644 (file)
@@ -3333,10 +3333,10 @@ pointer_diff (location_t loc, tree op0, tree op1)
 
 
   if (TREE_CODE (target_type) == VOID_TYPE)
-    pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+    pedwarn (loc, OPT_Wpointer_arith,
             "pointer of type %<void *%> used in subtraction");
   if (TREE_CODE (target_type) == FUNCTION_TYPE)
-    pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+    pedwarn (loc, OPT_Wpointer_arith,
             "pointer to a function used in subtraction");
 
   /* If the conversion to ptrdiff_type does anything like widening or
@@ -3663,10 +3663,10 @@ build_unary_op (location_t location,
                     || TREE_CODE (TREE_TYPE (argtype)) == VOID_TYPE)
              {
                if (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
-                 pedwarn (location, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+                 pedwarn (location, OPT_Wpointer_arith,
                           "wrong type argument to increment");
                else
-                 pedwarn (location, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+                 pedwarn (location, OPT_Wpointer_arith,
                           "wrong type argument to decrement");
              }
 
index 1c05d5d..761ca34 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * typeck.c (cxx_sizeof_or_alignof_type): Change -Wpointer-arith
+       pedwarn to simply use OPT_Wpointer_arith.
+       (cp_build_unary_op): Likewise.
+
 2013-04-24  Jason Merrill  <jason@redhat.com>
 
        N3648: init-captures are named.
index b45b685..84da5de 100644 (file)
@@ -1522,7 +1522,7 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain)
   if (TREE_CODE (type) == METHOD_TYPE)
     {
       if (complain)
-       pedwarn (input_location, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith, 
+       pedwarn (input_location, OPT_Wpointer_arith, 
                 "invalid application of %qs to a member function", 
                 operator_name_info[(int) op].name);
       value = size_one_node;
@@ -5601,8 +5601,7 @@ cp_build_unary_op (enum tree_code code, tree xarg, int noconvert,
            else if (!TYPE_PTROB_P (argtype)) 
               {
                 if (complain & tf_error)
-                  pedwarn (input_location,
-                          pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+                  pedwarn (input_location, OPT_Wpointer_arith,
                           (code == PREINCREMENT_EXPR
                               || code == POSTINCREMENT_EXPR)
                           ? G_("ISO C++ forbids incrementing a pointer of type %qT")
index 59f5b1a..c3cd691 100644 (file)
@@ -1,5 +1,9 @@
 2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
 
+       * c-c++-common/Wpointer-arith-1.c: New.
+
+2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
+
        * g++.dg/cpp1y/cxx1y_macro.C: New.
 
 2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
diff --git a/gcc/testsuite/c-c++-common/Wpointer-arith-1.c b/gcc/testsuite/c-c++-common/Wpointer-arith-1.c
new file mode 100644 (file)
index 0000000..86668ef
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-Wpedantic -Wno-pointer-arith" } */
+
+void h(void)
+{
+  typedef void (*pft) ();
+  typedef void (ft) ();
+
+  void *pv = 0;
+  pft pf = 0;
+
+  pv++;
+  pf++;
+
+  --pv;
+  --pf;
+
+  pv += 1;
+  pf += 1;
+
+  pv = pv - 1;
+  pf = pf - 1;
+
+  sizeof (void);
+  sizeof (ft);
+}