diff mbox series

Improve wording for error on too large non-local frames

Message ID 1610608.5eqqG9iB4r@polaris
State New
Headers show
Series Improve wording for error on too large non-local frames | expand

Commit Message

Eric Botcazou Oct. 19, 2018, 7:18 a.m. UTC
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  <ebotcazou@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  <ebotcazou@adacore.com>

	* gnat.dg/frame_overflow2.adb: New test.
diff mbox series

Patch

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);