]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/79883 (avr i18n: untranslated "interrupt" or "signal")
authorGeorg-Johann Lay <avr@gjlay.de>
Tue, 22 Aug 2017 09:48:48 +0000 (09:48 +0000)
committerGeorg-Johann Lay <gjl@gcc.gnu.org>
Tue, 22 Aug 2017 09:48:48 +0000 (09:48 +0000)
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>: Document.

From-SVN: r251269

gcc/ChangeLog
gcc/config/avr/avr.c
gcc/config/avr/avr.opt
gcc/doc/invoke.texi

index 7928130304b19ef7cd8883be949e34dc4a29153c..62bb658bf19da53911838cce44b14ef81763e0cd 100644 (file)
@@ -1,3 +1,16 @@
+2017-08-22  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>: Document.
+
 2017-08-22  Georg-Johann Lay  <avr@gjlay.de>
 
        Backport from 2017-04-19 trunk r246997.
index 497478c7a9f29a36db72f7e80e2cfc63c72e4a55..436ba034bc0a50ffe94dea30f836de4ab8447e39 100644 (file)
@@ -769,12 +769,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)
@@ -783,14 +777,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 identifier"
+                  " 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.  */
 
index 7e32ce5a350fdc4613811fe0fa5237f487660fa3..dc7326c3d12c59985048ff0d0e85163f1a7df063 100644 (file)
@@ -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
index 05a042100025dce44177dcb024c4e200a4d9dbd0..6353fe7b68c7527e0368d475393c7eabfd6a88bf 100644 (file)
@@ -574,7 +574,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
@@ -13656,12 +13657,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