The compiler currently issues a warning/error mentioning a variable "frame",
which is not very user-friendly. This is changed to using the same wording as
frame_offset_overflow, i.e. "total size of local objects".
Tested on x86-64/Linux, applied on the mainline as obvious.
Btw, in most cases, the compiler now issues both a warning and an error when a
variable has too large a size. What's the rationale for this oddity? IMO it
needs to make a choice here, it's either a warning or an error.
2018-10-19 Eric Botcazou <ebotca...@adacore.com>
* cfgexpand.c (expand_one_var): Use specific wording in error message
for non-local frame variables.
* stor-layout.c (layout_decl): Do not issue a warning for them.
2018-10-19 Eric Botcazou <ebotca...@adacore.com>
* gnat.dg/frame_overflow2.adb: New test.
--
Eric Botcazou
Index: cfgexpand.c
===================================================================
--- cfgexpand.c (revision 265259)
+++ cfgexpand.c (working copy)
@@ -1674,7 +1674,12 @@ expand_one_var (tree var, bool toplevel,
/* Reject variables which cover more than half of the address-space. */
if (really_expand)
{
- error ("size of variable %q+D is too large", var);
+ if (DECL_NONLOCAL_FRAME (var))
+ error_at (DECL_SOURCE_LOCATION (current_function_decl),
+ "total size of local objects is too large");
+ else
+ error_at (DECL_SOURCE_LOCATION (var),
+ "size of variable %q+D is too large", var);
expand_one_error_var (var);
}
}
Index: stor-layout.c
===================================================================
--- stor-layout.c (revision 265259)
+++ stor-layout.c (working copy)
@@ -755,8 +755,8 @@ layout_decl (tree decl, unsigned int kno
DECL_SIZE_UNIT (decl) = variable_size (DECL_SIZE_UNIT (decl));
/* If requested, warn about definitions of large data objects. */
- if ((code == VAR_DECL || code == PARM_DECL)
- && ! DECL_EXTERNAL (decl))
+ if ((code == PARM_DECL || (code == VAR_DECL && !DECL_NONLOCAL_FRAME (decl)))
+ && !DECL_EXTERNAL (decl))
{
tree size = DECL_SIZE_UNIT (decl);
-- { dg-do compile }
with System;
procedure Frame_Overflow2 is -- { dg-error "too large" }
type Index_T is range 1 .. 2**(System.Word_Size - 1) - 1;
type SetArray is array (Index_T) of Boolean;
type Set is record
Store: SetArray := (Others => False);
end record;
Phi: constant Set := (Store => (Others => False));
function F return Set is
begin
return Phi;
end;
begin
null;
end;