compiler/libec: Fixed keeping cast between long/int types
authorJerome St-Louis <jerome@ecere.com>
Sun, 6 Jul 2014 09:05:48 +0000 (05:05 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sun, 6 Jul 2014 09:19:51 +0000 (05:19 -0400)
24 files changed:
compiler/bootstrap/ecere/bootstrap/File.c
compiler/bootstrap/ecere/bootstrap/String.c
compiler/bootstrap/ecere/bootstrap/instance.c
compiler/bootstrap/ecp/bootstrap/ecp.c
compiler/bootstrap/ecs/bootstrap/ecs.c
compiler/bootstrap/libec/bootstrap/ast.c
compiler/bootstrap/libec/bootstrap/copy.c
compiler/bootstrap/libec/bootstrap/dbpass.c
compiler/bootstrap/libec/bootstrap/ecdefs.c
compiler/bootstrap/libec/bootstrap/expression.c
compiler/bootstrap/libec/bootstrap/firstPass.c
compiler/bootstrap/libec/bootstrap/freeAst.c
compiler/bootstrap/libec/bootstrap/grammar.c
compiler/bootstrap/libec/bootstrap/output.c
compiler/bootstrap/libec/bootstrap/pass0.c
compiler/bootstrap/libec/bootstrap/pass1.c
compiler/bootstrap/libec/bootstrap/pass15.c
compiler/bootstrap/libec/bootstrap/pass16.c
compiler/bootstrap/libec/bootstrap/pass2.c
compiler/bootstrap/libec/bootstrap/pass3.c
compiler/bootstrap/libec/bootstrap/type.c
compiler/libec/src/ast.ec
compiler/libec/src/ecdefs.ec
compiler/libec/src/pass15.ec

index 8bc0ff1..32cd2d0 100644 (file)
@@ -1294,7 +1294,7 @@ __attribute__((unused)) struct __ecereNameSpace__ecere__sys__File * __ecerePoint
 char string[32];
 
 __ecereMethod___ecereNameSpace__ecere__sys__File_GetString(this, string, sizeof (string));
-return strtoul(string, (((void *)0)), 16);
+return (unsigned int)strtoul(string, (((void *)0)), 16);
 }
 
 float __ecereMethod___ecereNameSpace__ecere__sys__File_GetFloat(struct __ecereNameSpace__ecere__com__Instance * this)
index b7e2525..9553bb1 100644 (file)
@@ -707,7 +707,7 @@ unsigned int __ecereNameSpace__ecere__sys__GetHexValue(char ** buffer)
 char string[20];
 
 __ecereNameSpace__ecere__sys__GetString(buffer, string, 20);
-return strtoul(string, (((void *)0)), 16);
+return (unsigned int)strtoul(string, (((void *)0)), 16);
 }
 
 double __ecereNameSpace__ecere__sys__FloatFromString(const char * string)
index d795aa4..a83062c 100644 (file)
@@ -4245,7 +4245,7 @@ argument.__anon1.expression.__anon1.ui = ch;
 }
 else if(!strcmp(curParam->__anon1.dataTypeString, "uint"))
 {
-argument.__anon1.expression.__anon1.ui = strtoul(value, (((void *)0)), 0);
+argument.__anon1.expression.__anon1.ui = (unsigned int)strtoul(value, (((void *)0)), 0);
 }
 else if(!strcmp(curParam->__anon1.dataTypeString, "char"))
 {
@@ -4281,7 +4281,7 @@ argument.__anon1.expression.__anon1.d = strtod(value, (((void *)0)));
 }
 else
 {
-argument.__anon1.expression.__anon1.i = strtol(value, (((void *)0)), 0);
+argument.__anon1.expression.__anon1.i = (int)strtol(value, (((void *)0)), 0);
 }
 break;
 }
index 525f7b7..d5d7695 100644 (file)
@@ -1253,6 +1253,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct __ecereNameSpace__ecere__com__ClassTemplateParameter;
index e988cb2..87d0b52 100644 (file)
@@ -670,6 +670,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 extern void DeclareMethod(struct External * neededFor, struct __ecereNameSpace__ecere__com__Method * method, const char *  name);
index b785aca..026a03d 100644 (file)
@@ -876,6 +876,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct TemplatedType *  FindTemplateTypeParameter(struct Context *  ctx, const char *  name);
@@ -4542,6 +4543,7 @@ if(isLong || (targetBits == 64 && targetPlatform != 1))
 specType->kind = 4;
 else
 specType->kind = 3;
+specType->isLong = 1;
 isLong = 1;
 }
 else if(spec->__anon1.specifier == FLOAT)
@@ -4969,7 +4971,7 @@ if(exp)
 ProcessExpressionType(exp);
 ComputeExpression(exp);
 if(exp->type == 2)
-type->bitFieldCount = strtoul(exp->__anon1.__anon1.constant, (((void *)0)), 0);
+type->bitFieldCount = (unsigned int)strtoul(exp->__anon1.__anon1.constant, (((void *)0)), 0);
 }
 break;
 }
index 69f06c1..c8daa04 100644 (file)
@@ -695,6 +695,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct Instantiation;
index 5662dda..8a0f8ba 100644 (file)
@@ -770,6 +770,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct TypeName;
index 4a6a978..623fa8e 100644 (file)
@@ -1122,6 +1122,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct Symbol
@@ -3456,6 +3457,7 @@ __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "declaredWithStruct",
 __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "typedByReference", "bool:1", 4, 4, 1);
 __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "casted", "bool:1", 4, 4, 1);
 __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "pointerAlignment", "bool:1", 4, 4, 1);
+__ecereNameSpace__ecere__com__eClass_AddDataMember(class, "isLong", "bool:1", 4, 4, 1);
 __ecerePropM_Type_specConst = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "specConst", "bool", 0, __ecereProp_Type_Get_specConst, 1);
 if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application)
 __ecereProp_Type_specConst = __ecerePropM_Type_specConst, __ecerePropM_Type_specConst = (void *)0;
index ffe4559..53bd84e 100644 (file)
@@ -1288,7 +1288,7 @@ yylsp = yyls + yysize - 1;
 do
 {
 if(expression_yydebug)
-fprintf((bsl_stderr()), "Stack size increased to %lu\n", yystacksize);
+fprintf((bsl_stderr()), "Stack size increased to %lu\n", (unsigned long int)yystacksize);
 }while((0));
 if(yyss + yystacksize - 1 <= yyssp)
 goto yyabortlab;
index 32b302f..d1ea6c6 100644 (file)
@@ -1017,6 +1017,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct PropertyDef;
index 8352ab1..c92b1c0 100644 (file)
@@ -1212,6 +1212,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct Specifier
index 3b5e53a..12096b8 100644 (file)
@@ -3035,7 +3035,7 @@ yylsp = yyls + yysize - 1;
 do
 {
 if(yydebug)
-fprintf((bsl_stderr()), "Stack size increased to %lu\n", yystacksize);
+fprintf((bsl_stderr()), "Stack size increased to %lu\n", (unsigned long int)yystacksize);
 }while((0));
 if(yyss + yystacksize - 1 <= yyssp)
 goto yyabortlab;
index e7e5bbc..48e9cea 100644 (file)
@@ -684,6 +684,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct Declaration;
index 5a28662..9779e55 100644 (file)
@@ -706,6 +706,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__com__eClass_AddMethod(struct __ecereNameSpace__ecere__com__Class * _class, const char *  name, const char *  type, void *  function, int declMode);
index 9ce5d85..814947b 100644 (file)
@@ -1155,6 +1155,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 unsigned int __ecereProp_Type_Get_isPointerTypeSize(struct Type * this);
index b6912e3..2d3edd0 100644 (file)
@@ -1833,6 +1833,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct Specifier
@@ -1904,7 +1905,7 @@ if(type1->kind == 20 && type2->kind == 4 && type2->passAsTemplate == 0)
 {
 return 0;
 }
-if(type1->kind == type2->kind)
+if(type1->kind == type2->kind && type1->isLong == type2->isLong)
 {
 switch(type1->kind)
 {
@@ -7615,7 +7616,7 @@ op.ops = intOps;
 }
 else
 {
-op.__anon1.ui = strtoul(exp->__anon1.__anon1.constant, (((void *)0)), 0);
+op.__anon1.ui = (unsigned int)strtoul(exp->__anon1.__anon1.constant, (((void *)0)), 0);
 op.ops = uintOps;
 }
 op.kind = 3;
index 7877f2f..2ea8ea5 100644 (file)
@@ -682,6 +682,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 extern void ProcessMethodType(struct __ecereNameSpace__ecere__com__Method * method);
index 16366cf..3e7eb03 100644 (file)
@@ -1020,6 +1020,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 struct Specifier
index 68f8f10..524f539 100644 (file)
@@ -705,6 +705,7 @@ unsigned int declaredWithStruct : 1;
 unsigned int typedByReference : 1;
 unsigned int casted : 1;
 unsigned int pointerAlignment : 1;
+unsigned int isLong : 1;
 } __attribute__ ((gcc_struct));
 
 unsigned int IsVoidPtrCast(struct TypeName * typeName)
index 79a5c0b..1accd71 100644 (file)
@@ -2174,7 +2174,7 @@ yylsp = yyls + yysize - 1;
 do
 {
 if(type_yydebug)
-fprintf((bsl_stderr()), "Stack size increased to %lu\n", yystacksize);
+fprintf((bsl_stderr()), "Stack size increased to %lu\n", (unsigned long int)yystacksize);
 }while((0));
 if(yyss + yystacksize - 1 <= yyssp)
 goto yyabortlab;
index 63af574..5ce9fb3 100644 (file)
@@ -2365,6 +2365,7 @@ static Type ProcessTypeSpecs(OldList specs, bool assumeEllipsis, bool keepTypeNa
                   specType.kind = int64Type;
                else
                   specType.kind = intType;
+               specType.isLong = true;
                isLong = true;
             }
             else if(spec.specifier == FLOAT) specType.kind = floatType;
index 16b7267..dfc33d6 100644 (file)
@@ -1431,6 +1431,7 @@ public:
    bool typedByReference:1;      // Originally typed by reference, regardless of class type
    bool casted:1;
    bool pointerAlignment:1; // true if the alignment is the pointer size
+   bool isLong:1;    // true if this is truly a long set as a int/int64 (need to improve long support)
    // bool wasThisClass:1;
    // TODO: Add _Complex & _Imaginary support
    // bool complex:1, imaginary:1;
index 09b9596..b02a41e 100644 (file)
@@ -84,7 +84,7 @@ bool NeedCast(Type type1, Type type2)
       return false;
    }
 
-   if(type1.kind == type2.kind)
+   if(type1.kind == type2.kind && type1.isLong == type2.isLong)
    {
       switch(type1.kind)
       {