Skip to content

Commit a0057c6

Browse files
committed
fix struct usage in DAT
1 parent 5e3ed3a commit a0057c6

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

Changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Version 7.1.2
22
- Fix namespace usage during initial address assignment (so labels in namespaces work in ORG/RES/FIT etc.)
33
- Fix some issues around array address calculations in Spin2
4+
- Fix struct usage in DAT sections
45

56
Version 7.1.1
67
- Fixed using struct names for return values and parameters in Spin2

backends/dat/outdat.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,9 +2026,10 @@ outputVarDeclare(Flexbuf *f, AST *ast, Flexbuf *relocs)
20262026
AST *type = ast->left;
20272027
int siz;
20282028
int typsiz;
2029-
2030-
ast = ast->right;
2031-
if (ast->kind == AST_ASSIGN) {
2029+
2030+
if (ast)
2031+
ast = ast->right;
2032+
if (ast && ast->kind == AST_ASSIGN) {
20322033
initval = ast->right;
20332034
ast = ast->left;
20342035
}

frontends/spin/spin.y

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,15 +1316,6 @@ datline:
13161316
idast = NewAST(AST_LISTHOLDER, linebreak, idast);
13171317
$$ = idast;
13181318
}
1319-
| identifier structname
1320-
{
1321-
AST *ident = $1;
1322-
AST *typ = $2;
1323-
AST *var;
1324-
1325-
var = NewAST(AST_DECLARE_VAR, typ, ident);
1326-
$$ = NewAST(AST_LISTHOLDER, var, NULL);
1327-
}
13281319
;
13291320

13301321
basedatline:
@@ -1465,6 +1456,15 @@ basedatline:
14651456
{
14661457
$$ = NewAST(AST_NAMESPACE, $2, NULL);
14671458
}
1459+
| structname
1460+
{
1461+
AST *ident = NULL;
1462+
AST *typ = $1;
1463+
AST *var;
1464+
1465+
var = NewAST(AST_DECLARE_VAR, typ, ident);
1466+
$$ = var;
1467+
}
14681468
;
14691469

14701470
optidentifier:

pasm.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,8 +1078,8 @@ AssignAddresses(PASMAddresses *addr, SymbolTable *orig_symtab, AST *instrlist, i
10781078
// initializers always go in HUB memory
10791079
inHub = 1;
10801080
MARK_DATA(label_flags);
1081-
AstReportAs(ident, &saveinfo);
1082-
if (ident->kind == AST_ASSIGN) {
1081+
AstReportAs(ast, &saveinfo);
1082+
if (ident && ident->kind == AST_ASSIGN) {
10831083
initptr = &ident->right;
10841084
initializer = ident->right;
10851085
ident = ident->left;
@@ -1090,6 +1090,7 @@ AssignAddresses(PASMAddresses *addr, SymbolTable *orig_symtab, AST *instrlist, i
10901090
}
10911091
typalign = TypeAlign(type);
10921092
typsize = TypeSize(type);
1093+
lasttype = type;
10931094
if (typsize == 0 && IsClassType(type)) {
10941095
// empty object; this is OK if it has methods
10951096
Module *Q = GetClassPtr(type);
@@ -1102,13 +1103,15 @@ AssignAddresses(PASMAddresses *addr, SymbolTable *orig_symtab, AST *instrlist, i
11021103
*initptr = initializer;
11031104
}
11041105
ALIGNPC(typalign);
1105-
if (ident->kind == AST_LOCAL_IDENTIFIER) {
1106-
ident = ident->left;
1107-
}
1108-
if (ident->kind != AST_IDENTIFIER) {
1109-
ERROR(ast, "Internal error in DECLARE_VAR: expected identifier");
1110-
} else {
1111-
pendingLabels = AddToList(pendingLabels, NewAST(AST_LISTHOLDER, ident, NULL));
1106+
if (ident) {
1107+
if (ident->kind == AST_LOCAL_IDENTIFIER) {
1108+
ident = ident->left;
1109+
}
1110+
if (ident->kind != AST_IDENTIFIER) {
1111+
ERROR(ast, "Internal error in DECLARE_VAR: expected identifier");
1112+
} else {
1113+
pendingLabels = AddToList(pendingLabels, NewAST(AST_LISTHOLDER, ident, NULL));
1114+
}
11121115
}
11131116
pendingLabels = emitPendingLabels(symtab, pendingLabels, hubpc, cogpc, type, lastOrg, inHub, label_flags, pass);
11141117
INCPC(typsize);

0 commit comments

Comments
 (0)