[llvm-bugs] [Bug 36758] New: #pragma GCC warning … with -Werror not treated as error

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 15 12:17:09 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=36758

            Bug ID: 36758
           Summary: #pragma GCC warning … with -Werror not treated as
                    error
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: clang at evan.coeusgroup.com
                CC: llvm-bugs at lists.llvm.org

Clang seems to support `#pragma GCC warning …` (see
<https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html#Pragmas>), 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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180315/4e478589/attachment.html>


More information about the llvm-bugs mailing list