+2004-06-01 Maarten Brock <sourceforge.brock AT dse.nl>
+ * support/regression/tests/zeropad.c: never meant to commit the
+ nestedstruct test: removed, added check for GCC version
+
2004-05-31 Maarten Brock <sourceforge.brock AT dse.nl>
* src/SDCCast.c (createIvalArray): fixed bug 770487 SIGSEGV
* src/SDCCglue.c (emitRegularMap): fixed bug 770484 allocation problem
#define STORAGE {storage}
#endif
+#if defined __GNUC__
+ #define FLEXARRAY (__GNUC__ >= 3)
+#else
+ #define FLEXARRAY 1
+#endif
+
#include <testfwk.h>
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;
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
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);
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
}