Test case for accessing nested struct fields

Currently fails.
This commit is contained in:
Bill Currie 2019-06-17 22:47:44 +09:00
parent ec128ffeee
commit e9c24dbf1c
3 changed files with 64 additions and 0 deletions

View File

@ -47,6 +47,7 @@ test_progs_dat=\
structarray.dat \
structlive.dat \
structptr.dat \
structstruct.dat \
swap.dat \
triangle.dat \
vecexpr.dat \
@ -236,6 +237,15 @@ structptr.run: Makefile build-run
include ./$(DEPDIR)/structptr.Qo # am--include-marker
r_depfiles_remade += ./$(DEPDIR)/structptr.Qo
structstruct_dat_SOURCES=structstruct.r
structstruct_obj=$(structstruct_dat_SOURCES:.r=.qfo)
structstruct.dat$(EXEEXT): $(structstruct_obj) $(QFCC_DEP)
$(QFCC) $(QCFLAGS) -o $@ $(structstruct_obj)
structstruct.run: Makefile build-run
$(srcdir)/build-run $@
include ./$(DEPDIR)/structstruct.Qo # am--include-marker
r_depfiles_remade += ./$(DEPDIR)/structstruct.Qo
swap_dat_SOURCES=swap.r
swap_obj=$(swap_dat_SOURCES:.r=.qfo)
swap.dat$(EXEEXT): $(swap_obj) $(QFCC_DEP)

View File

@ -0,0 +1,53 @@
#include "test-harness.h"
typedef struct Point {
int x;
int y;
} Point;
typedef struct Size {
int width;
int height;
} Size;
typedef struct Rect {
Point origin;
Size size;
} Rect;
Rect rect = {{1, 2}, {3, 4}};
int
test_struct_1(Rect rect)
{
return rect.origin.x;
}
int
test_struct_2(Rect rect)
{
return rect.origin.y;
}
int
test_struct_3(Rect rect)
{
return rect.size.width;
}
int
test_struct_4(Rect rect)
{
return rect.size.height;
}
int
main()
{
int ret = 0;
ret |= test_struct_1(rect) != 1;
ret |= test_struct_2(rect) != 2;
ret |= test_struct_3(rect) != 3;
ret |= test_struct_4(rect) != 4;
return ret;
}

View File

@ -1,3 +1,4 @@
void *obj_malloc (int size) = #0;
void printf (string fmt, ...) = #0;
int errno (void) = #0;
string strerror (int err) = #0;