diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-06-11 14:22:57 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-06-11 14:22:57 +0200 |
commit | 2c8d828a5fc1c18ef630ea45ce1ff13638d97918 (patch) | |
tree | 645544f68c75c182b632092acdfbe2feee66f73d /gcc/ada/sem_warn.adb | |
parent | 4622301b0dd6b595d51be6a6b9e39b177d0abb6a (diff) | |
download | gcc-2c8d828a5fc1c18ef630ea45ce1ff13638d97918.zip gcc-2c8d828a5fc1c18ef630ea45ce1ff13638d97918.tar.gz gcc-2c8d828a5fc1c18ef630ea45ce1ff13638d97918.tar.bz2 |
[multiple changes]
2014-06-11 Yannick Moy <moy@adacore.com>
* einfo.ads: Minor typo in comment
2014-06-11 Ed Schonberg <schonberg@adacore.com>
* sinfo.ads, sinfo.adb: New attribute Uninitialized_Variable, for
formal private types and private type extensions, to indicate
variable in a generic unit whose uninitialized use suggest that
actual type should be fully initialized.
Needs_Initialized_Actual: removed, functionaity replaced by
the above.
* lib-xref.adb (Generate_Reference): Generate a reference for
variables of a formal type when the unit is not the main unit,
to enable appropriate warnings in an instance.
* sem_ch12.adb (Check_Ininialized_Type): Improve warning on use
of variable in a generic unit that suggests that actual type
should be full initialized.
* sem_warn.adb; (May_Need_Initialized_Actual): Make into procedure
and do not emot warning, which now only appears in an instance.
2014-06-11 Eric Botcazou <ebotcazou@adacore.com>
* gnat_ugn.texi: Fix minor typo.
2014-06-11 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch3.adb Add with and use clause for Sem_Ch10.
(Analyze_Declarations): Code reformatting. Analyze the contract
of a subprogram body stub at the end of the declarative region.
* sem_ch6.adb (Analyze_Subprogram_Body_Contract): Spec_Id is
now a variable. Do not process the body if its contract is not
available. Account for subprogram body stubs when extracting
the corresponding spec.
* sem_ch6.ads (Analyze_Subprogram_Contract): Update the comment
on usage.
* sem_ch10.ads, sem_ch10.adb (Analyze_Subprogram_Body_Stub_Contract):
New routine.
* sem_prag.adb (Analyze_Depends_In_Decl_Part):
Account for subprogram body stubs when extracting the
corresponding spec.
(Analyze_Global_In_Decl_List):
Account for subprogram body stubs when extracting the
corresponding spec.
(Analyze_Refined_Depends_In_Decl_Part):
Use Find_Related_Subprogram_Or_Body to retrieve the declaration
of the related body. Spec_Is now a variable. Account for
subprogram body stubs when extracting the corresponding spec.
(Analyze_Refined_Global_In_Decl_Part): Use
Find_Related_Subprogram_Or_Body to retrieve the declaration
of the related body. Spec_Is now a variable. Account for
subprogram body stubs when extracting the corresponding spec.
(Collect_Subprogram_Inputs_Output): Account for subprogram body
stubs when extracting the corresponding spec.
2014-06-11 Vincent Celier <celier@adacore.com>
* gnatcmd.adb (Process_Link): Do not invoke gnatlink with
-lgnarl or -lgnat.
From-SVN: r211454
Diffstat (limited to 'gcc/ada/sem_warn.adb')
-rw-r--r-- | gcc/ada/sem_warn.adb | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 9d63668..cc4337f 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -762,13 +762,14 @@ package body Sem_Warn is -- For an entry formal entity from an entry declaration, find the -- corresponding body formal from the given accept statement. - function May_Need_Initialized_Actual (Ent : Entity_Id) return Boolean; + procedure May_Need_Initialized_Actual (Ent : Entity_Id); -- If an entity of a generic type has default initialization, then the -- corresponding actual type should be fully initialized, or else there -- will be uninitialized components in the instantiation, that might go - -- unreported. This predicate allows the compiler to emit an appropriate - -- warning in the generic itself. In a sense, the use of a type that - -- requires full initialization is a weak part of the generic contract. + -- unreported. This routine marks the type of the uninitialized variable + -- appropriately to allow the compiler to emit an appropriate warning + -- in the instance. In a sense, the use of a type that requires full + -- initialization is a weak part of the generic contract. function Missing_Subunits return Boolean; -- We suppress warnings when there are missing subunits, because this @@ -823,38 +824,30 @@ package body Sem_Warn is -- May_Need_Initialized_Actual -- ----------------------------------- - function May_Need_Initialized_Actual (Ent : Entity_Id) return Boolean is + procedure May_Need_Initialized_Actual (Ent : Entity_Id) is T : constant Entity_Id := Etype (Ent); Par : constant Node_Id := Parent (T); - Res : Boolean; begin if not Is_Generic_Type (T) then - Res := False; + null; elsif (Nkind (Par)) = N_Private_Extension_Declaration then - Set_Needs_Initialized_Actual (Par); - Res := True; + + -- We only indicate the first such variable in the generic. + + if No (Uninitialized_Variable (Par)) then + Set_Uninitialized_Variable (Par, Ent); + end if; elsif (Nkind (Par)) = N_Formal_Type_Declaration and then Nkind (Formal_Type_Definition (Par)) = N_Formal_Private_Type_Definition then - Set_Needs_Initialized_Actual (Formal_Type_Definition (Par)); - Res := True; - - else - Res := False; - end if; - - if Res then - Error_Msg_N ("??!variable& of a generic type is potentially " - & "uninitialized", Ent); - Error_Msg_NE ("\??instantiations must provide fully initialized " - & "type for&", Ent, T); + if No (Uninitialized_Variable (Formal_Type_Definition (Par))) then + Set_Uninitialized_Variable (Formal_Type_Definition (Par), Ent); + end if; end if; - - return Res; end May_Need_Initialized_Actual; ---------------------- @@ -1305,10 +1298,10 @@ package body Sem_Warn is if not Has_Unmodified (E1) and then not Warnings_Off_E1 and then not Is_Junk_Name (Chars (E1)) - and then not May_Need_Initialized_Actual (E1) then Output_Reference_Error ("?v?variable& is read but never assigned!"); + May_Need_Initialized_Actual (E1); end if; elsif not Has_Unreferenced (E1) |