summaryrefslogtreecommitdiff
path: root/devel/avr-gcc/files/patch-misspelled-signames
blob: cc4df593fea6013fcaf19cc50d75554ff368a7a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2004-05-12  Theodore A. Roth  <troth@openavr.org>

	* gcc/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.

Index: gcc/config/avr/avr.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/avr/avr.c,v
retrieving revision 1.118
diff -u -p -p -r1.118 avr.c
--- gcc/config/avr/avr.c	13 Mar 2004 06:43:30 -0000	1.118
+++ gcc/config/avr/avr.c	12 May 2004 19:40:28 -0000
@@ -4566,6 +4559,32 @@ avr_handle_fndecl_attribute (tree *node,
       warning ("`%s' attribute only applies to functions",
 	       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;