From a713b234edc3b9e76c9abc593a5872415d7d225a Mon Sep 17 00:00:00 2001 From: Joe Seymour Date: Tue, 13 Sep 2016 20:06:47 +0000 Subject: [PATCH] re PR target/70713 (msp430 interrupt attribute prevents overriding weak symbols) 2016-09-13 Joe Seymour gcc/ PR target/70713 * config/msp430/msp430.c (msp430_start_function): Emit an error if a function is both weak and specifies an interrupt number. gcc/testsuite/ PR target/70713 * gcc.target/msp430/function-attributes-1.c: New test. * gcc.target/msp430/function-attributes-2.c: New test. * gcc.target/msp430/function-attributes-3.c: New test. From-SVN: r240123 --- gcc/ChangeLog | 6 ++++++ gcc/config/msp430/msp430.c | 7 +++++++ gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.target/msp430/function-attributes-1.c | 9 +++++++++ gcc/testsuite/gcc.target/msp430/function-attributes-2.c | 3 +++ gcc/testsuite/gcc.target/msp430/function-attributes-3.c | 3 +++ 6 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/gcc.target/msp430/function-attributes-1.c create mode 100644 gcc/testsuite/gcc.target/msp430/function-attributes-2.c create mode 100644 gcc/testsuite/gcc.target/msp430/function-attributes-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 82034a9..ef690e4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-09-13 Joe Seymour + + PR target/70713 + * config/msp430/msp430.c (msp430_start_function): Emit an error + if a function is both weak and specifies an interrupt number. + 2016-09-13 Jakub Jelinek PR tree-optimization/77454 diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index dba4d19..c40d2da 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -2108,6 +2108,13 @@ msp430_start_function (FILE *file, const char *name, tree decl) { char buf[101]; + /* Interrupt vector sections should be unique, but use of weak + functions implies multiple definitions. */ + if (DECL_WEAK (decl)) + { + error ("argument to interrupt attribute is unsupported for weak functions"); + } + intr_vector = TREE_VALUE (intr_vector); /* The interrupt attribute has a vector value. Turn this into a diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 779145a..39de996 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2016-09-13 Joe Seymour + + PR target/70713 + * gcc.target/msp430/function-attributes-1.c: New test. + * gcc.target/msp430/function-attributes-2.c: New test. + * gcc.target/msp430/function-attributes-3.c: New test. + 2016-09-13 Jakub Jelinek * g++.dg/cpp0x/gen-attrs-61.C: New test. diff --git a/gcc/testsuite/gcc.target/msp430/function-attributes-1.c b/gcc/testsuite/gcc.target/msp430/function-attributes-1.c new file mode 100644 index 0000000..7a3b7be --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/function-attributes-1.c @@ -0,0 +1,9 @@ +void __attribute__((weak, interrupt)) +weak_interrupt (void) { +} + +void __attribute__((interrupt(11))) +interrupt_number (void) { +} + +/* { dg-final { scan-assembler-times "__interrupt_vector_" 1 } } */ diff --git a/gcc/testsuite/gcc.target/msp430/function-attributes-2.c b/gcc/testsuite/gcc.target/msp430/function-attributes-2.c new file mode 100644 index 0000000..fcb2fb2 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/function-attributes-2.c @@ -0,0 +1,3 @@ +void __attribute__((weak, interrupt(10))) +weak_interrupt_number (void) { +} /* { dg-error "argument to interrupt attribute is unsupported for weak functions" } */ diff --git a/gcc/testsuite/gcc.target/msp430/function-attributes-3.c b/gcc/testsuite/gcc.target/msp430/function-attributes-3.c new file mode 100644 index 0000000..b0acf4a --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/function-attributes-3.c @@ -0,0 +1,3 @@ +void __attribute__((interrupt("nmi"))) __attribute__((weak)) +interrupt_name_weak (void) { +} /* { dg-error "argument to interrupt attribute is unsupported for weak functions" } */ -- 2.7.4