diff mbox series

c-family: Enable -fpermissive for C and ObjC

Message ID 87il73rohj.fsf@oldenburg.str.redhat.com
State New
Headers show
Series c-family: Enable -fpermissive for C and ObjC | expand

Commit Message

Florian Weimer Oct. 19, 2023, 8:43 a.m. UTC
Future changes will treat some C front end warnings similar to
-Wnarrowing.

There are no new tests because there are no such C warnings yet.  The
existing test suite covers the -std=gnu89 -pedantic-errors corner cases
(which should not turn on -fpermissive).

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 (set_std_c89): Enable -fpermissive.

---
 gcc/c-family/c-opts.cc | 6 ++++++
 gcc/c-family/c.opt     | 2 +-
 gcc/doc/invoke.texi    | 8 ++++++--
 3 files changed, 13 insertions(+), 3 deletions(-)


base-commit: 8f4bbdc28df6e87a7ad5ec5ca191a7a836a4f016
diff mbox series

Patch

diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index ce2e021e69d..9a4beb4b024 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1711,6 +1711,12 @@  set_std_c89 (int c94, int iso)
   flag_isoc99 = 0;
   flag_isoc11 = 0;
   flag_isoc2x = 0;
+  /* -std=gnu89 etc. should not override -pedantic-errors.  */
+  if (!global_dc->pedantic_errors)
+    {
+      flag_permissive = 1;
+      global_dc->permissive = 1;
+    }
   lang_hooks.name = "GNU C89";
 }
 
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 44b9c862c14..e6ea5e52d24 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -2108,7 +2108,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
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 9b5ff457027..cfebab78f83 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -6166,13 +6166,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