public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "thakis at chromium dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/60875] New: `_Pragma("message \"foo\")"` doesn't work in expression contexts.
Date: Thu, 17 Apr 2014 19:56:00 -0000 [thread overview]
Message-ID: <bug-60875-4@http.gcc.gnu.org/bugzilla/> (raw)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60875
Bug ID: 60875
Summary: `_Pragma("message \"foo\")"` doesn't work in
expression contexts.
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: thakis at chromium dot org
Actual:
$ cat test.cc
int main() {
return _Pragma("message \"hello\"") 1234;
}
$ ~/gcc482prefix/bin/gcc -c test.cc -Wall
test.cc: In function ‘int main()’:
test.cc:2:1: error: ‘#pragma’ is not allowed here
return _Pragma("message \"my warning\"") 1234;
^
test.cc:2:44: error: expected ‘;’ before numeric constant
return _Pragma("message \"my warning\"") 1234;
^
test.cc:2:49: warning: statement has no effect [-Wunused-value]
return _Pragma("message \"my warning\"") 1234;
^
Expected (which is what clang does, and what MSVS does with `
__pragma(message...`):
Display the message instead.
(clang's output:
$ ../../../chrome/src/third_party/llvm-build/Release+Asserts/
bin/clang -c test.cc -Wall
test.cc:2:10: warning: my warning [-W#pragma-messages]
return _Pragma("message \"my warning\"") 1234;
^
<scratch space>:2:2: note: expanded from here
message "my warning"
^
1 warning generated.
)
A silly workaround is to use _Pragma("message_workaround...), then gcc will
warn like so:
test.cc:2:10: warning: unknown pragma ignored [-Wunknown-pragmas]
return _Pragma("message_workaround \"my warning\"") 1234;
^
It'd be nice if _Pragma(message...) could be used directly, instead of having
to rely on -Wunknown-pragmas for this functionality.
(The usecase we have for this in Chromium is that we want to make the compiler
print a diagnostic every time some symbols are used, so we define the symbols
as
#define MY_SYMBOL _Pragma("message \"foo\"") SYMBOL
This works fine in clang and MSVC, but for gcc we have to use a dummy pragma
and rely on -Wunknown-pragmas.)
>From gcc-bugs-return-449292-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 17 20:19:24 2014
Return-Path: <gcc-bugs-return-449292-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6362 invoked by alias); 17 Apr 2014 20:19:23 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 6327 invoked by uid 48); 17 Apr 2014 20:19:20 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/60875] `_Pragma("message \"foo\")"` doesn't work in expression contexts.
Date: Thu, 17 Apr 2014 20:19:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: preprocessor
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-60875-4-QilDNRUXbJ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60875-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60875-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-04/txt/msg01312.txt.bz2
Content-length: 409
http://gcc.gnu.org/bugzilla/show_bug.cgi?id`875
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Use deprecated attribute instead?
next reply other threads:[~2014-04-17 19:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-17 19:56 thakis at chromium dot org [this message]
2014-04-17 20:38 ` [Bug preprocessor/60875] " thakis at chromium dot org
2015-03-15 16:31 ` desrt at desrt dot ca
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-60875-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).