aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2019-07-22 13:57:51 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-22 13:57:51 +0000
commit8c029ee8cf5d14e8c0dc0a74d9a5278c3aee49e9 (patch)
treebe97ea27ba1cc2459f91ff6d462cf35ca3ce0519 /gcc/ada
parent22862ba6d688c95d9f9577746d212183a11c44da (diff)
downloadgcc-8c029ee8cf5d14e8c0dc0a74d9a5278c3aee49e9.zip
gcc-8c029ee8cf5d14e8c0dc0a74d9a5278c3aee49e9.tar.gz
gcc-8c029ee8cf5d14e8c0dc0a74d9a5278c3aee49e9.tar.bz2
[Ada] Misleading warning on variable not assigned
This patch removes a warning on a referenced entity with no explicit prior assignment, if the type of the entity has Preelaborable_Initialixation, such as Exception_Occurrence. 2019-07-22 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_warn.adb (Check_References): Do not emit s warning on a referenced entity with no explicit assignment if the type of the entity has Preelaborable_Initialixation, such as Exception_Occurrence. gcc/testsuite/ * gnat.dg/warn25.adb: New testcase. From-SVN: r273686
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/sem_warn.adb8
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index ac990be..12ea5ad 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2019-07-22 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_warn.adb (Check_References): Do not emit s warning on a
+ referenced entity with no explicit assignment if the type of the
+ entity has Preelaborable_Initialixation, such as
+ Exception_Occurrence.
+
2019-07-22 Javier Miranda <miranda@adacore.com>
* exp_ch4.adb (Size_In_Storage_Elements): Improve the expansion
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index 0e1e292..ab85162 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1413,9 +1413,13 @@ package body Sem_Warn is
goto Continue;
end if;
- -- Check for unset reference
+ -- Check for unset reference. If type of object has
+ -- preelaborable initialization, warning is misleading.
- if Warn_On_No_Value_Assigned and then Present (UR) then
+ if Warn_On_No_Value_Assigned
+ and then Present (UR)
+ and then not Known_To_Have_Preelab_Init (Etype (E1))
+ then
-- For other than access type, go back to original node to
-- deal with case where original unset reference has been