epiphany.c (epiphany_handle_interrupt_attribute): Emit an error when the function...
authorJoern Rennecke <joern.rennecke@embecosm.com>
Wed, 7 May 2014 13:21:59 +0000 (13:21 +0000)
committerJoern Rennecke <amylaar@gcc.gnu.org>
Wed, 7 May 2014 13:21:59 +0000 (14:21 +0100)
gcc:
        * config/epiphany/epiphany.c (epiphany_handle_interrupt_attribute):
        Emit an error when the function has arguments.
gcc/testsuite:
        * gcc.target/epiphany/isr-arg.c: New file.

From-SVN: r210157

gcc/ChangeLog
gcc/config/epiphany/epiphany.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/epiphany/isr-arg.c [new file with mode: 0644]

index 61a7b30..4532bd5 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-07  Joern Rennecke  <joern.rennecke@embecosm.com>
+
+       * config/epiphany/epiphany.c (epiphany_handle_interrupt_attribute):
+       Emit an error when the function has arguments.
+
 2014-05-07  Thomas Schwinge  <thomas@codesourcery.com>
 
        * cfgloop.h (unswitch_loops): Remove.
index f3955b9..ebe6f05 100644 (file)
@@ -450,15 +450,28 @@ static const struct attribute_spec epiphany_attribute_table[] =
 /* Handle an "interrupt" attribute; arguments as in
    struct attribute_spec.handler.  */
 static tree
-epiphany_handle_interrupt_attribute (tree *node ATTRIBUTE_UNUSED,
-                                    tree name, tree args,
+epiphany_handle_interrupt_attribute (tree *node, tree name, tree args,
                                     int flags ATTRIBUTE_UNUSED,
                                     bool *no_add_attrs)
 {
   tree value;
 
   if (!args)
-    return NULL_TREE;
+    {
+      gcc_assert (DECL_P (*node));
+      tree t = TREE_TYPE (*node);
+      if (TREE_CODE (t) != FUNCTION_TYPE)
+       warning (OPT_Wattributes, "%qE attribute only applies to functions",
+                name);
+      /* Argument handling and the stack layout for interrupt handlers
+        don't mix.  It makes no sense in the first place, so emit an
+        error for this.  */
+      else if (TYPE_ARG_TYPES (t)
+              && TREE_VALUE (TYPE_ARG_TYPES (t)) != void_type_node)
+       error_at (DECL_SOURCE_LOCATION (*node),
+                 "interrupt handlers cannot have arguments");
+      return NULL_TREE;
+    }
 
   value = TREE_VALUE (args);
 
index ea89f06..2925e32 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-07  Joern Rennecke  <joern.rennecke@embecosm.com>
+
+       * gcc.target/epiphany/isr-arg.c: New file.
+
 2014-05-07  Evgeny Stupachenko  <evstupac@gmail.com>
 
        PR tree-optimization/52252
diff --git a/gcc/testsuite/gcc.target/epiphany/isr-arg.c b/gcc/testsuite/gcc.target/epiphany/isr-arg.c
new file mode 100644 (file)
index 0000000..5a8acc6
--- /dev/null
@@ -0,0 +1,9 @@
+int *p;
+
+void __attribute__((interrupt))
+isr (int signum) /* { dg-error "interrupt handlers cannot have arguments"  } */
+{
+  *p = 1;
+  return;
+}
+