mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-03 11:31:21 +00:00
Added WeeIP test of complex array of structs with char* members. Improved error message when applying member reference operator to non-struct.
This commit is contained in:
parent
77b7785470
commit
6f69add10a
@ -7,6 +7,7 @@ import dk.camelot64.kickc.model.symbols.StructDefinition;
|
|||||||
import dk.camelot64.kickc.model.symbols.Variable;
|
import dk.camelot64.kickc.model.symbols.Variable;
|
||||||
import dk.camelot64.kickc.model.types.SymbolType;
|
import dk.camelot64.kickc.model.types.SymbolType;
|
||||||
import dk.camelot64.kickc.model.types.SymbolTypeInference;
|
import dk.camelot64.kickc.model.types.SymbolTypeInference;
|
||||||
|
import dk.camelot64.kickc.model.types.SymbolTypePointer;
|
||||||
import dk.camelot64.kickc.model.types.SymbolTypeStruct;
|
import dk.camelot64.kickc.model.types.SymbolTypeStruct;
|
||||||
import dk.camelot64.kickc.model.values.StructMemberRef;
|
import dk.camelot64.kickc.model.values.StructMemberRef;
|
||||||
|
|
||||||
@ -32,6 +33,11 @@ public class PassNAssertStructMembers extends Pass2SsaOptimization {
|
|||||||
if(member==null) {
|
if(member==null) {
|
||||||
throw new CompileError("Unknown struct member "+structMemberRef.getMemberName()+" in struct "+structType.getTypeName(), currentStmt);
|
throw new CompileError("Unknown struct member "+structMemberRef.getMemberName()+" in struct "+structType.getTypeName(), currentStmt);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if(type instanceof SymbolTypePointer)
|
||||||
|
throw new CompileError("member '"+structMemberRef.getMemberName()+"' reference type '"+type.getTypeBaseName()+"' is a pointer; did you mean to use '->'?", currentStmt);
|
||||||
|
else
|
||||||
|
throw new CompileError("member '"+structMemberRef.getMemberName()+"' reference operator '.'/'->' applied to a non-struct", currentStmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -2267,6 +2267,11 @@ public class TestProgramsFast extends TestPrograms {
|
|||||||
compileAndCompare("weeip-checksum.c");
|
compileAndCompare("weeip-checksum.c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWeeipBbbsList() throws IOException {
|
||||||
|
compileAndCompare("weeip-bbslist.c");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUnion8() throws IOException {
|
public void testUnion8() throws IOException {
|
||||||
compileAndCompare("union-8.c");
|
compileAndCompare("union-8.c");
|
||||||
|
49
src/test/kc/weeip-bbslist.c
Normal file
49
src/test/kc/weeip-bbslist.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// Test initialization of array of struct with char* elements
|
||||||
|
|
||||||
|
#include <c64.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
struct bbs {
|
||||||
|
char *name;
|
||||||
|
char *host_name;
|
||||||
|
unsigned int port_number;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NULL 0
|
||||||
|
|
||||||
|
const struct bbs bbs_list[27]=
|
||||||
|
{
|
||||||
|
{"Boar's Head","byob.hopto.org",64128},
|
||||||
|
{"RapidFire","rapidfire.hopto.org",64128},
|
||||||
|
{"Antidote by Triad","antidote.hopto.org",64128},
|
||||||
|
{"Wizards's Realm", "wizardsrealm.c64bbs.org", 23},
|
||||||
|
{"The Hidden", "the-hidden.hopto.org", 64128},
|
||||||
|
{"Eaglewing BBS", "eagelbird.ddns.net", 6400},
|
||||||
|
{"Scorps Portal", "scorp.us.to", 23},
|
||||||
|
{"My C=ult BBS", "maraud.dynalias.com", 6400},
|
||||||
|
{"Commodore Image", "cib.dyndns.org", 6400},
|
||||||
|
{"64 Vintag Remic", "64vintageremixbbs.dyndns.org", 6400},
|
||||||
|
{"Jamming Signal", "bbs.jammingsignal.com", 23},
|
||||||
|
{"Centronian BBS", "centronian.servebeer.com", 6400},
|
||||||
|
{"Anrchy Undergrnd", "aubbs.dyndns.org", 2300},
|
||||||
|
{"The Oasis BBS", "oasisbbs.hopto.org", 6400},
|
||||||
|
{"The Disk Box", "bbs.thediskbox.com", 6400},
|
||||||
|
{"Cottonwood", "cottonwoodbbs.dyndns.org", 6502},
|
||||||
|
{"Wrong Number ][", "cib.dyndns.org", 6404},
|
||||||
|
{"RabidFire", "rapidfire.hopto.org", 64128},
|
||||||
|
{"Mad World", "madworld.bounceme.net", 6400},
|
||||||
|
{"Citadel 64", "bbs.thejlab.com", 6400},
|
||||||
|
{"Hotwire BBS", "hotwirebbs.zapto.org", 6502},
|
||||||
|
{"Endless Chaos", "endlesschaos.dyndns.org", 6400},
|
||||||
|
{"Borderline", "borderlinebbs.dyndns.org", 6400},
|
||||||
|
{"RAVELOUTION","raveolution.hopto.org",64128},
|
||||||
|
{"The Edge BBS","theedgebbs.dyndns.org",1541},
|
||||||
|
{"PGS Test","F96NG92-L.fritz.box",64128},
|
||||||
|
{NULL,NULL,0}
|
||||||
|
};
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
VICII->MEMORY = 0x17;
|
||||||
|
for(struct bbs * bbs = bbs_list; bbs->name; bbs++)
|
||||||
|
printf("%s %s %u\n", bbs->name, bbs->host_name, bbs->port_number);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user