Bug 15843 - Illegal program not detected, RM 3.7.2(2)
Summary: Illegal program not detected, RM 3.7.2(2)
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2004-06-06 10:18 UTC by Ludovic Brenta
Modified: 2015-12-05 10:14 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.0.0, 4.3.0, 4.4.1
Last reconfirmed: 2007-12-13 14:11:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ludovic Brenta 2004-06-06 10:18:40 UTC
-- RM 3.7.2(2)
-- For a prefix A that is of a discriminated type ...
-- the following attribute [A'constrained] is defined
procedure Test_247017 is

    generic
       type T1 (<>) is private;
    procedure p1(x: out T1);

    procedure p1 (x: out T1) is
    b: boolean := x'constrained;   --ERROR: not a discriminated type
    begin
       null;
    end p1;

begin
   null;
end Test_247017;

I expect an error message like this:

test_247017.adb:11:20: "x" has no discriminants, Constraint attribute not defined

But the compiler says nothing.
Comment 1 Andrew Pinski 2004-10-29 13:33:18 UTC
I do get a warning on the mainline:
test_247017.adb:8:18: warning: "x" is never assigned a value
Comment 2 Andrew Pinski 2004-10-29 14:44:57 UTC
Confirmed.
Comment 3 Samuel Tardieu 2007-12-13 14:11:06 UTC
Confirmed on 4.3.0 20071213
Comment 4 Ludovic Brenta 2009-08-06 20:44:10 UTC
Confirmed on 4.4.1.
Comment 5 Nicolas Boulenguez 2011-08-31 00:57:13 UTC
confirmed 4.6.1
Comment 6 Nicolas Boulenguez 2014-02-27 14:33:34 UTC
confirm 4.9-20140218
Comment 7 Eric Botcazou 2015-12-05 10:14:51 UTC
In addition to the usage of this attribute in the Ada RM, GNAT also permits the use of the 'Constrained attribute in a generic template for any type, including types without discriminants. The value of this attribute in the generic instance when applied to a scalar type or a record type without discriminants is always True. This usage is compatible with older Ada compilers, including notably DEC Ada.