From patchwork Thu Oct 23 10:39:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 402437 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 88D0D14007F for ; Thu, 23 Oct 2014 21:40:07 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=dyBG3qlZozBkM0mcOEbbBlIx1ii1wZ0PqPIHwZOVHVX+X2XzZf z9LTWwkAe95p2YL5/ddvv/uMMSqrWt8KA8Q6M59vQh0X+7rUpgukojHFSEcjv8gi XsoHyTLeFQEVA/YoCNsOIuz+IW1mMRnpbzbwzdHIlZsIsOMirgLC+XQak= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=HWI+5rrzWpNp9gKKdsr37+Q3WVY=; b=Y9eA6nX0SBEAkF1AlNIs ED7S3x2TaWkAb7o1z2dEuP99WK3eVXtxcptB/kCzZ4METn9PS+AJcf17+FMXtafZ T4WCSCiK1pvw4do2RY9fbLPIRGROhlu49HahZ66JCVHzAPsrY0H4BimvTdhqAsCC bsUUIr97OttTfCQMgekg5SE= Received: (qmail 958 invoked by alias); 23 Oct 2014 10:40:01 -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 947 invoked by uid 89); 23 Oct 2014 10:40:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 23 Oct 2014 10:39:59 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 48D5F116191; Thu, 23 Oct 2014 06:39:57 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GR9MTqhyZA7F; Thu, 23 Oct 2014 06:39:57 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 393E61160F3; Thu, 23 Oct 2014 06:39:57 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 3528D3FE21; Thu, 23 Oct 2014 06:39:57 -0400 (EDT) Date: Thu, 23 Oct 2014 06:39:57 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Spurious warnings about unused units Message-ID: <20141023103957.GA22576@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) A prefixed call is resolved by examining the dispatch table of the controlling object, not by visibility. The operation may be defined in another unit, and no reference to it, or to its scope, might be created for it through the usual Generate_Reference machinery. To prevent spurious warnings about unused units, indicate that the operation and its scope are in fact referenced. No simple example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2014-10-23 Ed Schonberg * sem_ch4.adb (Complete_Object_Operation): Indicate that the scope of the operation (s) is referenced, to prevent spurious warnings about unused units. Index: sem_ch4.adb =================================================================== --- sem_ch4.adb (revision 216574) +++ sem_ch4.adb (working copy) @@ -7617,6 +7617,17 @@ Rewrite (First_Actual, Obj); end if; + -- The operation is obtained from the dispatch table and not by + -- visibility, and may be declared in a unit that is not explicitly + -- referenced in the source, but is nevertheless required in the + -- context of the current unit. Indicate that operation and its scope + -- are referenced, to prevent spurious and misleading warnings. If + -- the operation is overloaded, all primitives are in the same scope + -- and we can use any of them. + + Set_Referenced (Entity (Subprog), True); + Set_Referenced (Scope (Entity (Subprog)), True); + Rewrite (Node_To_Replace, Call_Node); -- Propagate the interpretations collected in subprog to the new