#define a! with -ansi -pedantic-errors should not receive an error, although it can receive a warning. C99 requires whitespace before the replacement text in a macro definition, but C90 (as amended by TC1) only requires it "if the first character of a replacement is not a character required by subclause 5.2.1", i.e. if it is not a character required to be in the basic source character set. C++ appears to follow the pre-TC1 wording with no requirement for whitespace at all (but in standard C++ with both conversion of extended characters to UCNs and UCNs in identifiers implemented, the case of extended characters starting a macro replacement can't arise: the UCN would lex as part of the macro name as the syntax makes them part of an identifier, and then give an error if that particular UCN is not permitted in identifiers; I'm not sure what the proper interim handling for C++ would be without those features implemented). This is a regression from 2.95.x, where cccp explicitly checked whether the character was one of those required by 5.2.1 to determine whether to issue a warning or a pedwarn, though not an important regression.
Confirmed.
Subject: [PATCH] Fix PR preprocessor/19475 Hi! This patch fixes PR preprocessor/19475 by issuing just warning, not pedwarn, for < ISO C99 if there is no whitespace between macro definition and replacement, but replacement starts with a basic character set character. Ok to commit? Unfortunately, the testcases provided fail in dejagnu (although the preprocessor behaviour is correct). Executing on host: /usr/src/gcc/obj/gcc/xgcc -B/usr/src/gcc/obj/gcc/ /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c -std=iso9899:1990 -pedantic-errors -E -o macspace1.i (timeout = 300) /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:5:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:6:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:7:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:8:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:9:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:10:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:11:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:12:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:13:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:14:10: warning: missing whitespace after the macro name /usr/src/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c:15:10: warning: missing whitespace after the macro name ... PASS: gcc.dg/cpp/macspace1.c (test for warnings, line 5) PASS: gcc.dg/cpp/macspace1.c (test for warnings, line 6) PASS: gcc.dg/cpp/macspace1.c (test for warnings, line 7) PASS: gcc.dg/cpp/macspace1.c (test for warnings, line 8) PASS: gcc.dg/cpp/macspace1.c (test for warnings, line 9) PASS: gcc.dg/cpp/macspace1.c (test for warnings, line 10) PASS: gcc.dg/cpp/macspace1.c (test for warnings, line 11) FAIL: gcc.dg/cpp/macspace1.c (test for warnings, line 12) FAIL: gcc.dg/cpp/macspace1.c (test for warnings, line 13) FAIL: gcc.dg/cpp/macspace1.c (test for warnings, line 14) FAIL: gcc.dg/cpp/macspace1.c (test for warnings, line 15) ... Is there some limitation on how many bytes or error messages dejagnu groks or something? When I split the tests into 6 warnings (resp. errors) chunks, it succeeds. I'm using dejagnu 1.4.4, expect 5.42.1 and tcl 8.4.7. 2005-04-05 Jakub Jelinek <jakub@redhat.com> PR preprocessor/19475 * libcpp/macro.c (create_iso_definition): For < ISO C99, don't pedwarn if there is no whitespace between macro name and its replacement, but the replacement starts with a basic character set character. * gcc.dg/cpp/macspace1.c: New test. * gcc.dg/cpp/macspace2.c: New test. --- gcc/libcpp/macro.c.jj 2005-03-17 13:39:12.000000000 +0100 +++ gcc/libcpp/macro.c 2005-04-05 11:39:57.000000000 +0200 @@ -1430,8 +1430,39 @@ create_iso_definition (cpp_reader *pfile macro->fun_like = 1; } else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE)) - cpp_error (pfile, CPP_DL_PEDWARN, - "ISO C requires whitespace after the macro name"); + { + /* While ISO C99 requires whitespace before replacement text + in a macro definition, ISO C90 with TC1 allows there characters + from the basic source character set. */ + if (CPP_OPTION (pfile, c99)) + cpp_error (pfile, CPP_DL_PEDWARN, + "ISO C99 requires whitespace after the macro name"); + else + { + int warntype = CPP_DL_WARNING; + switch (ctoken->type) + { + case CPP_ATSIGN: + case CPP_AT_NAME: + case CPP_OBJC_STRING: + /* '@' is not in basic character set. */ + warntype = CPP_DL_PEDWARN; + break; + case CPP_OTHER: + /* Basic character set sans letters, digits and _. */ + if (strchr ("!\"#%&'()*+,-./:;<=>?[\\]^{|}~", + ctoken->val.str.text[0]) == NULL) + warntype = CPP_DL_PEDWARN; + break; + default: + /* All other tokens start with a character from basic + character set. */ + break; + } + cpp_error (pfile, warntype, + "missing whitespace after the macro name"); + } + } if (macro->fun_like) token = lex_expansion_token (pfile, macro); --- gcc/gcc/testsuite/gcc.dg/cpp/macspace2.c.jj 2005-04-05 11:45:18.000000000 +0200 +++ gcc/gcc/testsuite/gcc.dg/cpp/macspace2.c 2005-04-05 11:46:41.000000000 +0200 @@ -0,0 +1,65 @@ +/* PR preprocessor/19475 */ +/* { dg-do preprocess } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +#define a! /* { dg-error "requires whitespace" } */ +#define b" /* { dg-error "requires whitespace" } */ +#define c# /* { dg-error "requires whitespace" } */ +#define d% /* { dg-error "requires whitespace" } */ +#define e& /* { dg-error "requires whitespace" } */ +#define f' /* { dg-error "requires whitespace" } */ +#define g) /* { dg-error "requires whitespace" } */ +#define h* /* { dg-error "requires whitespace" } */ +#define i+ /* { dg-error "requires whitespace" } */ +#define j, /* { dg-error "requires whitespace" } */ +#define k- /* { dg-error "requires whitespace" } */ +#define l. /* { dg-error "requires whitespace" } */ +#define m/ /* { dg-error "requires whitespace" } */ +#define n: /* { dg-error "requires whitespace" } */ +#define o; /* { dg-error "requires whitespace" } */ +#define p< /* { dg-error "requires whitespace" } */ +#define q= /* { dg-error "requires whitespace" } */ +#define r> /* { dg-error "requires whitespace" } */ +#define s? /* { dg-error "requires whitespace" } */ +#define t[ /* { dg-error "requires whitespace" } */ +#define u] /* { dg-error "requires whitespace" } */ +#define v^ /* { dg-error "requires whitespace" } */ +#define w{ /* { dg-error "requires whitespace" } */ +#define x| /* { dg-error "requires whitespace" } */ +#define y} /* { dg-error "requires whitespace" } */ +#define z~ /* { dg-error "requires whitespace" } */ +#define A>> /* { dg-error "requires whitespace" } */ +#define B<< /* { dg-error "requires whitespace" } */ +#define C<? /* { dg-error "requires whitespace" } */ +#define D>? /* { dg-error "requires whitespace" } */ +#define E&& /* { dg-error "requires whitespace" } */ +#define F|| /* { dg-error "requires whitespace" } */ +#define G== /* { dg-error "requires whitespace" } */ +#define H!= /* { dg-error "requires whitespace" } */ +#define I>= /* { dg-error "requires whitespace" } */ +#define J<= /* { dg-error "requires whitespace" } */ +#define K+= /* { dg-error "requires whitespace" } */ +#define L-= /* { dg-error "requires whitespace" } */ +#define M*= /* { dg-error "requires whitespace" } */ +#define N/= /* { dg-error "requires whitespace" } */ +#define O%= /* { dg-error "requires whitespace" } */ +#define P&= /* { dg-error "requires whitespace" } */ +#define Q|= /* { dg-error "requires whitespace" } */ +#define R^= /* { dg-error "requires whitespace" } */ +#define S>>= /* { dg-error "requires whitespace" } */ +#define T<<= /* { dg-error "requires whitespace" } */ +#define U<?= /* { dg-error "requires whitespace" } */ +#define V>?= /* { dg-error "requires whitespace" } */ +#define W... /* { dg-error "requires whitespace" } */ +#define X++ /* { dg-error "requires whitespace" } */ +#define Y-- /* { dg-error "requires whitespace" } */ +#define Z-> /* { dg-error "requires whitespace" } */ +#define aa:: /* { dg-error "requires whitespace" } */ +#define ab->* /* { dg-error "requires whitespace" } */ +#define ac.* /* { dg-error "requires whitespace" } */ +#define ad\x /* { dg-error "requires whitespace" } */ +#define ae\\x /* { dg-error "requires whitespace" } */ +#define af'1' /* { dg-error "requires whitespace" } */ +#define ag"abc" /* { dg-error "requires whitespace" } */ + +int dummy; --- gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c.jj 2005-04-05 11:45:18.000000000 +0200 +++ gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c 2005-04-05 11:54:16.000000000 +0200 @@ -0,0 +1,65 @@ +/* PR preprocessor/19475 */ +/* { dg-do preprocess } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +#define a! /* { dg-warning "missing whitespace" } */ +#define b" /* { dg-warning "missing whitespace" } */ +#define c# /* { dg-warning "missing whitespace" } */ +#define d% /* { dg-warning "missing whitespace" } */ +#define e& /* { dg-warning "missing whitespace" } */ +#define f' /* { dg-warning "missing whitespace" } */ +#define g) /* { dg-warning "missing whitespace" } */ +#define h* /* { dg-warning "missing whitespace" } */ +#define i+ /* { dg-warning "missing whitespace" } */ +#define j, /* { dg-warning "missing whitespace" } */ +#define k- /* { dg-warning "missing whitespace" } */ +#define l. /* { dg-warning "missing whitespace" } */ +#define m/ /* { dg-warning "missing whitespace" } */ +#define n: /* { dg-warning "missing whitespace" } */ +#define o; /* { dg-warning "missing whitespace" } */ +#define p< /* { dg-warning "missing whitespace" } */ +#define q= /* { dg-warning "missing whitespace" } */ +#define r> /* { dg-warning "missing whitespace" } */ +#define s? /* { dg-warning "missing whitespace" } */ +#define t[ /* { dg-warning "missing whitespace" } */ +#define u] /* { dg-warning "missing whitespace" } */ +#define v^ /* { dg-warning "missing whitespace" } */ +#define w{ /* { dg-warning "missing whitespace" } */ +#define x| /* { dg-warning "missing whitespace" } */ +#define y} /* { dg-warning "missing whitespace" } */ +#define z~ /* { dg-warning "missing whitespace" } */ +#define A>> /* { dg-warning "missing whitespace" } */ +#define B<< /* { dg-warning "missing whitespace" } */ +#define C<? /* { dg-warning "missing whitespace" } */ +#define D>? /* { dg-warning "missing whitespace" } */ +#define E&& /* { dg-warning "missing whitespace" } */ +#define F|| /* { dg-warning "missing whitespace" } */ +#define G== /* { dg-warning "missing whitespace" } */ +#define H!= /* { dg-warning "missing whitespace" } */ +#define I>= /* { dg-warning "missing whitespace" } */ +#define J<= /* { dg-warning "missing whitespace" } */ +#define K+= /* { dg-warning "missing whitespace" } */ +#define L-= /* { dg-warning "missing whitespace" } */ +#define M*= /* { dg-warning "missing whitespace" } */ +#define N/= /* { dg-warning "missing whitespace" } */ +#define O%= /* { dg-warning "missing whitespace" } */ +#define P&= /* { dg-warning "missing whitespace" } */ +#define Q|= /* { dg-warning "missing whitespace" } */ +#define R^= /* { dg-warning "missing whitespace" } */ +#define S>>= /* { dg-warning "missing whitespace" } */ +#define T<<= /* { dg-warning "missing whitespace" } */ +#define U<?= /* { dg-warning "missing whitespace" } */ +#define V>?= /* { dg-warning "missing whitespace" } */ +#define W... /* { dg-warning "missing whitespace" } */ +#define X++ /* { dg-warning "missing whitespace" } */ +#define Y-- /* { dg-warning "missing whitespace" } */ +#define Z-> /* { dg-warning "missing whitespace" } */ +#define aa:: /* { dg-warning "missing whitespace" } */ +#define ab->* /* { dg-warning "missing whitespace" } */ +#define ac.* /* { dg-warning "missing whitespace" } */ +#define ad\x /* { dg-warning "missing whitespace" } */ +#define ae\\x /* { dg-warning "missing whitespace" } */ +#define af'1' /* { dg-warning "missing whitespace" } */ +#define ag"abc" /* { dg-warning "missing whitespace" } */ + +int dummy; Jakub
Subject: Re: [PATCH] Fix PR preprocessor/19475 Jakub Jelinek wrote:- > Is there some limitation on how many bytes or error messages > dejagnu groks or something? I think it gets confused by the column numbers; if you add -fno-columns (or whatever it is) the problem would probably go away. Neil.
Subject: Re: [PATCH] Fix PR preprocessor/19475 On Tue, Apr 05, 2005 at 08:32:58PM +0900, Neil Booth wrote: > Jakub Jelinek wrote:- > > > Is there some limitation on how many bytes or error messages > > dejagnu groks or something? > > I think it gets confused by the column numbers; if you add > -fno-columns (or whatever it is) the problem would probably > go away. Thanks, you're right. With following incremental patch it passes just fine (and fails with cc1 built without the patch). diff -u gcc/testsuite/gcc.dg/cpp/macspace2.c gcc/testsuite/gcc.dg/cpp/macspace2.c --- gcc/testsuite/gcc.dg/cpp/macspace2.c 2005-04-05 11:46:41.000000000 +0200 +++ gcc/testsuite/gcc.dg/cpp/macspace2.c 2005-04-05 13:51:02.000000000 +0200 @@ -1,6 +1,6 @@ /* PR preprocessor/19475 */ /* { dg-do preprocess } */ -/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors -fno-show-column" } */ #define a! /* { dg-error "requires whitespace" } */ #define b" /* { dg-error "requires whitespace" } */ diff -u gcc/testsuite/gcc.dg/cpp/macspace1.c gcc/testsuite/gcc.dg/cpp/macspace1.c --- gcc/testsuite/gcc.dg/cpp/macspace1.c 2005-04-05 11:54:16.000000000 +0200 +++ gcc/testsuite/gcc.dg/cpp/macspace1.c 2005-04-05 13:50:54.000000000 +0200 @@ -1,6 +1,6 @@ /* PR preprocessor/19475 */ /* { dg-do preprocess } */ -/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors -fno-show-column" } */ #define a! /* { dg-warning "missing whitespace" } */ #define b" /* { dg-warning "missing whitespace" } */ Jakub
Subject: Re: [PATCH] Fix PR preprocessor/19475 Jakub Jelinek <jakub@redhat.com> writes: > Hi! > > This patch fixes PR preprocessor/19475 by issuing just warning, not pedwarn, > for < ISO C99 if there is no whitespace between macro definition and > replacement, but replacement starts with a basic character set character. > Ok to commit? OK except please remove the <?, >?, <?=, >?= testcases as those tokens are probably going to be removed in the near future. zw
Subject: Re: [PATCH] Fix PR preprocessor/19475 On Tue, Apr 05, 2005 at 09:49:19AM -0700, Zack Weinberg wrote: > > This patch fixes PR preprocessor/19475 by issuing just warning, not pedwarn, > > for < ISO C99 if there is no whitespace between macro definition and > > replacement, but replacement starts with a basic character set character. > > Ok to commit? > > OK except please remove the <?, >?, <?=, >?= testcases as those tokens > are probably going to be removed in the near future. I know, but that IMHO shouldn't matter for the testcase. #define a<? should be still treated like #define a <? in C90 (with a warning), no matter whether <? is a cpp token or 2 tokens. Jakub
Subject: Re: [PATCH] Fix PR preprocessor/19475 Jakub Jelinek <jakub@redhat.com> writes: > On Tue, Apr 05, 2005 at 09:49:19AM -0700, Zack Weinberg wrote: >> > This patch fixes PR preprocessor/19475 by issuing just warning, not pedwarn, >> > for < ISO C99 if there is no whitespace between macro definition and >> > replacement, but replacement starts with a basic character set character. >> > Ok to commit? >> >> OK except please remove the <?, >?, <?=, >?= testcases as those tokens >> are probably going to be removed in the near future. > > I know, but that IMHO shouldn't matter for the testcase. > #define a<? > should be still treated like > #define a <? > in C90 (with a warning), no matter whether <? is a cpp token or 2 tokens. Sure, but it's redundant with <= and so on. zw
Subject: Bug 19475 CVSROOT: /cvs/gcc Module name: gcc Changes by: jakub@gcc.gnu.org 2005-04-05 20:07:06 Modified files: gcc/testsuite : ChangeLog libcpp : ChangeLog macro.c Added files: gcc/testsuite/gcc.dg/cpp: macspace1.c macspace2.c Log message: PR preprocessor/19475 * macro.c (create_iso_definition): For < ISO C99, don't pedwarn if there is no whitespace between macro name and its replacement, but the replacement starts with a basic character set character. * gcc.dg/cpp/macspace1.c: New test. * gcc.dg/cpp/macspace2.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5287&r2=1.5288 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/ChangeLog.diff?cvsroot=gcc&r1=1.64&r2=1.65 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/macro.c.diff?cvsroot=gcc&r1=1.11&r2=1.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/macspace2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Re: [PATCH] Fix PR preprocessor/19475 Neil Booth wrote: > I think it gets confused by the column numbers; if you add > -fno-columns (or whatever it is) the problem would probably > go away. Or somebody could approve this patch: http://gcc.gnu.org/ml/gcc-patches/2005-04/msg00183.html
Subject: Re: [PATCH] Fix PR preprocessor/19475 On Tue, Apr 05, 2005 at 03:12:08PM -0700, Per Bothner wrote: > Neil Booth wrote: > > >I think it gets confused by the column numbers; if you add > >-fno-columns (or whatever it is) the problem would probably > >go away. > > Or somebody could approve this patch: > > http://gcc.gnu.org/ml/gcc-patches/2005-04/msg00183.html Looks good to me. Janis
Subject: Re: [PATCH] Fix PR preprocessor/19475 On Apr 5, 2005, at 4:56 AM, Jakub Jelinek wrote: > Thanks, you're right. With following incremental patch > it passes just fine (and fails with cc1 built without the patch). > > diff -u gcc/testsuite/gcc.dg/cpp/macspace2.c I prefer if the flag is added in the framework driver, not the testcase files....
Subject: Re: [PATCH] Fix PR preprocessor/19475 Per Bothner <per@bothner.com> writes: > http://gcc.gnu.org/ml/gcc-patches/2005-04/msg00183.html Yah, check that in already. zw
Subject: Bug 19475 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: jakub@gcc.gnu.org 2005-04-06 05:54:19 Modified files: gcc/testsuite : ChangeLog libcpp : ChangeLog macro.c Added files: gcc/testsuite/gcc.dg/cpp: macspace1.c macspace2.c Log message: PR preprocessor/19475 * macro.c (create_iso_definition): For < ISO C99, don't pedwarn if there is no whitespace between macro name and its replacement, but the replacement starts with a basic character set character. * gcc.dg/cpp/macspace1.c: New test. * gcc.dg/cpp/macspace2.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.107&r2=1.5084.2.108 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.56.2.3&r2=1.56.2.4 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libcpp/macro.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.9.6.1&r2=1.9.6.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/macspace1.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/cpp/macspace2.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Fixed in 4.0.0