public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ed Schonberg <schonberg@adacore.com>
Subject: [Ada] Reject properly an aspect Predicate on a formal type
Date: Tue, 05 Dec 2017 12:46:00 -0000	[thread overview]
Message-ID: <20171205124647.GA40250@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

This patch adds a check to reject an aspect Predicate on a formal type
declaration.

Compiling gen.adb must yield:

   gen.ads:2:55: predicate cannot apply to formal type

---
generic
   type T is array (Integer range <>) of Integer
       with Predicate => T'First /= 1;
function Gen return Integer;
---
function Gen return Integer is
   X : T(1 .. 2);
begin
   return X'First;
end Gen;

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-12-05  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch13.adb (Analyze_Aspect_Specifications, case Predicate): A
	predicate cannot apply to a formal type.


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 571 bytes --]

Index: sem_ch13.adb
===================================================================
--- sem_ch13.adb	(revision 255408)
+++ sem_ch13.adb	(working copy)
@@ -2389,6 +2389,10 @@
                   elsif Is_Incomplete_Type (E) then
                      Error_Msg_N
                        ("predicate cannot apply to incomplete view", Aspect);
+
+                  elsif Is_Generic_Type (E) then
+                     Error_Msg_N
+                       ("predicate cannot apply to formal type", Aspect);
                      goto Continue;
                   end if;
 

                 reply	other threads:[~2017-12-05 12:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171205124647.GA40250@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=schonberg@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).