This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Correct failure to detect Invariant'Class for untagged type

This fixes a problem with B test ND11001. There were actually three
problems reported

a) Bad use of Default_Component_Value, but this had already been
previously fixed.

b) Bad use of Invariant'Class, fixed as part of this patch

c) Failure to detect bad aspect on null body. This was actually
an issue of not detecting this after a previous error (i.e. a
B test splitting issue), but as part of this patch, this error
is now properly caught even if there are previous errors, which
avoids the need to split the test.

The following shows the three reported cases properly caught
and diagnosed (compiled with -gnatq -gnatld7 -gnatj55):

     1. procedure BadAsp is
     2.    package P1 is
     3.       type Arr is private with
        >>> aspect Default_Component_Value can only
            apply to an array of scalar components

     4.         Default_Component_Value => 1;
     5.    private
     6.       type Arr is array (1 .. 10) of Integer;
     7.    end;
     9.    package P2 is
    10.       type Rec is private with
    11.         Type_Invariant'Class => True;
        >>> Type_Invariant'Class cannot be specified
            for "Rec", can only be specified for a
            tagged type

    12.    private
    13.       type Rec is null record;
    14.    end;
    16.    package p3 is
    17.       type Priv is tagged null record;
    18.       procedure Prim1 (A : in out Priv);
    19.    end;
    21.    package body P3 is
    22.       procedure Prim1 (A : in out Priv) is null
    23.         with Post'Class => True;
        >>> aspect specification must appear in
            subprogram declaration

    24.    end;
    26. begin
    27.    null;
    28. end;

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

2014-07-31  Robert Dewar  <>

	* freeze.adb (Freeze_Entity): Check for error of
	Type_Invariant'Class applied to a untagged type.
	* sem_ch6.adb (Analyze_Null_Procedure): Unconditionally rewrite
	as null body, so that we perform error checks even if expansion
	is off.

Attachment: difs
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]