public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: fredette@mit.edu
To: gcc-gnats@gcc.gnu.org
Subject: preprocessor/4976: cpp fails to warn about macro redefinitions
Date: Thu, 22 Nov 2001 14:26:00 -0000	[thread overview]
Message-ID: <20011130220644.15073.qmail@sourceware.cygnus.com> (raw)


>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:


             reply	other threads:[~2001-11-30 22:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-22 14:26 fredette [this message]
2001-11-22 20:36 neil
2001-11-23  0:45 Neil Booth
2001-11-23  0:46 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=20011130220644.15073.qmail@sourceware.cygnus.com \
    --to=fredette@mit.edu \
    --cc=gcc-gnats@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).