Tweaked CFLAGS, and fixed related errors

This commit is contained in:
2024-12-12 16:18:41 +11:00
parent 5f4dfdccc5
commit fce71a6cda
19 changed files with 29 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
#compiler settings reference
#CC=gcc
#CFLAGS+=-std=c17 -g -Wall -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wformat=2
#CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
#LIBS+=-lm
#LDFLAGS+=

View File

@@ -1,6 +1,6 @@
#compiler settings
CC=gcc
CFLAGS+=-std=c17 -g -Wall -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wformat=2
#CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
LIBS+=-lm -lToy
LDFLAGS+=-Wl,-rpath,'$$ORIGIN'

View File

@@ -1,6 +1,6 @@
#compiler settings
CC=gcc
CFLAGS+=-std=c17 -g -Wall -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wformat=2
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
LIBS+=-lm
LDFLAGS+=

View File

@@ -406,6 +406,7 @@ static unsigned int writeInstructionWhileThen(Toy_Routine** rt, Toy_AstWhileThen
static unsigned int writeInstructionBreak(Toy_Routine** rt, Toy_AstBreak ast) {
//TODO: implement break
(void)ast;
fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Keyword 'break' not yet implemented\n" TOY_CC_RESET);
(*rt)->panic = true;
@@ -414,6 +415,7 @@ static unsigned int writeInstructionBreak(Toy_Routine** rt, Toy_AstBreak ast) {
static unsigned int writeInstructionContinue(Toy_Routine** rt, Toy_AstContinue ast) {
//TODO: implement continue
(void)ast;
fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Keyword 'continue' not yet implemented\n" TOY_CC_RESET);
(*rt)->panic = true;

View File

@@ -82,7 +82,7 @@ Toy_Scope* Toy_deepCopyScope(Toy_Bucket** bucketHandle, Toy_Scope* scope) {
incrementRefCount(newScope);
//forcibly copy the contents
for (int i = 0; i < scope->table->capacity; i++) {
for (unsigned int i = 0; i < scope->table->capacity; i++) {
if (!TOY_VALUE_IS_NULL(scope->table->data[i].key)) {
Toy_insertTable(&newScope->table, Toy_copyValue(scope->table->data[i].key), Toy_copyValue(scope->table->data[i].value));
}

View File

@@ -230,7 +230,7 @@ char* Toy_getStringRawBuffer(Toy_String* str) {
}
//BUGFIX: Make sure it's aligned, and there's space for the null
int len = (str->length + 3) & ~3;
unsigned int len = (str->length + 3) & ~3;
if (len == str->length) {
len += 4;
}

View File

@@ -74,7 +74,7 @@ Toy_Table* Toy_private_adjustTableCapacity(Toy_Table* oldTable, unsigned int new
}
//for each entry in the old table, copy it into the new table
for (int i = 0; i < oldTable->capacity; i++) {
for (unsigned int i = 0; i < oldTable->capacity; i++) {
if (!TOY_VALUE_IS_NULL(oldTable->data[i].key)) {
probeAndInsert(&newTable, oldTable->data[i].key, oldTable->data[i].value);
}

View File

@@ -231,7 +231,7 @@ static void processAssignCompound(Toy_VM* vm) {
int index = TOY_VALUE_AS_INTEGER(key);
//bounds check
if (index < 0 || index >= array->count) {
if (index < 0 || (unsigned int)index >= array->count) {
Toy_error("Index of assignment target out of bounds");
Toy_freeValue(target);
Toy_freeValue(key);
@@ -671,7 +671,7 @@ static void processIndex(Toy_VM* vm) {
Toy_String* str = TOY_VALUE_AS_STRING(value);
//check indexing is within bounds
if ( (i < 0 || i >= str->length) || (i+l <= 0 || i+l > str->length)) {
if ( (i < 0 || (unsigned int)i >= str->length) || (i+l <= 0 || (unsigned int)(i+l) > str->length)) {
Toy_error("String index is out of bounds");
if (TOY_VALUE_IS_REFERENCE(value) != true) {
Toy_freeValue(value);
@@ -743,7 +743,7 @@ static void processIndex(Toy_VM* vm) {
Toy_Array* array = TOY_VALUE_AS_ARRAY(value);
//check indexing is within bounds
if ( (i < 0 || i >= array->count) || (i+l <= 0 || i+l > array->count)) {
if ( (i < 0 || (unsigned int)i >= array->count) || (i+l <= 0 || (unsigned int)(i+l) > array->count)) {
Toy_error("Array index is out of bounds");
if (TOY_VALUE_IS_REFERENCE(value) != true) {
Toy_freeValue(value);

View File

@@ -1,6 +1,6 @@
#compiler settings
CC=gcc
CFLAGS+=-std=c17 -g -Wall -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wformat=2
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
LIBS+=-lm
LDFLAGS+=

View File

@@ -1,6 +1,6 @@
#compiler settings
CC=gcc
CFLAGS+=-std=c17 -g -Wall -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wformat=2
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
LIBS+=-lm
LDFLAGS+=

View File

@@ -25,10 +25,10 @@ int test_buckets() {
Toy_Bucket* bucket = Toy_allocateBucket(sizeof(int) * 32);
//grab some memory
int* a = Toy_partitionBucket(&bucket, sizeof(int));
int* b = Toy_partitionBucket(&bucket, sizeof(int));
int* c = Toy_partitionBucket(&bucket, sizeof(int));
int* d = Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
//check
if (bucket == NULL || bucket->count != 4 * sizeof(int)) {
@@ -46,12 +46,12 @@ int test_buckets() {
Toy_Bucket* bucket = Toy_allocateBucket(sizeof(int) * 4);
//grab some memory
int* a = Toy_partitionBucket(&bucket, sizeof(int));
int* b = Toy_partitionBucket(&bucket, sizeof(int));
int* c = Toy_partitionBucket(&bucket, sizeof(int));
int* d = Toy_partitionBucket(&bucket, sizeof(int));
int* e = Toy_partitionBucket(&bucket, sizeof(int));
int* f = Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
Toy_partitionBucket(&bucket, sizeof(int));
//checks - please note that the top-most bucket is what is being filled - older buckets are further along
if (

View File

@@ -5,7 +5,7 @@
int counter = 0;
void count(const char* msg) {
void count(const char*) {
counter++;
}

View File

@@ -19,7 +19,6 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -68,7 +67,6 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -117,7 +115,6 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -170,7 +167,6 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -223,7 +219,6 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -277,7 +272,6 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -331,7 +325,6 @@ int test_routine_expressions(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* header = (int*)buffer;
@@ -438,7 +431,6 @@ int test_routine_binary(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -504,7 +496,6 @@ int test_routine_binary(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -570,7 +561,6 @@ int test_routine_binary(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -636,7 +626,6 @@ int test_routine_binary(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -732,7 +721,6 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -791,7 +779,6 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -855,7 +842,6 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -946,7 +932,6 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -1061,7 +1046,6 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* ptr = (int*)buffer;
@@ -1119,7 +1103,6 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* header = (int*)buffer;
@@ -1227,7 +1210,6 @@ int test_routine_keywords(Toy_Bucket** bucketHandle) {
//run
void* buffer = Toy_compileRoutine(ast);
int len = ((int*)buffer)[0];
//check header
int* header = (int*)buffer;

View File

@@ -400,7 +400,6 @@ int test_string_equality() {
Toy_Bucket* bucket = Toy_allocateBucket(1024);
Toy_String* helloWorldOne = Toy_createString(&bucket, "Hello world");
Toy_String* helloWorldTwo = Toy_concatStrings(&bucket, Toy_createString(&bucket, "Hello "), Toy_createString(&bucket, "world"));
Toy_String* helloEveryone = Toy_createString(&bucket, "Hello everyone");
int result = 0; //for print the errors

View File

@@ -1,12 +1,2 @@
set breakpoint pending on
break main if argc > 1
command 1
set $i=0
while($i < argc)
p argv[$i++]
end
continue
end

View File

@@ -1,6 +1,6 @@
#compiler settings
CC=gcc
CFLAGS+=-std=c17 -g -Wall -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wformat=2
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
LIBS+=-lm
LDFLAGS+=

View File

@@ -1,6 +1,6 @@
#compiler settings
CC=gcc
CFLAGS+=-std=c17 -g -Wall -Werror -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wformat=2
CFLAGS+=-std=c17 -g -Wall -Werror -Wextra -Wformat=2
LIBS+=-lm
LDFLAGS+=

View File

@@ -40,7 +40,7 @@ unsigned char* readFile(char* path, int* size) {
}
//read the file
if (fread(buffer, sizeof(unsigned char), *size, file) < *size) {
if (fread(buffer, sizeof(unsigned char), *size, file) < (unsigned int)(*size)) {
fclose(file);
*size = -2; //singal a read error
return NULL;