In the context of the recent discussion, it occurred to me that this semantic
would be useful, but currently there is no easy way to access it. Bikeshedding
welcome; the use of this flag is a bit odd, but it has the advantage of being
accepted without error going back at least to 4.3.
-- 8< --
Currently there is no flag to use to upgrade all currently-enabled pedwarns
from warning to error. -pedantic-errors also enables the -Wpedantic
pedwarns, while -Werror=pedantic uselessly makes only the -Wpedantic
pedwarns errors.
I suggest that since -fpermissive lowers some diagnostics from error to
warning, -fno-permissive could do the reverse.
gcc/ChangeLog:
* doc/invoke.texi: Document -fno-permissive.
gcc/c-family/ChangeLog:
* c.opt (fpermissive): Accept in C and ObjC as well.
* c-opts.cc (c_common_post_options): -fno-permissive sets
global_dc->pedantic_errors.
---
gcc/doc/invoke.texi | 7 +++++++
gcc/c-family/c.opt | 2 +-
gcc/c-family/c-opts.cc | 4 ++++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b92b8576027..6198df14382 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -3438,11 +3438,18 @@ issue. Currently, the only such diagnostic issued by
G++ is the one for
a name having multiple meanings within a class.
@opindex fpermissive
+@opindex fno-permissive
@item -fpermissive
Downgrade some diagnostics about nonconformant code from errors to
warnings. Thus, using @option{-fpermissive} allows some
nonconforming code to compile.
+Conversely, @option{-fno-permissive} can be used to upgrade some
+diagnostics about nonconformant code from warnings to errors. This
+differs from @option{-pedantic-errors} in that the latter also implies
+@option{-Wpedantic}; this option does not enable additional
+diagnostics, only upgrades the severity of those that are enabled.
+
@opindex fno-pretty-templates
@opindex fpretty-templates
@item -fno-pretty-templates
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 3333cddeece..07165d2bbe8 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -2075,7 +2075,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/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index c68a2a27469..1973c068d59 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1021,6 +1021,10 @@ c_common_post_options (const char **pfilename)
SET_OPTION_IF_UNSET (&global_options, &global_options_set,
flag_delete_dead_exceptions, true);
+ if (!global_options_set.x_flag_pedantic_errors
+ && global_options_set.x_flag_permissive)
+ global_dc->pedantic_errors = !flag_permissive;
+
if (cxx_dialect >= cxx11)
{
/* If we're allowing C++0x constructs, don't warn about C++98
base-commit: 62c4d34ec005e95f000ffabd34da440dc62ac346
--
2.31.1