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: unassignedclangb...@nondot.org
          Reporter: cl...@evan.coeusgroup.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to