From: Florian Weimer <fweimer@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH] c-family: Enable -fpermissive for C and ObjC
Date: Mon, 06 Nov 2023 18:37:11 +0100 [thread overview]
Message-ID: <87msvqeqbc.fsf@oldenburg.str.redhat.com> (raw)
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.
---
v3: Handle -fpermissive in c_common_post_options, to get useful behavior
for various -std=gnu99 -fpermissive -std=gnu89 permutations.
gcc/c-family/c-opts.cc | 12 ++++++++++++
gcc/c-family/c.opt | 2 +-
gcc/doc/invoke.texi | 8 ++++++--
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index a980912f7e1..23ea79ec802 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -854,6 +854,18 @@ 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
+ && !global_options_set.x_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 29d3d789a49..cc3a6610148 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -2112,7 +2112,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 6e776a0faa1..dfa01220b93 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -6170,13 +6170,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: 3cc9ad41db87fb85b13a56bff1f930c258542a70
next reply other threads:[~2023-11-06 17:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 17:37 Florian Weimer [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-10-19 8:43 Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87msvqeqbc.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).