From: Georg-Johann Lay Date: Wed, 12 Jul 2017 15:25:07 +0000 (+0000) Subject: re PR target/79883 (avr i18n: untranslated "interrupt" or "signal") X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1bde114aaceb7f423aaafbc62df6e5ba51a15b27;p=gcc.git re PR target/79883 (avr i18n: untranslated "interrupt" or "signal") PR target/79883 * config/avr/avr.c (avr_set_current_function): In diagnostic messages: Quote keywords and (parts of) identifiers. [WITH_AVRLIBC]: Warn for functions named "ISR", "SIGNAL" or "INTERUPT". From-SVN: r250156 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5803941b1a..bdf6e45d849 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-07-12 Georg-Johann Lay + + PR target/79883 + * config/avr/avr.c (avr_set_current_function): In diagnostic + messages: Quote keywords and (parts of) identifiers. + [WITH_AVRLIBC]: Warn for functions named "ISR", "SIGNAL" or + "INTERUPT". + 2017-07-12 Carl Love * config/rs6000/rs6000-c.c: Add support for built-in functions diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index a8978ec84ff..49ebb6352a2 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -1076,12 +1076,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) @@ -1090,14 +1084,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, OPT_Wmisspelled_isr, "%qs appears to be a misspelled " - "%s handler, missing __vector prefix", name, isr); + "%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 %>" + " before using the %qs macro", name, name); } +#endif // AVR-LibC naming conventions /* Don't print the above diagnostics more than once. */