diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-05-21 15:14:06 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-05-21 15:14:06 +0200 |
commit | c8a3028c36d9c8fd7f6f07b8571e6db0db337616 (patch) | |
tree | aba9b3d524f3a98dd1c9d5af5b483425554a6a99 /gcc/ada/sem_warn.adb | |
parent | 23e28b42173b30e3ebe2b8e5765b01dc7fd60da2 (diff) | |
download | gcc-c8a3028c36d9c8fd7f6f07b8571e6db0db337616.zip gcc-c8a3028c36d9c8fd7f6f07b8571e6db0db337616.tar.gz gcc-c8a3028c36d9c8fd7f6f07b8571e6db0db337616.tar.bz2 |
[multiple changes]
2014-05-21 Robert Dewar <dewar@adacore.com>
* sem_elab.adb: Minor reformatting.
* s-taprop.ads: Minor comment fix.
* sem_ch8.adb (Analyze_Subprogram_Renaming): Remove call to
Kill_Elaboration_Checks.
* errout.adb, erroutc.adb: Minor reformatting.
2014-05-21 Thomas Quinot <quinot@adacore.com>
* exp_pakd.adb (Byte_Swap): Handle the case of a sub-byte
component. No byte swapping occurs, but this procedure also takes
care of appropriately justifying the argument.
2014-05-21 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch6.adb: sem_ch6.adb (Analyze_Aspects_On_Body_Or_Stub):
New routine.
(Analyze_Subprogram_Body_Helper): Move the
analysis of aspect specifications and the processing of the
subprogram body contract after inlining has taken place.
(Diagnose_Misplaced_Aspect_Specifications): Removed.
2014-05-21 Javier Miranda <miranda@adacore.com>
* sem_ch3.adb (Build_Derived_Record_Type): Revert previous change.
2014-05-21 Robert Dewar <dewar@adacore.com>
* sem_eval.ads, sem_eval.adb (Why_Not_Static): Messages are not
continuations any more.
2014-05-21 Ed Schonberg <schonberg@adacore.com>
* sinfo.ads, sinfo.adb: New flag Needs_Initialized_Actual,
present in formal_Private_Definitions and on private extension
declarations of a formal derived type. Set when the use of the
formal type in a generic suggests that the actual should be a
fully initialized type.
* sem_warn.adb (May_Need_Initialized_Actual): new subprogram
to indicate that an entity of a generic type has default
initialization, and that the corresponing actual type in any
subsequent instantiation should be fully initialized.
* sem_ch12.adb (Check_Initialized_Type): new subprogram,
to emit a warning if the actual for a generic type on which
Needs_Initialized_Actual is set is not a fully initialized type.
From-SVN: r210705
Diffstat (limited to 'gcc/ada/sem_warn.adb')
-rw-r--r-- | gcc/ada/sem_warn.adb | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index e73a54e..012345e 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1999-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1999-2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -766,6 +766,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; + -- 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. + function Missing_Subunits return Boolean; -- We suppress warnings when there are missing subunits, because this -- may generate too many false positives: entities in a parent may only @@ -815,6 +823,44 @@ package body Sem_Warn is raise Program_Error; end Body_Formal; + ----------------------------------- + -- May_Need_Initialized_Actual -- + ----------------------------------- + + function May_Need_Initialized_Actual (Ent : Entity_Id) return Boolean 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; + + elsif (Nkind (Par)) = N_Private_Extension_Declaration then + Set_Needs_Initialized_Actual (Par); + Res := True; + + 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); + end if; + + return Res; + end May_Need_Initialized_Actual; + ---------------------- -- Missing_Subunits -- ---------------------- @@ -1266,6 +1312,7 @@ 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!"); @@ -1274,6 +1321,7 @@ package body Sem_Warn is elsif not Has_Unreferenced (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 -- CODEFIX ("?v?variable& is never read and never assigned!"); @@ -1403,6 +1451,7 @@ package body Sem_Warn is end if; goto Continue; + end if; end if; |