From patchwork Fri Nov 5 17:47:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 70273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id DB2611007D2 for ; Sat, 6 Nov 2010 04:47:50 +1100 (EST) Received: (qmail 19357 invoked by alias); 5 Nov 2010 17:47:47 -0000 Received: (qmail 19346 invoked by uid 22791); 5 Nov 2010 17:47:46 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 05 Nov 2010 17:47:42 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA5HlX1o022297 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 5 Nov 2010 13:47:33 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oA5HlWA0005475 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 5 Nov 2010 13:47:32 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id oA5HlV01005153; Fri, 5 Nov 2010 18:47:31 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oA5HlV6V005146; Fri, 5 Nov 2010 18:47:31 +0100 Date: Fri, 5 Nov 2010 18:47:31 +0100 From: Jakub Jelinek To: "Joseph S. Myers" Cc: gcc-patches@gcc.gnu.org Subject: [C PATCH] Fix -Wc++-compat (PR c/44772) Message-ID: <20101105174731.GK29412@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi! pointer_set_contains is documented that it must not be called with NULL. We don't try to store NULL into tset (which doesn't work either), but pointer_set_contains (tset, NULL) just always returns 1. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-11-05 Jakub Jelinek PR c/44772 * c-decl.c (warn_cxx_compat_finish_struct): Don't call pointer_set_contains if DECL_NAME is NULL. * gcc.dg/Wcxx-compat-21.c: New test. Jakub --- gcc/c-decl.c.jj 2010-11-01 09:07:22.000000000 +0100 +++ gcc/c-decl.c 2010-11-05 14:35:08.000000000 +0100 @@ -6877,7 +6877,8 @@ warn_cxx_compat_finish_struct (tree fiel for (x = fieldlist; x != NULL_TREE; x = DECL_CHAIN (x)) { - if (pointer_set_contains (tset, DECL_NAME (x))) + if (DECL_NAME (x) != NULL_TREE + && pointer_set_contains (tset, DECL_NAME (x))) { warning_at (DECL_SOURCE_LOCATION (x), OPT_Wc___compat, ("using %qD as both field and typedef name is " --- gcc/testsuite/gcc.dg/Wcxx-compat-21.c.jj 2010-11-05 14:37:35.000000000 +0100 +++ gcc/testsuite/gcc.dg/Wcxx-compat-21.c 2010-11-05 14:41:11.000000000 +0100 @@ -0,0 +1,25 @@ +/* PR c/44772 */ +/* { dg-do compile } */ +/* { dg-options "-Wc++-compat" } */ + +typedef enum { E1, E2 } E; + +typedef struct +{ + E e; + union + { + int i; + char *c; + }; /* { dg-bogus "as both field and typedef name" } */ +} S; + +S s; + +typedef int T; + +struct U +{ + T t; + union { int i; }; /* { dg-bogus "as both field and typedef name" } */ +};