[PATCH] Fix testcase for PR c/78304

Christophe Lyon christophe.lyon@linaro.org
Tue Jan 17 09:45:00 GMT 2017


On 16 January 2017 at 19:50, David Malcolm <dmalcolm@redhat.com> wrote:
> On Mon, 2017-01-16 at 13:31 +0100, Rainer Orth wrote:
>> Hi Christophe,
>>
>> > > Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu;
>> > > adds 34 PASS results to gcc.sum.
>> > >
>> > These 2 tests fail on arm:
>> >
>> >   gcc.dg/format/pr78304.c     (test for warnings, line 9)
>> >   gcc.dg/format/pr78304.c   -DWIDE   (test for warnings, line 9)
>>
>> also on sparc-sun-solaris2.12 and i386-pc-solaris2.12, 32-bit only.
>>
>>       Rainer
>
> Sorry about the failures.
>
> The tests I committed made assumptions about size_t and long
> being invalid for use with "%u".
>
> The tests only need some invalid type, so this patch converts
> them to attempt a print "const char *" with "%u", which should be
> invalid for every target (and hence generate the expected warning).
>
> I reproduced the problem on i686-pc-linux-gnu, and the patch fixes
> it there.
>
> Committed to trunk as r244502.
>
> Does this fix the test for you?
>
Yes, they pass now.
Thanks

> Thanks; sorry again.
> Dave
>
> gcc/testsuite/ChangeLog:
>         PR c/78304
>         * gcc.dg/format/pr78304.c: Convert argument from integral type
>         to a pointer.
>         * gcc.dg/format/pr78304-2.c: Likewise.
> ---
>  gcc/testsuite/gcc.dg/format/pr78304-2.c | 4 ++--
>  gcc/testsuite/gcc.dg/format/pr78304.c   | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/testsuite/gcc.dg/format/pr78304-2.c b/gcc/testsuite/gcc.dg/format/pr78304-2.c
> index 5ee6d65..83648c4 100644
> --- a/gcc/testsuite/gcc.dg/format/pr78304-2.c
> +++ b/gcc/testsuite/gcc.dg/format/pr78304-2.c
> @@ -5,7 +5,7 @@ extern int printf (const char *, ...);
>
>  # define PRIu32                "u"
>
> -void test (long size)
> +void test (const char *msg)
>  {
> -  printf ("size: %" PRIu32 "\n", size); /* { dg-warning "expects argument of type" } */
> +  printf ("size: %" PRIu32 "\n", msg); /* { dg-warning "expects argument of type" } */
>  }
> diff --git a/gcc/testsuite/gcc.dg/format/pr78304.c b/gcc/testsuite/gcc.dg/format/pr78304.c
> index d0a96f6..f6ad807 100644
> --- a/gcc/testsuite/gcc.dg/format/pr78304.c
> +++ b/gcc/testsuite/gcc.dg/format/pr78304.c
> @@ -4,7 +4,7 @@
>  #include <inttypes.h>
>  #include <stdio.h>
>
> -void test (size_t size)
> +void test (const char *msg)
>  {
> -  printf ("size: %" PRIu32 "\n", size); /* { dg-warning "expects argument of type" } */
> +  printf ("size: %" PRIu32 "\n", msg); /* { dg-warning "expects argument of type" } */
>  }
> --
> 1.8.5.3
>



More information about the Gcc-patches mailing list