From patchwork Mon Oct 9 20:19:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 823494 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-463817-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CE0XLT2b"; 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 3y9s6d5vQmz9t2Z for ; Tue, 10 Oct 2017 07:19:52 +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=vZAewgc6QHcNhJMjPonEoYmUS3u5aFeeyEYmHDAfKLdd7yt0X7 a8uaMxmLSRhF9uZ2Q+uQx+kiZ6MxcnXvHJpL76C/wu2D9hQEnF58fmT+2UazK3vM CHnGSlj2n2QYC0SEhS8dRUouxO2SglYzsSL4iGcYDAF6h4z4W11KmmEyU= 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=kDj/nzcvPX+unHLaHJkhDEZb2M0=; b=CE0XLT2bWkJGymfyBdG/ o4sdQw5+3lpz/H0hj8aAzCcytBqNHLQkbhPhkcNMgsrl7DQacMv4ZdQbSclGw4je kclen8TDuYITmC5v7B8iCqp2+DKfmgVDDyirS+PMgI+V9+A8YBfSiYilJm16dmIe Y33N4PnZMxltu71vuNvu6fE= Received: (qmail 105840 invoked by alias); 9 Oct 2017 20:19:46 -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 105821 invoked by uid 89); 9 Oct 2017 20:19:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Mon, 09 Oct 2017 20:19:43 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 35AE85631C; Mon, 9 Oct 2017 16:19:42 -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 Zz-B8VPmW+O1; Mon, 9 Oct 2017 16:19:42 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 24EA156004; Mon, 9 Oct 2017 16:19:42 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 2139443A; Mon, 9 Oct 2017 16:19:42 -0400 (EDT) Date: Mon, 9 Oct 2017 16:19:42 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Hristian Kirtchev Subject: [Ada] Spurious warnings with dynamic elab checks Message-ID: <20171009201942.GA112373@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This patch classifies 'Access, variable assignments, and variable references as static model-only scenarios because they are graph-dependent and do not produce any checks. No need for a test. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-10-09 Hristian Kirtchev * sem_elab.adb (Is_Suitable_Access): This scenario is now only relevant in the static model. (Is_Suitable_Variable_Assignment): This scenario is now only relevant in the static model. (Is_Suitable_Variable_Reference): This scenario is now only relevant in the static model. Index: sem_elab.adb =================================================================== --- sem_elab.adb (revision 253563) +++ sem_elab.adb (working copy) @@ -4995,11 +4995,27 @@ Subp_Id : Entity_Id; begin - if Nkind (N) /= N_Attribute_Reference then + -- This scenario is relevant only when the static model is in effect + -- because it is graph-dependent and does not involve any run-time + -- checks. Allowing it in the dynamic model would create confusing + -- noise. + + if not Static_Elaboration_Checks then return False; - -- Internally-generated attributes are assumed to be ABE safe + -- Nothing to do when switch -gnatd.U (ignore 'Access) is in effect + elsif Debug_Flag_Dot_UU then + return False; + + -- Nothing to do when the scenario is not an attribute reference + + elsif Nkind (N) /= N_Attribute_Reference then + return False; + + -- Nothing to do for internally-generated attributes because they are + -- assumed to be ABE safe. + elsif not Comes_From_Source (N) then return False; end if; @@ -5031,16 +5047,10 @@ return - -- This particular scenario is relevant only in the static model when - -- switch -gnatd.U (ignore 'Access) is not in effect. + -- The prefix must denote a source entry, operator, or subprogram + -- which is not imported. - Static_Elaboration_Checks - and then not Debug_Flag_Dot_UU - - -- The prefix must denote an entry, operator, or subprogram which is - -- not imported. - - and then Comes_From_Source (Subp_Id) + Comes_From_Source (Subp_Id) and then Is_Subprogram_Or_Entry (Subp_Id) and then not Is_Bodiless_Subprogram (Subp_Id) @@ -5109,11 +5119,22 @@ Var_Unit_Id : Entity_Id; begin - if Nkind (N) /= N_Assignment_Statement then + -- This scenario is relevant only when the static model is in effect + -- because it is graph-dependent and does not involve any run-time + -- checks. Allowing it in the dynamic model would create confusing + -- noise. + + if not Static_Elaboration_Checks then return False; - -- Internally-generated assigments are assumed to be ABE safe + -- Nothing to do when the scenario is not an assignment + elsif Nkind (N) /= N_Assignment_Statement then + return False; + + -- Nothing to do for internally-generated assignments because they are + -- assumed to be ABE safe. + elsif not Comes_From_Source (N) then return False; @@ -5161,10 +5182,10 @@ -- To qualify, the assignment must meet the following prerequisites: return - Comes_From_Source (Var_Id) - -- The variable must be susceptible to warnings + -- The variable must be a source entity and susceptible to warnings + Comes_From_Source (Var_Id) and then not Has_Warnings_Off (Var_Id) -- The variable must be declared in the spec of compilation unit U @@ -5232,14 +5253,23 @@ -- Start of processing for Is_Suitable_Variable_Reference begin + -- This scenario is relevant only when the static model is in effect + -- because it is graph-dependent and does not involve any run-time + -- checks. Allowing it in the dynamic model would create confusing + -- noise. + + if not Static_Elaboration_Checks then + return False; + -- Attributes and operator sumbols are not considered to be suitable -- references to variables even though they are part of predicate -- Is_Entity_Name. - if not Nkind_In (N, N_Expanded_Name, N_Identifier) then + elsif not Nkind_In (N, N_Expanded_Name, N_Identifier) then return False; - -- Internally generated references are assumed to be ABE safe + -- Nothing to do for internally-generated references because they are + -- assumed to be ABE safe. elsif not Comes_From_Source (N) then return False;