From: Gaius Mulley Date: Mon, 3 Apr 2023 14:04:06 +0000 (+0100) Subject: PR modula2/109388 clang warnings related to Modula-2 X-Git-Tag: basepoints/gcc-14~220 X-Git-Url: https://gcc.gnu.org/git/?a=commitdiff_plain;h=9a75f0a02e5006e081b335acd36300a85bef8eb8;p=gcc.git PR modula2/109388 clang warnings related to Modula-2 This patch removes an unused parameter 'module' from DoVariableDeclaration in M2GCCDeclare.mod. It also removes unused procedures from PHBuild.bnf. gcc/m2/ChangeLog: PR modula2/109388 * gm2-compiler/M2GCCDeclare.mod (DoVariableDeclaration): Remove second parameter module. Adjust all callers to remove the second parameter. * gm2-compiler/PHBuild.bnf (CheckAndInsert): Remove. (InStopSet): Remove. (PeepToken): Remove. (PushQualident): Remove. (SimpleDes): Remove. (ActualParameters): Remove. Signed-off-by: Gaius Mulley --- diff --git a/gcc/m2/gm2-compiler/M2GCCDeclare.mod b/gcc/m2/gm2-compiler/M2GCCDeclare.mod index 3b1fc18dabe4..8dceaae4c60c 100644 --- a/gcc/m2/gm2-compiler/M2GCCDeclare.mod +++ b/gcc/m2/gm2-compiler/M2GCCDeclare.mod @@ -3153,10 +3153,11 @@ END FindOuterModule ; (* - DoVariableDeclaration - + DoVariableDeclaration - create a corresponding gcc variable and add the association + between the front end symbol var and the gcc tree. *) -PROCEDURE DoVariableDeclaration (var, module: CARDINAL; name: ADDRESS; +PROCEDURE DoVariableDeclaration (var: CARDINAL; name: ADDRESS; isImported, isExported, isTemporary, isGlobal: BOOLEAN; scope: Tree) ; @@ -3174,7 +3175,7 @@ BEGIN (* There are two issues to deal with: - (i) LeftValue is really a pointer to GetSType(Son), which is built + (i) LeftValue is really a pointer to GetSType (var), which is built here. (ii) Front end might have specified the back end use a particular data type, in which case we use the specified type. @@ -3183,7 +3184,7 @@ BEGIN varType := SkipType (GetVarBackEndType (var)) ; IF varType=NulSym THEN - (* we have not explicity told back end the type, so build it *) + (* We have not explicity told back end the type, so build it. *) varType := GetSType (var) ; IF IsVariableAtAddress (var) THEN @@ -3192,6 +3193,7 @@ BEGIN type := BuildPointerType (Mod2Gcc (varType)) END ELSE + (* We have been requested to use varType. *) type := Mod2Gcc (varType) END ; Assert (AllDependantsFullyDeclared (varType)) @@ -3199,7 +3201,6 @@ BEGIN type := Mod2Gcc (GetDType (var)) END ; location := TokenToLocation (GetDeclaredMod (var)) ; - (* The M2LINK module global variables are a special case and have initializers. *) PreAddModGcc (var, DeclareKnownVariable (location, name, type, isExported, isImported, isTemporary, @@ -3244,7 +3245,7 @@ BEGIN decl := FindOuterModule (variable) ; Assert (AllDependantsFullyDeclared (GetSType (variable))) ; PushBinding (ModSym) ; - DoVariableDeclaration (variable, decl, + DoVariableDeclaration (variable, KeyToCharStar (GetFullSymName (variable)), (* in Modula-2 we are allowed to import from ourselves, but we do not present this to GCC *) IsEffectivelyImported(ModSym, variable) AND (GetMainModule () # decl), @@ -3272,7 +3273,7 @@ BEGIN decl := FindOuterModule (variable) ; Assert (AllDependantsFullyDeclared (GetSType (variable))) ; PushBinding (mainModule) ; - DoVariableDeclaration (variable, decl, + DoVariableDeclaration (variable, KeyToCharStar (GetFullSymName (variable)), (NOT IsSourceSeen (decl)) AND IsEffectivelyImported (mainModule, variable) AND (GetMainModule () # decl), @@ -3368,7 +3369,7 @@ END DeclareImportedVariablesWholeProgram ; PROCEDURE DeclareLocalVariable (var: CARDINAL) ; BEGIN Assert (AllDependantsFullyDeclared (var)) ; - DoVariableDeclaration (var, NulSym, + DoVariableDeclaration (var, KeyToCharStar (GetFullSymName (var)), FALSE, (* local variables cannot be imported *) FALSE, (* or exported *) @@ -3412,7 +3413,7 @@ BEGIN Var := GetNth (sym, i) ; WHILE Var # NulSym DO Assert (AllDependantsFullyDeclared (GetSType (Var))) ; - DoVariableDeclaration (Var, NulSym, + DoVariableDeclaration (Var, KeyToCharStar (GetFullSymName (Var)), FALSE, (* inner module variables cannot be imported *) FALSE, (* or exported (as far as GCC is concerned) *) diff --git a/gcc/m2/gm2-compiler/PHBuild.bnf b/gcc/m2/gm2-compiler/PHBuild.bnf index a13da828c946..79ebcde97329 100644 --- a/gcc/m2/gm2-compiler/PHBuild.bnf +++ b/gcc/m2/gm2-compiler/PHBuild.bnf @@ -187,11 +187,6 @@ BEGIN END ErrorArray ; -PROCEDURE ErrorArrayAt (a: ARRAY OF CHAR; tok: CARDINAL) ; -BEGIN - ErrorStringAt (InitString(a), tok) -END ErrorArrayAt ; - % declaration PHBuild begin @@ -285,76 +280,6 @@ BEGIN END MissingToken ; -(* - CheckAndInsert - -*) - -PROCEDURE CheckAndInsert (t: toktype; stopset0: SetOfStop0; stopset1: SetOfStop1; stopset2: SetOfStop2) : BOOLEAN ; -BEGIN - IF ((ORD(t)<32) AND (t IN stopset0)) OR - ((ORD(t)>=32) AND (ORD(t)<64) AND (t IN stopset1)) OR - ((ORD(t)>=64) AND (t IN stopset2)) - THEN - WarnMissingToken(t) ; - InsertTokenAndRewind(t) ; - RETURN( TRUE ) - ELSE - RETURN( FALSE ) - END -END CheckAndInsert ; - - -(* - InStopSet -*) - -PROCEDURE InStopSet (t: toktype; stopset0: SetOfStop0; stopset1: SetOfStop1; stopset2: SetOfStop2) : BOOLEAN ; -BEGIN - IF ((ORD(t)<32) AND (t IN stopset0)) OR - ((ORD(t)>=32) AND (ORD(t)<64) AND (t IN stopset1)) OR - ((ORD(t)>=64) AND (t IN stopset2)) - THEN - RETURN( TRUE ) - ELSE - RETURN( FALSE ) - END -END InStopSet ; - - -(* - PeepToken - peep token checks to see whether the stopset is satisfied by currenttoken - If it is not then it will insert a token providing the token - is one of ; ] ) } . OF END , - - if the stopset contains then we do not insert a token -*) - -PROCEDURE PeepToken (stopset0: SetOfStop0; stopset1: SetOfStop1; stopset2: SetOfStop2) ; -BEGIN - (* and again (see above re: ORD) - *) - IF (NOT (((ORD(currenttoken)<32) AND (currenttoken IN stopset0)) OR - ((ORD(currenttoken)>=32) AND (ORD(currenttoken)<64) AND (currenttoken IN stopset1)) OR - ((ORD(currenttoken)>=64) AND (currenttoken IN stopset2)))) AND - (NOT InStopSet(identtok, stopset0, stopset1, stopset2)) - THEN - (* SyntaxCheck would fail since currentoken is not part of the stopset - we check to see whether any of currenttoken might be a commonly - omitted token. *) - IF CheckAndInsert(semicolontok, stopset0, stopset1, stopset2) OR - CheckAndInsert(rsbratok, stopset0, stopset1, stopset2) OR - CheckAndInsert(rparatok, stopset0, stopset1, stopset2) OR - CheckAndInsert(rcbratok, stopset0, stopset1, stopset2) OR - CheckAndInsert(periodtok, stopset0, stopset1, stopset2) OR - CheckAndInsert(oftok, stopset0, stopset1, stopset2) OR - CheckAndInsert(endtok, stopset0, stopset1, stopset2) OR - CheckAndInsert(commatok, stopset0, stopset1, stopset2) - THEN - END - END -END PeepToken ; - - (* Expect - *) @@ -639,71 +564,6 @@ Qualident := % VAR { "." Ident } % END % =: -PushQualident := % VAR name : Name ; - init, ip1 : CARDINAL ; - tok, tokstart: CARDINAL ; % - % PushAutoOn % - Ident % IF IsAutoPushOn() - THEN - PopTtok (name, tokstart) ; - tok := tokstart ; - init := GetSym (name) ; - IF init=NulSym - THEN - PushTFntok (NulSym, NulSym, name, tok) - ELSE - WHILE IsDefImp (init) OR IsModule (init) DO - IF currenttoken # periodtok - THEN - ErrorArrayAt ("expecting '.' after module in the construction of a qualident", tok) ; - IF tok#tokstart - THEN - tok := MakeVirtualTok (tokstart, tokstart, tok) - END ; - PushTtok (init, tok) ; - PopAuto ; - RETURN - ELSE - Expect (periodtok, stopset0, stopset1, stopset2 + SetOfStop2{identtok}) ; - StartScope (init) ; - Ident (stopset0, stopset1, stopset2) ; - PopTtok (name, tok) ; - ip1 := GetSym (name) ; - IF ip1 = NulSym - THEN - ErrorArrayAt ("unknown ident in the construction of a qualident", tok) ; - EndScope ; - IF tok#tokstart - THEN - tok := MakeVirtualTok (tokstart, tokstart, tok) - END ; - PushTFntok (NulSym, NulSym, name, tok) ; - PopAuto ; - RETURN - ELSE - PutIncluded (ip1) - END ; - EndScope ; - CheckCanBeImported (init, ip1) ; - init := ip1 - END - END ; - IF tok#tokstart - THEN - tok := MakeVirtualTok (tokstart, tokstart, tok) - END ; - IF IsProcedure (init) OR IsProcType (init) - THEN - PushTtok (init, tok) - ELSE - PushTFtok (init, GetType(init), tok) - END - END - ELSE % - { "." Ident } % END % - % PopAuto % - =: - ConstantDeclaration := % PushAutoOn % % VAR tokno: CARDINAL ; % ( Ident "=" % tokno := GetTokenNo () % @@ -1125,13 +985,6 @@ SetOrDesignatorOrFunction := % VAR % Assert (n = Top ()) % =: --- SimpleDes := { "." Ident | "[" ExpList "]" | "^" } =: -SimpleDes := { SubDesignator } =: - -ActualParameters := "(" - ( ExpList | % (* epsilon *) % - ) ")" =: - ConstActualParameters := "(" % BuildSizeCheckStart % ( ConstExpList | % BuildNulParam % ) ")" =: @@ -1182,7 +1035,7 @@ IfStatement := StatementSequence } [ "ELSE" - StatementSequence ] "END" + StatementSequence ] "END" =: CaseStatement := "CASE"