diff mbox

386: Disallow naked attribute with interrupt attribute

Message ID 20170801202055.GA6800@gmail.com
State New
Headers show

Commit Message

H.J. Lu Aug. 1, 2017, 8:20 p.m. UTC
OK for trunk?

H.J.
---
gcc/

	PR target/81654
	* config/i386/i386.c (ix86_set_func_type): Disallow naked
	attribute with interrupt attribute.

gcc/testsuite/

	PR target/81654
	* gcc.target/i386/pr81654.c: New test.
---
 gcc/config/i386/i386.c                  | 4 ++++
 gcc/testsuite/gcc.target/i386/pr81654.c | 8 ++++++++
 2 files changed, 12 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr81654.c

Comments

Uros Bizjak Aug. 1, 2017, 8:23 p.m. UTC | #1
On Tue, Aug 1, 2017 at 10:20 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> OK for trunk?
>
> H.J.
> ---
> gcc/
>
>         PR target/81654
>         * config/i386/i386.c (ix86_set_func_type): Disallow naked
>         attribute with interrupt attribute.
>
> gcc/testsuite/
>
>         PR target/81654
>         * gcc.target/i386/pr81654.c: New test.

OK.

Thanks,
Uros.

>  gcc/config/i386/i386.c                  | 4 ++++
>  gcc/testsuite/gcc.target/i386/pr81654.c | 8 ++++++++
>  2 files changed, 12 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr81654.c
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 494a18a2cd1..587dbe61e8b 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -7523,6 +7523,10 @@ ix86_set_func_type (tree fndecl)
>        if (lookup_attribute ("interrupt",
>                             TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
>         {
> +         if (ix86_function_naked (fndecl))
> +           error_at (DECL_SOURCE_LOCATION (fndecl),
> +                     "interrupt and naked attributes are not compatible");
> +
>           int nargs = 0;
>           for (tree arg = DECL_ARGUMENTS (fndecl);
>                arg;
> diff --git a/gcc/testsuite/gcc.target/i386/pr81654.c b/gcc/testsuite/gcc.target/i386/pr81654.c
> new file mode 100644
> index 00000000000..2a1a4b72f1e
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr81654.c
> @@ -0,0 +1,8 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -mgeneral-regs-only" } */
> +
> +__attribute__((interrupt, naked))
> +void
> +fn (void *frame) /* { dg-error "not compatible" } */
> +{
> +}
> --
> 2.13.3
>
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 494a18a2cd1..587dbe61e8b 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7523,6 +7523,10 @@  ix86_set_func_type (tree fndecl)
       if (lookup_attribute ("interrupt",
 			    TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
 	{
+	  if (ix86_function_naked (fndecl))
+	    error_at (DECL_SOURCE_LOCATION (fndecl),
+		      "interrupt and naked attributes are not compatible");
+
 	  int nargs = 0;
 	  for (tree arg = DECL_ARGUMENTS (fndecl);
 	       arg;
diff --git a/gcc/testsuite/gcc.target/i386/pr81654.c b/gcc/testsuite/gcc.target/i386/pr81654.c
new file mode 100644
index 00000000000..2a1a4b72f1e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr81654.c
@@ -0,0 +1,8 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mgeneral-regs-only" } */
+
+__attribute__((interrupt, naked))
+void
+fn (void *frame) /* { dg-error "not compatible" } */
+{
+}