aboutsummaryrefslogtreecommitdiff
path: root/tests/tests2
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests2')
-rw-r--r--tests/tests2/86-struct-init.c23
-rw-r--r--tests/tests2/86-struct-init.expect4
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/tests2/86-struct-init.c b/tests/tests2/86-struct-init.c
index fa0d967..6749f98 100644
--- a/tests/tests2/86-struct-init.c
+++ b/tests/tests2/86-struct-init.c
@@ -77,6 +77,25 @@ struct SU {
};
struct SU gsu = {5,6};
+/* Unnamed struct/union members aren't ISO C, but it's a widely accepted
+ extension. See below for further extensions to that under -fms-extension.*/
+union UV {
+ struct {u8 a,b;};
+ struct S s;
+};
+union UV guv = {{6,5}};
+union UV guv2 = {{.b = 7, .a = 8}};
+union UV guv3 = {.b = 8, .a = 7};
+
+/* Under -fms-extensions also the following is valid:
+union UV2 {
+ struct Anon {u8 a,b;}; // unnamed member, but tagged struct, ...
+ struct S s;
+};
+struct Anon gan = { 10, 11 }; // ... which makes it available here.
+union UV2 guv4 = {{4,3}}; // and the other inits from above as well
+*/
+
#include <stdio.h>
void print_ (const char *name, const u8 *p, long size)
{
@@ -144,6 +163,10 @@ int main()
print(sinit16);
print(gw);
print(gsu);
+ print(guv);
+ print(guv.b);
+ print(guv2);
+ print(guv3);
foo(&gw);
//printf("q: %s\n", q);
return 0;
diff --git a/tests/tests2/86-struct-init.expect b/tests/tests2/86-struct-init.expect
index 6ae60e0..a5333dc 100644
--- a/tests/tests2/86-struct-init.expect
+++ b/tests/tests2/86-struct-init.expect
@@ -13,6 +13,10 @@ gv3: 7 8 9 a 68 6f 68 6f 0 0 0 0 0 0 0 0 0 0 0 0 31 32
sinit16: 1 0 0 0 2 0 0 0
gw: 1 2 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
gsu: 5 6
+guv: 6 5 0 0
+guv.b: 5
+guv2: 8 7 0 0
+guv3: 7 8 0 0
ls: 1 2 3 4
ls2: 1 2 3 4
lt: 68 65 6c 6c 6f 0 0 0 0 0 0 0 0 0 0 0 2a