diff mbox series

[7/7,MSP430,TESTSUITE] Fix tests for msp430-elf large memory model

Message ID 5c55c4ab-b746-6e6a-f7c9-8d62bc6ac19b@mittosystems.com
State New
Headers show
Series Fix GCC tests for msp430-elf | expand

Commit Message

Jozef Lawrynowicz Nov. 14, 2018, 3:59 p.m. UTC
Patch 7 fixes tests for msp430-elf in the large memory model.
diff mbox series

Patch

From 494465f13df814bf3daad5e330d2c7139f2db625 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Sat, 10 Nov 2018 16:08:44 +0000
Subject: [PATCH 7/7] [TESTSUITE] Fix tests for msp430-elf large memory model

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

	gcc/testsuite/ChangeLog:

	* gcc.c-torture/execute/991014-1.c: Fix bufsize definition for
	msp430 large memory model.
	* gcc.dg/Walloca-1.c: Don't expect warning for msp430 large memory
	model.
	* gcc.dg/Walloca-2.c: Likewise.
	* gcc.dg/c99-const-expr-2.c: Define ZERO macro for msp430 large memory
	model.
	* gcc.dg/format/format.h: Prefix typedefs using __SIZE_TYPE__ and
	__PTRDIFF_TYPE__ with __extension__.
	* gcc.dg/lto/20081210-1_0.c: Always typedef uintptr_t as
	__UINTPTR_TYPE__.
	* gcc.dg/pr36227.c: Likewise.
	* gcc.dg/pr42611.c: Use __INTPTR_MAX__ as the maximum object size if
	size_t and ptr_t are the same size.
	* gcc.dg/pr78973.c: dg-warning XFAIL for int16 but not msp430 large
	memory model.
	* gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: Update dg-warning
	directives for msp430 large memory model.
	* gcc.dg/tree-ssa/pr66449.c: Always use __INTPTR_TYPE__ when integer
	type equal in size to ptr_t is required.
	* gcc.dg/tree-ssa/ssa-dom-thread-8.c: Extend pointer size checking
	macro for msp430.
	* lib/target-supports.exp (check_effective_target_msp430_large_mem):
	New. 

---
 gcc/testsuite/gcc.c-torture/execute/991014-1.c     |  7 ++++-
 gcc/testsuite/gcc.dg/Walloca-1.c                   |  4 +--
 gcc/testsuite/gcc.dg/Walloca-2.c                   |  8 +++---
 gcc/testsuite/gcc.dg/c99-const-expr-2.c            |  2 ++
 gcc/testsuite/gcc.dg/format/format.h               |  6 ++--
 gcc/testsuite/gcc.dg/lto/20081210-1_0.c            |  8 +-----
 gcc/testsuite/gcc.dg/pr36227.c                     | 10 +------
 gcc/testsuite/gcc.dg/pr42611.c                     |  3 +-
 gcc/testsuite/gcc.dg/pr78973.c                     |  2 +-
 .../gcc.dg/tree-ssa/builtin-sprintf-warn-3.c       | 32 +++++++++++-----------
 gcc/testsuite/gcc.dg/tree-ssa/pr66449.c            |  8 ++----
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-8.c   |  8 +++---
 gcc/testsuite/lib/target-supports.exp              |  7 +++++
 13 files changed, 52 insertions(+), 53 deletions(-)

diff --git a/gcc/testsuite/gcc.c-torture/execute/991014-1.c b/gcc/testsuite/gcc.c-torture/execute/991014-1.c
index e0bcd6d..95e38ce 100644
--- a/gcc/testsuite/gcc.c-torture/execute/991014-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/991014-1.c
@@ -1,11 +1,16 @@ 
-
 typedef __SIZE_TYPE__ Size_t;
 
+#ifdef __MSP430X_LARGE__
+/* size_t is __int20, so 20 bits, for __MSP430X_LARGE__, but __SIZEOF_POINTER__
+   returns the bytesize which is 4.  */
+#define bufsize ((1L << (20 - 2))-256)
+#else  /* !__MSP430X_LARGE__ */
 #if __SIZEOF_LONG__ < __SIZEOF_POINTER__
 #define bufsize ((1LL << (8 * sizeof(Size_t) - 2))-256)
 #else
 #define bufsize ((1L << (8 * sizeof(Size_t) - 2))-256)
 #endif
+#endif
 
 struct huge_struct
 {
diff --git a/gcc/testsuite/gcc.dg/Walloca-1.c b/gcc/testsuite/gcc.dg/Walloca-1.c
index 85e9160..c9a6c57 100644
--- a/gcc/testsuite/gcc.dg/Walloca-1.c
+++ b/gcc/testsuite/gcc.dg/Walloca-1.c
@@ -24,8 +24,8 @@  void foo1 (size_t len, size_t len2, size_t len3)
   char *s = alloca (123);
   useit (s);			// OK, constant argument to alloca
 
-  s = alloca (num);		// { dg-warning "large due to conversion" "" { target lp64 } }
-  // { dg-warning "unbounded use of 'alloca'" "" { target { ! lp64 } } .-1 }
+  s = alloca (num);		// { dg-warning "large due to conversion" "" { target { { lp64 } || { msp430_large_mem } } } }
+  // { dg-warning "unbounded use of 'alloca'" "" { target { { ! lp64 } && { ! msp430_large_mem } } } .-1 }
   useit (s);
 
   s = alloca (30000);		/* { dg-warning "is too large" } */
diff --git a/gcc/testsuite/gcc.dg/Walloca-2.c b/gcc/testsuite/gcc.dg/Walloca-2.c
index 766ff8d..446c811 100644
--- a/gcc/testsuite/gcc.dg/Walloca-2.c
+++ b/gcc/testsuite/gcc.dg/Walloca-2.c
@@ -13,7 +13,7 @@  g1 (int n)
     // 32-bit targets because VRP is not giving us any range info for
     // the argument to __builtin_alloca.  This should be fixed by the
     // upcoming range work.
-    p = __builtin_alloca (n); // { dg-bogus "unbounded use of 'alloca'" "" { xfail { ! lp64 } } }
+    p = __builtin_alloca (n); // { dg-bogus "unbounded use of 'alloca'" "" { xfail { { ! lp64 } && { ! msp430_large_mem } } } }
   else
     p = __builtin_malloc (n);
   f (p);
@@ -36,9 +36,9 @@  g3 (int n)
   void *p;
   if (n > 0 && n < 3000)
     {
-      p = __builtin_alloca (n); // { dg-warning "'alloca' may be too large" "" { target lp64} }
-      // { dg-message "note:.*argument may be as large as 2999" "note" { target lp64 } .-1 }
-      // { dg-warning "unbounded use of 'alloca'" "" { target { ! lp64 } } .-2 }
+      p = __builtin_alloca (n); // { dg-warning "'alloca' may be too large" "" { target { lp64 || msp430_large_mem } } }
+      // { dg-message "note:.*argument may be as large as 2999" "note" { target { lp64 || msp430_large_mem } } .-1 }
+      // { dg-warning "unbounded use of 'alloca'" "" { target { { ! lp64 } && { ! msp430_large_mem } } } .-2 }
     }
   else
     p = __builtin_malloc (n);
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-2.c b/gcc/testsuite/gcc.dg/c99-const-expr-2.c
index a78e412..2b85706 100644
--- a/gcc/testsuite/gcc.dg/c99-const-expr-2.c
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-2.c
@@ -18,6 +18,8 @@  long *c;
 #define ZERO 0L
 #elif defined(_WIN64)
 #define ZERO 0LL
+#elif defined(__MSP430X_LARGE__)
+#define ZERO (__int20)0
 #else
 #define ZERO 0
 #endif
diff --git a/gcc/testsuite/gcc.dg/format/format.h b/gcc/testsuite/gcc.dg/format/format.h
index a99927e..2d0a71b 100644
--- a/gcc/testsuite/gcc.dg/format/format.h
+++ b/gcc/testsuite/gcc.dg/format/format.h
@@ -58,12 +58,12 @@  __extension__ typedef unsigned int ullong  __attribute__ ((mode (DI)));
 #else
 /* Kludges to get types corresponding to size_t and ptrdiff_t.  */
 #define unsigned signed
-typedef __SIZE_TYPE__ signed_size_t;
+__extension__ typedef __SIZE_TYPE__ signed_size_t;
 /* We also use this type to approximate ssize_t.  */
-typedef __SIZE_TYPE__ ssize_t;
+__extension__ typedef __SIZE_TYPE__ ssize_t;
 #undef unsigned
 #define signed /* Type might or might not have explicit 'signed'.  */
-typedef unsigned __PTRDIFF_TYPE__ unsigned_ptrdiff_t;
+__extension__ typedef unsigned __PTRDIFF_TYPE__ unsigned_ptrdiff_t;
 #undef signed
 
 __extension__ typedef long long int llong;
diff --git a/gcc/testsuite/gcc.dg/lto/20081210-1_0.c b/gcc/testsuite/gcc.dg/lto/20081210-1_0.c
index 80a1e9a..8048b26 100644
--- a/gcc/testsuite/gcc.dg/lto/20081210-1_0.c
+++ b/gcc/testsuite/gcc.dg/lto/20081210-1_0.c
@@ -1,10 +1,4 @@ 
-#if defined(_LP64)
-typedef unsigned long int uintptr_t;
-#elif defined (_WIN64)
-typedef unsigned long long int uintptr_t;
-#else
-typedef unsigned int uintptr_t;
-#endif
+typedef __UINTPTR_TYPE__ uintptr_t;
 
 extern void srand (uintptr_t);
 
diff --git a/gcc/testsuite/gcc.dg/pr36227.c b/gcc/testsuite/gcc.dg/pr36227.c
index 27fe001..ba0d722 100644
--- a/gcc/testsuite/gcc.dg/pr36227.c
+++ b/gcc/testsuite/gcc.dg/pr36227.c
@@ -1,14 +1,6 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O2 -Wstrict-overflow=3" } */
-#if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__)
-typedef unsigned long long ptrcast;
-#elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__)
-typedef unsigned long ptrcast;
-#elif (__SIZEOF_INT__ == __SIZEOF_POINTER__)
-typedef unsigned int ptrcast;
-#else
-#error Add target support here
-#endif
+typedef __UINTPTR_TYPE__ ptrcast;
 
 volatile unsigned long *
 sat_add(volatile unsigned long *ptr, unsigned long i, volatile unsigned long *end)
diff --git a/gcc/testsuite/gcc.dg/pr42611.c b/gcc/testsuite/gcc.dg/pr42611.c
index 0426ce2..f502fea 100644
--- a/gcc/testsuite/gcc.dg/pr42611.c
+++ b/gcc/testsuite/gcc.dg/pr42611.c
@@ -3,7 +3,8 @@ 
 /* { dg-options "" } */
 
 #define L \
-  (sizeof (__SIZE_TYPE__) == 1 ? __SCHAR_MAX__				\
+  (sizeof (__SIZE_TYPE__) == sizeof (void *) ? __INTPTR_MAX__ \
+  : sizeof (__SIZE_TYPE__) == 1 ? __SCHAR_MAX__				\
   : sizeof (__SIZE_TYPE__) == sizeof (short) ? __SHRT_MAX__		\
   : sizeof (__SIZE_TYPE__) == sizeof (int) ? __INT_MAX__		\
   : sizeof (__SIZE_TYPE__) == sizeof (long) ? __LONG_MAX__		\
diff --git a/gcc/testsuite/gcc.dg/pr78973.c b/gcc/testsuite/gcc.dg/pr78973.c
index 6c53f89..e0148bbc 100644
--- a/gcc/testsuite/gcc.dg/pr78973.c
+++ b/gcc/testsuite/gcc.dg/pr78973.c
@@ -9,7 +9,7 @@ 
 void f (void *p, int n)
 {
   if (n <= 4)
-    __builtin_memset (p, 0, n);   /* { dg-warning "exceeds maximum object size" "pr79073" { xfail ilp32 } } */
+    __builtin_memset (p, 0, n);   /* { dg-warning "exceeds maximum object size" "pr79073" { xfail { ilp32 || { int16 && { ! msp430_large_mem } } } } } */
 }
 
 void g (void *d, unsigned n)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c
index d06248b..30a44a1 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-3.c
@@ -357,35 +357,35 @@  void test_too_large (char *d, int x, __builtin_va_list va)
   const size_t imax_p1 = imax + 1;
 
   __builtin_snprintf (d, imax,    "%c", x);
-  __builtin_snprintf (d, imax_p1, "%c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target lp64 } } */
-  /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { avr-*-* } || ilp32 } } .-1 } */
+  __builtin_snprintf (d, imax_p1, "%c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target { lp64 || msp430_large_mem } } } */
+  /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { ilp32 } || { int16 && { ! msp430_large_mem } } } } .-1 } */
 
   __builtin_vsnprintf (d, imax,    "%c", va);
-  __builtin_vsnprintf (d, imax_p1, "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target lp64 } } */
-  /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { avr-*-* } || ilp32 } } .-1 } */
+  __builtin_vsnprintf (d, imax_p1, "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target { lp64 || msp430_large_mem } } } */
+  /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { ilp32 } || { int16 && { ! msp430_large_mem } } } } .-1 } */
 
   __builtin___snprintf_chk (d, imax,    0, imax,    "%c", x);
-  __builtin___snprintf_chk (d, imax_p1, 0, imax_p1, "%c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target lp64 } } */
-  /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { avr-*-* } || ilp32 } } .-1 } */
+  __builtin___snprintf_chk (d, imax_p1, 0, imax_p1, "%c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target { lp64 || msp430_large_mem } } } */
+  /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { ilp32 } || { int16 && { ! msp430_large_mem } } } } .-1 } */
 
   __builtin___vsnprintf_chk (d, imax,    0, imax,    "%c", va);
-  __builtin___vsnprintf_chk (d, imax_p1, 0, imax_p1, "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target lp64 } } */
-  /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { avr-*-* } || ilp32 } } .-1 } */
+  __builtin___vsnprintf_chk (d, imax_p1, 0, imax_p1, "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "INT_MAX + 1" { target { lp64 || msp430_large_mem } } } */
+  /* { dg-warning "specified bound \[0-9\]+ exceeds maximum object size" "INT_MAX + 1" { target { { ilp32 } || { int16 && { ! msp430_large_mem } } } } .-1 } */
 
   const size_t ptrmax = __PTRDIFF_MAX__;
   const size_t ptrmax_m1 = ptrmax - 1;
 
-  __builtin_snprintf (d, ptrmax_m1, "%c", x);  /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX - 1" { target lp64 } } */
-  __builtin_snprintf (d, ptrmax, "  %c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX" { target lp64 } } */
+  __builtin_snprintf (d, ptrmax_m1, "%c", x);  /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX - 1" { target { lp64 || msp430_large_mem } } } */
+  __builtin_snprintf (d, ptrmax, "  %c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX" { target { lp64 || msp430_large_mem } } } */
 
-  __builtin_vsnprintf (d, ptrmax_m1, "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX - 1" { target lp64 } } */
-  __builtin_vsnprintf (d, ptrmax,    "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX" { target lp64 } } */
+  __builtin_vsnprintf (d, ptrmax_m1, "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX - 1" { target { lp64 || msp430_large_mem } } } */
+  __builtin_vsnprintf (d, ptrmax,    "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX" { target { lp64 || msp430_large_mem } } } */
 
-  __builtin___snprintf_chk (d, ptrmax_m1, 0, ptrmax_m1, "%c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX - 1" { target lp64 } } */
-  __builtin___snprintf_chk (d, ptrmax,    0, ptrmax,    "%c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX" { target lp64 } } */
+  __builtin___snprintf_chk (d, ptrmax_m1, 0, ptrmax_m1, "%c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX - 1" { target { lp64 || msp430_large_mem } } } */
+  __builtin___snprintf_chk (d, ptrmax,    0, ptrmax,    "%c", x);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX" { target { lp64 || msp430_large_mem } } } */
 
-  __builtin___vsnprintf_chk (d, ptrmax_m1, 0, ptrmax_m1, "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX - 1" { target lp64 } } */
-  __builtin___vsnprintf_chk (d, ptrmax,    0, ptrmax,    "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX" { target lp64 } } */
+  __builtin___vsnprintf_chk (d, ptrmax_m1, 0, ptrmax_m1, "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX - 1" { target { lp64 || msp430_large_mem } } } */
+  __builtin___vsnprintf_chk (d, ptrmax,    0, ptrmax,    "%c", va);   /* { dg-warning "specified bound \[0-9\]+ exceeds .INT_MAX." "PTRDIFF_MAX" { target { lp64 || msp430_large_mem } } } */
 }
 
 /* Exercise ordinary sprintf with malloc.  */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr66449.c b/gcc/testsuite/gcc.dg/tree-ssa/pr66449.c
index cce26eb..3b6de12 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr66449.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr66449.c
@@ -1,13 +1,11 @@ 
 /* { dg-do compile } */
 /* { dg-options "-O3" } */
 
-#if __SIZEOF_POINTER__ != __SIZEOF_LONG__
-#define long __INTPTR_TYPE__
-#endif
+#define intptr_t __INTPTR_TYPE__
 
-void *fn1(void *p1, void *p2, long p3)
+void *fn1(void *p1, void *p2, intptr_t p3)
 {
-  long a = (long)p1, b = (long)p2, c = p3;
+  intptr_t a = (intptr_t)p1, b = (intptr_t)p2, c = p3;
 
   while (c)
     {
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-8.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-8.c
index c456d73..bea0f89 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-8.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-8.c
@@ -300,9 +300,9 @@  f2 (struct C *x)
 	  else
 	    {
 	      o = f2 (x);
-#if __SIZEOF_POINTER__ == __SIZEOF_LONG__
+#if __SIZEOF_POINTER__ == __SIZEOF_LONG__ && !__MSP430X_LARGE__
 	      if (((unsigned long) o > (unsigned long) -4000L))
-#elif __SIZEOF_POINTER__ == __SIZEOF_INT__
+#else
 	  if (((__UINTPTR_TYPE__) o > (__UINTPTR_TYPE__) -4000U))
 #endif
 		{
@@ -388,9 +388,9 @@  f2 (struct C *x)
 	  break;
 	case 19:
 	  o = f2 (x);
-#if __SIZEOF_POINTER__ == __SIZEOF_LONG__
+#if __SIZEOF_POINTER__ == __SIZEOF_LONG__ && !__MSP430X_LARGE__
 	  if (((unsigned long) o > (unsigned long) -4000L))
-#elif __SIZEOF_POINTER__ == __SIZEOF_INT__
+#else
 	  if (((__UINTPTR_TYPE__) o > (__UINTPTR_TYPE__) -4000U))
 #endif
 	    {
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index ced1582..042a3cb 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -8950,3 +8950,10 @@  proc check_effective_target_cet { } {
 proc check_effective_target_newlib_nano_io { } {
     return [check_configured_with "--enable-newlib-nano-formatted-io"]
 }
+proc check_effective_target_msp430_large_mem {} {
+    return [check_no_compiler_messages msp430_large assembly {
+	#ifndef __MSP430X_LARGE__
+	#error
+	#endif
+    } ""]
+}
-- 
2.7.4