From 4429cef9f61d7a73836e5db9e86ddd894cf97b39 Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 13 May 2020 11:14:53 +0200 Subject: [PATCH] tccgen.c: merge more function attributes Merge function attributes with those given given for the prototype, also handle post-decl appearance such as void func() __attribute__((noreturn)) { } Also, some test fixes (unrelated). --- tccgen.c | 12 ++++++++++++ tests/Makefile | 2 +- tests/tests2/Makefile | 6 ++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tccgen.c b/tccgen.c index 3fa27a84..5a4b0412 100644 --- a/tccgen.c +++ b/tccgen.c @@ -1507,6 +1507,12 @@ static void merge_funcattr(struct FuncAttr *fa, struct FuncAttr *fa1) fa->func_type = fa1->func_type; if (fa1->func_args && !fa->func_args) fa->func_args = fa1->func_args; + if (fa1->func_noreturn) + fa->func_noreturn = 1; + if (fa1->func_ctor) + fa->func_ctor = 1; + if (fa1->func_dtor) + fa->func_dtor = 1; } /* Merge attributes. */ @@ -1563,9 +1569,11 @@ static void patch_type(Sym *sym, CType *type) } if (0 == (type->t & VT_EXTERN)) { + struct FuncAttr f = sym->type.ref->f; /* put complete type, use static from prototype */ sym->type.t = (type->t & ~(VT_STATIC|VT_INLINE)) | static_proto; sym->type.ref = type->ref; + merge_funcattr(&sym->type.ref->f, &f); } else { sym->type.t &= ~VT_INLINE | static_proto; } @@ -8201,9 +8209,13 @@ static int decl0(int l, int is_for_loop_init, Sym *func_sym) sym->type = int_type; } + /* apply post-declaraton attributes */ + merge_funcattr(&type.ref->f, &ad.f); + /* put function symbol */ type.t &= ~VT_EXTERN; sym = external_sym(v, &type, 0, &ad); + /* static inline functions are just recorded as a kind of macro. Their code will be emitted at the end of the compilation unit only if they are used */ diff --git a/tests/Makefile b/tests/Makefile index 42a0ee5f..0a8829f9 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -229,7 +229,7 @@ abitest-cc.exe: abitest.c $(LIBTCC) $(CC) -o $@ $^ $(CFLAGS) $(LIBS) -w abitest-tcc.exe: abitest.c libtcc.c - $(TCC) -o $@ $^ $(LIBS) + $(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS) abitest-% : abitest-%.exe @echo ------------ $@ ------------ diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index bdb03d78..ba1042b9 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -36,9 +36,11 @@ endif ifeq (-$(CONFIG_WIN32)-$(CONFIG_i386)$(CONFIG_arm)-,--yes-) SKIP += 95_bitfields%.test # type_align is different on 32bit-non-windows endif -ifneq (-$(CONFIG_WIN32)$(CONFIG_WIN64)-,--) +ifeq (-$(CONFIG_WIN32)-,-yes-) SKIP += 106_pthread.test # No pthread support - SKIP += 114_bound_signal.test +endif +ifneq (-$(CONFIG_WIN32)-$(findstring $(GCC_MAJOR),3 4)-,---) + SKIP += 114_bound_signal.test # not on windows or older linuxes endif # Some tests might need arguments