Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc8 compile and run fixes #9

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions opts.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ FIXINC ?= -isystem . -isystem /usr/include/pd/fixinclude
CPPFLAGS = \
$(FIXINC) -D_GNU_SOURCE=1 $(CPPDEFS) -Wundef


GCCVERSIONGTEQ7 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 7)

ifeq "$(GCCVERSIONGTEQ7)" "1"
FIXWARN := -Wno-implicit-fallthrough
endif

DEPS = \
-MD -MF deps/$(subst /,%,$(@)).d

Expand All @@ -33,12 +40,12 @@ CXXFLAGS = \
-fvisibility=hidden -fvisibility-inlines-hidden -fno-default-inline \
-fno-omit-frame-pointer -fno-common -fsigned-char \
-Wall -W -Werror -Wsign-promo -Woverloaded-virtual \
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor $(CPPFLAGS) $(CXXFLAGS.$(<))
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor $(FIXWARN) $(CPPFLAGS) $(CXXFLAGS.$(<))

CFLAGS = \
-g -O$(OPT) $(CSTD) \
-fvisibility=hidden -fno-omit-frame-pointer -fno-common -fsigned-char \
-Wall -W -Werror $(CPPFLAGS) $(CFLAGS.$(<))
-Wall -W -Werror $(FIXWARN) $(CPPFLAGS) $(CFLAGS.$(<))


%.o: %.C; $(CXX) -c $(CXXFLAGS) $(DEPS) $(<) -o $(@)
Expand Down
7 changes: 2 additions & 5 deletions pd/base/alloc.C
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,11 @@ class alloc_t {
inline bool check(bool _array) { return array == _array; }

inline void print(out_t &out) {
if(!this)
return;

out.print((void const *)(this + 1))(',')(' ').print(size).lf();

trace.print(out);

next->print(out);
if(next)
next->print(out);
}

inline void *operator new(size_t size, size_t body_size) {
Expand Down
8 changes: 4 additions & 4 deletions pd/base/config.C
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ class environ_t {
inline ~item_t() throw() { }

inline string_t const *lookup(string_t const &_key) const {
if(!this)
return NULL;

if(string_t::cmp_eq<ident_t>(key, _key))
return &val;

if(!next)
return NULL;

return next->lookup(_key);
}
};
Expand Down Expand Up @@ -139,7 +139,7 @@ public:
}

inline string_t const *lookup(string_t const &key) const {
return list->lookup(key);
return list ? list->lookup(key) : NULL;
}
};

Expand Down
54 changes: 26 additions & 28 deletions pd/base/config.H
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ class obj_t {
virtual x_t *get_item(string_t const &_name) const = 0;

x_t *get(string_t const &name) {
x_t *item = NULL;

if(this) {
item = get_item(name);
if(!item) item = next->get(name);
}
x_t *item = get_item(name);
if(!item && next) item = next->get(name);

return item;
}
Expand All @@ -56,7 +52,7 @@ class obj_t {

public:
static inline x_t *get(string_t const &name) {
return list->get(name);
return list ? list->get(name) : NULL;
}

static item_t *list;
Expand Down Expand Up @@ -104,8 +100,8 @@ public:
string_t ctor_name;

void print(out_t &out, int off, string_t const &type_name) const {
if(!this) return;
next->print(out, off, type_name);
if(next)
next->print(out, off, type_name);

print_off(out, off);
out(type_name)(' ')(name)(' ')('=')(' ')(ctor_name)(' ');
Expand Down Expand Up @@ -137,12 +133,14 @@ public:
inline ~obj_ref_t() throw() { while(list) delete list; }

inline void print(out_t &out, int off, string_t const &type_name) const {
list->print(out, off, type_name);
if(list)
list->print(out, off, type_name);
}
};

template<typename x_t>
class ctor_base_t : public named_list_item_t<ctor_base_t<x_t>> {
friend class named_list_item_t<ctor_base_t<x_t>>;
using named_list_item_t<ctor_base_t<x_t>>::list;
using named_list_item_t<ctor_base_t<x_t>>::next;

Expand All @@ -155,8 +153,8 @@ protected:
virtual void syntax_object_item(out_t &out) const = 0;

void syntax_object(out_t &out, unsigned int &num) {
if(!this) return;
next->syntax_object(out, num);
if(next)
next->syntax_object(out, num);

if(num) out(' ')('|');
out.lf()(' ')(' ');
Expand All @@ -167,8 +165,8 @@ protected:
virtual void syntax_name_item(out_t &out) const = 0;

void syntax_name(out_t &out, unsigned int &num) {
if(!this) return;
next->syntax_name(out, num);
if(next)
next->syntax_name(out, num);

if(num) out(' ')('|');
out.lf()(' ')(' ');
Expand All @@ -183,12 +181,14 @@ public:

static inline void syntax_object(out_t &out) {
unsigned int num = 0;
list->syntax_object(out, num);
if (list)
list->syntax_object(out, num);
}

static inline void syntax_name(out_t &out) {
unsigned int num = 0;
list->syntax_name(out, num);
if (list)
list->syntax_name(out, num);
}
};

Expand Down Expand Up @@ -226,26 +226,22 @@ class binding_t {
) const = 0;

bool parse(string_t const &name, in_t::ptr_t &ptr, conf_t &conf) const {
return
this && (
next->parse(name, ptr, conf) || parse_item(name, ptr, conf)
)
;
return next && next->parse(name, ptr, conf) ? true : parse_item(name, ptr, conf);
}

virtual void print_item(out_t &out, int off, conf_t const &conf) const = 0;

virtual void syntax_item(out_t &out, unsigned int &num) const = 0;

void print(out_t &out, int off, conf_t const &conf) const {
if(!this) return;
next->print(out, off, conf);
if(next)
next->print(out, off, conf);
print_item(out, off, conf);
}

void syntax(out_t &out, unsigned int &num) const {
if(!this) return;
next->syntax(out, num);
if(next)
next->syntax(out, num);
syntax_item(out, num);
}

Expand All @@ -262,7 +258,7 @@ public:
static inline bool parse_item(
string_t const &name, in_t::ptr_t &ptr, conf_t &conf
) {
return list->parse(name, ptr, conf);
return list && list->parse(name, ptr, conf);
}

static inline void check(in_t::ptr_t const &ptr, conf_t const &conf) {
Expand All @@ -287,12 +283,14 @@ public:
}

static inline void print(out_t &out, int off, conf_t const &conf) {
list->print(out, off, conf);
if (list)
list->print(out, off, conf);
}

static inline void syntax(out_t &out) {
unsigned int num = 0;
list->syntax(out, num);
if (list)
list->syntax(out, num);
}

template<typename val_t>
Expand Down
22 changes: 13 additions & 9 deletions pd/base/config_enum.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,28 @@ class enum_t {
val_t val;
public:
class item_t : public named_list_item_t<item_t> {
friend class named_list_item_t<item_t>;
using named_list_item_t<item_t>::next;
using named_list_item_t<item_t>::name;

val_t val;

void print(out_t &out, val_t _val) {
if(!this) {
out(CSTR("<unknown enum value>"));
}
else if(val == _val) {
if(val == _val) {
out(name);
}
else
else if(next) {
next->print(out, _val);
}
else {
out(CSTR("<unknown enum value>"));
}
}

void syntax(out_t &out, unsigned int &num) {
if(!this) return;
if(next)
next->syntax(out, num);

next->syntax(out, num);
if(num) out(' ')('|')(' ');
out(name);
++num;
Expand Down Expand Up @@ -85,12 +87,14 @@ struct helper_t<enum_t<val_t>> {
}

static inline void print(out_t &out, int, enum_t<val_t> const &val) {
enum_t<val_t>::item_t::list->print(out, val);
if (enum_t<val_t>::item_t::list)
enum_t<val_t>::item_t::list->print(out, val);
}

static inline void syntax_detail(out_t &out) {
unsigned int num = 0;
enum_t<val_t>::item_t::list->syntax(out, num);
if (enum_t<val_t>::item_t::list)
enum_t<val_t>::item_t::list->syntax(out, num);
}

static inline void syntax(out_t &out) {
Expand Down
26 changes: 13 additions & 13 deletions pd/base/config_record.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,22 @@ class record_t : public val_t, public block_t {
public:

inline void parse(in_t::ptr_t &ptr, val_t &val) const {
if(this) {
if(next)
next->parse(ptr, val);
parse_item(ptr, val);
}
parse_item(ptr, val);
}

inline void print(out_t &out, int off, val_t const &val) const {
if(this) {
if(next)
next->print(out, off, val);
print_item(out, off, val);
}
print_item(out, off, val);
}

inline void syntax(out_t &out) const {
if(this) {
if(next)
next->syntax(out);
syntax_item(out);
out(' ');
}
syntax_item(out);
out(' ');
}

inline item_t() throw() : list_item_t<item_t>(this, list) { }
Expand Down Expand Up @@ -81,20 +78,23 @@ public:

static inline void syntax(out_t &out) {
out('{')(' ');
list->syntax(out);
if(list)
list->syntax(out);
out('}');
}

static string_t sname;

private:
virtual void parse_content(in_t::ptr_t &ptr) {
list->parse(ptr, *this);
if(list)
list->parse(ptr, *this);
skip_space(ptr);
}

virtual void print_content(out_t &out, int off) const {
list->print(out, off, *this);
if(list)
list->print(out, off, *this);
}

static item_t *list;
Expand Down
2 changes: 2 additions & 0 deletions pd/base/in.H
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ public:
while(list->optimize(*this));
}

inline in_segment_t &operator=(const in_segment_t &) = default;

inline ~in_segment_t() throw() { }

operator int() const = delete;
Expand Down
2 changes: 1 addition & 1 deletion pd/bq/bq_cont.C
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public:
}

inline void *&operator[](unsigned int i) {
if(this && i < spec_num)
if(i < spec_num)
return ((void **)this)[-2 - (int)i];

throw exception_sys_t(log::error, EINVAL, "bq_spec: %m");
Expand Down
12 changes: 7 additions & 5 deletions pd/debug/addrinfo_bfd.C
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ class bfd_t {
inline void operator delete(void *ptr) { ::free(ptr); }

file_t *find(char const *_name) {
return (!this || !strcmp(name, _name))
? this
: next->find(_name)
;
if (strcmp(name, _name) == 0)
return this;
return next ? next->find(_name) : NULL;
}

void print(uintptr_t addr, uintptr_t addr_rel, demangle_t &demangle, out_t &out);
Expand All @@ -94,7 +93,10 @@ public:
inline void print(
uintptr_t addr, uintptr_t addr_rel, char const *fname, out_t &out
) {
file_t *file = list->find(fname) ?: new file_t(fname, list);
file_t *file = list ? list->find(fname) : NULL;

if(!file)
file = new file_t(fname, list);

file->print(addr, addr_rel, demangle, out);
}
Expand Down
4 changes: 2 additions & 2 deletions pd/http/time.C
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

namespace pd { namespace http {

static char const *(wnames[7]) = {
static char const *wnames[7] = {
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
};

static char const *(mnames[12]) = {
static char const *mnames[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
Expand Down
2 changes: 1 addition & 1 deletion pd/pi/pi_pro.C
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void pi_t::pro_t::put(pi_t *&ref, place_t &place) const throw() {
if(pi->bounds(&from, &to)) {
_size_t size = to - from;

memcpy(place._pi, from, size * sizeof(pi_t));
memcpy(static_cast<void*>(place._pi), from, size * sizeof(pi_t));

(--ref)->setup(pi->type(), place._pi);
place._pi += size;
Expand Down
Loading