diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2017-07-26 14:58:42 +0000 |
---|---|---|
committer | Georg-Johann Lay <avr@gjlay.de> | 2017-07-26 14:58:42 +0000 |
commit | 035410cdeee29e3577dc2f2aab38d2b4c9389f6c (patch) | |
tree | 972840d78756fbe7ca8193251b3d0891b4276ba8 | |
parent | 61062f9782283e0614e8c05aaa6db73cadb8e46b (diff) |
gcc/
Backport from 2016-06-15 trunk r237486.
Backport from 2017-07-12 trunk r250156.
PR target/79883
PR target/67353
* config/avr/avr.c (avr_set_current_function): Warn misspelled ISR
only if -Wmisspelled-isr is on. In diagnostic messages: Quote
keywords and (parts of) identifiers.
[WITH_AVRLIBC]: Warn functions named "ISR", "SIGNAL" or "INTERUPT".
* doc/invoke.texi (AVR Options) <-Wmisspelled-isr>: Decument.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@250577 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/config/avr/avr.c | 32 | ||||
-rw-r--r-- | gcc/config/avr/avr.opt | 4 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 10 |
4 files changed, 49 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ad7a2e8f5a9..9840285f71e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,18 @@ 2017-07-26 Georg-Johann Lay <avr@gjlay.de> + Backport from 2016-06-15 trunk r237486. + Backport from 2017-07-12 trunk r250156. + + PR target/79883 + PR target/67353 + * config/avr/avr.c (avr_set_current_function): Warn misspelled ISR + only if -Wmisspelled-isr is on. In diagnostic messages: Quote + keywords and (parts of) identifiers. + [WITH_AVRLIBC]: Warn functions named "ISR", "SIGNAL" or "INTERUPT". + * doc/invoke.texi (AVR Options) <-Wmisspelled-isr>: Decument. + +2017-07-26 Georg-Johann Lay <avr@gjlay.de> + Backport from 2017-07-05 trunk r249995. PR target/81305 diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index e27cecaee66..3fdd5fd33b9 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -735,12 +735,6 @@ avr_set_current_function (tree decl) name = default_strip_name_encoding (name); - /* Silently ignore 'signal' if 'interrupt' is present. AVR-LibC startet - using this when it switched from SIGNAL and INTERRUPT to ISR. */ - - if (cfun->machine->is_interrupt) - cfun->machine->is_signal = 0; - /* Interrupt handlers must be void __vector (void) functions. */ if (args && TREE_CODE (TREE_VALUE (args)) != VOID_TYPE) @@ -749,14 +743,36 @@ avr_set_current_function (tree decl) if (TREE_CODE (ret) != VOID_TYPE) error_at (loc, "%qs function cannot return a value", isr); +#if defined WITH_AVRLIBC + /* Silently ignore 'signal' if 'interrupt' is present. AVR-LibC startet + using this when it switched from SIGNAL and INTERRUPT to ISR. */ + + if (cfun->machine->is_interrupt) + cfun->machine->is_signal = 0; + /* If the function has the 'signal' or 'interrupt' attribute, ensure that the name of the function is "__vector_NN" so as to catch when the user misspells the vector name. */ if (!STR_PREFIX_P (name, "__vector")) - warning_at (loc, 0, "%qs appears to be a misspelled %s handler", - name, isr); + warning_at (loc, OPT_Wmisspelled_isr, "%qs appears to be a misspelled " + "%qs handler, missing %<__vector%> prefix", name, isr); +#endif // AVR-LibC naming conventions + } + +#if defined WITH_AVRLIBC + // Common problem is using "ISR" without first including avr/interrupt.h. + const char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); + name = default_strip_name_encoding (name); + if (0 == strcmp ("ISR", name) + || 0 == strcmp ("INTERRUPT", name) + || 0 == strcmp ("SIGNAL", name)) + { + warning_at (loc, OPT_Wmisspelled_isr, "%qs is a reserved indentifier" + " in AVR-LibC. Consider %<#include <avr/interrupt.h>%>" + " before using the %qs macro", name, name); } +#endif // AVR-LibC naming conventions /* Don't print the above diagnostics more than once. */ diff --git a/gcc/config/avr/avr.opt b/gcc/config/avr/avr.opt index 8809b9b0cff..05aa4b6db98 100644 --- a/gcc/config/avr/avr.opt +++ b/gcc/config/avr/avr.opt @@ -91,6 +91,10 @@ Waddr-space-convert Warning C Report Var(avr_warn_addr_space_convert) Init(0) Warn if the address space of an address is changed. +Wmisspelled-isr +Warning C C++ Report Var(avr_warn_misspelled_isr) Init(1) +Warn if the ISR is misspelled, i.e. without __vector prefix. Enabled by default. + mfract-convert-truncate Target Report Mask(FRACT_CONV_TRUNC) Allow to use truncation instead of rounding towards 0 for fractional int types. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 84a7cf885fa..b066f7bd419 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -637,7 +637,8 @@ Objective-C and Objective-C++ Dialects}. @emph{AVR Options} @gccoptlist{-mmcu=@var{mcu} -maccumulate-args -mbranch-cost=@var{cost} @gol -mcall-prologues -mint8 -mn_flash=@var{size} -mno-interrupts @gol --mrelax -mrmw -mstrict-X -mtiny-stack -nodevicelib -Waddr-space-convert} +-mrelax -mrmw -mstrict-X -mtiny-stack -nodevicelib -Waddr-space-convert @gol +-Wmisspelled-isr} @emph{Blackfin Options} @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol @@ -14449,12 +14450,17 @@ Only change the lower 8@tie{}bits of the stack pointer. @item -nodevicelib @opindex nodevicelib -Don't link against AVR-LibC's device specific library @code{libdev.a}. +Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}. @item -Waddr-space-convert @opindex Waddr-space-convert Warn about conversions between address spaces in the case where the resulting address space is not contained in the incoming address space. + +@item -Wmisspelled-isr +@opindex Wmisspelled-isr +Warn if the ISR is misspelled, i.e. without @code{__vector} prefix. +Enabled by default. @end table @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash |