From e498bf5a01d78781269323269fcc87ef6a3ea4cc Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Thu, 12 Jun 2014 15:40:40 -0400 Subject: [PATCH] compiler/libec: Warning on pointers to class incompatible with pointer to pointer - Updated bootstrap --- compiler/bootstrap/ecc/bootstrap/ecc.c | 2 +- compiler/bootstrap/ecere/bootstrap/dataTypes.c | 2 +- compiler/bootstrap/ecp/bootstrap/ecp.c | 2 +- compiler/bootstrap/ecs/bootstrap/ecs.c | 2 +- compiler/bootstrap/libec/bootstrap/pass15.c | 5 ++++- compiler/libec/src/pass15.ec | 13 +++++++++---- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/compiler/bootstrap/ecc/bootstrap/ecc.c b/compiler/bootstrap/ecc/bootstrap/ecc.c index c0db99d..abb4da4 100644 --- a/compiler/bootstrap/ecc/bootstrap/ecc.c +++ b/compiler/bootstrap/ecc/bootstrap/ecc.c @@ -1065,7 +1065,7 @@ SetOutputFile(defaultOutputFile); } if(!valid) { -printf(__ecereNameSpace__ecere__GetTranslatedString("ecc", "Syntax:\n ecc [-t ] [-cpp ] [-o ] [-module ] [-symbols ] [-I]* [-isystem ]* [-D]* -c \n", (((void *)0)))); +printf("%s", __ecereNameSpace__ecere__GetTranslatedString("ecc", "Syntax:\n ecc [-t ] [-cpp ] [-o ] [-module ] [-symbols ] [-I]* [-isystem ]* [-D]* -c \n", (((void *)0)))); } else { diff --git a/compiler/bootstrap/ecere/bootstrap/dataTypes.c b/compiler/bootstrap/ecere/bootstrap/dataTypes.c index 369c3d8..aca8e76 100644 --- a/compiler/bootstrap/ecere/bootstrap/dataTypes.c +++ b/compiler/bootstrap/ecere/bootstrap/dataTypes.c @@ -593,7 +593,7 @@ const char * __ecereNameSpace__ecere__com__Enum_OnGetString(struct __ecereNameSp { struct __ecereNameSpace__ecere__sys__NamedLink64 * item = (((void *)0)); struct __ecereNameSpace__ecere__com__Class * b; -long long i64Data; +long long i64Data = 0; switch(_class->typeSize) { diff --git a/compiler/bootstrap/ecp/bootstrap/ecp.c b/compiler/bootstrap/ecp/bootstrap/ecp.c index 1ca01a0..2772f94 100644 --- a/compiler/bootstrap/ecp/bootstrap/ecp.c +++ b/compiler/bootstrap/ecp/bootstrap/ecp.c @@ -2838,7 +2838,7 @@ SetOutputFile(defaultSymFile); } if(!valid) { -printf(__ecereNameSpace__ecere__GetTranslatedString("ecp", "Syntax:\n ecp [-t ] [-cpp ] [-o ] [-symbols ] [-I]* [-isystem ]* [-D]* -c \n", (((void *)0)))); +printf("%s", __ecereNameSpace__ecere__GetTranslatedString("ecp", "Syntax:\n ecp [-t ] [-cpp ] [-o ] [-symbols ] [-I]* [-isystem ]* [-D]* -c \n", (((void *)0)))); } else { diff --git a/compiler/bootstrap/ecs/bootstrap/ecs.c b/compiler/bootstrap/ecs/bootstrap/ecs.c index bdba30f..0f3b713 100644 --- a/compiler/bootstrap/ecs/bootstrap/ecs.c +++ b/compiler/bootstrap/ecs/bootstrap/ecs.c @@ -2657,7 +2657,7 @@ if(!output) valid = 0; if(!valid) { -printf(__ecereNameSpace__ecere__GetTranslatedString("ecs", "Syntax:\n ecs [-t ] [, ]* -o \n", (((void *)0)))); +printf("%s", __ecereNameSpace__ecere__GetTranslatedString("ecs", "Syntax:\n ecs [-t ] [, ]* -o \n", (((void *)0)))); } else { diff --git a/compiler/bootstrap/libec/bootstrap/pass15.c b/compiler/bootstrap/libec/bootstrap/pass15.c index 3b1281b..3d7ba7a 100644 --- a/compiler/bootstrap/libec/bootstrap/pass15.c +++ b/compiler/bootstrap/libec/bootstrap/pass15.c @@ -5373,12 +5373,15 @@ return 1; } else if((dest->kind == 13 || dest->kind == 12) && (source->kind == 12 || source->kind == 13)) { +if(!(dest->__anon1.type && dest->__anon1.type->kind == 13 && source->__anon1.type->kind == 8 && source->__anon1.type->__anon1._class && source->__anon1.type->__anon1._class->__anon1.registered && (source->__anon1.type->__anon1._class->__anon1.registered->type != 0 && source->__anon1.type->__anon1._class->__anon1.registered->type != 5) && !source->__anon1.type->byReference)) +{ ComputeTypeSize(source->__anon1.type); ComputeTypeSize(dest->__anon1.type); if(source->__anon1.type->size == dest->__anon1.type->size && MatchTypes(source->__anon1.type, dest->__anon1.type, (((void *)0)), (((void *)0)), (((void *)0)), 1, 1, 0, 0, warnConst)) return 1; } } +} return 0; } @@ -5450,7 +5453,7 @@ type->kind = 8; if(!_class->symbol) _class->symbol = FindClass(_class->fullName); type->__anon1._class = _class->symbol; -if(MatchTypes(type, dest, &converts, (((void *)0)), (((void *)0)), 1, 0, 0, 0, 0)) +if(MatchTypes(type, dest, &converts, (((void *)0)), (((void *)0)), dest->kind != 8 || !dest->__anon1._class || strcmp(dest->__anon1._class->string, "bool"), 0, 0, 0, 0)) { struct __ecereNameSpace__ecere__sys__NamedLink64 * value; struct __ecereNameSpace__ecere__com__Class * enumClass = __ecereNameSpace__ecere__com__eSystem_FindClass(privateModule, "enum"); diff --git a/compiler/libec/src/pass15.ec b/compiler/libec/src/pass15.ec index 6e5f43f..abfe0ed 100644 --- a/compiler/libec/src/pass15.ec +++ b/compiler/libec/src/pass15.ec @@ -3553,10 +3553,15 @@ public bool MatchTypes(Type source, Type dest, OldList conversions, Class owning else if((dest.kind == pointerType || dest.kind == arrayType) && (source.kind == arrayType || source.kind == pointerType)) { - ComputeTypeSize(source.type); - ComputeTypeSize(dest.type); - if(source.type.size == dest.type.size && MatchTypes(source.type, dest.type, null, null, null, true, true, false, false, warnConst)) - return true; + // Pointers to pointer is incompatible with non normal/nohead classes + if(!(dest.type && dest.type.kind == pointerType && source.type.kind == classType && source.type._class && + source.type._class.registered && (source.type._class.registered.type != normalClass && source.type._class.registered.type != noHeadClass) && !source.type.byReference)) + { + ComputeTypeSize(source.type); + ComputeTypeSize(dest.type); + if(source.type.size == dest.type.size && MatchTypes(source.type, dest.type, null, null, null, true, true, false, false, warnConst)) + return true; + } } } return false; -- 1.8.3.1