Bug 34508 - Legal program rejected, RM 3.7(26)
Summary: Legal program rejected, RM 3.7(26)
Status: RESOLVED WORKSFORME
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-17 09:46 UTC by Ludovic Brenta
Modified: 2015-12-05 12:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.1.2, 4.2.2
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Brenta 2007-12-17 09:46:01 UTC
package pak1 is
   type T1(<>) is tagged limited private;
private
   type T1(D: integer) is tagged limited null record;
end pak1;

package pak1.pak3 is
   type T3 is new pak1.T1 with null record;   -- legal, but rejected
   x2: T3 := (pak1.T1 with null record);      -- legal, but rejected
end pak1.pak3;

RM 3.7(26) states: "A type declared without a discriminant part has no discriminants, unless it is a derived type; if derived, such a type has the same sort of discriminants (known, unknown, or none) as its parent (or ancestor) type."  Therefore, the declaration of T3 is legal and T3 has unknown discriminants.
Comment 1 Ludovic Brenta 2007-12-18 12:10:10 UTC
Actually, the declaration of x2 is illegal; GNAT is correct in rejecting it.  The declaration of T3 is legal and incorrectly rejected.  The error messages are:

gnatmake -gnat05 pak1-pak3.ads
gcc-4.1 -c -gnat05 pak1-pak3.ads
pak1-pak3.ads:3:15: invalid constraint: type has no discriminant
pak1-pak3.ads:4:14: no value supplied for discriminant "D"

(see also PR ada/34507).
Comment 2 Eric Botcazou 2015-12-05 12:04:29 UTC
.