581
596
Check ((K_All, K_Type, K_Record_Type, K_Tagged_Type));
582
597
when An_Access_Type_Definition =>
583
598
if Access_Type_Kind (Def) in Access_To_Subprogram_Definition then
584
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Sp_Type));
586
Accessed := Definitions.Subtype_Mark (Definitions.Access_To_Object_Definition (Def));
587
if A4G_Bugs.Attribute_Kind (Accessed) = A_Class_Attribute then
588
-- Directly: type T is access T'Class
589
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Class_Type));
599
Check ((K_All, K_Type, K_Access_Type, K_Access_To_SP_Type));
603
-- Here, we have an acces to object
604
Accessed := Subtype_Simple_Name (Definitions.Access_To_Object_Definition (Def));
605
if A4G_Bugs.Attribute_Kind (Accessed) = A_Class_Attribute then
606
-- Directly: type T is access T'Class
607
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Class_Type));
611
-- Ignore a possible 'Base
612
if A4G_Bugs.Attribute_Kind (Accessed) = A_Base_Attribute then
613
Accessed := Prefix (Accessed);
617
if Expression_Kind (Accessed) = A_Selected_Component then
618
Accessed := Selector (Accessed);
621
-- Here, we should have a plain (sub)type identifier
623
Accessed := Corresponding_Name_Declaration (Accessed);
624
if Declaration_Kind (Accessed) = An_Incomplete_Type_Declaration then
625
Accessed := Corresponding_Type_Declaration (Accessed);
626
if Is_Nil (Accessed) then
627
-- The full declaration of the accessed type is not in the context.
628
-- We cannot know the real nature of the accessed type.
629
-- Limit the check to Access_Type, and hope the user will rerun AdaControl
630
-- on the full program.
631
Check ((K_All, K_Type, K_Access_Type));
636
if Declaration_Kind (Accessed) = A_Subtype_Declaration
637
and then Is_Class_Wide_Subtype (Accessed)
639
-- Annoying special case: the access type designates a subtype that names
640
-- a class-wide type. (i.e. subtype ST is T'Class; type Acc is access ST;)
641
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Class_Type));
645
-- Get rid of subtyping and derivations on the accessed type
646
-- But we may have a mixture of formal or non-formal derivations...
648
Accessed := Corresponding_First_Subtype (Accessed);
649
Def := Type_Declaration_View (Accessed);
651
in A_Derived_Type_Definition .. A_Derived_Record_Extension_Definition
653
Accessed := A4G_Bugs.Corresponding_Root_Type (Def);
654
elsif Formal_Type_Kind (Def) = A_Formal_Derived_Type_Definition then
655
Accessed := Corresponding_Name_Declaration (Subtype_Simple_Name (Def));
591
-- Ignore a possible 'Base
592
if A4G_Bugs.Attribute_Kind (Accessed) = A_Base_Attribute then
593
Accessed := Prefix (Accessed);
597
if Expression_Kind (Accessed) = A_Selected_Component then
598
Accessed := Selector (Accessed);
601
-- Here, we should have a plain (sub)type identifier
603
Accessed := Corresponding_Name_Declaration (Accessed);
604
if Declaration_Kind (Accessed) = An_Incomplete_Type_Declaration then
605
Accessed := Corresponding_Type_Declaration (Accessed);
608
if Declaration_Kind (Accessed) = A_Subtype_Declaration
609
and then Is_Class_Wide_Subtype (Accessed)
611
-- Annoying special case: the access type designates a subtype that names
612
-- a class-wide type. (i.e. subtype ST is T'Class; type Acc is access ST;)
613
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Class_Type));
616
-- Get rid of subtyping and derivations on the accessed type
617
-- But we may have a mixture of formal or non-formal derivations...
619
Accessed := Corresponding_First_Subtype (Accessed);
620
Def := Type_Declaration_View (Accessed);
622
in A_Derived_Type_Definition .. A_Derived_Record_Extension_Definition
624
Accessed := Corresponding_Root_Type (Def);
625
elsif Formal_Type_Kind (Def) = A_Formal_Derived_Type_Definition then
626
Accessed := Corresponding_Name_Declaration (Definitions.Subtype_Mark (Def));
632
case Declaration_Kind (Accessed) is
633
when An_Ordinary_Type_Declaration =>
634
case Type_Kind (Type_Declaration_View (Accessed)) is
635
when Not_A_Type_Definition =>
636
Failure ("Unexpected accessed type 1", Accessed);
637
when A_Tagged_Record_Type_definition
638
| A_Derived_Record_Extension_Definition
640
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Tagged_Type));
642
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Regular_Type));
644
when A_Task_Type_Declaration =>
645
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Task_Type));
646
when A_Protected_Type_Declaration =>
647
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Protected_Type));
648
when A_Private_Type_Declaration =>
649
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Regular_Type));
650
when A_Private_Extension_Declaration =>
651
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Tagged_Type));
652
when A_Formal_Type_Declaration =>
653
case Formal_Type_Kind (Type_Declaration_View (Accessed)) is
654
when Not_A_Formal_Type_Definition =>
655
Failure ("not a formal type definition");
656
when A_Formal_Derived_Type_Definition =>
657
Failure ("Unexpected formal derived type", Accessed);
658
when A_Formal_Discrete_Type_Definition
659
| A_Formal_Signed_Integer_Type_Definition
660
| A_Formal_Modular_Type_Definition
661
| A_Formal_Floating_Point_Definition
662
| A_Formal_Ordinary_Fixed_Point_Definition
663
| A_Formal_Decimal_Fixed_Point_Definition
664
| A_Formal_Access_Type_Definition
665
| A_Formal_Private_Type_Definition
666
| A_Formal_Unconstrained_Array_Definition
667
| A_Formal_Constrained_Array_Definition
669
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Regular_Type));
670
when A_Formal_Tagged_Private_Type_Definition =>
671
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Tagged_Type));
674
Failure ("Unexpected accessed type 2", Accessed);
661
case Declaration_Kind (Accessed) is
662
when An_Ordinary_Type_Declaration =>
663
case Type_Kind (Type_Declaration_View (Accessed)) is
664
when Not_A_Type_Definition =>
665
Failure ("Unexpected accessed type 1", Accessed);
666
when A_Tagged_Record_Type_Definition
667
| A_Derived_Record_Extension_Definition
669
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Tagged_Type));
671
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Regular_Type));
673
when A_Task_Type_Declaration =>
674
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Task_Type));
675
when A_Protected_Type_Declaration =>
676
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Protected_Type));
677
when A_Private_Type_Declaration =>
678
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Regular_Type));
679
when A_Private_Extension_Declaration =>
680
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Tagged_Type));
681
when A_Formal_Type_Declaration =>
682
case Formal_Type_Kind (Type_Declaration_View (Accessed)) is
683
when Not_A_Formal_Type_Definition =>
684
Failure ("not a formal type definition");
685
when A_Formal_Derived_Type_Definition =>
686
Failure ("Unexpected formal derived type", Accessed);
687
when A_Formal_Discrete_Type_Definition
688
| A_Formal_Signed_Integer_Type_Definition
689
| A_Formal_Modular_Type_Definition
690
| A_Formal_Floating_Point_Definition
691
| A_Formal_Ordinary_Fixed_Point_Definition
692
| A_Formal_Decimal_Fixed_Point_Definition
693
| A_Formal_Access_Type_Definition
694
| A_Formal_Private_Type_Definition
695
| A_Formal_Unconstrained_Array_Definition
696
| A_Formal_Constrained_Array_Definition
698
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Regular_Type));
699
when A_Formal_Tagged_Private_Type_Definition =>
700
Check ((K_All, K_Type, K_Access_Type, K_Access_To_Tagged_Type));
701
when others => -- Compatibility Ada 2005
705
Failure ("Unexpected accessed type 2", Accessed);
680
709
Failure ("Unexpected type kind: " & Type_Kinds'Wide_Image (Type_Kind (Def)));