Skip to content

Commit

Permalink
updated to r1912 from svn repo
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed May 16, 2019
1 parent 7af7d01 commit e61aac5
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 28 deletions.
7 changes: 7 additions & 0 deletions 64tass.1
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ Warns when a long branch is used.
This option gives a warning for instructions which were modified by the long branch function.
Less intrusive than disabling long branches and see where it fails.
.TP 0.5i
\fB\-Wmacro\-prefix\fR
Warn about macro call without prefix.
Such macro calls can easily be mistaken to be labels if invoked without parameters.
Also it's hard to notice that an unchanged call turned into label after the
definition got renamed. This warning helps to find such calls so that prefixes
can be added.
.TP 0.5i
\fB\-Wno\-deprecated\fR
Don't warn about deprecated features.
Unfortunately there were some features added previously which shouldn't
Expand Down
7 changes: 6 additions & 1 deletion 64tass.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Turbo Assembler 6502/65C02/65816/DTV
$Id: 64tass.c 1901 2019-02-22 18:25:42Z soci $
$Id: 64tass.c 1906 2019-04-19 09:14:42Z soci $
6502/65C02 Turbo Assembler Version 1.3
(c) 1996 Taboo Productions, Marek Matula
Expand Down Expand Up @@ -2609,6 +2609,7 @@ MUST_CHECK Obj *compile(void)
const Type *obj = tmp2->value->obj;
if (diagnostics.case_symbol && str_cmp(&labelname, &tmp2->name) != 0) err_msg_symbol_case(&labelname, tmp2, &epoint);
if (obj == MACRO_OBJ || obj == SEGMENT_OBJ || obj == MFUNC_OBJ) {
if (diagnostics.macro_prefix && (here() == 0 || here() == ';')) err_msg_macro_prefix(&epoint);
touch_label(tmp2);
labelname.len = 0;val = tmp2->value; goto as_macro;
}
Expand Down Expand Up @@ -4492,6 +4493,10 @@ MUST_CHECK Obj *compile(void)
const Type *obj = tmp2->value->obj;
if (diagnostics.case_symbol && str_cmp(&opname, &tmp2->name) != 0) err_msg_symbol_case(&opname, tmp2, &epoint);
if (obj == MACRO_OBJ || obj == SEGMENT_OBJ || obj == MFUNC_OBJ) {
if (diagnostics.macro_prefix) {
ignore();
if (here() == 0 || here() == ';') err_msg_macro_prefix(&epoint);
}
touch_label(tmp2);
val = tmp2->value;goto as_macro;
}
Expand Down
10 changes: 10 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,14 @@ default, the others are disabled.
long branch function. Less intrusive than disabling long branches and see
where it fails.

-Wmacro-prefix
Warn about macro call without prefix.

Such macro calls can easily be mistaken to be labels if invoked without
parameters. Also it's hard to notice that an unchanged call turned into
label after the definition got renamed. This warning helps to find such
calls so that prefixes can be added.

-Wno-deprecated
Don't warn about deprecated features.

Expand Down Expand Up @@ -3666,6 +3674,8 @@ last byte must not be gap
.shift or .shiftl needs a normal byte at the end
logarithm of non-positive number
only positive numbers have a logarithm
macro call without prefix
macro call was found without a prefix and without parameters
more than a single character
no more than a single character is allowed
more than two characters
Expand Down
8 changes: 8 additions & 0 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -3442,6 +3442,13 @@ <h3>Diagnostic options<a name="commandline-diagnostic" href="#commandline-diagno
<p>This option gives a warning for instructions which were modified by the long branch function.
Less intrusive than disabling long branches and see where it fails.</p>

<dt><b>-Wmacro-prefix</b><a name="o_Wmacro-prefix" href="#o_Wmacro-prefix"></a>
<dd>Warn about macro call without prefix.
<p>Such macro calls can easily be mistaken to be labels if invoked without parameters.
Also it's hard to notice that an unchanged call turned into label after the
definition got renamed. This warning helps to find such calls so that prefixes
can be added.</p>

<dt><b>-Wno-deprecated</b><a name="o_Wdeprecated" href="#o_Wdeprecated"></a>
<dd>Don't warn about deprecated features.
<p>Unfortunately there were some features added previously which shouldn't have
Expand Down Expand Up @@ -3994,6 +4001,7 @@ <h3>Errors<a name="messages-errors" href="#messages-errors"></a></h3>
<dt>label required<dd>a label is mandatory for this directive
<dt>last byte must not be gap<dd>.shift or .shiftl needs a normal byte at the end
<dt>logarithm of non-positive number<dd>only positive numbers have a logarithm
<dt>macro call without prefix<dd>macro call was found without a prefix and without parameters
<dt>more than a single character<dd>no more than a single character is allowed
<dt>more than two characters<dd>no more than two characters are allowed
<dt>most significant bit must be clear in byte<dd>for .shift and .shiftl only 7 bit "bytes" are valid
Expand Down
16 changes: 11 additions & 5 deletions arguments.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: arguments.c 1687 2018-12-09 17:44:10Z soci $
$Id: arguments.c 1906 2019-04-19 09:14:42Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -86,7 +86,8 @@ struct diagnostics_s diagnostics = {
false, /* long_branch */
false, /* altmode */
true, /* page */
true /* type_mixing */
true, /* type_mixing */
false /* macro_prefix */
};

struct diagnostics_s diagnostic_errors = {
Expand Down Expand Up @@ -120,7 +121,8 @@ struct diagnostics_s diagnostic_errors = {
false, /* long_branch */
false, /* altmode */
true, /* page */
true /* type_mixing */
true, /* type_mixing */
false /* macro_prefix */
};

static struct diagnostics_s diagnostic_no_all;
Expand Down Expand Up @@ -155,7 +157,8 @@ static struct diagnostics_s diagnostic_all = {
false, /* long_branch */
false, /* altmode */
true, /* page */
true /* type_mixing */
true, /* type_mixing */
false /* macro_prefix */
};

static struct diagnostics_s diagnostic_no_error_all;
Expand Down Expand Up @@ -190,7 +193,8 @@ static struct diagnostics_s diagnostic_error_all = {
true, /* long_branch */
true, /* altmode */
true, /* page */
true /* type_mixing */
true, /* type_mixing */
true /* macro_prefix */
};

struct w_options_s {
Expand Down Expand Up @@ -228,6 +232,7 @@ static const struct w_options_s w_options[] = {
{"altmode", &diagnostics.altmode},
{"page", &diagnostics.page},
{"type-mixing", &diagnostics.type_mixing},
{"macro-prefix", &diagnostics.macro_prefix},
{NULL, NULL}
};

Expand Down Expand Up @@ -545,6 +550,7 @@ int testarg(int *argc2, char **argv2[], struct file_s *fin) {
" -Wimplied-reg No implied register aliases\n"
" -Wleading-zeros Warn for ignored leading zeros\n"
" -Wlong-branch Warn when a long branch is used\n"
" -Wmacro-prefix Warn about unprefixed macro calls\n"
" -Wno-deprecated No deprecated feature warnings\n"
" -Wno-float-compare No approximate compare warnings\n"
" -Wno-ignored No directive ignored warnings\n"
Expand Down
3 changes: 2 additions & 1 deletion arguments.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: arguments.h 1660 2018-09-22 11:39:02Z soci $
$Id: arguments.h 1906 2019-04-19 09:14:42Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -99,6 +99,7 @@ struct diagnostics_s {
bool altmode;
bool page;
bool type_mixing;
bool macro_prefix;
};

extern int testarg(int *, char ***, struct file_s *);
Expand Down
4 changes: 2 additions & 2 deletions bytesobj.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: bytesobj.c 1861 2019-02-03 19:36:52Z soci $
$Id: bytesobj.c 1911 2019-04-22 07:41:49Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -243,7 +243,7 @@ static uint8_t *z85_encode(uint8_t *dest, const uint8_t *src, size_t len) {
return dest;
}

const uint8_t z85_dec[93] = {
static const uint8_t z85_dec[93] = {
68, 85, 84, 83, 82, 72, 85, 75, 76, 70, 65, 85, 63, 62, 69,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 64, 85, 73, 66, 74, 71,
81, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
Expand Down
13 changes: 9 additions & 4 deletions error.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: error.c 1902 2019-02-22 18:26:53Z soci $
$Id: error.c 1911 2019-04-22 07:41:49Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -903,6 +903,11 @@ void err_msg_symbol_case(const str_t *labelname1, Label *l, linepos_t epoint) {
if (l != NULL) err_msg_double_note(l->file_list, &l->epoint, &l->name);
}

void err_msg_macro_prefix(linepos_t epoint) {
new_error_msg2(diagnostic_errors.macro_prefix, epoint);
adderror("macro call without prefix [-Wmacro-prefix]");
}

static const char * const opr_names[ADR_LEN] = {
"", /* ADR_REG */
"", /* ADR_IMPLIED */
Expand Down Expand Up @@ -1230,7 +1235,7 @@ static bool different_line(const struct errorentry_s *err, const struct errorent
return memcmp(err + 1, err2 + 1, err->line_len) != 0;
}

bool error_print() {
bool error_print(void) {
const struct errorentry_s *err, *err2, *err3;
size_t pos;
bool noneerr = false, anyerr = false, usenote;
Expand Down Expand Up @@ -1365,14 +1370,14 @@ void fatal_error(const char *txt) {
putc('\n', stderr);
}

void err_msg_out_of_memory2(void)
NO_RETURN void err_msg_out_of_memory2(void)
{
fatal_error("out of memory");
fatal_error(NULL);
exit(EXIT_FAILURE);
}

void err_msg_out_of_memory(void)
NO_RETURN void err_msg_out_of_memory(void)
{
error_print();
err_msg_out_of_memory2();
Expand Down
3 changes: 2 additions & 1 deletion error.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: error.h 1872 2019-02-09 14:29:01Z soci $
$Id: error.h 1906 2019-04-19 09:14:42Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -77,6 +77,7 @@ extern void err_msg_unused_variable(struct Label *);
extern void err_msg_not_defined(const struct str_t *, linepos_t);
extern void err_msg_not_defined2(const struct str_t *, struct Namespace *, bool, linepos_t);
extern void err_msg_symbol_case(const struct str_t *, struct Label *, linepos_t);
extern void err_msg_macro_prefix(linepos_t);
extern void err_msg_address_mismatch(int, int, linepos_t);
extern void err_msg_file(Error_types, const char *, linepos_t);
extern void err_msg_output(const struct Error *);
Expand Down
4 changes: 2 additions & 2 deletions errorobj.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: errorobj.c 1885 2019-02-10 15:05:45Z soci $
$Id: errorobj.c 1912 2019-04-26 06:34:15Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -49,7 +49,7 @@ static FAST_CALL void destroy(Obj *o1) {
val_destroy(v1->u.intconv.val);
return;
case ERROR___NOT_DEFINED:
val_destroy((Obj *)v1->u.notdef.ident);
val_destroy(v1->u.notdef.ident);
val_destroy((Obj *)v1->u.notdef.names);
return;
case ERROR__NOT_KEYVALUE:
Expand Down
4 changes: 2 additions & 2 deletions file.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: file.c 1873 2019-02-09 14:34:38Z soci $
$Id: file.c 1911 2019-04-22 07:41:49Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -44,7 +44,7 @@ struct include_list_s {
};

static struct include_list_s include_list;
struct include_list_s *include_list_last = &include_list;
static struct include_list_s *include_list_last = &include_list;

static struct avltree file_tree;

Expand Down
14 changes: 8 additions & 6 deletions instruction.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: instruction.c 1881 2019-02-09 19:41:34Z soci $
$Id: instruction.c 1905 2019-04-16 06:08:52Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -439,11 +439,11 @@ MUST_CHECK Error *instruction(int prm, unsigned int w, Obj *vals, linepos_t epoi
} else {
adr = (uint16_t)(uval - current_address->l_address.address - 1 - ln);
}
if ((adr<0xFF80 && adr>0x007F) || crossbank) {
if (cnmemonic[ADR_REL_L] != ____ && !crossbank) { /* 65CE02 long branches */
if ((adr<0xFF80 && adr>0x007F) || crossbank || w == 1 || w == 2) {
if (cnmemonic[ADR_REL_L] != ____ && !crossbank && (w == 3 || w == 1)) { /* 65CE02 long branches */
opr = ADR_REL_L;
ln = 2;
} else if (arguments.longbranch && (cnmemonic[ADR_ADDR] == ____)) { /* fake long branches */
} else if (arguments.longbranch && (cnmemonic[ADR_ADDR] == ____) && w == 3) { /* fake long branches */
if ((cnmemonic[ADR_REL] & 0x1f) == 0x10) {/* bxx branch */
bool exists;
struct longjump_s *lj = new_longjump(uval, &exists);
Expand Down Expand Up @@ -523,7 +523,9 @@ MUST_CHECK Error *instruction(int prm, unsigned int w, Obj *vals, linepos_t epoi
if (current_cpu->brl >= 0 && !longbranchasjmp) goto asbrl; /* gcc -> brl */
goto asjmp; /* gcc -> jmp */
} else { /* too long */
if (crossbank) {
if (w != 3 && w != 0) {
err_msg2((w == 1) ? ERROR__NO_WORD_ADDR : ERROR__NO_LONG_ADDR, NULL, epoint);
} else if (crossbank) {
err_msg2(ERROR_CANT_CROSS_BA, val, epoint2);
} else {
int dist = (int16_t)adr; dist += (dist < 0) ? 0x80 : -0x7f;
Expand All @@ -537,7 +539,7 @@ MUST_CHECK Error *instruction(int prm, unsigned int w, Obj *vals, linepos_t epoi
if (!allowslowbranch) err_msg2(ERROR__BRANCH_CROSS, &diff, epoint);
else if (diagnostics.branch_page) err_msg_branch_page(diff, epoint);
}
if (cnmemonic[ADR_ADDR] != ____) { /* gcc */
if (cnmemonic[ADR_ADDR] != ____ && w == 3) { /* gcc */
if (adr == 0) {
dump_instr(cnmemonic[ADR_REL], 0, -1, epoint);
err = NULL;
Expand Down
4 changes: 2 additions & 2 deletions intobj.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: intobj.c 1875 2019-02-09 17:09:58Z soci $
$Id: intobj.c 1912 2019-04-26 06:34:15Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -359,7 +359,7 @@ static MUST_CHECK Obj *calc1(oper_t op) {
}
return &v->v;
case O_NEG:
if (op->inplace != &v1->v) return (Obj *)negate(v1, op->epoint3);
if (op->inplace != &v1->v) return negate(v1, op->epoint3);
v1->len = -v1->len;
return val_reference(&v1->v);
case O_POS: return (Obj *)ref_int(v1);
Expand Down
4 changes: 2 additions & 2 deletions ternary.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ternary.c - Ternary Search Trees
$Id: ternary.c 1826 2019-01-19 14:40:58Z soci $
$Id: ternary.c 1911 2019-04-22 07:41:49Z soci $
Copyright (C) 2001 Free Software Foundation, Inc.
Expand Down Expand Up @@ -43,7 +43,7 @@ static void tern_free(union tern_u *tern) {
terns_free = tern;
}

static union tern_u *terns_alloc() {
static union tern_u *terns_alloc(void) {
size_t i;
struct terns_s *old = terns;
terns = (struct terns_s *)mallocx(sizeof *terns);
Expand Down

0 comments on commit e61aac5

Please sign in to comment.