* [Ada] Warn on slices of the form A (subtype) for all objects
@ 2020-11-26 8:41 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-11-26 8:41 UTC (permalink / raw)
To: gcc-patches; +Cc: Piotr Trojanek
[-- Attachment #1: Type: text/plain, Size: 373 bytes --]
GNAT emits a warning on slices of the form "A (subtype)" if A is a
constant; a similar warning is now emitted if A is any object, e.g.
formal parameter, loop parameter (when iterating over an
array-of-arrays) or component.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_eval.adb (Eval_Slice): Emit warning not just for
constants, but for any objects.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 405 bytes --]
diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -3961,7 +3961,7 @@ package body Sem_Eval is
T : constant Entity_Id := Etype (E);
begin
- if Ekind (E) = E_Constant
+ if Is_Object (E)
and then Is_Array_Type (T)
and then Is_Entity_Name (Drange)
then
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-26 8:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26 8:41 [Ada] Warn on slices of the form A (subtype) for all objects Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).