# # Submitted-By: Robert Schwebel, 2006-12-04 # Committed-By: Robert Schwebel # # Description: # # See PR28516 for this fix. Note that, if this patch is applied, we also need # http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/config/tc-arm.c.diff?r1=1.292&r2=1.293&cvsroot=src # # State: # # fixed # gcc/config/arm/arm.c | 9 +++++++++ gcc/testsuite/gcc.dg/nested-func-5.c | 13 +++++++++++++ 2 files changed, 22 insertions(+) Index: gcc-4.1.2/gcc/config/arm/arm.c =================================================================== --- gcc-4.1.2.orig/gcc/config/arm/arm.c +++ gcc-4.1.2/gcc/config/arm/arm.c @@ -15371,6 +15371,15 @@ arm_unwind_emit_set (FILE * asm_out_file /* Move from sp to reg. */ asm_fprintf (asm_out_file, "\t.movsp %r\n", REGNO (e0)); } + else if (GET_CODE (e1) == PLUS + && GET_CODE (XEXP (e1, 0)) == REG + && REGNO (XEXP (e1, 0)) == SP_REGNUM + && GET_CODE (XEXP (e1, 1)) == CONST_INT) + { + /* Set reg to offset from sp. */ + asm_fprintf (asm_out_file, "\t.movsp %r, #%d\n", + REGNO (e0), (int)INTVAL(XEXP (e1, 1))); + } else abort (); break; Index: gcc-4.1.2/gcc/testsuite/gcc.dg/nested-func-5.c =================================================================== --- /dev/null +++ gcc-4.1.2/gcc/testsuite/gcc.dg/nested-func-5.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-fexceptions" } */ +/* PR28516: ICE generating ARM unwind directives for nested functions. */ + +void ex(int (*)(void)); +void foo(int i) +{ + int bar(void) + { + return i; + } + ex(bar); +}