public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] testsuite: Fix up pr111309-2.c on arm [PR111309]
@ 2023-11-21  8:48 Jakub Jelinek
  2023-11-21  8:49 ` Richard Biener
  2023-11-21 14:00 ` Christophe Lyon
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2023-11-21  8:48 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

ARM defaults to -fshort-enums and the following testcase FAILs there in 2
lines.  The difference is that in C++, E0 has enum E type, which normally
has unsigned int underlying type, so it isn't int nor something that
promotes to int, which is why we diagnose it (in C it is promoted to int).
But with -fshort-enums, the underlying type is unsigned char in that case,
which promotes to int just fine.

The following patch adjusts the expectations, such that we don't expect
it on arm or when people manually test with -fshort-enums.

Tested on x86_64-linux and i686-linux, ok for trunk?

2023-11-21  Jakub Jelinek  <jakub@redhat.com>

	PR c/111309
	* c-c++-common/pr111309-2.c (foo): Don't expect errors for C++ with
	-fshort-enums if second argument is E0.

--- gcc/testsuite/c-c++-common/pr111309-2.c.jj	2023-11-14 10:52:16.191276028 +0100
+++ gcc/testsuite/c-c++-common/pr111309-2.c	2023-11-20 17:52:30.606386073 +0100
@@ -32,7 +32,7 @@ foo (void)
   __builtin_clzg (0U, 2LL);	/* { dg-error "does not have 'int' type" } */
   __builtin_clzg (0U, 2U);	/* { dg-error "does not have 'int' type" } */
   __builtin_clzg (0U, true);
-  __builtin_clzg (0U, E0);	/* { dg-error "does not have 'int' type" "" { target c++ } } */
+  __builtin_clzg (0U, E0);	/* { dg-error "does not have 'int' type" "" { target { c++ && { ! short_enums } } } } */
   __builtin_ctzg ();		/* { dg-error "too few arguments" } */
   __builtin_ctzg (0U, 1, 2);	/* { dg-error "too many arguments" } */
   __builtin_ctzg (0);		/* { dg-error "has signed type" } */
@@ -51,7 +51,7 @@ foo (void)
   __builtin_ctzg (0U, 2LL);	/* { dg-error "does not have 'int' type" } */
   __builtin_ctzg (0U, 2U);	/* { dg-error "does not have 'int' type" } */
   __builtin_ctzg (0U, true);
-  __builtin_ctzg (0U, E0);	/* { dg-error "does not have 'int' type" "" { target c++ } } */
+  __builtin_ctzg (0U, E0);	/* { dg-error "does not have 'int' type" "" { target { c++ && { ! short_enums } } } } */
   __builtin_clrsbg ();		/* { dg-error "too few arguments" } */
   __builtin_clrsbg (0, 1);	/* { dg-error "too many arguments" } */
   __builtin_clrsbg (0U);	/* { dg-error "has unsigned type" } */

	Jakub


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

* Re: [PATCH] testsuite: Fix up pr111309-2.c on arm [PR111309]
  2023-11-21  8:48 [PATCH] testsuite: Fix up pr111309-2.c on arm [PR111309] Jakub Jelinek
@ 2023-11-21  8:49 ` Richard Biener
  2023-11-21 14:00 ` Christophe Lyon
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2023-11-21  8:49 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Tue, 21 Nov 2023, Jakub Jelinek wrote:

> Hi!
> 
> ARM defaults to -fshort-enums and the following testcase FAILs there in 2
> lines.  The difference is that in C++, E0 has enum E type, which normally
> has unsigned int underlying type, so it isn't int nor something that
> promotes to int, which is why we diagnose it (in C it is promoted to int).
> But with -fshort-enums, the underlying type is unsigned char in that case,
> which promotes to int just fine.
> 
> The following patch adjusts the expectations, such that we don't expect
> it on arm or when people manually test with -fshort-enums.
> 
> Tested on x86_64-linux and i686-linux, ok for trunk?

OK

> 2023-11-21  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR c/111309
> 	* c-c++-common/pr111309-2.c (foo): Don't expect errors for C++ with
> 	-fshort-enums if second argument is E0.
> 
> --- gcc/testsuite/c-c++-common/pr111309-2.c.jj	2023-11-14 10:52:16.191276028 +0100
> +++ gcc/testsuite/c-c++-common/pr111309-2.c	2023-11-20 17:52:30.606386073 +0100
> @@ -32,7 +32,7 @@ foo (void)
>    __builtin_clzg (0U, 2LL);	/* { dg-error "does not have 'int' type" } */
>    __builtin_clzg (0U, 2U);	/* { dg-error "does not have 'int' type" } */
>    __builtin_clzg (0U, true);
> -  __builtin_clzg (0U, E0);	/* { dg-error "does not have 'int' type" "" { target c++ } } */
> +  __builtin_clzg (0U, E0);	/* { dg-error "does not have 'int' type" "" { target { c++ && { ! short_enums } } } } */
>    __builtin_ctzg ();		/* { dg-error "too few arguments" } */
>    __builtin_ctzg (0U, 1, 2);	/* { dg-error "too many arguments" } */
>    __builtin_ctzg (0);		/* { dg-error "has signed type" } */
> @@ -51,7 +51,7 @@ foo (void)
>    __builtin_ctzg (0U, 2LL);	/* { dg-error "does not have 'int' type" } */
>    __builtin_ctzg (0U, 2U);	/* { dg-error "does not have 'int' type" } */
>    __builtin_ctzg (0U, true);
> -  __builtin_ctzg (0U, E0);	/* { dg-error "does not have 'int' type" "" { target c++ } } */
> +  __builtin_ctzg (0U, E0);	/* { dg-error "does not have 'int' type" "" { target { c++ && { ! short_enums } } } } */
>    __builtin_clrsbg ();		/* { dg-error "too few arguments" } */
>    __builtin_clrsbg (0, 1);	/* { dg-error "too many arguments" } */
>    __builtin_clrsbg (0U);	/* { dg-error "has unsigned type" } */
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

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

* Re: [PATCH] testsuite: Fix up pr111309-2.c on arm [PR111309]
  2023-11-21  8:48 [PATCH] testsuite: Fix up pr111309-2.c on arm [PR111309] Jakub Jelinek
  2023-11-21  8:49 ` Richard Biener
@ 2023-11-21 14:00 ` Christophe Lyon
  1 sibling, 0 replies; 3+ messages in thread
From: Christophe Lyon @ 2023-11-21 14:00 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Richard Biener, gcc-patches

On Tue, 21 Nov 2023 at 09:48, Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> ARM defaults to -fshort-enums and the following testcase FAILs there in 2
> lines.  The difference is that in C++, E0 has enum E type, which normally
> has unsigned int underlying type, so it isn't int nor something that
> promotes to int, which is why we diagnose it (in C it is promoted to int).
> But with -fshort-enums, the underlying type is unsigned char in that case,
> which promotes to int just fine.
>
> The following patch adjusts the expectations, such that we don't expect
> it on arm or when people manually test with -fshort-enums.
>
> Tested on x86_64-linux and i686-linux, ok for trunk?
>
> 2023-11-21  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c/111309
>         * c-c++-common/pr111309-2.c (foo): Don't expect errors for C++ with
>         -fshort-enums if second argument is E0.
>

Thanks for the fix!

I keep forgetting about the -fshort-enum difference between arm-linux
and arm-eabi targets....

Christophe

> --- gcc/testsuite/c-c++-common/pr111309-2.c.jj  2023-11-14 10:52:16.191276028 +0100
> +++ gcc/testsuite/c-c++-common/pr111309-2.c     2023-11-20 17:52:30.606386073 +0100
> @@ -32,7 +32,7 @@ foo (void)
>    __builtin_clzg (0U, 2LL);    /* { dg-error "does not have 'int' type" } */
>    __builtin_clzg (0U, 2U);     /* { dg-error "does not have 'int' type" } */
>    __builtin_clzg (0U, true);
> -  __builtin_clzg (0U, E0);     /* { dg-error "does not have 'int' type" "" { target c++ } } */
> +  __builtin_clzg (0U, E0);     /* { dg-error "does not have 'int' type" "" { target { c++ && { ! short_enums } } } } */
>    __builtin_ctzg ();           /* { dg-error "too few arguments" } */
>    __builtin_ctzg (0U, 1, 2);   /* { dg-error "too many arguments" } */
>    __builtin_ctzg (0);          /* { dg-error "has signed type" } */
> @@ -51,7 +51,7 @@ foo (void)
>    __builtin_ctzg (0U, 2LL);    /* { dg-error "does not have 'int' type" } */
>    __builtin_ctzg (0U, 2U);     /* { dg-error "does not have 'int' type" } */
>    __builtin_ctzg (0U, true);
> -  __builtin_ctzg (0U, E0);     /* { dg-error "does not have 'int' type" "" { target c++ } } */
> +  __builtin_ctzg (0U, E0);     /* { dg-error "does not have 'int' type" "" { target { c++ && { ! short_enums } } } } */
>    __builtin_clrsbg ();         /* { dg-error "too few arguments" } */
>    __builtin_clrsbg (0, 1);     /* { dg-error "too many arguments" } */
>    __builtin_clrsbg (0U);       /* { dg-error "has unsigned type" } */
>
>         Jakub
>

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

end of thread, other threads:[~2023-11-21 14:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-21  8:48 [PATCH] testsuite: Fix up pr111309-2.c on arm [PR111309] Jakub Jelinek
2023-11-21  8:49 ` Richard Biener
2023-11-21 14:00 ` Christophe Lyon

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).