Skip to content

Commit

Permalink
Merge pull request #318 from davidgiven/dtrg-warnings
Browse files Browse the repository at this point in the history
Fix a lot of K&Risms
  • Loading branch information
davidgiven authored Nov 3, 2024
2 parents 90ed7aa + 71d0466 commit e7b76f4
Show file tree
Hide file tree
Showing 481 changed files with 15,068 additions and 14,173 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@v3
- name: build
run: |
make LDFLAGS="-s -static" CFLAGS=-Os
make LDFLAGS="-s -static" CFLAGS="-g -Os"
- name: package
run: |
make ack-setup.exe
Expand Down
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ BUILDDIR ?= $(ACK_TEMP_DIR)/ack-build

# What build flags do you want to use for native code?

CFLAGS ?= -g -Wno-return-type
LDFLAGS ?=
CFLAGS ?= -g \
-Werror=return-type \
-Werror=implicit-function-declaration \
-Werror=strict-prototypes \
-fsanitize=unreachable

LDFLAGS ?= -g \
-fsanitize=unreachable

# Various commands.

Expand Down Expand Up @@ -70,6 +76,12 @@ INSDIR = $(abspath $(BUILDDIR)/staging)
PLATIND = $(INSDIR)/share/ack
PLATDEP = $(INSDIR)/lib/ack

MANDATORYCFLAGS = \
-DUNREACHABLE_CODE='__builtin_unreachable()' \
-DNORETURN=_Noreturn

MANDATORYLDFLAGS =

.NOTPARALLEL:

ifeq ($(BUILDSYSTEM),)
Expand Down Expand Up @@ -130,8 +142,8 @@ $(build-file): first/ackbuilder.lua Makefile $(lua-files)
PREFIX="$(PREFIX)" \
AR=$(AR) \
CC=$(CC) \
CFLAGS="$(CFLAGS)" \
LDFLAGS="$(LDFLAGS)" \
CFLAGS="$(MANDATORYCFLAGS) $(CFLAGS)" \
LDFLAGS="$(MANDATORYLDFLAGS) $(LDFLAGS)" \
> $(build-file)

ack-setup.exe: etc/windows-installer.nsi
Expand Down
5 changes: 1 addition & 4 deletions lang/basic/src/basic.lex
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,7 @@ char fgets_buf[GETSBUFSIZE];



char *our_fgets(buffer,n_char,stream)
char *buffer;
int n_char;
File *stream;
char *our_fgets(char* buffer, int n_char, File* stream)
{
/* Read one line or n_char */
static int characters_left = 0;
Expand Down
4 changes: 0 additions & 4 deletions lang/basic/src/bem.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,3 @@ extern label err_goto_label;
extern int dataused;

extern Linerecord *currline;


extern char *myitoa();
extern char *salloc();
2 changes: 1 addition & 1 deletion lang/basic/src/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern Linerecord *firstline,
*lastline;
extern List *forwardlabel;

extern List *gosublabel();
extern List *gosublabel(void);
extern void jumpelm(int nr);
extern int gotolabel(int nr);
extern void linewarnings(void);
Expand Down
4 changes: 2 additions & 2 deletions lang/cem/cemcom.ansi/LLlex.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int GetToken(register struct token* ptok)
break;
default:
crash("bad class for char 0%o", ch);
/* NOTREACHED */
UNREACHABLE_CODE;
}
UnGetChar();
return ptok->tk_symb = ch;
Expand Down Expand Up @@ -385,7 +385,7 @@ int GetToken(register struct token* ptok)
default: /* this cannot happen */
crash("bad class for char 0%o", ch);
}
/*NOTREACHED*/
UNREACHABLE_CODE;
}

static arith char_constant(char* nm)
Expand Down
7 changes: 4 additions & 3 deletions lang/cem/cemcom.ansi/LLlex.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ extern int err_occurred; /* "error.c" */

#define EOF (-1)

int GetChar(void);
int LLlex(void);
int GetToken(register struct token* ptok);
extern int GetChar(void);
extern int LLlex(void);
extern int GetToken(register struct token* ptok);
extern char* symbol2str(int tok);

#endif /* LLLEX_H_ */
2 changes: 1 addition & 1 deletion lang/cem/cemcom.ansi/LLmessage.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "Lpars.h"
#include "error.h"

extern char *symbol2str();


static void insert_token(int );

Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom.ansi/align.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ extern int
#define union_align ((int)AL_UNION)
#endif /* NOCROSS */

extern arith align();
extern arith align(arith pos, int al);
5 changes: 2 additions & 3 deletions lang/cem/cemcom.ansi/arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "label.h"
#include "expr.h"
#include "Lpars.h"
#include "LLlex.h"
#include "field.h"
#include "mes.h"
#include "cstoper.h"
Expand All @@ -31,10 +32,8 @@
#include "error.h"


extern char *symbol2str();

extern char options[];
extern arith flt_flt2arith();
extern label code_string();

/* 3.1.2.5 */
void arithbalance(register struct expr **e1p, int oper, register struct expr **e2p)
Expand Down
2 changes: 2 additions & 0 deletions lang/cem/cemcom.ansi/arith.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define ARITH_H_

#include <em_arith.h> /* obtain definition of "arith" */
#include <em_label.h> /* obtain definition of "label" */

#define writh long long
/* The compiler also uses "unsigned writh". */
Expand Down Expand Up @@ -55,5 +56,6 @@ void any2parameter(register struct expr **expp);
void field2arith(register struct expr **expp);
void switch_sign_fp(register struct expr *expr);
char *writh2str(writh val, int uns);
label code_string(char * val, int len);

#endif /* ARITH_H_ */
6 changes: 2 additions & 4 deletions lang/cem/cemcom.ansi/ch3.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
#include "expr.h"
#include "def.h"
#include "Lpars.h"
#include "LLlex.h"
#include "error.h"
#include "ch3bin.h"
#include "file_info.h"
#include "decspecs.h"

extern char options[];
extern char *symbol2str();
extern struct type *qualifier_type();



/* Most expression-handling routines have a pointer to a
(struct type *) as first parameter. The object under the pointer
Expand Down
4 changes: 1 addition & 3 deletions lang/cem/cemcom.ansi/ch3bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "label.h"
#include "expr.h"
#include "Lpars.h"
#include "LLlex.h"
#include "sizes.h"
#include "ch3bin.h"
#include "ch3mon.h"
Expand All @@ -23,9 +24,6 @@
#include "fltcstoper.h"

extern char options[];
extern char *symbol2str();

void pntminuspnt();

/* This chapter asks for the repeated application of code to handle
an operation that may be executed at compile time or at run time,
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom.ansi/ch3mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <flt_arith.h>
#include "idf.h"
#include "arith.h"
#include "LLlex.h"
#include "type.h"
#include "label.h"
#include "expr.h"
Expand All @@ -22,7 +23,6 @@


extern char options[];
char *symbol2str();

void ch3mon(int oper, register struct expr **expp)
{
Expand Down
6 changes: 2 additions & 4 deletions lang/cem/cemcom.ansi/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ static int pro_id;
#endif /* USE_TMP */

extern char options[];
extern char *symbol2str();
extern char *source;

void loc_init();
extern char *source;

#ifndef LINT
void init_code(char *dst_file)
Expand Down Expand Up @@ -531,7 +529,7 @@ code_declaration(
break;
default:
crash("bad local storage class");
/*NOTREACHED*/
UNREACHABLE_CODE;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom.ansi/conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void conversion(register struct type *from_type, register struct type *to_type)
break;
default:
crash("(conversion) illegal type conversion");
/*NOTREACHED*/
UNREACHABLE_CODE;
}
}
if ((int)(to_type->tp_size) < (int)word_size
Expand Down
1 change: 0 additions & 1 deletion lang/cem/cemcom.ansi/declar.str
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ struct decl_unary {

/* ALLOCDEF "decl_unary" 10 */

extern struct type *declare_type();
extern struct declarator null_declarator;

#endif
3 changes: 1 addition & 2 deletions lang/cem/cemcom.ansi/decspecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
#include "decspecs.h"
#include "Lpars.h"
#include "arith.h"
#include "LLlex.h"
#include "type.h"
#include "level.h"
#include "def.h"
#include "error.h"

extern char options[];
extern int level;
extern char *symbol2str();
extern struct type *qualifier_type();

struct decspecs null_decspecs;

Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom.ansi/decspecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct decspecs {
int ds_typequal; /* type qualifiers - see type.str */
};

extern struct type *qualifier_type();
extern struct type *qualifier_type(struct type* tp, int typequal);
extern struct decspecs null_decspecs;

struct type;
Expand Down
1 change: 1 addition & 0 deletions lang/cem/cemcom.ansi/def.str
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/* $Id$ */
/* IDENTIFIER DEFINITION DESCRIPTOR */

#include "alloc.h"
#include "parameters.h"

struct def { /* for ordinary tags */
Expand Down
2 changes: 1 addition & 1 deletion lang/cem/cemcom.ansi/dumpidf.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern char options[];


extern struct idf *idf_hashtable[];
extern char *symbol2str();


enum sdef_kind {selector, field}; /* parameter for dumpsdefs */

Expand Down
10 changes: 5 additions & 5 deletions lang/cem/cemcom.ansi/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void crash(char *fmt, ...)
#else /* DEBUG */
sys_stop(S_EXIT);
#endif /* DEBUG */
/* NOTREACHED */
UNREACHABLE_CODE;
}

/*VARARGS*/
Expand All @@ -270,7 +270,7 @@ void fatal(char *fmt, ...)

if (C_busy()) C_close();
sys_stop(S_EXIT);
/*NOTREACHED*/
UNREACHABLE_CODE;
}
#else
/*VARARGS*/
Expand Down Expand Up @@ -501,7 +501,7 @@ void crash(va_alist) /* fmt, args */
#else /* DEBUG */
sys_stop(S_EXIT);
#endif /* DEBUG */
/* NOTREACHED */
UNREACHABLE_CODE;
}

/*VARARGS*/
Expand All @@ -519,7 +519,7 @@ void fatal(va_alist) /* fmt, args */

if (C_busy()) C_close();
sys_stop(S_EXIT);
/*NOTREACHED*/
UNREACHABLE_CODE;
}
#endif

Expand Down Expand Up @@ -593,7 +593,7 @@ static void _error(int class, char *fn, unsigned int ln, char* fmt, va_list ap)
break;
#endif /* DEBUG */
default:
/*NOTREACHED*/;
UNREACHABLE_CODE;
}

#ifdef LINT
Expand Down
3 changes: 1 addition & 2 deletions lang/cem/cemcom.ansi/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "sizes.h"
#include "field.h"
#include "Lpars.h"
#include "LLlex.h"
#include "level.h"
#include "conversion.h"
#include "stack.h"
Expand All @@ -42,8 +43,6 @@

#define CRASH() crash("EVAL: CRASH at line %u", __LINE__)

char *symbol2str();
arith NewLocal(); /* util.c */
#define LocalPtrVar() NewLocal(pointer_size, pointer_align, reg_pointer, REGISTER)
extern int err_occurred; /* error.c */

Expand Down
10 changes: 5 additions & 5 deletions lang/cem/cemcom.ansi/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "cstoper.h"
#include "error.h"

extern char *symbol2str();

extern char options[];
extern int InSizeof;

Expand Down Expand Up @@ -97,7 +97,7 @@ int rank_of(int oper)
case ',':
return 15;
}
/*NOTREACHED*/
UNREACHABLE_CODE;
}

void dot2expr(struct expr **expp)
Expand All @@ -123,7 +123,7 @@ void dot2expr(struct expr **expp)
break;
default:
crash("bad conversion to expression");
/*NOTREACHED*/
UNREACHABLE_CODE;
}
}

Expand Down Expand Up @@ -306,7 +306,7 @@ writh ivalue, int fund)
break;
default:
crash("(fill_int_expr) bad fund %s\n", symbol2str(fund));
/*NOTREACHED*/
UNREACHABLE_CODE;
}
ex->ex_class = Value;
ex->VL_CLASS = Const;
Expand Down Expand Up @@ -488,7 +488,7 @@ int is_zero_cst(register struct expr *expr)
flt_arith2flt((arith) 0, &var, 0);
return flt_cmp(&var, &(expr->FL_ARITH)) == 0;
}
/*NOTREACHED*/
UNREACHABLE_CODE;
}

void free_expression(register struct expr *expr)
Expand Down
Loading

0 comments on commit e7b76f4

Please sign in to comment.