public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] [i386,testsuite] [PR 71958] Error on -mx32 with -mabi=ms
@ 2017-08-12  1:32 Daniel Santos
  2017-08-12 10:49 ` Uros Bizjak
  2017-08-13 15:26 ` Rainer Orth
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Santos @ 2017-08-12  1:32 UTC (permalink / raw)
  To: gcc-patches, Uros Bizjak, H . J . Lu, Mike Stump; +Cc: Rainer Orth

We currently error when -mx32 -mabi=sysv and we encounter a function
with attribute ms_abi, but we are not erroring on -mx32 and -mabi=ms
(either explicitly or when it is the default on Windows).  In fact, it
generates code that runs, but is of an undfined ABI.

I'm running -m64 and -m32 tests now and will run x32 tests when those
are done.  Presuming that I've corrected all existing tests that do not
filter out x32 target and there are no additional failures, is this OK
for head?

Thanks,
Daniel

gcc/ChangeLog:
2017-08-11  Daniel Santos  <daniel.santos@pobox.com>

	* config/i386/i386.c (ix86_option_override_internal): Modify.
	(ix86_function_type_abi): Likewise.

gcc/testsuite/ChangeLog:
2017-08-11  Daniel Santos  <daniel.santos@pobox.com>

	* gcc.target/i386/pr71958.c: New test.
 	* gcc.target/i386/pr64409.c: Modify to skip on Windows.
	* gcc.target/i386/pr46470.c: Modify to skip x32 target.
 	* gcc.target/i386/pr66275.c: Likewise.
 	* gcc.target/i386/pr68018.c: Likewise.

Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
---
 gcc/config/i386/i386.c                  | 11 +++++++++--
 gcc/testsuite/gcc.target/i386/pr46470.c |  2 +-
 gcc/testsuite/gcc.target/i386/pr64409.c |  3 ++-
 gcc/testsuite/gcc.target/i386/pr66275.c |  2 +-
 gcc/testsuite/gcc.target/i386/pr68018.c |  2 +-
 gcc/testsuite/gcc.target/i386/pr71958.c |  8 ++++++++
 6 files changed, 22 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr71958.c

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index b04321a8d40..311a52c2a1f 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -5585,6 +5585,9 @@ ix86_option_override_internal (bool main_args_p,
 
   if (TARGET_X32_P (opts->x_ix86_isa_flags))
     {
+      if (opts_set->x_ix86_abi == MS_ABI)
+	error ("-mx32 not supported with -mabi=ms");
+
       /* Always turn on OPTION_MASK_ISA_64BIT and turn off
 	 OPTION_MASK_ABI_64 for TARGET_X32.  */
       opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
@@ -8777,8 +8780,12 @@ ix86_function_type_abi (const_tree fntype)
   if (abi == SYSV_ABI
       && lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (fntype)))
     {
-      if (TARGET_X32)
-	error ("X32 does not support ms_abi attribute");
+      static int warned;
+      if (TARGET_X32 && !warned)
+	{
+	  error ("X32 does not support ms_abi attribute");
+	  warned = 1;
+	}
 
       abi = MS_ABI;
     }
diff --git a/gcc/testsuite/gcc.target/i386/pr46470.c b/gcc/testsuite/gcc.target/i386/pr46470.c
index 9e8e731188e..c66a378a1ad 100644
--- a/gcc/testsuite/gcc.target/i386/pr46470.c
+++ b/gcc/testsuite/gcc.target/i386/pr46470.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target { ! x32 } } } */
 /* The pic register save adds unavoidable stack pointer references.  */
 /* { dg-skip-if "" { ia32 && { ! nonpic } } } */
 /* These options are selected to ensure 1 word needs to be allocated
diff --git a/gcc/testsuite/gcc.target/i386/pr64409.c b/gcc/testsuite/gcc.target/i386/pr64409.c
index 917472653f4..3dbd9a09f01 100644
--- a/gcc/testsuite/gcc.target/i386/pr64409.c
+++ b/gcc/testsuite/gcc.target/i386/pr64409.c
@@ -1,6 +1,7 @@
 /* { dg-do compile { target { ! ia32 } } } */
 /* { dg-require-effective-target maybe_x32 } */
 /* { dg-options "-O0 -mx32" } */
+/* { xfail { "*-*-cygwin* *-*-mingw*" } } */
 
 int a;
-int* __attribute__ ((ms_abi)) fn1 () { return &a; } /* { dg-error "X32 does not support ms_abi attribute" } */
+int* __attribute__ ((ms_abi)) fn1 () { return &a; } /* { dg-error "X32 does not support ms_abi attribute" { target { ! "*-*-mingw* *-*-cygwin*" } } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr66275.c b/gcc/testsuite/gcc.target/i386/pr66275.c
index b8759aeb5ec..a1271857f6a 100644
--- a/gcc/testsuite/gcc.target/i386/pr66275.c
+++ b/gcc/testsuite/gcc.target/i386/pr66275.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-do compile { target { *-*-linux* && { ! { ia32 || x32 } } } } } */
 /* { dg-options "-mabi=ms -fdump-rtl-dfinit" } */
 
 void
diff --git a/gcc/testsuite/gcc.target/i386/pr68018.c b/gcc/testsuite/gcc.target/i386/pr68018.c
index a0fa21e0b00..871fdddf643 100644
--- a/gcc/testsuite/gcc.target/i386/pr68018.c
+++ b/gcc/testsuite/gcc.target/i386/pr68018.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-do compile { target { *-*-linux* && { ! { ia32 || x32 } } } } } */
 /* { dg-options "-O -mabi=ms -mstackrealign" } */
 
 typedef float V __attribute__ ((vector_size (16)));
diff --git a/gcc/testsuite/gcc.target/i386/pr71958.c b/gcc/testsuite/gcc.target/i386/pr71958.c
new file mode 100644
index 00000000000..090d1970ca9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71958.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mx32 -mabi=ms" } */
+/* { dg-require-effective-target maybe_x32 } */
+/* { dg-excess-errors "not supported" } */
+
+void main ()
+{
+}
-- 
2.13.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [i386,testsuite] [PR 71958] Error on -mx32 with -mabi=ms
  2017-08-12  1:32 [PATCH] [i386,testsuite] [PR 71958] Error on -mx32 with -mabi=ms Daniel Santos
@ 2017-08-12 10:49 ` Uros Bizjak
  2017-08-13 15:26 ` Rainer Orth
  1 sibling, 0 replies; 5+ messages in thread
From: Uros Bizjak @ 2017-08-12 10:49 UTC (permalink / raw)
  To: Daniel Santos; +Cc: gcc-patches, H . J . Lu, Mike Stump, Rainer Orth

On Fri, Aug 11, 2017 at 11:27 PM, Daniel Santos <daniel.santos@pobox.com> wrote:
> We currently error when -mx32 -mabi=sysv and we encounter a function
> with attribute ms_abi, but we are not erroring on -mx32 and -mabi=ms
> (either explicitly or when it is the default on Windows).  In fact, it
> generates code that runs, but is of an undfined ABI.
>
> I'm running -m64 and -m32 tests now and will run x32 tests when those
> are done.  Presuming that I've corrected all existing tests that do not
> filter out x32 target and there are no additional failures, is this OK
> for head?
>
> Thanks,
> Daniel
>
> gcc/ChangeLog:
> 2017-08-11  Daniel Santos  <daniel.santos@pobox.com>
>
>         * config/i386/i386.c (ix86_option_override_internal): Modify.
>         (ix86_function_type_abi): Likewise.
>
> gcc/testsuite/ChangeLog:
> 2017-08-11  Daniel Santos  <daniel.santos@pobox.com>
>
>         * gcc.target/i386/pr71958.c: New test.
>         * gcc.target/i386/pr64409.c: Modify to skip on Windows.
>         * gcc.target/i386/pr46470.c: Modify to skip x32 target.
>         * gcc.target/i386/pr66275.c: Likewise.
>         * gcc.target/i386/pr68018.c: Likewise.
>
> Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
> ---
>  gcc/config/i386/i386.c                  | 11 +++++++++--
>  gcc/testsuite/gcc.target/i386/pr46470.c |  2 +-
>  gcc/testsuite/gcc.target/i386/pr64409.c |  3 ++-
>  gcc/testsuite/gcc.target/i386/pr66275.c |  2 +-
>  gcc/testsuite/gcc.target/i386/pr68018.c |  2 +-
>  gcc/testsuite/gcc.target/i386/pr71958.c |  8 ++++++++
>  6 files changed, 22 insertions(+), 6 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr71958.c
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index b04321a8d40..311a52c2a1f 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -5585,6 +5585,9 @@ ix86_option_override_internal (bool main_args_p,
>
>    if (TARGET_X32_P (opts->x_ix86_isa_flags))
>      {
> +      if (opts_set->x_ix86_abi == MS_ABI)
> +       error ("-mx32 not supported with -mabi=ms");
> +
>        /* Always turn on OPTION_MASK_ISA_64BIT and turn off
>          OPTION_MASK_ABI_64 for TARGET_X32.  */
>        opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
> @@ -8777,8 +8780,12 @@ ix86_function_type_abi (const_tree fntype)
>    if (abi == SYSV_ABI
>        && lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (fntype)))
>      {
> -      if (TARGET_X32)
> -       error ("X32 does not support ms_abi attribute");
> +      static int warned;
> +      if (TARGET_X32 && !warned)
> +       {
> +         error ("X32 does not support ms_abi attribute");
> +         warned = 1;
> +       }
>
>        abi = MS_ABI;
>      }
> diff --git a/gcc/testsuite/gcc.target/i386/pr46470.c b/gcc/testsuite/gcc.target/i386/pr46470.c
> index 9e8e731188e..c66a378a1ad 100644
> --- a/gcc/testsuite/gcc.target/i386/pr46470.c
> +++ b/gcc/testsuite/gcc.target/i386/pr46470.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile } */
> +/* { dg-do compile { target { ! x32 } } } */
>  /* The pic register save adds unavoidable stack pointer references.  */
>  /* { dg-skip-if "" { ia32 && { ! nonpic } } } */
>  /* These options are selected to ensure 1 word needs to be allocated
> diff --git a/gcc/testsuite/gcc.target/i386/pr64409.c b/gcc/testsuite/gcc.target/i386/pr64409.c
> index 917472653f4..3dbd9a09f01 100644
> --- a/gcc/testsuite/gcc.target/i386/pr64409.c
> +++ b/gcc/testsuite/gcc.target/i386/pr64409.c
> @@ -1,6 +1,7 @@
>  /* { dg-do compile { target { ! ia32 } } } */
>  /* { dg-require-effective-target maybe_x32 } */
>  /* { dg-options "-O0 -mx32" } */
> +/* { xfail { "*-*-cygwin* *-*-mingw*" } } */
>
>  int a;
> -int* __attribute__ ((ms_abi)) fn1 () { return &a; } /* { dg-error "X32 does not support ms_abi attribute" } */
> +int* __attribute__ ((ms_abi)) fn1 () { return &a; } /* { dg-error "X32 does not support ms_abi attribute" { target { ! "*-*-mingw* *-*-cygwin*" } } } */
> diff --git a/gcc/testsuite/gcc.target/i386/pr66275.c b/gcc/testsuite/gcc.target/i386/pr66275.c
> index b8759aeb5ec..a1271857f6a 100644
> --- a/gcc/testsuite/gcc.target/i386/pr66275.c
> +++ b/gcc/testsuite/gcc.target/i386/pr66275.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
> +/* { dg-do compile { target { *-*-linux* && { ! { ia32 || x32 } } } } } */

"! { ia32 || x32 }" should be replaced with lp64.

>  /* { dg-options "-mabi=ms -fdump-rtl-dfinit" } */
>
>  void
> diff --git a/gcc/testsuite/gcc.target/i386/pr68018.c b/gcc/testsuite/gcc.target/i386/pr68018.c
> index a0fa21e0b00..871fdddf643 100644
> --- a/gcc/testsuite/gcc.target/i386/pr68018.c
> +++ b/gcc/testsuite/gcc.target/i386/pr68018.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
> +/* { dg-do compile { target { *-*-linux* && { ! { ia32 || x32 } } } } } */

Also here.

>  /* { dg-options "-O -mabi=ms -mstackrealign" } */
>
>  typedef float V __attribute__ ((vector_size (16)));
> diff --git a/gcc/testsuite/gcc.target/i386/pr71958.c b/gcc/testsuite/gcc.target/i386/pr71958.c
> new file mode 100644
> index 00000000000..090d1970ca9
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr71958.c
> @@ -0,0 +1,8 @@
> +/* { dg-do compile } */
> +/* { dg-options "-mx32 -mabi=ms" } */
> +/* { dg-require-effective-target maybe_x32 } */

The above is not needed for compile tests.

> +/* { dg-excess-errors "not supported" } */

For expected errors, you should use dg-error.

Uros.

> +
> +void main ()
> +{
> +}
> --
> 2.13.3
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [i386,testsuite] [PR 71958] Error on -mx32 with -mabi=ms
  2017-08-12  1:32 [PATCH] [i386,testsuite] [PR 71958] Error on -mx32 with -mabi=ms Daniel Santos
  2017-08-12 10:49 ` Uros Bizjak
@ 2017-08-13 15:26 ` Rainer Orth
  1 sibling, 0 replies; 5+ messages in thread
From: Rainer Orth @ 2017-08-13 15:26 UTC (permalink / raw)
  To: Daniel Santos; +Cc: gcc-patches, Uros Bizjak, H . J . Lu, Mike Stump

Hi Daniel,

> We currently error when -mx32 -mabi=sysv and we encounter a function
> with attribute ms_abi, but we are not erroring on -mx32 and -mabi=ms
> (either explicitly or when it is the default on Windows).  In fact, it
> generates code that runs, but is of an undfined ABI.
>
> I'm running -m64 and -m32 tests now and will run x32 tests when those
> are done.  Presuming that I've corrected all existing tests that do not
> filter out x32 target and there are no additional failures, is this OK
> for head?
>
> Thanks,
> Daniel
>
> gcc/ChangeLog:
> 2017-08-11  Daniel Santos  <daniel.santos@pobox.com>
>
> 	* config/i386/i386.c (ix86_option_override_internal): Modify.
> 	(ix86_function_type_abi): Likewise.

those entries are pretty useless as they stand: you should state *what*
you changed.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [i386, testsuite] [PR 71958] Error on -mx32 with -mabi=ms
  2017-08-22  6:16 [PATCH] [i386, testsuite] " Daniel Santos
@ 2017-08-22  7:29 ` Uros Bizjak
  0 siblings, 0 replies; 5+ messages in thread
From: Uros Bizjak @ 2017-08-22  7:29 UTC (permalink / raw)
  To: Daniel Santos
  Cc: gcc-patches, H . J . Lu, Jan Hubicka, Rainer Orth, Mike Stump

On Tue, Aug 22, 2017 at 4:00 AM, Daniel Santos <daniel.santos@pobox.com> wrote:
> We currently error when -mx32 and -mabi=sysv and we encounter a function
> with attribute ms_abi, but we are not erroring on -mx32 and -mabi=ms
> (either explicitly or when it is the default on Windows).  In fact, it
> generates code that runs, but is of an undfined ABI.
>
> I'm also changing pr64409.c because if you explicitly supply -m64, then
> the test became ineffective.  This is because the -mx32 parameter passed
> in dg-options is later overridden by the explicit -m64 parameter.
>
> I've bootstrapped and tested on
> *  an x86_64-pc-linux-gnux32 system building gcc with --with-abi=mx32,
> *  a "normal" x86_64-pc-linux-gnu testing with
>    --target_board=unix/\{,-m32\}, and
> *  on Windows.
>
> OK for trunk?
>
> gcc/ChangeLog:
> 2017-08-11  Daniel Santos  <daniel.santos@pobox.com>
>
>         * config/i386/i386.c (ix86_option_override_internal): Error when
>         -mx32 is combined with -mabi=ms.
>         (ix86_function_type_abi): Limit errors for mixing -mx32 with
>         attribute ms_abi.
>
> gcc/testsuite/ChangeLog:
> 2017-08-11  Daniel Santos  <daniel.santos@pobox.com>
>
>         * gcc.target/i386/pr71958.c: New test to verify error on -mx32
>         and -mabi=ms
>         * gcc.target/i386/pr64409.c: Modify to only run on x32.
>         * gcc.target/i386/pr46470.c: Modify to skip x32 target.
>         * gcc.target/i386/pr66275.c: Likewise.
>         * gcc.target/i386/pr68018.c: Likewise.

OK.

Thanks,
Uros.

> Thanks,
> Daniel
>
> Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
> ---
>  gcc/config/i386/i386.c                  | 12 ++++++++++--
>  gcc/testsuite/gcc.target/i386/pr46470.c |  2 +-
>  gcc/testsuite/gcc.target/i386/pr64409.c |  2 +-
>  gcc/testsuite/gcc.target/i386/pr66275.c |  2 +-
>  gcc/testsuite/gcc.target/i386/pr68018.c |  2 +-
>  gcc/testsuite/gcc.target/i386/pr71958.c |  7 +++++++
>  6 files changed, 21 insertions(+), 6 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr71958.c
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 1d88e4f247a..3b537f2608f 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -5684,6 +5684,10 @@ ix86_option_override_internal (bool main_args_p,
>    if (!opts_set->x_ix86_abi)
>      opts->x_ix86_abi = DEFAULT_ABI;
>
> +  if (opts->x_ix86_abi == MS_ABI && TARGET_X32_P (opts->x_ix86_isa_flags))
> +    error ("-mabi=ms not supported with X32 ABI");
> +  gcc_assert (opts->x_ix86_abi == SYSV_ABI || opts->x_ix86_abi == MS_ABI);
> +
>    /* For targets using ms ABI enable ms-extensions, if not
>       explicit turned off.  For non-ms ABI we turn off this
>       option.  */
> @@ -8777,8 +8781,12 @@ ix86_function_type_abi (const_tree fntype)
>    if (abi == SYSV_ABI
>        && lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (fntype)))
>      {
> -      if (TARGET_X32)
> -       error ("X32 does not support ms_abi attribute");
> +      static int warned;
> +      if (TARGET_X32 && !warned)
> +       {
> +         error ("X32 does not support ms_abi attribute");
> +         warned = 1;
> +       }
>
>        abi = MS_ABI;
>      }
> diff --git a/gcc/testsuite/gcc.target/i386/pr46470.c b/gcc/testsuite/gcc.target/i386/pr46470.c
> index 9e8e731188e..c66a378a1ad 100644
> --- a/gcc/testsuite/gcc.target/i386/pr46470.c
> +++ b/gcc/testsuite/gcc.target/i386/pr46470.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile } */
> +/* { dg-do compile { target { ! x32 } } } */
>  /* The pic register save adds unavoidable stack pointer references.  */
>  /* { dg-skip-if "" { ia32 && { ! nonpic } } } */
>  /* These options are selected to ensure 1 word needs to be allocated
> diff --git a/gcc/testsuite/gcc.target/i386/pr64409.c b/gcc/testsuite/gcc.target/i386/pr64409.c
> index 917472653f4..7bf9d1e398d 100644
> --- a/gcc/testsuite/gcc.target/i386/pr64409.c
> +++ b/gcc/testsuite/gcc.target/i386/pr64409.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile { target { ! ia32 } } } */
> +/* { dg-do compile { target x32 } } */
>  /* { dg-require-effective-target maybe_x32 } */
>  /* { dg-options "-O0 -mx32" } */
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr66275.c b/gcc/testsuite/gcc.target/i386/pr66275.c
> index b8759aeb5ec..51ae1f6859c 100644
> --- a/gcc/testsuite/gcc.target/i386/pr66275.c
> +++ b/gcc/testsuite/gcc.target/i386/pr66275.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
> +/* { dg-do compile { target { *-*-linux* && lp64 } } } */
>  /* { dg-options "-mabi=ms -fdump-rtl-dfinit" } */
>
>  void
> diff --git a/gcc/testsuite/gcc.target/i386/pr68018.c b/gcc/testsuite/gcc.target/i386/pr68018.c
> index a0fa21e0b00..04929c6c13c 100644
> --- a/gcc/testsuite/gcc.target/i386/pr68018.c
> +++ b/gcc/testsuite/gcc.target/i386/pr68018.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
> +/* { dg-do compile { target { *-*-linux* && lp64 } } } */
>  /* { dg-options "-O -mabi=ms -mstackrealign" } */
>
>  typedef float V __attribute__ ((vector_size (16)));
> diff --git a/gcc/testsuite/gcc.target/i386/pr71958.c b/gcc/testsuite/gcc.target/i386/pr71958.c
> new file mode 100644
> index 00000000000..c5a109767c1
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr71958.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile { target { x32 } } } */
> +/* { dg-options "-mabi=ms" } */
> +/* { dg-error "-mabi=ms not supported with X32 ABI" "" { target *-*-* } 0 } */
> +
> +void main ()
> +{
> +}
> --
> 2.13.3
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] [i386, testsuite] [PR 71958] Error on -mx32 with -mabi=ms
@ 2017-08-22  6:16 Daniel Santos
  2017-08-22  7:29 ` Uros Bizjak
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Santos @ 2017-08-22  6:16 UTC (permalink / raw)
  To: gcc-patches, Uros Bizjak, H . J . Lu, Jan Hubicka, Rainer Orth,
	Mike Stump

We currently error when -mx32 and -mabi=sysv and we encounter a function
with attribute ms_abi, but we are not erroring on -mx32 and -mabi=ms
(either explicitly or when it is the default on Windows).  In fact, it
generates code that runs, but is of an undfined ABI.

I'm also changing pr64409.c because if you explicitly supply -m64, then
the test became ineffective.  This is because the -mx32 parameter passed
in dg-options is later overridden by the explicit -m64 parameter.

I've bootstrapped and tested on
*  an x86_64-pc-linux-gnux32 system building gcc with --with-abi=mx32,
*  a "normal" x86_64-pc-linux-gnu testing with
   --target_board=unix/\{,-m32\}, and
*  on Windows.

OK for trunk?

gcc/ChangeLog:
2017-08-11  Daniel Santos  <daniel.santos@pobox.com>

	* config/i386/i386.c (ix86_option_override_internal): Error when
	-mx32 is combined with -mabi=ms.
	(ix86_function_type_abi): Limit errors for mixing -mx32 with
	attribute ms_abi.

gcc/testsuite/ChangeLog:
2017-08-11  Daniel Santos  <daniel.santos@pobox.com>

	* gcc.target/i386/pr71958.c: New test to verify error on -mx32
	and -mabi=ms
 	* gcc.target/i386/pr64409.c: Modify to only run on x32.
	* gcc.target/i386/pr46470.c: Modify to skip x32 target.
 	* gcc.target/i386/pr66275.c: Likewise.
 	* gcc.target/i386/pr68018.c: Likewise.

Thanks,
Daniel

Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
---
 gcc/config/i386/i386.c                  | 12 ++++++++++--
 gcc/testsuite/gcc.target/i386/pr46470.c |  2 +-
 gcc/testsuite/gcc.target/i386/pr64409.c |  2 +-
 gcc/testsuite/gcc.target/i386/pr66275.c |  2 +-
 gcc/testsuite/gcc.target/i386/pr68018.c |  2 +-
 gcc/testsuite/gcc.target/i386/pr71958.c |  7 +++++++
 6 files changed, 21 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr71958.c

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 1d88e4f247a..3b537f2608f 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -5684,6 +5684,10 @@ ix86_option_override_internal (bool main_args_p,
   if (!opts_set->x_ix86_abi)
     opts->x_ix86_abi = DEFAULT_ABI;
 
+  if (opts->x_ix86_abi == MS_ABI && TARGET_X32_P (opts->x_ix86_isa_flags))
+    error ("-mabi=ms not supported with X32 ABI");
+  gcc_assert (opts->x_ix86_abi == SYSV_ABI || opts->x_ix86_abi == MS_ABI);
+
   /* For targets using ms ABI enable ms-extensions, if not
      explicit turned off.  For non-ms ABI we turn off this
      option.  */
@@ -8777,8 +8781,12 @@ ix86_function_type_abi (const_tree fntype)
   if (abi == SYSV_ABI
       && lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (fntype)))
     {
-      if (TARGET_X32)
-	error ("X32 does not support ms_abi attribute");
+      static int warned;
+      if (TARGET_X32 && !warned)
+	{
+	  error ("X32 does not support ms_abi attribute");
+	  warned = 1;
+	}
 
       abi = MS_ABI;
     }
diff --git a/gcc/testsuite/gcc.target/i386/pr46470.c b/gcc/testsuite/gcc.target/i386/pr46470.c
index 9e8e731188e..c66a378a1ad 100644
--- a/gcc/testsuite/gcc.target/i386/pr46470.c
+++ b/gcc/testsuite/gcc.target/i386/pr46470.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target { ! x32 } } } */
 /* The pic register save adds unavoidable stack pointer references.  */
 /* { dg-skip-if "" { ia32 && { ! nonpic } } } */
 /* These options are selected to ensure 1 word needs to be allocated
diff --git a/gcc/testsuite/gcc.target/i386/pr64409.c b/gcc/testsuite/gcc.target/i386/pr64409.c
index 917472653f4..7bf9d1e398d 100644
--- a/gcc/testsuite/gcc.target/i386/pr64409.c
+++ b/gcc/testsuite/gcc.target/i386/pr64409.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-do compile { target x32 } } */
 /* { dg-require-effective-target maybe_x32 } */
 /* { dg-options "-O0 -mx32" } */
 
diff --git a/gcc/testsuite/gcc.target/i386/pr66275.c b/gcc/testsuite/gcc.target/i386/pr66275.c
index b8759aeb5ec..51ae1f6859c 100644
--- a/gcc/testsuite/gcc.target/i386/pr66275.c
+++ b/gcc/testsuite/gcc.target/i386/pr66275.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
 /* { dg-options "-mabi=ms -fdump-rtl-dfinit" } */
 
 void
diff --git a/gcc/testsuite/gcc.target/i386/pr68018.c b/gcc/testsuite/gcc.target/i386/pr68018.c
index a0fa21e0b00..04929c6c13c 100644
--- a/gcc/testsuite/gcc.target/i386/pr68018.c
+++ b/gcc/testsuite/gcc.target/i386/pr68018.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { *-*-linux* && { ! ia32 } } } } */
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
 /* { dg-options "-O -mabi=ms -mstackrealign" } */
 
 typedef float V __attribute__ ((vector_size (16)));
diff --git a/gcc/testsuite/gcc.target/i386/pr71958.c b/gcc/testsuite/gcc.target/i386/pr71958.c
new file mode 100644
index 00000000000..c5a109767c1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71958.c
@@ -0,0 +1,7 @@
+/* { dg-do compile { target { x32 } } } */
+/* { dg-options "-mabi=ms" } */
+/* { dg-error "-mabi=ms not supported with X32 ABI" "" { target *-*-* } 0 } */
+
+void main ()
+{
+}
-- 
2.13.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-22  6:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-12  1:32 [PATCH] [i386,testsuite] [PR 71958] Error on -mx32 with -mabi=ms Daniel Santos
2017-08-12 10:49 ` Uros Bizjak
2017-08-13 15:26 ` Rainer Orth
2017-08-22  6:16 [PATCH] [i386, testsuite] " Daniel Santos
2017-08-22  7:29 ` Uros Bizjak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).