From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: Weird error with Dynamic_Predicate
Date: Mon, 12 May 2014 14:01:32 -0700 (PDT)
Date: 2014-05-12T14:01:32-07:00 [thread overview]
Message-ID: <3f9e21b4-868d-44de-9673-824eefb9e79e@googlegroups.com> (raw)
In-Reply-To: <e4d8e3db-99b6-49d4-85f3-839f178d4047@googlegroups.com>
For what it's worth, here's the smallest reduced example I can come up with that gives the same error message:
package Prova is
type Identifier_Name is new String with Dynamic_Predicate => true;
function Extract_Namespace (Nome : Identifier_Name)
return Identifier_Name;
end Prova;
package body Prova is
function Extract_Namespace (Nome : Identifier_Name)
return Identifier_Name
is
Idx : Natural := Ada.Strings.Fixed.Index (String (Nome), ".");
begin
return "ns";
end Extract_Namespace;
end Prova;
This is with GCC 4.5.4 (20120510).
-- Adam
On Monday, May 12, 2014 12:47:41 PM UTC-7, mockturtle wrote:
> Dear all,
>
> I am experiencing an error that is making me crazy and I was wondering if someone can help.
>
>
>
> Some background: I want to define a type that represents an "identifier." The identifier can assume two forms:
>
> - qualified (es. namespace.foo)
>
> - not qualified (es. foo)
>
>
>
> The two components (namespace and name) have the usual syntax (letters, digits and underscore). Note that there are at most two components. I want to use the aspect Dynamic_Predicate to enforce (and document) the right syntax.
>
>
>
> You can find prova.ads and prova.adb at the end of this message. I am using GPS 5.2.1 (20130102) and when I try to compile I get the obscure message
>
>
>
> 29:32 error: conversion to incomplete type
>
> 29:32 confused by earlier errors, bailing out
>
>
>
> on >> prova.ads <<. If I try to do "check semantic" on prova.ads and prova.adb, everything is fine.
>
>
>
>
>
> Any ideas? Is it a compiler bug or am I doing something wrong? Updating the compiler in this moment it would be a little pain for me (for several reasons), so I would like to be sure that I am not doing some subtle error before trying the update path.
>
>
>
> Thank you in advance
>
>
>
> Riccardo
>
>
>
>
>
>
>
> --- prova.ads ---
>
> with Ada.Characters.Handling; use Ada.Characters.Handling;
>
> with Ada.Strings.Fixed;
>
>
>
> package Prova is
>
> type Identifier_Name is new
>
> String
>
> with Dynamic_Predicate =>
>
> ((for all I in Identifier_Name'Range =>
>
> Is_Alphanumeric (Identifier_Name (I))
>
> or Identifier_Name (I) = '_'
>
> or Identifier_Name (I) = '.')
>
> and
>
> (not (Identifier_Name (Identifier_Name'First) in '0' .. '9'))
>
> and
>
> (Identifier_Name (Identifier_Name'First) /= '.')
>
> and
>
> Ada.Strings.Fixed.Count (String (Identifier_Name), ".") <= 1);
>
>
>
> function Is_Qualified (Item : Identifier_Name) return Boolean
>
> is (Ada.Strings.Fixed.Count (String (Item), ".") = 1);
>
>
>
> subtype Namespace_Identifier is Identifier_Name
>
> with Dynamic_Predicate => not Is_Qualified (Namespace_Identifier);
>
>
>
> subtype Full_Identifier is Identifier_Name
>
> with Dynamic_Predicate => Is_Qualified (Full_Identifier);
>
>
>
>
>
> function Extract_Namespace (Nome : Full_Identifier)
>
> return Namespace_Identifier;
>
>
>
> end Prova;
>
>
>
> --- prova.adb ---
>
>
>
> package body Prova is
>
>
>
>
>
> -----------------------
>
> -- Extract_Namespace --
>
> -----------------------
>
>
>
> function Extract_Namespace (Nome : Full_Identifier)
>
> return Namespace_Identifier
>
> is
>
> Idx : Natural := Ada.Strings.Fixed.Index (String (Nome), ".");
>
> begin
>
> return Namespace_Identifier (Nome (Nome'First .. Idx - 1));
>
> end Extract_Namespace;
>
>
>
> end Prova;
>
> ----
next prev parent reply other threads:[~2014-05-12 21:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-12 19:47 Weird error with Dynamic_Predicate mockturtle
2014-05-12 20:45 ` Peter Chapin
2014-05-12 20:52 ` mockturtle
2014-05-12 21:01 ` Adam Beneschan [this message]
2014-05-12 22:17 ` Randy Brukardt
2014-05-13 4:40 ` Simon Wright
2014-05-13 20:50 ` Simon Wright
2014-05-13 4:59 ` Shark8
2014-05-13 12:46 ` G.B.
2014-05-13 17:04 ` Martin
2014-05-13 18:55 ` mockturtle
2014-05-13 21:39 ` Georg Bauhaus
2014-05-14 7:30 ` mockturtle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox