From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19860 invoked by alias); 17 Apr 2014 19:56:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 19834 invoked by uid 48); 17 Apr 2014 19:56:17 -0000 From: "thakis at chromium dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: thakis at chromium dot 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-04/txt/msg01311.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D60875 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 =E2=80=98int main()=E2=80=99: test.cc:2:1: error: =E2=80=98#pragma=E2=80=99 is not allowed here return _Pragma("message \"my warning\"") 1234; ^ test.cc:2:44: error: expected =E2=80=98;=E2=80=99 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; ^ :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 havi= ng to rely on -Wunknown-pragmas for this functionality. (The usecase we have for this in Chromium is that we want to make the compi= ler print a diagnostic every time some symbols are used, so we define the symbo= ls 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: 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: List-Archive: List-Post: List-Help: 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" 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: In-Reply-To: References: 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=60875 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek --- Use deprecated attribute instead?