http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54161

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-08-02
     Ever Confirmed|0                           |1

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-02 
21:11:37 UTC ---
Ok, thanks. Thus this specific issue seems quite minor, because even without
-pedantic we warn anyway *by default* because warn_pointer_arith is enabled by
default (ie, -Wall -pedantic are not needed).

(-pedantic-errors can always be used to have hard errors, of course)

In summary, I understand we want something like this (untested):

Index: c-common.c
===================================================================
--- c-common.c    (revision 190092)
+++ c-common.c    (working copy)
@@ -4578,10 +4578,17 @@ 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,
-             "invalid application of %<sizeof%> to a function type");
-          else if (!complain)
+      if (complain)
+        {
+          if (c_dialect_cxx ())
+        pedwarn (loc, 0, "invalid application of %<sizeof%> to "
+             "a function type");
+          else if (pedantic || warn_pointer_arith)
+        pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+             "invalid application of %<sizeof%> to "
+             "a function type");
+        }
+          else
             return error_mark_node;
       value = size_one_node;
     }
@@ -4601,12 +4608,17 @@ 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,
-         "invalid application of %qs to a void type", op_name);
+      if (complain && type_code == VOID_TYPE)
+    {
+      if (c_dialect_cxx ())
+        pedwarn (loc, 0,
+             "invalid application of %qs to a void type", op_name);
+      else if (pedantic || warn_pointer_arith)
+        pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpointer_arith,
+             "invalid application of %qs to a void type", op_name);
+    }
       else if (!complain)
-        return error_mark_node;
+    return error_mark_node;
       value = size_one_node;
     }
   else if (!COMPLETE_TYPE_P (type)

Reply via email to