Patchwork [avr] Fix PR57631: Check ISR's asm name rather than C name

login
register
mail settings
Submitter Georg-Johann Lay
Date July 10, 2013, 1:26 p.m.
Message ID <51DD611A.2040106@gjlay.de>
Download mbox | patch
Permalink /patch/258050/
State New
Headers show

Comments

Georg-Johann Lay - July 10, 2013, 1:26 p.m.
This change has been proposed so that the sanity checking of ISR
(signal,interrupt) functions tests the asm function name if available, not the
C name.

Okay to apply?

Johann

gcc/
	PR target/57631
	* config/avr/avr.c (avr_set_current_function): Sanity-check signal
	name seen by assembler/linker rather if available.

gcc/testsuite/
	PR target/57631
	* gcc.target/avr/torture/pr57631.c: New test.
Denis Chertykov - July 10, 2013, 5:37 p.m.
2013/7/10 Georg-Johann Lay <avr@gjlay.de>:
> This change has been proposed so that the sanity checking of ISR
> (signal,interrupt) functions tests the asm function name if available, not the
> C name.
>
> Okay to apply?
>
> Johann
>
> gcc/
>         PR target/57631
>         * config/avr/avr.c (avr_set_current_function): Sanity-check signal
>         name seen by assembler/linker rather if available.
>
> gcc/testsuite/
>         PR target/57631
>         * gcc.target/avr/torture/pr57631.c: New test.

Approved.

Denis.

Patch

Index: config/avr/avr.c
===================================================================
--- config/avr/avr.c	(revision 200872)
+++ config/avr/avr.c	(working copy)
@@ -584,7 +584,12 @@  avr_set_current_function (tree decl)
     {
       tree args = TYPE_ARG_TYPES (TREE_TYPE (decl));
       tree ret = TREE_TYPE (TREE_TYPE (decl));
-      const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
+      const char *name;
+
+      name = DECL_ASSEMBLER_NAME_SET_P (decl)
+        /* Remove the leading '*' added in set_user_assembler_name.  */
+        ? 1 + IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))
+        : IDENTIFIER_POINTER (DECL_NAME (decl));
 
       /* Silently ignore 'signal' if 'interrupt' is present.  AVR-LibC startet
          using this when it switched from SIGNAL and INTERRUPT to ISR.  */
Index: testsuite/gcc.target/avr/torture/pr57631.c
===================================================================
--- testsuite/gcc.target/avr/torture/pr57631.c	(revision 0)
+++ testsuite/gcc.target/avr/torture/pr57631.c	(revision 0)
@@ -0,0 +1,17 @@ 
+/* PR target/57631 */
+/* { dg-do compile } */
+
+void __attribute__((signal)) func1 (void) __asm ("__vector1");
+void func1  (void)
+{
+}
+
+void __attribute__((signal)) func2 (void)  __asm ("__vecto1");
+void func2  (void) /* { dg-warning "misspelled signal handler" } */
+{
+}
+
+void __attribute__((signal)) __vector_3 (void)  __asm ("__vecto1");
+void __vector_3 (void) /* { dg-warning "misspelled signal handler" } */
+{
+}