From f81484a068eb948c2f6555eb0942045b52165f58 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 10 Jun 2019 07:17:41 +0900 Subject: [PATCH] Test compiling enums It turns out the enumerator type and enum type wind up with different instances of the same type (due to the way type chaining works). This results in infinite recursion in assign_expr and check_types_compatible. --- tools/qfcc/test/Makefile.am | 10 ++++++++++ tools/qfcc/test/enum.r | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tools/qfcc/test/enum.r diff --git a/tools/qfcc/test/Makefile.am b/tools/qfcc/test/Makefile.am index 0e9e39e81..96351e926 100644 --- a/tools/qfcc/test/Makefile.am +++ b/tools/qfcc/test/Makefile.am @@ -33,6 +33,7 @@ test_progs_dat=\ chewed-return.dat \ comma-expr.dat \ deadbool.dat \ + enum.dat \ fordecl.dat \ func-expr.dat \ func-static.dat \ @@ -109,6 +110,15 @@ deadbool.run: Makefile build-run include ./$(DEPDIR)/deadbool.Qo # am--include-marker r_depfiles_remade += ./$(DEPDIR)/deadbool.Qo +enum_dat_SOURCES=enum.r +enum_obj=$(enum_dat_SOURCES:.r=.qfo) +enum.dat$(EXEEXT): $(enum_obj) $(QFCC_DEP) + $(QFCC) $(QCFLAGS) -o $@ $(enum_obj) +enum.run: Makefile build-run + $(srcdir)/build-run $@ +include ./$(DEPDIR)/enum.Qo # am--include-marker +r_depfiles_remade += ./$(DEPDIR)/enum.Qo + fordecl_dat_SOURCES=fordecl.r fordecl_obj=$(fordecl_dat_SOURCES:.r=.qfo) fordecl.dat$(EXEEXT): $(fordecl_obj) $(QFCC_DEP) diff --git a/tools/qfcc/test/enum.r b/tools/qfcc/test/enum.r new file mode 100644 index 000000000..b6ffb09c1 --- /dev/null +++ b/tools/qfcc/test/enum.r @@ -0,0 +1,12 @@ +typedef enum { + NO = 0, + YES +} BOOL; + +int +main() +{ + BOOL b; + b = YES; + return !b; +}