From e61aac56788fe8840f2af57929a624754f16c8e4 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 16 May 2019 23:38:37 +0200 Subject: [PATCH] updated to r1912 from svn repo --- 64tass.1 | 7 +++++++ 64tass.c | 7 ++++++- README | 10 ++++++++++ README.html | 8 ++++++++ arguments.c | 16 +++++++++++----- arguments.h | 3 ++- bytesobj.c | 4 ++-- error.c | 13 +++++++++---- error.h | 3 ++- errorobj.c | 4 ++-- file.c | 4 ++-- instruction.c | 14 ++++++++------ intobj.c | 4 ++-- ternary.c | 4 ++-- 14 files changed, 73 insertions(+), 28 deletions(-) diff --git a/64tass.1 b/64tass.1 index 895e783..7a5fcf8 100644 --- a/64tass.1 +++ b/64tass.1 @@ -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 diff --git a/64tass.c b/64tass.c index 56998dd..bb37eef 100644 --- a/64tass.c +++ b/64tass.c @@ -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 @@ -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; } @@ -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; } diff --git a/README b/README index 9ed6cc9..a94e67b 100644 --- a/README +++ b/README @@ -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. @@ -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 diff --git a/README.html b/README.html index f00f577..d14d712 100644 --- a/README.html +++ b/README.html @@ -3442,6 +3442,13 @@

Diagnostic options +
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.

Unfortunately there were some features added previously which shouldn't have @@ -3994,6 +4001,7 @@

Errors

label required
a label is mandatory for this directive
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
no more than two characters are allowed
most significant bit must be clear in byte
for .shift and .shiftl only 7 bit "bytes" are valid diff --git a/arguments.c b/arguments.c index a430ab0..2c78e4c 100644 --- a/arguments.c +++ b/arguments.c @@ -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 @@ -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 = { @@ -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; @@ -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; @@ -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 { @@ -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} }; @@ -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" diff --git a/arguments.h b/arguments.h index bad209b..1c12245 100644 --- a/arguments.h +++ b/arguments.h @@ -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 @@ -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 *); diff --git a/bytesobj.c b/bytesobj.c index 2ca87a7..4867030 100644 --- a/bytesobj.c +++ b/bytesobj.c @@ -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 @@ -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, diff --git a/error.c b/error.c index 85c4852..4d4b42b 100644 --- a/error.c +++ b/error.c @@ -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 @@ -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 */ @@ -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; @@ -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(); diff --git a/error.h b/error.h index 8251338..62ccbc2 100644 --- a/error.h +++ b/error.h @@ -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 @@ -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 *); diff --git a/errorobj.c b/errorobj.c index 4d86760..e2eed2e 100644 --- a/errorobj.c +++ b/errorobj.c @@ -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 @@ -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: diff --git a/file.c b/file.c index e5d0b77..ad56589 100644 --- a/file.c +++ b/file.c @@ -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 @@ -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; diff --git a/instruction.c b/instruction.c index a41d5ca..79b0eaf 100644 --- a/instruction.c +++ b/instruction.c @@ -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 @@ -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); @@ -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; @@ -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; diff --git a/intobj.c b/intobj.c index c77cc37..9471de5 100644 --- a/intobj.c +++ b/intobj.c @@ -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 @@ -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); diff --git a/ternary.c b/ternary.c index 450ee94..5c94491 100644 --- a/ternary.c +++ b/ternary.c @@ -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. @@ -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);