Introduce attribute unused into the grammar of gm2 and mc.
Emit attribute ((unused)) during parameters if specified.
Removes many unused warnings when building gm2 under bootstrap
(specifically used during generic walk procedures in M2GCCDeclare.mod).
gcc/m2/ChangeLog:
* gm2-compiler/M2AsmUtil.mod (UnderScoreString): Removed.
* gm2-compiler/M2GCCDeclare.mod (DeclareStringConstant): delete
variable location and remove passing it to any procedure.
(PromoteToString) remove variable location and remove it from all
usage.
(TryDeclareConst) remove tokenno.
(DeclareConst): remove tokenno.
* gm2-compiler/M2GenGCC.mod (CodeStatement): Remove first
parameter for CodeInitStart and CodeFinallyStart.
(BuildTreeFromInterface): Remove location variable as
BuildStringConstant no longer has this parameter.
(CodeInitStart): Remove the unused first parameter.
(CodeFinallyStart): Remove the unused first parameter.
(CodeAddr): Remove location variable as
BuildStringConstant no longer has this parameter.
* gm2-compiler/M2LexBuf.mod (stop): Removed.
* gm2-compiler/M2Options.def (m2linemap): Import list replaced
identifier GetSaveTempsDir.
* gm2-compiler/M2Options.mod (DynamicStrings): Import list replaced
identifiers GenModuleListFlag and SaveTempsDir.
(SetSaveTempsDir) copy directory string.
(GetSaveTempsDir) New procedure function.
* gm2-compiler/M2Range.mod (BuildStringParamLoc): Remove location
variable as it is no longer needed by BuildStringConstant.
* gm2-compiler/P0SyntaxCheck.bnf: Extend grammar to allow
attribute unused in parameters.
* gm2-compiler/P1Build.bnf: Extend grammar to allow
attribute unused in parameters.
* gm2-compiler/P2Build.bnf (NameKey): Imported. (MetaErrorT1)
Imported. Extend grammar to allow attribute unused in parameters
and also check attribute contents for usused and noreturn.
* gm2-compiler/P3Build.bnf: Extend grammar to allow attribute
unused in parameters.
* gm2-compiler/PCBuild.bnf: Extend grammar to allow attribute
unused in parameters.
* gm2-compiler/PHBuild.bnf: Extend grammar to allow attribute
unused in parameters.
* gm2-compiler/SymbolTable.mod (GetOuterModule): Remove function
procedure.
* gm2-gcc/m2decl.cc (BuildStringConstant): Remove unused
location parameter.
* gm2-gcc/m2decl.def (BuildStringConstant): Remove unused
location parameter.
* gm2-gcc/m2decl.h (BuildStringConstant): Remove unused
location parameter.
* m2/gm2-lang.cc: Tidy up comments.
* m2/m2-tree.def: Tidy up comments.
* m2/m2-tree.h: Tidy up comments.
* m2/m2pp.cc: Tidy up comments.
* m2/m2pp.h: Tidy up comments.
* mc-boot/GASCII.c: Rebuilt.
* mc-boot/GArgs.c: Rebuilt.
* mc-boot/GAssertion.c: Rebuilt.
* mc-boot/GBreak.c: Rebuilt.
* mc-boot/GCmdArgs.c: Rebuilt.
* mc-boot/GDebug.c: Rebuilt.
* mc-boot/GDynamicStrings.c: Rebuilt.
* mc-boot/GEnvironment.c: Rebuilt.
* mc-boot/GFIO.c: Rebuilt.
* mc-boot/GFormatStrings.c: Rebuilt.
* mc-boot/GFpuIO.c: Rebuilt.
* mc-boot/GIO.c: Rebuilt.
* mc-boot/GIndexing.c: Rebuilt.
* mc-boot/GM2Dependent.c: Rebuilt.
* mc-boot/GM2EXCEPTION.c: Rebuilt.
* mc-boot/GM2RTS.c: Rebuilt.
* mc-boot/GMemUtils.c: Rebuilt.
* mc-boot/GNumberIO.c: Rebuilt.
* mc-boot/GPushBackInput.c: Rebuilt.
* mc-boot/GRTExceptions.c: Rebuilt.
* mc-boot/GRTint.c: Rebuilt.
* mc-boot/GSArgs.c: Rebuilt.
* mc-boot/GSFIO.c: Rebuilt.
* mc-boot/GStdIO.c: Rebuilt.
* mc-boot/GStorage.c: Rebuilt.
* mc-boot/GStrCase.c: Rebuilt.
* mc-boot/GStrIO.c: Rebuilt.
* mc-boot/GStrLib.c: Rebuilt.
* mc-boot/GStringConvert.c: Rebuilt.
* mc-boot/GSysStorage.c: Rebuilt.
* mc-boot/GTimeString.c: Rebuilt.
* mc-boot/Galists.c: Rebuilt.
* mc-boot/Gdecl.h: Rebuilt.
* mc-boot/Gkeyc.c: Rebuilt.
* mc-boot/Glists.c: Rebuilt.
* mc-boot/GmcComment.c: Rebuilt.
* mc-boot/GmcComp.c: Rebuilt.
* mc-boot/GmcDebug.c: Rebuilt.
* mc-boot/GmcError.c: Rebuilt.
* mc-boot/GmcFileName.c: Rebuilt.
* mc-boot/GmcLexBuf.c: Rebuilt.
* mc-boot/GmcMetaError.c: Rebuilt.
* mc-boot/GmcPreprocess.c: Rebuilt.
* mc-boot/GmcPretty.c: Rebuilt.
* mc-boot/GmcPrintf.c: Rebuilt.
* mc-boot/GmcQuiet.c: Rebuilt.
* mc-boot/GmcReserved.c: Rebuilt.
* mc-boot/GmcSearch.c: Rebuilt.
* mc-boot/GmcStack.c: Rebuilt.
* mc-boot/GmcStream.c: Rebuilt.
* mc-boot/Gmcp1.c: Rebuilt.
* mc-boot/Gmcp2.c: Rebuilt.
* mc-boot/Gmcp3.c: Rebuilt.
* mc-boot/Gmcp4.c: Rebuilt.
* mc-boot/Gmcp5.c: Rebuilt.
* mc-boot/GnameKey.c: Rebuilt.
* mc-boot/GsymbolKey.c: Rebuilt.
* mc-boot/Gtop.c: Rebuilt.
* mc-boot/Gvarargs.c: Rebuilt.
* mc-boot/Gwlists.c: Rebuilt.
* mc/decl.def (makeVarParameter): Add parameter to signify used.
(makeNonVarParameter): Add parameter to signify used.
(addVarParameters): Add parameter to signify used.
* mc/decl.mod: Add isused boolean to parameters.
* mc/mcp1.bnf: Extend grammar to handle attribute unused during
parameters.
* mc/mcp2.bnf: Extend grammar to handle attribute unused during
parameters.
* mc/mcp3.bnf: Extend grammar to handle attribute unused during
parameters. (mcPrintf): Import list replaced identifiers makekey
and makeKey.
* mc/mcp4.bnf: Extend grammar to handle attribute unused during
parameters.
* mc/mcp5.bnf: Extend grammar to handle attribute unused during
parameters.
* tools-src/mklink.c: Pass envp with argc, argv parameters for
module initializer/finalization calls.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
END GetFullScopePrefix ;
-(*
- UnderScoreString - emits a string with a leading underscore if the C compiler
- uses _ prefixes. The string without the underscore is returned.
-*)
-
-PROCEDURE UnderScoreString (s: String) : String ;
-BEGIN
- IF UseUnderscoreForC
- THEN
- Write('_')
- END ;
- RETURN( WriteS(StdOut, s) )
-END UnderScoreString ;
-
-
END M2AsmUtil.
DeclareStringConstant - declares a string constant.
*)
-PROCEDURE DeclareStringConstant (tokenno: CARDINAL; sym: CARDINAL) ;
+PROCEDURE DeclareStringConstant (sym: CARDINAL) ;
VAR
symtree : Tree ;
- location: location_t ;
BEGIN
- location := TokenToLocation (tokenno) ;
IF IsConstStringM2nul (sym) OR IsConstStringCnul (sym)
THEN
(* in either case the string needs a nul terminator. If the string
symtree := BuildCStringConstant (KeyToCharStar (GetString (sym)),
GetStringLength (sym))
ELSE
- symtree := BuildStringConstant (location,
- KeyToCharStar (GetString (sym)),
+ symtree := BuildStringConstant (KeyToCharStar (GetString (sym)),
GetStringLength (sym))
END ;
PreAddModGcc (sym, symtree) ;
PROCEDURE PromoteToString (tokenno: CARDINAL; sym: CARDINAL) : Tree ;
VAR
- size : CARDINAL ;
- location: location_t ;
+ size: CARDINAL ;
BEGIN
- location := TokenToLocation (tokenno) ;
DeclareConstant (tokenno, sym) ;
size := GetStringLength (sym) ;
IF size > 1
(* will be a string anyway *)
RETURN Tree (Mod2Gcc (sym))
ELSE
- RETURN BuildStringConstant (location,
- KeyToCharStar (GetString (sym)),
+ RETURN BuildStringConstant (KeyToCharStar (GetString (sym)),
GetStringLength (sym))
END
END PromoteToString ;
THEN
DeclareCharConstant(sym)
ELSE
- DeclareStringConstant (tokenno, sym)
+ DeclareStringConstant (sym)
END
ELSIF IsValueSolved(sym)
THEN
THEN
DeclareCharConstant(sym)
ELSE
- DeclareStringConstant (tokenno, sym)
+ DeclareStringConstant (sym)
END
ELSIF IsValueSolved(sym)
THEN
WalkFamilyOfUnbounded -
*)
-PROCEDURE WalkFamilyOfUnbounded (oaf: CARDINAL; dim: CARDINAL; unbounded: CARDINAL) ;
+PROCEDURE WalkFamilyOfUnbounded (oaf: CARDINAL <* unused *> ; dim: CARDINAL <* unused *> ; unbounded: CARDINAL) ;
BEGIN
- IF unbounded#NulSym
+ IF unbounded # NulSym
THEN
- unboundedp(unbounded)
+ unboundedp (unbounded)
END
END WalkFamilyOfUnbounded ;
StartModFileOp : CodeStartModFile (op3) |
ModuleScopeOp : CodeModuleScope (op3) |
EndFileOp : CodeEndFile |
- InitStartOp : CodeInitStart (op2, op3, IsCompilingMainModule (op3)) |
+ InitStartOp : CodeInitStart (op3, IsCompilingMainModule (op3)) |
InitEndOp : CodeInitEnd (op3, IsCompilingMainModule (op3)) |
- FinallyStartOp : CodeFinallyStart (op2, op3, IsCompilingMainModule (op3)) |
+ FinallyStartOp : CodeFinallyStart (op3, IsCompilingMainModule (op3)) |
FinallyEndOp : CodeFinallyEnd (op3, IsCompilingMainModule (op3)) |
NewLocalVarOp : CodeNewLocalVar (op1, op3) |
KillLocalVarOp : CodeKillLocalVar (op3) |
obj : CARDINAL ;
gccName,
tree : Tree ;
- location: location_t;
BEGIN
tree := Tree (NIL) ;
IF sym#NulSym
THEN
- location := TokenToLocation (tokenno) ;
i := 1 ;
REPEAT
GetRegInterface (sym, i, name, str, obj) ;
THEN
gccName := NIL
ELSE
- gccName := BuildStringConstant (location, KeyToCharStar (name), LengthKey (name))
+ gccName := BuildStringConstant (KeyToCharStar (name), LengthKey (name))
END ;
tree := ChainOnParamValue (tree, gccName, PromoteToString (tokenno, str), Mod2Gcc (obj))
ELSE
current module.
*)
-PROCEDURE CodeInitStart (currentScope, moduleSym: CARDINAL;
+PROCEDURE CodeInitStart (moduleSym: CARDINAL;
CompilingMainModule: BOOLEAN) ;
VAR
location : location_t;
current module.
*)
-PROCEDURE CodeFinallyStart (outerModule, moduleSym: CARDINAL;
+PROCEDURE CodeFinallyStart (moduleSym: CARDINAL;
CompilingMainModule: BOOLEAN) ;
VAR
location : location_t;
DeclareConstructor (CurrentQuadToken, quad, op3) ;
IF (IsConst (op3) AND (type=Char)) OR IsConstString (op3)
THEN
- value := BuildStringConstant (location, KeyToCharStar (GetString (op3)), GetStringLength (op3))
+ value := BuildStringConstant (KeyToCharStar (GetString (op3)), GetStringLength (op3))
ELSE
value := Mod2Gcc (op3)
END ;
* create string from char and add nul to the end, nul is
* added by BuildStringConstant
*)
- op3t := BuildStringConstant (location, KeyToCharStar (GetString (op3)), 1)
+ op3t := BuildStringConstant (KeyToCharStar (GetString (op3)), 1)
ELSE
op3t := Mod2Gcc (op3)
END ;
END GetFileName ;
-PROCEDURE stop ; BEGIN END stop ;
-
-
(*
AddTokToList - adds a token to a dynamic list.
*)
DumpSystemExports, GenerateSwig, Exceptions,
OverrideLocation, FinaliseOptions,
DebugBuiltins, setdefextension, setmodextension,
- SetStatistics, SetWall, SetSaveTemps, SetSaveTempsDir,
- SaveTemps, GenModuleList,
+ SetStatistics, SetWall,
+ SetSaveTemps, SetSaveTempsDir, SaveTemps, GetSaveTempsDir,
+ GenModuleList,
CppArg, CppCommandLine, CppRemember,
SetDebugFunctionLineNumbers, DebugFunctionLineNumbers,
SetGenerateStatementNote, GenerateStatementNote,
PROCEDURE SetSaveTempsDir (arg: ADDRESS) ;
+(*
+ GetSaveTempsDir - return SaveTempsDir or NIL if -save-temps was not used.
+*)
+
+PROCEDURE GetSaveTempsDir () : String ;
+
+
(*
SetGenModuleList - set the GenModuleList flag to value and pass
set GenModuleListFilename to filename.
VAR
Barg,
+ SaveTempsDir,
GenModuleListFilename,
UselistFilename,
RuntimeModuleOverride,
CppArgs : String ;
UselistFlag,
- GenModuleListFlag,
CC1Quiet,
SeenSources : BOOLEAN ;
ForcedLocationValue : location_t ;
PROCEDURE SetSaveTempsDir (arg: ADDRESS) ;
BEGIN
- (* printf1 ("SetSaveTempsDir: arg = %s\n", arg); *)
+ SaveTempsDir := InitStringCharStar (arg)
END SetSaveTempsDir ;
+(*
+ GetSaveTempsDir - return SaveTempsDir or NIL if -save-temps was not used.
+*)
+
+PROCEDURE GetSaveTempsDir () : String ;
+BEGIN
+ RETURN SaveTempsDir
+END GetSaveTempsDir ;
+
+
(*
SetScaffoldDynamic - set the -fscaffold-dynamic flag.
*)
GenModuleList := FALSE ;
GenModuleListFilename := NIL ;
SharedFlag := FALSE ;
- Barg := NIL
+ Barg := NIL ;
+ SaveTempsDir := NIL
END M2Options.
BEGIN
BuildParam (location,
BuildConvert (location, Mod2Gcc (Address),
- BuildAddr (location, BuildStringConstant (location, string(s), Length(s)),
+ BuildAddr (location, BuildStringConstant (string(s), Length(s)),
FALSE), FALSE))
END BuildStringParamLoc ;
AttributeNoReturn := [ "<*" Ident "*>" ] =:
+AttributeUnused := [ "<*" Ident "*>" ] =:
+
-- note that we do need to know whether builtins are used as they
-- determine whether we need to parse the implementation module
-- the same is true for hidden types
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" IdentList ":" FormalType =:
+VarFPSection := "VAR" IdentList ":" FormalType [ AttributeUnused ] =:
-NonVarFPSection := IdentList ":" FormalType =:
+NonVarFPSection := IdentList ":" FormalType [ AttributeUnused ] =:
OptArg := "[" Ident ":" FormalType [ "=" ConstExpression ] "]" =:
END %
=:
-IdentScopeList := IdentScope % VAR
- on: BOOLEAN ;
- n : CARDINAL ; %
- % on := IsAutoPushOn() ;
- IF on
- THEN
- n := 1
- END %
- { "," IdentScope % IF on
- THEN
- INC(n)
- END %
- } % IF on
- THEN
- PushT(n)
- END %
- =:
-
PossiblyExportIdentList := PossiblyExportIdent % VAR
on: BOOLEAN ;
n : CARDINAL ; %
Ident '(' ConstExpression ')' % PopAuto %
=:
+AttributeUnused := [ "<*" % PushAutoOff %
+ Ident % PopAuto %
+ "*>" ] =:
+
FieldListSequence := FieldListStatement { ";" FieldListStatement } =:
FieldListStatement := [ FieldList ] =:
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" IdentScopeList ":" FormalType =:
+VarFPSection := "VAR" IdentList ":" FormalType [ AttributeUnused ] =:
-NonVarFPSection := IdentScopeList ":" FormalType =:
+NonVarFPSection := IdentList ":" FormalType [ AttributeUnused ] =:
OptArg := "[" IdentScope ":" FormalType [ "=" ConstExpression ] "]" =:
IMPLEMENTATION MODULE P2Build ;
FROM M2LexBuf IMPORT currentstring, currenttoken, GetToken, InsertToken, InsertTokenAndRewind, GetTokenNo ;
-FROM M2MetaError IMPORT MetaErrorStringT0 ;
+FROM M2MetaError IMPORT MetaErrorStringT0, MetaErrorT1 ;
FROM NameKey IMPORT NulName, Name, makekey, MakeKey ;
FROM M2Reserved IMPORT tokToTok, toktype, NulTok, ImportTok, ExportTok, QualifiedTok, UnQualifiedTok ;
FROM DynamicStrings IMPORT String, InitString, KillString, Mark, ConCat, ConCatChar ;
PROCEDURE ErrorString (s: String) ;
BEGIN
- MetaErrorStringT0(GetTokenNo(), s) ;
+ MetaErrorStringT0 (GetTokenNo (), s) ;
WasNoError := FALSE
END ErrorString ;
PROCEDURE ErrorArray (a: ARRAY OF CHAR) ;
BEGIN
- ErrorString(InitString(a))
+ ErrorString (InitString (a))
END ErrorArray ;
% declaration P2Build begin
+(*
+ checkReturnAttribute -
+*)
+
+PROCEDURE checkReturnAttribute ;
+VAR
+ ident: Name ;
+ tok : CARDINAL ;
+BEGIN
+ PopTtok (ident, tok) ;
+ IF ident # MakeKey ('noreturn')
+ THEN
+ MetaErrorT1 (tok, 'attribute {%1k} is not allowed in the procedure return type, only noreturn is allowed', ident)
+ END
+END checkReturnAttribute ;
+
+
+(*
+ checkParameterAttribute -
+*)
+
+PROCEDURE checkParameterAttribute ;
+VAR
+ ident: Name ;
+ tok : CARDINAL ;
+BEGIN
+ PopTtok (ident, tok) ;
+ IF ident # MakeKey ('noreturn')
+ THEN
+ MetaErrorT1 (tok, 'attribute {%1k} is not allowed in the parameter formal type section, only unused is allowed', ident)
+ END
+END checkParameterAttribute ;
+
(*
SyntaxError - after a syntax error we skip all tokens up until we reach
s0 := SetOfStop0{} ;
s1 := SetOfStop1{} ;
s2 := SetOfStop2{} ;
- IF ORD(t)<32
+ IF ORD (t) <32
THEN
- INCL(s0, t)
- ELSIF ORD(t)<64
+ INCL (s0, t)
+ ELSIF ORD (t) <64
THEN
- INCL(s1, t)
+ INCL (s1, t)
ELSE
- INCL(s2, t)
+ INCL (s2, t)
END ;
- str := DescribeStop(s0, s1, s2) ;
+ str := DescribeStop (s0, s1, s2) ;
- str := ConCat(InitString('syntax error,'), Mark(str)) ;
- MetaErrorStringT0(GetTokenNo(), str)
+ str := ConCat (InitString ('syntax error,'), Mark (str)) ;
+ MetaErrorStringT0 (GetTokenNo (), str)
END WarnMissingToken ;
) % M2Error.LeaveErrorScope %
=:
-AttributeNoReturn := [ "<*" % PushAutoOff %
+AttributeNoReturn := [ "<*" % PushAutoOn %
Ident % PopAuto %
+ % checkReturnAttribute %
"*>" ] =:
+AttributeUnused := [ "<*" % PushAutoOn %
+ Ident % PopAuto %
+ % checkParameterAttribute %
+ "*>" ] =:
+
-- introduced procedure block so we can produce more informative
-- error messages
% PopT(n) ; %
% PushT(VarTok) ; %
IdentList ":" FormalType % PushT(n) %
+ [ AttributeUnused ]
% BuildFPSection %
=:
% PopT(n) %
% PushT(NulTok) %
IdentList ":" FormalType % PushT(n) %
+ [ AttributeUnused ]
% BuildFPSection %
=:
AttributeNoReturn := [ "<*" Ident "*>" ] =:
+AttributeUnused := [ "<*" Ident "*>" ] =:
+
-- introduced procedure block so we can produce more informative
-- error messages
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" IdentList ":" FormalType =:
+VarFPSection := "VAR" IdentList ":" FormalType [ AttributeUnused ] =:
-NonVarFPSection := IdentList ":" FormalType =:
+NonVarFPSection := IdentList ":" FormalType [ AttributeUnused ] =:
OptArg := "[" Ident ":" FormalType [ "=" ConstExpression % BuildOptArgInitializer %
] "]" =:
AttributeNoReturn := [ "<*" Ident "*>" ] =:
+AttributeUnused := [ "<*" Ident "*>" ] =:
+
-- introduced procedure block so we can produce more informative
-- error messages
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" IdentList ":" FormalType =:
+VarFPSection := "VAR" IdentList ":" FormalType [ AttributeUnused ] =:
-NonVarFPSection := IdentList ":" FormalType =:
+NonVarFPSection := IdentList ":" FormalType [ AttributeUnused ] =:
OptArg := "[" Ident ":" FormalType [ "=" ConstExpression ] "]" =:
AttributeNoReturn := [ "<*" Ident "*>" ] =:
+AttributeUnused := [ "<*" Ident "*>" ] =:
+
-- introduced procedure block so we can produce more informative
-- error messages
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" IdentList ":" FormalType =:
+VarFPSection := "VAR" IdentList ":" FormalType [ AttributeUnused ] =:
-NonVarFPSection := IdentList ":" FormalType =:
+NonVarFPSection := IdentList ":" FormalType [ AttributeUnused ] =:
OptArg := "[" Ident ":" FormalType [ "=" SilentConstExpression ] "]" =:
END IsDefLink ;
-(*
- GetOuterModule - returns the outer module or NulSym if there
- is no module being compiled.
-*)
-
-PROCEDURE GetOuterModule () : CARDINAL ;
-VAR
- OuterModule: CARDINAL ;
-BEGIN
- OuterModule := GetCurrentModule () ;
- IF OuterModule # NulSym
- THEN
- WHILE GetScope (OuterModule) # NulSym DO
- OuterModule := GetScope (OuterModule)
- END
- END ;
- RETURN OuterModule
-END GetOuterModule ;
-
-
(*
GetLink - returns TRUE if the current module is only used for linkage.
*)
and, length. */
tree
-m2decl_BuildStringConstant (location_t location, const char *string, int length)
+m2decl_BuildStringConstant (const char *string, int length)
{
tree elem, index, type;
and, length.
*)
-PROCEDURE BuildStringConstant (location: location_t; string: ADDRESS; length: INTEGER) : Tree ;
+PROCEDURE BuildStringConstant (string: ADDRESS; length: INTEGER) : Tree ;
(*
EXTERN void m2decl_BuildModuleCtor (tree module_ctor);
EXTERN tree m2decl_DeclareModuleCtor (tree decl);
EXTERN tree m2decl_GetDeclContext (tree t);
-EXTERN tree m2decl_BuildStringConstant (location_t location, const char *string, int length);
+EXTERN tree m2decl_BuildStringConstant (const char *string, int length);
EXTERN tree m2decl_BuildCStringConstant (const char *string, int length);
EXTERN tree m2decl_BuildConstLiteralNumber (location_t location,
const char *str,
gcc_unreachable ();
}
-/* This hook is used to get the current list of declarations as
- trees. We don't support that; instead we use write_globals. This
- can't simply crash because it is called by -gstabs. */
+/* This hook is used to get the current list of declarations as trees.
+ We don't support that; instead we use write_globals. This can't
+ simply crash because it is called by -gstabs. */
static tree
gm2_langhook_getdecls (void)
return NULL;
}
+/* m2_write_global_declarations writes out globals by coping into a vec
+ and calling wrapup_global_declarations. */
static void
m2_write_global_declarations (tree globals)
}
-/* Gimplify an EXPR_STMT node. */
+/* Gimplify an EXPR_STMT node. */
static void
gimplify_expr_stmt (tree *stmt_p)
{
/* If a function's arguments are copied to create a thunk, then
- DECL_BY_REFERENCE will be set -- but the type of the argument will be
- a pointer type, so we will never get here. */
+ DECL_BY_REFERENCE will be set -- but the type of the argument will be
+ a pointer type, so we will never get here. */
gcc_assert (!DECL_BY_REFERENCE (t));
gcc_assert (DECL_ARG_TYPE (t) != TREE_TYPE (t));
TREE_TYPE (t) = DECL_ARG_TYPE (t);
default:
return true;
}
- /* never reach here. */
+ /* Never reach here. */
gcc_unreachable ();
}
Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
-/* A SET_TYPE type */
+/* A SET_TYPE type. */
DEFTREECODE (SET_TYPE, "set_type", tcc_type, 0)
/* STMT_EXPR accessor. */
#define STMT_EXPR_STMT(NODE) TREE_OPERAND (STMT_EXPR_CHECK (NODE), 0)
-/* EXPR_STMT accessor. This gives the expression associated with an
+/* EXPR_STMT accessor. This gives the expression associated with an
expression statement. */
#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
killPretty (state);
}
-/* pf - print function. Expected to be printed interactively from
+/* pf print function. Expected to be printed interactively from
the debugger: print pf(func), or to be called from code. */
void
do_pf (t, FALSE);
}
-/* pe - print expression. Expected to be printed interactively from
+/* pe print expression. Expected to be printed interactively from
the debugger: print pe(expr), or to be called from code. */
void
killPretty (state);
}
-/* pet - print expression and its type. Expected to be printed
+/* pet print expression and its type. Expected to be printed
interactively from the debugger: print pet(expr), or to be called
from code. */
killPretty (state);
}
-/* pt - print type. Expected to be printed interactively from the
+/* pt print type. Expected to be printed interactively from the
debugger: print pt(expr), or to be called from code. */
void
killPretty (state);
}
-/* ptl - print type low level. Expected to be printed interactively
+/* ptl print type low level. Expected to be printed interactively
from the debugger: print ptl(type), or to be called from code. */
void
killPretty (state);
}
-/* ptcl - print TREE_CHAINed list. */
+/* ptcl print TREE_CHAINed list. */
void
ptcl (tree t)
killPretty (state);
}
-/* loc - if tree has a location then display it within a comment. */
+/* loc if tree has a location then display it within a comment. */
static void
m2pp_loc (pretty *s, tree t)
}
}
-/* m2pp_decl_list - prints a TREE_CHAINed list for a decl node. */
+/* m2pp_decl_list prints a TREE_CHAINed list for a decl node. */
static void
m2pp_decl_list (pretty *s, tree t)
}
}
-/* */
-
#if defined(GM2_MAINTAINER)
+
+/* remember an internal debugging hook. */
static tree rememberF = NULL;
static void
}
#endif
-/* push - pushes tree, t, onto stack. */
+/* push pushes tree t onto stack. */
static void
push (tree t)
stackPtr = s;
}
-/* pop - pops a tree, from the stack. */
+/* pop pops a tree, from the stack. */
static void
pop (void)
free (s);
}
-/* being_printed - returns TRUE if, t, is held on the stack. */
+/* being_printed returns TRUE if t is held on the stack. */
static int
begin_printed (tree t)
return FALSE;
}
-/* dupPretty - duplicate and return a copy of state, s. */
+/* dupPretty duplicate and return a copy of state s. */
static pretty *
dupPretty (pretty *s)
return p;
}
-/* initPretty - initialise the state of the pretty printer. */
+/* initPretty initialise the state of the pretty printer. */
static pretty *
initPretty (int bits)
return state;
}
-/* killPretty - cleans up the state. */
+/* killPretty cleans up the state. */
static void
killPretty (pretty *s)
fflush (stdout);
}
-/* getindent - returns the current indent value. */
+/* getindent returns the current indent value. */
static int
getindent (pretty *s)
return s->indent;
}
-/* setindent - sets the current indent to, n. */
+/* setindent sets the current indent to, n. */
static void
setindent (pretty *s, int n)
s->indent = n;
}
-/* getcurpos - returns the current cursor position. */
+/* getcurpos returns the current cursor position. */
static int
getcurpos (pretty *s)
return s->curpos;
}
-/* m2pp_type_lowlevel - prints out the low level details of a
+/* m2pp_type_lowlevel prints out the low level details of a
fundamental type. */
static void
}
}
-/* m2pp_var - emit a VAR if necessary. */
+/* m2pp_var emit a VAR if necessary. */
static void
m2pp_var (pretty *s)
}
}
-/* m2pp_types - emit a TYPE if necessary. */
+/* m2pp_types emit a TYPE if necessary. */
static void
m2pp_types (pretty *s)
}
}
-/* hextree - displays the critical fields for function, block and
+/* hextree displays the critical fields for function, block and
bind_expr trees in raw hex. */
static void
}
}
-/* m2pp_begin - emit a BEGIN if necessary. */
+/* m2pp_begin emit a BEGIN if necessary. */
static void
m2pp_begin (pretty *s)
}
}
-/* m2pp_function - walk over the function. */
+/* m2pp_function walk over the function. */
static void
m2pp_function (pretty *s, tree t)
}
}
-/* m2pp_bind_expr - displays the bind expr tree node. */
+/* m2pp_bind_expr displays the bind expr tree node. */
static void
m2pp_bind_expr (pretty *s, tree t)
}
}
-/* m2pp_block_list - iterates over the list of blocks. */
+/* m2pp_block_list iterates over the list of blocks. */
static void
m2pp_block_list (pretty *s, tree t)
m2pp_block (s, t);
}
-/* m2pp_block - prints the VARiables and the TYPEs inside a block. */
+/* m2pp_block prints the VARiables and the TYPEs inside a block. */
static void
m2pp_block (pretty *s, tree t)
}
}
-/* m2pp_var_type_decl - displays the variable and type declaration. */
+/* m2pp_var_type_decl displays the variable and type declaration. */
static void
m2pp_var_type_decl (pretty *s, tree t)
m2pp_print (s, ";\n");
}
-/* m2pp_var_list - print a variable list. */
+/* m2pp_var_list print a variable list. */
static void
m2pp_var_list (pretty *s, tree t)
}
#if 0
-/* m2pp_type_list - print a variable list. */
+/* m2pp_type_list print a variable list. */
static void
m2pp_type_list (pretty *s, tree t)
}
#endif
-/* m2pp_needspace - sets appropriate flag to TRUE. */
+/* m2pp_needspace sets appropriate flag to TRUE. */
static void
m2pp_needspace (pretty *s)
s->needs_space = TRUE;
}
-/* m2pp_identifer - prints an identifier. */
+/* m2pp_identifer prints an identifier. */
static void
m2pp_identifier (pretty *s, tree t)
}
}
-/* m2pp_ident_pointer - displays an ident pointer. */
+/* m2pp_ident_pointer displays an ident pointer. */
static void
m2pp_ident_pointer (pretty *s, tree t)
m2pp_print (s, IDENTIFIER_POINTER (t));
}
-/* m2pp_parameter - prints out a param decl tree. */
+/* m2pp_parameter prints out a param decl tree. */
static void
m2pp_parameter (pretty *s, tree t)
}
}
-/* m2pp_param_type - prints out the type of parameter. */
+/* m2pp_param_type prints out the type of parameter. */
static void
m2pp_param_type (pretty *s, tree t)
m2pp_simple_type (s, t);
}
-/* m2pp_procedure_type - displays a procedure type. */
+/* m2pp_procedure_type displays a procedure type. */
static void
m2pp_procedure_type (pretty *s, tree t)
if (TREE_CHAIN (i) == NULL_TREE)
{
if (TREE_VALUE (i) == void_type_node)
- /* ignore void_type_node at the end. */
+ /* Ignore void_type_node at the end. */
;
else
{
pop ();
}
-/* m2pp_comment_header - displays a simple header with some critical
+/* m2pp_comment_header displays a simple header with some critical
tree info. */
static void
m2pp_print (s, "*)\n\n");
}
-/* m2pp_function_header - displays the function header. */
+/* m2pp_function_header displays the function header. */
static void
m2pp_function_header (pretty *s, tree t)
pop ();
}
-/* m2pp_add_var - adds a variable into a list as defined by, data. */
+/* m2pp_add_var adds a variable into a list as defined by, data. */
static tree
m2pp_add_var (tree *tp, int *walk_subtrees, void *data)
return NULL_TREE;
}
-/* m2pp_function_vars - displays variables as defined by the function
+/* m2pp_function_vars displays variables as defined by the function
tree. */
static void
}
}
-/* m2pp_print - print out a string, p, interpreting '\n' and
- adjusting the fields within, state, s. */
+/* m2pp_print print out a string p interpreting '\n' and
+ adjusting the fields within state s. */
static void
m2pp_print (pretty *s, const char *p)
}
}
-/* m2pp_print_char - prints out a character, ch, obeying needs_space
+/* m2pp_print_char prints out a character ch obeying needs_space
and needs_indent. */
static void
s->curpos++;
}
-/* m2pp_integer - display the appropriate integer type. */
+/* m2pp_integer display the appropriate integer type. */
#if defined(GM2)
void
}
#endif
-/* m2pp_complex - display the actual complex type. */
+/* m2pp_complex display the actual complex type. */
#if defined(GM2)
static void
}
#endif
-/* m2pp_type - prints a full type. */
+/* m2pp_type prints a full type. */
void
m2pp_type (pretty *s, tree t)
}
}
-/* m2pp_set_type - prints out the set type. */
+/* m2pp_set_type prints out the set type. */
static void
m2pp_set_type (pretty *s, tree t)
pop ();
}
-/* m2pp_enum - print out the enumeration type. */
+/* m2pp_enum print out the enumeration type. */
static void
m2pp_enum (pretty *s, tree t)
pop ();
}
-/* m2pp_array - prints out the array type. */
+/* m2pp_array prints out the array type. */
static void
m2pp_array (pretty *s, tree t)
pop ();
}
-/* m2pp_subrange - prints out the subrange, but probably the lower
+/* m2pp_subrange prints out the subrange, but probably the lower
bound will always be zero. */
static void
m2pp_print (s, "]");
}
-/* m2pp_gimplified - print out a gimplified comment. */
+/* m2pp_gimplified print out a gimplified comment. */
static void
m2pp_gimpified (pretty *s, tree t)
}
}
-/* m2pp_printer_type - display the pointer type. */
+/* m2pp_printer_type display the pointer type. */
static void
m2pp_pointer_type (pretty *s, tree t)
pop ();
}
-/* m2pp_record_alignment - prints out whether this record is aligned
+/* m2pp_record_alignment prints out whether this record is aligned
(packed). */
static void
}
}
-/* m2pp_record_type - displays the record type. */
+/* m2pp_record_type displays the record type. */
static void
m2pp_record_type (pretty *s, tree t)
pop ();
}
-/* m2pp_record_type - displays the record type. */
+/* m2pp_record_type displays the record type. */
static void
m2pp_union_type (pretty *s, tree t)
}
}
-/* m2pp_expression - */
+/* m2pp_expression display an expression. */
static void
m2pp_expression (pretty *s, tree t)
}
}
-/* m2pp_relop - displays the lhs relop rhs. */
+/* m2pp_relop displays the lhs relop rhs. */
static void
m2pp_relop (pretty *s, tree t, const char *p)
m2pp_expression (s, TREE_OPERAND (t, 1));
}
-/* m2pp_compound_expression - handle compound expression tree. */
+/* m2pp_compound_expression handle compound expression tree. */
static void
m2pp_compound_expression (pretty *s, tree t)
m2pp_needspace (s);
}
-/* m2pp_target_expression - handle target expression tree. */
+/* m2pp_target_expression handle target expression tree. */
static void
m2pp_target_expression (pretty *s, tree t)
m2pp_needspace (s);
}
-/* m2pp_constructor - print out a constructor. */
+/* m2pp_constructor print out a constructor. */
static void
m2pp_constructor (pretty *s, tree t)
m2pp_print (s, " *)\n");
}
-/* m2pp_complex_expr - handle GCC complex_expr tree. */
+/* m2pp_complex_expr handle GCC complex_expr tree. */
static void
m2pp_complex_expr (pretty *s, tree t)
}
}
-/* m2pp_imagpart_expr - handle imagpart_expr tree. */
+/* m2pp_imagpart_expr handle imagpart_expr tree. */
static void
m2pp_imagpart_expr (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_realpart_expr - handle imagpart_expr tree. */
+/* m2pp_realpart_expr handle imagpart_expr tree. */
static void
m2pp_realpart_expr (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_bit_ior_expr - */
+/* m2pp_bit_ior_expr generate a C style bit or. */
static void
m2pp_bit_ior_expr (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_simple_expression - handle GCC expression tree. */
+/* m2pp_simple_expression handle GCC expression tree. */
static void
m2pp_simple_expression (pretty *s, tree t)
}
}
-/* non_lvalue_expr - indicates that operand 0 is not an lvalue. */
+/* non_lvalue_expr indicates that operand 0 is not an lvalue. */
static void
m2pp_non_lvalue_expr (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_array_ref - prints out the array reference. */
+/* m2pp_array_ref prints out the array reference. */
static void
m2pp_array_ref (pretty *s, tree t)
m2pp_print (s, "]");
}
-/* m2pp_ssa - prints out the ssa variable name. */
+/* m2pp_ssa prints out the ssa variable name. */
static void
m2pp_ssa (pretty *s, tree t)
m2pp_identifier (s, SSA_NAME_VAR (t));
}
-/* m2pp_binary - print the binary operator, p, and lhs, rhs. */
+/* m2pp_binary print the binary operator, p, and lhs, rhs. */
static void
m2pp_binary (pretty *s, tree t, const char *p)
m2pp_expression (s, right);
}
-/* m2pp_unary - print the unary operator, p, and expression. */
+/* m2pp_unary print the unary operator, p, and expression. */
static void
m2pp_unary (pretty *s, tree t, const char *p)
m2pp_expression (s, expr);
}
-/* m2pp_integer_cst - displays the integer constant. */
+/* m2pp_integer_cst displays the integer constant. */
static void
m2pp_integer_cst (pretty *s, tree t)
m2pp_print (s, val);
}
-/* m2pp_real_cst - displays the real constant. */
+/* m2pp_real_cst displays the real constant. */
static void
m2pp_real_cst (pretty *s, tree t ATTRIBUTE_UNUSED)
m2pp_print (s, "<unknown real>");
}
-/* m2pp_string_cst - displays the real constant. */
+/* m2pp_string_cst displays the real constant. */
static void
m2pp_string_cst (pretty *s, tree t)
m2pp_print (s, "\"");
}
-/* m2pp_statement_sequence - iterates over a statement list
+/* m2pp_statement_sequence iterates over a statement list
displaying each statement in turn. */
static void
}
}
-/* m2pp_unknown - displays an error message. */
+/* m2pp_unknown displays an error message. */
static void
m2pp_unknown (pretty *s, const char *s1, const char *s2)
m2pp_needspace (s);
}
-/* m2pp_throw - displays a throw statement. */
+/* m2pp_throw displays a throw statement. */
static void
m2pp_throw (pretty *s, tree t)
}
}
-/* m2pp_catch_expr - attempts to reconstruct a catch expr. */
+/* m2pp_catch_expr attempts to reconstruct a catch expr. */
static void
m2pp_catch_expr (pretty *s, tree t)
m2pp_print (s, "(* end catch body *)\n");
}
-/* m2pp_try_finally_expr - attemts to reconstruct a try finally expr. */
+/* m2pp_try_finally_expr attemts to reconstruct a try finally expr. */
static void
m2pp_try_finally_expr (pretty *s, tree t)
}
#if !defined(GM2)
-/* m2pp_if_stmt - pretty print a C++ if_stmt. */
+/* m2pp_if_stmt pretty print a C++ if_stmt. */
static void
m2pp_if_stmt (pretty *s, tree t)
}
#endif
-/* m2pp_statement - attempts to reconstruct a statement. */
+/* m2pp_statement attempts to reconstruct a statement. */
static void
m2pp_statement (pretty *s, tree t)
}
}
-/* m2pp_try_catch_expr - is used after gimplification. */
+/* m2pp_try_catch_expr is used after gimplification. */
static void
m2pp_try_catch_expr (pretty *s, tree t)
m2pp_print (s, "(* try_catch_expr ends *)\n");
}
-/* m2pp_cleanup_point_expr - emits a comment indicating a GCC
+/* m2pp_cleanup_point_expr emits a comment indicating a GCC
cleanup_point_expr is present. */
static void
m2pp_print (s, "(* cleanup point ends *)\n");
}
-/* m2pp_decl_expr - displays a local declaration. */
+/* m2pp_decl_expr displays a local declaration. */
static void
m2pp_decl_expr (pretty *s, tree t)
m2pp_var_type_decl (s, DECL_EXPR_DECL (t));
}
-/* m2pp_procedure_call - print a call to a procedure. */
+/* m2pp_procedure_call print a call to a procedure. */
static void
m2pp_procedure_call (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_call_expr - print a call to a procedure or function. */
+/* m2pp_call_expr print a call to a procedure or function. */
static void
m2pp_call_expr (pretty *s, tree t)
else
proc = call;
- m2pp_expression (s, proc); /* m2pp_identifier (s, proc); */
+ m2pp_expression (s, proc);
if (args || has_return_type)
m2pp_args (s, t);
}
-/* m2pp_return_expr - displays the return statement. */
+/* m2pp_return_expr displays the return statement. */
static void
m2pp_return_expr (pretty *s, tree t)
m2pp_print (s, ";\n");
}
-/* m2pp_try_block - displays the try block. */
+/* m2pp_try_block displays the try block. */
static void
m2pp_try_block (pretty *s, tree t)
m2pp_print (s, "(* END TRY *)\n");
}
-/* m2pp_try_block - displays the handler block. */
+/* m2pp_try_block displays the handler block. */
static void
m2pp_handler (pretty *s, tree t)
m2pp_statement_sequence (s, body);
}
-/* m2pp_assignment - prints out the assignment statement. */
+/* m2pp_assignment prints out the assignment statement. */
static void
m2pp_assignment (pretty *s, tree t)
setindent (s, o);
}
-/* m2pp_designator - displays the lhs of an assignment. */
+/* m2pp_designator displays the lhs of an assignment. */
static void
m2pp_designator (pretty *s, tree t)
m2pp_expression (s, t);
}
-/* m2pp_indirect_ref - displays the indirect operator. */
+/* m2pp_indirect_ref displays the indirect operator. */
static void
m2pp_indirect_ref (pretty *s, tree t)
m2pp_print (s, ")^");
}
-/* m2pp_conditional - builds an IF THEN ELSE END. With more work
+/* m2pp_conditional builds an IF THEN ELSE END. With more work
this should be moved into statement sequence which could look for
repeat and while loops. */
m2pp_print (s, "END ;\n");
}
-/* m2pp_label_decl - displays a label. Again should be moved into
+/* m2pp_label_decl displays a label. Again should be moved into
statement sequence to determine proper loop constructs. */
static void
m2pp_print (s, ": *)\n");
}
-/* m2pp_label_expr - skips the LABEL_EXPR to find the LABEL_DECL. */
+/* m2pp_label_expr skips the LABEL_EXPR to find the LABEL_DECL. */
static void
m2pp_label_expr (pretty *s, tree t)
m2pp_statement (s, TREE_OPERAND (t, 0));
}
-/* m2pp_goto - displays a goto statement. Again should be moved into
+/* m2pp_goto displays a goto statement. Again should be moved into
statement sequence to determine proper loop constructs. */
static void
m2pp_print (s, " *)\n");
}
-/* m2pp_list - prints a TREE_CHAINed list. */
+/* m2pp_list prints a TREE_CHAINed list. */
static void
m2pp_list (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_offset - displays the offset operator. */
+/* m2pp_offset displays the offset operator. */
static void
m2pp_offset (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_addr_expr - */
+/* m2pp_addr_expr create an ADR expression. */
static void
m2pp_addr_expr (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_nop - */
+/* m2pp_nop generate a CAST expression. */
static void
m2pp_nop (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_convert - */
+/* m2pp_convert generate a CONVERT expression. */
static void
m2pp_convert (pretty *s, tree t)
m2pp_print (s, ")");
}
-/* m2pp_var_decl - */
+/* m2pp_var_decl generate a variable. */
static void
m2pp_var_decl (pretty *s, tree t)
m2pp_identifier (s, t);
}
-/* m2pp_result_decl - */
+/* m2pp_result_decl generate a result declaration (variable). */
static void
m2pp_result_decl (pretty *s, tree t)
m2pp_identifier (s, t);
}
-/* m2pp_component_ref - */
+/* m2pp_component_ref generate a record field access. */
static void
m2pp_component_ref (pretty *s, tree t)
# define EXTERN extern
# endif
+/* These functions allow a maintainer to dump the trees in Modula-2. */
+
EXTERN void pf (tree t);
EXTERN void pe (tree t);
EXTERN void pt (tree t);
# define ASCII_del (char) 0177
# define ASCII_EOL ASCII_nl
-extern "C" void _M2_ASCII_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_ASCII_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_ASCII_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_ASCII_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_Args_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Args_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_Args_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Args_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_Assertion_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Assertion_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_Assertion_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Assertion_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_Break_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Break_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_Break_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Break_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_CmdArgs_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_CmdArgs_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_CmdArgs_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_CmdArgs_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_Debug_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Debug_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_Debug_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Debug_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_DynamicStrings_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_DynamicStrings_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
Initialized = FALSE;
Init ();
}
-extern "C" void _M2_DynamicStrings_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_DynamicStrings_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_Environment_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Environment_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_Environment_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Environment_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_FIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_FIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
Init ();
}
-extern "C" void _M2_FIO_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_FIO_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
FIO_FlushOutErr ();
}
__builtin_unreachable ();
}
-extern "C" void _M2_FormatStrings_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_FormatStrings_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_FormatStrings_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_FormatStrings_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
s = DynamicStrings_KillString (s);
}
-extern "C" void _M2_FpuIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_FpuIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_FpuIO_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_FpuIO_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
term = termios_KillTermios (term);
}
-extern "C" void _M2_IO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_IO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
Init ();
}
-extern "C" void _M2_IO_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_IO_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_Indexing_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Indexing_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_Indexing_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Indexing_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_M2Dependent_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_M2Dependent_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
CheckInitialized ();
}
-extern "C" void _M2_M2Dependent_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_M2Dependent_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_M2EXCEPTION_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_M2EXCEPTION_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
RTExceptions_SetExceptionBlock (RTExceptions_InitExceptionBlock ());
}
-extern "C" void _M2_M2EXCEPTION_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_M2EXCEPTION_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
RTExceptions_Raise ( ((unsigned int) (M2EXCEPTION_exException)), filename, line, column, scope, message);
}
-extern "C" void _M2_M2RTS_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_M2RTS_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
CheckInitialized ();
}
-extern "C" void _M2_M2RTS_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_M2RTS_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_MemUtils_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_MemUtils_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_MemUtils_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_MemUtils_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_NumberIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_NumberIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_NumberIO_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_NumberIO_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_PushBackInput_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_PushBackInput_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
PushBackInput_SetDebug (FALSE);
Init ();
}
-extern "C" void _M2_PushBackInput_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_PushBackInput_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_RTExceptions_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_RTExceptions_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
Init ();
}
-extern "C" void _M2_RTExceptions_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_RTExceptions_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
TidyUp ();
}
}
}
-extern "C" void _M2_RTint_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_RTint_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
RTint_Init ();
}
-extern "C" void _M2_RTint_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_RTint_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_SArgs_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_SArgs_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_SArgs_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_SArgs_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_SFIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_SFIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_SFIO_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_SFIO_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_StdIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StdIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
StackWPtr = 0;
StackRPtr = 0;
StdIO_PushInput ((StdIO_ProcRead) {(StdIO_ProcRead_t) IO_Read});
}
-extern "C" void _M2_StdIO_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StdIO_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_Storage_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Storage_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_Storage_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_Storage_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_StrCase_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StrCase_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_StrCase_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StrCase_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_StrIO_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StrIO_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
/* IsATTY := isatty() */
IsATTY = FALSE;
}
-extern "C" void _M2_StrIO_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StrIO_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_StrLib_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StrLib_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_StrLib_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StrLib_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_StringConvert_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StringConvert_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_StringConvert_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_StringConvert_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
{
}
-extern "C" void _M2_SysStorage_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_SysStorage_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
callno = 0;
if (enableTrace)
}
}
-extern "C" void _M2_SysStorage_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_SysStorage_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_TimeString_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_TimeString_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_TimeString_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_TimeString_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_alists_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_alists_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_alists_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_alists_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
decl_node scope;
unsigned int isUnbounded;
unsigned int isForC;
+ unsigned int isUsed;
};
struct paramT_r {
decl_node scope;
unsigned int isUnbounded;
unsigned int isForC;
+ unsigned int isUsed;
};
struct varargsT_r {
unsigned int isInitialised;
unsigned int isParameter;
unsigned int isVarParameter;
+ unsigned int isUsed;
cnameT cname;
};
makeVarParameter - returns a var parameter node with, name: type.
*/
-extern "C" decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_node proc);
+extern "C" decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_node proc, unsigned int isused);
/*
makeNonVarParameter - returns a non var parameter node with, name: type.
*/
-extern "C" decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl_node proc);
+extern "C" decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl_node proc, unsigned int isused);
/*
paramEnter - reset the parameter count.
in procedure, n.
*/
-extern "C" void decl_addVarParameters (decl_node n, decl_node i, decl_node type);
+extern "C" void decl_addVarParameters (decl_node n, decl_node i, decl_node type, unsigned int isused);
/*
addNonVarParameters - adds the identlist, i, of, type, to be parameters
in procedure, n.
*/
-extern "C" void decl_addNonVarParameters (decl_node n, decl_node i, decl_node type);
+extern "C" void decl_addNonVarParameters (decl_node n, decl_node i, decl_node type, unsigned int isused);
/*
makeVarargs - returns a varargs node.
static void setUnary (decl_node u, nodeT k, decl_node a, decl_node t);
/*
- putVarBool - assigns the three booleans associated with a variable.
+ putVarBool - assigns the four booleans associated with a variable.
*/
-static void putVarBool (decl_node v, unsigned int init, unsigned int param, unsigned int isvar);
+static void putVarBool (decl_node v, unsigned int init, unsigned int param, unsigned int isvar, unsigned int isused);
/*
checkPtr - in C++ we need to create a typedef for a pointer
makeVariablesFromParameters - creates variables which are really parameters.
*/
-static void makeVariablesFromParameters (decl_node proc, decl_node id, decl_node type, unsigned int isvar);
+static void makeVariablesFromParameters (decl_node proc, decl_node id, decl_node type, unsigned int isvar, unsigned int isused);
/*
addProcedureToScope - add a procedure name n and node d to the
checkParameters - placeholder for future parameter checking.
*/
-static void checkParameters (decl_node p, decl_node i, decl_node type, unsigned int var);
+static void checkParameters (decl_node p, decl_node i, decl_node type, unsigned int isvar, unsigned int isused);
/*
checkMakeVariables - create shadow local variables for parameters providing that
a module or an implementation module.
*/
-static void checkMakeVariables (decl_node n, decl_node i, decl_node type, unsigned int isvar);
+static void checkMakeVariables (decl_node n, decl_node i, decl_node type, unsigned int isvar, unsigned int isused);
/*
makeVarientField - create a varient field within varient, v,
static void doNameM2 (mcPretty_pretty p, decl_node n);
+/*
+ doUsed -
+*/
+
+static void doUsed (mcPretty_pretty p, unsigned int used);
+
/*
doHighC -
*/
-static void doHighC (mcPretty_pretty p, decl_node a, nameKey_Name n);
+static void doHighC (mcPretty_pretty p, decl_node a, nameKey_Name n, unsigned int isused);
/*
doParamConstCast -
/*
- putVarBool - assigns the three booleans associated with a variable.
+ putVarBool - assigns the four booleans associated with a variable.
*/
-static void putVarBool (decl_node v, unsigned int init, unsigned int param, unsigned int isvar)
+static void putVarBool (decl_node v, unsigned int init, unsigned int param, unsigned int isvar, unsigned int isused)
{
mcDebug_assert (decl_isVar (v));
v->varF.isInitialised = init;
v->varF.isParameter = param;
v->varF.isVarParameter = isvar;
+ v->varF.isUsed = isused;
}
makeVariablesFromParameters - creates variables which are really parameters.
*/
-static void makeVariablesFromParameters (decl_node proc, decl_node id, decl_node type, unsigned int isvar)
+static void makeVariablesFromParameters (decl_node proc, decl_node id, decl_node type, unsigned int isvar, unsigned int isused)
{
decl_node v;
unsigned int i;
m = static_cast<nameKey_Name> (wlists_getItemFromList (id->identlistF.names, i));
v = decl_makeVar (m);
decl_putVar (v, type, NULL);
- putVarBool (v, TRUE, TRUE, isvar);
+ putVarBool (v, TRUE, TRUE, isvar, isused);
if (debugScopes)
{
libc_printf ((const char *) "adding parameter variable into top scope\\n", 42);
checkParameters - placeholder for future parameter checking.
*/
-static void checkParameters (decl_node p, decl_node i, decl_node type, unsigned int var)
+static void checkParameters (decl_node p, decl_node i, decl_node type, unsigned int isvar, unsigned int isused)
{
/* do check. */
disposeNode (&i);
a module or an implementation module.
*/
-static void checkMakeVariables (decl_node n, decl_node i, decl_node type, unsigned int isvar)
+static void checkMakeVariables (decl_node n, decl_node i, decl_node type, unsigned int isvar, unsigned int isused)
{
if (((decl_isImp (currentModule)) || (decl_isModule (currentModule))) && ! n->procedureF.built)
{
- makeVariablesFromParameters (n, i, type, isvar);
+ makeVariablesFromParameters (n, i, type, isvar, isused);
}
}
}
+/*
+ doUsed -
+*/
+
+static void doUsed (mcPretty_pretty p, unsigned int used)
+{
+ if (! used)
+ {
+ mcPretty_setNeedSpace (p);
+ outText (p, (const char *) "__attribute__((unused))", 23);
+ }
+}
+
+
/*
doHighC -
*/
-static void doHighC (mcPretty_pretty p, decl_node a, nameKey_Name n)
+static void doHighC (mcPretty_pretty p, decl_node a, nameKey_Name n, unsigned int isused)
{
if ((decl_isArray (a)) && (decl_isUnbounded (a)))
{
mcPretty_print (p, (const char *) "_", 1);
outTextN (p, n);
mcPretty_print (p, (const char *) "_high", 5);
+ doUsed (p, isused);
}
}
/* avoid dangling else. */
doParamConstCast (p, n);
doTypeNameC (p, ptype);
+ doUsed (p, n->paramF.isUsed);
if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype)))
{
outText (p, (const char *) ",", 1);
doParamTypeEmit (p, n, ptype);
if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype)))
{
+ doUsed (p, n->paramF.isUsed);
outText (p, (const char *) ",", 1);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "unsigned int", 12);
{
outText (p, (const char *) "_", 1);
}
- doHighC (p, ptype, i);
+ doUsed (p, n->paramF.isUsed);
+ doHighC (p, ptype, i, n->paramF.isUsed);
if (c < t)
{
outText (p, (const char *) ",", 1);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "*", 1);
}
+ doUsed (p, n->varparamF.isUsed);
if ((decl_isArray (ptype)) && (decl_isUnbounded (ptype)))
{
outText (p, (const char *) ",", 1);
if (l == NULL)
{
doParamTypeEmit (p, n, ptype);
+ doUsed (p, n->varparamF.isUsed);
}
else
{
{
doFQDNameC (p, v, TRUE);
}
- doHighC (p, ptype, i);
+ doUsed (p, n->varparamF.isUsed);
+ doHighC (p, ptype, i, n->varparamF.isUsed);
if (c < t)
{
outText (p, (const char *) ",", 1);
doFQNameC (p, n);
outText (p, (const char *) "_init", 5);
mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])\\n", 74);
+ outText (p, (const char *) "(__attribute__((unused)) int argc", 33);
+ outText (p, (const char *) ",__attribute__((unused)) char *argv[]", 37);
+ outText (p, (const char *) ",__attribute__((unused)) char *envp[])\\n", 40);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->impF.beginStatements);
p = outKc (p, (const char *) "}\\n", 3);
doFQNameC (p, n);
outText (p, (const char *) "_finish", 7);
mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])\\n", 74);
+ outText (p, (const char *) "(__attribute__((unused)) int argc", 33);
+ outText (p, (const char *) ",__attribute__((unused)) char *argv[]", 37);
+ outText (p, (const char *) ",__attribute__((unused)) char *envp[])\\n", 40);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->impF.finallyStatements);
p = outKc (p, (const char *) "}\\n", 3);
outText (p, (const char *) "_init", 5);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(__attribute__((unused)) int argc,", 34);
- outText (p, (const char *) " __attribute__((unused)) char *argv[],", 38);
+ outText (p, (const char *) " __attribute__((unused)) char *argv[]", 37);
outText (p, (const char *) " __attribute__((unused)) char *envp[])\\n", 40);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->impF.beginStatements);
outText (p, (const char *) "_fini", 5);
mcPretty_setNeedSpace (p);
outText (p, (const char *) "(__attribute__((unused)) int argc,", 34);
- outText (p, (const char *) " __attribute__((unused)) char *argv[],", 38);
+ outText (p, (const char *) " __attribute__((unused)) char *argv[]", 37);
outText (p, (const char *) " __attribute__((unused)) char *envp[])\\n", 40);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->impF.finallyStatements);
doFQNameC (p, n);
outText (p, (const char *) "_init", 5);
mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])\\n", 74);
+ outText (p, (const char *) "(__attribute__((unused)) int argc", 33);
+ outText (p, (const char *) ",__attribute__((unused)) char *argv[]", 37);
+ outText (p, (const char *) ",__attribute__((unused)) char *envp[])\\n", 40);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->moduleF.beginStatements);
p = outKc (p, (const char *) "}\\n", 3);
doFQNameC (p, n);
outText (p, (const char *) "_finish", 7);
mcPretty_setNeedSpace (p);
- outText (p, (const char *) "(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])\\n", 74);
+ outText (p, (const char *) "(__attribute__((unused)) int argc", 33);
+ outText (p, (const char *) ",__attribute__((unused)) char *argv[]", 37);
+ outText (p, (const char *) ",__attribute__((unused)) char *envp[])\\n", 40);
p = outKc (p, (const char *) "{\\n", 3);
doStatementsC (p, n->moduleF.finallyStatements);
p = outKc (p, (const char *) "}\\n", 3);
mcDebug_assert (decl_isProcedure (proc));
l = decl_makeIdentList ();
mcDebug_assert (decl_putIdent (l, id));
- checkMakeVariables (proc, l, type, FALSE);
+ checkMakeVariables (proc, l, type, FALSE, TRUE);
if (! proc->procedureF.checking)
{
p = makeOptParameter (l, type, init);
makeVarParameter - returns a var parameter node with, name: type.
*/
-extern "C" decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_node proc)
+extern "C" decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_node proc, unsigned int isused)
{
decl_node d;
d->varparamF.scope = proc;
d->varparamF.isUnbounded = FALSE;
d->varparamF.isForC = isDefForCNode (proc);
+ d->varparamF.isUsed = isused;
return d;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
makeNonVarParameter - returns a non var parameter node with, name: type.
*/
-extern "C" decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl_node proc)
+extern "C" decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl_node proc, unsigned int isused)
{
decl_node d;
d->paramF.scope = proc;
d->paramF.isUnbounded = FALSE;
d->paramF.isForC = isDefForCNode (proc);
+ d->paramF.isUsed = isused;
return d;
/* static analysis guarentees a RETURN statement will be used before here. */
__builtin_unreachable ();
in procedure, n.
*/
-extern "C" void decl_addVarParameters (decl_node n, decl_node i, decl_node type)
+extern "C" void decl_addVarParameters (decl_node n, decl_node i, decl_node type, unsigned int isused)
{
decl_node p;
mcDebug_assert (isIdentList (i));
mcDebug_assert (decl_isProcedure (n));
- checkMakeVariables (n, i, type, TRUE);
+ checkMakeVariables (n, i, type, TRUE, isused);
if (n->procedureF.checking)
{
- checkParameters (n, i, type, TRUE); /* will destroy, i. */
+ checkParameters (n, i, type, TRUE, isused); /* will destroy, i. */
}
else
{
- p = decl_makeVarParameter (i, type, n);
+ p = decl_makeVarParameter (i, type, n, isused);
Indexing_IncludeIndiceIntoIndex (n->procedureF.parameters, reinterpret_cast<void *> (p));
}
}
in procedure, n.
*/
-extern "C" void decl_addNonVarParameters (decl_node n, decl_node i, decl_node type)
+extern "C" void decl_addNonVarParameters (decl_node n, decl_node i, decl_node type, unsigned int isused)
{
decl_node p;
mcDebug_assert (isIdentList (i));
mcDebug_assert (decl_isProcedure (n));
- checkMakeVariables (n, i, type, FALSE);
+ checkMakeVariables (n, i, type, FALSE, isused);
if (n->procedureF.checking)
{
- checkParameters (n, i, type, FALSE); /* will destroy, i. */
+ checkParameters (n, i, type, FALSE, isused); /* will destroy, i. */
}
else
{
- p = decl_makeNonVarParameter (i, type, n);
+ p = decl_makeNonVarParameter (i, type, n, isused);
Indexing_IncludeIndiceIntoIndex (n->procedureF.parameters, reinterpret_cast<void *> (p));
}
}
closeOutput ();
}
-extern "C" void _M2_decl_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_decl_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
init ();
}
-extern "C" void _M2_decl_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_decl_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
Where the parameters are declared as l: type.
*/
-EXTERN decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_node proc);
+EXTERN decl_node decl_makeVarParameter (decl_node l, decl_node type, decl_node proc, unsigned int isused);
/*
makeNonVarParameter - returns a non var parameter node with namelist and type.
Where the parameters are declared as l: type.
*/
-EXTERN decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl_node proc);
+EXTERN decl_node decl_makeNonVarParameter (decl_node l, decl_node type, decl_node proc, unsigned int isused);
/*
paramEnter - reset the parameter count.
in procedure, n.
*/
-EXTERN void decl_addVarParameters (decl_node n, decl_node i, decl_node type);
+EXTERN void decl_addVarParameters (decl_node n, decl_node i, decl_node type, unsigned int isused);
/*
addNonVarParameters - adds the identlist, i, of, type, to be parameters
in procedure, n.
*/
-EXTERN void decl_addNonVarParameters (decl_node n, decl_node i, decl_node type);
+EXTERN void decl_addNonVarParameters (decl_node n, decl_node i, decl_node type, unsigned int isused);
/*
makeVarargs - returns a varargs node.
}
}
-extern "C" void _M2_keyc_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_keyc_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
init ();
}
-extern "C" void _M2_keyc_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_keyc_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_lists_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_lists_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_lists_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_lists_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcComment_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcComment_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcComment_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcComment_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcComp_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcComp_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
init ();
}
-extern "C" void _M2_mcComp_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcComp_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_mcDebug_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcDebug_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcDebug_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcDebug_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcError_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcError_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
init ();
}
-extern "C" void _M2_mcError_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcError_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcFileName_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcFileName_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcFileName_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcFileName_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
/* source file list is empty, cannot pop an include.. */
}
-extern "C" void _M2_mcLexBuf_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcLexBuf_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
init ();
}
-extern "C" void _M2_mcLexBuf_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcLexBuf_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
varargs_end (&sym);
}
-extern "C" void _M2_mcMetaError_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcMetaError_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcMetaError_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcMetaError_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
issueGPL (f);
}
-extern "C" void _M2_mcOptions_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcOptions_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
langC = TRUE;
langCPP = FALSE;
projectContents = DynamicStrings_InitString ((const char *) "GNU Modula-2", 12);
}
-extern "C" void _M2_mcOptions_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcOptions_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcPreprocess_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcPreprocess_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
listOfFiles = alists_initList ();
if (! (M2RTS_InstallTerminationProcedure ((PROC ) {(PROC_t) removeFiles})))
}
}
-extern "C" void _M2_mcPreprocess_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcPreprocess_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_mcPretty_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcPretty_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcPretty_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcPretty_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
{} /* empty. */
}
-extern "C" void _M2_mcPrintf_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcPrintf_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcPrintf_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcPrintf_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
}
}
-extern "C" void _M2_mcQuiet_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcQuiet_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcQuiet_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcQuiet_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
typedef enum {mcReserved_eoftok, mcReserved_plustok, mcReserved_minustok, mcReserved_timestok, mcReserved_dividetok, mcReserved_becomestok, mcReserved_ambersandtok, mcReserved_periodtok, mcReserved_commatok, mcReserved_semicolontok, mcReserved_lparatok, mcReserved_rparatok, mcReserved_lsbratok, mcReserved_rsbratok, mcReserved_lcbratok, mcReserved_rcbratok, mcReserved_uparrowtok, mcReserved_singlequotetok, mcReserved_equaltok, mcReserved_hashtok, mcReserved_lesstok, mcReserved_greatertok, mcReserved_lessgreatertok, mcReserved_lessequaltok, mcReserved_greaterequaltok, mcReserved_ldirectivetok, mcReserved_rdirectivetok, mcReserved_periodperiodtok, mcReserved_colontok, mcReserved_doublequotestok, mcReserved_bartok, mcReserved_andtok, mcReserved_arraytok, mcReserved_begintok, mcReserved_bytok, mcReserved_casetok, mcReserved_consttok, mcReserved_definitiontok, mcReserved_divtok, mcReserved_dotok, mcReserved_elsetok, mcReserved_elsiftok, mcReserved_endtok, mcReserved_excepttok, mcReserved_exittok, mcReserved_exporttok, mcReserved_finallytok, mcReserved_fortok, mcReserved_fromtok, mcReserved_iftok, mcReserved_implementationtok, mcReserved_importtok, mcReserved_intok, mcReserved_looptok, mcReserved_modtok, mcReserved_moduletok, mcReserved_nottok, mcReserved_oftok, mcReserved_ortok, mcReserved_packedsettok, mcReserved_pointertok, mcReserved_proceduretok, mcReserved_qualifiedtok, mcReserved_unqualifiedtok, mcReserved_recordtok, mcReserved_remtok, mcReserved_repeattok, mcReserved_retrytok, mcReserved_returntok, mcReserved_settok, mcReserved_thentok, mcReserved_totok, mcReserved_typetok, mcReserved_untiltok, mcReserved_vartok, mcReserved_whiletok, mcReserved_withtok, mcReserved_asmtok, mcReserved_volatiletok, mcReserved_periodperiodperiodtok, mcReserved_datetok, mcReserved_linetok, mcReserved_filetok, mcReserved_attributetok, mcReserved_builtintok, mcReserved_inlinetok, mcReserved_integertok, mcReserved_identtok, mcReserved_realtok, mcReserved_stringtok, mcReserved_commenttok} mcReserved_toktype;
-extern "C" void _M2_mcReserved_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcReserved_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcReserved_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcReserved_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
Mod = DynamicStrings_Dup (ext);
}
-extern "C" void _M2_mcSearch_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcSearch_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
Init ();
}
-extern "C" void _M2_mcSearch_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcSearch_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcStack_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcStack_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcStack_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcStack_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcStream_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcStream_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
listOfFiles = alists_initList ();
seenDest = FALSE;
frag = Indexing_InitIndex (1);
}
-extern "C" void _M2_mcStream_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcStream_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
static void AttributeNoReturn (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+/*
+ AttributeUnused := [ '' ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+
/*
MultiFPSection := ExtendedFP | FPSection [ ';'
MultiFPSection ]
static void ExtendedFP (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
/*
- VarFPSection := 'VAR' IdentList ':' FormalType
+ VarFPSection := 'VAR' IdentList ':' FormalType [
+ AttributeUnused ]
first symbols:vartok
static void VarFPSection (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
/*
- NonVarFPSection := IdentList ':' FormalType
+ NonVarFPSection := IdentList ':' FormalType [ AttributeUnused ]
first symbols:identtok
}
+/*
+ AttributeUnused := [ '' ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2)
+{
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ Expect (mcReserved_ldirectivetok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
+ Ident (stopset0|(SetOfStop0) ((1 << (mcReserved_rdirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ Expect (mcReserved_rdirectivetok, stopset0, stopset1, stopset2);
+ }
+}
+
+
/*
MultiFPSection := ExtendedFP | FPSection [ ';'
MultiFPSection ]
/*
- VarFPSection := 'VAR' IdentList ':' FormalType
+ VarFPSection := 'VAR' IdentList ':' FormalType [
+ AttributeUnused ]
first symbols:vartok
Expect (mcReserved_vartok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
IdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
}
/*
- NonVarFPSection := IdentList ':' FormalType
+ NonVarFPSection := IdentList ':' FormalType [ AttributeUnused ]
first symbols:identtok
{
IdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcp1_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp1_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcp1_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp1_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
static void AttributeNoReturn (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+/*
+ AttributeUnused := [ '' ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+
/*
MultiFPSection := ExtendedFP | FPSection [ ';'
MultiFPSection ]
static void ExtendedFP (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
/*
- VarFPSection := 'VAR' IdentList ':' FormalType
+ VarFPSection := 'VAR' IdentList ':' FormalType [
+ AttributeUnused ]
first symbols:vartok
static void VarFPSection (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
/*
- NonVarFPSection := IdentList ':' FormalType
+ NonVarFPSection := IdentList ':' FormalType [ AttributeUnused ]
first symbols:identtok
}
+/*
+ AttributeUnused := [ '' ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2)
+{
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ Expect (mcReserved_ldirectivetok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
+ Ident (stopset0|(SetOfStop0) ((1 << (mcReserved_rdirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ Expect (mcReserved_rdirectivetok, stopset0, stopset1, stopset2);
+ }
+}
+
+
/*
MultiFPSection := ExtendedFP | FPSection [ ';'
MultiFPSection ]
/*
- VarFPSection := 'VAR' IdentList ':' FormalType
+ VarFPSection := 'VAR' IdentList ':' FormalType [
+ AttributeUnused ]
first symbols:vartok
Expect (mcReserved_vartok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
IdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
}
/*
- NonVarFPSection := IdentList ':' FormalType
+ NonVarFPSection := IdentList ':' FormalType [ AttributeUnused ]
first symbols:identtok
{
IdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcp2_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp2_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcp2_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp2_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
typedef unsigned int SetOfStop2;
static unsigned int WasNoError;
+static unsigned int curisused;
static nameKey_Name curstring;
static nameKey_Name curident;
static decl_node curproc;
static void ErrorArray (const char *a_, unsigned int _a_high);
+/*
+ checkParameterAttribute -
+*/
+
+static void checkParameterAttribute (void);
+
+/*
+ checkReturnAttribute -
+*/
+
+static void checkReturnAttribute (void);
+
/*
pushNunbounded -
*/
% n := push (makeVarargs ()) %
| 'VAR' FormalType
- % n := push (makeVarParameter (NIL, pop (), curproc)) %
+ % n := push (makeVarParameter (NIL, pop (), curproc, TRUE)) %
| FormalType
- % n := push (makeNonVarParameter (NIL, pop (), curproc)) %
+ % n := push (makeNonVarParameter (NIL, pop (), curproc, TRUE)) %
first symbols:identtok, arraytok, vartok, periodperiodperiodtok
static void NoReturn (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+/*
+ AttributeUnused := [ Unused ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+
+/*
+ Unused := ''
+
+ first symbols:ldirectivetok
+
+ cannot reachend
+*/
+
+static void Unused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+
/*
MultiFPSection := ExtendedFP | FPSection [ ';'
MultiFPSection ]
% l := pop () %
- % addVarParameters (curproc, l, t) %
+ % curisused := TRUE %
+ [ AttributeUnused ]
+ % addVarParameters (curproc, l, t, curisused) %
first symbols:vartok
% l := pop () %
- % addNonVarParameters (curproc, l, t) %
+ % curisused := TRUE %
+ [ AttributeUnused ]
+ % addNonVarParameters (curproc, l, t, curisused) %
first symbols:identtok
}
+/*
+ checkParameterAttribute -
+*/
+
+static void checkParameterAttribute (void)
+{
+ if ((nameKey_makeKey ((const char *) "unused", 6)) != curident)
+ {
+ mcMetaError_metaError1 ((const char *) "attribute {%1k} is not allowed in the formal parameter section, currently only unused is allowed", 96, (const unsigned char *) &curident, (sizeof (curident)-1));
+ }
+}
+
+
+/*
+ checkReturnAttribute -
+*/
+
+static void checkReturnAttribute (void)
+{
+ if ((nameKey_makeKey ((const char *) "noreturn", 8)) != curident)
+ {
+ mcMetaError_metaError1 ((const char *) "attribute {%1k} is not allowed in the procedure return type, only noreturn is allowed", 85, (const unsigned char *) &curident, (sizeof (curident)-1));
+ }
+}
+
+
/*
pushNunbounded -
*/
% n := push (makeVarargs ()) %
| 'VAR' FormalType
- % n := push (makeVarParameter (NIL, pop (), curproc)) %
+ % n := push (makeVarParameter (NIL, pop (), curproc, TRUE)) %
| FormalType
- % n := push (makeNonVarParameter (NIL, pop (), curproc)) %
+ % n := push (makeNonVarParameter (NIL, pop (), curproc, TRUE)) %
first symbols:identtok, arraytok, vartok, periodperiodperiodtok
/* avoid dangling else. */
Expect (mcReserved_vartok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
FormalType (stopset0, stopset1, stopset2);
- n = push (decl_makeVarParameter (static_cast<decl_node> (NULL), pop (), curproc));
+ n = push (decl_makeVarParameter (static_cast<decl_node> (NULL), pop (), curproc, TRUE));
}
else if ((mcLexBuf_currenttoken == mcReserved_arraytok) || (mcLexBuf_currenttoken == mcReserved_identtok))
{
/* avoid dangling else. */
FormalType (stopset0, stopset1, stopset2);
- n = push (decl_makeNonVarParameter (static_cast<decl_node> (NULL), pop (), curproc));
+ n = push (decl_makeNonVarParameter (static_cast<decl_node> (NULL), pop (), curproc, TRUE));
}
else
{
Expect (mcReserved_ldirectivetok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
Ident (stopset0|(SetOfStop0) ((1 << (mcReserved_rdirectivetok-mcReserved_eoftok))), stopset1, stopset2);
decl_setNoReturn (curproc, TRUE);
+ checkReturnAttribute ();
+ Expect (mcReserved_rdirectivetok, stopset0, stopset1, stopset2);
+}
+
+
+/*
+ AttributeUnused := [ Unused ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2)
+{
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ Unused (stopset0, stopset1, stopset2);
+ }
+}
+
+
+/*
+ Unused := ''
+
+ first symbols:ldirectivetok
+
+ cannot reachend
+*/
+
+static void Unused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2)
+{
+ Expect (mcReserved_ldirectivetok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
+ Ident (stopset0|(SetOfStop0) ((1 << (mcReserved_rdirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ curisused = FALSE;
+ checkParameterAttribute ();
Expect (mcReserved_rdirectivetok, stopset0, stopset1, stopset2);
}
% l := pop () %
- % addVarParameters (curproc, l, t) %
+ % curisused := TRUE %
+ [ AttributeUnused ]
+ % addVarParameters (curproc, l, t, curisused) %
first symbols:vartok
Expect (mcReserved_vartok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
PushIdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
t = pop ();
l = pop ();
- decl_addVarParameters (curproc, l, t);
+ curisused = TRUE;
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
+ decl_addVarParameters (curproc, l, t, curisused);
}
% l := pop () %
- % addNonVarParameters (curproc, l, t) %
+ % curisused := TRUE %
+ [ AttributeUnused ]
+ % addNonVarParameters (curproc, l, t, curisused) %
first symbols:identtok
PushIdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
t = pop ();
l = pop ();
- decl_addNonVarParameters (curproc, l, t);
+ curisused = TRUE;
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
+ decl_addNonVarParameters (curproc, l, t, curisused);
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcp3_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp3_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcp3_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp3_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
static void AttributeNoReturn (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+/*
+ AttributeUnused := [ '' ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+
/*
MultiFPSection := ExtendedFP | FPSection [ ';'
MultiFPSection ]
/*
VarFPSection := 'VAR' PushIdentList ':' FormalType
+ [ AttributeUnused ]
first symbols:vartok
/*
NonVarFPSection := PushIdentList ':' FormalType
+ [ AttributeUnused ]
first symbols:identtok
}
+/*
+ AttributeUnused := [ '' ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2)
+{
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ Expect (mcReserved_ldirectivetok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
+ Ident (stopset0|(SetOfStop0) ((1 << (mcReserved_rdirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ Expect (mcReserved_rdirectivetok, stopset0, stopset1, stopset2);
+ }
+}
+
+
/*
MultiFPSection := ExtendedFP | FPSection [ ';'
MultiFPSection ]
/*
VarFPSection := 'VAR' PushIdentList ':' FormalType
+ [ AttributeUnused ]
first symbols:vartok
Expect (mcReserved_vartok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
PushIdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
}
/*
NonVarFPSection := PushIdentList ':' FormalType
+ [ AttributeUnused ]
first symbols:identtok
{
PushIdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcp4_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp4_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcp4_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp4_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
static void AttributeNoReturn (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+/*
+ AttributeUnused := [ '' ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
+
/*
DefMultiFPSection := DefExtendedFP |
FPSection [ ';' DefMultiFPSection ]
static void ExtendedFP (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
/*
- VarFPSection := 'VAR' IdentList ':' FormalType
+ VarFPSection := 'VAR' IdentList ':' FormalType [
+ AttributeUnused ]
first symbols:vartok
static void VarFPSection (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2);
/*
- NonVarFPSection := IdentList ':' FormalType
+ NonVarFPSection := IdentList ':' FormalType [ AttributeUnused ]
first symbols:identtok
}
+/*
+ AttributeUnused := [ '' ]
+
+ first symbols:ldirectivetok
+
+ reachend
+*/
+
+static void AttributeUnused (SetOfStop0 stopset0, SetOfStop1 stopset1, SetOfStop2 stopset2)
+{
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ Expect (mcReserved_ldirectivetok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
+ Ident (stopset0|(SetOfStop0) ((1 << (mcReserved_rdirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ Expect (mcReserved_rdirectivetok, stopset0, stopset1, stopset2);
+ }
+}
+
+
/*
DefMultiFPSection := DefExtendedFP |
FPSection [ ';' DefMultiFPSection ]
/*
- VarFPSection := 'VAR' IdentList ':' FormalType
+ VarFPSection := 'VAR' IdentList ':' FormalType [
+ AttributeUnused ]
first symbols:vartok
Expect (mcReserved_vartok, stopset0, stopset1, stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
IdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
}
/*
- NonVarFPSection := IdentList ':' FormalType
+ NonVarFPSection := IdentList ':' FormalType [ AttributeUnused ]
first symbols:identtok
{
IdentList (stopset0|(SetOfStop0) ((1 << (mcReserved_colontok-mcReserved_eoftok))), stopset1, stopset2);
Expect (mcReserved_colontok, stopset0, stopset1|(SetOfStop1) ((1 << (mcReserved_arraytok-mcReserved_arraytok))), stopset2|(SetOfStop2) ((1 << (mcReserved_identtok-mcReserved_recordtok))));
- FormalType (stopset0, stopset1, stopset2);
+ FormalType (stopset0|(SetOfStop0) ((1 << (mcReserved_ldirectivetok-mcReserved_eoftok))), stopset1, stopset2);
+ if (mcLexBuf_currenttoken == mcReserved_ldirectivetok)
+ {
+ AttributeUnused (stopset0, stopset1, stopset2);
+ }
}
__builtin_unreachable ();
}
-extern "C" void _M2_mcp5_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp5_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_mcp5_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_mcp5_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_nameKey_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_nameKey_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
lastIndice = 0;
keyIndex = Indexing_InitIndex (1);
binaryTree->left = NULL;
}
-extern "C" void _M2_nameKey_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_nameKey_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
searchAndDo (t->left, p);
}
-extern "C" void _M2_symbolKey_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_symbolKey_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_symbolKey_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_symbolKey_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
mcComp_compile (mcOptions_handleOptions ());
}
-extern "C" void _M2_top_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_top_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
init ();
}
-extern "C" void _M2_top_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_top_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_varargs_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_varargs_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_varargs_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_varargs_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
__builtin_unreachable ();
}
-extern "C" void _M2_wlists_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_wlists_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
-extern "C" void _M2_wlists_finish (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+extern "C" void _M2_wlists_finish (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
{
}
Where the parameters are declared as l: type.
*)
-PROCEDURE makeVarParameter (l: node; type, proc: node) : node ;
+PROCEDURE makeVarParameter (l: node; type, proc: node; isused: BOOLEAN) : node ;
(*
Where the parameters are declared as l: type.
*)
-PROCEDURE makeNonVarParameter (l: node; type, proc: node) : node ;
+PROCEDURE makeNonVarParameter (l: node; type, proc: node; isused: BOOLEAN) : node ;
(*
in procedure, n.
*)
-PROCEDURE addVarParameters (n: node; i: node; type: node) ;
+PROCEDURE addVarParameters (n: node; i: node; type: node; isused: BOOLEAN) ;
(*
in procedure, n.
*)
-PROCEDURE addNonVarParameters (n: node; i: node; type: node) ;
+PROCEDURE addNonVarParameters (n: node; i: node; type: node; isused: BOOLEAN) ;
(*
scope : node ;
isInitialised,
isParameter,
- isVarParameter: BOOLEAN ;
+ isVarParameter,
+ isUsed : BOOLEAN ;
cname : cnameT ;
END ;
scope : node ;
isUnbounded: BOOLEAN ;
isForC : BOOLEAN ;
+ isUsed : BOOLEAN ;
END ;
paramT = RECORD
scope : node ;
isUnbounded: BOOLEAN ;
isForC : BOOLEAN ;
+ isUsed : BOOLEAN ;
END ;
varargsT = RECORD
(*
- putVarBool - assigns the three booleans associated with a variable.
+ putVarBool - assigns the four booleans associated with a variable.
*)
-PROCEDURE putVarBool (v: node; init, param, isvar: BOOLEAN) ;
+PROCEDURE putVarBool (v: node; init, param, isvar, isused: BOOLEAN) ;
BEGIN
assert (isVar (v)) ;
v^.varF.isInitialised := init ;
v^.varF.isParameter := param ;
- v^.varF.isVarParameter := isvar
+ v^.varF.isVarParameter := isvar ;
+ v^.varF.isUsed := isused
END putVarBool ;
makeVariablesFromParameters - creates variables which are really parameters.
*)
-PROCEDURE makeVariablesFromParameters (proc, id, type: node; isvar: BOOLEAN) ;
+PROCEDURE makeVariablesFromParameters (proc, id, type: node; isvar, isused: BOOLEAN) ;
VAR
v : node ;
i, n: CARDINAL ;
m := wlists.getItemFromList (id^.identlistF.names, i) ;
v := makeVar (m) ;
putVar (v, type, NIL) ;
- putVarBool (v, TRUE, TRUE, isvar) ;
+ putVarBool (v, TRUE, TRUE, isvar, isused) ;
IF debugScopes
THEN
printf ("adding parameter variable into top scope\n") ;
makeNonVarParameter - returns a non var parameter node with, name: type.
*)
-PROCEDURE makeNonVarParameter (l: node; type, proc: node) : node ;
+PROCEDURE makeNonVarParameter (l: node; type, proc: node; isused: BOOLEAN) : node ;
VAR
d: node ;
BEGIN
d^.paramF.scope := proc ;
d^.paramF.isUnbounded := FALSE ;
d^.paramF.isForC := isDefForCNode (proc) ;
+ d^.paramF.isUsed := isused ;
RETURN d
END makeNonVarParameter ;
makeVarParameter - returns a var parameter node with, name: type.
*)
-PROCEDURE makeVarParameter (l: node; type, proc: node) : node ;
+PROCEDURE makeVarParameter (l: node; type, proc: node; isused: BOOLEAN) : node ;
VAR
d: node ;
BEGIN
d^.varparamF.scope := proc ;
d^.varparamF.isUnbounded := FALSE ;
d^.varparamF.isForC := isDefForCNode (proc) ;
+ d^.varparamF.isUsed := isused ;
RETURN d
END makeVarParameter ;
assert (isProcedure (proc)) ;
l := makeIdentList () ;
assert (putIdent (l, id)) ;
- checkMakeVariables (proc, l, type, FALSE) ;
+ checkMakeVariables (proc, l, type, FALSE, TRUE) ;
IF NOT proc^.procedureF.checking
THEN
p := makeOptParameter (l, type, init) ;
checkParameters - placeholder for future parameter checking.
*)
-PROCEDURE checkParameters (p: node; i: node; type: node; var: BOOLEAN) ;
+PROCEDURE checkParameters (p: node; i: node; type: node; isvar, isused: BOOLEAN) ;
BEGIN
(* do check. *)
disposeNode (i)
a module or an implementation module.
*)
-PROCEDURE checkMakeVariables (n, i, type: node; isvar: BOOLEAN) ;
+PROCEDURE checkMakeVariables (n, i, type: node; isvar, isused: BOOLEAN) ;
BEGIN
IF (isImp (currentModule) OR isModule (currentModule)) AND
(NOT n^.procedureF.built)
THEN
- makeVariablesFromParameters (n, i, type, isvar)
+ makeVariablesFromParameters (n, i, type, isvar, isused)
END ;
END checkMakeVariables ;
in procedure, n.
*)
-PROCEDURE addVarParameters (n: node; i: node; type: node) ;
+PROCEDURE addVarParameters (n: node; i: node; type: node; isused: BOOLEAN) ;
VAR
p: node ;
BEGIN
assert (isIdentList (i)) ;
assert (isProcedure (n)) ;
- checkMakeVariables (n, i, type, TRUE) ;
+ checkMakeVariables (n, i, type, TRUE, isused) ;
IF n^.procedureF.checking
THEN
- checkParameters (n, i, type, TRUE) (* will destroy, i. *)
+ checkParameters (n, i, type, TRUE, isused) (* will destroy, i. *)
ELSE
- p := makeVarParameter (i, type, n) ;
+ p := makeVarParameter (i, type, n, isused) ;
IncludeIndiceIntoIndex (n^.procedureF.parameters, p) ;
END ;
END addVarParameters ;
in procedure, n.
*)
-PROCEDURE addNonVarParameters (n: node; i: node; type: node) ;
+PROCEDURE addNonVarParameters (n: node; i: node; type: node; isused: BOOLEAN) ;
VAR
p: node ;
BEGIN
assert (isIdentList (i)) ;
assert (isProcedure (n)) ;
- checkMakeVariables (n, i, type, FALSE) ;
+ checkMakeVariables (n, i, type, FALSE, isused) ;
IF n^.procedureF.checking
THEN
- checkParameters (n, i, type, FALSE) (* will destroy, i. *)
+ checkParameters (n, i, type, FALSE, isused) (* will destroy, i. *)
ELSE
- p := makeNonVarParameter (i, type, n) ;
+ p := makeNonVarParameter (i, type, n, isused) ;
IncludeIndiceIntoIndex (n^.procedureF.parameters, p)
END ;
END addNonVarParameters ;
END doNameM2 ;
+(*
+ doUsed -
+*)
+
+PROCEDURE doUsed (p: pretty; used: BOOLEAN) ;
+BEGIN
+ IF NOT used
+ THEN
+ setNeedSpace (p) ;
+ outText (p, "__attribute__((unused))")
+ END
+END doUsed ;
+
+
(*
doHighC -
*)
-PROCEDURE doHighC (p: pretty; a: node; n: Name) ;
+PROCEDURE doHighC (p: pretty; a: node; n: Name; isused: BOOLEAN) ;
BEGIN
IF isArray (a) AND isUnbounded (a)
THEN
(* need to display high. *)
print (p, ",") ; setNeedSpace (p) ;
doTypeNameC (p, cardinalN) ; setNeedSpace (p) ;
- print (p, "_") ; outTextN (p, n) ; print (p, "_high")
+ print (p, "_") ; outTextN (p, n) ; print (p, "_high") ;
+ doUsed (p, isused)
END
END doHighC ;
THEN
doParamConstCast (p, n) ;
doTypeNameC (p, ptype) ;
+ doUsed (p, n^.paramF.isUsed) ;
IF isArray (ptype) AND isUnbounded (ptype)
THEN
outText (p, ',') ; setNeedSpace (p) ;
doParamTypeEmit (p, n, ptype) ;
IF isArray (ptype) AND isUnbounded (ptype)
THEN
+ doUsed (p, n^.paramF.isUsed) ;
outText (p, ',') ; setNeedSpace (p) ;
outText (p, 'unsigned int')
END
THEN
outText (p, '_')
END ;
- doHighC (p, ptype, i) ;
+ doUsed (p, n^.paramF.isUsed) ;
+ doHighC (p, ptype, i, n^.paramF.isUsed) ;
IF c<t
THEN
outText (p, ',') ; setNeedSpace (p)
setNeedSpace (p) ;
outText (p, "*")
END ;
+ doUsed (p, n^.varparamF.isUsed) ;
IF isArray (ptype) AND isUnbounded (ptype)
THEN
outText (p, ',') ; setNeedSpace (p) ;
l := n^.varparamF.namelist^.identlistF.names ;
IF l=NIL
THEN
- doParamTypeEmit (p, n, ptype)
+ doParamTypeEmit (p, n, ptype) ;
+ doUsed (p, n^.varparamF.isUsed)
ELSE
t := wlists.noOfItemsInList (l) ;
c := 1 ;
ELSE
doFQDNameC (p, v, TRUE)
END ;
- doHighC (p, ptype, i) ;
+ doUsed (p, n^.varparamF.isUsed) ;
+ doHighC (p, ptype, i, n^.varparamF.isUsed) ;
IF c<t
THEN
outText (p, ',') ; setNeedSpace (p)
doFQNameC (p, n) ;
outText (p, "_init") ;
setNeedSpace (p) ;
- outText (p, "(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])\n") ;
+ outText (p, "(__attribute__((unused)) int argc") ;
+ outText (p, ",__attribute__((unused)) char *argv[]") ;
+ outText (p, ",__attribute__((unused)) char *envp[])\n");
p := outKc (p, "{\n") ;
doStatementsC (p, n^.impF.beginStatements) ;
p := outKc (p, "}\n") ;
doFQNameC (p, n) ;
outText (p, "_finish") ;
setNeedSpace (p) ;
- outText (p, "(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])\n") ;
+ outText (p, "(__attribute__((unused)) int argc") ;
+ outText (p, ",__attribute__((unused)) char *argv[]") ;
+ outText (p, ",__attribute__((unused)) char *envp[])\n");
p := outKc (p, "{\n") ;
doStatementsC (p, n^.impF.finallyStatements) ;
p := outKc (p, "}\n")
outText (p, "_init") ;
setNeedSpace (p) ;
outText (p, "(__attribute__((unused)) int argc,") ;
- outText (p, " __attribute__((unused)) char *argv[],") ;
+ outText (p, " __attribute__((unused)) char *argv[]") ;
outText (p, " __attribute__((unused)) char *envp[])\n") ;
p := outKc (p, "{\n") ;
doStatementsC (p, n^.impF.beginStatements) ;
outText (p, "_fini") ;
setNeedSpace (p) ;
outText (p, "(__attribute__((unused)) int argc,") ;
- outText (p, " __attribute__((unused)) char *argv[],") ;
+ outText (p, " __attribute__((unused)) char *argv[]") ;
outText (p, " __attribute__((unused)) char *envp[])\n") ;
p := outKc (p, "{\n") ;
doStatementsC (p, n^.impF.finallyStatements) ;
doFQNameC (p, n) ;
outText (p, "_init") ;
setNeedSpace (p) ;
- outText (p, "(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])\n") ;
+ outText (p, "(__attribute__((unused)) int argc") ;
+ outText (p, ",__attribute__((unused)) char *argv[]") ;
+ outText (p, ",__attribute__((unused)) char *envp[])\n");
p := outKc (p, "{\n") ;
doStatementsC (p, n^.moduleF.beginStatements) ;
p := outKc (p, "}\n") ;
doFQNameC (p, n) ;
outText (p, "_finish") ;
setNeedSpace (p) ;
- outText (p, "(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])\n") ;
+ outText (p, "(__attribute__((unused)) int argc") ;
+ outText (p, ",__attribute__((unused)) char *argv[]") ;
+ outText (p, ",__attribute__((unused)) char *envp[])\n");
p := outKc (p, "{\n") ;
doStatementsC (p, n^.moduleF.finallyStatements) ;
p := outKc (p, "}\n")
AttributeNoReturn := [ "<*" Ident "*>" ] =:
+AttributeUnused := [ "<*" Ident "*>" ] =:
+
MultiFPSection := ExtendedFP | FPSection [ ";" MultiFPSection ] =:
FPSection := NonVarFPSection | VarFPSection =:
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" IdentList ":" FormalType =:
+VarFPSection := "VAR" IdentList ":" FormalType [ AttributeUnused ] =:
-NonVarFPSection := IdentList ":" FormalType =:
+NonVarFPSection := IdentList ":" FormalType [ AttributeUnused ] =:
OptArg := "[" Ident ":" FormalType [ "=" ConstExpression ] "]" =:
AttributeNoReturn := [ "<*" Ident "*>" ] =:
+AttributeUnused := [ "<*" Ident "*>" ] =:
+
MultiFPSection := ExtendedFP | FPSection [ ";" MultiFPSection ] =:
FPSection := NonVarFPSection | VarFPSection =:
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" IdentList ":" FormalType =:
+VarFPSection := "VAR" IdentList ":" FormalType [ AttributeUnused ] =:
-NonVarFPSection := IdentList ":" FormalType =:
+NonVarFPSection := IdentList ":" FormalType [ AttributeUnused ] =:
OptArg := "[" Ident ":" FormalType [ "=" ConstExpression ] "]" =:
ConCat, ConCatChar ;
FROM mcError IMPORT errorStringAt ;
-FROM nameKey IMPORT NulName, Name, makekey ;
+FROM nameKey IMPORT NulName, Name, makekey, makeKey ;
FROM mcPrintf IMPORT printf0, printf1 ;
FROM mcDebug IMPORT assert ;
FROM mcReserved IMPORT toktype ;
VAR
WasNoError : BOOLEAN ;
+ curisused : BOOLEAN ;
curstring,
curident : Name ;
curproc,
END ErrorArray ;
+(*
+ checkParameterAttribute -
+*)
+
+PROCEDURE checkParameterAttribute ;
+BEGIN
+ IF makeKey ("unused") # curident
+ THEN
+ metaError1 ('attribute {%1k} is not allowed in the formal parameter section, currently only unused is allowed', curident)
+ END
+END checkParameterAttribute ;
+
+
+(*
+ checkReturnAttribute -
+*)
+
+PROCEDURE checkReturnAttribute ;
+BEGIN
+ IF makeKey ("noreturn") # curident
+ THEN
+ metaError1 ('attribute {%1k} is not allowed in the procedure return type, only noreturn is allowed', curident)
+ END
+END checkReturnAttribute ;
+
+
(*
pushNunbounded -
*)
ProcedureParameter := "..." % VAR n: node ; %
% n := push (makeVarargs ()) %
- | "VAR" FormalType % n := push (makeVarParameter (NIL, pop (), curproc)) %
- | FormalType % n := push (makeNonVarParameter (NIL, pop (), curproc)) %
+ | "VAR" FormalType % n := push (makeVarParameter (NIL, pop (), curproc, TRUE)) %
+ | FormalType % n := push (makeNonVarParameter (NIL, pop (), curproc, TRUE)) %
=:
[ MultiFPSection ] ")" % paramLeave (curproc) %
FormalReturn =:
-AttributeNoReturn := [ NoReturn | % setNoReturn (curproc, FALSE) %
+AttributeNoReturn := [ NoReturn | % setNoReturn (curproc, FALSE) %
] =:
-NoReturn := "<*" Ident % setNoReturn (curproc, TRUE) %
+NoReturn := "<*" Ident % setNoReturn (curproc, TRUE) %
+ % checkReturnAttribute %
"*>" =:
+AttributeUnused := [ Unused ] =:
+
+Unused := "<*" Ident % curisused := FALSE %
+ % checkParameterAttribute %
+ "*>" =:
+
MultiFPSection := ExtendedFP | FPSection [ ";" MultiFPSection ] =:
FPSection := NonVarFPSection | VarFPSection =:
VarFPSection := "VAR" PushIdentList % VAR l, t: node ; %
":" FormalType % t := pop () %
% l := pop () %
- % addVarParameters (curproc, l, t) %
+ % curisused := TRUE %
+ [ AttributeUnused ]
+ % addVarParameters (curproc, l, t, curisused) %
=:
NonVarFPSection := PushIdentList % VAR l, t: node ; %
":" FormalType % t := pop () %
% l := pop () %
- % addNonVarParameters (curproc, l, t) %
+ % curisused := TRUE %
+ [ AttributeUnused ]
+ % addNonVarParameters (curproc, l, t, curisused) %
=:
OptArg := % VAR p, init, type: node ; id: Name ; %
AttributeNoReturn := [ "<*" Ident "*>" ] =:
+AttributeUnused := [ "<*" Ident "*>" ] =:
+
MultiFPSection := ExtendedFP | FPSection [ ";" MultiFPSection ] =:
FPSection := NonVarFPSection | VarFPSection =:
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" PushIdentList ":" FormalType =:
+VarFPSection := "VAR" PushIdentList ":" FormalType [ AttributeUnused ] =:
-NonVarFPSection := PushIdentList ":" FormalType =:
+NonVarFPSection := PushIdentList ":" FormalType [ AttributeUnused ] =:
OptArg := "[" Ident ":" FormalType [ "=" ConstExpression ] "]" =:
AttributeNoReturn := [ "<*" Ident "*>" ] =:
+AttributeUnused := [ "<*" Ident "*>" ] =:
+
DefMultiFPSection := DefExtendedFP | FPSection [ ";" DefMultiFPSection ] =:
FormalParameters := "(" % paramEnter (curproc) %
ExtendedFP := OptArg | "..." =:
-VarFPSection := "VAR" IdentList ":" FormalType
+VarFPSection := "VAR" IdentList ":" FormalType [ AttributeUnused ]
=:
-NonVarFPSection := IdentList ":" FormalType
+NonVarFPSection := IdentList ":" FormalType [ AttributeUnused ]
=:
OptArg := "[" Ident ":" FormalType [ "=" ConstExpressionNop ] "]" =:
{
while (p != NULL)
{
- printf (" _M2_%s_init(argc, argv);\n", p->functname);
+ printf (" _M2_%s_init (argc, argv, envp);\n", p->functname);
p = p->next;
}
}
{
if (p->next != NULL)
GenerateFinishCalls (p->next);
- printf (" _M2_%s_finish(argc, argv);\n", p->functname);
+ printf (" _M2_%s_finish (argc, argv, envp);\n", p->functname);
}
static void
{
if (langC)
{
- printf ("extern void _M2_%s_init(int argc, char *argv[]);\n",
+ printf ("extern void _M2_%s_init (int argc, char *argv[], char *envp[]);\n",
p->functname);
- printf ("extern void _M2_%s_finish(int argc, char *argv[]);\n",
+ printf ("extern void _M2_%s_finish (int argc, char *argv[], char *envp[]);\n",
p->functname);
}
else
{
- printf ("extern \"C\" void _M2_%s_init(int argc, char *argv[]);\n",
+ printf ("extern \"C\" void _M2_%s_init (int argc, char *argv[], char *envp[]);\n",
p->functname);
- printf ("extern \"C\" void _M2_%s_finish(int argc, char *argv[]);\n",
+ printf ("extern \"C\" void _M2_%s_finish (int argc, char *argv[], char *envp[]);\n",
p->functname);
}
p = p->next;
printf (" \"C\"");
printf (" void _exit(int);\n");
- printf ("\n\nint %s(int argc, char *argv[])\n", NameOfMain);
+ printf ("\n\nint %s(int argc, char *argv[], char *envp[])\n", NameOfMain);
printf ("{\n");
GenerateInitCalls (head);
GenerateFinishCalls (head);