From patchwork Fri Sep 20 09:11:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1165114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509344-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kaza+V6r"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46ZSf52S5tz9s00 for ; Fri, 20 Sep 2019 19:12:12 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=v02Oe+suF1wYUYVU iPD7VzzFcqOLWLOmC7PZn5rHkxSRKEPOXYFB+oYjcacKrfYOugMBlrYbefrcNJ9p 0VpUVWt8k0fLbfBuja/kzUq8wJl5vEeRkYjJjxh0zLCWusNE5IY1t+IVHIo3vKpN rPj1VRn7LzDWhrAmo70joX9LnPI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=0bQ1Yvf2IFwnKvRcjjMXba jtC0Q=; b=kaza+V6rR/mrxblYMWBEIyT77TMfBnvcLZwX9fn0OwhJ+dym2hHCrK 3R5c/d0IaLXdRUHCIhBgOPQp9jF58nQiIH7WCpLeqEyI6hSUB5HXokLOEjqfCRDb qphRzwdTmrjzPr0j2rHg0kcfDMlWuChRMJMKIlpxFgzxxAmEn8rM8= Received: (qmail 17731 invoked by alias); 20 Sep 2019 09:12:03 -0000 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 Received: (qmail 17647 invoked by uid 89); 20 Sep 2019 09:12:03 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Sep 2019 09:12:00 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 88C4B81398 for ; Fri, 20 Sep 2019 11:11:56 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lYDrBYEQ8scx for ; Fri, 20 Sep 2019 11:11:56 +0200 (CEST) Received: from polaris.localnet (unknown [IPv6:2a01:e35:8a16:3850:1a03:73ff:fe45:373a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 62EE881393 for ; Fri, 20 Sep 2019 11:11:56 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix PR c/91815 Date: Fri, 20 Sep 2019 11:11:55 +0200 Message-ID: <5321767.8bt0uQpQXk@polaris> MIME-Version: 1.0 This gets rid of a bogus error issued by the C compiler on a type definition at file scope when there is a preceding external declaration in a local scope for the same symbol (but the error is still issued if the preceding external declaration is also at file scope). Bootstrapped/regtested on x86-64/Linux, approved by Joseph in the audit trail and applied on the mainline. 2019-09-20 Eric Botcazou PR c/91815 * c-decl.c (pushdecl): In C detect duplicate declarations across scopes of identifiers in the external scope only for variables and functions. 2019-09-20 Eric Botcazou * gcc.dg/typedef-var-1.c: New test. * gcc.dg/typedef-var-2.c: Likewise. Index: c-decl.c =================================================================== --- c-decl.c (revision 275988) +++ c-decl.c (working copy) @@ -3130,8 +3130,11 @@ pushdecl (tree x) detecting duplicate declarations of the same object, no matter what scope they are in; this is what we do here. (C99 6.2.7p2: All declarations that refer to the same object or function shall - have compatible type; otherwise, the behavior is undefined.) */ - if (DECL_EXTERNAL (x) || scope == file_scope) + have compatible type; otherwise, the behavior is undefined.) + However, in Objective-C, we also want to detect declarations + conflicting with those of the basic types. */ + if ((DECL_EXTERNAL (x) || scope == file_scope) + && (VAR_OR_FUNCTION_DECL_P (x) || c_dialect_objc ())) { tree type = TREE_TYPE (x); tree vistype = NULL_TREE;