Bug 53075 - -Werror=pedantic should be equivalent to -pedantic-errors
Summary: -Werror=pedantic should be equivalent to -pedantic-errors
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on: 80529
Blocks:
  Show dependency treegraph
 
Reported: 2012-04-22 19:55 UTC by Manuel López-Ibáñez
Modified: 2020-11-30 00:01 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-07-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel López-Ibáñez 2012-04-22 19:55:04 UTC
Some background discussion in PR 44774 and http://gcc.gnu.org/ml/gcc-patches/2012-04/msg01324.html

A currently visible effect is that

$ cc1  ~/trunk/src/gcc/testsuite/gcc.dg/c90-init-1.c -pedantic-errors

prints -Wpedantic while

$ cc1  ~/trunk/src/gcc/testsuite/gcc.dg/c90-init-1.c -Werror=pedantic

prints -Werror=pedantic (as it should).
Comment 1 Manuel López-Ibáñez 2015-01-19 00:40:08 UTC
More discussion in the topic: https://gcc.gnu.org/ml/gcc-patches/2014-10/msg01799.html
Comment 2 Eric Gallager 2017-07-27 16:50:51 UTC
Confirmed.
Comment 3 Eric Gallager 2019-09-02 04:18:55 UTC
(In reply to Manuel López-Ibáñez from comment #0)
> Some background discussion in PR 44774 and
> http://gcc.gnu.org/ml/gcc-patches/2012-04/msg01324.html

bug 53072 came up under that discussion; adding it under "See Also" here

> 
> A currently visible effect is that
> 
> $ cc1  ~/trunk/src/gcc/testsuite/gcc.dg/c90-init-1.c -pedantic-errors
> 
> prints -Wpedantic while
> 
> $ cc1  ~/trunk/src/gcc/testsuite/gcc.dg/c90-init-1.c -Werror=pedantic
> 
> prints -Werror=pedantic (as it should).
Comment 4 Kamlesh Kumar 2019-09-02 14:41:41 UTC
This patch resolves this.

diff --git a/gcc/opts.c b/gcc/opts.c
index 1417dba..2e71fef 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -3212,7 +3212,7 @@ option_name (diagnostic_context *context, int option_index,
   if (option_index)
     {
       /* A warning classified as an error.  */
-      if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN)
+      if ((context->pedantic_errors || orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN)
          && diag_kind == DK_ERROR)
        return concat (cl_options[OPT_Werror_].opt_text,
                       /* Skip over "-W".  */
Comment 5 Manuel López-Ibáñez 2019-09-02 17:51:10 UTC
(In reply to Kamlesh Kumar from comment #4)
> This patch resolves this.

No, it doesn't.

As the documentation says: -pedantic-errors is not equivalent to
@option{-Werror=pedantic}, since there are errors enabled by this option
and not enabled by the latter and vice versa.

According to the discussion in the email threads above, it is not possible to make them equivalent, one would need to create a new options for everything that is in the disjoint set of -pedantic-errors and -Werror=pedantic (but there may be some bugs worth fixing there to reduce this set).

In any case, patches are sent to gcc-patches: https://gcc.gnu.org/wiki/GettingStarted#Basics:_Contributing_to_GCC_in_10_easy_steps