diff mbox

[testsuite] Fix gcc.dg/pr60114.c on arm/aarch64

Message ID 535E38ED.7010906@arm.com
State New
Headers show

Commit Message

Kyrylo Tkachov April 28, 2014, 11:18 a.m. UTC
Hi all,

I noticed this test is failing on aarch64:

FAIL: gcc.dg/pr60114.c  (test for warnings, line 7)
FAIL: gcc.dg/pr60114.c  (test for warnings, line 8)
FAIL: gcc.dg/pr60114.c  (test for warnings, line 21)
FAIL: gcc.dg/pr60114.c  (test for warnings, line 22)
FAIL: gcc.dg/pr60114.c  (test for warnings, line 23)
FAIL: gcc.dg/pr60114.c  (test for warnings, line 25)
FAIL: gcc.dg/pr60114.c (test for excess errors)

The test was recently added with 
http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00592.html

The offending code is of the form:


const char z[] = {
   [0] = 0x100, /* { dg-warning "9:overflow in implicit constant conversion" } */
   [2] = 0x101, /* { dg-warning "9:overflow in implicit constant conversion" } */
};


On aarch64 (and arm) chars are unsigned by default so instead we get the warning 
"large integer implicitly truncated to unsigned type".

This patch explicitly uses signed chars in the test as suggested by richi in the PR.

Ok for trunk?

Thanks,
Kyrill

2014-04-28  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR c/60983
     * gcc.dg/pr60114.c: Use signed chars.

Comments

Marek Polacek April 28, 2014, 12:02 p.m. UTC | #1
On Mon, Apr 28, 2014 at 12:18:05PM +0100, Kyrill Tkachov wrote:
> Hi all,
> 
> I noticed this test is failing on aarch64:
> 
> FAIL: gcc.dg/pr60114.c  (test for warnings, line 7)
> FAIL: gcc.dg/pr60114.c  (test for warnings, line 8)
> FAIL: gcc.dg/pr60114.c  (test for warnings, line 21)
> FAIL: gcc.dg/pr60114.c  (test for warnings, line 22)
> FAIL: gcc.dg/pr60114.c  (test for warnings, line 23)
> FAIL: gcc.dg/pr60114.c  (test for warnings, line 25)
> FAIL: gcc.dg/pr60114.c (test for excess errors)
> 
> The test was recently added with
> http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00592.html
 
Sorry, I tested x86_64, both -m64 and -m32, but I don't test ARM.

> The offending code is of the form:
> 
> 
> const char z[] = {
>   [0] = 0x100, /* { dg-warning "9:overflow in implicit constant conversion" } */
>   [2] = 0x101, /* { dg-warning "9:overflow in implicit constant conversion" } */
> };
> 
> 
> On aarch64 (and arm) chars are unsigned by default so instead we get
> the warning "large integer implicitly truncated to unsigned type".
> 
> This patch explicitly uses signed chars in the test as suggested by richi in the PR.
> 
> Ok for trunk?

Looks good.

	Marek
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.dg/pr60114.c b/gcc/testsuite/gcc.dg/pr60114.c
index 83f9852..c656a95 100644
--- a/gcc/testsuite/gcc.dg/pr60114.c
+++ b/gcc/testsuite/gcc.dg/pr60114.c
@@ -3,7 +3,7 @@ 
 /* { dg-options "-Wconversion" } */
 
 struct S { int n, u[2]; };
-const char z[] = {
+const signed char z[] = {
   [0] = 0x100, /* { dg-warning "9:overflow in implicit constant conversion" } */
   [2] = 0x101, /* { dg-warning "9:overflow in implicit constant conversion" } */
 };
@@ -18,11 +18,11 @@  typedef int H[];
 void
 foo (void)
 {
-  char a[][3] = { { 0x100, /* { dg-warning "21:overflow in implicit constant conversion" } */
+  signed char a[][3] = { { 0x100, /* { dg-warning "28:overflow in implicit constant conversion" } */
                     1, 0x100 }, /* { dg-warning "24:overflow in implicit constant conversion" } */
                   { '\0', 0x100, '\0' } /* { dg-warning "27:overflow in implicit constant conversion" } */
                 };
-  (const char []) { 0x100 }; /* { dg-warning "21:overflow in implicit constant conversion" } */
+  (const signed char []) { 0x100 }; /* { dg-warning "28:overflow in implicit constant conversion" } */
   (const float []) { 1e0, 1e1, 1e100 }; /* { dg-warning "32:conversion" } */
   struct S s1 = { 0x80000000 }; /* { dg-warning "19:conversion of unsigned constant value to negative integer" } */
   struct S s2 = { .n = 0x80000000 }; /* { dg-warning "24:conversion of unsigned constant value to negative integer" } */