[llvm-bugs] [Bug 51837] New: inconsistent handling of #pragma message

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 13 10:08:36 PDT 2021


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

            Bug ID: 51837
           Summary: inconsistent handling of #pragma message
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Wolfgang_Pieb at playstation.sony.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

// Given a simple source like
#pragma message("foobar")


we get a warning when compiled with no extra options, -Werror, or
-W#pragma-messages:

> clang -c test2.cpp
test2.cpp:1:9: warning: foobar [-W#pragma-messages]
#pragma message("foobar")
        ^
1 warning generated.

> clang -c -Werror test2.cpp
test2.cpp:1:9: warning: foobar [-W#pragma-messages]
#pragma message("foobar")
        ^
1 warning generated.

> clang -c -W#pragma-messages test2.cpp
test2.cpp:1:9: warning: foobar [-W#pragma-messages]
#pragma message("foobar")
        ^
1 warning generated.


However, when compiled with both -Werror and -W#pragma-messages we get an
error:
> clang -c  -Werror  -W#pragma-messages test2.cpp
test2.cpp:1:9: error: foobar [-Werror,-W#pragma-messages]
#pragma message("foobar")
        ^
1 error generated.

The reason seems to be that the "NoWarningAsError" flag (which is present in
the descriptor for the pragma messages warning) is dropped during warning
options processing (probably in DiagnosticsEngine::setSeverity()) or
thereabouts.

-- 
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/20210913/b0b89992/attachment.html>


More information about the llvm-bugs mailing list