Skip to content

Commit

Permalink
Tweaked CFLAGS, and fixed related errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratstail91 committed Dec 12, 2024
1 parent 5f4dfdc commit fce71a6
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 56 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
@@ -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+=

Expand Down
2 changes: 1 addition & 1 deletion repl/makefile
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion source/makefile
Original file line number Diff line number Diff line change
@@ -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+=

Expand Down
2 changes: 2 additions & 0 deletions source/toy_routine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion source/toy_scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion source/toy_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion source/toy_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/toy_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions source/toy_vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/benchmarks/makefile
Original file line number Diff line number Diff line change
@@ -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+=

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/makefile
Original file line number Diff line number Diff line change
@@ -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+=

Expand Down
20 changes: 10 additions & 10 deletions tests/cases/test_bucket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/test_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

int counter = 0;

void count(const char* msg) {
void count(const char*) {
counter++;
}

Expand Down
18 changes: 0 additions & 18 deletions tests/cases/test_routine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion tests/cases/test_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 0 additions & 10 deletions tests/integrations/gdb_init
Original file line number Diff line number Diff line change
@@ -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

2 changes: 1 addition & 1 deletion tests/integrations/makefile
Original file line number Diff line number Diff line change
@@ -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+=

Expand Down
2 changes: 1 addition & 1 deletion tests/standalone/makefile
Original file line number Diff line number Diff line change
@@ -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+=

Expand Down
4 changes: 2 additions & 2 deletions tests/standalone/platform_behaviours.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -144,4 +144,4 @@ int main() {
}

return 0;
}
}

0 comments on commit fce71a6

Please sign in to comment.