public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: preprocessor/4976: cpp fails to warn about macro redefinitions
@ 2001-11-23 0:46 neil
0 siblings, 0 replies; 4+ messages in thread
From: neil @ 2001-11-23 0:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/4976; it has been noted by GNATS.
From: neil@gcc.gnu.org
To: fredette@mit.edu, gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org,
gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:
Subject: Re: preprocessor/4976: cpp fails to warn about macro redefinitions
Date: 30 Nov 2001 23:03:09 -0000
Synopsis: cpp fails to warn about macro redefinitions
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Fri Nov 30 15:03:08 2001
State-Changed-Why:
Please don't mark PRs as high priority; that is supposed to
be reserved for GCC maintainers.
GCC has been fixed to emit the warning in 3.0.3 and 3.1.
3.0.2 only warns if -pedantic.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4976&database=gcc
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: preprocessor/4976: cpp fails to warn about macro redefinitions
@ 2001-11-23 0:45 Neil Booth
0 siblings, 0 replies; 4+ messages in thread
From: Neil Booth @ 2001-11-23 0:45 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR preprocessor/4976; it has been noted by GNATS.
From: Neil Booth <neil@daikokuya.demon.co.uk>
To: fredette@mit.edu
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: preprocessor/4976: cpp fails to warn about macro redefinitions
Date: Fri, 30 Nov 2001 23:02:13 +0000
fredette@mit.edu wrote:-
> cpp fails to warn about macro redefinitions.
It was changed to only warn if -pedantic, for a reason lost in the
mists of time.
> gcc/gcc/cppmacro.c revision 1.46 introduced the NODE_WARN flag, with
> this code at the end of the _cpp_create_definition function:
>
> if (! ustrncmp (node->name, DSC ("__STDC_")))
> node->flags |= NODE_WARN;
>
> It is this NODE_WARN flag that is supposed to trigger (through the
> warn_of_redefinition function) a warning when a macro is redefined.
>
> The test seems wrong - as ustrncmp behaves like strncmp, this test
> will fail for all macros other than __STDC__. I.e., only a
> redefined __STDC__ macro node will happen to get this flag.
No, it will warn for any macro beginning with __STDC_ since that
namespace is reserved.
> Further, gcc/gcc/cpplib.c revision 1.240, in the do_undef function,
> replaced a check of NODE_BUILTIN with NODE_WARN. Assuming
> that normal macros are supposed to be tagged with NODE_WARN,
> this check is also wrong, because it will cause a warning
> whenever a normal macro is undefined.
No, normal macros are not tagged NODE_WARN. If you look more closely
at the code, you'd observe that macros tagged NODE_WARN trigger
warnings unconditionally when redefined or undefined.
Further, you would notice that NODE_WARN macros are precisely those
beginning with __STDC_ and builtins like __TIME__ and __LINE__.
We don't want code like
#define x some thing
#define x some /* Comment. */ thing
to give a warning; the standard explicitly permits such things. If
all macros were tagged NODE_WARN, then everything would warn and there
would be no point in the warn_of_redefinition() function.
What causes non-trivial redefinitions of normal macros to be ignored
in your case is the check for -pedantic in warn_of_redefinition().
That was removed last week, and GCC 3.0.3 and 3.1 will warn regardless
of -pedantic.
Neil.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: preprocessor/4976: cpp fails to warn about macro redefinitions
@ 2001-11-22 20:36 neil
0 siblings, 0 replies; 4+ messages in thread
From: neil @ 2001-11-22 20:36 UTC (permalink / raw)
To: fredette, gcc-bugs, gcc-gnats, gcc-prs, nobody
Synopsis: cpp fails to warn about macro redefinitions
State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Fri Nov 30 15:03:08 2001
State-Changed-Why:
Please don't mark PRs as high priority; that is supposed to
be reserved for GCC maintainers.
GCC has been fixed to emit the warning in 3.0.3 and 3.1.
3.0.2 only warns if -pedantic.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4976&database=gcc
^ permalink raw reply [flat|nested] 4+ messages in thread
* preprocessor/4976: cpp fails to warn about macro redefinitions
@ 2001-11-22 14:26 fredette
0 siblings, 0 replies; 4+ messages in thread
From: fredette @ 2001-11-22 14:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 4976
>Category: preprocessor
>Synopsis: cpp fails to warn about macro redefinitions
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Nov 30 14:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Matthew Fredette
>Release: gcc-3.0.2
>Organization:
>Environment:
NetBSD the-gates-of-delirium.home 1.5W NetBSD 1.5W (THE-GATES-OF-DELIRIUM) #3: Fri Jul 13 09:31:17 EDT 2001 root@the-gates-of-delirium:/data/union-i386/src/sys/arch/i386/compile/THE-GATES-OF-DELIRIUM i386
>Description:
cpp fails to warn about macro redefinitions.
gcc/gcc/cppmacro.c revision 1.46 introduced the NODE_WARN flag, with
this code at the end of the _cpp_create_definition function:
if (! ustrncmp (node->name, DSC ("__STDC_")))
node->flags |= NODE_WARN;
It is this NODE_WARN flag that is supposed to trigger (through the
warn_of_redefinition function) a warning when a macro is redefined.
The test seems wrong - as ustrncmp behaves like strncmp, this test
will fail for all macros other than __STDC__. I.e., only a
redefined __STDC__ macro node will happen to get this flag.
Further, gcc/gcc/cpplib.c revision 1.240, in the do_undef function,
replaced a check of NODE_BUILTIN with NODE_WARN. Assuming
that normal macros are supposed to be tagged with NODE_WARN,
this check is also wrong, because it will cause a warning
whenever a normal macro is undefined.
>How-To-Repeat:
Try to preprocess a file that defines a macro, then redefines
it with a different value.
>Fix:
Remove the ! from the test at line 1426 of gcc/gcc/cppmacro.c, revision 1.87.
Replace NODE_WARN with NODE_BUILTIN at line 496 of gcc/gcc/gcclib.c, revision 1.287.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-11-30 23:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-23 0:46 preprocessor/4976: cpp fails to warn about macro redefinitions neil
-- strict thread matches above, loose matches on Subject: below --
2001-11-23 0:45 Neil Booth
2001-11-22 20:36 neil
2001-11-22 14:26 fredette
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).