aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSenthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>2016-11-16 09:28:40 +0000
committerSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>2016-11-16 09:28:40 +0000
commit4786fabecc8559f04eed93d3d49738680b52536b (patch)
tree21c370d260e45cb1cbf0398b895943c99a39effe /gcc
parentb6adf1c5fb249497a0f35a2ffb9897b35764d3c9 (diff)
downloadgcc-4786fabecc8559f04eed93d3d49738680b52536b.zip
gcc-4786fabecc8559f04eed93d3d49738680b52536b.tar.gz
gcc-4786fabecc8559f04eed93d3d49738680b52536b.tar.bz2
Fix bogus failure of Wlogical-op-1.c for avr
The test assumes short is always smaller than int, and therefore does not expect a warning when the logical operands are of type short and int. This isn't true for the avr - shorts and ints are of the same size, and therefore the warning triggers for the above case also. Fix by explicitly typedef'ing __INT32_TYPE for int and __INT16_TYPE__ for short if the target's int size is less than 4 bytes. gcc/testsuite/ 2016-11-16 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com> * c-c++-common/Wlogical-op-1.c: Use __INT{16,32}_TYPE__ instead of {short,int} if __SIZEOF_INT__ is less than 4 bytes. From-SVN: r242472
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/Wlogical-op-1.c28
2 files changed, 24 insertions, 9 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3da84c6..00f1166 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-16 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
+
+ * c-c++-common/Wlogical-op-1.c: Use __INT{16,32}_TYPE__ instead
+ of {short,int} if __SIZEOF_INT__ is less than 4 bytes.
+
2016-11-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/78348
diff --git a/gcc/testsuite/c-c++-common/Wlogical-op-1.c b/gcc/testsuite/c-c++-common/Wlogical-op-1.c
index 33d4f38..c5f992a 100644
--- a/gcc/testsuite/c-c++-common/Wlogical-op-1.c
+++ b/gcc/testsuite/c-c++-common/Wlogical-op-1.c
@@ -8,12 +8,22 @@
# define false 0
#endif
-extern int bar (void);
-extern int *p;
-struct R { int a, b; } S;
+#if __SIZEOF_INT__ < 4
+ __extension__ typedef __INT32_TYPE__ int32_t;
+ __extension__ typedef __UINT32_TYPE__ uint32_t;
+ __extension__ typedef __INT16_TYPE__ int16_t;
+#else
+ typedef int int32_t;
+ typedef unsigned int uint32_t;
+ typedef short int16_t;
+#endif
+
+extern int32_t bar (void);
+extern int32_t *p;
+struct R { int32_t a, b; } S;
void
-andfn (int a, int b)
+andfn (int32_t a, int32_t b)
{
if (a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
if (!a && !a) {} /* { dg-warning "logical .and. of equal expressions" } */
@@ -34,7 +44,7 @@ andfn (int a, int b)
if (p[0] && p[0]) {} /* { dg-warning "logical .and. of equal expressions" } */
if (S.a && S.a) {} /* { dg-warning "logical .and. of equal expressions" } */
if ((bool) a && (bool) a) {} /* { dg-warning "logical .and. of equal expressions" } */
- if ((unsigned) a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
+ if ((uint32_t) a && a) {} /* { dg-warning "logical .and. of equal expressions" } */
/* Stay quiet here. */
if (a && b) {}
@@ -48,7 +58,7 @@ andfn (int a, int b)
if (a > 0 && a > 1) {}
if (a > -2 && a > 1) {}
- if (a && (short) a) {}
+ if (a && (int16_t) a) {}
if ((char) a && a) {}
if (++a && a) {}
if (++a && ++a) {}
@@ -61,7 +71,7 @@ andfn (int a, int b)
}
void
-orfn (int a, int b)
+orfn (int32_t a, int32_t b)
{
if (a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
if (!a || !a) {} /* { dg-warning "logical .or. of equal expressions" } */
@@ -82,7 +92,7 @@ orfn (int a, int b)
if (p[0] || p[0]) {} /* { dg-warning "logical .or. of equal expressions" } */
if (S.a || S.a) {} /* { dg-warning "logical .or. of equal expressions" } */
if ((bool) a || (bool) a) {} /* { dg-warning "logical .or. of equal expressions" } */
- if ((unsigned) a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
+ if ((uint32_t) a || a) {} /* { dg-warning "logical .or. of equal expressions" } */
/* Stay quiet here. */
if (a || b) {}
@@ -96,7 +106,7 @@ orfn (int a, int b)
if (a > 0 || a > 1) {}
if (a > -2 || a > 1) {}
- if (a || (short) a) {}
+ if (a || (int16_t) a) {}
if ((char) a || a) {}
if (++a || a) {}
if (++a || ++a) {}