[committed,testsuite,MSP430,4/4] Fix calculation of USHRT_MAX in tests

Message ID e7d4ee7d-c30d-644c-2dbf-fd77d04ff1e6@mittosystems.com
State New
Headers show
Series
  • "Obvious" fixes to GCC tests for msp430-elf
Related show

Commit Message

Jozef Lawrynowicz Nov. 8, 2018, 4:54 p.m.
Patch 4 fixes the calculation of USHRT_MAX in some tests, to prevent integer
overflow for targets where sizeof(short) == sizeof(int). i.e.
   -#define USHRT_MAX (SHRT_MAX * 2 + 1)
   +#define USHRT_MAX (SHRT_MAX * 2U + 1)

Patch

From 6a6580c486a7705798c5a2c9898f46e7a319976b Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Tue, 6 Nov 2018 12:50:01 +0000
Subject: [PATCH 4/4] [TESTSUITE] size of short == size of int

2018-11-08  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	gcc/testsuite/ChangeLog:

	* gcc.dg/attr-alloc_size-10.c: Fix calculation of USHRT_MAX to prevent
	integer overflow when sizeof(short) == sizeof(int).
	* gcc.dg/attr-alloc_size-11.c: Likewise.
	* gcc.dg/attr-alloc_size-3.c: Likewise.
	* gcc.dg/attr-alloc_size-5.c: Likewise.
	* gcc.dg/builtin-stringop-chk-7.c: Likewise.
---
 gcc/testsuite/gcc.dg/attr-alloc_size-10.c     | 2 +-
 gcc/testsuite/gcc.dg/attr-alloc_size-11.c     | 2 +-
 gcc/testsuite/gcc.dg/attr-alloc_size-3.c      | 2 +-
 gcc/testsuite/gcc.dg/attr-alloc_size-5.c      | 2 +-
 gcc/testsuite/gcc.dg/builtin-stringop-chk-7.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-10.c b/gcc/testsuite/gcc.dg/attr-alloc_size-10.c
index 4080717..071c6aa 100644
--- a/gcc/testsuite/gcc.dg/attr-alloc_size-10.c
+++ b/gcc/testsuite/gcc.dg/attr-alloc_size-10.c
@@ -13,7 +13,7 @@ 
 
 #define SHRT_MAX  __SHRT_MAX__
 #define SHRT_MIN  (-SHRT_MAX - 1)
-#define USHRT_MAX (SHRT_MAX * 2 + 1)
+#define USHRT_MAX (SHRT_MAX * 2U + 1)
 
 #define INT_MAX   __INT_MAX__
 #define INT_MIN   (-INT_MAX - 1)
diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-11.c b/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
index 301a06f..7f2fc49 100644
--- a/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
+++ b/gcc/testsuite/gcc.dg/attr-alloc_size-11.c
@@ -11,7 +11,7 @@ 
 
 #define SHRT_MAX  __SHRT_MAX__
 #define SHRT_MIN  (-SHRT_MAX - 1)
-#define USHRT_MAX (SHRT_MAX * 2 + 1)
+#define USHRT_MAX (SHRT_MAX * 2U + 1)
 
 #define INT_MAX   __INT_MAX__
 #define INT_MIN   (-INT_MAX - 1)
diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-3.c b/gcc/testsuite/gcc.dg/attr-alloc_size-3.c
index 96ff077..7e8c22f 100644
--- a/gcc/testsuite/gcc.dg/attr-alloc_size-3.c
+++ b/gcc/testsuite/gcc.dg/attr-alloc_size-3.c
@@ -14,7 +14,7 @@ 
 
 #define SHRT_MAX   __SHRT_MAX__
 #define SHRT_MIN   (-SHRT_MAX - 1)
-#define USHRT_MAX  (SHRT_MAX * 2 + 1)
+#define USHRT_MAX  (SHRT_MAX * 2U + 1)
 
 #define INT_MAX    __INT_MAX__
 #define INT_MIN    (-INT_MAX - 1)
diff --git a/gcc/testsuite/gcc.dg/attr-alloc_size-5.c b/gcc/testsuite/gcc.dg/attr-alloc_size-5.c
index f9884ed..26ee43f 100644
--- a/gcc/testsuite/gcc.dg/attr-alloc_size-5.c
+++ b/gcc/testsuite/gcc.dg/attr-alloc_size-5.c
@@ -12,7 +12,7 @@ 
 
 #define SHRT_MAX   __SHRT_MAX__
 #define SHRT_MIN   (-SHRT_MAX - 1)
-#define USHRT_MAX  (SHRT_MAX * 2 + 1)
+#define USHRT_MAX  (SHRT_MAX * 2U + 1)
 
 #define INT_MAX    __INT_MAX__
 #define INT_MIN    (-INT_MAX - 1)
diff --git a/gcc/testsuite/gcc.dg/builtin-stringop-chk-7.c b/gcc/testsuite/gcc.dg/builtin-stringop-chk-7.c
index 173e4ff..d3908a2 100644
--- a/gcc/testsuite/gcc.dg/builtin-stringop-chk-7.c
+++ b/gcc/testsuite/gcc.dg/builtin-stringop-chk-7.c
@@ -9,7 +9,7 @@ 
 #define UCHAR_MAX (SCHAR_MAX * 2 + 1)
 
 #define SHRT_MAX  __SHRT_MAX__
-#define USHRT_MAX (SHRT_MAX * 2 + 1)
+#define USHRT_MAX (SHRT_MAX * 2U + 1)
 
 #define INT_MAX   __INT_MAX__
 #define UINT_MAX  (INT_MAX * 2U + 1)
-- 
2.7.4