public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix gcc.c-torture/compile/20010605-1.c on SPARC 32-bit
@ 2009-11-10 18:01 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2009-11-10 18:01 UTC (permalink / raw)
  To: gcc-patches

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

It's a corner case: an unreachable nested function returning a variable-sized 
structure.  The DECL_RESULT of the nested function has no DECL_SIZE in this 
case (I guess that doesn't matter) and the compiler segfaults in the backend.

Tested on SPARC/Solaris 9, applied on the mainline.


2009-11-10  Eric Botcazou  <ebotcazou@adacore.com>

	* config/sparc/sparc.c (print_operand) <')'>: Test for a non-null
	DECL_SIZE of DECL_RESULT before evaluating it.


-- 
Eric Botcazou

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

Index: config/sparc/sparc.c
===================================================================
--- config/sparc/sparc.c	(revision 154059)
+++ config/sparc/sparc.c	(working copy)
@@ -6958,19 +6958,19 @@ print_operand (FILE *file, rtx x, int co
       /* Output the right displacement from the saved PC on function return.
 	 The caller may have placed an "unimp" insn immediately after the call
 	 so we have to account for it.  This insn is used in the 32-bit ABI
-	 when calling a function that returns a non zero-sized structure. The
+	 when calling a function that returns a non zero-sized structure.  The
 	 64-bit ABI doesn't have it.  Be careful to have this test be the same
-	 as that used on the call. The exception here is that when 
-	 sparc_std_struct_return is enabled, the psABI is followed exactly
-	 and the adjustment is made by the code in sparc_struct_value_rtx. 
-	 The call emitted is the same when sparc_std_struct_return is 
-	 present. */
-     if (! TARGET_ARCH64
+	 as that for the call.  The exception is when sparc_std_struct_return
+	 is enabled, the psABI is followed exactly and the adjustment is made
+	 by the code in sparc_struct_value_rtx.  The call emitted is the same
+	 when sparc_std_struct_return is enabled. */
+     if (!TARGET_ARCH64
 	 && cfun->returns_struct
-	 && ! sparc_std_struct_return
-	 && (TREE_CODE (DECL_SIZE (DECL_RESULT (current_function_decl)))
-	     == INTEGER_CST)
-	 && ! integer_zerop (DECL_SIZE (DECL_RESULT (current_function_decl))))
+	 && !sparc_std_struct_return
+	 && DECL_SIZE (DECL_RESULT (current_function_decl))
+	 && TREE_CODE (DECL_SIZE (DECL_RESULT (current_function_decl)))
+	     == INTEGER_CST
+	 && !integer_zerop (DECL_SIZE (DECL_RESULT (current_function_decl))))
 	fputs ("12", file);
       else
         fputc ('8', file);

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

only message in thread, other threads:[~2009-11-10 17:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-10 18:01 Fix gcc.c-torture/compile/20010605-1.c on SPARC 32-bit Eric Botcazou

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