From 5716b14e4fb0d350bfae21840c5bdcf0483505bb Mon Sep 17 00:00:00 2001 From: maartenbrock Date: Tue, 1 Jun 2004 11:46:57 +0000 Subject: [PATCH] * support/regression/tests/zeropad.c: never meant to commit the nestedstruct test: removed, added check for GCC version git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3336 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 +++ support/regression/tests/zeropad.c | 41 ++++++++++-------------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2b0fb850..930c0776 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-06-01 Maarten Brock + * support/regression/tests/zeropad.c: never meant to commit the + nestedstruct test: removed, added check for GCC version + 2004-05-31 Maarten Brock * src/SDCCast.c (createIvalArray): fixed bug 770487 SIGSEGV * src/SDCCglue.c (emitRegularMap): fixed bug 770484 allocation problem diff --git a/support/regression/tests/zeropad.c b/support/regression/tests/zeropad.c index dbec36a2..299be534 100644 --- a/support/regression/tests/zeropad.c +++ b/support/regression/tests/zeropad.c @@ -6,6 +6,12 @@ #define STORAGE {storage} #endif +#if defined __GNUC__ + #define FLEXARRAY (__GNUC__ >= 3) +#else + #define FLEXARRAY 1 +#endif + #include typedef unsigned int size_t; @@ -17,7 +23,7 @@ typedef unsigned int size_t; # define code #endif -char array[5] = {'a', 'b', 'c'}; +char STORAGE array[5] = {'a', 'b', 'c'}; struct w { char a; @@ -33,36 +39,21 @@ struct x { char b[10]; }; -struct y { - short a; - char b[]; -}; - -/* I think section 6.7.2.1 paragraph 2 of ISO/IEC 9899:1999 prohibits */ -/* nesting a structure ending in a flexible array inside another */ -/* struct/union. In any case, my gcc (3.2.2) chokes on this. -- EEP */ -#ifdef NESTED_FLEX_ARRAY -struct z { - char c; - struct y s; -}; -#endif - struct x STORAGE teststruct[5] = { { 10, { 1, 2, 3, 4, 5} }, { 20, { 11 } }, { 30, { 6, 7, 8} } }; +#if FLEXARRAY + struct y { + short a; + char b[]; + }; + struct y STORAGE incompletestruct = { 10, {1, 2, 3, 4, 5} }; - -#ifdef NESTED_FLEX_ARRAY -struct z STORAGE nestedstruct = { - 16, - {20, {6, 7, 8} } -}; #endif void @@ -86,6 +77,7 @@ testZeropad(void) ASSERT(sizeof(teststruct[1]) == 12); ASSERT(sizeof(teststruct) == 60); +#if FLEXARRAY ASSERT(incompletestruct.a == 10); ASSERT(incompletestruct.b[0] == 1); ASSERT(incompletestruct.b[4] == 5); @@ -93,10 +85,5 @@ testZeropad(void) ASSERT(sizeof(incompletestruct) == sizeof(struct y)); ASSERT(sizeof(incompletestruct) == offsetof(struct y, b)); ASSERT(sizeof(incompletestruct) == offsetof(struct x, b)); - -#ifdef NESTED_FLEX_ARRAY - ASSERT(nestedstruct.c == 16); - ASSERT(nestedstruct.s.a == 20); - ASSERT(nestedstruct.s.b[2] == 8); #endif } -- 2.47.2