public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Crash processing Valid_Scalars whose evaluation is always true
@ 2018-05-23 10:34 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2018-05-23 10:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: Javier Miranda

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

The compiler blows up generating code associated with occurrences of attribute
Valid_Scalars whose evaluation is always true. After this patch the following
test compiles fine.

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

2018-05-23  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* sem_attr.adb (Valid_Scalars): Do not invoke Error_Attr_P to report
	the warning on occurrences of this attribute whose evaluation is always
	true (since that subprogram aborts processing the attribute). In
	addition, replace the node by its boolean result 'True' (required
	because the backend has no knowledge of this attribute).

gcc/testsuite/

	* gnat.dg/valid_scalars1.adb: New testcase.

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

--- gcc/ada/sem_attr.adb
+++ gcc/ada/sem_attr.adb
@@ -6929,8 +6929,10 @@ package body Sem_Attr is
 
             else
                if not Scalar_Part_Present (P_Type) then
-                  Error_Attr_P
-                    ("??attribute % always True, no scalars to check");
+                  Error_Msg_Name_1 := Aname;
+                  Error_Msg_F
+                    ("??attribute % always True, no scalars to check", P);
+                  Set_Boolean_Result (N, True);
                end if;
 
                --  Attribute 'Valid_Scalars is illegal on unchecked union types

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/valid_scalars1.adb
@@ -0,0 +1,11 @@
+--  { dg-do compile }
+--  { dg-options "-gnata -gnatws" }
+
+procedure Valid_Scalars1 is
+   type Ptr is access Integer;
+   V1 : Ptr;
+
+   Check : Boolean := V1'Valid_Scalars;
+begin
+   pragma Assert (Check);
+end;


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

only message in thread, other threads:[~2018-05-23 10:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-23 10:34 [Ada] Crash processing Valid_Scalars whose evaluation is always true 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).