public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Spurious error on 'Image
@ 2021-04-29  8:03 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-04-29  8:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: Arnaud Charlet

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

As part of recent improvements related to discriminant checks, a
regression was introduced in complex cases of generics and use of 'Image
on an expression partially rewritten as a [raise Constraint_Error] node.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_attr.adb (Check_Image_Type): Protect against empty
	Image_Type.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 623 bytes --]

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -1466,7 +1466,11 @@ package body Sem_Attr is
 
          procedure Check_Image_Type (Image_Type : Entity_Id) is
          begin
+            --  Image_Type may be empty in case of another error detected,
+            --  or if an N_Raise_xxx_Error node is a parent of N.
+
             if Ada_Version < Ada_2020
+              and then Present (Image_Type)
               and then not Is_Scalar_Type (Image_Type)
             then
                Error_Msg_Ada_2020_Feature ("nonscalar ''Image", Sloc (P));



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-29  8:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29  8:03 [Ada] Spurious error on 'Image 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).