Skip to content

Commit

Permalink
another attempt on clang-16 support [fixes #216]
Browse files Browse the repository at this point in the history
Have to disable -Wpacked for clang-16 as its broken there.
Should be "fixed" in clang-17.
  • Loading branch information
stsp committed May 12, 2023
1 parent b5aca51 commit 6185fe0
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
11 changes: 7 additions & 4 deletions fdpp/clang.mak
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ CLANG_VER := $(shell $(CC) -v 2>&1 | head -n 1 | \
sed -E 's/.+ version ([^.]+)\.[^.]+\.[^ ]+.*/\1/')
# below requires make-4.4, uncomment when it is widely available
#CC += $(intcmp 15,$(CLANG_VER),-fclang-abi-compat=15)
ifeq ($(CLANG_VER),16)
CC += -fclang-abi-compat=15
endif
#ifeq ($(CLANG_VER),16)
#CC += -fclang-abi-compat=15
#endif

# Override builtin CXX.
# The assignment below is ignored if CXX was set via cmd line.
Expand Down Expand Up @@ -45,7 +45,10 @@ USE_UBSAN ?= 0

IFLAGS = -iquote $(srcdir)/../hdr
CPPFLAGS = $(IFLAGS) -DFDPP
WFLAGS = -Wall -Wpacked -Werror=packed-non-pod -Wno-unknown-warning-option
WFLAGS = -Wall -Werror=packed-non-pod -Wno-unknown-warning-option
ifneq ($(CLANG_VER),16)
WFLAGS += -Wpacked
endif
WCFLAGS = $(WFLAGS)
ifeq ($(DEBUG_MODE),1)
DBGFLAGS += -ggdb3
Expand Down
2 changes: 1 addition & 1 deletion fdpp/farobj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
template<typename T>
class NearPtr_DO : public NearPtr<T, dosobj_seg> {
using NearPtr<T, dosobj_seg>::NearPtr;
};
} NONPOD_PACKED;

template <typename T>
class FarObjBase {
Expand Down
14 changes: 11 additions & 3 deletions fdpp/farptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
#include "thunks_priv.h"
#include "farhlp_sta.h"

#if !defined(__clang__) || (__clang_major__ >= 16)
#define NONPOD_PACKED __attribute__((packed))
#define MAYBE_PACKED
#else
#define NONPOD_PACKED
#define MAYBE_PACKED __attribute__((packed))
#endif

/* for get_sym() */
static const int sym_store[] = { SYM_STORE, STORE_MAX };
static const int arr_store[] = { ARR_STORE, STORE_MAX };
Expand Down Expand Up @@ -198,7 +206,7 @@ class FarPtrBase {
T* get_ptr() const { return (T*)resolve_segoff(ptr); }
void *get_buf() const { return (void*)resolve_segoff(ptr); }
explicit operator uint32_t () const { return get_fp32(); }
};
} NONPOD_PACKED;

class ObjIf {
public:
Expand Down Expand Up @@ -672,7 +680,7 @@ class SymMemb : public T, public MembBase<T, P, M, O> {
store_far(SYM_STORE, this->lookup_sym().get_far());
return *this;
}
};
} NONPOD_PACKED;

template<typename T, typename P, int (*M)(void), int O = 0>
class SymMemb2 : public MembBase<T, P, M, O> {
Expand All @@ -684,7 +692,7 @@ class SymMemb2 : public MembBase<T, P, M, O> {
T& operator =(const T& f) { sym = f; return sym; }
FarPtr<T> operator &() const { return this->lookup_sym(); }
operator T &() { return sym; }
};
} NONPOD_PACKED;

#undef _P
#undef _C
Expand Down
2 changes: 1 addition & 1 deletion hdr/cds.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct cds {
never access == 0xFFFF */
UWORD _cdsParam;
} _cdsRedir;
} _cdsUnion;
} NONPOD_PACKED _cdsUnion;

UWORD cdsStoreUData;

Expand Down
4 changes: 2 additions & 2 deletions hdr/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@ typedef struct {
__DOSFAR(struct gblkfv)_r_fv;
__DOSFAR(struct Gioc_media)_r_gioc;
__DOSFAR(struct Access_info)_r_ai;
} _r_par; /* Pointer to param. block from 440C/440D */
} _r_gen;
} NONPOD_PACKED _r_par; /* Pointer to param. block from 440C/440D */
} NONPOD_PACKED _r_gen;
} PACKED _r_x;
} PACKED request;
ANNOTATE_SIZE(request, 30);
Expand Down
2 changes: 1 addition & 1 deletion hdr/nls.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ struct nlsPointer { /* Information of DOS-65-0X is addressed
of DOS-65 is called (Note: won't work for
subfunctions 0, 1, 0x20, 0x21, 0x22, 0x23,
0xA0, 0xA1,& 0xA2 */
} PACKED;
} MAYBE_PACKED;
ANNOTATE_SIZE(struct nlsPointer, 5);

struct nlsPackage { /* the contents of one chain item of the
Expand Down

0 comments on commit 6185fe0

Please sign in to comment.