This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch/testsuite] PR 18246 Allow compat-struct-layout tests to function on mingw32


Hello,
The C and C++ compat-struct-layout tests generated by the testsuite fail
on
mingw32 because the target's printf (from MSVCRT.dll) does not recognize
the
"ll" format specifier, but uses "I64" instead.

This patch allows all these tests to succeed.

Danny

:ADDPATCH testsuite

2007-07-19  Danny Smith  <dannysmith@users.sourceforge.net>

	PR 18246
	* gcc.dg/compat/struct-layout-1_generate.c (COMPAT_PRLL): Define
	and use throughout as long long printf format specifier.
	* g++.dg/compat/struct-layout-1_generate.c (COMPAT_PRLL):
Likewise.



Index: gcc.dg/compat/struct-layout-1_generate.c
===================================================================
--- gcc.dg/compat/struct-layout-1_generate.c	(revision 126673)
+++ gcc.dg/compat/struct-layout-1_generate.c	(working copy)
@@ -36,6 +36,12 @@
 # error Need 64-bit long long
 #endif
 
+#if defined __MSVCRT__ 
+#define COMPAT_PRLL "I64"
+#else 
+#define COMPAT_PRLL "ll"
+#endif
+
 typedef unsigned int hashval_t;
 
 enum TYPE
@@ -1038,7 +1044,7 @@
 	m &= e->len > 1 ? (1ULL << (e->len - 1)) - 1 : 1;
       l1 &= m;
       l2 &= m;
-      fprintf (outfile, "%s%llu%s,%s%llu%s",
+      fprintf (outfile, "%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s",
 	       (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
 	       (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
       break;
@@ -1048,7 +1054,8 @@
 	m &= (1ULL << e->len) - 1;
       l1 &= m;
       l2 &= m;
-      fprintf (outfile, "%lluU%s,%lluU%s", l1, l1 > 4294967295U ? "LL"
: "",
+      fprintf (outfile, "%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s",
+	       l1, l1 > 4294967295U ? "LL" : "",
 	       l2, l2 > 4294967295U ? "LL" : "");
       break;
     case TYPE_FLOAT:
@@ -1085,7 +1092,8 @@
       signs = generate_random () & 3;
       l1 &= e->type->maxval;
       l2 &= e->type->maxval;
-      fprintf (outfile, "CINT(%s%llu%s,%s%llu%s),",
+      fprintf (outfile,
+	       "CINT(%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s),",
 	       (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
 	       (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
       signs = generate_random () & 3;
@@ -1093,21 +1101,24 @@
       l2 = getrandll ();
       l1 &= e->type->maxval;
       l2 &= e->type->maxval;
-      fprintf (outfile, "CINT(%s%llu%s,%s%llu%s)",
+      fprintf (outfile,
+	       "CINT(%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s)",
 	       (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
 	       (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
       break;
     case TYPE_CUINT:
       l1 &= e->type->maxval;
       l2 &= e->type->maxval;
-      fprintf (outfile, "CINT(%lluU%s,%lluU%s),",
+      fprintf (outfile,
+	       "CINT(%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s),",
 	       l1, l1 > 4294967295U ? "LL" : "",
 	       l2, l2 > 4294967295U ? "LL" : "");
       l1 = getrandll ();
       l2 = getrandll ();
       l1 &= e->type->maxval;
       l2 &= e->type->maxval;
-      fprintf (outfile, "CINT(%lluU%s,%lluU%s)",
+      fprintf (outfile,
+	       "CINT(%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s)",
 	       l1, l1 > 4294967295U ? "LL" : "",
 	       l2, l2 > 4294967295U ? "LL" : "");
       break;
@@ -1131,7 +1142,8 @@
       if (e->type->maxval == 0)
 	fputs ("e0_0,e0_0", outfile);
       else if (e->type->maxval == 1)
-        fprintf (outfile, "e1_%lld,e1_%lld", l1 & 1, l2 & 1);
+        fprintf (outfile, "e1_%" COMPAT_PRLL "d,e1_%" COMPAT_PRLL "d",
+		 l1 & 1, l2 & 1);
       else
         {
 	  p = strchr (e->type->name, '\0');
@@ -1143,7 +1155,8 @@
             l1 += e->type->maxval - 6;
           if (l2 > 3)
             l2 += e->type->maxval - 6;
-	  fprintf (outfile, "e%s_%lld,e%s_%lld", p, l1, p, l2);
+	  fprintf (outfile, "e%s_%" COMPAT_PRLL "d,e%s_%" COMPAT_PRLL
"d",
+	           p, l1, p, l2);
         }
       break;
     case TYPE_SENUM:
@@ -1152,7 +1165,7 @@
       p++;
       l1 %= 7;
       l2 %= 7;
-      fprintf (outfile, "e%s_%s%lld,e%s_%s%lld",
+      fprintf (outfile, "e%s_%s%" COMPAT_PRLL "d,e%s_%s%" COMPAT_PRLL
"d",
 	       p, l1 < 3 ? "m" : "",
 	       l1 == 3 ? 0LL : e->type->maxval - (l1 & 3),
 	       p, l2 < 3 ? "m" : "",
@@ -1161,13 +1174,14 @@
     case TYPE_PTR:
       l1 %= 256;
       l2 %= 256;
-      fprintf (outfile, "(%s)&intarray[%lld],(%s)&intarray[%lld]",
+      fprintf (outfile,
+	       "(%s)&intarray[%" COMPAT_PRLL "d], (%s)&intarray[%"
COMPAT_PRLL "d]",
 	       e->type->name, l1, e->type->name, l2);
       break;
     case TYPE_FNPTR:
       l1 %= 10;
       l2 %= 10;
-      fprintf (outfile, "fn%lld,fn%lld", l1, l2);
+      fprintf (outfile, "fn%" COMPAT_PRLL "d,fn%" COMPAT_PRLL "d", l1,
l2);
       break;
     default:
       abort ();
Index: g++.dg/compat/struct-layout-1_generate.c
===================================================================
--- g++.dg/compat/struct-layout-1_generate.c	(revision 126673)
+++ g++.dg/compat/struct-layout-1_generate.c	(working copy)
@@ -36,6 +36,13 @@
 # error Need 64-bit long long
 #endif
 
+#if defined __MSVCRT__ 
+#define COMPAT_PRLL "I64"
+#else 
+#define COMPAT_PRLL "ll"
+#endif
+
+
 typedef unsigned int hashval_t;
 
 enum TYPE
@@ -778,7 +785,7 @@
 	m &= e->len > 1 ? (1ULL << (e->len - 1)) - 1 : 1;
       l1 &= m;
       l2 &= m;
-      fprintf (outfile, "%s%llu%s,%s%llu%s",
+      fprintf (outfile, "%s%" COMPAT_PRLL "u%s,%s%" COMPAT_PRLL "u%s",
 	       (signs & 1) ? "-" : "", l1, l1 > 2147483647 ? "LL" : "",
 	       (signs & 2) ? "-" : "", l2, l2 > 2147483647 ? "LL" : "");
       break;
@@ -788,7 +795,8 @@
 	m &= (1ULL << e->len) - 1;
       l1 &= m;
       l2 &= m;
-      fprintf (outfile, "%lluU%s,%lluU%s", l1, l1 > 4294967295U ? "LL"
: "",
+      fprintf (outfile,"%" COMPAT_PRLL "uU%s,%" COMPAT_PRLL "uU%s",
+	       l1, l1 > 4294967295U ? "LL" : "",
 	       l2, l2 > 4294967295U ? "LL" : "");
       break;
     case TYPE_FLOAT:
@@ -802,7 +810,8 @@
       if (e->type->maxval == 0)
 	fputs ("e0_0,e0_0", outfile);
       else if (e->type->maxval == 1)
-	fprintf (outfile, "e1_%lld,e1_%lld", l1 & 1, l2 & 1);
+	fprintf (outfile, "e1_%" COMPAT_PRLL "d,e1_%" COMPAT_PRLL "d",
+		 l1 & 1, l2 & 1);
       else
 	{
 	  p = strchr (e->type->name, '\0');
@@ -814,7 +823,8 @@
 	    l1 += e->type->maxval - 6;
 	  if (l2 > 3)
 	    l2 += e->type->maxval - 6;
-	  fprintf (outfile, "e%s_%lld,e%s_%lld", p, l1, p, l2);
+	  fprintf (outfile, "e%s_%" COMPAT_PRLL "d,e%s_%" COMPAT_PRLL
"d",
+		   p, l1, p, l2);
 	}
       break;
     case TYPE_SENUM:
@@ -823,7 +833,7 @@
       p++;
       l1 %= 7;
       l2 %= 7;
-      fprintf (outfile, "e%s_%s%lld,e%s_%s%lld",
+      fprintf (outfile, "e%s_%s%" COMPAT_PRLL "d,e%s_%s%" COMPAT_PRLL
"d",
 	       p, l1 < 3 ? "m" : "",
 	       l1 == 3 ? 0LL : e->type->maxval - (l1 & 3),
 	       p, l2 < 3 ? "m" : "",
@@ -832,13 +842,15 @@
     case TYPE_PTR:
       l1 %= 256;
       l2 %= 256;
-      fprintf (outfile, "(%s)&intarray[%lld],(%s)&intarray[%lld]",
+      fprintf (outfile,
+	      "(%s)&intarray[%" COMPAT_PRLL "d], (%s)&intarray[%"
COMPAT_PRLL "d]",
 	       e->type->name, l1, e->type->name, l2);
       break;
     case TYPE_FNPTR:
       l1 %= 10;
       l2 %= 10;
-      fprintf (outfile, "fn%lld,fn%lld", l1, l2);
+      fprintf (outfile,
+	       "fn%" COMPAT_PRLL "d,fn%" COMPAT_PRLL "d", l1, l2);
       break;
     default:
       abort ();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]