From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19773 invoked by alias); 30 Nov 2001 22:16:05 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 19715 invoked by uid 71); 30 Nov 2001 22:16:02 -0000 Resent-Date: 30 Nov 2001 22:16:02 -0000 Resent-Message-ID: <20011130221602.19714.qmail@sourceware.cygnus.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, fredette@mit.edu Received:(qmail 15076 invoked by uid 61); 30 Nov 2001 22:06:45 -0000 Message-Id:<20011130220644.15073.qmail@sourceware.cygnus.com> Date: Thu, 22 Nov 2001 14:26:00 -0000 From: fredette@mit.edu Reply-To: fredette@mit.edu To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.2 (1.1.1.1.2.21) Subject: preprocessor/4976: cpp fails to warn about macro redefinitions X-SW-Source: 2001-11/txt/msg00781.txt.bz2 List-Id: >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: