diff mbox series

[testsuite,applied] ad PR52641: Make strict-flex-array-3.c work on int != 32-bit targets

Message ID 02bd2e25-e1d3-4bb9-93df-640d82b28830@gjlay.de
State New
Headers show
Series [testsuite,applied] ad PR52641: Make strict-flex-array-3.c work on int != 32-bit targets | expand

Commit Message

Georg-Johann Lay Oct. 2, 2024, 5:21 p.m. UTC
gcc.dg/strict-flex-array-3.c used hard-coded values instead of
__SIZEOF_INT__ or equivalent expressions.  Fixed as obvious.
Plus, on AVR, printf doesn't support %zd, so that expect() is
now special-cased.

Johann

--

testsuite/52641 - Make gcc.dg/strict-flex-array-3.c work on int != 32 bits.

         PR testsuite/52641
gcc/testsuite/
         * gcc.dg/strict-flex-array-3.c (expect) [AVR]: Use custom
         version due to AVR-LibC limitations.
         (stuff): Use __SIZEOF_INT__ instead of hard-coded values.
diff mbox series

Patch

    testsuite/52641 - Make gcc.dg/strict-flex-array-3.c work on int != 32 bits.
    
            PR testsuite/52641
    gcc/testsuite/
            * gcc.dg/strict-flex-array-3.c (expect) [AVR]: Use custom
            version due to AVR-LibC limitations.
            (stuff): Use __SIZEOF_INT__ instead of hard-coded values.

diff --git a/gcc/testsuite/gcc.dg/strict-flex-array-3.c b/gcc/testsuite/gcc.dg/strict-flex-array-3.c
index f74ed96c751..064f779501a 100644
--- a/gcc/testsuite/gcc.dg/strict-flex-array-3.c
+++ b/gcc/testsuite/gcc.dg/strict-flex-array-3.c
@@ -17,6 +17,21 @@ 
 	} \
 } while (0);
 
+#ifdef __AVR__
+/* AVR-Libc doesn't support %zd, thus use %d for size_t.  */
+#undef  expect
+#define expect(p, _v) do {						\
+    size_t v = _v;							\
+    if (p == v)								\
+      __builtin_printf ("ok:  %s == %d\n", #p, p);			\
+    else								\
+      {									\
+	__builtin_printf ("WAT: %s == %d (expected %d)\n", #p, p, v);	\
+	FAIL ();							\
+      }									\
+} while (0);
+#endif /* AVR */
+
 struct trailing_array_1 {
     int a;
     int b;
@@ -46,8 +61,8 @@  void __attribute__((__noinline__)) stuff(
     struct trailing_array_3 *trailing_0,
     struct trailing_array_4 *trailing_flex)
 {
-    expect(__builtin_object_size(normal->c, 1), 16);
-    expect(__builtin_object_size(trailing_1->c, 1), 4);
+    expect(__builtin_object_size(normal->c, 1), 4 * __SIZEOF_INT__);
+    expect(__builtin_object_size(trailing_1->c, 1), __SIZEOF_INT__);
     expect(__builtin_object_size(trailing_0->c, 1), 0);
     expect(__builtin_object_size(trailing_flex->c, 1), -1);
 }