Commit 026733d8 by Javier Miranda Committed by Pierre-Marie de Rodat

[Ada] Crash processing Valid_Scalars whose evaluation is always true

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.

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.

From-SVN: r260591
parent aeaa0347
2018-05-23 Javier Miranda <miranda@adacore.com>
* 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).
2018-05-23 Bob Duff <duff@adacore.com> 2018-05-23 Bob Duff <duff@adacore.com>
* libgnat/a-convec.adb: (Insert, Insert_Space): Suppress warnings. The * libgnat/a-convec.adb: (Insert, Insert_Space): Suppress warnings. The
......
...@@ -6929,8 +6929,10 @@ package body Sem_Attr is ...@@ -6929,8 +6929,10 @@ package body Sem_Attr is
else else
if not Scalar_Part_Present (P_Type) then if not Scalar_Part_Present (P_Type) then
Error_Attr_P Error_Msg_Name_1 := Aname;
("??attribute % always True, no scalars to check"); Error_Msg_F
("??attribute % always True, no scalars to check", P);
Set_Boolean_Result (N, True);
end if; end if;
-- Attribute 'Valid_Scalars is illegal on unchecked union types -- Attribute 'Valid_Scalars is illegal on unchecked union types
......
2018-05-23 Javier Miranda <miranda@adacore.com>
* gnat.dg/valid_scalars1.adb: New testcase.
2018-05-23 Ed Schonberg <schonberg@adacore.com> 2018-05-23 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/iter1.adb, gnat.dg/iter1.ads: New testcase. * gnat.dg/iter1.adb, gnat.dg/iter1.ads: New testcase.
......
-- { 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment