diff options
Diffstat (limited to 'gcc/m2/gm2-compiler/M2Quads.mod')
-rw-r--r-- | gcc/m2/gm2-compiler/M2Quads.mod | 107 |
1 files changed, 85 insertions, 22 deletions
diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod index a45d67a..9bb8c4d 100644 --- a/gcc/m2/gm2-compiler/M2Quads.mod +++ b/gcc/m2/gm2-compiler/M2Quads.mod @@ -8474,7 +8474,7 @@ BEGIN THEN (* we cannot test for IsConst(Param) AND (GetSType(Param)=Char) as the type might not be assigned yet *) MetaError1 ('base procedure {%EkHIGH} expects a variable or string constant as its parameter {%1d:rather than {%1d}} {%1asa}', Param) - ELSIF IsUnbounded(Type) + ELSIF (Type # NulSym) AND IsUnbounded(Type) THEN BuildHighFromUnbounded (combinedtok) ELSE @@ -9776,11 +9776,30 @@ END CheckBaseTypeValue ; (* - GetTypeMin - returns the minimium value of type. + GetTypeMin - returns the minimium value of type and generate an error + if this is unavailable. *) PROCEDURE GetTypeMin (tok: CARDINAL; func, type: CARDINAL) : CARDINAL ; VAR + min: CARDINAL ; +BEGIN + min := GetTypeMinLower (tok, func, type) ; + IF min = NulSym + THEN + MetaErrorT1 (tok, + 'unable to obtain the {%AkMIN} value for type {%1ad}', type) + END ; + RETURN min +END GetTypeMin ; + + +(* + GetTypeMinLower - obtain the maximum value for type. +*) + +PROCEDURE GetTypeMinLower (tok: CARDINAL; func, type: CARDINAL) : CARDINAL ; +VAR min, max: CARDINAL ; BEGIN IF IsSubrange (type) @@ -9803,22 +9822,38 @@ BEGIN RETURN min ELSIF GetSType (type) = NulSym THEN - MetaErrorT1 (tok, - 'unable to obtain the {%AkMIN} value for type {%1ad}', type) ; - (* non recoverable error. *) - InternalError ('MetaErrorT1 {%AkMIN} should call abort') + RETURN NulSym ELSE RETURN GetTypeMin (tok, func, GetSType (type)) END -END GetTypeMin ; +END GetTypeMinLower ; (* - GetTypeMax - returns the maximum value of type. + GetTypeMax - returns the maximum value of type and generate an error + if this is unavailable. *) PROCEDURE GetTypeMax (tok: CARDINAL; func, type: CARDINAL) : CARDINAL ; VAR + max: CARDINAL ; +BEGIN + max := GetTypeMaxLower (tok, func, type) ; + IF max = NulSym + THEN + MetaErrorT1 (tok, + 'unable to obtain the {%AkMAX} value for type {%1ad}', type) + END ; + RETURN max +END GetTypeMax ; + + +(* + GetTypeMaxLower - obtain the maximum value for type. +*) + +PROCEDURE GetTypeMaxLower (tok: CARDINAL; func, type: CARDINAL) : CARDINAL ; +VAR min, max: CARDINAL ; BEGIN IF IsSubrange (type) @@ -9841,14 +9876,11 @@ BEGIN RETURN max ELSIF GetSType (type) = NulSym THEN - MetaErrorT1 (tok, - 'unable to obtain the {%AkMAX} value for type {%1ad}', type) ; - (* non recoverable error. *) - InternalError ('MetaErrorT1 {%AkMAX} should call abort') + RETURN NulSym ELSE RETURN GetTypeMax (tok, func, GetSType (type)) END -END GetTypeMax ; +END GetTypeMaxLower ; (* @@ -11449,13 +11481,12 @@ END BuildDesignatorPointerError ; (* BuildDesignatorArray - Builds the array referencing. The purpose of this procedure is to work out - whether the DesignatorArray is a static or - dynamic array and to call the appropriate + whether the DesignatorArray is a constant string or + dynamic array/static array and to call the appropriate BuildRoutine. The Stack is expected to contain: - Entry Exit ===== ==== @@ -11468,6 +11499,41 @@ END BuildDesignatorPointerError ; *) PROCEDURE BuildDesignatorArray ; +BEGIN + IF IsConst (OperandT (2)) AND IsConstString (OperandT (2)) + THEN + MetaErrorT1 (OperandTtok (2), + '{%1Ead} is not an array, but a constant string. Hint use a string constant created with an array constructor', + OperandT (2)) ; + BuildDesignatorError ('bad array access') + ELSE + BuildDesignatorArrayStaticDynamic + END +END BuildDesignatorArray ; + + +(* + BuildDesignatorArrayStaticDynamic - Builds the array referencing. + The purpose of this procedure is to work out + whether the DesignatorArray is a static or + dynamic array and to call the appropriate + BuildRoutine. + + The Stack is expected to contain: + + + Entry Exit + ===== ==== + + Ptr -> + +--------------+ + | e | <- Ptr + |--------------| +------------+ + | Sym | Type | | S | T | + |--------------| |------------| +*) + +PROCEDURE BuildDesignatorArrayStaticDynamic ; VAR combinedTok, arrayTok, @@ -11480,10 +11546,7 @@ BEGIN IF IsConst (OperandT (2)) THEN type := GetDType (OperandT (2)) ; - IF type = NulSym - THEN - InternalError ('constant type should have been resolved') - ELSIF IsArray (type) + IF (type # NulSym) AND IsArray (type) THEN PopTtok (e, exprTok) ; PopTFDtok (Sym, Type, dim, arrayTok) ; @@ -11501,7 +11564,7 @@ BEGIN IF (NOT IsVar (OperandT (2))) AND (NOT IsTemporary (OperandT (2))) THEN MetaErrorT1 (OperandTtok (2), - 'can only access arrays using variables or formal parameters not {%1Ead}', + 'can only access arrays using constants, variables or formal parameters not {%1Ead}', OperandT (2)) ; BuildDesignatorError ('bad array access') END ; @@ -11528,7 +11591,7 @@ BEGIN Sym) ; BuildDesignatorError ('bad array access') END -END BuildDesignatorArray ; +END BuildDesignatorArrayStaticDynamic ; (* |