public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v3] c-family: Enable -fpermissive for C and ObjC
@ 2023-11-07 19:10 Florian Weimer
  2023-11-07 21:26 ` Joseph Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2023-11-07 19:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: Joseph Myers

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.

(snip)

Joseph, would you be able to review this?

There are no new tests because there are no permerrors yet.

Thanks,
Florian
---
v3: One operator per line, and use OPTION_SET_P.

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

diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index 87da6c180cd..a7963646fbc 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -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
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 359f071e632..4984cd796f4 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -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
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 80bb1efac40..8527dbd1823 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -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

base-commit: 7e3c58bfc1d957e48faf0752758da0fed811ed58


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] c-family: Enable -fpermissive for C and ObjC
  2023-11-07 19:10 [PATCH v3] c-family: Enable -fpermissive for C and ObjC Florian Weimer
@ 2023-11-07 21:26 ` Joseph Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2023-11-07 21:26 UTC (permalink / raw)
  To: Florian Weimer; +Cc: gcc-patches

On Tue, 7 Nov 2023, Florian Weimer wrote:

> 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.
> 
> (snip)
> 
> Joseph, would you be able to review this?
> 
> There are no new tests because there are no permerrors yet.

OK.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-07 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-07 19:10 [PATCH v3] c-family: Enable -fpermissive for C and ObjC Florian Weimer
2023-11-07 21:26 ` Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).