diff --git a/makefile b/makefile index d4869fb..8e2680c 100644 --- a/makefile +++ b/makefile @@ -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+= diff --git a/repl/makefile b/repl/makefile index b1a451d..7084b0f 100644 --- a/repl/makefile +++ b/repl/makefile @@ -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' diff --git a/source/makefile b/source/makefile index 60d163b..8a06c4d 100644 --- a/source/makefile +++ b/source/makefile @@ -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+= diff --git a/source/toy_routine.c b/source/toy_routine.c index 814a5bb..7d06933 100644 --- a/source/toy_routine.c +++ b/source/toy_routine.c @@ -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; diff --git a/source/toy_scope.c b/source/toy_scope.c index 058b3fb..5612560 100644 --- a/source/toy_scope.c +++ b/source/toy_scope.c @@ -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)); } diff --git a/source/toy_string.c b/source/toy_string.c index 9db205d..733d296 100644 --- a/source/toy_string.c +++ b/source/toy_string.c @@ -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; } diff --git a/source/toy_string.h b/source/toy_string.h index c113fcc..c657ede 100644 --- a/source/toy_string.h +++ b/source/toy_string.h @@ -30,7 +30,7 @@ typedef struct Toy_String { //32 | 64 BITNESS struct { Toy_ValueType type; //4 | 4 - bool constant; //1 | 1 + bool constant; //1 | 1 char data[]; //- | - } name; //8 | 8 } as; //8 | 16 diff --git a/source/toy_table.c b/source/toy_table.c index 33b7991..fcf2f89 100644 --- a/source/toy_table.c +++ b/source/toy_table.c @@ -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); } diff --git a/source/toy_vm.c b/source/toy_vm.c index 73950c8..978c28d 100644 --- a/source/toy_vm.c +++ b/source/toy_vm.c @@ -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); diff --git a/tests/benchmarks/makefile b/tests/benchmarks/makefile index 0b20cd7..0e3706a 100644 --- a/tests/benchmarks/makefile +++ b/tests/benchmarks/makefile @@ -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+= diff --git a/tests/cases/makefile b/tests/cases/makefile index 22c8cf6..220466a 100644 --- a/tests/cases/makefile +++ b/tests/cases/makefile @@ -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+= diff --git a/tests/cases/test_bucket.c b/tests/cases/test_bucket.c index ae5be38..abc9179 100644 --- a/tests/cases/test_bucket.c +++ b/tests/cases/test_bucket.c @@ -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 ( diff --git a/tests/cases/test_print.c b/tests/cases/test_print.c index f1e74ca..d7d0e22 100644 --- a/tests/cases/test_print.c +++ b/tests/cases/test_print.c @@ -5,7 +5,7 @@ int counter = 0; -void count(const char* msg) { +void count(const char*) { counter++; } diff --git a/tests/cases/test_routine.c b/tests/cases/test_routine.c index 9437002..7c848f2 100644 --- a/tests/cases/test_routine.c +++ b/tests/cases/test_routine.c @@ -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; diff --git a/tests/cases/test_string.c b/tests/cases/test_string.c index 6764ea3..265bad5 100644 --- a/tests/cases/test_string.c +++ b/tests/cases/test_string.c @@ -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 diff --git a/tests/integrations/gdb_init b/tests/integrations/gdb_init index 6b811a4..6c33498 100644 --- a/tests/integrations/gdb_init +++ b/tests/integrations/gdb_init @@ -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 - diff --git a/tests/integrations/makefile b/tests/integrations/makefile index af71489..7d6cbb5 100644 --- a/tests/integrations/makefile +++ b/tests/integrations/makefile @@ -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+= diff --git a/tests/standalone/makefile b/tests/standalone/makefile index f7d9d38..ed09b83 100644 --- a/tests/standalone/makefile +++ b/tests/standalone/makefile @@ -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+= diff --git a/tests/standalone/platform_behaviours.c b/tests/standalone/platform_behaviours.c index 506e211..8b501c2 100644 --- a/tests/standalone/platform_behaviours.c +++ b/tests/standalone/platform_behaviours.c @@ -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; @@ -144,4 +144,4 @@ int main() { } return 0; -} \ No newline at end of file +}