avr.c (avr_handle_fndecl_attribute): Generate a warning if the function name does...
authorTheodore A. Roth <troth@openavr.org>
Sun, 28 Nov 2004 23:15:59 +0000 (23:15 +0000)
committerMarek Michalkiewicz <marekm@gcc.gnu.org>
Sun, 28 Nov 2004 23:15:59 +0000 (23:15 +0000)
* config/avr/avr.c (avr_handle_fndecl_attribute): Generate a
warning if the function name does not begin with "__vector" and the
function has either the 'signal' or 'interrupt' attribute.

From-SVN: r91433

gcc/ChangeLog
gcc/config/avr/avr.c

index 4d4cad0d06cc2da1537b5a21e013260243e004fd..591a97cad429ee2d765f34f48205485598f4071e 100644 (file)
@@ -1,3 +1,9 @@
+2004-11-28  Theodore A. Roth  <troth@openavr.org>
+
+       * config/avr/avr.c (avr_handle_fndecl_attribute): Generate a
+       warning if the function name does not begin with "__vector" and the
+       function has either the 'signal' or 'interrupt' attribute.
+
 2004-11-28  Theodore A. Roth  <troth@openavr.org>
 
        * config/avr/avr.c (avr_mcu_types): Add entries for atmega48,
index a00e3b1ab2b6775e154aadfbae24054c210d2cb7..6ea3303cf7be24e2e1e0ec436bc256f920dfc006 100644 (file)
@@ -4545,6 +4545,32 @@ avr_handle_fndecl_attribute (tree *node, tree name,
               IDENTIFIER_POINTER (name));
       *no_add_attrs = true;
     }
+  else
+    {
+      const char *func_name = IDENTIFIER_POINTER (DECL_NAME (*node));
+      const char *attr = IDENTIFIER_POINTER (name);
+
+      /* If the function has the 'signal' or 'interrupt' attribute, test to
+         make sure that the name of the function is "__vector_NN" so as to
+         catch when the user misspells the interrupt vector name.  */
+
+      if (strncmp (attr, "interrupt", strlen ("interrupt")) == 0)
+        {
+          if (strncmp (func_name, "__vector", strlen ("__vector")) != 0)
+            {
+              warning ("`%s' appears to be a misspelled interrupt handler",
+                       func_name);
+            }
+        }
+      else if (strncmp (attr, "signal", strlen ("signal")) == 0)
+        {
+          if (strncmp (func_name, "__vector", strlen ("__vector")) != 0)
+            {
+              warning ("`%s' appears to be a misspelled signal handler",
+                       func_name);
+            }
+        }
+    }
 
   return NULL_TREE;
 }