From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48440 invoked by alias); 1 Jul 2019 13:38:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 48292 invoked by uid 89); 1 Jul 2019 13:38:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_NEUTRAL autolearn=ham version=3.3.1 spammy=misuse, HX-detected-operating-system:3.x X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (209.51.188.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 01 Jul 2019 13:38:08 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhwVR-0001IW-Qa for gcc-patches@gcc.gnu.org; Mon, 01 Jul 2019 09:38:06 -0400 Received: from rock.gnat.com ([205.232.38.15]:42167) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hhwVR-0001HK-Jy for gcc-patches@gcc.gnu.org; Mon, 01 Jul 2019 09:38:05 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 667495605A; Mon, 1 Jul 2019 09:38:00 -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 RE0PlWk3v8IU; Mon, 1 Jul 2019 09:38:00 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 5555056059; Mon, 1 Jul 2019 09:38:00 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 5497B5B9; Mon, 1 Jul 2019 09:38:00 -0400 (EDT) Date: Mon, 01 Jul 2019 13:38:00 -0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Ed Schonberg Subject: [Ada] Crash on improper pragma Weak_External Message-ID: <20190701133800.GA18538@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 205.232.38.15 X-IsSubscribed: yes X-SW-Source: 2019-07/txt/msg00045.txt.bz2 --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 527 This patch adds a guard on the use of pragma Weak_External. This pragma affects link-time addresses of entities, and does not apply to types. Previous to this patch the compiler would abort on a misuse of the pragma. Tested on x86_64-pc-linux-gnu, committed on trunk 2019-07-01 Ed Schonberg gcc/ada/ * sem_prag.adb (Analyze_Pragma, case Weak_External): Pragma only applies to entities with run-time addresses, not to types. gcc/testsuite/ * gnat.dg/weak3.adb, gnat.dg/weak3.ads: New testcase. --a8Wt8u1KmwUX3Y2C Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" Content-length: 1050 --- gcc/ada/sem_prag.adb +++ gcc/ada/sem_prag.adb @@ -25608,6 +25608,12 @@ package body Sem_Prag is Ent := Underlying_Type (Ent); end if; + -- The pragma applies to entities with addresses. + + if Is_Type (Ent) then + Error_Pragma ("pragma applies to objects and subprograms"); + end if; + -- The only processing required is to link this item on to the -- list of rep items for the given entity. This is accomplished -- by the call to Rep_Item_Too_Late (when no error is detected --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/weak3.adb @@ -0,0 +1,11 @@ +-- { dg-do compile } + +package body Weak3 is + + type T is new Integer; + pragma Weak_External (T); -- { dg-error "pragma applies to objects and subprograms" } + X : T; + + procedure Foo is null; + +end Weak3; --- /dev/null new file mode 100644 +++ gcc/testsuite/gnat.dg/weak3.ads @@ -0,0 +1,3 @@ +package Weak3 is + procedure Foo; +end Weak3; --a8Wt8u1KmwUX3Y2C--