<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - #pragma GCC warning … with -Werror not treated as error"
   href="https://bugs.llvm.org/show_bug.cgi?id=36758">36758</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>#pragma GCC warning … with -Werror not treated as error
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>clang@evan.coeusgroup.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang seems to support `#pragma GCC warning …` (see
<<a href="https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html#Pragmas">https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html#Pragmas</a>>), but the messages
are *always* treated as warnings, even when -Werror is provided.

AFAICT `#pragma GCC warning …` is treated as an alias for `#pragma message …`
(the warning which is emitted says it's -W#pragma-messages). It should be
treated more like #warning.

Test case is simple:

  $ cat warn.c
  #pragma GCC warning "Hello"
  $ clang -Werror -c -o warn.o warn.c && echo "I shouldn't be printed"
  warn.c:1:13: warning: Hello [-W#pragma-messages]
  #pragma GCC warning "Hello"
              ^
  1 warning generated.
  I shouldn't be printed

GCC works as expected:

  $ gcc -Werror -c -o warn.o warn.c && echo "I shouldn't be printed"
  warn.c:1:21: error: Hello [-Werror]
   #pragma GCC warning "Hello"
                       ^~~~~~~
  cc1: all warnings being treated as errors

As does ICC:

  icc -Werror -c -o warn.o warn.c && echo "I shouldn't be printed"
  warn.c(1): error #1028: unknown warning specifier
    #pragma GCC warning "Hello"
            ^

  compilation aborted for warn.c (code 2)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>