From patchwork Wed Apr 27 12:42:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 615613 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 3qw03s5tghz9ssM for ; Wed, 27 Apr 2016 22:42:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=fSFXvXbp; 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=mHLZOben8GH2hLN83aKbc9vGAEQQ+eto18BjDO2WrBkjQbCTF+ jY9Tec+50jSceNrxQskaMWYgQReL3U2TFUTNehJgZ/j4tR+S6Hj0tFrLBMSTa5YZ 8zLVqfbEqRY12tm4ySzthCVYS6GAyRPN9umfwJs1WIEE9bNO6moi09p0I= 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=lpuWmmefXW3DVL3n86Ejwn44t7w=; b=fSFXvXbpAgfZgzXEKYr5 AYvlpLYBHE+2Kh9cLhy9BtA3gqOce7LBg64tCbJcnYKbJCwHZEC+sdi61ppk5tas 1GqgjmN07ZAi0ieMaf6iOh64LmR5Kz6zMQci0wU17io7oKHmw/63bfpU7PeIETnR +EsRuO6tP60Qv8ljhboUnH8= Received: (qmail 83652 invoked by alias); 27 Apr 2016 12:42:42 -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 83601 invoked by uid 89); 27 Apr 2016 12:42:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.8 required=5.0 tests=BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 spammy=235481, sk:Analyze, Schonberg, schonbergadacorecom 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; Wed, 27 Apr 2016 12:42:31 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BF921116B8D; Wed, 27 Apr 2016 08:42:29 -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 QQZMUhVlutkN; Wed, 27 Apr 2016 08:42:29 -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 AF9A2116AD7; Wed, 27 Apr 2016 08:42:29 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id AA6A5370; Wed, 27 Apr 2016 08:42:29 -0400 (EDT) Date: Wed, 27 Apr 2016 08:42:29 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Missing error on classwide precondition on a generic subprogram Message-ID: <20160427124229.GA90388@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) A generic subprogram is never a primitive operation, and thus a classwide condition for it is not legal. This patch diagnoses such an illegal class- wide condition properly. Example in ACATS test B611003 Tested on x86_64-pc-linux-gnu, committed on trunk 2016-04-27 Ed Schonberg * sem_prag.adb (Analyze_Pre_Post_Condition_In_Decl_Part): A generic subprogram is never a primitive operation, and thus a classwide condition for it is not legal. Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 235481) +++ sem_prag.adb (working copy) @@ -23319,11 +23319,12 @@ if Class_Present (N) then -- Verify that a class-wide condition is legal, i.e. the operation is - -- a primitive of a tagged type. + -- a primitive of a tagged type. Note that a generic subprogram is + -- not a primitive operation. Disp_Typ := Find_Dispatching_Type (Spec_Id); - if No (Disp_Typ) then + if No (Disp_Typ) or else Is_Generic_Subprogram (Spec_Id) then Error_Msg_Name_1 := Original_Aspect_Pragma_Name (N); if From_Aspect_Specification (N) then