LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 38231 - -w does not suppress warnings promoted to errors with -Werror=…
Summary: -w does not suppress warnings promoted to errors with -Werror=…
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: -New Bugs (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-19 12:29 PDT by Benjamin Barenblat
Modified: 2019-01-29 11:35 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Barenblat 2018-07-19 12:29:49 PDT
When run with -w, GCC disables all warnings, including those which have been explicitly promoted to errors with -Werror=warningname. Clang’s -w disables all warnings *except* those which have been so promoted. For example:

    $ cat <<EOF >c.c
    > void f() {
    >   int x;
    >   if (x = 1) {}
    > }
    > EOF
    $ gcc -Werror=parentheses -w -c -o /dev/null c.c
    $ clang -Werror=parentheses -w -c -o /dev/null c.c
    c.c:3:9: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses]
      if (x = 1) {}
          ~~^~~
    c.c:3:9: note: place parentheses around the assignment to silence this warning
      if (x = 1) {}
            ^
          (    )
    c.c:3:9: note: use '==' to turn this assignment into an equality comparison
      if (x = 1) {}
            ^
            ==
    1 error generated.

This is already a FIXME in DiagnosticIDs.cpp (https://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?revision=331834&view=markup#l460).