From patchwork Tue Jun 14 12:20:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 635227 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 3rTTHx4lM4z9s2k for ; Tue, 14 Jun 2016 22:20:28 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=N1/YFtRJ; dkim-atps=neutral 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=CGcFANDAtl3a52y2LqzyHDBdujikboEiM9AQFtGBm7DwQ2QhgK 3wx/0a+R/Gpz3IvUOD0lf2Ny8wCgsGzk1PYQjZX4bn+A5e4q5w2d3KT8y2yIJOtu f/2rhPMwAYWQS9nJS59h/b0OuZvQTO+ohqksWOc95XDnk4h9VptPO3WjE= 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=vrpK/C9p4MqKl/ThGkacP5Lrd2I=; b=N1/YFtRJ4umt7l0jnqhZ myLJc4ipJyuCmFzKW5PRRAXSerSFyGdpPsL/8I+G0KrNcOLxUt3CdRAUeLVBXeM/ h9T9f65GJqwDQjOJumyp3Qqq/pnFMN2hn9pXcXO8Ae/lVlOwlBPwlbleBm6AYOsB fFioq9XZ64fcXG2J5LJdrDw= Received: (qmail 116833 invoked by alias); 14 Jun 2016 12:20:21 -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 116808 invoked by uid 89); 14 Jun 2016 12:20:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=sk:analyze, Nkind, nkind, Hx-languages-length:2031 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; Tue, 14 Jun 2016 12:20:10 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 34042116E86; Tue, 14 Jun 2016 08:20:09 -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 eHg3Ffv0H-0N; Tue, 14 Jun 2016 08:20:09 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id CBDA41171AE; Tue, 14 Jun 2016 08:20:07 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id C8303410; Tue, 14 Jun 2016 08:20:07 -0400 (EDT) Date: Tue, 14 Jun 2016 08:20:07 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Missing error on formal package Message-ID: <20160614122007.GA26068@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch fixes an omission in the analysis of formal package declarations. Actuals in the instance are properly rejected if their name does not correspond to any of the actuals, and there are box associations for existing formals. Compiling gcc -c c_test.ads must yield generic_p_level_2.ads:7:53: unmatched actual "C_Test" generic_p_level_2.ads:7:53: in instantiation of "Generic_P_Level_1" declared at generic_p_level_1.ads:5 --- -------------------------- generic type Param is (<>); package Generic_P_Level_1 is Var : Integer; end; -------------------------- with Generic_P_Level_1; generic with package P_Level_1 is new Generic_P_Level_1 (C_Test => 2, Param => <>); package Generic_P_Level_2 is Var : Integer; end; ------------------------ with Generic_P_Level_1; with Generic_P_Level_2; package test is package P_Level_1 is new Generic_P_Level_1(Integer); package P_Level_2 is new Generic_P_Level_2(P_Level_1); end; Tested on x86_64-pc-linux-gnu, committed on trunk 2016-06-14 Ed Schonberg * sem_ch12.adb (Analyze_Associations): An actual parameter with a box must be included in the count of actuals, to detect possible superfluous named actuals that do not match any of the formals of the generic unit in a formal package declaration. Index: sem_ch12.adb =================================================================== --- sem_ch12.adb (revision 237432) +++ sem_ch12.adb (working copy) @@ -1496,10 +1496,13 @@ -- A named association may lack an actual parameter, if it was -- introduced for a default subprogram that turns out to be local - -- to the outer instantiation. + -- to the outer instantiation. If it has a box association it must + -- correspond to some formal in the generic. if Nkind (Named) /= N_Others_Choice - and then Present (Explicit_Generic_Actual_Parameter (Named)) + and then + (Present (Explicit_Generic_Actual_Parameter (Named)) + or else Box_Present (Named)) then Num_Actuals := Num_Actuals + 1; end if;