diff mbox

Fix wrong code with discriminated type in Ada at -Os

Message ID 2967279.CmmVPkUtd1@polaris
State New
Headers show

Commit Message

Eric Botcazou Oct. 15, 2014, 10:18 a.m. UTC
This is a regression present on all active branches which comes from an 
oversight in self_referential_size: the code sets DECL_ARG_TYPE of the 
parameters it builds as the C/C++/Ada compilers but it doesn't generate the 
associated conversions in the GENERIC code, which later fools the combiner.

The original idea was to mimic the C/C++/Ada compilers here, but the actual 
conversions have never been generated and the size functions are meant to be 
inlined anyway, so the attached patch simply removes the problematic code.

Tested on x86_64-suse-linux, applied on all active branches (this only affects 
the Ada compiler).


2014-10-15  Eric Botcazou  <ebotcazou@adacore.com>

	* stor-layout.c (self_referential_size): Do not promote arguments.


2014-10-15  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/opt41.adb: New test.
	* gnat.dg/opt41_pkg.ad[sb]: New helper.
diff mbox

Patch

Index: stor-layout.c
===================================================================
--- stor-layout.c	(revision 216144)
+++ stor-layout.c	(working copy)
@@ -211,12 +211,7 @@  self_referential_size (tree size)
       param_type = TREE_TYPE (ref);
       param_decl
 	= build_decl (input_location, PARM_DECL, param_name, param_type);
-      if (targetm.calls.promote_prototypes (NULL_TREE)
-	  && INTEGRAL_TYPE_P (param_type)
-	  && TYPE_PRECISION (param_type) < TYPE_PRECISION (integer_type_node))
-	DECL_ARG_TYPE (param_decl) = integer_type_node;
-      else
-	DECL_ARG_TYPE (param_decl) = param_type;
+      DECL_ARG_TYPE (param_decl) = param_type;
       DECL_ARTIFICIAL (param_decl) = 1;
       TREE_READONLY (param_decl) = 1;