public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Matthias Klose <doko@smile.cs.tu-berlin.de>
To: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org
Cc: Zack Weinberg <zack@codesourcery.com>,
	Neil Booth <neil@daikokuya.co.uk>,
	Andrew Suffield <asuffield@debian.org>
Subject: preprocessor/8524: _Pragma within macros is improperly expanded
Date: Sun, 10 Nov 2002 22:36:00 -0000	[thread overview]
Message-ID: <E18B85X-0003yv-00@smile.cs.tu-berlin.de> (raw)


>Number:         8524
>Category:       preprocessor
>Synopsis:       _Pragma within macros is improperly expanded
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 10 22:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Matthias Klose
>Release:        3.2.1 2002-11-03
>Organization:
>Environment:
System: Linux smile 2.4.18-xfs #1 Tue Mar 12 22:42:02 CET 2002 i686 unknown
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
>Description:
The original report from the Debian BTS, fix applied to head and branch:

aps100@cyclone:~$ cat foo.c
_Pragma("foo"); int y;
#define FOO _Pragma("foo"); int x;
FOO
aps100@cyclone:~$ cpp-3.2 foo.c
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"

# 1 "foo.c"
#pragma foo 
# 1 "foo.c"
             ; int y;


# 3 "foo.c"
#pragma ; int x;foo 

The first line is expanded correctly; the third is not (rendering
_Pragma almost completely useless).


Fixed by Neil:
	* cpphash.h (FIRST, LAST, CUR, RLIMIT): Fix definitions.
	* cpplib.c (destringize_and_run): Kludge around getting
	tokens from in-progress macros.
	(_cpp_do__Pragma): Simplify. testsuite:
	* gcc.dg/cpp/_Pragma4.c: New test.

Bug submitter claims:

Nope, still not right. Here's a new case where it breaks:

aps100@cyclone:~/tmp$ cat foo.c
#define ALPHA(A) alpha_ ## A
#define BETA(B) beta_ ## B
#define GAMMA(C) _Pragma("moose") ALPHA(C) BETA(C)
GAMMA(baz);
aps100@cyclone:~/tmp$ cpp-3.2 foo.c
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"




# 4 "foo.c"
#pragma moose=20
# 4 "foo.c"
alpha_baz beta_alpha_baz;
aps100@cyclone:~/tmp$ cpp-2.95 foo.c
# 1 "foo.c"



_Pragma("moose") alpha_baz    beta_baz    ;
=3D=3D

Note how beta_baz has become beta_alpha_baz in 3.2. This only happens
when the _Pragma is present, so I presume it's the same bug in another
form.

But wait! It gets better:

aps100@cyclone:~/tmp$ cat foo.c
#define ALPHA
#define BETA(B) beta_ ## B
#define GAMMA(C) _Pragma("moose") ALPHA BETA(C)
GAMMA(baz);
aps100@cyclone:~/tmp$ cpp-3.2 foo.c
# 1 "foo.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "foo.c"




# 4 "foo.c"
#pragma moose=20
# 4 "foo.c"
cpp-3.2: Internal error: Aborted (program cpp0)
Please submit a full bug report.

>How-To-Repeat:
	
>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2002-11-11  6:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-10 22:36 Matthias Klose [this message]
2002-11-10 22:44 neil
2002-11-22 13:26 neil
2002-11-23 21:36 Neil Booth
2002-11-24  3:25 Neil Booth
2002-11-24  3:35 neil

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=E18B85X-0003yv-00@smile.cs.tu-berlin.de \
    --to=doko@smile.cs.tu-berlin.de \
    --cc=157416@bugs.debian.org \
    --cc=asuffield@debian.org \
    --cc=debian-gcc@lists.debian.org \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=neil@daikokuya.co.uk \
    --cc=zack@codesourcery.com \
    /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).