]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-family: Enable -fpermissive for C and ObjC
authorFlorian Weimer <fweimer@redhat.com>
Wed, 8 Nov 2023 05:41:15 +0000 (06:41 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 8 Nov 2023 07:01:24 +0000 (08:01 +0100)
Future changes will treat some C front end warnings similar to
-Wnarrowing.

gcc/

* doc/invoke.texi (Warning Options): Mention C diagnostics
for -fpermissive.

gcc/c-family/

* c.opt (fpermissive): Enable for C and ObjC.
* c-opts.cc (c_common_post_options): Enable -fpermissive.

gcc/c-family/c-opts.cc
gcc/c-family/c.opt
gcc/doc/invoke.texi

index d30d413c8d03c922a357fabb0f9cb37b49f1d008..fbabd1816c18cf678018e46fec139809883504c4 100644 (file)
@@ -854,6 +854,20 @@ c_common_post_options (const char **pfilename)
       && flag_unsafe_math_optimizations == 0)
     flag_fp_contract_mode = FP_CONTRACT_OFF;
 
+  /* C language modes before C99 enable -fpermissive by default, but
+     only if -pedantic-errors is not specified.  Also treat
+     -fno-permissive as a subset of -pedantic-errors that does not
+     reject certain GNU extensions also present the defaults for later
+     language modes.  */
+  if (!c_dialect_cxx ()
+      && !flag_isoc99
+      && !global_dc->m_pedantic_errors
+      && !OPTION_SET_P (flag_permissive))
+    {
+      flag_permissive = 1;
+      global_dc->m_permissive = 1;
+    }
+
   /* If we are compiling C, and we are outside of a standards mode,
      we can permit the new values from ISO/IEC TS 18661-3 for
      FLT_EVAL_METHOD.  Otherwise, we must restrict the possible values to
index 26f629fb6226d81a040dcb293af9e4b69e6d6c16..d81177f38001cb886b15b64a4f6e675b2e4ecd51 100644 (file)
@@ -2116,7 +2116,7 @@ C ObjC C++ ObjC++
 Look for and use PCH files even when preprocessing.
 
 fpermissive
-C++ ObjC++ Var(flag_permissive)
+C ObjC C++ ObjC++ Var(flag_permissive)
 Downgrade conformance errors to warnings.
 
 fplan9-extensions
index 2caa7ceec40dd4fefa51095f06ea7bfa472a6b0c..d0b55fb106f908e8222394bbd07670aa583c5680 100644 (file)
@@ -6174,13 +6174,17 @@ errors by @option{-pedantic-errors}.  For instance:
 Downgrade some required diagnostics about nonconformant code from
 errors to warnings.  Thus, using @option{-fpermissive} allows some
 nonconforming code to compile.  Some C++ diagnostics are controlled
-only by this flag, but it also downgrades some diagnostics that have
-their own flag:
+only by this flag, but it also downgrades some C and C++ diagnostics
+that have their own flag:
 
 @gccoptlist{
 -Wnarrowing @r{(C++)}
 }
 
+The @option{-fpermissive} option is the default for historic C language
+modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90},
+@option{-std=gnu90}).
+
 @opindex Wall
 @opindex Wno-all
 @item -Wall