]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
msp430.c (msp430_attr): Warn when the critical and interrupt function attributes...
authorJozef Lawrynowicz <jozefl@gcc.gnu.org>
Sat, 29 Dec 2018 19:00:48 +0000 (19:00 +0000)
committerJozef Lawrynowicz <jozefl@gcc.gnu.org>
Sat, 29 Dec 2018 19:00:48 +0000 (19:00 +0000)
2018-12-29  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

gcc/ChangeLog:

* config/msp430/msp430.c (msp430_attr): Warn when the critical and
interrupt function attributes are used together.
* gcc/doc/extend.texi: Update documentation on the critical attribute.

gcc/testsuite/ChangeLog:

* gcc.target/msp430/critical-interrupt.c: New test.

From-SVN: r267467

gcc/ChangeLog
gcc/config/msp430/msp430.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/msp430/critical-interrupt.c [new file with mode: 0644]

index 3ce73b4d090e81af6f9b1a718bd9c6b499f6c1a9..bb02095e42f9d488045def9fcf7da37488921080 100644 (file)
@@ -1,7 +1,13 @@
+2018-12-29  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
+
+       * config/msp430/msp430.c (msp430_attr): Warn when the critical and
+       interrupt function attributes are used together.
+       * gcc/doc/extend.texi: Update documentation on the critical attribute.
+
 2018-12-29  John David Anglin  <danglin@gcc.gnu.org>
 
-        * config.gcc (hppa*64*-*-linux*): Add pa/t-pa to tmake_file.  Define
-        d_target_objs.
+       * config.gcc (hppa*64*-*-linux*): Add pa/t-pa to tmake_file.  Define
+       d_target_objs.
        (hppa*-*-openbsd*): Likewise.
        (hppa[12]*-*-hpux10*): Likewise.
        (hppa*64*-*-hpux11*): Likewise.
index 3a41cc011e7516f25f244bb724cfb7fd800b81b3..21b5819380f9d73dcdc82929cef456b5b3dfd9b6 100644 (file)
@@ -1946,6 +1946,13 @@ msp430_attr (tree * node,
          TREE_USED (* node) = 1;
          DECL_PRESERVE_P (* node) = 1;
        }
+      if (is_critical_func (* node))
+       {
+         warning (OPT_Wattributes,
+                  "critical attribute has no effect on interrupt functions");
+         DECL_ATTRIBUTES (*node) = remove_attribute (ATTR_CRIT,
+                                                     DECL_ATTRIBUTES (* node));
+       }
     }
   else if (TREE_NAME_EQ (name, ATTR_REENT))
     {
@@ -1960,6 +1967,8 @@ msp430_attr (tree * node,
        message = "naked functions cannot be critical";
       else if (is_reentrant_func (* node))
        message = "reentrant functions cannot be critical";
+      else if (is_interrupt_func ( *node))
+       message = "critical attribute has no effect on interrupt functions";
     }
   else if (TREE_NAME_EQ (name, ATTR_NAKED))
     {
index 1849120b7bd16261d3558511523eb96fcfb4e4ae..27724e400d2c4f9dddcd4d9916a314831647a8e5 100644 (file)
@@ -4978,8 +4978,12 @@ These function attributes are supported by the MSP430 back end:
 @cindex @code{critical} function attribute, MSP430
 Critical functions disable interrupts upon entry and restore the
 previous interrupt state upon exit.  Critical functions cannot also
-have the @code{naked} or @code{reentrant} attributes.  They can have
-the @code{interrupt} attribute.
+have the @code{naked}, @code{reentrant} or @code{interrupt} attributes.
+
+The MSP430 hardware ensures that interrupts are disabled on entry to
+@code{interrupt} functions, and restores the previous interrupt state
+on exit. The @code{critical} attribute is therefore redundant on
+@code{interrupt} functions.
 
 @item interrupt
 @cindex @code{interrupt} function attribute, MSP430
index 109441d80b2d03308692b844827069c7b6649ae5..cdfc940b45f7ab47a33a1f073473b2ee3a4096c2 100644 (file)
@@ -1,3 +1,7 @@
+2018-12-29  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
+
+       * gcc.target/msp430/critical-interrupt.c: New test.
+
 2018-12-29  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/88342
diff --git a/gcc/testsuite/gcc.target/msp430/critical-interrupt.c b/gcc/testsuite/gcc.target/msp430/critical-interrupt.c
new file mode 100644 (file)
index 0000000..3ef7a12
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-final { scan-assembler-not "attributes.*critical" } } */
+
+void __attribute__((interrupt,critical))
+fn1 (void)
+{ /* { dg-warning "critical attribute has no effect on interrupt functions" } */
+}
+
+void __attribute__((critical,interrupt))
+fn2 (void)
+{ /* { dg-warning "critical attribute has no effect on interrupt functions" } */
+}