LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2GCCDeclare.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 71.7 % 3044 2184
Test Date: 2025-06-21 16:26:05 Functions: 76.9 % 251 193
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* do not edit automatically generated by mc from M2GCCDeclare.  */
       2                 :             : /* M2GCCDeclare.mod declares Modula-2 types to GCC.
       3                 :             : 
       4                 :             : Copyright (C) 2001-2025 Free Software Foundation, Inc.
       5                 :             : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
       6                 :             : 
       7                 :             : This file is part of GNU Modula-2.
       8                 :             : 
       9                 :             : GNU Modula-2 is free software; you can redistribute it and/or modify
      10                 :             : it under the terms of the GNU General Public License as published by
      11                 :             : the Free Software Foundation; either version 3, or (at your option)
      12                 :             : any later version.
      13                 :             : 
      14                 :             : GNU Modula-2 is distributed in the hope that it will be useful, but
      15                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :             : General Public License for more details.
      18                 :             : 
      19                 :             : You should have received a copy of the GNU General Public License
      20                 :             : along with GNU Modula-2; see the file COPYING3.  If not see
      21                 :             : <http://www.gnu.org/licenses/>.  */
      22                 :             : 
      23                 :             : #include "config.h"
      24                 :             : #include "system.h"
      25                 :             : #include "gcc-consolidation.h"
      26                 :             : 
      27                 :             : #include <stdbool.h>
      28                 :             : #   if !defined (PROC_D)
      29                 :             : #      define PROC_D
      30                 :             :        typedef void (*PROC_t) (void);
      31                 :             :        typedef struct { PROC_t proc; } PROC;
      32                 :             : #   endif
      33                 :             : 
      34                 :             : #   if !defined (TRUE)
      35                 :             : #      define TRUE (1==1)
      36                 :             : #   endif
      37                 :             : 
      38                 :             : #   if !defined (FALSE)
      39                 :             : #      define FALSE (1==0)
      40                 :             : #   endif
      41                 :             : 
      42                 :             : #   include "GStorage.h"
      43                 :             : #   include "Gmcrts.h"
      44                 :             : #if defined(__cplusplus)
      45                 :             : #   undef NULL
      46                 :             : #   define NULL 0
      47                 :             : #endif
      48                 :             : #define _M2GCCDeclare_C
      49                 :             : 
      50                 :             : #include "GM2GCCDeclare.h"
      51                 :             : #   include "GSYSTEM.h"
      52                 :             : #   include "GASCII.h"
      53                 :             : #   include "GStorage.h"
      54                 :             : #   include "GM2Debug.h"
      55                 :             : #   include "GM2Quads.h"
      56                 :             : #   include "Gm2pp.h"
      57                 :             : #   include "GFIO.h"
      58                 :             : #   include "GM2Options.h"
      59                 :             : #   include "GM2AsmUtil.h"
      60                 :             : #   include "GM2Batch.h"
      61                 :             : #   include "GNameKey.h"
      62                 :             : #   include "GM2FileName.h"
      63                 :             : #   include "GDynamicStrings.h"
      64                 :             : #   include "GM2LexBuf.h"
      65                 :             : #   include "GM2MetaError.h"
      66                 :             : #   include "GM2Error.h"
      67                 :             : #   include "GM2LangDump.h"
      68                 :             : #   include "GM2Printf.h"
      69                 :             : #   include "GIndexing.h"
      70                 :             : #   include "GLists.h"
      71                 :             : #   include "GSets.h"
      72                 :             : #   include "GM2BasicBlock.h"
      73                 :             : #   include "GSymbolTable.h"
      74                 :             : #   include "GM2Base.h"
      75                 :             : #   include "GM2System.h"
      76                 :             : #   include "GM2Bitset.h"
      77                 :             : #   include "GSymbolConversion.h"
      78                 :             : #   include "GM2GenGCC.h"
      79                 :             : #   include "GM2Scope.h"
      80                 :             : #   include "GM2ALU.h"
      81                 :             : #   include "Ggcctypes.h"
      82                 :             : #   include "Gm2linemap.h"
      83                 :             : #   include "Gm2decl.h"
      84                 :             : #   include "Gm2type.h"
      85                 :             : #   include "Gm2convert.h"
      86                 :             : #   include "Gm2expr.h"
      87                 :             : #   include "Gm2block.h"
      88                 :             : 
      89                 :             : #   define Debugging false
      90                 :             : #   define Progress false
      91                 :             : #   define EnableSSA false
      92                 :             : #   define EnableWatch true
      93                 :             : #   define TraceQuadruples false
      94                 :             : typedef struct M2GCCDeclare_StartProcedure_p M2GCCDeclare_StartProcedure;
      95                 :             : 
      96                 :             : typedef struct M2GCCDeclare_doDeclareProcedure_p M2GCCDeclare_doDeclareProcedure;
      97                 :             : 
      98                 :             : typedef struct M2GCCDeclare__T1_r M2GCCDeclare__T1;
      99                 :             : 
     100                 :             : typedef M2GCCDeclare__T1 *M2GCCDeclare_Group;
     101                 :             : 
     102                 :             : typedef enum {M2GCCDeclare_fullydeclared, M2GCCDeclare_partiallydeclared, M2GCCDeclare_niltypedarrays, M2GCCDeclare_heldbyalignment, M2GCCDeclare_finishedalignment, M2GCCDeclare_todolist, M2GCCDeclare_tobesolvedbyquads, M2GCCDeclare_finishedsetarray} M2GCCDeclare_ListType;
     103                 :             : 
     104                 :             : typedef enum {M2GCCDeclare_norule, M2GCCDeclare_partialtype, M2GCCDeclare_arraynil, M2GCCDeclare_pointernilarray, M2GCCDeclare_arraypartial, M2GCCDeclare_pointerfully, M2GCCDeclare_recordkind, M2GCCDeclare_recordfully, M2GCCDeclare_typeconstfully, M2GCCDeclare_pointerfrompartial, M2GCCDeclare_typefrompartial, M2GCCDeclare_partialfrompartial, M2GCCDeclare_partialtofully, M2GCCDeclare_circulartodo, M2GCCDeclare_circularpartial, M2GCCDeclare_circularniltyped} M2GCCDeclare_Rule;
     105                 :             : 
     106                 :             : #   define DebugLoop 1000
     107                 :             : typedef tree (*M2GCCDeclare_StartProcedure_t) (location_t, void *);
     108                 :             : struct M2GCCDeclare_StartProcedure_p { M2GCCDeclare_StartProcedure_t proc; };
     109                 :             : 
     110                 :             : typedef void (*M2GCCDeclare_doDeclareProcedure_t) (unsigned int, unsigned int);
     111                 :             : struct M2GCCDeclare_doDeclareProcedure_p { M2GCCDeclare_doDeclareProcedure_t proc; };
     112                 :             : 
     113                 :             : struct M2GCCDeclare__T1_r {
     114                 :             :                             Sets_Set ToBeSolvedByQuads;
     115                 :             :                             Sets_Set FinishedSetArray;
     116                 :             :                             Sets_Set NilTypedArrays;
     117                 :             :                             Sets_Set FullyDeclared;
     118                 :             :                             Sets_Set PartiallyDeclared;
     119                 :             :                             Sets_Set HeldByAlignment;
     120                 :             :                             Sets_Set FinishedAlignment;
     121                 :             :                             Sets_Set ToDoList;
     122                 :             :                             M2GCCDeclare_Group Next;
     123                 :             :                           };
     124                 :             : 
     125                 :             : static M2GCCDeclare_Group FreeGroup;
     126                 :             : static M2GCCDeclare_Group GlobalGroup;
     127                 :             : static Sets_Set ErrorDepList;
     128                 :             : static Sets_Set VisitedList;
     129                 :             : static Sets_Set ChainedList;
     130                 :             : static bool HaveInitDefaultTypes;
     131                 :             : static Sets_Set WatchList;
     132                 :             : static Indexing_Index EnumerationIndex;
     133                 :             : static M2GCCDeclare_IsAction action;
     134                 :             : static bool ConstantResolved;
     135                 :             : static bool enumDeps;
     136                 :             : static M2GCCDeclare_WalkAction bodyp;
     137                 :             : static M2GCCDeclare_IsAction bodyq;
     138                 :             : static M2GCCDeclare_ListType bodyt;
     139                 :             : static M2GCCDeclare_Rule bodyr;
     140                 :             : static bool recursionCaught;
     141                 :             : static bool oneResolved;
     142                 :             : static bool noMoreWritten;
     143                 :             : static M2GCCDeclare_WalkAction unboundedp;
     144                 :             : static unsigned int MaxEnumerationField;
     145                 :             : static unsigned int MinEnumerationField;
     146                 :             : 
     147                 :             : /*
     148                 :             :    FoldConstants - a wrapper for ResolveConstantExpressions.
     149                 :             : */
     150                 :             : 
     151                 :             : extern "C" void M2GCCDeclare_FoldConstants (M2BasicBlock_BasicBlock bb);
     152                 :             : 
     153                 :             : /*
     154                 :             :    StartDeclareScope - declares types, variables associated with this scope.
     155                 :             : */
     156                 :             : 
     157                 :             : extern "C" void M2GCCDeclare_StartDeclareScope (unsigned int scope);
     158                 :             : 
     159                 :             : /*
     160                 :             :    EndDeclareScope -
     161                 :             : */
     162                 :             : 
     163                 :             : extern "C" void M2GCCDeclare_EndDeclareScope (void);
     164                 :             : 
     165                 :             : /*
     166                 :             :    DeclareParameters -
     167                 :             : */
     168                 :             : 
     169                 :             : extern "C" void M2GCCDeclare_DeclareParameters (unsigned int sym);
     170                 :             : 
     171                 :             : /*
     172                 :             :    DeclareConstant - checks to see whether, sym, is a constant and
     173                 :             :                      declares the constant to gcc.
     174                 :             : */
     175                 :             : 
     176                 :             : extern "C" void M2GCCDeclare_DeclareConstant (unsigned int tokenno, unsigned int sym);
     177                 :             : 
     178                 :             : /*
     179                 :             :    DeclareConstructor - declares a constructor.
     180                 :             : */
     181                 :             : 
     182                 :             : extern "C" void M2GCCDeclare_DeclareConstructor (unsigned int tokenno, unsigned int quad, unsigned int sym);
     183                 :             : 
     184                 :             : /*
     185                 :             :    TryDeclareConstant - try and declare a constant.  If, sym, is a
     186                 :             :                         constant try and declare it, if we cannot
     187                 :             :                         then enter it into the to do list.
     188                 :             : */
     189                 :             : 
     190                 :             : extern "C" void M2GCCDeclare_TryDeclareConstant (unsigned int tokenno, unsigned int sym);
     191                 :             : 
     192                 :             : /*
     193                 :             :    TryDeclareType - try and declare a type.  If sym is a
     194                 :             :                     type try and declare it, if we cannot
     195                 :             :                     then enter it into the to do list.
     196                 :             : */
     197                 :             : 
     198                 :             : extern "C" void M2GCCDeclare_TryDeclareType (unsigned int type);
     199                 :             : 
     200                 :             : /*
     201                 :             :    TryDeclareConstructor - try and declare a constructor.  If, sym, is a
     202                 :             :                            constructor try and declare it, if we cannot
     203                 :             :                            then enter it into the to do list.
     204                 :             : */
     205                 :             : 
     206                 :             : extern "C" void M2GCCDeclare_TryDeclareConstructor (unsigned int tokenno, unsigned int sym);
     207                 :             : 
     208                 :             : /*
     209                 :             :    DeclareLocalVariables - declares Local variables for procedure.
     210                 :             : */
     211                 :             : 
     212                 :             : extern "C" void M2GCCDeclare_DeclareLocalVariables (unsigned int procedure);
     213                 :             : 
     214                 :             : /*
     215                 :             :    DeclareLocalVariable - declare a local variable var.
     216                 :             : */
     217                 :             : 
     218                 :             : extern "C" void M2GCCDeclare_DeclareLocalVariable (unsigned int var);
     219                 :             : 
     220                 :             : /*
     221                 :             :    DeclareProcedure - declares procedure, sym, or all procedures inside
     222                 :             :                       module sym.
     223                 :             : */
     224                 :             : 
     225                 :             : extern "C" void M2GCCDeclare_DeclareProcedure (unsigned int sym);
     226                 :             : 
     227                 :             : /*
     228                 :             :    DeclareModuleVariables - declares Module variables for a module
     229                 :             :                             which was declared inside a procedure.
     230                 :             : */
     231                 :             : 
     232                 :             : extern "C" void M2GCCDeclare_DeclareModuleVariables (unsigned int sym);
     233                 :             : 
     234                 :             : /*
     235                 :             :    IsProcedureGccNested - returns TRUE if procedure, sym, will be considered
     236                 :             :                           as nested by GCC.
     237                 :             :                           This will occur if either its outer defining scope
     238                 :             :                           is a procedure or is a module which is inside a
     239                 :             :                           procedure.
     240                 :             : */
     241                 :             : 
     242                 :             : extern "C" bool M2GCCDeclare_IsProcedureGccNested (unsigned int sym);
     243                 :             : 
     244                 :             : /*
     245                 :             :    PoisonSymbols - poisons all gcc symbols from procedure, sym.
     246                 :             :                    A debugging aid.
     247                 :             : */
     248                 :             : 
     249                 :             : extern "C" void M2GCCDeclare_PoisonSymbols (unsigned int sym);
     250                 :             : 
     251                 :             : /*
     252                 :             :    PromoteToString - declare, sym, and then promote it to a string.
     253                 :             :                      Note that if sym is a single character we do
     254                 :             :                           *not* record it as a string
     255                 :             :                           but as a char however we always
     256                 :             :                           return a string constant.
     257                 :             : */
     258                 :             : 
     259                 :             : extern "C" tree M2GCCDeclare_PromoteToString (unsigned int tokenno, unsigned int sym);
     260                 :             : 
     261                 :             : /*
     262                 :             :    PromoteToCString - declare, sym, and then promote it to a string.
     263                 :             :                       Note that if sym is a single character we do
     264                 :             :                           *not* record it as a string
     265                 :             :                           but as a char however we always
     266                 :             :                           return a string constant.
     267                 :             : */
     268                 :             : 
     269                 :             : extern "C" tree M2GCCDeclare_PromoteToCString (unsigned int tokenno, unsigned int sym);
     270                 :             : 
     271                 :             : /*
     272                 :             :    CompletelyResolved - returns TRUE if a symbols has been completely resolved
     273                 :             :                         and is not partically declared (such as a record).
     274                 :             : */
     275                 :             : 
     276                 :             : extern "C" bool M2GCCDeclare_CompletelyResolved (unsigned int sym);
     277                 :             : 
     278                 :             : /*
     279                 :             :    ConstantKnownAndUsed -
     280                 :             : */
     281                 :             : 
     282                 :             : extern "C" void M2GCCDeclare_ConstantKnownAndUsed (unsigned int sym, tree t);
     283                 :             : 
     284                 :             : /*
     285                 :             :    PutToBeSolvedByQuads - places, sym, to this list and returns,
     286                 :             :                           sym.
     287                 :             : */
     288                 :             : 
     289                 :             : extern "C" void M2GCCDeclare_PutToBeSolvedByQuads (unsigned int sym);
     290                 :             : 
     291                 :             : /*
     292                 :             :    MarkExported - tell GCC to mark all exported procedures in module sym.
     293                 :             : */
     294                 :             : 
     295                 :             : extern "C" void M2GCCDeclare_MarkExported (unsigned int sym);
     296                 :             : 
     297                 :             : /*
     298                 :             :    GetTypeMin -
     299                 :             : */
     300                 :             : 
     301                 :             : extern "C" unsigned int M2GCCDeclare_GetTypeMin (unsigned int type);
     302                 :             : 
     303                 :             : /*
     304                 :             :    GetTypeMax -
     305                 :             : */
     306                 :             : 
     307                 :             : extern "C" unsigned int M2GCCDeclare_GetTypeMax (unsigned int type);
     308                 :             : 
     309                 :             : /*
     310                 :             :    PrintSym - prints limited information about a symbol.
     311                 :             :               This procedure is externally visible.
     312                 :             : */
     313                 :             : 
     314                 :             : extern "C" void M2GCCDeclare_PrintSym (unsigned int sym);
     315                 :             : 
     316                 :             : /*
     317                 :             :    IncludeDumpSymbol - include sym into the watch list and all syms dependants.
     318                 :             : */
     319                 :             : 
     320                 :             : extern "C" void M2GCCDeclare_IncludeDumpSymbol (unsigned int sym);
     321                 :             : 
     322                 :             : /*
     323                 :             :    DumpFilteredResolver - dumps the gimple or tree representation of all watched symbols.
     324                 :             : */
     325                 :             : 
     326                 :             : extern "C" void M2GCCDeclare_DumpFilteredResolver (void);
     327                 :             : 
     328                 :             : /*
     329                 :             :    DumpFilteredDefinitive - dumps the gimple or tree representation of all watched symbols.
     330                 :             : */
     331                 :             : 
     332                 :             : extern "C" void M2GCCDeclare_DumpFilteredDefinitive (void);
     333                 :             : 
     334                 :             : /*
     335                 :             :    InitDeclarations - initializes default types and the source filename.
     336                 :             : */
     337                 :             : 
     338                 :             : extern "C" void M2GCCDeclare_InitDeclarations (void);
     339                 :             : 
     340                 :             : /*
     341                 :             :    PrintNum -
     342                 :             : */
     343                 :             : 
     344                 :             : static void PrintNum (unsigned int sym);
     345                 :             : 
     346                 :             : /*
     347                 :             :    DebugSet -
     348                 :             : */
     349                 :             : 
     350                 :             : static void DebugSet (const char *a_, unsigned int _a_high, Sets_Set l);
     351                 :             : 
     352                 :             : /*
     353                 :             :    DebugSets -
     354                 :             : */
     355                 :             : 
     356                 :             : static void DebugSets (void);
     357                 :             : 
     358                 :             : /*
     359                 :             :    DebugNumber -
     360                 :             : */
     361                 :             : 
     362                 :             : static void DebugNumber (const char *a_, unsigned int _a_high, Sets_Set s);
     363                 :             : static void DebugSetNumbers (void);
     364                 :             : 
     365                 :             : /*
     366                 :             :    AddSymToWatch - adds symbol, sym, to the list of symbols
     367                 :             :                    to watch and annotate their movement between
     368                 :             :                    lists.
     369                 :             : */
     370                 :             : 
     371                 :             : static void AddSymToWatch (unsigned int sym);
     372                 :             : 
     373                 :             : /*
     374                 :             :    doInclude -
     375                 :             : */
     376                 :             : 
     377                 :             : static void doInclude (Sets_Set l, const char *a_, unsigned int _a_high, unsigned int sym);
     378                 :             : 
     379                 :             : /*
     380                 :             :    WatchIncludeList - include a symbol onto the set first checking
     381                 :             :                       whether it is already on the set and
     382                 :             :                       displaying a debug message if the set is
     383                 :             :                       changed.
     384                 :             : */
     385                 :             : 
     386                 :             : static void WatchIncludeList (unsigned int sym, M2GCCDeclare_ListType lt);
     387                 :             : 
     388                 :             : /*
     389                 :             :    doExclude -
     390                 :             : */
     391                 :             : 
     392                 :             : static void doExclude (Sets_Set l, const char *a_, unsigned int _a_high, unsigned int sym);
     393                 :             : 
     394                 :             : /*
     395                 :             :    WatchRemoveList - remove a symbol onto the list first checking
     396                 :             :                      whether it is already on the list and
     397                 :             :                      displaying a debug message if the list is
     398                 :             :                      changed.
     399                 :             : */
     400                 :             : 
     401                 :             : static void WatchRemoveList (unsigned int sym, M2GCCDeclare_ListType lt);
     402                 :             : 
     403                 :             : /*
     404                 :             :    NewGroup -
     405                 :             : */
     406                 :             : 
     407                 :             : static void NewGroup (M2GCCDeclare_Group *g);
     408                 :             : 
     409                 :             : /*
     410                 :             :    DisposeGroup -
     411                 :             : */
     412                 :             : 
     413                 :             : static void DisposeGroup (M2GCCDeclare_Group *g);
     414                 :             : 
     415                 :             : /*
     416                 :             :    InitGroup - initialize all sets in group and return the group.
     417                 :             : */
     418                 :             : 
     419                 :             : static M2GCCDeclare_Group InitGroup (void);
     420                 :             : 
     421                 :             : /*
     422                 :             :    KillGroup - delete all sets in group and deallocate g.
     423                 :             : */
     424                 :             : 
     425                 :             : static void KillGroup (M2GCCDeclare_Group *g);
     426                 :             : 
     427                 :             : /*
     428                 :             :    DupGroup - If g is not NIL then destroy g.
     429                 :             :               Return a duplicate of GlobalGroup.
     430                 :             : */
     431                 :             : 
     432                 :             : static M2GCCDeclare_Group DupGroup (M2GCCDeclare_Group g);
     433                 :             : 
     434                 :             : /*
     435                 :             :    EqualGroup - return TRUE if group left = right.
     436                 :             : */
     437                 :             : 
     438                 :             : static bool EqualGroup (M2GCCDeclare_Group left, M2GCCDeclare_Group right);
     439                 :             : 
     440                 :             : /*
     441                 :             :    LookupSet -
     442                 :             : */
     443                 :             : 
     444                 :             : static Sets_Set LookupSet (M2GCCDeclare_ListType listtype);
     445                 :             : 
     446                 :             : /*
     447                 :             :    GetEnumList -
     448                 :             : */
     449                 :             : 
     450                 :             : static tree GetEnumList (unsigned int sym);
     451                 :             : 
     452                 :             : /*
     453                 :             :    PutEnumList -
     454                 :             : */
     455                 :             : 
     456                 :             : static void PutEnumList (unsigned int sym, tree enumlist);
     457                 :             : 
     458                 :             : /*
     459                 :             :    Chained - checks to see that, sym, has not already been placed on a chain.
     460                 :             :              It returns the symbol, sym.
     461                 :             : */
     462                 :             : 
     463                 :             : static unsigned int Chained (unsigned int sym);
     464                 :             : 
     465                 :             : /*
     466                 :             :    DoStartDeclaration - returns a tree representing a symbol which has
     467                 :             :                         not yet been finished.  Used when declaring
     468                 :             :                         recursive types.
     469                 :             : */
     470                 :             : 
     471                 :             : static tree DoStartDeclaration (unsigned int sym, M2GCCDeclare_StartProcedure p);
     472                 :             : 
     473                 :             : /*
     474                 :             :    ArrayComponentsDeclared - returns TRUE if array, sym,
     475                 :             :                              subscripts and type are known.
     476                 :             : */
     477                 :             : 
     478                 :             : static bool ArrayComponentsDeclared (unsigned int sym);
     479                 :             : 
     480                 :             : /*
     481                 :             :    GetRecordOfVarient -
     482                 :             : */
     483                 :             : 
     484                 :             : static unsigned int GetRecordOfVarient (unsigned int sym);
     485                 :             : 
     486                 :             : /*
     487                 :             :    CanDeclareRecordKind -
     488                 :             : */
     489                 :             : 
     490                 :             : static bool CanDeclareRecordKind (unsigned int sym);
     491                 :             : 
     492                 :             : /*
     493                 :             :    DeclareRecordKind - works out whether record, sym, is packed or not.
     494                 :             : */
     495                 :             : 
     496                 :             : static void DeclareRecordKind (unsigned int sym);
     497                 :             : 
     498                 :             : /*
     499                 :             :    CanDeclareRecord -
     500                 :             : */
     501                 :             : 
     502                 :             : static bool CanDeclareRecord (unsigned int sym);
     503                 :             : 
     504                 :             : /*
     505                 :             :    FinishDeclareRecord -
     506                 :             : */
     507                 :             : 
     508                 :             : static void FinishDeclareRecord (unsigned int sym);
     509                 :             : 
     510                 :             : /*
     511                 :             :    CanDeclareTypePartially - return TRUE if we are able to make a
     512                 :             :                              gcc partially created type.
     513                 :             : */
     514                 :             : 
     515                 :             : static bool CanDeclareTypePartially (unsigned int sym);
     516                 :             : 
     517                 :             : /*
     518                 :             :    DeclareTypePartially - create the gcc partial type symbol from, sym.
     519                 :             : */
     520                 :             : 
     521                 :             : static void DeclareTypePartially (unsigned int sym);
     522                 :             : 
     523                 :             : /*
     524                 :             :    CanDeclareArrayAsNil -
     525                 :             : */
     526                 :             : 
     527                 :             : static bool CanDeclareArrayAsNil (unsigned int sym);
     528                 :             : 
     529                 :             : /*
     530                 :             :    DeclareArrayAsNil -
     531                 :             : */
     532                 :             : 
     533                 :             : static void DeclareArrayAsNil (unsigned int sym);
     534                 :             : 
     535                 :             : /*
     536                 :             :    CanDeclareArrayPartially -
     537                 :             : */
     538                 :             : 
     539                 :             : static bool CanDeclareArrayPartially (unsigned int sym);
     540                 :             : 
     541                 :             : /*
     542                 :             :    DeclareArrayPartially -
     543                 :             : */
     544                 :             : 
     545                 :             : static void DeclareArrayPartially (unsigned int sym);
     546                 :             : 
     547                 :             : /*
     548                 :             :    CanDeclarePointerToNilArray -
     549                 :             : */
     550                 :             : 
     551                 :             : static bool CanDeclarePointerToNilArray (unsigned int sym);
     552                 :             : 
     553                 :             : /*
     554                 :             :    DeclarePointerToNilArray -
     555                 :             : */
     556                 :             : 
     557                 :             : static void DeclarePointerToNilArray (unsigned int sym);
     558                 :             : 
     559                 :             : /*
     560                 :             :    CanPromotePointerFully -
     561                 :             : */
     562                 :             : 
     563                 :             : static bool CanPromotePointerFully (unsigned int sym);
     564                 :             : 
     565                 :             : /*
     566                 :             :    PromotePointerFully -
     567                 :             : */
     568                 :             : 
     569                 :             : static void PromotePointerFully (unsigned int sym);
     570                 :             : 
     571                 :             : /*
     572                 :             :    IsTypeQ - returns TRUE if all q(dependants) of, sym,
     573                 :             :              return TRUE.
     574                 :             : */
     575                 :             : 
     576                 :             : static bool IsTypeQ (unsigned int sym, M2GCCDeclare_IsAction q);
     577                 :             : 
     578                 :             : /*
     579                 :             :    IsNilTypedArrays - returns TRUE if, sym, is dependant upon a NIL typed array
     580                 :             : */
     581                 :             : 
     582                 :             : static bool IsNilTypedArrays (unsigned int sym);
     583                 :             : 
     584                 :             : /*
     585                 :             :    IsFullyDeclared - returns TRUE if, sym, is fully declared.
     586                 :             : */
     587                 :             : 
     588                 :             : static bool IsFullyDeclared (unsigned int sym);
     589                 :             : 
     590                 :             : /*
     591                 :             :    AllDependantsFullyDeclared - returns TRUE if all dependants of,
     592                 :             :                                 sym, are declared.
     593                 :             : */
     594                 :             : 
     595                 :             : static bool AllDependantsFullyDeclared (unsigned int sym);
     596                 :             : 
     597                 :             : /*
     598                 :             :    NotAllDependantsFullyDeclared - returns TRUE if any dependants of,
     599                 :             :                                    sym, are not declared.
     600                 :             : */
     601                 :             : 
     602                 :             : static bool NotAllDependantsFullyDeclared (unsigned int sym);
     603                 :             : 
     604                 :             : /*
     605                 :             :    IsPartiallyDeclared - returns TRUE if, sym, is partially declared.
     606                 :             : */
     607                 :             : 
     608                 :             : static bool IsPartiallyDeclared (unsigned int sym);
     609                 :             : 
     610                 :             : /*
     611                 :             :    AllDependantsPartiallyDeclared - returns TRUE if all dependants of,
     612                 :             :                                     sym, are partially declared.
     613                 :             : */
     614                 :             : 
     615                 :             : static bool AllDependantsPartiallyDeclared (unsigned int sym);
     616                 :             : 
     617                 :             : /*
     618                 :             :    NotAllDependantsPartiallyDeclared - returns TRUE if any dependants of,
     619                 :             :                                        sym, are not partially declared.
     620                 :             : */
     621                 :             : 
     622                 :             : static bool NotAllDependantsPartiallyDeclared (unsigned int sym);
     623                 :             : 
     624                 :             : /*
     625                 :             :    IsPartiallyOrFullyDeclared - returns TRUE if, sym, is partially or fully declared.
     626                 :             : */
     627                 :             : 
     628                 :             : static bool IsPartiallyOrFullyDeclared (unsigned int sym);
     629                 :             : 
     630                 :             : /*
     631                 :             :    AllDependantsPartiallyOrFullyDeclared - returns TRUE if all dependants of,
     632                 :             :                                            sym, are partially or fully declared.
     633                 :             : */
     634                 :             : 
     635                 :             : static bool AllDependantsPartiallyOrFullyDeclared (unsigned int sym);
     636                 :             : 
     637                 :             : /*
     638                 :             :    TypeConstDependantsFullyDeclared - returns TRUE if sym is a constant or
     639                 :             :                                       type and its dependants are fully
     640                 :             :                                       declared.
     641                 :             : */
     642                 :             : 
     643                 :             : static bool TypeConstDependantsFullyDeclared (unsigned int sym);
     644                 :             : 
     645                 :             : /*
     646                 :             :    CanBeDeclaredViaPartialDependants - returns TRUE if this symbol
     647                 :             :                                        can be declared by partial
     648                 :             :                                        dependants.  Such a symbol must
     649                 :             :                                        be a record, proctype or
     650                 :             :                                        an array.
     651                 :             : */
     652                 :             : 
     653                 :             : static bool CanBeDeclaredViaPartialDependants (unsigned int sym);
     654                 :             : 
     655                 :             : /*
     656                 :             :    DeclareConstFully - will add, sym, to the fully declared list and
     657                 :             :                        also remove it from the to do list.  This is
     658                 :             :                        called indirectly from M2GenGCC as it calculates
     659                 :             :                        constants during quadruple processing.
     660                 :             : */
     661                 :             : 
     662                 :             : static void DeclareConstFully (unsigned int sym);
     663                 :             : 
     664                 :             : /*
     665                 :             :    DeclareTypeConstFully - declare the GCC type and add the double
     666                 :             :                            book keeping entry.
     667                 :             : */
     668                 :             : 
     669                 :             : static void DeclareTypeConstFully (unsigned int sym);
     670                 :             : 
     671                 :             : /*
     672                 :             :    DeclareTypeFromPartial - declare the full GCC type from a partial type
     673                 :             :                             and add the double book keeping entry.
     674                 :             : */
     675                 :             : 
     676                 :             : static void DeclareTypeFromPartial (unsigned int sym);
     677                 :             : 
     678                 :             : /*
     679                 :             :    CanBeDeclaredPartiallyViaPartialDependants - returns TRUE if, sym,
     680                 :             :                                                 can be partially declared via
     681                 :             :                                                 another partially declared type.
     682                 :             : */
     683                 :             : 
     684                 :             : static bool CanBeDeclaredPartiallyViaPartialDependants (unsigned int sym);
     685                 :             : 
     686                 :             : /*
     687                 :             :    EmitCircularDependencyError - issue a dependency error.
     688                 :             : */
     689                 :             : 
     690                 :             : static void EmitCircularDependencyError (unsigned int sym);
     691                 :             : 
     692                 :             : /*
     693                 :             :    WriteRule - writes out the name of the rule.
     694                 :             : */
     695                 :             : 
     696                 :             : static void WriteRule (void);
     697                 :             : 
     698                 :             : /*
     699                 :             :    Body -
     700                 :             : */
     701                 :             : 
     702                 :             : static void Body (unsigned int sym);
     703                 :             : 
     704                 :             : /*
     705                 :             :    ForeachTryDeclare - while q (of one sym in set t) is true
     706                 :             :                           for each symbol in set t,
     707                 :             :                              if q (sym)
     708                 :             :                              then
     709                 :             :                                 p (sym)
     710                 :             :                              end
     711                 :             :                           end
     712                 :             :                        end
     713                 :             : */
     714                 :             : 
     715                 :             : static bool ForeachTryDeclare (M2GCCDeclare_ListType t, M2GCCDeclare_Rule r, M2GCCDeclare_IsAction q, M2GCCDeclare_WalkAction p);
     716                 :             : static bool DeclaredOutstandingTypes (bool ForceComplete);
     717                 :             : 
     718                 :             : /*
     719                 :             :    CompleteDeclarationOf - returns the GCC Tree for, sym, if it can
     720                 :             :                            be created from partially or fully declared
     721                 :             :                            dependents.
     722                 :             : */
     723                 :             : 
     724                 :             : static tree CompleteDeclarationOf (unsigned int sym);
     725                 :             : 
     726                 :             : /*
     727                 :             :    DeclareType - here a type has been created via TYPE foo = bar,
     728                 :             :                  we must tell GCC about it.
     729                 :             : */
     730                 :             : 
     731                 :             : static tree DeclareType (unsigned int sym);
     732                 :             : static void DeclareConstantFromTree (unsigned int sym, tree value);
     733                 :             : 
     734                 :             : /*
     735                 :             :    DeclareCharConstant - declares a character constant.
     736                 :             : */
     737                 :             : 
     738                 :             : static void DeclareCharConstant (unsigned int tokenno, unsigned int sym);
     739                 :             : 
     740                 :             : /*
     741                 :             :    DeclareStringConstant - declares a string constant the sym will be known.
     742                 :             : */
     743                 :             : 
     744                 :             : static void DeclareStringConstant (unsigned int tokenno, unsigned int sym);
     745                 :             : 
     746                 :             : /*
     747                 :             :    WalkConstructor - walks all dependants of, sym.
     748                 :             : */
     749                 :             : 
     750                 :             : static void WalkConstructor (unsigned int sym, M2GCCDeclare_WalkAction p);
     751                 :             : 
     752                 :             : /*
     753                 :             :    WalkConst - walks all dependants of, sym.
     754                 :             : */
     755                 :             : 
     756                 :             : static void WalkConst (unsigned int sym, M2GCCDeclare_WalkAction p);
     757                 :             : 
     758                 :             : /*
     759                 :             :    IsConstDependants - returns TRUE if the symbol, sym,
     760                 :             :                        q(dependants) all return TRUE.
     761                 :             : */
     762                 :             : 
     763                 :             : static bool IsConstDependants (unsigned int sym, M2GCCDeclare_IsAction q);
     764                 :             : 
     765                 :             : /*
     766                 :             :    IsAnyType - return TRUE if sym is any Modula-2 type.
     767                 :             : */
     768                 :             : 
     769                 :             : static bool IsAnyType (unsigned int sym);
     770                 :             : 
     771                 :             : /*
     772                 :             :    DeclareConstString -
     773                 :             : */
     774                 :             : 
     775                 :             : static bool DeclareConstString (unsigned int tokenno, unsigned int sym);
     776                 :             : 
     777                 :             : /*
     778                 :             :    TryDeclareConst - try to declare a const to gcc.  If it cannot
     779                 :             :                      declare the symbol it places it into the
     780                 :             :                      todolist.
     781                 :             : */
     782                 :             : 
     783                 :             : static void TryDeclareConst (unsigned int tokenno, unsigned int sym);
     784                 :             : 
     785                 :             : /*
     786                 :             :    DeclareConst - declares a const to gcc and returns a Tree.
     787                 :             : */
     788                 :             : 
     789                 :             : static tree DeclareConst (unsigned int tokenno, unsigned int sym);
     790                 :             : 
     791                 :             : /*
     792                 :             :    WalkFamilyOfUnbounded -
     793                 :             : */
     794                 :             : 
     795                 :             : static void WalkFamilyOfUnbounded (unsigned int oaf __attribute__((unused)), unsigned int dim __attribute__((unused)), unsigned int unbounded);
     796                 :             : 
     797                 :             : /*
     798                 :             :    WalkAssociatedUnbounded -
     799                 :             : */
     800                 :             : 
     801                 :             : static void WalkAssociatedUnbounded (unsigned int sym, M2GCCDeclare_WalkAction p);
     802                 :             : 
     803                 :             : /*
     804                 :             :    WalkDependants - walks through all dependants of, Sym,
     805                 :             :                     calling, p, for each dependant.
     806                 :             : */
     807                 :             : 
     808                 :             : static void WalkDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
     809                 :             : 
     810                 :             : /*
     811                 :             :    TraverseDependantsInner -
     812                 :             : */
     813                 :             : 
     814                 :             : static void TraverseDependantsInner (unsigned int sym);
     815                 :             : 
     816                 :             : /*
     817                 :             :    TraverseDependants - walks, sym, dependants.  But it checks
     818                 :             :                         to see that, sym, is not on the
     819                 :             :                         FullyDeclared and not on the ToDoList.
     820                 :             : */
     821                 :             : 
     822                 :             : static void TraverseDependants (unsigned int sym);
     823                 :             : 
     824                 :             : /*
     825                 :             :    WalkTypeInfo - walks type, sym, and its dependants.
     826                 :             : */
     827                 :             : 
     828                 :             : static void WalkTypeInfo (unsigned int sym);
     829                 :             : 
     830                 :             : /*
     831                 :             :    DeclareUnboundedProcedureParameters -
     832                 :             : */
     833                 :             : 
     834                 :             : static void DeclareUnboundedProcedureParameters (unsigned int sym);
     835                 :             : 
     836                 :             : /*
     837                 :             :    WalkUnboundedProcedureParameters -
     838                 :             : */
     839                 :             : 
     840                 :             : static void WalkUnboundedProcedureParameters (unsigned int sym);
     841                 :             : 
     842                 :             : /*
     843                 :             :    WalkTypesInProcedure - walk all types in procedure, Sym.
     844                 :             : */
     845                 :             : 
     846                 :             : static void WalkTypesInProcedure (unsigned int sym);
     847                 :             : 
     848                 :             : /*
     849                 :             :    WalkTypesInModule - declare all types in module, Sym, to GCC.
     850                 :             : */
     851                 :             : 
     852                 :             : static void WalkTypesInModule (unsigned int sym);
     853                 :             : 
     854                 :             : /*
     855                 :             :    IsRecordFieldDependants - returns TRUE if the record field
     856                 :             :                              symbol, sym, p(dependants) all return TRUE.
     857                 :             : */
     858                 :             : 
     859                 :             : static bool IsRecordFieldDependants (unsigned int sym, M2GCCDeclare_IsAction q);
     860                 :             : 
     861                 :             : /*
     862                 :             :    GetModuleWhereDeclared - returns the module where, Sym, was created.
     863                 :             : */
     864                 :             : 
     865                 :             : static unsigned int GetModuleWhereDeclared (unsigned int sym);
     866                 :             : 
     867                 :             : /*
     868                 :             :    IsPseudoProcFunc - returns TRUE if Sym is a pseudo function or procedure.
     869                 :             : */
     870                 :             : 
     871                 :             : static bool IsPseudoProcFunc (unsigned int Sym);
     872                 :             : 
     873                 :             : /*
     874                 :             :    IsExternal -
     875                 :             : */
     876                 :             : 
     877                 :             : static bool IsExternal (unsigned int sym);
     878                 :             : 
     879                 :             : /*
     880                 :             :    IsExternalToWholeProgram - return TRUE if the symbol, sym, is external to the
     881                 :             :                               sources that we have parsed.
     882                 :             : */
     883                 :             : 
     884                 :             : static bool IsExternalToWholeProgram (unsigned int sym);
     885                 :             : 
     886                 :             : /*
     887                 :             :    DeclareProcedureToGccWholeProgram -
     888                 :             : */
     889                 :             : 
     890                 :             : static void DeclareProcedureToGccWholeProgram (unsigned int Sym);
     891                 :             : 
     892                 :             : /*
     893                 :             :    DeclareProcedureToGccSeparateProgram -
     894                 :             : */
     895                 :             : 
     896                 :             : static void DeclareProcedureToGccSeparateProgram (unsigned int Sym);
     897                 :             : 
     898                 :             : /*
     899                 :             :    DeclareProcedureToGcc - traverses all parameters and interfaces to gm2gcc.
     900                 :             : */
     901                 :             : 
     902                 :             : static void DeclareProcedureToGcc (unsigned int sym);
     903                 :             : 
     904                 :             : /*
     905                 :             :    ActivateWatch - activate a watch for any symbol (lista xor listb).
     906                 :             : */
     907                 :             : 
     908                 :             : static void ActivateWatch (Sets_Set lista, Sets_Set listb);
     909                 :             : 
     910                 :             : /*
     911                 :             :    DeclareTypesConstantsProceduresInRange -
     912                 :             : */
     913                 :             : 
     914                 :             : static void DeclareTypesConstantsProceduresInRange (unsigned int scope, unsigned int start, unsigned int end);
     915                 :             : 
     916                 :             : /*
     917                 :             :    SkipModuleScope - skips all module scopes for, scope.
     918                 :             :                      It returns either NulSym or a procedure sym.
     919                 :             : */
     920                 :             : 
     921                 :             : static unsigned int SkipModuleScope (unsigned int scope);
     922                 :             : 
     923                 :             : /*
     924                 :             :    PushBinding -
     925                 :             : */
     926                 :             : 
     927                 :             : static void PushBinding (unsigned int scope);
     928                 :             : 
     929                 :             : /*
     930                 :             :    PopBinding -
     931                 :             : */
     932                 :             : 
     933                 :             : static void PopBinding (unsigned int scope);
     934                 :             : 
     935                 :             : /*
     936                 :             :    DeclareTypesConstantsProcedures -
     937                 :             : */
     938                 :             : 
     939                 :             : static void DeclareTypesConstantsProcedures (unsigned int scope);
     940                 :             : 
     941                 :             : /*
     942                 :             :    AssertAllTypesDeclared - asserts that all types for variables are declared in, scope.
     943                 :             : */
     944                 :             : 
     945                 :             : static void AssertAllTypesDeclared (unsigned int scope);
     946                 :             : 
     947                 :             : /*
     948                 :             :    DeclareModuleInit - declare all the ctor related functions within
     949                 :             :                        a module.
     950                 :             : */
     951                 :             : 
     952                 :             : static void DeclareModuleInit (unsigned int moduleSym);
     953                 :             : 
     954                 :             : /*
     955                 :             :    StartDeclareProcedureScope -
     956                 :             : */
     957                 :             : 
     958                 :             : static void StartDeclareProcedureScope (unsigned int scope);
     959                 :             : 
     960                 :             : /*
     961                 :             :    StartDeclareModuleScopeSeparate -
     962                 :             : */
     963                 :             : 
     964                 :             : static void StartDeclareModuleScopeSeparate (unsigned int scope);
     965                 :             : 
     966                 :             : /*
     967                 :             :    StartDeclareModuleScopeWholeProgram -
     968                 :             : */
     969                 :             : 
     970                 :             : static void StartDeclareModuleScopeWholeProgram (unsigned int scope);
     971                 :             : 
     972                 :             : /*
     973                 :             :    StartDeclareModuleScope -
     974                 :             : */
     975                 :             : 
     976                 :             : static void StartDeclareModuleScope (unsigned int scope);
     977                 :             : 
     978                 :             : /*
     979                 :             :    DumpResolver - dumps the m2 representation of sym.
     980                 :             : */
     981                 :             : 
     982                 :             : static void DumpResolver (unsigned int sym);
     983                 :             : 
     984                 :             : /*
     985                 :             :    DumpDefinitive - dumps the m2 and m2 gimple representation of sym.
     986                 :             : */
     987                 :             : 
     988                 :             : static void DumpDefinitive (unsigned int sym);
     989                 :             : 
     990                 :             : /*
     991                 :             :    PreAddModGcc - adds a relationship between sym and tree.
     992                 :             : */
     993                 :             : 
     994                 :             : static void PreAddModGcc (unsigned int sym, tree tree);
     995                 :             : 
     996                 :             : /*
     997                 :             :    DeclareDefaultType - declares a default type, sym, with, name.
     998                 :             : */
     999                 :             : 
    1000                 :             : static void DeclareDefaultType (unsigned int sym, const char *name_, unsigned int _name_high, tree gcctype);
    1001                 :             : 
    1002                 :             : /*
    1003                 :             :    DeclareBoolean - declares the Boolean type together with true and false.
    1004                 :             : */
    1005                 :             : 
    1006                 :             : static void DeclareBoolean (void);
    1007                 :             : 
    1008                 :             : /*
    1009                 :             :    DeclareFixedSizedType - declares the GNU Modula-2 fixed types
    1010                 :             :                            (if the back end support such a type).
    1011                 :             : */
    1012                 :             : 
    1013                 :             : static void DeclareFixedSizedType (const char *name_, unsigned int _name_high, unsigned int type, tree t);
    1014                 :             : 
    1015                 :             : /*
    1016                 :             :    DeclareDefaultSimpleTypes - declares the simple types.
    1017                 :             : */
    1018                 :             : 
    1019                 :             : static void DeclareDefaultSimpleTypes (void);
    1020                 :             : 
    1021                 :             : /*
    1022                 :             :    DeclarePackedBoolean -
    1023                 :             : */
    1024                 :             : 
    1025                 :             : static void DeclarePackedBoolean (void);
    1026                 :             : 
    1027                 :             : /*
    1028                 :             :    DeclarePackedDefaultSimpleTypes -
    1029                 :             : */
    1030                 :             : 
    1031                 :             : static void DeclarePackedDefaultSimpleTypes (void);
    1032                 :             : 
    1033                 :             : /*
    1034                 :             :    DeclareDefaultTypes - makes default types known to GCC
    1035                 :             : */
    1036                 :             : 
    1037                 :             : static void DeclareDefaultTypes (void);
    1038                 :             : 
    1039                 :             : /*
    1040                 :             :    DeclareDefaultConstants - make default constants known to GCC
    1041                 :             : */
    1042                 :             : 
    1043                 :             : static void DeclareDefaultConstants (void);
    1044                 :             : 
    1045                 :             : /*
    1046                 :             :    FindContext - returns the scope where the symbol
    1047                 :             :                  should be created.
    1048                 :             : 
    1049                 :             :                  Symbols created in a module will
    1050                 :             :                  return the global context tree, but symbols created
    1051                 :             :                  in a module which is declared inside
    1052                 :             :                  a procedure will return the procedure Tree.
    1053                 :             : */
    1054                 :             : 
    1055                 :             : static tree FindContext (unsigned int sym);
    1056                 :             : 
    1057                 :             : /*
    1058                 :             :    IsEffectivelyImported - returns TRUE if symbol, Sym, was
    1059                 :             :                            effectively imported into ModSym.
    1060                 :             : */
    1061                 :             : 
    1062                 :             : static bool IsEffectivelyImported (unsigned int ModSym, unsigned int sym);
    1063                 :             : 
    1064                 :             : /*
    1065                 :             :    FindOuterModule - returns the out most module where, sym,
    1066                 :             :                      was declared.  It returns NulSym if the
    1067                 :             :                      symbol or the module was declared inside
    1068                 :             :                      a procedure.
    1069                 :             : */
    1070                 :             : 
    1071                 :             : static unsigned int FindOuterModule (unsigned int sym);
    1072                 :             : 
    1073                 :             : /*
    1074                 :             :    DoVariableDeclaration - create a corresponding gcc variable and add the association
    1075                 :             :                            between the front end symbol var and the gcc tree.
    1076                 :             : */
    1077                 :             : 
    1078                 :             : static void DoVariableDeclaration (unsigned int var, void * name, bool isImported, bool isExported, bool isTemporary, bool isGlobal, tree scope);
    1079                 :             : 
    1080                 :             : /*
    1081                 :             :    TypeDependentsDeclared - return TRUE if all type dependents of variable
    1082                 :             :                             have been declared.
    1083                 :             : */
    1084                 :             : 
    1085                 :             : static bool TypeDependentsDeclared (unsigned int variable, bool errorMessage);
    1086                 :             : 
    1087                 :             : /*
    1088                 :             :    PrepareGCCVarDeclaration -
    1089                 :             : */
    1090                 :             : 
    1091                 :             : static void PrepareGCCVarDeclaration (unsigned int var, void * name, bool isImported, bool isExported, bool isTemporary, bool isGlobal, tree scope);
    1092                 :             : 
    1093                 :             : /*
    1094                 :             :    IsGlobal - is the variable not in a procedure scope.
    1095                 :             : */
    1096                 :             : 
    1097                 :             : static bool IsGlobal (unsigned int sym);
    1098                 :             : 
    1099                 :             : /*
    1100                 :             :    DeclareVariable - declares a global variable to GCC.
    1101                 :             : */
    1102                 :             : 
    1103                 :             : static void DeclareVariable (unsigned int ModSym, unsigned int variable);
    1104                 :             : 
    1105                 :             : /*
    1106                 :             :    DeclareVariableWholeProgram - declares a global variable to GCC when using -fm2-whole-program.
    1107                 :             : */
    1108                 :             : 
    1109                 :             : static void DeclareVariableWholeProgram (unsigned int mainModule, unsigned int variable);
    1110                 :             : 
    1111                 :             : /*
    1112                 :             :    DeclareGlobalVariablesWholeProgram -
    1113                 :             : */
    1114                 :             : 
    1115                 :             : static void DeclareGlobalVariablesWholeProgram (unsigned int ModSym);
    1116                 :             : 
    1117                 :             : /*
    1118                 :             :    DeclareGlobalVariables - lists the Global variables for
    1119                 :             :                             Module ModSym together with their offset.
    1120                 :             : */
    1121                 :             : 
    1122                 :             : static void DeclareGlobalVariables (unsigned int ModSym);
    1123                 :             : 
    1124                 :             : /*
    1125                 :             :    DeclareImportedVariables - declares all imported variables to GM2.
    1126                 :             : */
    1127                 :             : 
    1128                 :             : static void DeclareImportedVariables (unsigned int sym);
    1129                 :             : 
    1130                 :             : /*
    1131                 :             :    DeclareImportedVariablesWholeProgram - declares all imported variables.
    1132                 :             : */
    1133                 :             : 
    1134                 :             : static void DeclareImportedVariablesWholeProgram (unsigned int sym);
    1135                 :             : 
    1136                 :             : /*
    1137                 :             :    DeclareFieldValue -
    1138                 :             : */
    1139                 :             : 
    1140                 :             : static tree DeclareFieldValue (unsigned int sym, tree value, tree *list);
    1141                 :             : 
    1142                 :             : /*
    1143                 :             :    DeclareFieldEnumeration - declares an enumerator within the current enumeration type.
    1144                 :             : */
    1145                 :             : 
    1146                 :             : static tree DeclareFieldEnumeration (unsigned int sym);
    1147                 :             : 
    1148                 :             : /*
    1149                 :             :    DeclareEnumeration - declare an enumerated type.
    1150                 :             : */
    1151                 :             : 
    1152                 :             : static tree DeclareEnumeration (unsigned int sym);
    1153                 :             : 
    1154                 :             : /*
    1155                 :             :    DeclareSubrangeNarrow - will return cardinal, integer, or type depending on whether
    1156                 :             :                            low..high fits in the C data type.
    1157                 :             : */
    1158                 :             : 
    1159                 :             : static tree DeclareSubrangeNarrow (location_t location, unsigned int high, unsigned int low, tree type);
    1160                 :             : 
    1161                 :             : /*
    1162                 :             :    DeclareSubrange - declare a subrange type.
    1163                 :             : */
    1164                 :             : 
    1165                 :             : static tree DeclareSubrange (unsigned int sym);
    1166                 :             : 
    1167                 :             : /*
    1168                 :             :    IncludeGetNth -
    1169                 :             : */
    1170                 :             : 
    1171                 :             : static void IncludeGetNth (Lists_List l, unsigned int sym);
    1172                 :             : 
    1173                 :             : /*
    1174                 :             :    IncludeType -
    1175                 :             : */
    1176                 :             : 
    1177                 :             : static void IncludeType (Lists_List l, unsigned int sym);
    1178                 :             : 
    1179                 :             : /*
    1180                 :             :    IncludeSubscript -
    1181                 :             : */
    1182                 :             : 
    1183                 :             : static void IncludeSubscript (Lists_List l, unsigned int sym);
    1184                 :             : 
    1185                 :             : /*
    1186                 :             :    PrintLocalSymbol -
    1187                 :             : */
    1188                 :             : 
    1189                 :             : static void PrintLocalSymbol (unsigned int sym);
    1190                 :             : 
    1191                 :             : /*
    1192                 :             :    PrintLocalSymbols -
    1193                 :             : */
    1194                 :             : 
    1195                 :             : static void PrintLocalSymbols (unsigned int sym);
    1196                 :             : 
    1197                 :             : /*
    1198                 :             :    IncludeGetVarient -
    1199                 :             : */
    1200                 :             : 
    1201                 :             : static void IncludeGetVarient (Lists_List l, unsigned int sym);
    1202                 :             : 
    1203                 :             : /*
    1204                 :             :    IncludeUnbounded - includes the record component of an unbounded type.
    1205                 :             : */
    1206                 :             : 
    1207                 :             : static void IncludeUnbounded (Lists_List l, unsigned int sym);
    1208                 :             : 
    1209                 :             : /*
    1210                 :             :    IncludePartialUnbounded - includes the type component of a partial unbounded symbol.
    1211                 :             : */
    1212                 :             : 
    1213                 :             : static void IncludePartialUnbounded (Lists_List l, unsigned int sym);
    1214                 :             : 
    1215                 :             : /*
    1216                 :             :    PrintDeclared - prints out where, sym, was declared.
    1217                 :             : */
    1218                 :             : 
    1219                 :             : static void PrintDeclared (unsigned int sym);
    1220                 :             : 
    1221                 :             : /*
    1222                 :             :    PrintAlignment -
    1223                 :             : */
    1224                 :             : 
    1225                 :             : static void PrintAlignment (unsigned int sym);
    1226                 :             : 
    1227                 :             : /*
    1228                 :             :    IncludeGetParent -
    1229                 :             : */
    1230                 :             : 
    1231                 :             : static void IncludeGetParent (Lists_List l, unsigned int sym);
    1232                 :             : 
    1233                 :             : /*
    1234                 :             :    PrintDecl -
    1235                 :             : */
    1236                 :             : 
    1237                 :             : static void PrintDecl (unsigned int sym);
    1238                 :             : 
    1239                 :             : /*
    1240                 :             :    PrintScope - displays the scope and line number of declaration of symbol, sym.
    1241                 :             : */
    1242                 :             : 
    1243                 :             : static void PrintScope (unsigned int sym);
    1244                 :             : 
    1245                 :             : /*
    1246                 :             :    PrintKind -
    1247                 :             : */
    1248                 :             : 
    1249                 :             : static void PrintKind (SymbolTable_ProcedureKind kind);
    1250                 :             : 
    1251                 :             : /*
    1252                 :             :    PrintProcedureParameters -
    1253                 :             : */
    1254                 :             : 
    1255                 :             : static void PrintProcedureParameters (unsigned int sym, SymbolTable_ProcedureKind kind);
    1256                 :             : 
    1257                 :             : /*
    1258                 :             :    PrintProcedureReturnType -
    1259                 :             : */
    1260                 :             : 
    1261                 :             : static void PrintProcedureReturnType (unsigned int sym);
    1262                 :             : 
    1263                 :             : /*
    1264                 :             :    PrintProcedure -
    1265                 :             : */
    1266                 :             : 
    1267                 :             : static void PrintProcedure (unsigned int sym);
    1268                 :             : 
    1269                 :             : /*
    1270                 :             :    PrintProcTypeParameters -
    1271                 :             : */
    1272                 :             : 
    1273                 :             : static void PrintProcTypeParameters (unsigned int sym);
    1274                 :             : 
    1275                 :             : /*
    1276                 :             :    PrintProcType -
    1277                 :             : */
    1278                 :             : 
    1279                 :             : static void PrintProcType (unsigned int sym);
    1280                 :             : 
    1281                 :             : /*
    1282                 :             :    PrintString -
    1283                 :             : */
    1284                 :             : 
    1285                 :             : static void PrintString (unsigned int sym);
    1286                 :             : 
    1287                 :             : /*
    1288                 :             :    PrintVerboseFromList - prints the, i, th element in the list, l.
    1289                 :             : */
    1290                 :             : 
    1291                 :             : static void PrintVerboseFromList (Lists_List l, unsigned int i);
    1292                 :             : 
    1293                 :             : /*
    1294                 :             :    PrintVerbose - prints limited information about a symbol.
    1295                 :             : */
    1296                 :             : 
    1297                 :             : static void PrintVerbose (unsigned int sym);
    1298                 :             : 
    1299                 :             : /*
    1300                 :             :    PrintTerse -
    1301                 :             : */
    1302                 :             : 
    1303                 :             : static void PrintTerse (unsigned int sym);
    1304                 :             : 
    1305                 :             : /*
    1306                 :             :    CheckAlignment -
    1307                 :             : */
    1308                 :             : 
    1309                 :             : static tree CheckAlignment (tree type, unsigned int sym);
    1310                 :             : 
    1311                 :             : /*
    1312                 :             :    CheckPragma -
    1313                 :             : */
    1314                 :             : 
    1315                 :             : static tree CheckPragma (tree type, unsigned int sym);
    1316                 :             : 
    1317                 :             : /*
    1318                 :             :    IsZero - returns TRUE if symbol, sym, is zero.
    1319                 :             : */
    1320                 :             : 
    1321                 :             : static bool IsZero (unsigned int sym);
    1322                 :             : 
    1323                 :             : /*
    1324                 :             :    SetFieldPacked - sets Varient, VarientField and RecordField symbols
    1325                 :             :                     as packed.
    1326                 :             : */
    1327                 :             : 
    1328                 :             : static void SetFieldPacked (unsigned int field);
    1329                 :             : 
    1330                 :             : /*
    1331                 :             :    RecordPacked - indicates that record, sym, and its fields
    1332                 :             :                   are all packed.
    1333                 :             : */
    1334                 :             : 
    1335                 :             : static void RecordPacked (unsigned int sym);
    1336                 :             : 
    1337                 :             : /*
    1338                 :             :    SetFieldNotPacked - sets Varient, VarientField and RecordField symbols
    1339                 :             :                        as not packed.
    1340                 :             : */
    1341                 :             : 
    1342                 :             : static void SetFieldNotPacked (unsigned int field);
    1343                 :             : 
    1344                 :             : /*
    1345                 :             :    RecordNotPacked - indicates that record, sym, and its fields
    1346                 :             :                      are all not packed.
    1347                 :             : */
    1348                 :             : 
    1349                 :             : static void RecordNotPacked (unsigned int sym);
    1350                 :             : 
    1351                 :             : /*
    1352                 :             :    DetermineIfRecordPacked -
    1353                 :             : */
    1354                 :             : 
    1355                 :             : static void DetermineIfRecordPacked (unsigned int sym);
    1356                 :             : 
    1357                 :             : /*
    1358                 :             :    DeclarePackedSubrange -
    1359                 :             : */
    1360                 :             : 
    1361                 :             : static void DeclarePackedSubrange (unsigned int equiv, unsigned int sym);
    1362                 :             : 
    1363                 :             : /*
    1364                 :             :    DeclarePackedSet -
    1365                 :             : */
    1366                 :             : 
    1367                 :             : static void DeclarePackedSet (unsigned int equiv, unsigned int sym);
    1368                 :             : static void DeclarePackedFieldEnumeration (unsigned int sym);
    1369                 :             : 
    1370                 :             : /*
    1371                 :             :    DeclarePackedEnumeration -
    1372                 :             : */
    1373                 :             : 
    1374                 :             : static void DeclarePackedEnumeration (unsigned int equiv, unsigned int sym);
    1375                 :             : 
    1376                 :             : /*
    1377                 :             :    DeclarePackedType -
    1378                 :             : */
    1379                 :             : 
    1380                 :             : static void DeclarePackedType (unsigned int equiv, unsigned int sym);
    1381                 :             : 
    1382                 :             : /*
    1383                 :             :    doDeclareEquivalent -
    1384                 :             : */
    1385                 :             : 
    1386                 :             : static tree doDeclareEquivalent (unsigned int sym, M2GCCDeclare_doDeclareProcedure p);
    1387                 :             : 
    1388                 :             : /*
    1389                 :             :    PossiblyPacked -
    1390                 :             : */
    1391                 :             : 
    1392                 :             : static tree PossiblyPacked (unsigned int sym, bool isPacked);
    1393                 :             : 
    1394                 :             : /*
    1395                 :             :    GetPackedType - returns a possibly packed type for field.
    1396                 :             : */
    1397                 :             : 
    1398                 :             : static tree GetPackedType (unsigned int sym);
    1399                 :             : 
    1400                 :             : /*
    1401                 :             :    MaybeAlignField - checks to see whether, field, is packed or aligned and it updates
    1402                 :             :                      the offsets if appropriate.
    1403                 :             : */
    1404                 :             : 
    1405                 :             : static tree MaybeAlignField (unsigned int field, tree *byteOffset, tree *bitOffset);
    1406                 :             : 
    1407                 :             : /*
    1408                 :             :    DeclareRecord - declares a record and its fields to gcc.
    1409                 :             :                    The final gcc record type is returned.
    1410                 :             : */
    1411                 :             : 
    1412                 :             : static tree DeclareRecord (unsigned int Sym);
    1413                 :             : 
    1414                 :             : /*
    1415                 :             :    DeclareRecordField -
    1416                 :             : */
    1417                 :             : 
    1418                 :             : static tree DeclareRecordField (unsigned int sym);
    1419                 :             : 
    1420                 :             : /*
    1421                 :             :    DeclareVarient - declares a record and its fields to gcc.
    1422                 :             :                     The final gcc record type is returned.
    1423                 :             : */
    1424                 :             : 
    1425                 :             : static tree DeclareVarient (unsigned int sym);
    1426                 :             : 
    1427                 :             : /*
    1428                 :             :    DeclareFieldVarient -
    1429                 :             : */
    1430                 :             : 
    1431                 :             : static tree DeclareFieldVarient (unsigned int sym);
    1432                 :             : 
    1433                 :             : /*
    1434                 :             :    DeclarePointer - declares a pointer type to gcc and returns the Tree.
    1435                 :             : */
    1436                 :             : 
    1437                 :             : static tree DeclarePointer (unsigned int sym);
    1438                 :             : 
    1439                 :             : /*
    1440                 :             :    DeclareUnbounded - builds an unbounded type and returns the gcc tree.
    1441                 :             : */
    1442                 :             : 
    1443                 :             : static tree DeclareUnbounded (unsigned int sym);
    1444                 :             : 
    1445                 :             : /*
    1446                 :             :    BuildIndex -
    1447                 :             : */
    1448                 :             : 
    1449                 :             : static tree BuildIndex (unsigned int tokenno, unsigned int array);
    1450                 :             : 
    1451                 :             : /*
    1452                 :             :    DeclareArray - declares an array to gcc and returns the gcc tree.
    1453                 :             : */
    1454                 :             : 
    1455                 :             : static tree DeclareArray (unsigned int Sym);
    1456                 :             : 
    1457                 :             : /*
    1458                 :             :    DeclareProcType - declares a procedure type to gcc and returns the gcc type tree.
    1459                 :             : */
    1460                 :             : 
    1461                 :             : static tree DeclareProcType (unsigned int Sym);
    1462                 :             : 
    1463                 :             : /*
    1464                 :             :    FindMinMaxEnum - finds the minimum and maximum enumeration fields.
    1465                 :             : */
    1466                 :             : 
    1467                 :             : static void FindMinMaxEnum (unsigned int field);
    1468                 :             : 
    1469                 :             : /*
    1470                 :             :    PushNoOfBits - pushes the integer value of the number of bits required
    1471                 :             :                   to maintain a set of type.
    1472                 :             : */
    1473                 :             : 
    1474                 :             : static void PushNoOfBits (unsigned int type, unsigned int low, unsigned int high);
    1475                 :             : 
    1476                 :             : /*
    1477                 :             :    DeclareLargeSet - n is the name of the set.
    1478                 :             :                      type is the subrange type (or simple type)
    1479                 :             :                      low and high are the limits of the subrange.
    1480                 :             : */
    1481                 :             : 
    1482                 :             : static tree DeclareLargeSet (NameKey_Name n, unsigned int type, unsigned int low, unsigned int high);
    1483                 :             : 
    1484                 :             : /*
    1485                 :             :    DeclareLargeOrSmallSet - works out whether the set will exceed TSIZE(WORD). If it does
    1486                 :             :                             we manufacture a set using:
    1487                 :             : 
    1488                 :             :                             settype = RECORD
    1489                 :             :                                          w1: SET OF [...]
    1490                 :             :                                          w2: SET OF [...]
    1491                 :             :                                       END
    1492                 :             : 
    1493                 :             :                             We do this as GCC and GDB (stabs) only knows about WORD sized sets.
    1494                 :             :                             If the set will fit into a WORD then we call gccgm2 directly.
    1495                 :             : */
    1496                 :             : 
    1497                 :             : static tree DeclareLargeOrSmallSet (unsigned int sym, NameKey_Name n, unsigned int type, unsigned int low, unsigned int high);
    1498                 :             : 
    1499                 :             : /*
    1500                 :             :    DeclareSet - declares a set type to gcc and returns a Tree.
    1501                 :             : */
    1502                 :             : 
    1503                 :             : static tree DeclareSet (unsigned int sym);
    1504                 :             : 
    1505                 :             : /*
    1506                 :             :    CheckResolveSubrange - checks to see whether we can determine
    1507                 :             :                           the subrange type.  We are able to do
    1508                 :             :                           this once low, high and the type are known.
    1509                 :             : */
    1510                 :             : 
    1511                 :             : static void CheckResolveSubrange (unsigned int sym);
    1512                 :             : 
    1513                 :             : /*
    1514                 :             :    TypeConstFullyDeclared - all, sym, dependents are declared, so create and
    1515                 :             :                             return the GCC Tree equivalent.
    1516                 :             : */
    1517                 :             : 
    1518                 :             : static tree TypeConstFullyDeclared (unsigned int sym);
    1519                 :             : 
    1520                 :             : /*
    1521                 :             :    IsBaseType - returns true if a type, Sym, is a base type and
    1522                 :             :                 we use predefined GDB information to represent this
    1523                 :             :                 type.
    1524                 :             : */
    1525                 :             : 
    1526                 :             : static bool IsBaseType (unsigned int Sym);
    1527                 :             : 
    1528                 :             : /*
    1529                 :             :    IsFieldEnumerationDependants - sets enumDeps to FALSE if action(Sym)
    1530                 :             :                                   is also FALSE.
    1531                 :             : */
    1532                 :             : 
    1533                 :             : static void IsFieldEnumerationDependants (unsigned int Sym);
    1534                 :             : 
    1535                 :             : /*
    1536                 :             :    IsEnumerationDependants - returns true if the enumeration
    1537                 :             :                              p(dependants) all return true.
    1538                 :             : */
    1539                 :             : 
    1540                 :             : static bool IsEnumerationDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1541                 :             : 
    1542                 :             : /*
    1543                 :             :    WalkEnumerationDependants - returns walks all dependants of Sym.
    1544                 :             : */
    1545                 :             : 
    1546                 :             : static void WalkEnumerationDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1547                 :             : 
    1548                 :             : /*
    1549                 :             :    WalkSubrangeDependants - calls p(dependants) for each dependant of, sym.
    1550                 :             : */
    1551                 :             : 
    1552                 :             : static void WalkSubrangeDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1553                 :             : 
    1554                 :             : /*
    1555                 :             :    IsSubrangeDependants - returns TRUE if the subrange
    1556                 :             :                           q(dependants) all return TRUE.
    1557                 :             : */
    1558                 :             : 
    1559                 :             : static bool IsSubrangeDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1560                 :             : 
    1561                 :             : /*
    1562                 :             :    WalkComponentDependants -
    1563                 :             : */
    1564                 :             : 
    1565                 :             : static void WalkComponentDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1566                 :             : 
    1567                 :             : /*
    1568                 :             :    IsComponentDependants -
    1569                 :             : */
    1570                 :             : 
    1571                 :             : static bool IsComponentDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1572                 :             : 
    1573                 :             : /*
    1574                 :             :    WalkVarDependants - walks all dependants of sym.
    1575                 :             : */
    1576                 :             : 
    1577                 :             : static void WalkVarDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1578                 :             : 
    1579                 :             : /*
    1580                 :             :    IsVarDependants - returns TRUE if the pointer symbol, sym,
    1581                 :             :                      p(dependants) all return TRUE.
    1582                 :             : */
    1583                 :             : 
    1584                 :             : static bool IsVarDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1585                 :             : 
    1586                 :             : /*
    1587                 :             :    WalkPointerDependants - walks all dependants of sym.
    1588                 :             : */
    1589                 :             : 
    1590                 :             : static void WalkPointerDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1591                 :             : 
    1592                 :             : /*
    1593                 :             :    IsPointerDependants - returns TRUE if the pointer symbol, sym,
    1594                 :             :                          p(dependants) all return TRUE.
    1595                 :             : */
    1596                 :             : 
    1597                 :             : static bool IsPointerDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1598                 :             : 
    1599                 :             : /*
    1600                 :             :    IsRecordAlignment -
    1601                 :             : */
    1602                 :             : 
    1603                 :             : static bool IsRecordAlignment (unsigned int sym, M2GCCDeclare_IsAction q);
    1604                 :             : 
    1605                 :             : /*
    1606                 :             :    IsRecordDependants - returns TRUE if the symbol, sym,
    1607                 :             :                         q(dependants) all return TRUE.
    1608                 :             : */
    1609                 :             : 
    1610                 :             : static bool IsRecordDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1611                 :             : 
    1612                 :             : /*
    1613                 :             :    WalkRecordAlignment - walks the alignment constant associated with
    1614                 :             :                          record, sym.
    1615                 :             : */
    1616                 :             : 
    1617                 :             : static void WalkRecordAlignment (unsigned int sym, M2GCCDeclare_WalkAction p);
    1618                 :             : 
    1619                 :             : /*
    1620                 :             :    WalkRecordDependants - walks symbol, sym, dependants.  It only
    1621                 :             :                           walks the fields if the alignment is
    1622                 :             :                           unused or fully declared.
    1623                 :             : */
    1624                 :             : 
    1625                 :             : static void WalkRecordDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1626                 :             : 
    1627                 :             : /*
    1628                 :             :    WalkRecordFieldDependants -
    1629                 :             : */
    1630                 :             : 
    1631                 :             : static void WalkRecordFieldDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1632                 :             : 
    1633                 :             : /*
    1634                 :             :    WalkRecordDependants2 - walks the fields of record, sym, calling
    1635                 :             :                            p on every dependant.
    1636                 :             : */
    1637                 :             : 
    1638                 :             : static void WalkRecordDependants2 (unsigned int sym, M2GCCDeclare_WalkAction p);
    1639                 :             : 
    1640                 :             : /*
    1641                 :             :    IsVarientAlignment -
    1642                 :             : */
    1643                 :             : 
    1644                 :             : static bool IsVarientAlignment (unsigned int sym, M2GCCDeclare_IsAction q);
    1645                 :             : 
    1646                 :             : /*
    1647                 :             :    IsVarientDependants - returns TRUE if the symbol, sym,
    1648                 :             :                          q(dependants) all return TRUE.
    1649                 :             : */
    1650                 :             : 
    1651                 :             : static bool IsVarientDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1652                 :             : 
    1653                 :             : /*
    1654                 :             :    WalkVarientAlignment -
    1655                 :             : */
    1656                 :             : 
    1657                 :             : static void WalkVarientAlignment (unsigned int sym, M2GCCDeclare_WalkAction p);
    1658                 :             : 
    1659                 :             : /*
    1660                 :             :    WalkVarientDependants - walks symbol, sym, dependants.
    1661                 :             : */
    1662                 :             : 
    1663                 :             : static void WalkVarientDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1664                 :             : 
    1665                 :             : /*
    1666                 :             :    IsVarientFieldDependants - returns TRUE if the symbol, sym,
    1667                 :             :                               q(dependants) all return TRUE.
    1668                 :             : */
    1669                 :             : 
    1670                 :             : static bool IsVarientFieldDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1671                 :             : 
    1672                 :             : /*
    1673                 :             :    WalkVarientFieldDependants -
    1674                 :             : */
    1675                 :             : 
    1676                 :             : static void WalkVarientFieldDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1677                 :             : 
    1678                 :             : /*
    1679                 :             :    IsArrayDependants - returns TRUE if the symbol, sym,
    1680                 :             :                        q(dependants) all return TRUE.
    1681                 :             : 
    1682                 :             : */
    1683                 :             : 
    1684                 :             : static bool IsArrayDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1685                 :             : 
    1686                 :             : /*
    1687                 :             :    WalkArrayDependants - walks symbol, sym, dependants.
    1688                 :             : */
    1689                 :             : 
    1690                 :             : static void WalkArrayDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1691                 :             : 
    1692                 :             : /*
    1693                 :             :    IsSetDependants - returns TRUE if the symbol, sym,
    1694                 :             :                      q(dependants) all return TRUE.
    1695                 :             : */
    1696                 :             : 
    1697                 :             : static bool IsSetDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1698                 :             : 
    1699                 :             : /*
    1700                 :             :    WalkSetDependants - walks dependants, sym.
    1701                 :             : */
    1702                 :             : 
    1703                 :             : static void WalkSetDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1704                 :             : 
    1705                 :             : /*
    1706                 :             :    IsProcTypeDependants -
    1707                 :             : */
    1708                 :             : 
    1709                 :             : static bool IsProcTypeDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1710                 :             : 
    1711                 :             : /*
    1712                 :             :    WalkProcTypeDependants - walks dependants, sym.
    1713                 :             : */
    1714                 :             : 
    1715                 :             : static void WalkProcTypeDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1716                 :             : 
    1717                 :             : /*
    1718                 :             :    IsProcedureDependants -
    1719                 :             : */
    1720                 :             : 
    1721                 :             : static bool IsProcedureDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1722                 :             : 
    1723                 :             : /*
    1724                 :             :    WalkProcedureDependants - walks dependants, sym.
    1725                 :             : */
    1726                 :             : 
    1727                 :             : static void WalkProcedureDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1728                 :             : 
    1729                 :             : /*
    1730                 :             :    IsUnboundedDependants - returns TRUE if the symbol, sym,
    1731                 :             :                            q(dependants) all return TRUE.
    1732                 :             : */
    1733                 :             : 
    1734                 :             : static bool IsUnboundedDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1735                 :             : 
    1736                 :             : /*
    1737                 :             :    WalkUnboundedDependants - walks the dependants of, sym.
    1738                 :             : */
    1739                 :             : 
    1740                 :             : static void WalkUnboundedDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1741                 :             : 
    1742                 :             : /*
    1743                 :             :    IsTypeDependants - returns TRUE if all q(dependants) return
    1744                 :             :                       TRUE.
    1745                 :             : */
    1746                 :             : 
    1747                 :             : static bool IsTypeDependants (unsigned int sym, M2GCCDeclare_IsAction q);
    1748                 :             : 
    1749                 :             : /*
    1750                 :             :    WalkTypeDependants - walks all dependants of, sym.
    1751                 :             : */
    1752                 :             : 
    1753                 :             : static void WalkTypeDependants (unsigned int sym, M2GCCDeclare_WalkAction p);
    1754                 :             : 
    1755                 :             : 
    1756                 :             : /*
    1757                 :             :    PrintNum -
    1758                 :             : */
    1759                 :             : 
    1760                 :           0 : static void PrintNum (unsigned int sym)
    1761                 :             : {
    1762                 :           0 :   M2Printf_printf1 ((const char *) "%d, ", 4, (const unsigned char *) &sym, (sizeof (sym)-1));
    1763                 :           0 : }
    1764                 :             : 
    1765                 :             : 
    1766                 :             : /*
    1767                 :             :    DebugSet -
    1768                 :             : */
    1769                 :             : 
    1770                 :           0 : static void DebugSet (const char *a_, unsigned int _a_high, Sets_Set l)
    1771                 :             : {
    1772                 :           0 :   char a[_a_high+1];
    1773                 :             : 
    1774                 :             :   /* make a local copy of each unbounded array.  */
    1775                 :           0 :   memcpy (a, a_, _a_high+1);
    1776                 :             : 
    1777                 :           0 :   M2Printf_printf0 ((const char *) a, _a_high);
    1778                 :           0 :   M2Printf_printf0 ((const char *) " {", 2);
    1779                 :           0 :   Sets_ForeachElementInSetDo (l, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PrintNum});
    1780                 :           0 :   M2Printf_printf0 ((const char *) "}\\n", 3);
    1781                 :           0 : }
    1782                 :             : 
    1783                 :             : 
    1784                 :             : /*
    1785                 :             :    DebugSets -
    1786                 :             : */
    1787                 :             : 
    1788                 :           0 : static void DebugSets (void)
    1789                 :             : {
    1790                 :           0 :   DebugSet ((const char *) "ToDoList", 8, GlobalGroup->ToDoList);
    1791                 :           0 :   DebugSet ((const char *) "HeldByAlignment", 15, GlobalGroup->HeldByAlignment);
    1792                 :           0 :   DebugSet ((const char *) "FinishedAlignment", 17, GlobalGroup->FinishedAlignment);
    1793                 :           0 :   DebugSet ((const char *) "PartiallyDeclared", 17, GlobalGroup->PartiallyDeclared);
    1794                 :           0 :   DebugSet ((const char *) "FullyDeclared", 13, GlobalGroup->FullyDeclared);
    1795                 :           0 :   DebugSet ((const char *) "NilTypedArrays", 14, GlobalGroup->NilTypedArrays);
    1796                 :           0 :   DebugSet ((const char *) "ToBeSolvedByQuads", 17, GlobalGroup->ToBeSolvedByQuads);
    1797                 :           0 :   DebugSet ((const char *) "FinishedSetArray", 16, GlobalGroup->FinishedSetArray);
    1798                 :           0 : }
    1799                 :             : 
    1800                 :             : 
    1801                 :             : /*
    1802                 :             :    DebugNumber -
    1803                 :             : */
    1804                 :             : 
    1805                 :           0 : static void DebugNumber (const char *a_, unsigned int _a_high, Sets_Set s)
    1806                 :             : {
    1807                 :           0 :   unsigned int n;
    1808                 :           0 :   char a[_a_high+1];
    1809                 :             : 
    1810                 :             :   /* make a local copy of each unbounded array.  */
    1811                 :           0 :   memcpy (a, a_, _a_high+1);
    1812                 :             : 
    1813                 :           0 :   n = Sets_NoOfElementsInSet (s);
    1814                 :           0 :   M2Printf_printf1 ((const char *) a, _a_high, (const unsigned char *) &n, (sizeof (n)-1));
    1815                 :           0 :   FIO_FlushBuffer (FIO_StdOut);
    1816                 :           0 : }
    1817                 :             : 
    1818                 :           0 : static void DebugSetNumbers (void)
    1819                 :             : {
    1820                 :             :   /* 
    1821                 :             :    DebugSets -
    1822                 :             :   */
    1823                 :           0 :   DebugNumber ((const char *) "ToDoList : %d\\n", 15, GlobalGroup->ToDoList);
    1824                 :           0 :   DebugNumber ((const char *) "HeldByAlignment : %d\\n", 22, GlobalGroup->HeldByAlignment);
    1825                 :           0 :   DebugNumber ((const char *) "PartiallyDeclared : %d\\n", 24, GlobalGroup->PartiallyDeclared);
    1826                 :           0 :   DebugNumber ((const char *) "FullyDeclared : %d\\n", 20, GlobalGroup->FullyDeclared);
    1827                 :           0 :   DebugNumber ((const char *) "NilTypedArrays : %d\\n", 21, GlobalGroup->NilTypedArrays);
    1828                 :           0 :   DebugNumber ((const char *) "ToBeSolvedByQuads : %d\\n", 24, GlobalGroup->ToBeSolvedByQuads);
    1829                 :           0 :   DebugNumber ((const char *) "FinishedSetArray : %d\\n", 23, GlobalGroup->FinishedSetArray);
    1830                 :           0 : }
    1831                 :             : 
    1832                 :             : 
    1833                 :             : /*
    1834                 :             :    AddSymToWatch - adds symbol, sym, to the list of symbols
    1835                 :             :                    to watch and annotate their movement between
    1836                 :             :                    lists.
    1837                 :             : */
    1838                 :             : 
    1839                 :           0 : static void AddSymToWatch (unsigned int sym)
    1840                 :             : {
    1841                 :           0 :   if ((sym != SymbolTable_NulSym) && (! (Sets_IsElementInSet (WatchList, sym))))
    1842                 :             :     {
    1843                 :           0 :       Sets_IncludeElementIntoSet (WatchList, sym);
    1844                 :           0 :       WalkDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) AddSymToWatch});
    1845                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "%d, ", 4, (const unsigned char *) &sym, (sizeof (sym)-1));
    1846                 :             :     }
    1847                 :           0 : }
    1848                 :             : 
    1849                 :             : 
    1850                 :             : /*
    1851                 :             :    doInclude -
    1852                 :             : */
    1853                 :             : 
    1854                 :           0 : static void doInclude (Sets_Set l, const char *a_, unsigned int _a_high, unsigned int sym)
    1855                 :             : {
    1856                 :           0 :   char a[_a_high+1];
    1857                 :             : 
    1858                 :             :   /* make a local copy of each unbounded array.  */
    1859                 :           0 :   memcpy (a, a_, _a_high+1);
    1860                 :             : 
    1861                 :           0 :   if (! (Sets_IsElementInSet (l, sym)))
    1862                 :             :     {
    1863                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "rule: ", 6);
    1864                 :           0 :       WriteRule ();
    1865                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "  ", 2);
    1866                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) a, _a_high, (const unsigned char *) &sym, (sizeof (sym)-1));
    1867                 :           0 :       Sets_IncludeElementIntoSet (l, sym);
    1868                 :             :     }
    1869                 :           0 : }
    1870                 :             : 
    1871                 :             : 
    1872                 :             : /*
    1873                 :             :    WatchIncludeList - include a symbol onto the set first checking
    1874                 :             :                       whether it is already on the set and
    1875                 :             :                       displaying a debug message if the set is
    1876                 :             :                       changed.
    1877                 :             : */
    1878                 :             : 
    1879                 :    13965138 : static void WatchIncludeList (unsigned int sym, M2GCCDeclare_ListType lt)
    1880                 :             : {
    1881                 :    13965138 :   if (Sets_IsElementInSet (WatchList, sym))
    1882                 :             :     {
    1883                 :           0 :       switch (lt)
    1884                 :             :         {
    1885                 :           0 :           case M2GCCDeclare_tobesolvedbyquads:
    1886                 :           0 :             doInclude (GlobalGroup->ToBeSolvedByQuads, (const char *) "symbol %d -> ToBeSolvedByQuads\\n", 32, sym);
    1887                 :           0 :             break;
    1888                 :             : 
    1889                 :           0 :           case M2GCCDeclare_fullydeclared:
    1890                 :           0 :             doInclude (GlobalGroup->FullyDeclared, (const char *) "symbol %d -> FullyDeclared\\n", 28, sym);
    1891                 :           0 :             break;
    1892                 :             : 
    1893                 :           0 :           case M2GCCDeclare_partiallydeclared:
    1894                 :           0 :             doInclude (GlobalGroup->PartiallyDeclared, (const char *) "symbol %d -> PartiallyDeclared\\n", 32, sym);
    1895                 :           0 :             break;
    1896                 :             : 
    1897                 :           0 :           case M2GCCDeclare_heldbyalignment:
    1898                 :           0 :             doInclude (GlobalGroup->HeldByAlignment, (const char *) "symbol %d -> HeldByAlignment\\n", 30, sym);
    1899                 :           0 :             break;
    1900                 :             : 
    1901                 :           0 :           case M2GCCDeclare_finishedalignment:
    1902                 :           0 :             doInclude (GlobalGroup->FinishedAlignment, (const char *) "symbol %d -> FinishedAlignment\\n", 32, sym);
    1903                 :           0 :             break;
    1904                 :             : 
    1905                 :           0 :           case M2GCCDeclare_todolist:
    1906                 :           0 :             doInclude (GlobalGroup->ToDoList, (const char *) "symbol %d -> ToDoList\\n", 23, sym);
    1907                 :           0 :             break;
    1908                 :             : 
    1909                 :           0 :           case M2GCCDeclare_niltypedarrays:
    1910                 :           0 :             doInclude (GlobalGroup->NilTypedArrays, (const char *) "symbol %d -> NilTypedArrays\\n", 29, sym);
    1911                 :           0 :             break;
    1912                 :             : 
    1913                 :           0 :           case M2GCCDeclare_finishedsetarray:
    1914                 :           0 :             doInclude (GlobalGroup->FinishedSetArray, (const char *) "symbol %d -> FinishedSetArray\\n", 31, sym);
    1915                 :           0 :             break;
    1916                 :             : 
    1917                 :             : 
    1918                 :           0 :           default:
    1919                 :           0 :             M2Error_InternalError ((const char *) "unknown list", 12);
    1920                 :             :             break;
    1921                 :             :         }
    1922                 :             :     }
    1923                 :             :   else
    1924                 :             :     {
    1925                 :    13965138 :       switch (lt)
    1926                 :             :         {
    1927                 :      300080 :           case M2GCCDeclare_tobesolvedbyquads:
    1928                 :      300080 :             Sets_IncludeElementIntoSet (GlobalGroup->ToBeSolvedByQuads, sym);
    1929                 :      300080 :             break;
    1930                 :             : 
    1931                 :    10187640 :           case M2GCCDeclare_fullydeclared:
    1932                 :    10187640 :             Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, sym);
    1933                 :    10187640 :             break;
    1934                 :             : 
    1935                 :      144581 :           case M2GCCDeclare_partiallydeclared:
    1936                 :      144581 :             Sets_IncludeElementIntoSet (GlobalGroup->PartiallyDeclared, sym);
    1937                 :      144581 :             break;
    1938                 :             : 
    1939                 :       82749 :           case M2GCCDeclare_heldbyalignment:
    1940                 :       82749 :             Sets_IncludeElementIntoSet (GlobalGroup->HeldByAlignment, sym);
    1941                 :       82749 :             break;
    1942                 :             : 
    1943                 :      335838 :           case M2GCCDeclare_finishedalignment:
    1944                 :      335838 :             Sets_IncludeElementIntoSet (GlobalGroup->FinishedAlignment, sym);
    1945                 :      335838 :             break;
    1946                 :             : 
    1947                 :     2906698 :           case M2GCCDeclare_todolist:
    1948                 :     2906698 :             Sets_IncludeElementIntoSet (GlobalGroup->ToDoList, sym);
    1949                 :     2906698 :             break;
    1950                 :             : 
    1951                 :        7552 :           case M2GCCDeclare_niltypedarrays:
    1952                 :        7552 :             Sets_IncludeElementIntoSet (GlobalGroup->NilTypedArrays, sym);
    1953                 :        7552 :             break;
    1954                 :             : 
    1955                 :           0 :           case M2GCCDeclare_finishedsetarray:
    1956                 :           0 :             Sets_IncludeElementIntoSet (GlobalGroup->FinishedSetArray, sym);
    1957                 :           0 :             break;
    1958                 :             : 
    1959                 :             : 
    1960                 :           0 :           default:
    1961                 :           0 :             M2Error_InternalError ((const char *) "unknown list", 12);
    1962                 :    13965138 :             break;
    1963                 :             :         }
    1964                 :             :     }
    1965                 :    13965138 : }
    1966                 :             : 
    1967                 :             : 
    1968                 :             : /*
    1969                 :             :    doExclude -
    1970                 :             : */
    1971                 :             : 
    1972                 :           0 : static void doExclude (Sets_Set l, const char *a_, unsigned int _a_high, unsigned int sym)
    1973                 :             : {
    1974                 :           0 :   char a[_a_high+1];
    1975                 :             : 
    1976                 :             :   /* make a local copy of each unbounded array.  */
    1977                 :           0 :   memcpy (a, a_, _a_high+1);
    1978                 :             : 
    1979                 :           0 :   if (Sets_IsElementInSet (l, sym))
    1980                 :             :     {
    1981                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "rule: ", 6);
    1982                 :           0 :       WriteRule ();
    1983                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "  ", 2);
    1984                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) a, _a_high, (const unsigned char *) &sym, (sizeof (sym)-1));
    1985                 :           0 :       Sets_ExcludeElementFromSet (l, sym);
    1986                 :             :     }
    1987                 :           0 : }
    1988                 :             : 
    1989                 :             : 
    1990                 :             : /*
    1991                 :             :    WatchRemoveList - remove a symbol onto the list first checking
    1992                 :             :                      whether it is already on the list and
    1993                 :             :                      displaying a debug message if the list is
    1994                 :             :                      changed.
    1995                 :             : */
    1996                 :             : 
    1997                 :    16444720 : static void WatchRemoveList (unsigned int sym, M2GCCDeclare_ListType lt)
    1998                 :             : {
    1999                 :    16444720 :   if (Sets_IsElementInSet (WatchList, sym))
    2000                 :             :     {
    2001                 :           0 :       switch (lt)
    2002                 :             :         {
    2003                 :           0 :           case M2GCCDeclare_tobesolvedbyquads:
    2004                 :           0 :             doExclude (GlobalGroup->ToBeSolvedByQuads, (const char *) "symbol %d off ToBeSolvedByQuads\\n", 33, sym);
    2005                 :           0 :             break;
    2006                 :             : 
    2007                 :           0 :           case M2GCCDeclare_fullydeclared:
    2008                 :           0 :             doExclude (GlobalGroup->FullyDeclared, (const char *) "symbol %d off FullyDeclared\\n", 29, sym);
    2009                 :           0 :             break;
    2010                 :             : 
    2011                 :           0 :           case M2GCCDeclare_partiallydeclared:
    2012                 :           0 :             doExclude (GlobalGroup->PartiallyDeclared, (const char *) "symbol %d off PartiallyDeclared\\n", 33, sym);
    2013                 :           0 :             break;
    2014                 :             : 
    2015                 :           0 :           case M2GCCDeclare_heldbyalignment:
    2016                 :           0 :             doExclude (GlobalGroup->HeldByAlignment, (const char *) "symbol %d -> HeldByAlignment\\n", 30, sym);
    2017                 :           0 :             break;
    2018                 :             : 
    2019                 :           0 :           case M2GCCDeclare_finishedalignment:
    2020                 :           0 :             doExclude (GlobalGroup->FinishedAlignment, (const char *) "symbol %d -> FinishedAlignment\\n", 32, sym);
    2021                 :           0 :             break;
    2022                 :             : 
    2023                 :           0 :           case M2GCCDeclare_todolist:
    2024                 :           0 :             doExclude (GlobalGroup->ToDoList, (const char *) "symbol %d off ToDoList\\n", 24, sym);
    2025                 :           0 :             break;
    2026                 :             : 
    2027                 :           0 :           case M2GCCDeclare_niltypedarrays:
    2028                 :           0 :             doExclude (GlobalGroup->NilTypedArrays, (const char *) "symbol %d off NilTypedArrays\\n", 30, sym);
    2029                 :           0 :             break;
    2030                 :             : 
    2031                 :           0 :           case M2GCCDeclare_finishedsetarray:
    2032                 :           0 :             doExclude (GlobalGroup->FinishedSetArray, (const char *) "symbol %d off FinishedSetArray\\n", 32, sym);
    2033                 :           0 :             break;
    2034                 :             : 
    2035                 :             : 
    2036                 :           0 :           default:
    2037                 :           0 :             M2Error_InternalError ((const char *) "unknown list", 12);
    2038                 :             :             break;
    2039                 :             :         }
    2040                 :             :     }
    2041                 :             :   else
    2042                 :             :     {
    2043                 :    16444720 :       switch (lt)
    2044                 :             :         {
    2045                 :      378604 :           case M2GCCDeclare_tobesolvedbyquads:
    2046                 :      378604 :             Sets_ExcludeElementFromSet (GlobalGroup->ToBeSolvedByQuads, sym);
    2047                 :      378604 :             break;
    2048                 :             : 
    2049                 :           0 :           case M2GCCDeclare_fullydeclared:
    2050                 :           0 :             Sets_ExcludeElementFromSet (GlobalGroup->FullyDeclared, sym);
    2051                 :           0 :             break;
    2052                 :             : 
    2053                 :     1678099 :           case M2GCCDeclare_partiallydeclared:
    2054                 :     1678099 :             Sets_ExcludeElementFromSet (GlobalGroup->PartiallyDeclared, sym);
    2055                 :     1678099 :             break;
    2056                 :             : 
    2057                 :     1516370 :           case M2GCCDeclare_heldbyalignment:
    2058                 :     1516370 :             Sets_ExcludeElementFromSet (GlobalGroup->HeldByAlignment, sym);
    2059                 :     1516370 :             break;
    2060                 :             : 
    2061                 :     1432805 :           case M2GCCDeclare_finishedalignment:
    2062                 :     1432805 :             Sets_ExcludeElementFromSet (GlobalGroup->FinishedAlignment, sym);
    2063                 :     1432805 :             break;
    2064                 :             : 
    2065                 :    11431338 :           case M2GCCDeclare_todolist:
    2066                 :    11431338 :             Sets_ExcludeElementFromSet (GlobalGroup->ToDoList, sym);
    2067                 :    11431338 :             break;
    2068                 :             : 
    2069                 :        7504 :           case M2GCCDeclare_niltypedarrays:
    2070                 :        7504 :             Sets_ExcludeElementFromSet (GlobalGroup->NilTypedArrays, sym);
    2071                 :        7504 :             break;
    2072                 :             : 
    2073                 :           0 :           case M2GCCDeclare_finishedsetarray:
    2074                 :           0 :             Sets_ExcludeElementFromSet (GlobalGroup->FinishedSetArray, sym);
    2075                 :           0 :             break;
    2076                 :             : 
    2077                 :             : 
    2078                 :           0 :           default:
    2079                 :           0 :             M2Error_InternalError ((const char *) "unknown list", 12);
    2080                 :    16444720 :             break;
    2081                 :             :         }
    2082                 :             :     }
    2083                 :    16444720 : }
    2084                 :             : 
    2085                 :             : 
    2086                 :             : /*
    2087                 :             :    NewGroup -
    2088                 :             : */
    2089                 :             : 
    2090                 :     1514970 : static void NewGroup (M2GCCDeclare_Group *g)
    2091                 :             : {
    2092                 :     1514970 :   if (FreeGroup == NULL)
    2093                 :             :     {
    2094                 :       58205 :       Storage_ALLOCATE ((void **) &(*g), sizeof (M2GCCDeclare__T1));
    2095                 :             :     }
    2096                 :             :   else
    2097                 :             :     {
    2098                 :     1456765 :       (*g) = FreeGroup;
    2099                 :     1456765 :       FreeGroup = FreeGroup->Next;
    2100                 :             :     }
    2101                 :     1514970 : }
    2102                 :             : 
    2103                 :             : 
    2104                 :             : /*
    2105                 :             :    DisposeGroup -
    2106                 :             : */
    2107                 :             : 
    2108                 :     1499626 : static void DisposeGroup (M2GCCDeclare_Group *g)
    2109                 :             : {
    2110                 :     1499626 :   (*g)->Next = FreeGroup;
    2111                 :     1499626 :   FreeGroup = (*g);
    2112                 :     1499626 :   (*g) = NULL;
    2113                 :     1499626 : }
    2114                 :             : 
    2115                 :             : 
    2116                 :             : /*
    2117                 :             :    InitGroup - initialize all sets in group and return the group.
    2118                 :             : */
    2119                 :             : 
    2120                 :       15260 : static M2GCCDeclare_Group InitGroup (void)
    2121                 :             : {
    2122                 :       15260 :   M2GCCDeclare_Group g;
    2123                 :             : 
    2124                 :       15260 :   NewGroup (&g);
    2125                 :             :   /* Initialize all sets in group.  */
    2126                 :       15260 :   g->FinishedSetArray = Sets_InitSet (1);
    2127                 :       15260 :   g->ToDoList = Sets_InitSet (1);
    2128                 :       15260 :   g->FullyDeclared = Sets_InitSet (1);
    2129                 :       15260 :   g->PartiallyDeclared = Sets_InitSet (1);
    2130                 :       15260 :   g->NilTypedArrays = Sets_InitSet (1);
    2131                 :       15260 :   g->HeldByAlignment = Sets_InitSet (1);
    2132                 :       15260 :   g->FinishedAlignment = Sets_InitSet (1);
    2133                 :       15260 :   g->ToBeSolvedByQuads = Sets_InitSet (1);
    2134                 :       15260 :   g->Next = NULL;
    2135                 :       15260 :   return g;
    2136                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2137                 :             :   __builtin_unreachable ();
    2138                 :             : }
    2139                 :             : 
    2140                 :             : 
    2141                 :             : /*
    2142                 :             :    KillGroup - delete all sets in group and deallocate g.
    2143                 :             : */
    2144                 :             : 
    2145                 :     1499626 : static void KillGroup (M2GCCDeclare_Group *g)
    2146                 :             : {
    2147                 :             :   /* Delete all sets in group.  */
    2148                 :     1499626 :   if ((*g) != NULL)
    2149                 :             :     {
    2150                 :     1499626 :       (*g)->FinishedSetArray = Sets_KillSet ((*g)->FinishedSetArray);
    2151                 :     1499626 :       (*g)->ToDoList = Sets_KillSet ((*g)->ToDoList);
    2152                 :     1499626 :       (*g)->FullyDeclared = Sets_KillSet ((*g)->FullyDeclared);
    2153                 :     1499626 :       (*g)->PartiallyDeclared = Sets_KillSet ((*g)->PartiallyDeclared);
    2154                 :     1499626 :       (*g)->NilTypedArrays = Sets_KillSet ((*g)->NilTypedArrays);
    2155                 :     1499626 :       (*g)->HeldByAlignment = Sets_KillSet ((*g)->HeldByAlignment);
    2156                 :     1499626 :       (*g)->FinishedAlignment = Sets_KillSet ((*g)->FinishedAlignment);
    2157                 :     1499626 :       (*g)->ToBeSolvedByQuads = Sets_KillSet ((*g)->ToBeSolvedByQuads);
    2158                 :     1499626 :       (*g)->Next = NULL;
    2159                 :     1499626 :       DisposeGroup (g);
    2160                 :             :     }
    2161                 :     1499626 : }
    2162                 :             : 
    2163                 :             : 
    2164                 :             : /*
    2165                 :             :    DupGroup - If g is not NIL then destroy g.
    2166                 :             :               Return a duplicate of GlobalGroup.
    2167                 :             : */
    2168                 :             : 
    2169                 :     1499710 : static M2GCCDeclare_Group DupGroup (M2GCCDeclare_Group g)
    2170                 :             : {
    2171                 :     1499710 :   if (g != NULL)
    2172                 :             :     {
    2173                 :             :       /* Kill old group.  */
    2174                 :      153898 :       KillGroup (&g);
    2175                 :             :     }
    2176                 :     1499710 :   NewGroup (&g);
    2177                 :             :   /* Copy all sets.  */
    2178                 :     1499710 :   g->FinishedSetArray = Sets_DuplicateSet (GlobalGroup->FinishedSetArray);
    2179                 :     1499710 :   g->ToDoList = Sets_DuplicateSet (GlobalGroup->ToDoList);
    2180                 :     1499710 :   g->FullyDeclared = Sets_DuplicateSet (GlobalGroup->FullyDeclared);
    2181                 :     1499710 :   g->PartiallyDeclared = Sets_DuplicateSet (GlobalGroup->PartiallyDeclared);
    2182                 :     1499710 :   g->NilTypedArrays = Sets_DuplicateSet (GlobalGroup->NilTypedArrays);
    2183                 :     1499710 :   g->HeldByAlignment = Sets_DuplicateSet (GlobalGroup->HeldByAlignment);
    2184                 :     1499710 :   g->FinishedAlignment = Sets_DuplicateSet (GlobalGroup->FinishedAlignment);
    2185                 :     1499710 :   g->ToBeSolvedByQuads = Sets_DuplicateSet (GlobalGroup->ToBeSolvedByQuads);
    2186                 :     1499710 :   g->Next = NULL;
    2187                 :     1499710 :   return g;
    2188                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2189                 :             :   __builtin_unreachable ();
    2190                 :             : }
    2191                 :             : 
    2192                 :             : 
    2193                 :             : /*
    2194                 :             :    EqualGroup - return TRUE if group left = right.
    2195                 :             : */
    2196                 :             : 
    2197                 :      739350 : static bool EqualGroup (M2GCCDeclare_Group left, M2GCCDeclare_Group right)
    2198                 :             : {
    2199                 :      739350 :   return (left == right) || ((((((((Sets_EqualSet (left->FullyDeclared, right->FullyDeclared)) && (Sets_EqualSet (left->PartiallyDeclared, right->PartiallyDeclared))) && (Sets_EqualSet (left->NilTypedArrays, right->NilTypedArrays))) && (Sets_EqualSet (left->HeldByAlignment, right->HeldByAlignment))) && (Sets_EqualSet (left->FinishedAlignment, right->FinishedAlignment))) && (Sets_EqualSet (left->ToDoList, right->ToDoList))) && (Sets_EqualSet (left->ToBeSolvedByQuads, right->ToBeSolvedByQuads))) && (Sets_EqualSet (left->FinishedSetArray, right->FinishedSetArray)));
    2200                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2201                 :             :   __builtin_unreachable ();
    2202                 :             : }
    2203                 :             : 
    2204                 :             : 
    2205                 :             : /*
    2206                 :             :    LookupSet -
    2207                 :             : */
    2208                 :             : 
    2209                 :     9361712 : static Sets_Set LookupSet (M2GCCDeclare_ListType listtype)
    2210                 :             : {
    2211                 :     9361712 :   switch (listtype)
    2212                 :             :     {
    2213                 :           0 :       case M2GCCDeclare_fullydeclared:
    2214                 :           0 :         return GlobalGroup->FullyDeclared;
    2215                 :     1307084 :         break;
    2216                 :             : 
    2217                 :     1307084 :       case M2GCCDeclare_partiallydeclared:
    2218                 :     1307084 :         return GlobalGroup->PartiallyDeclared;
    2219                 :     1487954 :         break;
    2220                 :             : 
    2221                 :     1487954 :       case M2GCCDeclare_niltypedarrays:
    2222                 :     1487954 :         return GlobalGroup->NilTypedArrays;
    2223                 :      830763 :         break;
    2224                 :             : 
    2225                 :      830763 :       case M2GCCDeclare_heldbyalignment:
    2226                 :      830763 :         return GlobalGroup->HeldByAlignment;
    2227                 :      822438 :         break;
    2228                 :             : 
    2229                 :      822438 :       case M2GCCDeclare_finishedalignment:
    2230                 :      822438 :         return GlobalGroup->FinishedAlignment;
    2231                 :     4913473 :         break;
    2232                 :             : 
    2233                 :     4913473 :       case M2GCCDeclare_todolist:
    2234                 :     4913473 :         return GlobalGroup->ToDoList;
    2235                 :           0 :         break;
    2236                 :             : 
    2237                 :           0 :       case M2GCCDeclare_tobesolvedbyquads:
    2238                 :           0 :         return GlobalGroup->ToBeSolvedByQuads;
    2239                 :           0 :         break;
    2240                 :             : 
    2241                 :           0 :       case M2GCCDeclare_finishedsetarray:
    2242                 :           0 :         return GlobalGroup->FinishedSetArray;
    2243                 :           0 :         break;
    2244                 :             : 
    2245                 :             : 
    2246                 :           0 :       default:
    2247                 :           0 :         M2Error_InternalError ((const char *) "unknown ListType", 16);
    2248                 :             :         break;
    2249                 :             :     }
    2250                 :             :   return static_cast<Sets_Set> (NULL);
    2251                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2252                 :             :   __builtin_unreachable ();
    2253                 :             : }
    2254                 :             : 
    2255                 :             : 
    2256                 :             : /*
    2257                 :             :    GetEnumList -
    2258                 :             : */
    2259                 :             : 
    2260                 :      447216 : static tree GetEnumList (unsigned int sym)
    2261                 :             : {
    2262                 :      447216 :   if (Indexing_InBounds (EnumerationIndex, sym))
    2263                 :             :     {
    2264                 :      427616 :       return (tree) (Indexing_GetIndice (EnumerationIndex, sym));
    2265                 :             :     }
    2266                 :             :   else
    2267                 :             :     {
    2268                 :             :       return NULL;
    2269                 :             :     }
    2270                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2271                 :             :   __builtin_unreachable ();
    2272                 :             : }
    2273                 :             : 
    2274                 :             : 
    2275                 :             : /*
    2276                 :             :    PutEnumList -
    2277                 :             : */
    2278                 :             : 
    2279                 :      423942 : static void PutEnumList (unsigned int sym, tree enumlist)
    2280                 :             : {
    2281                 :           0 :   Indexing_PutIndice (EnumerationIndex, sym, enumlist);
    2282                 :           0 : }
    2283                 :             : 
    2284                 :             : 
    2285                 :             : /*
    2286                 :             :    Chained - checks to see that, sym, has not already been placed on a chain.
    2287                 :             :              It returns the symbol, sym.
    2288                 :             : */
    2289                 :             : 
    2290                 :      326060 : static unsigned int Chained (unsigned int sym)
    2291                 :             : {
    2292                 :      326060 :   if (Sets_IsElementInSet (ChainedList, sym))
    2293                 :             :     {
    2294                 :           0 :       M2Error_InternalError ((const char *) "symbol has already been chained onto a previous list", 52);
    2295                 :             :     }
    2296                 :      326060 :   Sets_IncludeElementIntoSet (ChainedList, sym);
    2297                 :      326060 :   return sym;
    2298                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2299                 :             :   __builtin_unreachable ();
    2300                 :             : }
    2301                 :             : 
    2302                 :             : 
    2303                 :             : /*
    2304                 :             :    DoStartDeclaration - returns a tree representing a symbol which has
    2305                 :             :                         not yet been finished.  Used when declaring
    2306                 :             :                         recursive types.
    2307                 :             : */
    2308                 :             : 
    2309                 :      274322 : static tree DoStartDeclaration (unsigned int sym, M2GCCDeclare_StartProcedure p)
    2310                 :             : {
    2311                 :      274322 :   location_t location;
    2312                 :             : 
    2313                 :      274322 :   if (! (SymbolConversion_GccKnowsAbout (sym)))
    2314                 :             :     {
    2315                 :      137161 :       location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    2316                 :      137161 :       PreAddModGcc (sym, (tree) ((*p.proc) (location, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym)))));
    2317                 :             :     }
    2318                 :      274322 :   return SymbolConversion_Mod2Gcc (sym);
    2319                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2320                 :             :   __builtin_unreachable ();
    2321                 :             : }
    2322                 :             : 
    2323                 :             : 
    2324                 :             : /*
    2325                 :             :    ArrayComponentsDeclared - returns TRUE if array, sym,
    2326                 :             :                              subscripts and type are known.
    2327                 :             : */
    2328                 :             : 
    2329                 :       58550 : static bool ArrayComponentsDeclared (unsigned int sym)
    2330                 :             : {
    2331                 :       58550 :   unsigned int Subscript;
    2332                 :       58550 :   unsigned int Type;
    2333                 :       58550 :   unsigned int High;
    2334                 :       58550 :   unsigned int Low;
    2335                 :             : 
    2336                 :       58550 :   Subscript = SymbolTable_GetArraySubscript (sym);
    2337                 :       58550 :   M2Debug_Assert (SymbolTable_IsSubscript (Subscript));
    2338                 :       58550 :   Type = SymbolTable_GetDType (Subscript);
    2339                 :       58550 :   Low = M2GCCDeclare_GetTypeMin (Type);
    2340                 :       58550 :   High = M2GCCDeclare_GetTypeMax (Type);
    2341                 :       73492 :   return ((IsFullyDeclared (Type)) && (IsFullyDeclared (Low))) && (IsFullyDeclared (High));
    2342                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2343                 :             :   __builtin_unreachable ();
    2344                 :             : }
    2345                 :             : 
    2346                 :             : 
    2347                 :             : /*
    2348                 :             :    GetRecordOfVarient -
    2349                 :             : */
    2350                 :             : 
    2351                 :      147999 : static unsigned int GetRecordOfVarient (unsigned int sym)
    2352                 :             : {
    2353                 :      147999 :   if ((SymbolTable_IsVarient (sym)) || (SymbolTable_IsFieldVarient (sym)))
    2354                 :             :     {
    2355                 :       67572 :       do {
    2356                 :       67572 :         sym = SymbolTable_GetParent (sym);
    2357                 :       67572 :       } while (! (SymbolTable_IsRecord (sym)));
    2358                 :             :     }
    2359                 :      147999 :   return sym;
    2360                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2361                 :             :   __builtin_unreachable ();
    2362                 :             : }
    2363                 :             : 
    2364                 :             : 
    2365                 :             : /*
    2366                 :             :    CanDeclareRecordKind -
    2367                 :             : */
    2368                 :             : 
    2369                 :       82749 : static bool CanDeclareRecordKind (unsigned int sym)
    2370                 :             : {
    2371                 :       82749 :   sym = GetRecordOfVarient (sym);
    2372                 :       82785 :   return (SymbolTable_IsRecord (sym)) && (((SymbolTable_GetDefaultRecordFieldAlignment (sym)) == SymbolTable_NulSym) || (IsFullyDeclared (SymbolTable_GetDefaultRecordFieldAlignment (sym))));
    2373                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2374                 :             :   __builtin_unreachable ();
    2375                 :             : }
    2376                 :             : 
    2377                 :             : 
    2378                 :             : /*
    2379                 :             :    DeclareRecordKind - works out whether record, sym, is packed or not.
    2380                 :             : */
    2381                 :             : 
    2382                 :       82749 : static void DeclareRecordKind (unsigned int sym)
    2383                 :             : {
    2384                 :       82749 :   if (SymbolTable_IsRecord (sym))
    2385                 :             :     {
    2386                 :       81807 :       DetermineIfRecordPacked (sym);
    2387                 :             :     }
    2388                 :       82749 :   WatchIncludeList (sym, M2GCCDeclare_todolist);
    2389                 :       82749 :   WatchRemoveList (sym, M2GCCDeclare_heldbyalignment);
    2390                 :       82749 :   WatchIncludeList (sym, M2GCCDeclare_finishedalignment);
    2391                 :      165498 :   if (AllDependantsFullyDeclared (sym))
    2392                 :             :     {}  /* empty.  */
    2393                 :             :   /* All good and ready to be solved.  */
    2394                 :       82749 : }
    2395                 :             : 
    2396                 :             : 
    2397                 :             : /*
    2398                 :             :    CanDeclareRecord -
    2399                 :             : */
    2400                 :             : 
    2401                 :      335022 : static bool CanDeclareRecord (unsigned int sym)
    2402                 :             : {
    2403                 :      335022 :   TraverseDependants (sym);
    2404                 :      335022 :   if (AllDependantsFullyDeclared (sym))
    2405                 :             :     {
    2406                 :             :       return true;
    2407                 :             :     }
    2408                 :             :   else
    2409                 :             :     {
    2410                 :      253089 :       WatchIncludeList (sym, M2GCCDeclare_finishedalignment);
    2411                 :      253089 :       return false;
    2412                 :             :     }
    2413                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2414                 :             :   __builtin_unreachable ();
    2415                 :             : }
    2416                 :             : 
    2417                 :             : 
    2418                 :             : /*
    2419                 :             :    FinishDeclareRecord -
    2420                 :             : */
    2421                 :             : 
    2422                 :       81933 : static void FinishDeclareRecord (unsigned int sym)
    2423                 :             : {
    2424                 :       81933 :   DeclareTypeConstFully (sym);
    2425                 :       81933 :   WatchRemoveList (sym, M2GCCDeclare_heldbyalignment);
    2426                 :       81933 :   WatchRemoveList (sym, M2GCCDeclare_finishedalignment);
    2427                 :       81933 :   WatchRemoveList (sym, M2GCCDeclare_todolist);
    2428                 :       81933 :   WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    2429                 :       81933 : }
    2430                 :             : 
    2431                 :             : 
    2432                 :             : /*
    2433                 :             :    CanDeclareTypePartially - return TRUE if we are able to make a
    2434                 :             :                              gcc partially created type.
    2435                 :             : */
    2436                 :             : 
    2437                 :    13168308 : static bool CanDeclareTypePartially (unsigned int sym)
    2438                 :             : {
    2439                 :    13168308 :   unsigned int type;
    2440                 :             : 
    2441                 :    13168308 :   if (Sets_IsElementInSet (GlobalGroup->PartiallyDeclared, sym))
    2442                 :             :     {
    2443                 :             :       return false;
    2444                 :             :     }
    2445                 :    12666236 :   else if ((((SymbolTable_IsProcType (sym)) || (SymbolTable_IsRecord (sym))) || (SymbolTable_IsVarient (sym))) || (SymbolTable_IsFieldVarient (sym)))
    2446                 :             :     {
    2447                 :             :       /* avoid dangling else.  */
    2448                 :      137161 :       return true;
    2449                 :             :     }
    2450                 :    12529075 :   else if (SymbolTable_IsType (sym))
    2451                 :             :     {
    2452                 :             :       /* avoid dangling else.  */
    2453                 :       63176 :       type = SymbolTable_GetSType (sym);
    2454                 :      126352 :       if ((type != SymbolTable_NulSym) && (IsNilTypedArrays (type)))
    2455                 :             :         {
    2456                 :             :           return true;
    2457                 :             :         }
    2458                 :             :     }
    2459                 :             :   return false;
    2460                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2461                 :             :   __builtin_unreachable ();
    2462                 :             : }
    2463                 :             : 
    2464                 :             : 
    2465                 :             : /*
    2466                 :             :    DeclareTypePartially - create the gcc partial type symbol from, sym.
    2467                 :             : */
    2468                 :             : 
    2469                 :      137167 : static void DeclareTypePartially (unsigned int sym)
    2470                 :             : {
    2471                 :      137167 :   location_t location;
    2472                 :             : 
    2473                 :             :   /* check to see if we have already partially declared the symbol  */
    2474                 :      137167 :   if (! (Sets_IsElementInSet (GlobalGroup->PartiallyDeclared, sym)))
    2475                 :             :     {
    2476                 :      137167 :       if (SymbolTable_IsRecord (sym))
    2477                 :             :         {
    2478                 :       81807 :           M2Debug_Assert (! (Sets_IsElementInSet (GlobalGroup->HeldByAlignment, sym)));
    2479                 :       81807 :           M2Debug_Assert ((DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartRecord})) != NULL);
    2480                 :       81807 :           WatchIncludeList (sym, M2GCCDeclare_heldbyalignment);
    2481                 :             :         }
    2482                 :       55360 :       else if (SymbolTable_IsVarient (sym))
    2483                 :             :         {
    2484                 :             :           /* avoid dangling else.  */
    2485                 :         276 :           M2Debug_Assert (! (Sets_IsElementInSet (GlobalGroup->HeldByAlignment, sym)));
    2486                 :         276 :           M2Debug_Assert ((DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartVarient})) != NULL);
    2487                 :         276 :           WatchIncludeList (sym, M2GCCDeclare_heldbyalignment);
    2488                 :             :         }
    2489                 :       55084 :       else if (SymbolTable_IsFieldVarient (sym))
    2490                 :             :         {
    2491                 :             :           /* avoid dangling else.  */
    2492                 :         666 :           M2Debug_Assert (! (Sets_IsElementInSet (GlobalGroup->HeldByAlignment, sym)));
    2493                 :         666 :           M2Debug_Assert ((DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartFieldVarient})) != NULL);
    2494                 :         666 :           WatchIncludeList (sym, M2GCCDeclare_heldbyalignment);
    2495                 :             :         }
    2496                 :       54418 :       else if (SymbolTable_IsProcType (sym))
    2497                 :             :         {
    2498                 :             :           /* avoid dangling else.  */
    2499                 :       54412 :           M2Debug_Assert ((DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartFunctionType})) != NULL);
    2500                 :             :         }
    2501                 :           6 :       else if (SymbolTable_IsType (sym))
    2502                 :             :         {
    2503                 :             :           /* avoid dangling else.  */
    2504                 :           6 :           if (! (SymbolConversion_GccKnowsAbout (sym)))
    2505                 :             :             {
    2506                 :           6 :               location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    2507                 :           6 :               PreAddModGcc (sym, m2type_BuildStartType (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym))), SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym))));
    2508                 :             :             }
    2509                 :             :         }
    2510                 :             :       else
    2511                 :             :         {
    2512                 :             :           /* avoid dangling else.  */
    2513                 :           0 :           M2Error_InternalError ((const char *) "do not know how to create a partial type from this symbol", 57);
    2514                 :             :         }
    2515                 :      137167 :       WatchIncludeList (sym, M2GCCDeclare_partiallydeclared);
    2516                 :      137167 :       TraverseDependants (sym);
    2517                 :             :     }
    2518                 :      137167 : }
    2519                 :             : 
    2520                 :             : 
    2521                 :             : /*
    2522                 :             :    CanDeclareArrayAsNil -
    2523                 :             : */
    2524                 :             : 
    2525                 :    13324092 : static bool CanDeclareArrayAsNil (unsigned int sym)
    2526                 :             : {
    2527                 :    13324092 :   return (SymbolTable_IsArray (sym)) && (ArrayComponentsDeclared (sym));
    2528                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2529                 :             :   __builtin_unreachable ();
    2530                 :             : }
    2531                 :             : 
    2532                 :             : 
    2533                 :             : /*
    2534                 :             :    DeclareArrayAsNil -
    2535                 :             : */
    2536                 :             : 
    2537                 :        7456 : static void DeclareArrayAsNil (unsigned int sym)
    2538                 :             : {
    2539                 :        7456 :   PreAddModGcc (sym, m2type_BuildStartArrayType (BuildIndex (SymbolTable_GetDeclaredMod (sym), sym), NULL, static_cast<int> (SymbolTable_GetDType (sym))));
    2540                 :        7456 :   WatchIncludeList (sym, M2GCCDeclare_niltypedarrays);
    2541                 :        7456 : }
    2542                 :             : 
    2543                 :             : 
    2544                 :             : /*
    2545                 :             :    CanDeclareArrayPartially -
    2546                 :             : */
    2547                 :             : 
    2548                 :       26684 : static bool CanDeclareArrayPartially (unsigned int sym)
    2549                 :             : {
    2550                 :       26684 :   unsigned int type;
    2551                 :             : 
    2552                 :       26684 :   if (SymbolTable_IsArray (sym))
    2553                 :             :     {
    2554                 :       26372 :       type = SymbolTable_GetSType (sym);
    2555                 :       45262 :       if ((IsPartiallyOrFullyDeclared (type)) || ((SymbolTable_IsPointer (type)) && (IsNilTypedArrays (type))))
    2556                 :             :         {
    2557                 :        7414 :           return true;
    2558                 :             :         }
    2559                 :             :     }
    2560                 :             :   return false;
    2561                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2562                 :             :   __builtin_unreachable ();
    2563                 :             : }
    2564                 :             : 
    2565                 :             : 
    2566                 :             : /*
    2567                 :             :    DeclareArrayPartially -
    2568                 :             : */
    2569                 :             : 
    2570                 :        7414 : static void DeclareArrayPartially (unsigned int sym)
    2571                 :             : {
    2572                 :        7414 :   M2Debug_Assert ((SymbolTable_IsArray (sym)) && (SymbolConversion_GccKnowsAbout (sym)));
    2573                 :        7414 :   m2type_PutArrayType (SymbolConversion_Mod2Gcc (sym), SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym)));
    2574                 :        7414 :   WatchIncludeList (sym, M2GCCDeclare_partiallydeclared);
    2575                 :        7414 : }
    2576                 :             : 
    2577                 :             : 
    2578                 :             : /*
    2579                 :             :    CanDeclarePointerToNilArray -
    2580                 :             : */
    2581                 :             : 
    2582                 :    13005590 : static bool CanDeclarePointerToNilArray (unsigned int sym)
    2583                 :             : {
    2584                 :    13365622 :   return (SymbolTable_IsPointer (sym)) && (IsNilTypedArrays (SymbolTable_GetSType (sym)));
    2585                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2586                 :             :   __builtin_unreachable ();
    2587                 :             : }
    2588                 :             : 
    2589                 :             : 
    2590                 :             : /*
    2591                 :             :    DeclarePointerToNilArray -
    2592                 :             : */
    2593                 :             : 
    2594                 :          96 : static void DeclarePointerToNilArray (unsigned int sym)
    2595                 :             : {
    2596                 :          96 :   PreAddModGcc (sym, m2type_BuildPointerType (SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym))));
    2597                 :          96 :   WatchIncludeList (sym, M2GCCDeclare_niltypedarrays);
    2598                 :          96 : }
    2599                 :             : 
    2600                 :             : 
    2601                 :             : /*
    2602                 :             :    CanPromotePointerFully -
    2603                 :             : */
    2604                 :             : 
    2605                 :       13606 : static bool CanPromotePointerFully (unsigned int sym)
    2606                 :             : {
    2607                 :       13606 :   return (SymbolTable_IsPointer (sym)) && (IsPartiallyOrFullyDeclared (SymbolTable_GetSType (sym)));
    2608                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2609                 :             :   __builtin_unreachable ();
    2610                 :             : }
    2611                 :             : 
    2612                 :             : 
    2613                 :             : /*
    2614                 :             :    PromotePointerFully -
    2615                 :             : */
    2616                 :             : 
    2617                 :          90 : static void PromotePointerFully (unsigned int sym)
    2618                 :             : {
    2619                 :          90 :   WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    2620                 :          90 : }
    2621                 :             : 
    2622                 :             : 
    2623                 :             : /*
    2624                 :             :    IsTypeQ - returns TRUE if all q(dependants) of, sym,
    2625                 :             :              return TRUE.
    2626                 :             : */
    2627                 :             : 
    2628                 :     4020141 : static bool IsTypeQ (unsigned int sym, M2GCCDeclare_IsAction q)
    2629                 :             : {
    2630                 :     4020141 :   if (SymbolTable_IsVar (sym))
    2631                 :             :     {
    2632                 :           0 :       return IsVarDependants (sym, q);
    2633                 :             :     }
    2634                 :     4020141 :   else if (SymbolTable_IsEnumeration (sym))
    2635                 :             :     {
    2636                 :             :       /* avoid dangling else.  */
    2637                 :      104625 :       return IsEnumerationDependants (sym, q);
    2638                 :             :     }
    2639                 :     3915516 :   else if (SymbolTable_IsFieldEnumeration (sym))
    2640                 :             :     {
    2641                 :             :       /* avoid dangling else.  */
    2642                 :             :       return true;
    2643                 :             :     }
    2644                 :     3491694 :   else if (SymbolTable_IsSubrange (sym))
    2645                 :             :     {
    2646                 :             :       /* avoid dangling else.  */
    2647                 :       53494 :       return IsSubrangeDependants (sym, q);
    2648                 :             :     }
    2649                 :     3438200 :   else if (SymbolTable_IsPointer (sym))
    2650                 :             :     {
    2651                 :             :       /* avoid dangling else.  */
    2652                 :      887917 :       return IsPointerDependants (sym, q);
    2653                 :             :     }
    2654                 :     2550283 :   else if (SymbolTable_IsRecord (sym))
    2655                 :             :     {
    2656                 :             :       /* avoid dangling else.  */
    2657                 :      518909 :       return IsRecordDependants (sym, q);
    2658                 :             :     }
    2659                 :     2031374 :   else if (SymbolTable_IsRecordField (sym))
    2660                 :             :     {
    2661                 :             :       /* avoid dangling else.  */
    2662                 :      800692 :       return IsRecordFieldDependants (sym, q);
    2663                 :             :     }
    2664                 :     1230682 :   else if (SymbolTable_IsVarient (sym))
    2665                 :             :     {
    2666                 :             :       /* avoid dangling else.  */
    2667                 :        2190 :       return IsVarientDependants (sym, q);
    2668                 :             :     }
    2669                 :     1228492 :   else if (SymbolTable_IsFieldVarient (sym))
    2670                 :             :     {
    2671                 :             :       /* avoid dangling else.  */
    2672                 :        3654 :       return IsVarientFieldDependants (sym, q);
    2673                 :             :     }
    2674                 :     1224838 :   else if (SymbolTable_IsArray (sym))
    2675                 :             :     {
    2676                 :             :       /* avoid dangling else.  */
    2677                 :      113622 :       return IsArrayDependants (sym, q);
    2678                 :             :     }
    2679                 :     1111216 :   else if (SymbolTable_IsProcType (sym))
    2680                 :             :     {
    2681                 :             :       /* avoid dangling else.  */
    2682                 :      211642 :       return IsProcTypeDependants (sym, q);
    2683                 :             :     }
    2684                 :      899574 :   else if (SymbolTable_IsUnbounded (sym))
    2685                 :             :     {
    2686                 :             :       /* avoid dangling else.  */
    2687                 :      204648 :       return IsUnboundedDependants (sym, q);
    2688                 :             :     }
    2689                 :      694926 :   else if (SymbolTable_IsPartialUnbounded (sym))
    2690                 :             :     {
    2691                 :             :       /* avoid dangling else.  */
    2692                 :           0 :       M2Error_InternalError ((const char *) "should not be declaring a partial unbounded symbol", 50);
    2693                 :             :     }
    2694                 :      694926 :   else if (SymbolTable_IsSet (sym))
    2695                 :             :     {
    2696                 :             :       /* avoid dangling else.  */
    2697                 :       21628 :       return IsSetDependants (sym, q);
    2698                 :             :     }
    2699                 :      673298 :   else if (SymbolTable_IsType (sym))
    2700                 :             :     {
    2701                 :             :       /* avoid dangling else.  */
    2702                 :      506160 :       return IsTypeDependants (sym, q);
    2703                 :             :     }
    2704                 :      167138 :   else if (SymbolTable_IsConst (sym))
    2705                 :             :     {
    2706                 :             :       /* avoid dangling else.  */
    2707                 :      166568 :       return IsConstDependants (sym, q);
    2708                 :             :     }
    2709                 :         570 :   else if ((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym)))
    2710                 :             :     {
    2711                 :             :       /* avoid dangling else.  */
    2712                 :             :       /* sym can be a constructor, but at present we have not resolved whether
    2713                 :             :          all dependants are constants.
    2714                 :             :   */
    2715                 :           0 :       return M2ALU_IsConstructorDependants (sym, q);
    2716                 :             :     }
    2717                 :         570 :   else if (SymbolTable_IsProcedure (sym))
    2718                 :             :     {
    2719                 :             :       /* avoid dangling else.  */
    2720                 :         426 :       return IsProcedureDependants (sym, q);
    2721                 :             :     }
    2722                 :             :   else
    2723                 :             :     {
    2724                 :             :       /* avoid dangling else.  */
    2725                 :             :       return true;
    2726                 :             :     }
    2727                 :             :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2GCCDeclare.def", 20, 1);
    2728                 :             :   __builtin_unreachable ();
    2729                 :             : }
    2730                 :             : 
    2731                 :             : 
    2732                 :             : /*
    2733                 :             :    IsNilTypedArrays - returns TRUE if, sym, is dependant upon a NIL typed array
    2734                 :             : */
    2735                 :             : 
    2736                 :      442098 : static bool IsNilTypedArrays (unsigned int sym)
    2737                 :             : {
    2738                 :      442098 :   return Sets_IsElementInSet (GlobalGroup->NilTypedArrays, sym);
    2739                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2740                 :             :   __builtin_unreachable ();
    2741                 :             : }
    2742                 :             : 
    2743                 :             : 
    2744                 :             : /*
    2745                 :             :    IsFullyDeclared - returns TRUE if, sym, is fully declared.
    2746                 :             : */
    2747                 :             : 
    2748                 :     7211459 : static bool IsFullyDeclared (unsigned int sym)
    2749                 :             : {
    2750                 :     6927349 :   return Sets_IsElementInSet (GlobalGroup->FullyDeclared, sym);
    2751                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2752                 :             :   __builtin_unreachable ();
    2753                 :             : }
    2754                 :             : 
    2755                 :             : 
    2756                 :             : /*
    2757                 :             :    AllDependantsFullyDeclared - returns TRUE if all dependants of,
    2758                 :             :                                 sym, are declared.
    2759                 :             : */
    2760                 :             : 
    2761                 :     3997209 : static bool AllDependantsFullyDeclared (unsigned int sym)
    2762                 :             : {
    2763                 :     2595346 :   return IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared});
    2764                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2765                 :             :   __builtin_unreachable ();
    2766                 :             : }
    2767                 :             : 
    2768                 :             : 
    2769                 :             : /*
    2770                 :             :    NotAllDependantsFullyDeclared - returns TRUE if any dependants of,
    2771                 :             :                                    sym, are not declared.
    2772                 :             : */
    2773                 :             : 
    2774                 :           0 : static bool NotAllDependantsFullyDeclared (unsigned int sym)
    2775                 :             : {
    2776                 :           0 :   return ! (IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared}));
    2777                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2778                 :             :   __builtin_unreachable ();
    2779                 :             : }
    2780                 :             : 
    2781                 :             : 
    2782                 :             : /*
    2783                 :             :    IsPartiallyDeclared - returns TRUE if, sym, is partially declared.
    2784                 :             : */
    2785                 :             : 
    2786                 :           0 : static bool IsPartiallyDeclared (unsigned int sym)
    2787                 :             : {
    2788                 :           0 :   return Sets_IsElementInSet (GlobalGroup->PartiallyDeclared, sym);
    2789                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2790                 :             :   __builtin_unreachable ();
    2791                 :             : }
    2792                 :             : 
    2793                 :             : 
    2794                 :             : /*
    2795                 :             :    AllDependantsPartiallyDeclared - returns TRUE if all dependants of,
    2796                 :             :                                     sym, are partially declared.
    2797                 :             : */
    2798                 :             : 
    2799                 :           0 : static bool AllDependantsPartiallyDeclared (unsigned int sym)
    2800                 :             : {
    2801                 :           0 :   return IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsPartiallyDeclared});
    2802                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2803                 :             :   __builtin_unreachable ();
    2804                 :             : }
    2805                 :             : 
    2806                 :             : 
    2807                 :             : /*
    2808                 :             :    NotAllDependantsPartiallyDeclared - returns TRUE if any dependants of,
    2809                 :             :                                        sym, are not partially declared.
    2810                 :             : */
    2811                 :             : 
    2812                 :           0 : static bool NotAllDependantsPartiallyDeclared (unsigned int sym)
    2813                 :             : {
    2814                 :           0 :   return ! (IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsPartiallyDeclared}));
    2815                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2816                 :             :   __builtin_unreachable ();
    2817                 :             : }
    2818                 :             : 
    2819                 :             : 
    2820                 :             : /*
    2821                 :             :    IsPartiallyOrFullyDeclared - returns TRUE if, sym, is partially or fully declared.
    2822                 :             : */
    2823                 :             : 
    2824                 :       59938 : static bool IsPartiallyOrFullyDeclared (unsigned int sym)
    2825                 :             : {
    2826                 :       59938 :   return (Sets_IsElementInSet (GlobalGroup->PartiallyDeclared, sym)) || (Sets_IsElementInSet (GlobalGroup->FullyDeclared, sym));
    2827                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2828                 :             :   __builtin_unreachable ();
    2829                 :             : }
    2830                 :             : 
    2831                 :             : 
    2832                 :             : /*
    2833                 :             :    AllDependantsPartiallyOrFullyDeclared - returns TRUE if all dependants of,
    2834                 :             :                                            sym, are partially or fully declared.
    2835                 :             : */
    2836                 :             : 
    2837                 :       22932 : static bool AllDependantsPartiallyOrFullyDeclared (unsigned int sym)
    2838                 :             : {
    2839                 :       22932 :   return IsTypeQ (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsPartiallyOrFullyDeclared});
    2840                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2841                 :             :   __builtin_unreachable ();
    2842                 :             : }
    2843                 :             : 
    2844                 :             : 
    2845                 :             : /*
    2846                 :             :    TypeConstDependantsFullyDeclared - returns TRUE if sym is a constant or
    2847                 :             :                                       type and its dependants are fully
    2848                 :             :                                       declared.
    2849                 :             : */
    2850                 :             : 
    2851                 :    14272886 : static bool TypeConstDependantsFullyDeclared (unsigned int sym)
    2852                 :             : {
    2853                 :    16450461 :   return (((! (SymbolTable_IsVar (sym))) && (! (SymbolTable_IsRecord (sym)))) && (! (SymbolTable_IsParameter (sym)))) && (AllDependantsFullyDeclared (sym));
    2854                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2855                 :             :   __builtin_unreachable ();
    2856                 :             : }
    2857                 :             : 
    2858                 :             : 
    2859                 :             : /*
    2860                 :             :    CanBeDeclaredViaPartialDependants - returns TRUE if this symbol
    2861                 :             :                                        can be declared by partial
    2862                 :             :                                        dependants.  Such a symbol must
    2863                 :             :                                        be a record, proctype or
    2864                 :             :                                        an array.
    2865                 :             : */
    2866                 :             : 
    2867                 :     8307087 : static bool CanBeDeclaredViaPartialDependants (unsigned int sym)
    2868                 :             : {
    2869                 :     8330019 :   return ((SymbolTable_IsPointer (sym)) || (SymbolTable_IsProcType (sym))) && (AllDependantsPartiallyOrFullyDeclared (sym));
    2870                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2871                 :             :   __builtin_unreachable ();
    2872                 :             : }
    2873                 :             : 
    2874                 :             : 
    2875                 :             : /*
    2876                 :             :    DeclareConstFully - will add, sym, to the fully declared list and
    2877                 :             :                        also remove it from the to do list.  This is
    2878                 :             :                        called indirectly from M2GenGCC as it calculates
    2879                 :             :                        constants during quadruple processing.
    2880                 :             : */
    2881                 :             : 
    2882                 :      378604 : static void DeclareConstFully (unsigned int sym)
    2883                 :             : {
    2884                 :      378604 :   WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    2885                 :      378604 :   WatchRemoveList (sym, M2GCCDeclare_todolist);
    2886                 :      378604 :   WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
    2887                 :      378604 :   WatchRemoveList (sym, M2GCCDeclare_tobesolvedbyquads);
    2888                 :      378604 : }
    2889                 :             : 
    2890                 :             : 
    2891                 :             : /*
    2892                 :             :    DeclareTypeConstFully - declare the GCC type and add the double
    2893                 :             :                            book keeping entry.
    2894                 :             : */
    2895                 :             : 
    2896                 :     1187408 : static void DeclareTypeConstFully (unsigned int sym)
    2897                 :             : {
    2898                 :     1187408 :   tree t;
    2899                 :             : 
    2900                 :     1187408 :   if (! (Sets_IsElementInSet (GlobalGroup->ToBeSolvedByQuads, sym)))
    2901                 :             :     {
    2902                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    2903                 :     1187408 :       if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
    2904                 :             :         {
    2905                 :         144 :           WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    2906                 :         144 :           WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
    2907                 :         144 :           WatchRemoveList (sym, M2GCCDeclare_todolist);
    2908                 :             :         }
    2909                 :     1187264 :       else if (SymbolTable_IsProcedure (sym))
    2910                 :             :         {
    2911                 :             :           /* avoid dangling else.  */
    2912                 :         408 :           DeclareProcedureToGcc (sym);
    2913                 :         408 :           WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    2914                 :         408 :           WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
    2915                 :         408 :           WatchRemoveList (sym, M2GCCDeclare_todolist);
    2916                 :             :         }
    2917                 :             :       else
    2918                 :             :         {
    2919                 :             :           /* avoid dangling else.  */
    2920                 :     1186856 :           t = TypeConstFullyDeclared (sym);
    2921                 :     1186856 :           if (t != NULL)
    2922                 :             :             {
    2923                 :             :               /* add relationship between gccsym and sym  */
    2924                 :     2373712 :               PreAddModGcc (sym, t);
    2925                 :     1186856 :               WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    2926                 :     1186856 :               WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
    2927                 :     1186856 :               WatchRemoveList (sym, M2GCCDeclare_heldbyalignment);
    2928                 :     1186856 :               WatchRemoveList (sym, M2GCCDeclare_finishedalignment);
    2929                 :     1186856 :               WatchRemoveList (sym, M2GCCDeclare_todolist);
    2930                 :             :             }
    2931                 :             :         }
    2932                 :             :     }
    2933                 :     1187408 : }
    2934                 :             : 
    2935                 :             : 
    2936                 :             : /*
    2937                 :             :    DeclareTypeFromPartial - declare the full GCC type from a partial type
    2938                 :             :                             and add the double book keeping entry.
    2939                 :             : */
    2940                 :             : 
    2941                 :       22932 : static void DeclareTypeFromPartial (unsigned int sym)
    2942                 :             : {
    2943                 :       22932 :   tree t;
    2944                 :             : 
    2945                 :       22932 :   t = CompleteDeclarationOf (sym);
    2946                 :       22932 :   if (t == NULL)
    2947                 :             :     {
    2948                 :           0 :       M2Error_InternalError ((const char *) "expecting to be able to create a gcc type", 41);
    2949                 :             :     }
    2950                 :             :   else
    2951                 :             :     {
    2952                 :       22932 :       SymbolConversion_AddModGcc (sym, t);
    2953                 :       22932 :       WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    2954                 :       22932 :       WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
    2955                 :             :     }
    2956                 :       22932 : }
    2957                 :             : 
    2958                 :             : 
    2959                 :             : /*
    2960                 :             :    CanBeDeclaredPartiallyViaPartialDependants - returns TRUE if, sym,
    2961                 :             :                                                 can be partially declared via
    2962                 :             :                                                 another partially declared type.
    2963                 :             : */
    2964                 :             : 
    2965                 :        6432 : static bool CanBeDeclaredPartiallyViaPartialDependants (unsigned int sym)
    2966                 :             : {
    2967                 :        6432 :   return (SymbolTable_IsType (sym)) && (AllDependantsPartiallyDeclared (sym));
    2968                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    2969                 :             :   __builtin_unreachable ();
    2970                 :             : }
    2971                 :             : 
    2972                 :             : 
    2973                 :             : /*
    2974                 :             :    EmitCircularDependencyError - issue a dependency error.
    2975                 :             : */
    2976                 :             : 
    2977                 :         144 : static void EmitCircularDependencyError (unsigned int sym)
    2978                 :             : {
    2979                 :             :   /* Ensure we only issue one dependency message per symbol for this
    2980                 :             :       error classification.  */
    2981                 :         144 :   if (! (Sets_IsElementInSet (ErrorDepList, sym)))
    2982                 :             :     {
    2983                 :         114 :       Sets_IncludeElementIntoSet (ErrorDepList, sym);
    2984                 :         114 :       if ((SymbolTable_IsVar (sym)) || (SymbolTable_IsParameter (sym)))
    2985                 :             :         {
    2986                 :          24 :           M2MetaError_MetaError1 ((const char *) "circular dependency error found when trying to resolve {%1Had}", 62, sym);
    2987                 :             :         }
    2988                 :             :       else
    2989                 :             :         {
    2990                 :          90 :           M2MetaError_MetaError1 ((const char *) "circular dependency error found when trying to resolve {%1Dad}", 62, sym);
    2991                 :             :         }
    2992                 :             :     }
    2993                 :         144 : }
    2994                 :             : 
    2995                 :             : 
    2996                 :             : /*
    2997                 :             :    WriteRule - writes out the name of the rule.
    2998                 :             : */
    2999                 :             : 
    3000                 :           0 : static void WriteRule (void)
    3001                 :             : {
    3002                 :           0 :   if (Debugging)
    3003                 :             :     {
    3004                 :             :       switch (bodyr)
    3005                 :             :         {
    3006                 :             :           case M2GCCDeclare_norule:
    3007                 :             :             M2Printf_printf0 ((const char *) "norule", 6);
    3008                 :             :             break;
    3009                 :             : 
    3010                 :             :           case M2GCCDeclare_partialtype:
    3011                 :             :             M2Printf_printf0 ((const char *) "partialtype", 11);
    3012                 :             :             break;
    3013                 :             : 
    3014                 :             :           case M2GCCDeclare_arraynil:
    3015                 :             :             M2Printf_printf0 ((const char *) "arraynil", 8);
    3016                 :             :             break;
    3017                 :             : 
    3018                 :             :           case M2GCCDeclare_pointernilarray:
    3019                 :             :             M2Printf_printf0 ((const char *) "pointernilarray", 15);
    3020                 :             :             break;
    3021                 :             : 
    3022                 :             :           case M2GCCDeclare_arraypartial:
    3023                 :             :             M2Printf_printf0 ((const char *) "arraypartial", 12);
    3024                 :             :             break;
    3025                 :             : 
    3026                 :             :           case M2GCCDeclare_pointerfully:
    3027                 :             :             M2Printf_printf0 ((const char *) "pointerfully", 12);
    3028                 :             :             break;
    3029                 :             : 
    3030                 :             :           case M2GCCDeclare_recordkind:
    3031                 :             :             M2Printf_printf0 ((const char *) "recordkind", 10);
    3032                 :             :             break;
    3033                 :             : 
    3034                 :             :           case M2GCCDeclare_recordfully:
    3035                 :             :             M2Printf_printf0 ((const char *) "recordfully", 11);
    3036                 :             :             break;
    3037                 :             : 
    3038                 :             :           case M2GCCDeclare_typeconstfully:
    3039                 :             :             M2Printf_printf0 ((const char *) "typeconstfully", 14);
    3040                 :             :             break;
    3041                 :             : 
    3042                 :             :           case M2GCCDeclare_pointerfrompartial:
    3043                 :             :             M2Printf_printf0 ((const char *) "pointerfrompartial", 18);
    3044                 :             :             break;
    3045                 :             : 
    3046                 :             :           case M2GCCDeclare_typefrompartial:
    3047                 :             :             M2Printf_printf0 ((const char *) "typefrompartial", 15);
    3048                 :             :             break;
    3049                 :             : 
    3050                 :             :           case M2GCCDeclare_partialfrompartial:
    3051                 :             :             M2Printf_printf0 ((const char *) "partialfrompartial", 18);
    3052                 :             :             break;
    3053                 :             : 
    3054                 :             :           case M2GCCDeclare_partialtofully:
    3055                 :             :             M2Printf_printf0 ((const char *) "partialtofully", 14);
    3056                 :             :             break;
    3057                 :             : 
    3058                 :             :           case M2GCCDeclare_circulartodo:
    3059                 :             :             M2Printf_printf0 ((const char *) "circulartodo", 12);
    3060                 :             :             break;
    3061                 :             : 
    3062                 :             :           case M2GCCDeclare_circularpartial:
    3063                 :             :             M2Printf_printf0 ((const char *) "circularpartial", 15);
    3064                 :             :             break;
    3065                 :             : 
    3066                 :             :           case M2GCCDeclare_circularniltyped:
    3067                 :             :             M2Printf_printf0 ((const char *) "circularniltyped", 16);
    3068                 :             :             break;
    3069                 :             : 
    3070                 :             : 
    3071                 :             :           default:
    3072                 :             :             M2Error_InternalError ((const char *) "unknown rule", 12);
    3073                 :             :             break;
    3074                 :             :         }
    3075                 :             :     }
    3076                 :           0 : }
    3077                 :             : 
    3078                 :             : 
    3079                 :             : /*
    3080                 :             :    Body -
    3081                 :             : */
    3082                 :             : 
    3083                 :    62542456 : static void Body (unsigned int sym)
    3084                 :             : {
    3085                 :    62542456 :   if ((*bodyq.proc) (sym))
    3086                 :             :     {
    3087                 :     1445312 :       WatchRemoveList (sym, bodyt);
    3088                 :     1445312 :       (*bodyp.proc) (sym);
    3089                 :             :       /* The bodyp (sym) procedure function might have replaced sym into the set.  */
    3090                 :     1445312 :       if (! (Sets_IsElementInSet (LookupSet (bodyt), sym)))
    3091                 :             :         {
    3092                 :     1308145 :           noMoreWritten = false;
    3093                 :     1308145 :           oneResolved = true;
    3094                 :             :         }
    3095                 :             :     }
    3096                 :    62542456 : }
    3097                 :             : 
    3098                 :             : 
    3099                 :             : /*
    3100                 :             :    ForeachTryDeclare - while q (of one sym in set t) is true
    3101                 :             :                           for each symbol in set t,
    3102                 :             :                              if q (sym)
    3103                 :             :                              then
    3104                 :             :                                 p (sym)
    3105                 :             :                              end
    3106                 :             :                           end
    3107                 :             :                        end
    3108                 :             : */
    3109                 :             : 
    3110                 :     7803150 : static bool ForeachTryDeclare (M2GCCDeclare_ListType t, M2GCCDeclare_Rule r, M2GCCDeclare_IsAction q, M2GCCDeclare_WalkAction p)
    3111                 :             : {
    3112                 :     7803150 :   if (recursionCaught)
    3113                 :             :     {
    3114                 :           0 :       M2Error_InternalError ((const char *) "caught recursive cycle in ForeachTryDeclare", 43);
    3115                 :             :     }
    3116                 :     7803150 :   bodyt = t;
    3117                 :     7803150 :   bodyq = q;
    3118                 :     7803150 :   bodyp = p;
    3119                 :     7803150 :   bodyr = r;
    3120                 :     7803150 :   recursionCaught = true;
    3121                 :     7803150 :   oneResolved = false;
    3122                 :     7916400 :   do {
    3123                 :     7916400 :     noMoreWritten = true;
    3124                 :     7916400 :     Sets_ForeachElementInSetDo (LookupSet (t), (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) Body});
    3125                 :     7916400 :   } while (! (noMoreWritten));
    3126                 :     7803150 :   bodyr = M2GCCDeclare_norule;
    3127                 :     7803150 :   recursionCaught = false;
    3128                 :     7803150 :   return oneResolved;
    3129                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3130                 :             :   __builtin_unreachable ();
    3131                 :             : }
    3132                 :             : 
    3133                 :      645529 : static bool DeclaredOutstandingTypes (bool ForceComplete)
    3134                 :             : {
    3135                 :      645529 :   bool finished;
    3136                 :      645529 :   M2GCCDeclare_Group copy;
    3137                 :             : 
    3138                 :             :   /* 
    3139                 :             :    DeclaredOutandingTypes - writes out any types that have their
    3140                 :             :                             dependants solved.  It returns TRUE if
    3141                 :             :                             all outstanding types have been written.
    3142                 :             :   */
    3143                 :      645529 :   copy = NULL;
    3144                 :      645529 :   finished = false;
    3145                 :      744005 :   do {
    3146                 :      744005 :     if (Progress && (copy != NULL))
    3147                 :             :       {
    3148                 :             :         if (! (EqualGroup (copy, GlobalGroup)))
    3149                 :             :           {
    3150                 :             :             DebugSetNumbers ();
    3151                 :             :             DebugSets ();
    3152                 :             :           }
    3153                 :             :       }
    3154                 :      744005 :     copy = DupGroup (copy);
    3155                 :      744005 :     if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_partialtype, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareTypePartially}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypePartially}))
    3156                 :             :       {}  /* empty.  */
    3157                 :             :     /* Continue looping.  */
    3158                 :      744005 :     else if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_arraynil, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareArrayAsNil}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareArrayAsNil}))
    3159                 :             :       {
    3160                 :             :         /* avoid dangling else.  */
    3161                 :             :       }
    3162                 :      740233 :     else if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_pointernilarray, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclarePointerToNilArray}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclarePointerToNilArray}))
    3163                 :             :       {
    3164                 :             :         /* avoid dangling else.  */
    3165                 :             :       }
    3166                 :      740155 :     else if (ForeachTryDeclare (M2GCCDeclare_niltypedarrays, M2GCCDeclare_arraypartial, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareArrayPartially}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareArrayPartially}))
    3167                 :             :       {
    3168                 :             :         /* avoid dangling else.  */
    3169                 :             :       }
    3170                 :      733801 :     else if (ForeachTryDeclare (M2GCCDeclare_niltypedarrays, M2GCCDeclare_pointerfully, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanPromotePointerFully}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) PromotePointerFully}))
    3171                 :             :       {
    3172                 :             :         /* avoid dangling else.  */
    3173                 :             :       }
    3174                 :      733729 :     else if (ForeachTryDeclare (M2GCCDeclare_heldbyalignment, M2GCCDeclare_recordkind, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareRecordKind}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareRecordKind}))
    3175                 :             :       {
    3176                 :             :         /* avoid dangling else.  */
    3177                 :             :       }
    3178                 :      719444 :     else if (ForeachTryDeclare (M2GCCDeclare_finishedalignment, M2GCCDeclare_recordfully, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanDeclareRecord}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) FinishDeclareRecord}))
    3179                 :             :       {
    3180                 :             :         /* avoid dangling else.  */
    3181                 :             :       }
    3182                 :      698383 :     else if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_typeconstfully, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) TypeConstDependantsFullyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypeConstFully}))
    3183                 :             :       {
    3184                 :             :         /* avoid dangling else.  */
    3185                 :             :       }
    3186                 :      651969 :     else if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_typefrompartial, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanBeDeclaredViaPartialDependants}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypeFromPartial}))
    3187                 :             :       {
    3188                 :             :         /* avoid dangling else.  */
    3189                 :             :       }
    3190                 :      648713 :     else if (ForeachTryDeclare (M2GCCDeclare_partiallydeclared, M2GCCDeclare_partialfrompartial, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) CanBeDeclaredPartiallyViaPartialDependants}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypePartially}))
    3191                 :             :       {
    3192                 :             :         /* avoid dangling else.  */
    3193                 :             :       }
    3194                 :      648713 :     else if (ForeachTryDeclare (M2GCCDeclare_partiallydeclared, M2GCCDeclare_partialtofully, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) TypeConstDependantsFullyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareTypeConstFully}))
    3195                 :             :       {
    3196                 :             :         /* avoid dangling else.  */
    3197                 :             :       }
    3198                 :             :     else
    3199                 :             :       {
    3200                 :             :         /* avoid dangling else.  */
    3201                 :             :         /* Nothing left to do (and constants are resolved elsewhere).  */
    3202                 :      744005 :         finished = true;
    3203                 :             :       }
    3204                 :      744005 :   } while (! (finished));
    3205                 :      645529 :   KillGroup (&copy);
    3206                 :      645529 :   if (ForceComplete)
    3207                 :             :     {
    3208                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    3209                 :           0 :       if (ForeachTryDeclare (M2GCCDeclare_todolist, M2GCCDeclare_circulartodo, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) NotAllDependantsFullyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) EmitCircularDependencyError}))
    3210                 :             :         {}  /* empty.  */
    3211                 :           0 :       else if (ForeachTryDeclare (M2GCCDeclare_partiallydeclared, M2GCCDeclare_circularpartial, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) NotAllDependantsPartiallyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) EmitCircularDependencyError}))
    3212                 :             :         {
    3213                 :             :           /* avoid dangling else.  */
    3214                 :             :         }
    3215                 :           0 :       else if (ForeachTryDeclare (M2GCCDeclare_niltypedarrays, M2GCCDeclare_circularniltyped, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) NotAllDependantsPartiallyDeclared}, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) EmitCircularDependencyError}))
    3216                 :             :         {
    3217                 :             :           /* avoid dangling else.  */
    3218                 :             :         }
    3219                 :             :     }
    3220                 :      645529 :   return (Sets_NoOfElementsInSet (GlobalGroup->ToDoList)) == 0;
    3221                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3222                 :             :   __builtin_unreachable ();
    3223                 :             : }
    3224                 :             : 
    3225                 :             : 
    3226                 :             : /*
    3227                 :             :    CompleteDeclarationOf - returns the GCC Tree for, sym, if it can
    3228                 :             :                            be created from partially or fully declared
    3229                 :             :                            dependents.
    3230                 :             : */
    3231                 :             : 
    3232                 :       22932 : static tree CompleteDeclarationOf (unsigned int sym)
    3233                 :             : {
    3234                 :       22932 :   if (SymbolTable_IsArray (sym))
    3235                 :             :     {
    3236                 :           0 :       return DeclareArray (sym);
    3237                 :             :     }
    3238                 :       22932 :   else if (SymbolTable_IsProcType (sym))
    3239                 :             :     {
    3240                 :             :       /* avoid dangling else.  */
    3241                 :        5958 :       return DeclareProcType (sym);
    3242                 :             :     }
    3243                 :       16974 :   else if (SymbolTable_IsRecordField (sym))
    3244                 :             :     {
    3245                 :             :       /* avoid dangling else.  */
    3246                 :           0 :       return DeclareRecordField (sym);
    3247                 :             :     }
    3248                 :       16974 :   else if (SymbolTable_IsPointer (sym))
    3249                 :             :     {
    3250                 :             :       /* avoid dangling else.  */
    3251                 :       16974 :       return DeclarePointer (sym);
    3252                 :             :     }
    3253                 :             :   else
    3254                 :             :     {
    3255                 :             :       /* avoid dangling else.  */
    3256                 :             :       return NULL;
    3257                 :             :     }
    3258                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3259                 :             :   __builtin_unreachable ();
    3260                 :             : }
    3261                 :             : 
    3262                 :             : 
    3263                 :             : /*
    3264                 :             :    DeclareType - here a type has been created via TYPE foo = bar,
    3265                 :             :                  we must tell GCC about it.
    3266                 :             : */
    3267                 :             : 
    3268                 :       28551 : static tree DeclareType (unsigned int sym)
    3269                 :             : {
    3270                 :       28551 :   tree t;
    3271                 :       28551 :   location_t location;
    3272                 :             : 
    3273                 :       28551 :   if ((SymbolTable_GetSType (sym)) == SymbolTable_NulSym)
    3274                 :             :     {
    3275                 :           0 :       M2MetaError_MetaError1 ((const char *) "base type {%1Ua} not understood", 31, sym);
    3276                 :           0 :       M2Error_InternalError ((const char *) "base type should have been declared", 35);
    3277                 :             :     }
    3278                 :             :   else
    3279                 :             :     {
    3280                 :       28551 :       if ((SymbolTable_GetSymName (sym)) == NameKey_NulName)
    3281                 :             :         {
    3282                 :           0 :           return (tree) (SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym)));
    3283                 :             :         }
    3284                 :             :       else
    3285                 :             :         {
    3286                 :       28551 :           location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    3287                 :       28551 :           if (SymbolConversion_GccKnowsAbout (sym))
    3288                 :             :             {
    3289                 :           6 :               t = SymbolConversion_Mod2Gcc (sym);
    3290                 :             :             }
    3291                 :             :           else
    3292                 :             :             {
    3293                 :             :               /* not partially declared therefore start it  */
    3294                 :       28545 :               t = m2type_BuildStartType (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym))), SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym)));
    3295                 :             :             }
    3296                 :       28551 :           t = m2type_BuildEndType (location, t);  /* now finish it  */
    3297                 :       28551 :           return t;  /* now finish it  */
    3298                 :             :         }
    3299                 :             :     }
    3300                 :             :   ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2GCCDeclare.def", 20, 1);
    3301                 :             :   __builtin_unreachable ();
    3302                 :             : }
    3303                 :             : 
    3304                 :      487949 : static void DeclareConstantFromTree (unsigned int sym, tree value)
    3305                 :             : {
    3306                 :             :   /* 
    3307                 :             :    DeclareIntegerFromTree - declares an integer constant from a Tree, value.
    3308                 :             :   */
    3309                 :      975898 :   PreAddModGcc (sym, value);
    3310                 :      487949 :   WatchRemoveList (sym, M2GCCDeclare_todolist);
    3311                 :      487949 :   WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    3312                 :      487949 : }
    3313                 :             : 
    3314                 :             : 
    3315                 :             : /*
    3316                 :             :    DeclareCharConstant - declares a character constant.
    3317                 :             : */
    3318                 :             : 
    3319                 :       12722 : static void DeclareCharConstant (unsigned int tokenno, unsigned int sym)
    3320                 :             : {
    3321                 :       12722 :   location_t location;
    3322                 :             : 
    3323                 :       12722 :   M2Debug_Assert (SymbolTable_IsConstStringKnown (sym));
    3324                 :       12722 :   location = M2LexBuf_TokenToLocation (tokenno);
    3325                 :       12722 :   PreAddModGcc (sym, m2type_BuildCharConstant (location, const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetString (sym))))));
    3326                 :       12722 :   WatchRemoveList (sym, M2GCCDeclare_todolist);
    3327                 :       12722 :   WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    3328                 :       12722 : }
    3329                 :             : 
    3330                 :             : 
    3331                 :             : /*
    3332                 :             :    DeclareStringConstant - declares a string constant the sym will be known.
    3333                 :             : */
    3334                 :             : 
    3335                 :      222626 : static void DeclareStringConstant (unsigned int tokenno, unsigned int sym)
    3336                 :             : {
    3337                 :      222626 :   tree symtree;
    3338                 :             : 
    3339                 :      222626 :   M2Debug_Assert (SymbolTable_IsConstStringKnown (sym));
    3340                 :      222626 :   if ((SymbolTable_IsConstStringM2nul (sym)) || (SymbolTable_IsConstStringCnul (sym)))
    3341                 :             :     {
    3342                 :             :       /* in either case the string needs a nul terminator.  If the string
    3343                 :             :          is a C variant it will already have had any escape characters applied.
    3344                 :             :          The BuildCStringConstant only adds the nul terminator.  */
    3345                 :      222614 :       symtree = m2decl_BuildCStringConstant (const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetString (sym)))), static_cast<int> (SymbolTable_GetStringLength (tokenno, sym)));
    3346                 :             :     }
    3347                 :             :   else
    3348                 :             :     {
    3349                 :          12 :       symtree = m2decl_BuildStringConstant (const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetString (sym)))), static_cast<int> (SymbolTable_GetStringLength (tokenno, sym)));
    3350                 :             :     }
    3351                 :      445252 :   PreAddModGcc (sym, symtree);
    3352                 :      222626 :   WatchRemoveList (sym, M2GCCDeclare_todolist);
    3353                 :      222626 :   WatchIncludeList (sym, M2GCCDeclare_fullydeclared);
    3354                 :      222626 : }
    3355                 :             : 
    3356                 :             : 
    3357                 :             : /*
    3358                 :             :    WalkConstructor - walks all dependants of, sym.
    3359                 :             : */
    3360                 :             : 
    3361                 :     1084792 : static void WalkConstructor (unsigned int sym, M2GCCDeclare_WalkAction p)
    3362                 :             : {
    3363                 :     1084792 :   unsigned int type;
    3364                 :             : 
    3365                 :     1084792 :   type = SymbolTable_GetSType (sym);
    3366                 :     1084792 :   if (type != SymbolTable_NulSym)
    3367                 :             :     {
    3368                 :     1083508 :       WalkDependants (type, p);
    3369                 :     1083508 :       M2ALU_WalkConstructorDependants (sym, p);
    3370                 :             :     }
    3371                 :     1084792 : }
    3372                 :             : 
    3373                 :             : 
    3374                 :             : /*
    3375                 :             :    WalkConst - walks all dependants of, sym.
    3376                 :             : */
    3377                 :             : 
    3378                 :    29209636 : static void WalkConst (unsigned int sym, M2GCCDeclare_WalkAction p)
    3379                 :             : {
    3380                 :    29209636 :   unsigned int type;
    3381                 :             : 
    3382                 :    29209636 :   M2Debug_Assert (SymbolTable_IsConst (sym));
    3383                 :    29209636 :   type = SymbolTable_GetSType (sym);
    3384                 :    29209636 :   if (type != SymbolTable_NulSym)
    3385                 :             :     {
    3386                 :    26592111 :       (*p.proc) (type);
    3387                 :             :     }
    3388                 :    29209636 :   if ((SymbolTable_IsConstSet (sym)) || (SymbolTable_IsConstructor (sym)))
    3389                 :             :     {
    3390                 :     1030698 :       WalkConstructor (sym, p);
    3391                 :             :     }
    3392                 :    29209636 : }
    3393                 :             : 
    3394                 :             : 
    3395                 :             : /*
    3396                 :             :    IsConstDependants - returns TRUE if the symbol, sym,
    3397                 :             :                        q(dependants) all return TRUE.
    3398                 :             : */
    3399                 :             : 
    3400                 :      166568 : static bool IsConstDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    3401                 :             : {
    3402                 :      166568 :   unsigned int type;
    3403                 :             : 
    3404                 :      166568 :   M2Debug_Assert (SymbolTable_IsConst (sym));
    3405                 :      166568 :   type = SymbolTable_GetSType (sym);
    3406                 :      166568 :   if (type != SymbolTable_NulSym)
    3407                 :             :     {
    3408                 :      159512 :       if (! ((*q.proc) (type)))
    3409                 :             :         {
    3410                 :             :           return false;
    3411                 :             :         }
    3412                 :             :     }
    3413                 :      142154 :   if ((SymbolTable_IsConstSet (sym)) || (SymbolTable_IsConstructor (sym)))
    3414                 :             :     {
    3415                 :       45842 :       return M2ALU_IsConstructorDependants (sym, q);
    3416                 :             :     }
    3417                 :       96312 :   return SymbolTable_IsValueSolved (sym);
    3418                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3419                 :             :   __builtin_unreachable ();
    3420                 :             : }
    3421                 :             : 
    3422                 :             : 
    3423                 :             : /*
    3424                 :             :    IsAnyType - return TRUE if sym is any Modula-2 type.
    3425                 :             : */
    3426                 :             : 
    3427                 :          60 : static bool IsAnyType (unsigned int sym)
    3428                 :             : {
    3429                 :          60 :   return (((((((SymbolTable_IsRecord (sym)) || (SymbolTable_IsType (sym))) || (SymbolTable_IsRecordField (sym))) || (SymbolTable_IsPointer (sym))) || (SymbolTable_IsArray (sym))) || (SymbolTable_IsSet (sym))) || (SymbolTable_IsEnumeration (sym))) || (SymbolTable_IsPointer (sym));
    3430                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3431                 :             :   __builtin_unreachable ();
    3432                 :             : }
    3433                 :             : 
    3434                 :             : 
    3435                 :             : /*
    3436                 :             :    DeclareConstString -
    3437                 :             : */
    3438                 :             : 
    3439                 :      235348 : static bool DeclareConstString (unsigned int tokenno, unsigned int sym)
    3440                 :             : {
    3441                 :      235348 :   unsigned int size;
    3442                 :             : 
    3443                 :      235348 :   if (SymbolTable_IsConstStringKnown (sym))
    3444                 :             :     {
    3445                 :      235348 :       size = SymbolTable_GetStringLength (tokenno, sym);
    3446                 :      235348 :       if (size == 1)
    3447                 :             :         {
    3448                 :       12722 :           DeclareCharConstant (tokenno, sym);
    3449                 :             :         }
    3450                 :             :       else
    3451                 :             :         {
    3452                 :      222626 :           DeclareStringConstant (tokenno, sym);
    3453                 :             :         }
    3454                 :      235348 :       return true;
    3455                 :             :     }
    3456                 :             :   return false;
    3457                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3458                 :             :   __builtin_unreachable ();
    3459                 :             : }
    3460                 :             : 
    3461                 :             : 
    3462                 :             : /*
    3463                 :             :    TryDeclareConst - try to declare a const to gcc.  If it cannot
    3464                 :             :                      declare the symbol it places it into the
    3465                 :             :                      todolist.
    3466                 :             : */
    3467                 :             : 
    3468                 :     7887202 : static void TryDeclareConst (unsigned int tokenno, unsigned int sym)
    3469                 :             : {
    3470                 :     7887202 :   unsigned int type;
    3471                 :             : 
    3472                 :     7887202 :   if (! (SymbolConversion_GccKnowsAbout (sym)))
    3473                 :             :     {
    3474                 :      444052 :       if ((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym)))
    3475                 :             :         {
    3476                 :          12 :           M2ALU_WalkConstructorDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
    3477                 :          12 :           M2ALU_TryEvaluateValue (sym);
    3478                 :          12 :           if (! (M2ALU_IsConstructorDependants (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared})))
    3479                 :             :             {
    3480                 :           0 :               TraverseDependants (sym);
    3481                 :           0 :               return;
    3482                 :             :             }
    3483                 :          12 :           if (! (SymbolTable_IsConstructorConstant (sym)))
    3484                 :             :             {
    3485                 :             :               return;
    3486                 :             :             }
    3487                 :             :         }
    3488                 :      444052 :       if ((SymbolTable_IsConstString (sym)) && (SymbolTable_IsConstStringKnown (sym)))
    3489                 :             :         {
    3490                 :             :           /* avoid dangling else.  */
    3491                 :       80176 :           if (DeclareConstString (tokenno, sym))
    3492                 :             :             {}  /* empty.  */
    3493                 :             :         }
    3494                 :      363876 :       else if (SymbolTable_IsValueSolved (sym))
    3495                 :             :         {
    3496                 :             :           /* avoid dangling else.  */
    3497                 :      355710 :           SymbolTable_PushValue (sym);
    3498                 :      355710 :           if (SymbolTable_IsConstSet (sym))
    3499                 :             :             {
    3500                 :          12 :               DeclareConstantFromTree (sym, M2ALU_PopSetTree (tokenno));
    3501                 :             :             }
    3502                 :      355698 :           else if (SymbolTable_IsConstructor (sym))
    3503                 :             :             {
    3504                 :             :               /* avoid dangling else.  */
    3505                 :           0 :               DeclareConstantFromTree (sym, M2ALU_PopConstructorTree (tokenno));
    3506                 :             :             }
    3507                 :      355698 :           else if ((M2Base_IsRealType (SymbolTable_GetDType (sym))) || (M2System_IsRealN (SymbolTable_GetDType (sym))))
    3508                 :             :             {
    3509                 :             :               /* avoid dangling else.  */
    3510                 :        4864 :               type = SymbolTable_GetDType (sym);
    3511                 :        4864 :               DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopRealTree (), true));
    3512                 :             :             }
    3513                 :      350834 :           else if (M2Base_IsComplexType (SymbolTable_GetDType (sym)))
    3514                 :             :             {
    3515                 :             :               /* avoid dangling else.  */
    3516                 :         330 :               type = SymbolTable_GetDType (sym);
    3517                 :         330 :               DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopComplexTree (), true));
    3518                 :             :             }
    3519                 :             :           else
    3520                 :             :             {
    3521                 :             :               /* avoid dangling else.  */
    3522                 :      350504 :               if ((SymbolTable_GetSType (sym)) == SymbolTable_NulSym)
    3523                 :             :                 {
    3524                 :           0 :                   type = M2Base_ZType;
    3525                 :             :                 }
    3526                 :             :               else
    3527                 :             :                 {
    3528                 :      350504 :                   type = SymbolTable_GetDType (sym);
    3529                 :             :                 }
    3530                 :      350504 :               DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopIntegerTree (), true));
    3531                 :             :             }
    3532                 :             :         }
    3533                 :             :       else
    3534                 :             :         {
    3535                 :             :           /* avoid dangling else.  */
    3536                 :        8166 :           TraverseDependants (sym);
    3537                 :             :         }
    3538                 :             :     }
    3539                 :             : }
    3540                 :             : 
    3541                 :             : 
    3542                 :             : /*
    3543                 :             :    DeclareConst - declares a const to gcc and returns a Tree.
    3544                 :             : */
    3545                 :             : 
    3546                 :      810148 : static tree DeclareConst (unsigned int tokenno, unsigned int sym)
    3547                 :             : {
    3548                 :      810148 :   unsigned int type;
    3549                 :             : 
    3550                 :      810148 :   if (SymbolConversion_GccKnowsAbout (sym))
    3551                 :             :     {
    3552                 :      529091 :       return SymbolConversion_Mod2Gcc (sym);
    3553                 :             :     }
    3554                 :      281057 :   if ((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym)))
    3555                 :             :     {
    3556                 :        7932 :       M2ALU_EvaluateValue (sym);
    3557                 :             :     }
    3558                 :      281057 :   if (SymbolTable_IsConstString (sym))
    3559                 :             :     {
    3560                 :             :       /* avoid dangling else.  */
    3561                 :      155172 :       if (DeclareConstString (tokenno, sym))
    3562                 :             :         {}  /* empty.  */
    3563                 :             :     }
    3564                 :      125885 :   else if (SymbolTable_IsValueSolved (sym))
    3565                 :             :     {
    3566                 :             :       /* avoid dangling else.  */
    3567                 :      125885 :       SymbolTable_PushValue (sym);
    3568                 :      125885 :       if (SymbolTable_IsConstSet (sym))
    3569                 :             :         {
    3570                 :        5322 :           DeclareConstantFromTree (sym, M2ALU_PopSetTree (tokenno));
    3571                 :             :         }
    3572                 :      120563 :       else if (SymbolTable_IsConstructor (sym))
    3573                 :             :         {
    3574                 :             :           /* avoid dangling else.  */
    3575                 :        2610 :           DeclareConstantFromTree (sym, M2ALU_PopConstructorTree (tokenno));
    3576                 :             :         }
    3577                 :      117953 :       else if (M2Base_IsRealType (SymbolTable_GetDType (sym)))
    3578                 :             :         {
    3579                 :             :           /* avoid dangling else.  */
    3580                 :        1566 :           type = SymbolTable_GetDType (sym);
    3581                 :        1566 :           DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopRealTree (), true));
    3582                 :             :         }
    3583                 :      116387 :       else if (M2Base_IsComplexType (SymbolTable_GetDType (sym)))
    3584                 :             :         {
    3585                 :             :           /* avoid dangling else.  */
    3586                 :           0 :           type = SymbolTable_GetDType (sym);
    3587                 :           0 :           DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopComplexTree (), true));
    3588                 :             :         }
    3589                 :             :       else
    3590                 :             :         {
    3591                 :             :           /* avoid dangling else.  */
    3592                 :      116387 :           if ((SymbolTable_GetSType (sym)) == SymbolTable_NulSym)
    3593                 :             :             {
    3594                 :       14329 :               type = M2Base_ZType;
    3595                 :             :             }
    3596                 :             :           else
    3597                 :             :             {
    3598                 :      102058 :               type = SymbolTable_GetDType (sym);
    3599                 :             :             }
    3600                 :      116387 :           DeclareConstantFromTree (sym, m2convert_BuildConvert (M2LexBuf_TokenToLocation (tokenno), SymbolConversion_Mod2Gcc (type), M2ALU_PopIntegerTree (), true));
    3601                 :             :         }
    3602                 :             :     }
    3603                 :      281057 :   if (SymbolConversion_GccKnowsAbout (sym))
    3604                 :             :     {
    3605                 :      281057 :       return SymbolConversion_Mod2Gcc (sym);
    3606                 :             :     }
    3607                 :             :   else
    3608                 :             :     {
    3609                 :             :       return NULL;
    3610                 :             :     }
    3611                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3612                 :             :   __builtin_unreachable ();
    3613                 :             : }
    3614                 :             : 
    3615                 :             : 
    3616                 :             : /*
    3617                 :             :    WalkFamilyOfUnbounded -
    3618                 :             : */
    3619                 :             : 
    3620                 :     4757256 : static void WalkFamilyOfUnbounded (unsigned int oaf __attribute__((unused)), unsigned int dim __attribute__((unused)), unsigned int unbounded)
    3621                 :             : {
    3622                 :     4757256 :   if (unbounded != SymbolTable_NulSym)
    3623                 :             :     {
    3624                 :     4729026 :       (*unboundedp.proc) (unbounded);
    3625                 :             :     }
    3626                 :     4757256 : }
    3627                 :             : 
    3628                 :             : 
    3629                 :             : /*
    3630                 :             :    WalkAssociatedUnbounded -
    3631                 :             : */
    3632                 :             : 
    3633                 :   103177964 : static void WalkAssociatedUnbounded (unsigned int sym, M2GCCDeclare_WalkAction p)
    3634                 :             : {
    3635                 :   103177964 :   unsigned int oaf;
    3636                 :   103177964 :   M2GCCDeclare_WalkAction o;
    3637                 :             : 
    3638                 :   103177964 :   oaf = SymbolTable_GetOAFamily (sym);
    3639                 :   103177964 :   o = unboundedp;
    3640                 :   103177964 :   unboundedp = p;
    3641                 :   103177964 :   SymbolTable_ForeachOAFamily (oaf, (SymbolTable_FamilyOperation) {(SymbolTable_FamilyOperation_t) WalkFamilyOfUnbounded});
    3642                 :   103177964 :   unboundedp = o;
    3643                 :   103177964 : }
    3644                 :             : 
    3645                 :             : 
    3646                 :             : /*
    3647                 :             :    WalkDependants - walks through all dependants of, Sym,
    3648                 :             :                     calling, p, for each dependant.
    3649                 :             : */
    3650                 :             : 
    3651                 :   102504501 : static void WalkDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    3652                 :             : {
    3653                 :   102504501 :   WalkAssociatedUnbounded (sym, p);
    3654                 :   102504501 :   if (SymbolTable_IsComponent (sym))
    3655                 :             :     {
    3656                 :      100062 :       WalkComponentDependants (sym, p);
    3657                 :             :     }
    3658                 :   102404439 :   else if (SymbolTable_IsEnumeration (sym))
    3659                 :             :     {
    3660                 :             :       /* avoid dangling else.  */
    3661                 :     2887152 :       WalkEnumerationDependants (sym, p);
    3662                 :             :     }
    3663                 :    99517287 :   else if (SymbolTable_IsSubrange (sym))
    3664                 :             :     {
    3665                 :             :       /* avoid dangling else.  */
    3666                 :     1262763 :       WalkSubrangeDependants (sym, p);
    3667                 :             :     }
    3668                 :    98254524 :   else if (SymbolTable_IsPointer (sym))
    3669                 :             :     {
    3670                 :             :       /* avoid dangling else.  */
    3671                 :    10468496 :       WalkPointerDependants (sym, p);
    3672                 :             :     }
    3673                 :    87786028 :   else if (SymbolTable_IsRecord (sym))
    3674                 :             :     {
    3675                 :             :       /* avoid dangling else.  */
    3676                 :     7201613 :       WalkRecordDependants (sym, p);
    3677                 :             :     }
    3678                 :    80584415 :   else if (SymbolTable_IsVarient (sym))
    3679                 :             :     {
    3680                 :             :       /* avoid dangling else.  */
    3681                 :        7344 :       WalkVarientDependants (sym, p);
    3682                 :             :     }
    3683                 :    80577071 :   else if (SymbolTable_IsRecordField (sym))
    3684                 :             :     {
    3685                 :             :       /* avoid dangling else.  */
    3686                 :    19221736 :       WalkRecordFieldDependants (sym, p);
    3687                 :             :     }
    3688                 :    61355335 :   else if (SymbolTable_IsFieldVarient (sym))
    3689                 :             :     {
    3690                 :             :       /* avoid dangling else.  */
    3691                 :       18828 :       WalkVarientFieldDependants (sym, p);
    3692                 :             :     }
    3693                 :    61336507 :   else if (SymbolTable_IsArray (sym))
    3694                 :             :     {
    3695                 :             :       /* avoid dangling else.  */
    3696                 :      678850 :       WalkArrayDependants (sym, p);
    3697                 :             :     }
    3698                 :    60657657 :   else if (SymbolTable_IsProcType (sym))
    3699                 :             :     {
    3700                 :             :       /* avoid dangling else.  */
    3701                 :     2331832 :       WalkProcTypeDependants (sym, p);
    3702                 :             :     }
    3703                 :    58325825 :   else if (SymbolTable_IsUnbounded (sym))
    3704                 :             :     {
    3705                 :             :       /* avoid dangling else.  */
    3706                 :     4602096 :       WalkUnboundedDependants (sym, p);
    3707                 :             :     }
    3708                 :    53723729 :   else if (SymbolTable_IsSet (sym))
    3709                 :             :     {
    3710                 :             :       /* avoid dangling else.  */
    3711                 :     1184596 :       WalkSetDependants (sym, p);
    3712                 :             :     }
    3713                 :    52539133 :   else if (SymbolTable_IsType (sym))
    3714                 :             :     {
    3715                 :             :       /* avoid dangling else.  */
    3716                 :    22754069 :       WalkTypeDependants (sym, p);
    3717                 :             :     }
    3718                 :    29785064 :   else if (SymbolTable_IsConst (sym))
    3719                 :             :     {
    3720                 :             :       /* avoid dangling else.  */
    3721                 :    29209636 :       WalkConst (sym, p);
    3722                 :             :     }
    3723                 :      575428 :   else if (SymbolTable_IsVar (sym))
    3724                 :             :     {
    3725                 :             :       /* avoid dangling else.  */
    3726                 :      574864 :       WalkVarDependants (sym, p);
    3727                 :             :     }
    3728                 :         564 :   else if (SymbolTable_IsProcedure (sym))
    3729                 :             :     {
    3730                 :             :       /* avoid dangling else.  */
    3731                 :         408 :       WalkProcedureDependants (sym, p);
    3732                 :             :     }
    3733                 :   102504501 : }
    3734                 :             : 
    3735                 :             : 
    3736                 :             : /*
    3737                 :             :    TraverseDependantsInner -
    3738                 :             : */
    3739                 :             : 
    3740                 :   174586323 : static void TraverseDependantsInner (unsigned int sym)
    3741                 :             : {
    3742                 :   174586323 :   if ((! (Sets_IsElementInSet (GlobalGroup->FullyDeclared, sym))) && (! (Sets_IsElementInSet (GlobalGroup->ToDoList, sym))))
    3743                 :             :     {
    3744                 :     2823949 :       WatchIncludeList (sym, M2GCCDeclare_todolist);
    3745                 :             :     }
    3746                 :   174586323 :   if (! (Sets_IsElementInSet (VisitedList, sym)))
    3747                 :             :     {
    3748                 :   101420993 :       Sets_IncludeElementIntoSet (VisitedList, sym);
    3749                 :   101420993 :       WalkDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependantsInner});
    3750                 :             :     }
    3751                 :   174586323 : }
    3752                 :             : 
    3753                 :             : 
    3754                 :             : /*
    3755                 :             :    TraverseDependants - walks, sym, dependants.  But it checks
    3756                 :             :                         to see that, sym, is not on the
    3757                 :             :                         FullyDeclared and not on the ToDoList.
    3758                 :             : */
    3759                 :             : 
    3760                 :    19830061 : static void TraverseDependants (unsigned int sym)
    3761                 :             : {
    3762                 :    19830061 :   if (VisitedList == NULL)
    3763                 :             :     {
    3764                 :    19830061 :       VisitedList = Sets_InitSet (1);
    3765                 :    19830061 :       TraverseDependantsInner (sym);
    3766                 :    19830061 :       VisitedList = Sets_KillSet (VisitedList);
    3767                 :             :     }
    3768                 :             :   else
    3769                 :             :     {
    3770                 :           0 :       M2Error_InternalError ((const char *) "recursive call to TraverseDependants caught", 43);
    3771                 :             :     }
    3772                 :    19830061 : }
    3773                 :             : 
    3774                 :             : 
    3775                 :             : /*
    3776                 :             :    WalkTypeInfo - walks type, sym, and its dependants.
    3777                 :             : */
    3778                 :             : 
    3779                 :    14013676 : static void WalkTypeInfo (unsigned int sym)
    3780                 :             : {
    3781                 :    14016670 :   if (SymbolTable_IsVarient (sym))
    3782                 :             :     {
    3783                 :           0 :       M2Error_InternalError ((const char *) "why have we reached here?", 25);
    3784                 :             :     }
    3785                 :    14016670 :   else if (SymbolTable_IsVar (sym))
    3786                 :             :     {
    3787                 :             :       /* avoid dangling else.  */
    3788                 :      239242 :       WalkTypeInfo (SymbolTable_GetSType (sym));
    3789                 :      239242 :       if ((SymbolTable_GetVarBackEndType (sym)) != SymbolTable_NulSym)
    3790                 :             :         {
    3791                 :        2994 :           WalkTypeInfo (SymbolTable_GetVarBackEndType (sym));
    3792                 :             :         }
    3793                 :             :     }
    3794                 :    13777428 :   else if (SymbolTable_IsAModula2Type (sym))
    3795                 :             :     {
    3796                 :             :       /* avoid dangling else.  */
    3797                 :     8509213 :       TraverseDependants (sym);
    3798                 :             :     }
    3799                 :    14013676 : }
    3800                 :             : 
    3801                 :             : 
    3802                 :             : /*
    3803                 :             :    DeclareUnboundedProcedureParameters -
    3804                 :             : */
    3805                 :             : 
    3806                 :      182906 : static void DeclareUnboundedProcedureParameters (unsigned int sym)
    3807                 :             : {
    3808                 :      182906 :   unsigned int param;
    3809                 :      182906 :   unsigned int type;
    3810                 :      182906 :   unsigned int p;
    3811                 :      182906 :   unsigned int i;
    3812                 :      182906 :   location_t location;
    3813                 :             : 
    3814                 :      182906 :   if (SymbolTable_IsProcedure (sym))
    3815                 :             :     {
    3816                 :      182234 :       p = SymbolTable_NoOfParamAny (sym);
    3817                 :      182234 :       i = p;
    3818                 :      832052 :       while (i > 0)
    3819                 :             :         {
    3820                 :      467584 :           if (SymbolTable_IsUnboundedParamAny (sym, i))
    3821                 :             :             {
    3822                 :             :               /* avoid dangling else.  */
    3823                 :       42508 :               param = SymbolTable_GetNthParamAny (sym, i);
    3824                 :       42508 :               type = SymbolTable_GetSType (param);
    3825                 :       42508 :               TraverseDependants (type);
    3826                 :       42508 :               if (SymbolConversion_GccKnowsAbout (type))
    3827                 :             :                 {
    3828                 :       42508 :                   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (type));
    3829                 :       42508 :                   m2type_BuildTypeDeclaration (location, SymbolConversion_Mod2Gcc (type));
    3830                 :             :                 }
    3831                 :             :             }
    3832                 :             :           else
    3833                 :             :             {
    3834                 :      425076 :               param = SymbolTable_GetNth (sym, i);
    3835                 :      425076 :               type = SymbolTable_GetSType (param);
    3836                 :      425076 :               TraverseDependants (type);
    3837                 :             :             }
    3838                 :      467584 :           i -= 1;
    3839                 :             :         }
    3840                 :             :     }
    3841                 :      182906 : }
    3842                 :             : 
    3843                 :             : 
    3844                 :             : /*
    3845                 :             :    WalkUnboundedProcedureParameters -
    3846                 :             : */
    3847                 :             : 
    3848                 :     6560512 : static void WalkUnboundedProcedureParameters (unsigned int sym)
    3849                 :             : {
    3850                 :     6560512 :   unsigned int param;
    3851                 :     6560512 :   unsigned int type;
    3852                 :     6560512 :   unsigned int p;
    3853                 :     6560512 :   unsigned int i;
    3854                 :             : 
    3855                 :     6560512 :   if (SymbolTable_IsProcedure (sym))
    3856                 :             :     {
    3857                 :     4048707 :       p = SymbolTable_NoOfParamAny (sym);
    3858                 :     4048707 :       i = p;
    3859                 :    15311336 :       while (i > 0)
    3860                 :             :         {
    3861                 :     7213922 :           if (SymbolTable_IsUnboundedParamAny (sym, i))
    3862                 :             :             {
    3863                 :      685314 :               param = SymbolTable_GetNthParamAny (sym, i);
    3864                 :             :             }
    3865                 :             :           else
    3866                 :             :             {
    3867                 :     6528608 :               param = SymbolTable_GetNth (sym, i);
    3868                 :             :             }
    3869                 :     7213922 :           type = SymbolTable_GetSType (param);
    3870                 :     7213922 :           WalkTypeInfo (type);
    3871                 :     7213922 :           i -= 1;
    3872                 :             :         }
    3873                 :             :     }
    3874                 :     6560512 : }
    3875                 :             : 
    3876                 :             : 
    3877                 :             : /*
    3878                 :             :    WalkTypesInProcedure - walk all types in procedure, Sym.
    3879                 :             : */
    3880                 :             : 
    3881                 :       69112 : static void WalkTypesInProcedure (unsigned int sym)
    3882                 :             : {
    3883                 :           0 :   SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) TraverseDependants});
    3884                 :           0 : }
    3885                 :             : 
    3886                 :             : 
    3887                 :             : /*
    3888                 :             :    WalkTypesInModule - declare all types in module, Sym, to GCC.
    3889                 :             : */
    3890                 :             : 
    3891                 :      153278 : static void WalkTypesInModule (unsigned int sym)
    3892                 :             : {
    3893                 :      153278 :   NameKey_Name n;
    3894                 :             : 
    3895                 :      153278 :   if (Debugging)
    3896                 :             :     {
    3897                 :             :       n = SymbolTable_GetSymName (sym);
    3898                 :             :       M2Printf_printf1 ((const char *) "Declaring types in MODULE %a\\n", 30, (const unsigned char *) &n, (sizeof (n)-1));
    3899                 :             :     }
    3900                 :      153278 :   SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypeInfo});
    3901                 :      153278 :   SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkUnboundedProcedureParameters});
    3902                 :      153278 :   SymbolTable_ForeachInnerModuleDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});
    3903                 :      153278 : }
    3904                 :             : 
    3905                 :             : 
    3906                 :             : /*
    3907                 :             :    IsRecordFieldDependants - returns TRUE if the record field
    3908                 :             :                              symbol, sym, p(dependants) all return TRUE.
    3909                 :             : */
    3910                 :             : 
    3911                 :      800692 : static bool IsRecordFieldDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    3912                 :             : {
    3913                 :      800692 :   unsigned int align;
    3914                 :      800692 :   bool final;
    3915                 :             : 
    3916                 :      800692 :   final = true;
    3917                 :      800692 :   if (! ((*q.proc) (SymbolTable_GetSType (sym))))
    3918                 :             :     {
    3919                 :             :       final = false;
    3920                 :             :     }
    3921                 :      800692 :   align = SymbolTable_GetAlignment (sym);
    3922                 :      800692 :   if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
    3923                 :             :     {
    3924                 :             :       final = false;
    3925                 :             :     }
    3926                 :      800692 :   return final;
    3927                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3928                 :             :   __builtin_unreachable ();
    3929                 :             : }
    3930                 :             : 
    3931                 :             : 
    3932                 :             : /*
    3933                 :             :    GetModuleWhereDeclared - returns the module where, Sym, was created.
    3934                 :             : */
    3935                 :             : 
    3936                 :    10764286 : static unsigned int GetModuleWhereDeclared (unsigned int sym)
    3937                 :             : {
    3938                 :    10770592 :   unsigned int s;
    3939                 :             : 
    3940                 :    10770592 :   s = SymbolTable_GetScope (sym);
    3941                 :    10770592 :   if (((s == SymbolTable_NulSym) || (SymbolTable_IsDefImp (s))) || ((SymbolTable_IsModule (s)) && ((SymbolTable_GetScope (s)) == SymbolTable_NulSym)))
    3942                 :             :     {
    3943                 :    10764286 :       return s;
    3944                 :             :     }
    3945                 :             :   else
    3946                 :             :     {
    3947                 :        6306 :       return GetModuleWhereDeclared (s);
    3948                 :             :     }
    3949                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3950                 :             :   __builtin_unreachable ();
    3951                 :             : }
    3952                 :             : 
    3953                 :             : 
    3954                 :             : /*
    3955                 :             :    IsPseudoProcFunc - returns TRUE if Sym is a pseudo function or procedure.
    3956                 :             : */
    3957                 :             : 
    3958                 :     3333100 : static bool IsPseudoProcFunc (unsigned int Sym)
    3959                 :             : {
    3960                 :     3333100 :   return ((M2Base_IsPseudoBaseProcedure (Sym)) || (M2Base_IsPseudoBaseFunction (Sym))) || (M2System_IsPseudoSystemFunction (Sym));
    3961                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3962                 :             :   __builtin_unreachable ();
    3963                 :             : }
    3964                 :             : 
    3965                 :             : 
    3966                 :             : /*
    3967                 :             :    IsExternal -
    3968                 :             : */
    3969                 :             : 
    3970                 :     2268166 : static bool IsExternal (unsigned int sym)
    3971                 :             : {
    3972                 :     2268166 :   unsigned int mod;
    3973                 :             : 
    3974                 :     2268166 :   M2Debug_Assert (! (SymbolTable_IsDefImp (sym)));
    3975                 :     2268166 :   if ((SymbolTable_IsProcedure (sym)) && (SymbolTable_IsExtern (sym)))
    3976                 :             :     {
    3977                 :             :       return true;
    3978                 :             :     }
    3979                 :     2028318 :   mod = SymbolTable_GetScope (sym);
    3980                 :     2030322 :   do {
    3981                 :     2030322 :     if (mod == SymbolTable_NulSym)
    3982                 :             :       {
    3983                 :             :         return false;
    3984                 :             :       }
    3985                 :     2030322 :     else if (SymbolTable_IsDefImp (mod))
    3986                 :             :       {
    3987                 :             :         /* avoid dangling else.  */
    3988                 :     1941522 :         return mod != (SymbolTable_GetMainModule ());
    3989                 :             :       }
    3990                 :       88800 :     mod = SymbolTable_GetScope (mod);
    3991                 :       88800 :   } while (! (mod == SymbolTable_NulSym));
    3992                 :             :   return false;
    3993                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    3994                 :             :   __builtin_unreachable ();
    3995                 :             : }
    3996                 :             : 
    3997                 :             : 
    3998                 :             : /*
    3999                 :             :    IsExternalToWholeProgram - return TRUE if the symbol, sym, is external to the
    4000                 :             :                               sources that we have parsed.
    4001                 :             : */
    4002                 :             : 
    4003                 :       11424 : static bool IsExternalToWholeProgram (unsigned int sym)
    4004                 :             : {
    4005                 :       11424 :   unsigned int mod;
    4006                 :             : 
    4007                 :       11424 :   mod = SymbolTable_GetScope (sym);
    4008                 :       11424 :   do {
    4009                 :       11424 :     if (mod == SymbolTable_NulSym)
    4010                 :             :       {
    4011                 :             :         return false;
    4012                 :             :       }
    4013                 :       11424 :     else if (SymbolTable_IsDefImp (mod))
    4014                 :             :       {
    4015                 :             :         /* avoid dangling else.  */
    4016                 :             :         /* return TRUE if we have no source file.  */
    4017                 :       11160 :         return (M2Batch_GetModuleFile (mod)) == NULL;
    4018                 :             :       }
    4019                 :         264 :     mod = SymbolTable_GetScope (mod);
    4020                 :         264 :   } while (! (mod == SymbolTable_NulSym));
    4021                 :             :   return false;
    4022                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4023                 :             :   __builtin_unreachable ();
    4024                 :             : }
    4025                 :             : 
    4026                 :             : 
    4027                 :             : /*
    4028                 :             :    DeclareProcedureToGccWholeProgram -
    4029                 :             : */
    4030                 :             : 
    4031                 :      253272 : static void DeclareProcedureToGccWholeProgram (unsigned int Sym)
    4032                 :             : {
    4033                 :      253272 :   tree returnType;
    4034                 :      253272 :   tree GccParam;
    4035                 :      253272 :   unsigned int scope;
    4036                 :      253272 :   unsigned int Variable;
    4037                 :      253272 :   unsigned int p;
    4038                 :      253272 :   unsigned int i;
    4039                 :      253272 :   unsigned int b;
    4040                 :      253272 :   unsigned int e;
    4041                 :      253272 :   location_t begin;
    4042                 :      253272 :   location_t end;
    4043                 :      253272 :   location_t location;
    4044                 :             : 
    4045                 :      253272 :   if ((! (SymbolConversion_GccKnowsAbout (Sym))) && (! (IsPseudoProcFunc (Sym))))
    4046                 :             :     {
    4047                 :       11424 :       m2decl_BuildStartFunctionDeclaration (SymbolTable_UsesVarArgs (Sym));
    4048                 :       11424 :       p = SymbolTable_NoOfParamAny (Sym);
    4049                 :       11424 :       i = p;
    4050                 :             :       /* note we dont use GetNthParamAny as we want the parameter that is seen by the procedure block
    4051                 :             :             remember that this is treated exactly the same as a variable, just its position on
    4052                 :             :             the activation record is special (ie a parameter)
    4053                 :             :   */
    4054                 :       43848 :       while (i > 0)
    4055                 :             :         {
    4056                 :       21000 :           Variable = SymbolTable_GetNth (Sym, i);
    4057                 :       21000 :           location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Variable));
    4058                 :       21000 :           if (SymbolTable_IsUnboundedParamAny (Sym, i))
    4059                 :             :             {
    4060                 :        2088 :               GccParam = m2decl_BuildParameterDeclaration (location, const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (Variable)))), SymbolConversion_Mod2Gcc (SymbolTable_GetLType (Variable)), false);
    4061                 :             :             }
    4062                 :             :           else
    4063                 :             :             {
    4064                 :       18912 :               GccParam = m2decl_BuildParameterDeclaration (location, const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (Variable)))), SymbolConversion_Mod2Gcc (SymbolTable_GetLType (Variable)), SymbolTable_IsVarParamAny (Sym, i));
    4065                 :             :             }
    4066                 :       42000 :           PreAddModGcc (Variable, GccParam);
    4067                 :       21000 :           WatchRemoveList (Variable, M2GCCDeclare_todolist);
    4068                 :       21000 :           WatchIncludeList (Variable, M2GCCDeclare_fullydeclared);
    4069                 :       21000 :           i -= 1;
    4070                 :             :         }
    4071                 :       11424 :       SymbolTable_GetProcedureBeginEnd (Sym, &b, &e);
    4072                 :       11424 :       begin = M2LexBuf_TokenToLocation (b);
    4073                 :       11424 :       end = M2LexBuf_TokenToLocation (e);
    4074                 :       11424 :       scope = SymbolTable_GetScope (Sym);
    4075                 :       11424 :       PushBinding (scope);
    4076                 :       11424 :       if ((SymbolTable_GetSType (Sym)) == SymbolTable_NulSym)
    4077                 :             :         {
    4078                 :             :           returnType = NULL;
    4079                 :             :         }
    4080                 :             :       else
    4081                 :             :         {
    4082                 :        4632 :           returnType = SymbolConversion_Mod2Gcc (SymbolTable_GetSType (Sym));
    4083                 :             :         }
    4084                 :       11424 :       PreAddModGcc (Sym, m2decl_BuildEndFunctionDeclaration (begin, end, const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (Sym)))), returnType, IsExternalToWholeProgram (Sym), M2GCCDeclare_IsProcedureGccNested (Sym), SymbolTable_IsExported (GetModuleWhereDeclared (Sym), Sym), SymbolTable_IsProcedureAnyNoReturn (Sym)));
    4085                 :       11424 :       PopBinding (scope);
    4086                 :       11424 :       WatchRemoveList (Sym, M2GCCDeclare_todolist);
    4087                 :       11424 :       WatchIncludeList (Sym, M2GCCDeclare_fullydeclared);
    4088                 :             :     }
    4089                 :      253272 : }
    4090                 :             : 
    4091                 :             : 
    4092                 :             : /*
    4093                 :             :    DeclareProcedureToGccSeparateProgram -
    4094                 :             : */
    4095                 :             : 
    4096                 :     3598781 : static void DeclareProcedureToGccSeparateProgram (unsigned int Sym)
    4097                 :             : {
    4098                 :     3598781 :   tree returnType;
    4099                 :     3598781 :   tree GccParam;
    4100                 :     3598781 :   unsigned int scope;
    4101                 :     3598781 :   unsigned int Variable;
    4102                 :     3598781 :   unsigned int p;
    4103                 :     3598781 :   unsigned int i;
    4104                 :     3598781 :   unsigned int b;
    4105                 :     3598781 :   unsigned int e;
    4106                 :     3598781 :   location_t begin;
    4107                 :     3598781 :   location_t end;
    4108                 :     3598781 :   location_t location;
    4109                 :     3598781 :   unsigned int tok;
    4110                 :             : 
    4111                 :     3598781 :   tok = SymbolTable_GetDeclaredMod (Sym);
    4112                 :     3598781 :   if (((! (SymbolConversion_GccKnowsAbout (Sym))) && (! (IsPseudoProcFunc (Sym)))) && ((((((IsEffectivelyImported (SymbolTable_GetMainModule (), Sym)) || ((GetModuleWhereDeclared (Sym)) == (SymbolTable_GetMainModule ()))) || (M2Base_IsNeededAtRunTime (tok, Sym))) || (SymbolTable_IsImported (SymbolTable_GetBaseModule (), Sym))) || (SymbolTable_IsExported (GetModuleWhereDeclared (Sym), Sym))) || (SymbolTable_IsExtern (Sym))))
    4113                 :             :     {
    4114                 :     2268166 :       m2decl_BuildStartFunctionDeclaration (SymbolTable_UsesVarArgs (Sym));
    4115                 :     2268166 :       p = SymbolTable_NoOfParamAny (Sym);
    4116                 :     2268166 :       i = p;
    4117                 :             :       /* Note we dont use GetNthParamAny as we want the parameter that is seen by
    4118                 :             :             the procedure block remember that this is treated exactly the same as
    4119                 :             :             a variable, just its position on the activation record is special (ie
    4120                 :             :             a parameter).  */
    4121                 :     9484215 :       while (i > 0)
    4122                 :             :         {
    4123                 :     4947883 :           Variable = SymbolTable_GetNth (Sym, i);
    4124                 :     4947883 :           location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Variable));
    4125                 :     4947883 :           if (SymbolTable_IsUnboundedParamAny (Sym, i))
    4126                 :             :             {
    4127                 :      312105 :               GccParam = m2decl_BuildParameterDeclaration (location, const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (Variable)))), SymbolConversion_Mod2Gcc (SymbolTable_GetLType (Variable)), false);
    4128                 :             :             }
    4129                 :             :           else
    4130                 :             :             {
    4131                 :     4635778 :               GccParam = m2decl_BuildParameterDeclaration (location, const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (Variable)))), SymbolConversion_Mod2Gcc (SymbolTable_GetLType (Variable)), SymbolTable_IsVarParamAny (Sym, i));
    4132                 :             :             }
    4133                 :     9895766 :           PreAddModGcc (Variable, GccParam);
    4134                 :     4947883 :           WatchRemoveList (Variable, M2GCCDeclare_todolist);
    4135                 :     4947883 :           WatchIncludeList (Variable, M2GCCDeclare_fullydeclared);
    4136                 :     4947883 :           i -= 1;
    4137                 :             :         }
    4138                 :     2268166 :       SymbolTable_GetProcedureBeginEnd (Sym, &b, &e);
    4139                 :     2268166 :       begin = M2LexBuf_TokenToLocation (b);
    4140                 :     2268166 :       end = M2LexBuf_TokenToLocation (e);
    4141                 :     2268166 :       scope = SymbolTable_GetScope (Sym);
    4142                 :     2268166 :       PushBinding (scope);
    4143                 :     2268166 :       if ((SymbolTable_GetSType (Sym)) == SymbolTable_NulSym)
    4144                 :             :         {
    4145                 :             :           returnType = NULL;
    4146                 :             :         }
    4147                 :             :       else
    4148                 :             :         {
    4149                 :      951491 :           returnType = SymbolConversion_Mod2Gcc (SymbolTable_GetSType (Sym));
    4150                 :             :         }
    4151                 :             :       /* Exported from the module where it was declared.  */
    4152                 :     4418789 :       PreAddModGcc (Sym, m2decl_BuildEndFunctionDeclaration (begin, end, const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (Sym)))), returnType, IsExternal (Sym), M2GCCDeclare_IsProcedureGccNested (Sym), (SymbolTable_IsExported (GetModuleWhereDeclared (Sym), Sym)) || (SymbolTable_IsExtern (Sym)), SymbolTable_IsProcedureAnyNoReturn (Sym)));
    4153                 :     2268166 :       PopBinding (scope);
    4154                 :     2268166 :       WatchRemoveList (Sym, M2GCCDeclare_todolist);
    4155                 :     2268166 :       WatchIncludeList (Sym, M2GCCDeclare_fullydeclared);
    4156                 :             :     }
    4157                 :     3598781 : }
    4158                 :             : 
    4159                 :             : 
    4160                 :             : /*
    4161                 :             :    DeclareProcedureToGcc - traverses all parameters and interfaces to gm2gcc.
    4162                 :             : */
    4163                 :             : 
    4164                 :     3864381 : static void DeclareProcedureToGcc (unsigned int sym)
    4165                 :             : {
    4166                 :     3864381 :   if (sym != SymbolTable_NulSym)
    4167                 :             :     {
    4168                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    4169                 :     3852053 :       if (M2Options_WholeProgram)
    4170                 :             :         {
    4171                 :      253272 :           DeclareProcedureToGccWholeProgram (sym);
    4172                 :             :         }
    4173                 :             :       else
    4174                 :             :         {
    4175                 :     3598781 :           DeclareProcedureToGccSeparateProgram (sym);
    4176                 :             :         }
    4177                 :             :     }
    4178                 :     3864381 : }
    4179                 :             : 
    4180                 :             : 
    4181                 :             : /*
    4182                 :             :    ActivateWatch - activate a watch for any symbol (lista xor listb).
    4183                 :             : */
    4184                 :             : 
    4185                 :           0 : static void ActivateWatch (Sets_Set lista, Sets_Set listb)
    4186                 :             : {
    4187                 :           0 :   Sets_Set smallest;
    4188                 :           0 :   Sets_Set largest;
    4189                 :           0 :   unsigned int n;
    4190                 :           0 :   unsigned int sym;
    4191                 :             : 
    4192                 :           0 :   if ((Sets_NoOfElementsInSet (lista)) != (Sets_NoOfElementsInSet (listb)))
    4193                 :             :     {
    4194                 :           0 :       if ((Sets_NoOfElementsInSet (lista)) > (Sets_NoOfElementsInSet (listb)))
    4195                 :             :         {
    4196                 :             :           largest = lista;
    4197                 :             :           smallest = listb;
    4198                 :             :         }
    4199                 :             :       else
    4200                 :             :         {
    4201                 :           0 :           largest = listb;
    4202                 :           0 :           smallest = lista;
    4203                 :             :         }
    4204                 :           0 :       M2Printf_printf0 ((const char *) "adding the following symbols to the watch list as the declarator has detected an internal bug: ", 95);
    4205                 :           0 :       sym = 1;
    4206                 :           0 :       n = SymbolTable_FinalSymbol ();
    4207                 :           0 :       while (sym <= n)
    4208                 :             :         {
    4209                 :           0 :           if (((Sets_IsElementInSet (largest, sym)) && (! (Sets_IsElementInSet (smallest, sym)))) || ((! (Sets_IsElementInSet (largest, sym))) && (Sets_IsElementInSet (smallest, sym))))
    4210                 :             :             {
    4211                 :           0 :               AddSymToWatch (sym);
    4212                 :           0 :               M2Printf_printf1 ((const char *) "%d ", 3, (const unsigned char *) &sym, (sizeof (sym)-1));
    4213                 :             :             }
    4214                 :           0 :           sym += 1;
    4215                 :             :         }
    4216                 :           0 :       M2Printf_printf0 ((const char *) "\\n", 2);
    4217                 :             :     }
    4218                 :           0 : }
    4219                 :             : 
    4220                 :             : 
    4221                 :             : /*
    4222                 :             :    DeclareTypesConstantsProceduresInRange -
    4223                 :             : */
    4224                 :             : 
    4225                 :      615684 : static void DeclareTypesConstantsProceduresInRange (unsigned int scope, unsigned int start, unsigned int end)
    4226                 :             : {
    4227                 :      615684 :   M2GCCDeclare_Group copy;
    4228                 :      615684 :   unsigned int loop;
    4229                 :      615684 :   M2Scope_ScopeBlock sb;
    4230                 :      615684 :   M2BasicBlock_BasicBlock bb;
    4231                 :             : 
    4232                 :      615684 :   if (TraceQuadruples)
    4233                 :             :     {
    4234                 :             :       M2Quads_DisplayQuadRange (scope, start, end);
    4235                 :             :     }
    4236                 :      615684 :   loop = 0;
    4237                 :      615684 :   copy = NULL;
    4238                 :      615684 :   sb = M2Scope_InitScopeBlock (scope);
    4239                 :             :   /* Throw away any unreachable quad.  */
    4240                 :      645571 :   do {
    4241                 :      645571 :     bb = M2BasicBlock_InitBasicBlocks (sb);
    4242                 :      645571 :     M2BasicBlock_KillBasicBlocks (&bb);
    4243                 :             :     /* Now iterate over remaining quads in scope attempting to resolve constants.  */
    4244                 :      645571 :     copy = DupGroup (copy);
    4245                 :      645571 :     bb = M2BasicBlock_InitBasicBlocks (sb);
    4246                 :      645571 :     ConstantResolved = false;
    4247                 :      645571 :     M2BasicBlock_ForeachBasicBlockDo (bb, (M2BasicBlock_BasicBlockProc) {(M2BasicBlock_BasicBlockProc_t) M2GCCDeclare_FoldConstants});
    4248                 :      645529 :     M2BasicBlock_KillBasicBlocks (&bb);
    4249                 :             :     /* And now types.  */
    4250                 :      645529 :     if (DeclaredOutstandingTypes (false))
    4251                 :             :       {}  /* empty.  */
    4252                 :      645529 :     if (loop == DebugLoop)
    4253                 :             :       {
    4254                 :           0 :         if (TraceQuadruples)
    4255                 :             :           {
    4256                 :             :             M2Quads_DisplayQuadRange (scope, start, end);
    4257                 :             :           }
    4258                 :           0 :         ActivateWatch (copy->ToDoList, GlobalGroup->ToDoList);
    4259                 :           0 :         loop = 0;
    4260                 :             :       }
    4261                 :      645529 :     loop += 1;
    4262                 :      675416 :   } while (! (! ConstantResolved && (EqualGroup (copy, GlobalGroup))));
    4263                 :      615642 :   KillGroup (&copy);
    4264                 :      615642 :   bb = M2BasicBlock_InitBasicBlocks (sb);
    4265                 :      615642 :   M2BasicBlock_KillBasicBlocks (&bb);
    4266                 :      615642 :   M2Scope_KillScopeBlock (&sb);
    4267                 :      615642 : }
    4268                 :             : 
    4269                 :             : 
    4270                 :             : /*
    4271                 :             :    SkipModuleScope - skips all module scopes for, scope.
    4272                 :             :                      It returns either NulSym or a procedure sym.
    4273                 :             : */
    4274                 :             : 
    4275                 :     4935596 : static unsigned int SkipModuleScope (unsigned int scope)
    4276                 :             : {
    4277                 :     9734864 :   if ((scope == SymbolTable_NulSym) || (SymbolTable_IsProcedure (scope)))
    4278                 :             :     {
    4279                 :     4935596 :       return scope;
    4280                 :             :     }
    4281                 :             :   else
    4282                 :             :     {
    4283                 :     4799268 :       return SkipModuleScope (SymbolTable_GetScope (scope));
    4284                 :             :     }
    4285                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4286                 :             :   __builtin_unreachable ();
    4287                 :             : }
    4288                 :             : 
    4289                 :             : 
    4290                 :             : /*
    4291                 :             :    PushBinding -
    4292                 :             : */
    4293                 :             : 
    4294                 :     2467819 : static void PushBinding (unsigned int scope)
    4295                 :             : {
    4296                 :     2467819 :   scope = SkipModuleScope (scope);
    4297                 :     2467819 :   if (scope == SymbolTable_NulSym)
    4298                 :             :     {
    4299                 :     2397663 :       m2block_pushGlobalScope ();
    4300                 :             :     }
    4301                 :             :   else
    4302                 :             :     {
    4303                 :       70156 :       m2block_pushFunctionScope (SymbolConversion_Mod2Gcc (scope));
    4304                 :             :     }
    4305                 :     2467819 : }
    4306                 :             : 
    4307                 :             : 
    4308                 :             : /*
    4309                 :             :    PopBinding -
    4310                 :             : */
    4311                 :             : 
    4312                 :     2467777 : static void PopBinding (unsigned int scope)
    4313                 :             : {
    4314                 :     2467777 :   scope = SkipModuleScope (scope);
    4315                 :     2467777 :   if (scope == SymbolTable_NulSym)
    4316                 :             :     {
    4317                 :     2397621 :       m2block_popGlobalScope ();
    4318                 :             :     }
    4319                 :             :   else
    4320                 :             :     {
    4321                 :       70156 :       M2Debug_Assert (SymbolTable_IsProcedure (scope));
    4322                 :       70156 :       m2block_finishFunctionDecl (M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (scope)), SymbolConversion_Mod2Gcc (scope));
    4323                 :       70156 :       M2Debug_Assert ((m2block_popFunctionScope ()) != NULL);
    4324                 :             :     }
    4325                 :     2467777 : }
    4326                 :             : 
    4327                 :             : 
    4328                 :             : /*
    4329                 :             :    DeclareTypesConstantsProcedures -
    4330                 :             : */
    4331                 :             : 
    4332                 :       84599 : static void DeclareTypesConstantsProcedures (unsigned int scope)
    4333                 :             : {
    4334                 :       84599 :   M2GCCDeclare_Group copy;
    4335                 :       84599 :   M2Scope_ScopeBlock sb;
    4336                 :             : 
    4337                 :       84599 :   if (Debugging)
    4338                 :             :     {
    4339                 :             :       M2Printf_printf0 ((const char *) "declaring types constants in: ", 30);
    4340                 :             :       PrintTerse (scope);
    4341                 :             :     }
    4342                 :       84599 :   copy = NULL;
    4343                 :       84599 :   sb = M2Scope_InitScopeBlock (scope);
    4344                 :       84599 :   PushBinding (scope);
    4345                 :      110134 :   do {
    4346                 :      110134 :     copy = DupGroup (copy);
    4347                 :      110134 :     M2Scope_ForeachScopeBlockDo3 (sb, (M2Scope_ScopeProcedure3) {(M2Scope_ScopeProcedure3_t) DeclareTypesConstantsProceduresInRange});
    4348                 :      110092 :   } while (! (EqualGroup (copy, GlobalGroup)));
    4349                 :       84557 :   KillGroup (&copy);
    4350                 :       84557 :   PopBinding (scope);
    4351                 :       84557 :   M2Scope_KillScopeBlock (&sb);
    4352                 :       84557 : }
    4353                 :             : 
    4354                 :             : 
    4355                 :             : /*
    4356                 :             :    AssertAllTypesDeclared - asserts that all types for variables are declared in, scope.
    4357                 :             : */
    4358                 :             : 
    4359                 :       84191 : static void AssertAllTypesDeclared (unsigned int scope)
    4360                 :             : {
    4361                 :       84191 :   unsigned int n;
    4362                 :       84191 :   unsigned int Var;
    4363                 :       84191 :   bool failed;
    4364                 :             : 
    4365                 :       84191 :   failed = false;
    4366                 :       84191 :   n = 1;
    4367                 :       84191 :   Var = SymbolTable_GetNth (scope, n);
    4368                 :      916064 :   while (Var != SymbolTable_NulSym)
    4369                 :             :     {
    4370                 :      747682 :       if (! (TypeDependentsDeclared (Var, true)))
    4371                 :             :         {
    4372                 :          24 :           failed = true;
    4373                 :             :         }
    4374                 :      747682 :       n += 1;
    4375                 :      747682 :       Var = SymbolTable_GetNth (scope, n);
    4376                 :             :     }
    4377                 :       84191 :   if (failed)
    4378                 :             :     {
    4379                 :          24 :       M2Error_FlushErrors ();
    4380                 :             :     }
    4381                 :       84167 : }
    4382                 :             : 
    4383                 :             : 
    4384                 :             : /*
    4385                 :             :    DeclareModuleInit - declare all the ctor related functions within
    4386                 :             :                        a module.
    4387                 :             : */
    4388                 :             : 
    4389                 :       24853 : static void DeclareModuleInit (unsigned int moduleSym)
    4390                 :             : {
    4391                 :       24853 :   unsigned int ctor;
    4392                 :       24853 :   unsigned int init;
    4393                 :       24853 :   unsigned int fini;
    4394                 :       24853 :   unsigned int dep;
    4395                 :             : 
    4396                 :       24853 :   SymbolTable_GetModuleCtors (moduleSym, &ctor, &init, &fini, &dep);
    4397                 :       24853 :   DeclareProcedureToGcc (ctor);
    4398                 :       24853 :   DeclareProcedureToGcc (init);
    4399                 :       24853 :   DeclareProcedureToGcc (fini);
    4400                 :       24853 :   DeclareProcedureToGcc (dep);
    4401                 :       24853 : }
    4402                 :             : 
    4403                 :             : 
    4404                 :             : /*
    4405                 :             :    StartDeclareProcedureScope -
    4406                 :             : */
    4407                 :             : 
    4408                 :       69112 : static void StartDeclareProcedureScope (unsigned int scope)
    4409                 :             : {
    4410                 :       69112 :   WalkTypesInProcedure (scope);
    4411                 :       69112 :   M2GCCDeclare_DeclareProcedure (scope);
    4412                 :       69112 :   SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});
    4413                 :       69112 :   DeclareTypesConstantsProcedures (scope);
    4414                 :       69112 :   SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareTypesConstantsProcedures});
    4415                 :       69112 :   M2GCCDeclare_DeclareLocalVariables (scope);
    4416                 :       69112 :   SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareModuleVariables});
    4417                 :       69112 :   AssertAllTypesDeclared (scope);
    4418                 :       69106 :   SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
    4419                 :       69106 :   SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
    4420                 :       69106 : }
    4421                 :             : 
    4422                 :             : 
    4423                 :             : /*
    4424                 :             :    StartDeclareModuleScopeSeparate -
    4425                 :             : */
    4426                 :             : 
    4427                 :       14713 : static void StartDeclareModuleScopeSeparate (unsigned int scope)
    4428                 :             : {
    4429                 :       14713 :   if (scope == (SymbolTable_GetMainModule ()))
    4430                 :             :     {
    4431                 :       14305 :       SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});  /* will populate the TYPE and CONST ToDo list  */
    4432                 :       14305 :       DeclareTypesConstantsProcedures (scope);  /* will resolved TYPEs and CONSTs on the ToDo  */
    4433                 :             :       /* lists.  */
    4434                 :       14263 :       SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
    4435                 :             :       /* 
    4436                 :             :          now that all types have been resolved it is safe to declare
    4437                 :             :          variables
    4438                 :             :   */
    4439                 :       14263 :       AssertAllTypesDeclared (scope);
    4440                 :       14245 :       DeclareGlobalVariables (scope);
    4441                 :       14245 :       SymbolTable_ForeachImportedDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareImportedVariables});
    4442                 :             :       /* now it is safe to declare all procedures  */
    4443                 :       14245 :       SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
    4444                 :       14245 :       SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});
    4445                 :       14245 :       SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareTypesConstantsProcedures});
    4446                 :       14245 :       SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
    4447                 :       14245 :       DeclareModuleInit (scope);
    4448                 :             :     }
    4449                 :             :   else
    4450                 :             :     {
    4451                 :         408 :       DeclareTypesConstantsProcedures (scope);
    4452                 :         408 :       AssertAllTypesDeclared (scope);
    4453                 :         408 :       SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
    4454                 :         408 :       DeclareModuleInit (scope);
    4455                 :         408 :       SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
    4456                 :             :     }
    4457                 :       14653 : }
    4458                 :             : 
    4459                 :             : 
    4460                 :             : /*
    4461                 :             :    StartDeclareModuleScopeWholeProgram -
    4462                 :             : */
    4463                 :             : 
    4464                 :         408 : static void StartDeclareModuleScopeWholeProgram (unsigned int scope)
    4465                 :             : {
    4466                 :         408 :   if (M2Batch_IsSourceSeen (scope))
    4467                 :             :     {
    4468                 :         408 :       SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});  /* will populate the TYPE and CONST ToDo list  */
    4469                 :         408 :       DeclareTypesConstantsProcedures (scope);  /* will resolved TYPEs and CONSTs on the ToDo  */
    4470                 :             :       /* lists.  */
    4471                 :         408 :       SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
    4472                 :         408 :       SymbolTable_ForeachModuleDo ((SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareModuleInit});
    4473                 :             :       /* 
    4474                 :             :          now that all types have been resolved it is safe to declare
    4475                 :             :          variables
    4476                 :             :   */
    4477                 :         408 :       AssertAllTypesDeclared (scope);
    4478                 :         408 :       DeclareGlobalVariablesWholeProgram (scope);
    4479                 :         408 :       SymbolTable_ForeachImportedDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareImportedVariablesWholeProgram});
    4480                 :             :       /* now it is safe to declare all procedures  */
    4481                 :         408 :       SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
    4482                 :         408 :       SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) WalkTypesInModule});
    4483                 :         408 :       SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareTypesConstantsProcedures});
    4484                 :         408 :       SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
    4485                 :         408 :       DeclareModuleInit (scope);
    4486                 :             :     }
    4487                 :             :   else
    4488                 :             :     {
    4489                 :           0 :       DeclareTypesConstantsProcedures (scope);
    4490                 :           0 :       AssertAllTypesDeclared (scope);
    4491                 :           0 :       SymbolTable_ForeachProcedureDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
    4492                 :           0 :       DeclareModuleInit (scope);
    4493                 :           0 :       SymbolTable_ForeachInnerModuleDo (scope, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_StartDeclareScope});
    4494                 :             :     }
    4495                 :         408 : }
    4496                 :             : 
    4497                 :             : 
    4498                 :             : /*
    4499                 :             :    StartDeclareModuleScope -
    4500                 :             : */
    4501                 :             : 
    4502                 :       15121 : static void StartDeclareModuleScope (unsigned int scope)
    4503                 :             : {
    4504                 :       15121 :   if (M2Options_WholeProgram)
    4505                 :             :     {
    4506                 :         408 :       StartDeclareModuleScopeWholeProgram (scope);
    4507                 :             :     }
    4508                 :             :   else
    4509                 :             :     {
    4510                 :       14713 :       StartDeclareModuleScopeSeparate (scope);
    4511                 :             :     }
    4512                 :       15061 : }
    4513                 :             : 
    4514                 :             : 
    4515                 :             : /*
    4516                 :             :    DumpResolver - dumps the m2 representation of sym.
    4517                 :             : */
    4518                 :             : 
    4519                 :           0 : static void DumpResolver (unsigned int sym)
    4520                 :             : {
    4521                 :           0 :   M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "dump filtered symbol %d and dependants\\n", 40, (const unsigned char *) &sym, (sizeof (sym)-1));
    4522                 :           0 :   PrintVerbose (sym);
    4523                 :           0 : }
    4524                 :             : 
    4525                 :             : 
    4526                 :             : /*
    4527                 :             :    DumpDefinitive - dumps the m2 and m2 gimple representation of sym.
    4528                 :             : */
    4529                 :             : 
    4530                 :           0 : static void DumpDefinitive (unsigned int sym)
    4531                 :             : {
    4532                 :           0 :   int fd;
    4533                 :             : 
    4534                 :           0 :   M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "\\nm2 symbol synopsis: %d\\n", 26, (const unsigned char *) &sym, (sizeof (sym)-1));
    4535                 :           0 :   PrintVerbose (sym);
    4536                 :           0 :   if (SymbolConversion_GccKnowsAbout (sym))
    4537                 :             :     {
    4538                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "\\nm2 gimple: %d", 15, (const unsigned char *) &sym, (sizeof (sym)-1));
    4539                 :           0 :       FIO_FlushBuffer (M2LangDump_GetDumpFile ());
    4540                 :           0 :       fd = FIO_GetUnixFileDescriptor (M2LangDump_GetDumpFile ());
    4541                 :           0 :       m2pp_DumpGimpleFd (fd, SymbolConversion_Mod2Gcc (sym));
    4542                 :             :     }
    4543                 :             :   else
    4544                 :             :     {
    4545                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "\\nno m2 gimple for %d\\n", 23, (const unsigned char *) &sym, (sizeof (sym)-1));
    4546                 :             :     }
    4547                 :           0 : }
    4548                 :             : 
    4549                 :             : 
    4550                 :             : /*
    4551                 :             :    PreAddModGcc - adds a relationship between sym and tree.
    4552                 :             : */
    4553                 :             : 
    4554                 :    10012718 : static void PreAddModGcc (unsigned int sym, tree tree)
    4555                 :             : {
    4556                 :     9303345 :   SymbolConversion_AddModGcc (sym, tree);
    4557                 :      155829 : }
    4558                 :             : 
    4559                 :             : 
    4560                 :             : /*
    4561                 :             :    DeclareDefaultType - declares a default type, sym, with, name.
    4562                 :             : */
    4563                 :             : 
    4564                 :      616147 : static void DeclareDefaultType (unsigned int sym, const char *name_, unsigned int _name_high, tree gcctype)
    4565                 :             : {
    4566                 :      616147 :   tree t;
    4567                 :      616147 :   unsigned int high;
    4568                 :      616147 :   unsigned int low;
    4569                 :      616147 :   location_t location;
    4570                 :      616147 :   char name[_name_high+1];
    4571                 :             : 
    4572                 :             :   /* make a local copy of each unbounded array.  */
    4573                 :      616147 :   memcpy (name, name_, _name_high+1);
    4574                 :             : 
    4575                 :             :   /* DeclareDefaultType will declare a new identifier as a type of, gcctype, if it has not already been
    4576                 :             :       declared by gccgm2.c  */
    4577                 :     1232294 :   location = m2linemap_BuiltinsLocation ();
    4578                 :      616147 :   t = m2type_GetDefaultType (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (NameKey_MakeKey ((const char *) name, _name_high))), gcctype);
    4579                 :      616147 :   SymbolConversion_AddModGcc (sym, t);
    4580                 :      616147 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, sym);
    4581                 :      616147 :   WalkAssociatedUnbounded (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
    4582                 :             :   /* 
    4583                 :             :       this is very simplistic and assumes that the caller only uses Subranges, Sets and GCC types.
    4584                 :             :       We need to declare any constants with the types so that AllDependantsFullyDeclared works.
    4585                 :             :   */
    4586                 :      616147 :   if (SymbolTable_IsSubrange (sym))
    4587                 :             :     {
    4588                 :       14329 :       SymbolTable_GetSubrange (sym, &high, &low);
    4589                 :       14329 :       M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), high);
    4590                 :       14329 :       M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), low);
    4591                 :             :     }
    4592                 :      601818 :   else if (SymbolTable_IsSet (sym))
    4593                 :             :     {
    4594                 :             :       /* avoid dangling else.  */
    4595                 :       57316 :       if (SymbolTable_IsSubrange (SymbolTable_GetSType (sym)))
    4596                 :             :         {
    4597                 :       57316 :           if (! (SymbolConversion_GccKnowsAbout (SymbolTable_GetSType (sym))))
    4598                 :             :             {
    4599                 :             :               /* only true for internal types of course  */
    4600                 :           0 :               M2Error_InternalError ((const char *) "subrange type within the set type must be declared before the set type", 70);
    4601                 :             :             }
    4602                 :       57316 :           SymbolTable_GetSubrange (SymbolTable_GetSType (sym), &high, &low);
    4603                 :       57316 :           M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), high);
    4604                 :       57316 :           M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (sym), low);
    4605                 :             :         }
    4606                 :           0 :       else if (SymbolTable_IsEnumeration (SymbolTable_GetSType (sym)))
    4607                 :             :         {
    4608                 :             :           /* avoid dangling else.  */
    4609                 :           0 :           if (! (SymbolConversion_GccKnowsAbout (SymbolTable_GetSType (sym))))
    4610                 :             :             {
    4611                 :             :               /* only true for internal types of course  */
    4612                 :           0 :               M2Error_InternalError ((const char *) "enumeration type within the set type must be declared before the set type", 73);
    4613                 :             :             }
    4614                 :             :         }
    4615                 :             :     }
    4616                 :      616147 : }
    4617                 :             : 
    4618                 :             : 
    4619                 :             : /*
    4620                 :             :    DeclareBoolean - declares the Boolean type together with true and false.
    4621                 :             : */
    4622                 :             : 
    4623                 :       14329 : static void DeclareBoolean (void)
    4624                 :             : {
    4625                 :       14329 :   SymbolConversion_AddModGcc (M2Base_Boolean, m2type_GetBooleanType ());
    4626                 :       14329 :   SymbolConversion_AddModGcc (M2Base_True, m2type_GetBooleanTrue ());
    4627                 :       14329 :   SymbolConversion_AddModGcc (M2Base_False, m2type_GetBooleanFalse ());
    4628                 :       14329 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_Boolean);
    4629                 :       14329 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_True);
    4630                 :       14329 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_False);
    4631                 :       14329 :   WalkAssociatedUnbounded (M2Base_Boolean, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
    4632                 :       14329 : }
    4633                 :             : 
    4634                 :             : 
    4635                 :             : /*
    4636                 :             :    DeclareFixedSizedType - declares the GNU Modula-2 fixed types
    4637                 :             :                            (if the back end support such a type).
    4638                 :             : */
    4639                 :             : 
    4640                 :      315238 : static void DeclareFixedSizedType (const char *name_, unsigned int _name_high, unsigned int type, tree t)
    4641                 :             : {
    4642                 :      315238 :   location_t location;
    4643                 :      315238 :   unsigned int typetype;
    4644                 :      315238 :   unsigned int low;
    4645                 :      315238 :   unsigned int high;
    4646                 :      315238 :   char name[_name_high+1];
    4647                 :             : 
    4648                 :             :   /* make a local copy of each unbounded array.  */
    4649                 :      315238 :   memcpy (name, name_, _name_high+1);
    4650                 :             : 
    4651                 :      315238 :   if (type != SymbolTable_NulSym)
    4652                 :             :     {
    4653                 :      286580 :       if ((SymbolTable_IsSet (type)) && (! (SymbolConversion_GccKnowsAbout (SymbolTable_GetSType (type)))))
    4654                 :             :         {
    4655                 :       42987 :           typetype = SymbolTable_GetSType (type);
    4656                 :       42987 :           SymbolTable_GetSubrange (typetype, &high, &low);
    4657                 :       42987 :           M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (type), high);
    4658                 :       42987 :           M2GCCDeclare_DeclareConstant (SymbolTable_GetDeclaredMod (type), low);
    4659                 :       42987 :           location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (typetype));
    4660                 :       42987 :           PreAddModGcc (typetype, m2type_BuildSubrangeType (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (typetype))), SymbolConversion_Mod2Gcc (SymbolTable_GetSType (typetype)), SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high)));
    4661                 :       42987 :           Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, typetype);
    4662                 :       42987 :           WalkAssociatedUnbounded (typetype, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
    4663                 :             :         }
    4664                 :             :       /* gcc back end supports, type  */
    4665                 :      286580 :       DeclareDefaultType (type, (const char *) name, _name_high, t);
    4666                 :             :     }
    4667                 :      315238 : }
    4668                 :             : 
    4669                 :             : 
    4670                 :             : /*
    4671                 :             :    DeclareDefaultSimpleTypes - declares the simple types.
    4672                 :             : */
    4673                 :             : 
    4674                 :       14329 : static void DeclareDefaultSimpleTypes (void)
    4675                 :             : {
    4676                 :       14329 :   SymbolConversion_AddModGcc (M2Base_ZType, m2type_GetM2ZType ());
    4677                 :       14329 :   SymbolConversion_AddModGcc (M2Base_RType, m2type_GetM2RType ());
    4678                 :       14329 :   SymbolConversion_AddModGcc (M2Base_CType, m2type_GetM2CType ());
    4679                 :       14329 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_ZType);
    4680                 :       14329 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_RType);
    4681                 :       14329 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_CType);
    4682                 :       14329 :   DeclareDefaultType (M2Base_Cardinal, (const char *) "CARDINAL", 8, m2type_GetM2CardinalType ());
    4683                 :       14329 :   DeclareDefaultType (M2Base_Integer, (const char *) "INTEGER", 7, m2type_GetM2IntegerType ());
    4684                 :       14329 :   DeclareDefaultType (M2Base_Char, (const char *) "CHAR", 4, m2type_GetM2CharType ());
    4685                 :       14329 :   DeclareDefaultType (M2System_Loc, (const char *) "LOC", 3, m2type_GetISOLocType ());
    4686                 :       14329 :   if (M2Options_Iso)
    4687                 :             :     {
    4688                 :        3454 :       DeclareDefaultType (M2System_Byte, (const char *) "BYTE", 4, m2type_GetISOByteType ());
    4689                 :        3454 :       DeclareDefaultType (M2System_Word, (const char *) "WORD", 4, m2type_GetISOWordType ());
    4690                 :             :     }
    4691                 :             :   else
    4692                 :             :     {
    4693                 :       10875 :       DeclareDefaultType (M2System_Byte, (const char *) "BYTE", 4, m2type_GetByteType ());
    4694                 :       10875 :       DeclareDefaultType (M2System_Word, (const char *) "WORD", 4, m2type_GetWordType ());
    4695                 :             :     }
    4696                 :       14329 :   DeclareDefaultType (M2Base_Proc, (const char *) "PROC", 4, m2type_GetProcType ());
    4697                 :       14329 :   DeclareDefaultType (M2System_Address, (const char *) "ADDRESS", 7, m2type_GetPointerType ());
    4698                 :       14329 :   DeclareDefaultType (M2Base_LongInt, (const char *) "LONGINT", 7, m2type_GetM2LongIntType ());
    4699                 :       14329 :   DeclareDefaultType (M2Base_LongCard, (const char *) "LONGCARD", 8, m2type_GetM2LongCardType ());
    4700                 :       14329 :   DeclareDefaultType (M2Base_ShortInt, (const char *) "SHORTINT", 8, m2type_GetM2ShortIntType ());
    4701                 :       14329 :   DeclareDefaultType (M2Base_ShortCard, (const char *) "SHORTCARD", 9, m2type_GetM2ShortCardType ());
    4702                 :       14329 :   DeclareDefaultType (M2Base_ShortReal, (const char *) "SHORTREAL", 9, m2type_GetM2ShortRealType ());
    4703                 :       14329 :   DeclareDefaultType (M2Base_Real, (const char *) "REAL", 4, m2type_GetM2RealType ());
    4704                 :       14329 :   DeclareDefaultType (M2Base_LongReal, (const char *) "LONGREAL", 8, m2type_GetM2LongRealType ());
    4705                 :       14329 :   DeclareDefaultType (M2Bitset_Bitnum, (const char *) "BITNUM", 6, m2type_GetBitnumType ());
    4706                 :       14329 :   DeclareDefaultType (M2Bitset_Bitset, (const char *) "BITSET", 6, m2type_GetBitsetType ());
    4707                 :       14329 :   DeclareDefaultType (M2Base_Complex, (const char *) "COMPLEX", 7, m2type_GetM2ComplexType ());
    4708                 :       14329 :   DeclareDefaultType (M2Base_LongComplex, (const char *) "LONGCOMPLEX", 11, m2type_GetM2LongComplexType ());
    4709                 :       14329 :   DeclareDefaultType (M2Base_ShortComplex, (const char *) "SHORTCOMPLEX", 12, m2type_GetM2ShortComplexType ());
    4710                 :       14329 :   DeclareDefaultType (M2System_CSizeT, (const char *) "CSIZE_T", 7, m2type_GetCSizeTType ());
    4711                 :       14329 :   DeclareDefaultType (M2System_CSSizeT, (const char *) "CSSIZE_T", 8, m2type_GetCSSizeTType ());
    4712                 :       14329 :   DeclareDefaultType (M2System_COffT, (const char *) "COFF_T", 6, m2type_GetCOffTType ());
    4713                 :       14329 :   DeclareBoolean ();
    4714                 :       14329 :   DeclareFixedSizedType ((const char *) "INTEGER8", 8, M2System_IntegerN (8), m2type_GetM2Integer8 ());
    4715                 :       14329 :   DeclareFixedSizedType ((const char *) "INTEGER16", 9, M2System_IntegerN (16), m2type_GetM2Integer16 ());
    4716                 :       14329 :   DeclareFixedSizedType ((const char *) "INTEGER32", 9, M2System_IntegerN (32), m2type_GetM2Integer32 ());
    4717                 :       14329 :   DeclareFixedSizedType ((const char *) "INTEGER64", 9, M2System_IntegerN (64), m2type_GetM2Integer64 ());
    4718                 :       14329 :   DeclareFixedSizedType ((const char *) "CARDINAL8", 9, M2System_CardinalN (8), m2type_GetM2Cardinal8 ());
    4719                 :       14329 :   DeclareFixedSizedType ((const char *) "CARDINAL16", 10, M2System_CardinalN (16), m2type_GetM2Cardinal16 ());
    4720                 :       14329 :   DeclareFixedSizedType ((const char *) "CARDINAL32", 10, M2System_CardinalN (32), m2type_GetM2Cardinal32 ());
    4721                 :       14329 :   DeclareFixedSizedType ((const char *) "CARDINAL64", 10, M2System_CardinalN (64), m2type_GetM2Cardinal64 ());
    4722                 :       14329 :   DeclareFixedSizedType ((const char *) "WORD16", 6, M2System_WordN (16), m2type_GetM2Word16 ());
    4723                 :       14329 :   DeclareFixedSizedType ((const char *) "WORD32", 6, M2System_WordN (32), m2type_GetM2Word32 ());
    4724                 :       14329 :   DeclareFixedSizedType ((const char *) "WORD64", 6, M2System_WordN (64), m2type_GetM2Word64 ());
    4725                 :       14329 :   DeclareFixedSizedType ((const char *) "BITSET8", 7, M2System_SetN (8), m2type_GetM2Bitset8 ());
    4726                 :       14329 :   DeclareFixedSizedType ((const char *) "BITSET16", 8, M2System_SetN (16), m2type_GetM2Bitset16 ());
    4727                 :       14329 :   DeclareFixedSizedType ((const char *) "BITSET32", 8, M2System_SetN (32), m2type_GetM2Bitset32 ());
    4728                 :       14329 :   DeclareFixedSizedType ((const char *) "REAL32", 6, M2System_RealN (32), m2type_GetM2Real32 ());
    4729                 :       14329 :   DeclareFixedSizedType ((const char *) "REAL64", 6, M2System_RealN (64), m2type_GetM2Real64 ());
    4730                 :       14329 :   DeclareFixedSizedType ((const char *) "REAL96", 6, M2System_RealN (96), m2type_GetM2Real96 ());
    4731                 :       14329 :   DeclareFixedSizedType ((const char *) "REAL128", 7, M2System_RealN (128), m2type_GetM2Real128 ());
    4732                 :       14329 :   DeclareFixedSizedType ((const char *) "COMPLEX32", 9, M2System_ComplexN (32), m2type_GetM2Complex32 ());
    4733                 :       14329 :   DeclareFixedSizedType ((const char *) "COMPLEX64", 9, M2System_ComplexN (64), m2type_GetM2Complex64 ());
    4734                 :       14329 :   DeclareFixedSizedType ((const char *) "COMPLEX96", 9, M2System_ComplexN (96), m2type_GetM2Complex96 ());
    4735                 :       14329 :   DeclareFixedSizedType ((const char *) "COMPLEX128", 10, M2System_ComplexN (128), m2type_GetM2Complex128 ());
    4736                 :       14329 : }
    4737                 :             : 
    4738                 :             : 
    4739                 :             : /*
    4740                 :             :    DeclarePackedBoolean -
    4741                 :             : */
    4742                 :             : 
    4743                 :       14329 : static void DeclarePackedBoolean (void)
    4744                 :             : {
    4745                 :       14329 :   unsigned int e;
    4746                 :             : 
    4747                 :       14329 :   e = SymbolTable_GetPackedEquivalent (M2Base_Boolean);
    4748                 :       14329 :   SymbolConversion_AddModGcc (e, m2type_GetPackedBooleanType ());
    4749                 :       14329 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, e);
    4750                 :       14329 : }
    4751                 :             : 
    4752                 :             : 
    4753                 :             : /*
    4754                 :             :    DeclarePackedDefaultSimpleTypes -
    4755                 :             : */
    4756                 :             : 
    4757                 :       14329 : static void DeclarePackedDefaultSimpleTypes (void)
    4758                 :             : {
    4759                 :           0 :   DeclarePackedBoolean ();
    4760                 :           0 : }
    4761                 :             : 
    4762                 :             : 
    4763                 :             : /*
    4764                 :             :    DeclareDefaultTypes - makes default types known to GCC
    4765                 :             : */
    4766                 :             : 
    4767                 :       14329 : static void DeclareDefaultTypes (void)
    4768                 :             : {
    4769                 :       14329 :   if (! HaveInitDefaultTypes)
    4770                 :             :     {
    4771                 :       14329 :       HaveInitDefaultTypes = true;
    4772                 :       14329 :       m2block_pushGlobalScope ();
    4773                 :       14329 :       DeclareDefaultSimpleTypes ();
    4774                 :       14329 :       DeclarePackedDefaultSimpleTypes ();
    4775                 :       14329 :       m2block_popGlobalScope ();
    4776                 :             :     }
    4777                 :       14329 : }
    4778                 :             : 
    4779                 :             : 
    4780                 :             : /*
    4781                 :             :    DeclareDefaultConstants - make default constants known to GCC
    4782                 :             : */
    4783                 :             : 
    4784                 :       14329 : static void DeclareDefaultConstants (void)
    4785                 :             : {
    4786                 :       14329 :   SymbolConversion_AddModGcc (M2Base_Nil, m2expr_GetPointerZero (m2linemap_BuiltinsLocation ()));
    4787                 :       14329 :   Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, M2Base_Nil);
    4788                 :       14329 : }
    4789                 :             : 
    4790                 :             : 
    4791                 :             : /*
    4792                 :             :    FindContext - returns the scope where the symbol
    4793                 :             :                  should be created.
    4794                 :             : 
    4795                 :             :                  Symbols created in a module will
    4796                 :             :                  return the global context tree, but symbols created
    4797                 :             :                  in a module which is declared inside
    4798                 :             :                  a procedure will return the procedure Tree.
    4799                 :             : */
    4800                 :             : 
    4801                 :      103630 : static tree FindContext (unsigned int sym)
    4802                 :             : {
    4803                 :      103630 :   sym = SymbolTable_GetProcedureScope (sym);
    4804                 :      103630 :   if (sym == SymbolTable_NulSym)
    4805                 :             :     {
    4806                 :      103630 :       return m2block_GetGlobalContext ();
    4807                 :             :     }
    4808                 :             :   else
    4809                 :             :     {
    4810                 :           0 :       return SymbolConversion_Mod2Gcc (sym);
    4811                 :             :     }
    4812                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4813                 :             :   __builtin_unreachable ();
    4814                 :             : }
    4815                 :             : 
    4816                 :             : 
    4817                 :             : /*
    4818                 :             :    IsEffectivelyImported - returns TRUE if symbol, Sym, was
    4819                 :             :                            effectively imported into ModSym.
    4820                 :             : */
    4821                 :             : 
    4822                 :     2912968 : static bool IsEffectivelyImported (unsigned int ModSym, unsigned int sym)
    4823                 :             : {
    4824                 :     2912968 :   return (SymbolTable_IsImported (ModSym, sym)) || ((SymbolTable_IsImported (ModSym, GetModuleWhereDeclared (sym))) && (SymbolTable_IsExported (GetModuleWhereDeclared (sym), sym)));
    4825                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4826                 :             :   __builtin_unreachable ();
    4827                 :             : }
    4828                 :             : 
    4829                 :             : 
    4830                 :             : /*
    4831                 :             :    FindOuterModule - returns the out most module where, sym,
    4832                 :             :                      was declared.  It returns NulSym if the
    4833                 :             :                      symbol or the module was declared inside
    4834                 :             :                      a procedure.
    4835                 :             : */
    4836                 :             : 
    4837                 :      103708 : static unsigned int FindOuterModule (unsigned int sym)
    4838                 :             : {
    4839                 :      103708 :   sym = SymbolTable_GetScope (sym);
    4840                 :      207518 :   while (! (SymbolTable_IsDefImp (sym)))
    4841                 :             :     {
    4842                 :       99426 :       if (SymbolTable_IsModule (sym))
    4843                 :             :         {
    4844                 :       99426 :           if ((SymbolTable_GetScope (sym)) == SymbolTable_NulSym)
    4845                 :             :             {
    4846                 :             :               return sym;
    4847                 :             :             }
    4848                 :             :           else
    4849                 :             :             {
    4850                 :         102 :               sym = SymbolTable_GetScope (sym);
    4851                 :             :             }
    4852                 :             :         }
    4853                 :           0 :       else if (SymbolTable_IsProcedure (sym))
    4854                 :             :         {
    4855                 :             :           /* avoid dangling else.  */
    4856                 :           0 :           sym = SymbolTable_GetScope (sym);
    4857                 :             :         }
    4858                 :             :     }
    4859                 :             :   return sym;
    4860                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4861                 :             :   __builtin_unreachable ();
    4862                 :             : }
    4863                 :             : 
    4864                 :             : 
    4865                 :             : /*
    4866                 :             :    DoVariableDeclaration - create a corresponding gcc variable and add the association
    4867                 :             :                            between the front end symbol var and the gcc tree.
    4868                 :             : */
    4869                 :             : 
    4870                 :      673389 : static void DoVariableDeclaration (unsigned int var, void * name, bool isImported, bool isExported, bool isTemporary, bool isGlobal, tree scope)
    4871                 :             : {
    4872                 :      673389 :   if (! ((SymbolTable_IsComponent (var)) || (SymbolTable_IsVarHeap (var))))
    4873                 :             :     {
    4874                 :      544909 :       if (TypeDependentsDeclared (var, true))
    4875                 :             :         {
    4876                 :      544903 :           PrepareGCCVarDeclaration (var, name, isImported, isExported, isTemporary, isGlobal, scope);
    4877                 :             :         }
    4878                 :             :     }
    4879                 :      673389 : }
    4880                 :             : 
    4881                 :             : 
    4882                 :             : /*
    4883                 :             :    TypeDependentsDeclared - return TRUE if all type dependents of variable
    4884                 :             :                             have been declared.
    4885                 :             : */
    4886                 :             : 
    4887                 :     1292591 : static bool TypeDependentsDeclared (unsigned int variable, bool errorMessage)
    4888                 :             : {
    4889                 :     1292591 :   unsigned int type;
    4890                 :             : 
    4891                 :     1292591 :   type = SymbolTable_GetSType (variable);
    4892                 :     1292591 :   if (AllDependantsFullyDeclared (type))
    4893                 :             :     {
    4894                 :             :       return true;
    4895                 :             :     }
    4896                 :             :   else
    4897                 :             :     {
    4898                 :          30 :       if (errorMessage)
    4899                 :             :         {
    4900                 :          30 :           EmitCircularDependencyError (variable);
    4901                 :          30 :           Sets_ForeachElementInSetDo (GlobalGroup->ToDoList, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) EmitCircularDependencyError});
    4902                 :             :         }
    4903                 :             :     }
    4904                 :             :   return false;
    4905                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4906                 :             :   __builtin_unreachable ();
    4907                 :             : }
    4908                 :             : 
    4909                 :             : 
    4910                 :             : /*
    4911                 :             :    PrepareGCCVarDeclaration -
    4912                 :             : */
    4913                 :             : 
    4914                 :      544903 : static void PrepareGCCVarDeclaration (unsigned int var, void * name, bool isImported, bool isExported, bool isTemporary, bool isGlobal, tree scope)
    4915                 :             : {
    4916                 :      544903 :   tree type;
    4917                 :      544903 :   unsigned int varType;
    4918                 :      544903 :   location_t location;
    4919                 :             : 
    4920                 :      544903 :   if ((SymbolTable_GetMode (var)) == SymbolTable_LeftValue)
    4921                 :             :     {
    4922                 :             :       /* 
    4923                 :             :         There are two issues to deal with:
    4924                 :             : 
    4925                 :             :         (i)   LeftValue is really a pointer to GetSType (var), which is built
    4926                 :             :               here.
    4927                 :             :         (ii)  Front end might have specified the back end use a particular
    4928                 :             :               data type, in which case we use the specified type.
    4929                 :             :               We do not add an extra pointer if this is the case.
    4930                 :             :   */
    4931                 :       77414 :       varType = SymbolTable_SkipType (SymbolTable_GetVarBackEndType (var));
    4932                 :       77414 :       if (varType == SymbolTable_NulSym)
    4933                 :             :         {
    4934                 :             :           /* We have not explicity told back end the type, so build it.  */
    4935                 :       28334 :           varType = SymbolTable_GetSType (var);
    4936                 :       28334 :           if (SymbolTable_IsVariableAtAddress (var))
    4937                 :             :             {
    4938                 :          54 :               type = m2type_BuildConstPointerType (SymbolConversion_Mod2Gcc (varType));
    4939                 :             :             }
    4940                 :             :           else
    4941                 :             :             {
    4942                 :       28280 :               type = m2type_BuildPointerType (SymbolConversion_Mod2Gcc (varType));
    4943                 :             :             }
    4944                 :             :         }
    4945                 :             :       else
    4946                 :             :         {
    4947                 :             :           /* We have been requested to use varType.  */
    4948                 :       49080 :           type = SymbolConversion_Mod2Gcc (varType);
    4949                 :             :         }
    4950                 :       77414 :       M2Debug_Assert (AllDependantsFullyDeclared (varType));
    4951                 :             :     }
    4952                 :             :   else
    4953                 :             :     {
    4954                 :      467489 :       type = SymbolConversion_Mod2Gcc (SymbolTable_GetDType (var));
    4955                 :             :     }
    4956                 :      544903 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (var));
    4957                 :      544903 :   PreAddModGcc (var, m2decl_DeclareKnownVariable (location, const_cast <const char * > (static_cast <char * > (name)), type, isExported, isImported, isTemporary, isGlobal, scope, NULL));
    4958                 :      544903 :   WatchRemoveList (var, M2GCCDeclare_todolist);
    4959                 :      544903 :   WatchIncludeList (var, M2GCCDeclare_fullydeclared);
    4960                 :      544903 : }
    4961                 :             : 
    4962                 :             : 
    4963                 :             : /*
    4964                 :             :    IsGlobal - is the variable not in a procedure scope.
    4965                 :             : */
    4966                 :             : 
    4967                 :      103630 : static bool IsGlobal (unsigned int sym)
    4968                 :             : {
    4969                 :      103630 :   unsigned int s;
    4970                 :             : 
    4971                 :      103630 :   s = SymbolTable_GetScope (sym);
    4972                 :      207260 :   while (((s != SymbolTable_NulSym) && (! (SymbolTable_IsDefImp (s)))) && (! (SymbolTable_IsModule (s))))
    4973                 :             :     {
    4974                 :           0 :       if (SymbolTable_IsProcedure (s))
    4975                 :             :         {
    4976                 :             :           return false;
    4977                 :             :         }
    4978                 :           0 :       s = SymbolTable_GetScope (s);
    4979                 :             :     }
    4980                 :             :   return true;
    4981                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    4982                 :             :   __builtin_unreachable ();
    4983                 :             : }
    4984                 :             : 
    4985                 :             : 
    4986                 :             : /*
    4987                 :             :    DeclareVariable - declares a global variable to GCC.
    4988                 :             : */
    4989                 :             : 
    4990                 :      102710 : static void DeclareVariable (unsigned int ModSym, unsigned int variable)
    4991                 :             : {
    4992                 :      102710 :   tree scope;
    4993                 :      102710 :   unsigned int decl;
    4994                 :             : 
    4995                 :      102710 :   if (! (SymbolConversion_GccKnowsAbout (variable)))
    4996                 :             :     {
    4997                 :      102634 :       scope = FindContext (ModSym);
    4998                 :      102634 :       decl = FindOuterModule (variable);
    4999                 :      102634 :       PushBinding (ModSym);
    5000                 :             :       /* in Modula-2 we are allowed to import from ourselves, but we do not present this to GCC  */
    5001                 :      204262 :       DoVariableDeclaration (variable, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (variable)), (IsEffectivelyImported (ModSym, variable)) && ((SymbolTable_GetMainModule ()) != decl), SymbolTable_IsExported (ModSym, variable), SymbolTable_IsTemporary (variable), IsGlobal (variable), scope);
    5002                 :      102634 :       PopBinding (ModSym);
    5003                 :             :     }
    5004                 :      102710 : }
    5005                 :             : 
    5006                 :             : 
    5007                 :             : /*
    5008                 :             :    DeclareVariableWholeProgram - declares a global variable to GCC when using -fm2-whole-program.
    5009                 :             : */
    5010                 :             : 
    5011                 :         996 : static void DeclareVariableWholeProgram (unsigned int mainModule, unsigned int variable)
    5012                 :             : {
    5013                 :         996 :   tree scope;
    5014                 :         996 :   unsigned int decl;
    5015                 :             : 
    5016                 :         996 :   if (! (SymbolConversion_GccKnowsAbout (variable)))
    5017                 :             :     {
    5018                 :         996 :       scope = FindContext (mainModule);
    5019                 :         996 :       decl = FindOuterModule (variable);
    5020                 :         996 :       PushBinding (mainModule);
    5021                 :        1992 :       DoVariableDeclaration (variable, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (variable)), ((! (M2Batch_IsSourceSeen (decl))) && (IsEffectivelyImported (mainModule, variable))) && ((SymbolTable_GetMainModule ()) != decl), SymbolTable_IsExported (mainModule, variable), SymbolTable_IsTemporary (variable), IsGlobal (variable), scope);
    5022                 :         996 :       PopBinding (mainModule);
    5023                 :             :     }
    5024                 :         996 : }
    5025                 :             : 
    5026                 :             : 
    5027                 :             : /*
    5028                 :             :    DeclareGlobalVariablesWholeProgram -
    5029                 :             : */
    5030                 :             : 
    5031                 :         408 : static void DeclareGlobalVariablesWholeProgram (unsigned int ModSym)
    5032                 :             : {
    5033                 :         408 :   unsigned int n;
    5034                 :         408 :   unsigned int Variable;
    5035                 :             : 
    5036                 :         408 :   n = 1;
    5037                 :         408 :   Variable = SymbolTable_GetNth (ModSym, n);
    5038                 :        1812 :   while (Variable != SymbolTable_NulSym)
    5039                 :             :     {
    5040                 :         996 :       DeclareVariableWholeProgram (ModSym, Variable);
    5041                 :         996 :       n += 1;
    5042                 :         996 :       Variable = SymbolTable_GetNth (ModSym, n);
    5043                 :             :     }
    5044                 :         408 :   SymbolTable_ForeachInnerModuleDo (ModSym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareGlobalVariablesWholeProgram});
    5045                 :         408 : }
    5046                 :             : 
    5047                 :             : 
    5048                 :             : /*
    5049                 :             :    DeclareGlobalVariables - lists the Global variables for
    5050                 :             :                             Module ModSym together with their offset.
    5051                 :             : */
    5052                 :             : 
    5053                 :       14497 : static void DeclareGlobalVariables (unsigned int ModSym)
    5054                 :             : {
    5055                 :       14497 :   unsigned int n;
    5056                 :       14497 :   unsigned int Variable;
    5057                 :             : 
    5058                 :       14497 :   n = 1;
    5059                 :       14497 :   Variable = SymbolTable_GetNth (ModSym, n);
    5060                 :      130628 :   while (Variable != SymbolTable_NulSym)
    5061                 :             :     {
    5062                 :      101634 :       DeclareVariable (ModSym, Variable);
    5063                 :      101634 :       n += 1;
    5064                 :      101634 :       Variable = SymbolTable_GetNth (ModSym, n);
    5065                 :             :     }
    5066                 :       14497 :   SymbolTable_ForeachInnerModuleDo (ModSym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareGlobalVariables});
    5067                 :       14497 : }
    5068                 :             : 
    5069                 :             : 
    5070                 :             : /*
    5071                 :             :    DeclareImportedVariables - declares all imported variables to GM2.
    5072                 :             : */
    5073                 :             : 
    5074                 :       83057 : static void DeclareImportedVariables (unsigned int sym)
    5075                 :             : {
    5076                 :       83057 :   if (SymbolTable_IsVar (sym))
    5077                 :             :     {
    5078                 :        1076 :       DeclareVariable (SymbolTable_GetMainModule (), sym);
    5079                 :             :     }
    5080                 :       81981 :   else if (SymbolTable_IsDefImp (sym))
    5081                 :             :     {
    5082                 :             :       /* avoid dangling else.  */
    5083                 :        1872 :       SymbolTable_ForeachExportedDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareImportedVariables});
    5084                 :             :     }
    5085                 :       83057 : }
    5086                 :             : 
    5087                 :             : 
    5088                 :             : /*
    5089                 :             :    DeclareImportedVariablesWholeProgram - declares all imported variables.
    5090                 :             : */
    5091                 :             : 
    5092                 :        7404 : static void DeclareImportedVariablesWholeProgram (unsigned int sym)
    5093                 :             : {
    5094                 :        7404 :   if (SymbolTable_IsVar (sym))
    5095                 :             :     {
    5096                 :             :       /* avoid dangling else.  */
    5097                 :          78 :       if (! (M2Batch_IsSourceSeen (FindOuterModule (sym))))
    5098                 :             :         {
    5099                 :             :           /* import is necessary, even for -fm2-whole-program as we
    5100                 :             :             cannot see the source.  */
    5101                 :           0 :           DeclareVariableWholeProgram (SymbolTable_GetMainModule (), sym);
    5102                 :             :         }
    5103                 :             :     }
    5104                 :        7326 :   else if (SymbolTable_IsDefImp (sym))
    5105                 :             :     {
    5106                 :             :       /* avoid dangling else.  */
    5107                 :         144 :       SymbolTable_ForeachExportedDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclareImportedVariablesWholeProgram});
    5108                 :             :     }
    5109                 :        7404 : }
    5110                 :             : 
    5111                 :             : 
    5112                 :             : /*
    5113                 :             :    DeclareFieldValue -
    5114                 :             : */
    5115                 :             : 
    5116                 :      423942 : static tree DeclareFieldValue (unsigned int sym, tree value, tree *list)
    5117                 :             : {
    5118                 :      423942 :   location_t location;
    5119                 :             : 
    5120                 :      423942 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    5121                 :      423942 :   if (((GetModuleWhereDeclared (sym)) == SymbolTable_NulSym) || ((GetModuleWhereDeclared (sym)) == (SymbolTable_GetMainModule ())))
    5122                 :             :     {
    5123                 :        9732 :       return m2type_BuildEnumerator (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetSymName (sym))), value, list);
    5124                 :             :     }
    5125                 :             :   else
    5126                 :             :     {
    5127                 :      414210 :       return m2type_BuildEnumerator (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullScopeAsmName (sym))), value, list);
    5128                 :             :     }
    5129                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5130                 :             :   __builtin_unreachable ();
    5131                 :             : }
    5132                 :             : 
    5133                 :             : 
    5134                 :             : /*
    5135                 :             :    DeclareFieldEnumeration - declares an enumerator within the current enumeration type.
    5136                 :             : */
    5137                 :             : 
    5138                 :      423822 : static tree DeclareFieldEnumeration (unsigned int sym)
    5139                 :             : {
    5140                 :      423822 :   unsigned int type;
    5141                 :      423822 :   tree field;
    5142                 :      423822 :   tree enumlist;
    5143                 :             : 
    5144                 :             :   /* add relationship between gccSym and sym  */
    5145                 :      423822 :   type = SymbolTable_GetSType (sym);
    5146                 :      423822 :   enumlist = GetEnumList (type);
    5147                 :      423822 :   SymbolTable_PushValue (sym);
    5148                 :      423822 :   field = DeclareFieldValue (sym, M2ALU_PopIntegerTree (), &enumlist);
    5149                 :      423822 :   PutEnumList (type, enumlist);
    5150                 :      423822 :   return field;
    5151                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5152                 :             :   __builtin_unreachable ();
    5153                 :             : }
    5154                 :             : 
    5155                 :             : 
    5156                 :             : /*
    5157                 :             :    DeclareEnumeration - declare an enumerated type.
    5158                 :             : */
    5159                 :             : 
    5160                 :       23238 : static tree DeclareEnumeration (unsigned int sym)
    5161                 :             : {
    5162                 :       23238 :   tree enumlist;
    5163                 :       23238 :   tree gccenum;
    5164                 :       23238 :   location_t location;
    5165                 :             : 
    5166                 :       23238 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    5167                 :       23238 :   gccenum = m2type_BuildStartEnumeration (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym))), false);
    5168                 :       23238 :   enumlist = GetEnumList (sym);
    5169                 :       23238 :   return m2type_BuildEndEnumeration (location, gccenum, enumlist);
    5170                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5171                 :             :   __builtin_unreachable ();
    5172                 :             : }
    5173                 :             : 
    5174                 :             : 
    5175                 :             : /*
    5176                 :             :    DeclareSubrangeNarrow - will return cardinal, integer, or type depending on whether
    5177                 :             :                            low..high fits in the C data type.
    5178                 :             : */
    5179                 :             : 
    5180                 :       21094 : static tree DeclareSubrangeNarrow (location_t location, unsigned int high, unsigned int low, tree type)
    5181                 :             : {
    5182                 :       21094 :   tree m2low;
    5183                 :       21094 :   tree m2high;
    5184                 :       21094 :   tree lowtree;
    5185                 :       21094 :   tree hightree;
    5186                 :             : 
    5187                 :             :   /* No zero alignment, therefore the front end will prioritize subranges to match
    5188                 :             :       unsigned int, int, or ZTYPE assuming the low..high range fits.  */
    5189                 :       21094 :   lowtree = SymbolConversion_Mod2Gcc (low);
    5190                 :       21094 :   hightree = SymbolConversion_Mod2Gcc (high);
    5191                 :       21094 :   if ((m2expr_CompareTrees (lowtree, m2expr_GetIntegerZero (location))) >= 0)
    5192                 :             :     {
    5193                 :             :       /* avoid dangling else.  */
    5194                 :             :       /* low..high is always positive, can we use unsigned int?  */
    5195                 :       20838 :       m2high = m2type_GetMaxFrom (location, m2type_GetM2CardinalType ());
    5196                 :       20838 :       if ((m2expr_CompareTrees (hightree, m2high)) <= 0)
    5197                 :             :         {
    5198                 :       20838 :           return m2type_GetM2CardinalType ();
    5199                 :             :         }
    5200                 :             :     }
    5201                 :             :   else
    5202                 :             :     {
    5203                 :             :       /* Must be a signed subrange base, can we use int?  */
    5204                 :         256 :       m2high = m2type_GetMaxFrom (location, m2type_GetM2IntegerType ());
    5205                 :         256 :       m2low = m2type_GetMinFrom (location, m2type_GetM2IntegerType ());
    5206                 :         256 :       if (((m2expr_CompareTrees (lowtree, m2low)) >= 0) && ((m2expr_CompareTrees (hightree, m2high)) <= 0))
    5207                 :             :         {
    5208                 :         256 :           return m2type_GetM2IntegerType ();
    5209                 :             :         }
    5210                 :             :     }
    5211                 :             :   /* Fall back to the ZType.  */
    5212                 :             :   return type;
    5213                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5214                 :             :   __builtin_unreachable ();
    5215                 :             : }
    5216                 :             : 
    5217                 :             : 
    5218                 :             : /*
    5219                 :             :    DeclareSubrange - declare a subrange type.
    5220                 :             : */
    5221                 :             : 
    5222                 :       24558 : static tree DeclareSubrange (unsigned int sym)
    5223                 :             : {
    5224                 :       24558 :   tree type;
    5225                 :       24558 :   tree gccsym;
    5226                 :       24558 :   unsigned int align;
    5227                 :       24558 :   unsigned int high;
    5228                 :       24558 :   unsigned int low;
    5229                 :       24558 :   location_t location;
    5230                 :             : 
    5231                 :       24558 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    5232                 :       24558 :   SymbolTable_GetSubrange (sym, &high, &low);
    5233                 :       24558 :   align = SymbolTable_GetAlignment (sym);
    5234                 :       24558 :   type = SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym));
    5235                 :       24558 :   if (align != SymbolTable_NulSym)
    5236                 :             :     {
    5237                 :          12 :       if (m2expr_AreConstantsEqual (m2expr_GetIntegerZero (location), SymbolConversion_Mod2Gcc (align)))
    5238                 :             :         {
    5239                 :          12 :           type = m2type_BuildSmallestTypeRange (location, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
    5240                 :             :         }
    5241                 :             :       else
    5242                 :             :         {
    5243                 :           0 :           M2MetaError_MetaError1 ((const char *) "a non-zero alignment in a subrange type {%1Wa} is currently not implemented and will be ignored", 95, sym);
    5244                 :             :         }
    5245                 :             :     }
    5246                 :       24546 :   else if ((SymbolTable_GetSType (sym)) == M2Base_ZType)
    5247                 :             :     {
    5248                 :             :       /* avoid dangling else.  */
    5249                 :             :       /* Can we narrow the ZType subrange to CARDINAL or INTEGER?  */
    5250                 :       21094 :       type = DeclareSubrangeNarrow (location, high, low, type);
    5251                 :             :     }
    5252                 :       24558 :   gccsym = m2type_BuildSubrangeType (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym))), type, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
    5253                 :       24558 :   return gccsym;
    5254                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    5255                 :             :   __builtin_unreachable ();
    5256                 :             : }
    5257                 :             : 
    5258                 :             : 
    5259                 :             : /*
    5260                 :             :    IncludeGetNth -
    5261                 :             : */
    5262                 :             : 
    5263                 :           0 : static void IncludeGetNth (Lists_List l, unsigned int sym)
    5264                 :             : {
    5265                 :           0 :   unsigned int i;
    5266                 :             : 
    5267                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " ListOfFields [", 15);
    5268                 :           0 :   i = 1;
    5269                 :           0 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    5270                 :             :     {
    5271                 :           0 :       if (i > 1)
    5272                 :             :         {
    5273                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) ", ", 2);
    5274                 :             :         }
    5275                 :           0 :       Lists_IncludeItemIntoList (l, SymbolTable_GetNth (sym, i));
    5276                 :           0 :       PrintTerse (SymbolTable_GetNth (sym, i));
    5277                 :           0 :       i += 1;
    5278                 :             :     }
    5279                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
    5280                 :           0 : }
    5281                 :             : 
    5282                 :             : 
    5283                 :             : /*
    5284                 :             :    IncludeType -
    5285                 :             : */
    5286                 :             : 
    5287                 :           0 : static void IncludeType (Lists_List l, unsigned int sym)
    5288                 :             : {
    5289                 :           0 :   unsigned int t;
    5290                 :             : 
    5291                 :           0 :   t = SymbolTable_GetSType (sym);
    5292                 :           0 :   if (t != SymbolTable_NulSym)
    5293                 :             :     {
    5294                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " type [", 7);
    5295                 :           0 :       PrintTerse (t);
    5296                 :           0 :       Lists_IncludeItemIntoList (l, t);
    5297                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
    5298                 :           0 :       t = SymbolTable_GetVarBackEndType (sym);
    5299                 :           0 :       if (t != SymbolTable_NulSym)
    5300                 :             :         {
    5301                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " gcc type [", 11);
    5302                 :           0 :           PrintTerse (t);
    5303                 :           0 :           Lists_IncludeItemIntoList (l, t);
    5304                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
    5305                 :             :         }
    5306                 :             :     }
    5307                 :           0 : }
    5308                 :             : 
    5309                 :             : 
    5310                 :             : /*
    5311                 :             :    IncludeSubscript -
    5312                 :             : */
    5313                 :             : 
    5314                 :           0 : static void IncludeSubscript (Lists_List l, unsigned int sym)
    5315                 :             : {
    5316                 :           0 :   unsigned int t;
    5317                 :             : 
    5318                 :           0 :   t = SymbolTable_GetArraySubscript (sym);
    5319                 :           0 :   if (t != SymbolTable_NulSym)
    5320                 :             :     {
    5321                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " subrange [", 11);
    5322                 :           0 :       PrintTerse (t);
    5323                 :           0 :       Lists_IncludeItemIntoList (l, t);
    5324                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
    5325                 :             :     }
    5326                 :           0 : }
    5327                 :             : 
    5328                 :             : 
    5329                 :             : /*
    5330                 :             :    PrintLocalSymbol -
    5331                 :             : */
    5332                 :             : 
    5333                 :           0 : static void PrintLocalSymbol (unsigned int sym)
    5334                 :             : {
    5335                 :           0 :   PrintTerse (sym);
    5336                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) ", ", 2);
    5337                 :           0 : }
    5338                 :             : 
    5339                 :             : 
    5340                 :             : /*
    5341                 :             :    PrintLocalSymbols -
    5342                 :             : */
    5343                 :             : 
    5344                 :           0 : static void PrintLocalSymbols (unsigned int sym)
    5345                 :             : {
    5346                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "Local Symbols {", 15);
    5347                 :           0 :   SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PrintLocalSymbol});
    5348                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "}", 1);
    5349                 :           0 : }
    5350                 :             : 
    5351                 :             : 
    5352                 :             : /*
    5353                 :             :    IncludeGetVarient -
    5354                 :             : */
    5355                 :             : 
    5356                 :           0 : static void IncludeGetVarient (Lists_List l, unsigned int sym)
    5357                 :             : {
    5358                 :           0 :   if ((SymbolTable_GetVarient (sym)) != SymbolTable_NulSym)
    5359                 :             :     {
    5360                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " Varient [", 10);
    5361                 :           0 :       PrintTerse (SymbolTable_GetVarient (sym));
    5362                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
    5363                 :           0 :       Lists_IncludeItemIntoList (l, SymbolTable_GetVarient (sym));
    5364                 :             :     }
    5365                 :           0 : }
    5366                 :             : 
    5367                 :             : 
    5368                 :             : /*
    5369                 :             :    IncludeUnbounded - includes the record component of an unbounded type.
    5370                 :             : */
    5371                 :             : 
    5372                 :           0 : static void IncludeUnbounded (Lists_List l, unsigned int sym)
    5373                 :             : {
    5374                 :           0 :   if ((SymbolTable_GetUnboundedRecordType (sym)) != SymbolTable_NulSym)
    5375                 :             :     {
    5376                 :           0 :       Lists_IncludeItemIntoList (l, SymbolTable_GetUnboundedRecordType (sym));
    5377                 :             :     }
    5378                 :           0 : }
    5379                 :             : 
    5380                 :             : 
    5381                 :             : /*
    5382                 :             :    IncludePartialUnbounded - includes the type component of a partial unbounded symbol.
    5383                 :             : */
    5384                 :             : 
    5385                 :           0 : static void IncludePartialUnbounded (Lists_List l, unsigned int sym)
    5386                 :             : {
    5387                 :           0 :   if ((SymbolTable_GetSType (sym)) != SymbolTable_NulSym)
    5388                 :             :     {
    5389                 :           0 :       Lists_IncludeItemIntoList (l, SymbolTable_GetSType (sym));
    5390                 :             :     }
    5391                 :           0 : }
    5392                 :             : 
    5393                 :             : 
    5394                 :             : /*
    5395                 :             :    PrintDeclared - prints out where, sym, was declared.
    5396                 :             : */
    5397                 :             : 
    5398                 :           0 : static void PrintDeclared (unsigned int sym)
    5399                 :             : {
    5400                 :           0 :   DynamicStrings_String filename;
    5401                 :           0 :   unsigned int lineno;
    5402                 :           0 :   unsigned int tokenno;
    5403                 :             : 
    5404                 :           0 :   tokenno = SymbolTable_GetDeclaredMod (sym);
    5405                 :           0 :   filename = M2LexBuf_FindFileNameFromToken (tokenno, 0);
    5406                 :           0 :   lineno = M2LexBuf_TokenToLineNo (tokenno, 0);
    5407                 :           0 :   M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) " declared in %s:%d", 18, (const unsigned char *) &filename, (sizeof (filename)-1), (const unsigned char *) &lineno, (sizeof (lineno)-1));
    5408                 :           0 : }
    5409                 :             : 
    5410                 :             : 
    5411                 :             : /*
    5412                 :             :    PrintAlignment -
    5413                 :             : */
    5414                 :             : 
    5415                 :           0 : static void PrintAlignment (unsigned int sym)
    5416                 :             : {
    5417                 :           0 :   unsigned int align;
    5418                 :             : 
    5419                 :           0 :   if (((((SymbolTable_IsRecord (sym)) || (SymbolTable_IsType (sym))) || (SymbolTable_IsRecordField (sym))) || (SymbolTable_IsPointer (sym))) || (SymbolTable_IsArray (sym)))
    5420                 :             :     {
    5421                 :           0 :       align = SymbolTable_GetAlignment (sym);
    5422                 :           0 :       if (align != SymbolTable_NulSym)
    5423                 :             :         {
    5424                 :           0 :           M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) " aligned [%d]", 13, (const unsigned char *) &align, (sizeof (align)-1));
    5425                 :             :         }
    5426                 :             :     }
    5427                 :           0 : }
    5428                 :             : 
    5429                 :             : 
    5430                 :             : /*
    5431                 :             :    IncludeGetParent -
    5432                 :             : */
    5433                 :             : 
    5434                 :           0 : static void IncludeGetParent (Lists_List l, unsigned int sym)
    5435                 :             : {
    5436                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " Parent [", 9);
    5437                 :           0 :   Lists_IncludeItemIntoList (l, SymbolTable_GetParent (sym));
    5438                 :           0 :   PrintTerse (SymbolTable_GetParent (sym));
    5439                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "]", 1);
    5440                 :           0 : }
    5441                 :             : 
    5442                 :             : 
    5443                 :             : /*
    5444                 :             :    PrintDecl -
    5445                 :             : */
    5446                 :             : 
    5447                 :           0 : static void PrintDecl (unsigned int sym)
    5448                 :             : {
    5449                 :           0 :   if (SymbolTable_IsDeclaredPackedResolved (sym))
    5450                 :             :     {
    5451                 :           0 :       if (SymbolTable_IsDeclaredPacked (sym))
    5452                 :             :         {
    5453                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " packed", 7);
    5454                 :             :         }
    5455                 :             :       else
    5456                 :             :         {
    5457                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " unpacked", 9);
    5458                 :             :         }
    5459                 :             :     }
    5460                 :             :   else
    5461                 :             :     {
    5462                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " unknown if packed", 18);
    5463                 :             :     }
    5464                 :           0 : }
    5465                 :             : 
    5466                 :             : 
    5467                 :             : /*
    5468                 :             :    PrintScope - displays the scope and line number of declaration of symbol, sym.
    5469                 :             : */
    5470                 :             : 
    5471                 :           0 : static void PrintScope (unsigned int sym)
    5472                 :             : {
    5473                 :           0 :   NameKey_Name name;
    5474                 :           0 :   unsigned int scope;
    5475                 :           0 :   unsigned int line;
    5476                 :             : 
    5477                 :           0 :   line = M2LexBuf_TokenToLineNo (SymbolTable_GetDeclaredMod (sym), 0);
    5478                 :           0 :   scope = SymbolTable_GetScope (sym);
    5479                 :           0 :   name = SymbolTable_GetSymName (scope);
    5480                 :           0 :   M2Printf_fprintf3 (M2LangDump_GetDumpFile (), (const char *) " scope %a:%d %d", 15, (const unsigned char *) &name, (sizeof (name)-1), (const unsigned char *) &line, (sizeof (line)-1), (const unsigned char *) &scope, (sizeof (scope)-1));
    5481                 :           0 : }
    5482                 :             : 
    5483                 :             : 
    5484                 :             : /*
    5485                 :             :    PrintKind -
    5486                 :             : */
    5487                 :             : 
    5488                 :           0 : static void PrintKind (SymbolTable_ProcedureKind kind)
    5489                 :             : {
    5490                 :           0 :   DynamicStrings_String s;
    5491                 :             : 
    5492                 :           0 :   s = SymbolTable_GetProcedureKindDesc (kind);
    5493                 :           0 :   M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "%s", 2, (const unsigned char *) &s, (sizeof (s)-1));
    5494                 :           0 :   s = DynamicStrings_KillString (s);
    5495                 :           0 : }
    5496                 :             : 
    5497                 :             : 
    5498                 :             : /*
    5499                 :             :    PrintProcedureParameters -
    5500                 :             : */
    5501                 :             : 
    5502                 :           0 : static void PrintProcedureParameters (unsigned int sym, SymbolTable_ProcedureKind kind)
    5503                 :             : {
    5504                 :           0 :   NameKey_Name typeName;
    5505                 :           0 :   NameKey_Name paramName;
    5506                 :           0 :   unsigned int p;
    5507                 :           0 :   unsigned int i;
    5508                 :           0 :   unsigned int n;
    5509                 :           0 :   unsigned int type;
    5510                 :             : 
    5511                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " (", 2);
    5512                 :           0 :   n = SymbolTable_NoOfParam (sym, kind);
    5513                 :           0 :   i = 1;
    5514                 :           0 :   while (i <= n)
    5515                 :             :     {
    5516                 :           0 :       if (i > 1)
    5517                 :             :         {
    5518                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "; ", 2);
    5519                 :             :         }
    5520                 :           0 :       if (SymbolTable_IsVarParam (sym, kind, i))
    5521                 :             :         {
    5522                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "VAR ", 4);
    5523                 :             :         }
    5524                 :           0 :       p = SymbolTable_GetNthParam (sym, kind, i);
    5525                 :           0 :       paramName = SymbolTable_GetSymName (p);
    5526                 :           0 :       type = SymbolTable_GetType (p);
    5527                 :           0 :       typeName = SymbolTable_GetSymName (type);
    5528                 :           0 :       if (SymbolTable_IsUnboundedParam (sym, kind, i))
    5529                 :             :         {
    5530                 :           0 :           M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "%a: ARRAY OF %a", 15, (const unsigned char *) &paramName, (sizeof (paramName)-1), (const unsigned char *) &typeName, (sizeof (typeName)-1));
    5531                 :             :         }
    5532                 :             :       else
    5533                 :             :         {
    5534                 :           0 :           M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "%a: %a", 6, (const unsigned char *) &paramName, (sizeof (paramName)-1), (const unsigned char *) &typeName, (sizeof (typeName)-1));
    5535                 :             :         }
    5536                 :           0 :       i += 1;
    5537                 :             :     }
    5538                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) ")", 1);
    5539                 :           0 : }
    5540                 :             : 
    5541                 :             : 
    5542                 :             : /*
    5543                 :             :    PrintProcedureReturnType -
    5544                 :             : */
    5545                 :             : 
    5546                 :           0 : static void PrintProcedureReturnType (unsigned int sym)
    5547                 :             : {
    5548                 :           0 :   NameKey_Name typeName;
    5549                 :             : 
    5550                 :           0 :   if ((SymbolTable_GetType (sym)) != SymbolTable_NulSym)
    5551                 :             :     {
    5552                 :           0 :       typeName = SymbolTable_GetSymName (SymbolTable_GetType (sym));
    5553                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) " : %a", 5, (const unsigned char *) &typeName, (sizeof (typeName)-1));
    5554                 :             :     }
    5555                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " ;", 2);
    5556                 :           0 : }
    5557                 :             : 
    5558                 :             : 
    5559                 :             : /*
    5560                 :             :    PrintProcedure -
    5561                 :             : */
    5562                 :             : 
    5563                 :           0 : static void PrintProcedure (unsigned int sym)
    5564                 :             : {
    5565                 :           0 :   NameKey_Name n;
    5566                 :           0 :   SymbolTable_ProcedureKind kind;
    5567                 :             : 
    5568                 :           0 :   n = SymbolTable_GetSymName (sym);
    5569                 :           0 :   M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedure (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5570                 :           0 :   if (SymbolTable_IsProcedureReachable (sym))
    5571                 :             :     {
    5572                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsProcedureReachable", 21);
    5573                 :             :     }
    5574                 :           0 :   PrintScope (sym);
    5575                 :           0 :   if (SymbolTable_IsExtern (sym))
    5576                 :             :     {
    5577                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " extern", 7);
    5578                 :             :     }
    5579                 :           0 :   if (SymbolTable_IsPublic (sym))
    5580                 :             :     {
    5581                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " public", 7);
    5582                 :             :     }
    5583                 :           0 :   if (SymbolTable_IsCtor (sym))
    5584                 :             :     {
    5585                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " ctor", 5);
    5586                 :             :     }
    5587                 :           0 :   PrintDeclared (sym);
    5588                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "\\n", 2);
    5589                 :           0 :   for (kind=SymbolTable_ProperProcedure; kind<=SymbolTable_DefProcedure; kind= static_cast<SymbolTable_ProcedureKind>(static_cast<int>(kind+1)))
    5590                 :             :     {
    5591                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "parameters ", 11);
    5592                 :           0 :       PrintKind (kind);
    5593                 :           0 :       if (SymbolTable_GetProcedureParametersDefined (sym, kind))
    5594                 :             :         {
    5595                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " defined", 8);
    5596                 :           0 :           PrintProcedureParameters (sym, kind);
    5597                 :           0 :           PrintProcedureReturnType (sym);
    5598                 :             :         }
    5599                 :             :       else
    5600                 :             :         {
    5601                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " undefined", 10);
    5602                 :             :         }
    5603                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "\\n", 2);
    5604                 :             :     }
    5605                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " Associated proctype: ", 22);
    5606                 :           0 :   PrintProcType (SymbolTable_GetProcedureProcType (sym));
    5607                 :           0 : }
    5608                 :             : 
    5609                 :             : 
    5610                 :             : /*
    5611                 :             :    PrintProcTypeParameters -
    5612                 :             : */
    5613                 :             : 
    5614                 :           0 : static void PrintProcTypeParameters (unsigned int sym)
    5615                 :             : {
    5616                 :           0 :   NameKey_Name typeName;
    5617                 :           0 :   unsigned int p;
    5618                 :           0 :   unsigned int i;
    5619                 :           0 :   unsigned int n;
    5620                 :           0 :   unsigned int type;
    5621                 :             : 
    5622                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " (", 2);
    5623                 :           0 :   n = SymbolTable_NoOfParam (sym, SymbolTable_ProperProcedure);
    5624                 :           0 :   i = 1;
    5625                 :           0 :   while (i <= n)
    5626                 :             :     {
    5627                 :           0 :       if (i > 1)
    5628                 :             :         {
    5629                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "; ", 2);
    5630                 :             :         }
    5631                 :           0 :       if (SymbolTable_IsVarParam (sym, SymbolTable_ProperProcedure, i))
    5632                 :             :         {
    5633                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "VAR ", 4);
    5634                 :             :         }
    5635                 :           0 :       p = SymbolTable_GetNthParam (sym, SymbolTable_ProperProcedure, i);
    5636                 :           0 :       type = SymbolTable_GetType (p);
    5637                 :           0 :       typeName = SymbolTable_GetSymName (type);
    5638                 :           0 :       if (SymbolTable_IsUnboundedParam (sym, SymbolTable_ProperProcedure, i))
    5639                 :             :         {
    5640                 :           0 :           M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "ARRAY OF %a", 11, (const unsigned char *) &typeName, (sizeof (typeName)-1));
    5641                 :             :         }
    5642                 :             :       else
    5643                 :             :         {
    5644                 :           0 :           M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "%a", 2, (const unsigned char *) &typeName, (sizeof (typeName)-1));
    5645                 :             :         }
    5646                 :           0 :       i += 1;
    5647                 :             :     }
    5648                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) ")", 1);
    5649                 :           0 : }
    5650                 :             : 
    5651                 :             : 
    5652                 :             : /*
    5653                 :             :    PrintProcType -
    5654                 :             : */
    5655                 :             : 
    5656                 :           0 : static void PrintProcType (unsigned int sym)
    5657                 :             : {
    5658                 :           0 :   NameKey_Name n;
    5659                 :             : 
    5660                 :           0 :   n = SymbolTable_GetSymName (sym);
    5661                 :           0 :   M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcType (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5662                 :           0 :   PrintScope (sym);
    5663                 :           0 :   PrintDeclared (sym);
    5664                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "\\n", 2);
    5665                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "parameters ", 11);
    5666                 :           0 :   PrintProcTypeParameters (sym);
    5667                 :           0 :   PrintProcedureReturnType (sym);
    5668                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "\\n", 2);
    5669                 :           0 : }
    5670                 :             : 
    5671                 :             : 
    5672                 :             : /*
    5673                 :             :    PrintString -
    5674                 :             : */
    5675                 :             : 
    5676                 :           0 : static void PrintString (unsigned int sym)
    5677                 :             : {
    5678                 :           0 :   unsigned int len;
    5679                 :           0 :   unsigned int tokenno;
    5680                 :             : 
    5681                 :           0 :   if (SymbolTable_IsConstStringKnown (sym))
    5682                 :             :     {
    5683                 :           0 :       if (SymbolTable_IsConstStringM2 (sym))
    5684                 :             :         {
    5685                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "a Modula-2 string", 17);
    5686                 :             :         }
    5687                 :           0 :       else if (SymbolTable_IsConstStringC (sym))
    5688                 :             :         {
    5689                 :             :           /* avoid dangling else.  */
    5690                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " a C string", 11);
    5691                 :             :         }
    5692                 :           0 :       else if (SymbolTable_IsConstStringM2nul (sym))
    5693                 :             :         {
    5694                 :             :           /* avoid dangling else.  */
    5695                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " a nul terminated Modula-2 string", 33);
    5696                 :             :         }
    5697                 :           0 :       else if (SymbolTable_IsConstStringCnul (sym))
    5698                 :             :         {
    5699                 :             :           /* avoid dangling else.  */
    5700                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " a nul terminated C string", 26);
    5701                 :             :         }
    5702                 :           0 :       tokenno = SymbolTable_GetDeclaredMod (sym);
    5703                 :           0 :       len = SymbolTable_GetStringLength (tokenno, sym);
    5704                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) " length %d", 10, (const unsigned char *) &len, (sizeof (len)-1));
    5705                 :             :     }
    5706                 :             :   else
    5707                 :             :     {
    5708                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "is not currently known", 22);
    5709                 :             :     }
    5710                 :           0 : }
    5711                 :             : 
    5712                 :             : 
    5713                 :             : /*
    5714                 :             :    PrintVerboseFromList - prints the, i, th element in the list, l.
    5715                 :             : */
    5716                 :             : 
    5717                 :           0 : static void PrintVerboseFromList (Lists_List l, unsigned int i)
    5718                 :             : {
    5719                 :           0 :   unsigned int type;
    5720                 :           0 :   unsigned int low;
    5721                 :           0 :   unsigned int high;
    5722                 :           0 :   unsigned int sym;
    5723                 :           0 :   NameKey_Name n;
    5724                 :           0 :   NameKey_Name n2;
    5725                 :             : 
    5726                 :           0 :   sym = static_cast<unsigned int> (Lists_GetItemFromList (l, i));
    5727                 :           0 :   n = SymbolTable_GetSymName (sym);
    5728                 :           0 :   if (SymbolTable_IsError (sym))
    5729                 :             :     {
    5730                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsError (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5731                 :             :     }
    5732                 :           0 :   else if (SymbolTable_IsDefImp (sym))
    5733                 :             :     {
    5734                 :             :       /* avoid dangling else.  */
    5735                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsDefImp (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5736                 :           0 :       if (SymbolTable_IsDefinitionForC (sym))
    5737                 :             :         {
    5738                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "and IsDefinitionForC", 20);
    5739                 :             :         }
    5740                 :           0 :       if (SymbolTable_IsHiddenTypeDeclared (sym))
    5741                 :             :         {
    5742                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsHiddenTypeDeclared", 21);
    5743                 :             :         }
    5744                 :           0 :       SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) PrintProcedure});
    5745                 :             :     }
    5746                 :           0 :   else if (SymbolTable_IsModule (sym))
    5747                 :             :     {
    5748                 :             :       /* avoid dangling else.  */
    5749                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsModule (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5750                 :           0 :       if (SymbolTable_IsModuleWithinProcedure (sym))
    5751                 :             :         {
    5752                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " and IsModuleWithinProcedure", 28);
    5753                 :             :         }
    5754                 :             :     }
    5755                 :           0 :   else if (SymbolTable_IsInnerModule (sym))
    5756                 :             :     {
    5757                 :             :       /* avoid dangling else.  */
    5758                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsInnerModule (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5759                 :             :     }
    5760                 :           0 :   else if (SymbolTable_IsUnknown (sym))
    5761                 :             :     {
    5762                 :             :       /* avoid dangling else.  */
    5763                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsUnknown (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5764                 :             :     }
    5765                 :           0 :   else if (SymbolTable_IsType (sym))
    5766                 :             :     {
    5767                 :             :       /* avoid dangling else.  */
    5768                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsType (%a)", 18, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5769                 :           0 :       IncludeType (l, sym);
    5770                 :           0 :       PrintAlignment (sym);
    5771                 :             :     }
    5772                 :           0 :   else if (SymbolTable_IsProcedure (sym))
    5773                 :             :     {
    5774                 :             :       /* avoid dangling else.  */
    5775                 :           0 :       PrintProcedure (sym);
    5776                 :             :     }
    5777                 :           0 :   else if (SymbolTable_IsParameter (sym))
    5778                 :             :     {
    5779                 :             :       /* avoid dangling else.  */
    5780                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsParameter (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5781                 :           0 :       if ((SymbolTable_GetParameterShadowVar (sym)) == SymbolTable_NulSym)
    5782                 :             :         {
    5783                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " no shadow local variable", 25);
    5784                 :             :         }
    5785                 :             :       else
    5786                 :             :         {
    5787                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " shadow ", 8);
    5788                 :             :           /* PrintVerboseFromList(l, GetParameterShadowVar(sym))  */
    5789                 :           0 :           IncludeType (l, SymbolTable_GetParameterShadowVar (sym));
    5790                 :             :         }
    5791                 :           0 :       IncludeType (l, sym);
    5792                 :             :     }
    5793                 :           0 :   else if (SymbolTable_IsPointer (sym))
    5794                 :             :     {
    5795                 :             :       /* avoid dangling else.  */
    5796                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsPointer (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5797                 :           0 :       IncludeType (l, sym);
    5798                 :           0 :       PrintAlignment (sym);
    5799                 :             :     }
    5800                 :           0 :   else if (SymbolTable_IsRecord (sym))
    5801                 :             :     {
    5802                 :             :       /* avoid dangling else.  */
    5803                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsRecord (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5804                 :           0 :       PrintLocalSymbols (sym);
    5805                 :           0 :       IncludeGetNth (l, sym);
    5806                 :           0 :       PrintAlignment (sym);
    5807                 :           0 :       PrintDecl (sym);
    5808                 :             :     }
    5809                 :           0 :   else if (SymbolTable_IsVarient (sym))
    5810                 :             :     {
    5811                 :             :       /* avoid dangling else.  */
    5812                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVarient (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5813                 :           0 :       PrintDecl (sym);
    5814                 :           0 :       IncludeGetNth (l, sym);
    5815                 :           0 :       IncludeGetVarient (l, sym);
    5816                 :           0 :       IncludeGetParent (l, sym);
    5817                 :             :     }
    5818                 :           0 :   else if (SymbolTable_IsFieldVarient (sym))
    5819                 :             :     {
    5820                 :             :       /* avoid dangling else.  */
    5821                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsFieldVarient (%a)", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5822                 :           0 :       PrintDecl (sym);
    5823                 :           0 :       IncludeGetNth (l, sym);
    5824                 :           0 :       IncludeGetVarient (l, sym);
    5825                 :           0 :       IncludeGetParent (l, sym);
    5826                 :             :     }
    5827                 :           0 :   else if (SymbolTable_IsFieldEnumeration (sym))
    5828                 :             :     {
    5829                 :             :       /* avoid dangling else.  */
    5830                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsFieldEnumeration (%a)", 30, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5831                 :             :     }
    5832                 :           0 :   else if (SymbolTable_IsArray (sym))
    5833                 :             :     {
    5834                 :             :       /* avoid dangling else.  */
    5835                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsArray (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5836                 :           0 :       IncludeSubscript (l, sym);
    5837                 :           0 :       IncludeType (l, sym);
    5838                 :           0 :       PrintAlignment (sym);
    5839                 :             :     }
    5840                 :           0 :   else if (SymbolTable_IsEnumeration (sym))
    5841                 :             :     {
    5842                 :             :       /* avoid dangling else.  */
    5843                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsEnumeration (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5844                 :             :     }
    5845                 :           0 :   else if (SymbolTable_IsSet (sym))
    5846                 :             :     {
    5847                 :             :       /* avoid dangling else.  */
    5848                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSet (%a)", 17, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5849                 :           0 :       IncludeType (l, sym);
    5850                 :             :     }
    5851                 :           0 :   else if (SymbolTable_IsUnbounded (sym))
    5852                 :             :     {
    5853                 :             :       /* avoid dangling else.  */
    5854                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsUnbounded (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5855                 :           0 :       IncludeUnbounded (l, sym);
    5856                 :             :     }
    5857                 :           0 :   else if (SymbolTable_IsPartialUnbounded (sym))
    5858                 :             :     {
    5859                 :             :       /* avoid dangling else.  */
    5860                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsPartialUnbounded (%a)", 30, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5861                 :           0 :       IncludePartialUnbounded (l, sym);
    5862                 :             :     }
    5863                 :           0 :   else if (SymbolTable_IsRecordField (sym))
    5864                 :             :     {
    5865                 :             :       /* avoid dangling else.  */
    5866                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsRecordField (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5867                 :           0 :       if (SymbolTable_IsRecordFieldAVarientTag (sym))
    5868                 :             :         {
    5869                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " variant tag", 12);
    5870                 :             :         }
    5871                 :           0 :       IncludeType (l, sym);
    5872                 :           0 :       IncludeGetVarient (l, sym);
    5873                 :           0 :       IncludeGetParent (l, sym);
    5874                 :           0 :       PrintAlignment (sym);
    5875                 :           0 :       PrintDecl (sym);
    5876                 :             :     }
    5877                 :           0 :   else if (SymbolTable_IsProcType (sym))
    5878                 :             :     {
    5879                 :             :       /* avoid dangling else.  */
    5880                 :           0 :       PrintProcType (sym);
    5881                 :             :     }
    5882                 :           0 :   else if (SymbolTable_IsVar (sym))
    5883                 :             :     {
    5884                 :             :       /* avoid dangling else.  */
    5885                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVar (%a) declared in ", 30, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5886                 :           0 :       PrintScope (sym);
    5887                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "mode ", 5);
    5888                 :           0 :       switch (SymbolTable_GetMode (sym))
    5889                 :             :         {
    5890                 :           0 :           case SymbolTable_LeftValue:
    5891                 :           0 :             M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "l ", 2);
    5892                 :           0 :             break;
    5893                 :             : 
    5894                 :           0 :           case SymbolTable_RightValue:
    5895                 :           0 :             M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "r ", 2);
    5896                 :           0 :             break;
    5897                 :             : 
    5898                 :           0 :           case SymbolTable_ImmediateValue:
    5899                 :           0 :             M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "i ", 2);
    5900                 :           0 :             break;
    5901                 :             : 
    5902                 :           0 :           case SymbolTable_NoValue:
    5903                 :           0 :             M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "n ", 2);
    5904                 :           0 :             break;
    5905                 :             : 
    5906                 :             : 
    5907                 :           0 :           default:
    5908                 :           0 :             CaseException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2GCCDeclare.def", 20, 1);
    5909                 :           0 :             __builtin_unreachable ();
    5910                 :             :         }
    5911                 :           0 :       if (SymbolTable_IsTemporary (sym))
    5912                 :             :         {
    5913                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "temporary ", 10);
    5914                 :             :         }
    5915                 :           0 :       if (SymbolTable_IsComponent (sym))
    5916                 :             :         {
    5917                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "component ", 10);
    5918                 :             :         }
    5919                 :           0 :       if (SymbolTable_IsVarHeap (sym))
    5920                 :             :         {
    5921                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "heap ", 5);
    5922                 :             :         }
    5923                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "\\n", 2);
    5924                 :           0 :       SymbolTable_PrintInitialized (sym);
    5925                 :           0 :       IncludeType (l, sym);
    5926                 :             :     }
    5927                 :           0 :   else if (SymbolTable_IsConst (sym))
    5928                 :             :     {
    5929                 :             :       /* avoid dangling else.  */
    5930                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConst (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5931                 :           0 :       if (SymbolTable_IsConstString (sym))
    5932                 :             :         {
    5933                 :           0 :           M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "  also IsConstString (%a)", 25, (const unsigned char *) &n, (sizeof (n)-1));
    5934                 :           0 :           PrintString (sym);
    5935                 :             :         }
    5936                 :           0 :       else if (SymbolTable_IsConstructor (sym))
    5937                 :             :         {
    5938                 :             :           /* avoid dangling else.  */
    5939                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " constant constructor ", 22);
    5940                 :           0 :           IncludeType (l, sym);
    5941                 :             :         }
    5942                 :           0 :       else if (SymbolTable_IsConstSet (sym))
    5943                 :             :         {
    5944                 :             :           /* avoid dangling else.  */
    5945                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " constant constructor set ", 26);
    5946                 :           0 :           IncludeType (l, sym);
    5947                 :             :         }
    5948                 :             :       else
    5949                 :             :         {
    5950                 :             :           /* avoid dangling else.  */
    5951                 :           0 :           IncludeType (l, sym);
    5952                 :             :         }
    5953                 :             :     }
    5954                 :           0 :   else if (SymbolTable_IsConstructor (sym))
    5955                 :             :     {
    5956                 :             :       /* avoid dangling else.  */
    5957                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConstructor (non constant) (%a)", 40, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5958                 :           0 :       IncludeType (l, sym);
    5959                 :             :     }
    5960                 :           0 :   else if (SymbolTable_IsConstLit (sym))
    5961                 :             :     {
    5962                 :             :       /* avoid dangling else.  */
    5963                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConstLit (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5964                 :             :     }
    5965                 :           0 :   else if (SymbolTable_IsDummy (sym))
    5966                 :             :     {
    5967                 :             :       /* avoid dangling else.  */
    5968                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsDummy (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5969                 :             :     }
    5970                 :           0 :   else if (SymbolTable_IsTemporary (sym))
    5971                 :             :     {
    5972                 :             :       /* avoid dangling else.  */
    5973                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsTemporary (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5974                 :             :     }
    5975                 :           0 :   else if (SymbolTable_IsVarAParam (sym))
    5976                 :             :     {
    5977                 :             :       /* avoid dangling else.  */
    5978                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVarAParam (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5979                 :             :     }
    5980                 :           0 :   else if (SymbolTable_IsSubscript (sym))
    5981                 :             :     {
    5982                 :             :       /* avoid dangling else.  */
    5983                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSubscript (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5984                 :             :     }
    5985                 :           0 :   else if (SymbolTable_IsSubrange (sym))
    5986                 :             :     {
    5987                 :             :       /* avoid dangling else.  */
    5988                 :           0 :       SymbolTable_GetSubrange (sym, &high, &low);
    5989                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSubrange (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    5990                 :           0 :       if ((low != SymbolTable_NulSym) && (high != SymbolTable_NulSym))
    5991                 :             :         {
    5992                 :           0 :           type = SymbolTable_GetSType (sym);
    5993                 :           0 :           if (type != SymbolTable_NulSym)
    5994                 :             :             {
    5995                 :           0 :               IncludeType (l, sym);
    5996                 :           0 :               n = SymbolTable_GetSymName (type);
    5997                 :           0 :               M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) " %a", 3, (const unsigned char *) &n, (sizeof (n)-1));
    5998                 :             :             }
    5999                 :           0 :           n = SymbolTable_GetSymName (low);
    6000                 :           0 :           n2 = SymbolTable_GetSymName (high);
    6001                 :           0 :           M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "[%a..%a]", 8, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &n2, (sizeof (n2)-1));
    6002                 :             :         }
    6003                 :             :     }
    6004                 :           0 :   else if (SymbolTable_IsProcedureVariable (sym))
    6005                 :             :     {
    6006                 :             :       /* avoid dangling else.  */
    6007                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedureVariable (%a)", 31, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6008                 :             :     }
    6009                 :           0 :   else if (SymbolTable_IsProcedureNested (sym))
    6010                 :             :     {
    6011                 :             :       /* avoid dangling else.  */
    6012                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedureNested (%a)", 29, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6013                 :             :     }
    6014                 :           0 :   else if (SymbolTable_IsAModula2Type (sym))
    6015                 :             :     {
    6016                 :             :       /* avoid dangling else.  */
    6017                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsAModula2Type (%a)", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6018                 :             :     }
    6019                 :           0 :   else if (SymbolTable_IsObject (sym))
    6020                 :             :     {
    6021                 :             :       /* avoid dangling else.  */
    6022                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsObject (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6023                 :             :     }
    6024                 :           0 :   else if (SymbolTable_IsTuple (sym))
    6025                 :             :     {
    6026                 :             :       /* avoid dangling else.  */
    6027                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsTuple (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6028                 :           0 :       low = SymbolTable_GetNth (sym, 1);
    6029                 :           0 :       high = SymbolTable_GetNth (sym, 2);
    6030                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "%d, %d\\n", 8, (const unsigned char *) &low, (sizeof (low)-1), (const unsigned char *) &high, (sizeof (high)-1));
    6031                 :             :     }
    6032                 :           0 :   else if (SymbolTable_IsGnuAsm (sym))
    6033                 :             :     {
    6034                 :             :       /* avoid dangling else.  */
    6035                 :           0 :       if (SymbolTable_IsGnuAsmVolatile (sym))
    6036                 :             :         {
    6037                 :           0 :           M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsGnuAsmVolatile (%a)", 28, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6038                 :             :         }
    6039                 :             :       else
    6040                 :             :         {
    6041                 :           0 :           M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsGnuAsm (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6042                 :             :         }
    6043                 :             :     }
    6044                 :           0 :   else if (SymbolTable_IsComponent (sym))
    6045                 :             :     {
    6046                 :             :       /* avoid dangling else.  */
    6047                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsComponent (%a) ", 24, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6048                 :           0 :       i = 1;
    6049                 :           0 :       do {
    6050                 :           0 :         type = SymbolTable_GetNth (sym, i);
    6051                 :           0 :         if (type != SymbolTable_NulSym)
    6052                 :             :           {
    6053                 :           0 :             Lists_IncludeItemIntoList (l, type);
    6054                 :           0 :             n = SymbolTable_GetSymName (type);
    6055                 :           0 :             M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "[%a %d] ", 8, (const unsigned char *) &n, (sizeof (n)-1), (const unsigned char *) &type, (sizeof (type)-1));
    6056                 :           0 :             i += 1;
    6057                 :             :           }
    6058                 :           0 :       } while (! (type == SymbolTable_NulSym));
    6059                 :             :     }
    6060                 :           0 :   if (SymbolTable_IsHiddenType (sym))
    6061                 :             :     {
    6062                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsHiddenType", 13);
    6063                 :             :     }
    6064                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "\\n", 2);
    6065                 :           0 : }
    6066                 :             : 
    6067                 :             : 
    6068                 :             : /*
    6069                 :             :    PrintVerbose - prints limited information about a symbol.
    6070                 :             : */
    6071                 :             : 
    6072                 :           0 : static void PrintVerbose (unsigned int sym)
    6073                 :             : {
    6074                 :           0 :   Lists_List l;
    6075                 :           0 :   unsigned int i;
    6076                 :             : 
    6077                 :           0 :   Lists_InitList (&l);
    6078                 :           0 :   Lists_IncludeItemIntoList (l, sym);
    6079                 :           0 :   i = 1;
    6080                 :           0 :   while (i <= (Lists_NoOfItemsInList (l)))
    6081                 :             :     {
    6082                 :           0 :       PrintVerboseFromList (l, i);
    6083                 :           0 :       i += 1;
    6084                 :             :     }
    6085                 :           0 :   Lists_KillList (&l);
    6086                 :           0 : }
    6087                 :             : 
    6088                 :             : 
    6089                 :             : /*
    6090                 :             :    PrintTerse -
    6091                 :             : */
    6092                 :             : 
    6093                 :           0 : static void PrintTerse (unsigned int sym)
    6094                 :             : {
    6095                 :           0 :   NameKey_Name n;
    6096                 :             : 
    6097                 :           0 :   n = SymbolTable_GetSymName (sym);
    6098                 :           0 :   if (SymbolTable_IsError (sym))
    6099                 :             :     {
    6100                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsError (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6101                 :             :     }
    6102                 :           0 :   else if (SymbolTable_IsDefImp (sym))
    6103                 :             :     {
    6104                 :             :       /* avoid dangling else.  */
    6105                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsDefImp (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6106                 :           0 :       if (SymbolTable_IsDefinitionForC (sym))
    6107                 :             :         {
    6108                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "and IsDefinitionForC", 20);
    6109                 :             :         }
    6110                 :           0 :       if (SymbolTable_IsHiddenTypeDeclared (sym))
    6111                 :             :         {
    6112                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsHiddenTypeDeclared", 21);
    6113                 :             :         }
    6114                 :             :     }
    6115                 :           0 :   else if (SymbolTable_IsModule (sym))
    6116                 :             :     {
    6117                 :             :       /* avoid dangling else.  */
    6118                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsModule (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6119                 :           0 :       if (SymbolTable_IsModuleWithinProcedure (sym))
    6120                 :             :         {
    6121                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " and IsModuleWithinProcedure", 28);
    6122                 :             :         }
    6123                 :             :     }
    6124                 :           0 :   else if (SymbolTable_IsInnerModule (sym))
    6125                 :             :     {
    6126                 :             :       /* avoid dangling else.  */
    6127                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsInnerModule (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6128                 :             :     }
    6129                 :           0 :   else if (SymbolTable_IsUnknown (sym))
    6130                 :             :     {
    6131                 :             :       /* avoid dangling else.  */
    6132                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsUnknown (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6133                 :             :     }
    6134                 :           0 :   else if (SymbolTable_IsType (sym))
    6135                 :             :     {
    6136                 :             :       /* avoid dangling else.  */
    6137                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsType (%a)", 18, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6138                 :             :     }
    6139                 :           0 :   else if (SymbolTable_IsProcedure (sym))
    6140                 :             :     {
    6141                 :             :       /* avoid dangling else.  */
    6142                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedure (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6143                 :           0 :       if (SymbolTable_IsProcedureReachable (sym))
    6144                 :             :         {
    6145                 :           0 :           M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " and IsProcedureReachable", 25);
    6146                 :             :         }
    6147                 :             :     }
    6148                 :           0 :   else if (SymbolTable_IsParameter (sym))
    6149                 :             :     {
    6150                 :             :       /* avoid dangling else.  */
    6151                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsParameter (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6152                 :             :     }
    6153                 :           0 :   else if (SymbolTable_IsPointer (sym))
    6154                 :             :     {
    6155                 :             :       /* avoid dangling else.  */
    6156                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsPointer (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6157                 :             :     }
    6158                 :           0 :   else if (SymbolTable_IsRecord (sym))
    6159                 :             :     {
    6160                 :             :       /* avoid dangling else.  */
    6161                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsRecord (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6162                 :             :     }
    6163                 :           0 :   else if (SymbolTable_IsVarient (sym))
    6164                 :             :     {
    6165                 :             :       /* avoid dangling else.  */
    6166                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVarient (%a)", 21, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6167                 :             :     }
    6168                 :           0 :   else if (SymbolTable_IsFieldVarient (sym))
    6169                 :             :     {
    6170                 :             :       /* avoid dangling else.  */
    6171                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsFieldVarient (%a)", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6172                 :             :     }
    6173                 :           0 :   else if (SymbolTable_IsFieldEnumeration (sym))
    6174                 :             :     {
    6175                 :             :       /* avoid dangling else.  */
    6176                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsFieldEnumeration (%a)", 30, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6177                 :             :     }
    6178                 :           0 :   else if (SymbolTable_IsArray (sym))
    6179                 :             :     {
    6180                 :             :       /* avoid dangling else.  */
    6181                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsArray (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6182                 :             :     }
    6183                 :           0 :   else if (SymbolTable_IsEnumeration (sym))
    6184                 :             :     {
    6185                 :             :       /* avoid dangling else.  */
    6186                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsEnumeration (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6187                 :             :     }
    6188                 :           0 :   else if (SymbolTable_IsSet (sym))
    6189                 :             :     {
    6190                 :             :       /* avoid dangling else.  */
    6191                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSet (%a)", 17, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6192                 :             :     }
    6193                 :           0 :   else if (SymbolTable_IsUnbounded (sym))
    6194                 :             :     {
    6195                 :             :       /* avoid dangling else.  */
    6196                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsUnbounded (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6197                 :             :     }
    6198                 :           0 :   else if (SymbolTable_IsRecordField (sym))
    6199                 :             :     {
    6200                 :             :       /* avoid dangling else.  */
    6201                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsRecordField (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6202                 :             :     }
    6203                 :           0 :   else if (SymbolTable_IsProcType (sym))
    6204                 :             :     {
    6205                 :             :       /* avoid dangling else.  */
    6206                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcType (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6207                 :             :     }
    6208                 :           0 :   else if (SymbolTable_IsVar (sym))
    6209                 :             :     {
    6210                 :             :       /* avoid dangling else.  */
    6211                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVar (%a)", 17, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6212                 :             :     }
    6213                 :           0 :   else if (SymbolTable_IsConstString (sym))
    6214                 :             :     {
    6215                 :             :       /* avoid dangling else.  */
    6216                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConstString (%a)", 25, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6217                 :             :     }
    6218                 :           0 :   else if (SymbolTable_IsConst (sym))
    6219                 :             :     {
    6220                 :             :       /* avoid dangling else.  */
    6221                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConst (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6222                 :             :     }
    6223                 :           0 :   else if (SymbolTable_IsConstLit (sym))
    6224                 :             :     {
    6225                 :             :       /* avoid dangling else.  */
    6226                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsConstLit (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6227                 :             :     }
    6228                 :           0 :   else if (SymbolTable_IsDummy (sym))
    6229                 :             :     {
    6230                 :             :       /* avoid dangling else.  */
    6231                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsDummy (%a)", 19, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6232                 :             :     }
    6233                 :           0 :   else if (SymbolTable_IsTemporary (sym))
    6234                 :             :     {
    6235                 :             :       /* avoid dangling else.  */
    6236                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsTemporary (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6237                 :             :     }
    6238                 :           0 :   else if (SymbolTable_IsVarAParam (sym))
    6239                 :             :     {
    6240                 :             :       /* avoid dangling else.  */
    6241                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsVarAParam (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6242                 :             :     }
    6243                 :           0 :   else if (SymbolTable_IsSubscript (sym))
    6244                 :             :     {
    6245                 :             :       /* avoid dangling else.  */
    6246                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSubscript (%a)", 23, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6247                 :             :     }
    6248                 :           0 :   else if (SymbolTable_IsSubrange (sym))
    6249                 :             :     {
    6250                 :             :       /* avoid dangling else.  */
    6251                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsSubrange (%a)", 22, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6252                 :             :     }
    6253                 :           0 :   else if (SymbolTable_IsProcedureVariable (sym))
    6254                 :             :     {
    6255                 :             :       /* avoid dangling else.  */
    6256                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedureVariable (%a)", 31, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6257                 :             :     }
    6258                 :           0 :   else if (SymbolTable_IsProcedureNested (sym))
    6259                 :             :     {
    6260                 :             :       /* avoid dangling else.  */
    6261                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsProcedureNested (%a)", 29, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6262                 :             :     }
    6263                 :           0 :   else if (SymbolTable_IsAModula2Type (sym))
    6264                 :             :     {
    6265                 :             :       /* avoid dangling else.  */
    6266                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsAModula2Type (%a)", 26, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6267                 :             :     }
    6268                 :           0 :   else if (SymbolTable_IsGnuAsm (sym))
    6269                 :             :     {
    6270                 :             :       /* avoid dangling else.  */
    6271                 :           0 :       M2Printf_fprintf2 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsGnuAsm (%a)", 20, (const unsigned char *) &sym, (sizeof (sym)-1), (const unsigned char *) &n, (sizeof (n)-1));
    6272                 :             :     }
    6273                 :           0 :   else if (SymbolTable_IsImport (sym))
    6274                 :             :     {
    6275                 :             :       /* avoid dangling else.  */
    6276                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsImport", 15, (const unsigned char *) &sym, (sizeof (sym)-1));
    6277                 :             :     }
    6278                 :           0 :   else if (SymbolTable_IsImportStatement (sym))
    6279                 :             :     {
    6280                 :             :       /* avoid dangling else.  */
    6281                 :           0 :       M2Printf_fprintf1 (M2LangDump_GetDumpFile (), (const char *) "sym %d IsImportStatement", 24, (const unsigned char *) &sym, (sizeof (sym)-1));
    6282                 :             :     }
    6283                 :           0 :   if (SymbolTable_IsHiddenType (sym))
    6284                 :             :     {
    6285                 :           0 :       M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) " IsHiddenType", 13);
    6286                 :             :     }
    6287                 :           0 : }
    6288                 :             : 
    6289                 :             : 
    6290                 :             : /*
    6291                 :             :    CheckAlignment -
    6292                 :             : */
    6293                 :             : 
    6294                 :      901916 : static tree CheckAlignment (tree type, unsigned int sym)
    6295                 :             : {
    6296                 :      901916 :   unsigned int align;
    6297                 :             : 
    6298                 :      901916 :   align = SymbolTable_GetAlignment (sym);
    6299                 :      901916 :   if (align != SymbolTable_NulSym)
    6300                 :             :     {
    6301                 :         192 :       M2ALU_PushInt (0);
    6302                 :         192 :       SymbolTable_PushValue (align);
    6303                 :         192 :       if (! (M2ALU_Equ (SymbolTable_GetDeclaredMod (sym))))
    6304                 :             :         {
    6305                 :          84 :           return m2type_SetAlignment (type, SymbolConversion_Mod2Gcc (SymbolTable_GetAlignment (sym)));
    6306                 :             :         }
    6307                 :             :     }
    6308                 :             :   return type;
    6309                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6310                 :             :   __builtin_unreachable ();
    6311                 :             : }
    6312                 :             : 
    6313                 :             : 
    6314                 :             : /*
    6315                 :             :    CheckPragma -
    6316                 :             : */
    6317                 :             : 
    6318                 :      406955 : static tree CheckPragma (tree type, unsigned int sym)
    6319                 :             : {
    6320                 :      406955 :   if (SymbolTable_IsDeclaredPacked (sym))
    6321                 :             :     {
    6322                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    6323                 :         144 :       if ((SymbolTable_IsRecordField (sym)) || (SymbolTable_IsFieldVarient (sym)))
    6324                 :             :         {
    6325                 :         108 :           type = m2type_SetDeclPacked (type);
    6326                 :             :         }
    6327                 :          36 :       else if ((SymbolTable_IsRecord (sym)) || (SymbolTable_IsVarient (sym)))
    6328                 :             :         {
    6329                 :             :           /* avoid dangling else.  */
    6330                 :          36 :           type = m2type_SetTypePacked (type);
    6331                 :             :         }
    6332                 :             :     }
    6333                 :      406955 :   return CheckAlignment (type, sym);
    6334                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6335                 :             :   __builtin_unreachable ();
    6336                 :             : }
    6337                 :             : 
    6338                 :             : 
    6339                 :             : /*
    6340                 :             :    IsZero - returns TRUE if symbol, sym, is zero.
    6341                 :             : */
    6342                 :             : 
    6343                 :          36 : static bool IsZero (unsigned int sym)
    6344                 :             : {
    6345                 :          36 :   M2ALU_PushIntegerTree (SymbolConversion_Mod2Gcc (sym));
    6346                 :          36 :   M2ALU_PushInt (0);
    6347                 :          36 :   return M2ALU_Equ (SymbolTable_GetDeclaredMod (sym));
    6348                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6349                 :             :   __builtin_unreachable ();
    6350                 :             : }
    6351                 :             : 
    6352                 :             : 
    6353                 :             : /*
    6354                 :             :    SetFieldPacked - sets Varient, VarientField and RecordField symbols
    6355                 :             :                     as packed.
    6356                 :             : */
    6357                 :             : 
    6358                 :         360 : static void SetFieldPacked (unsigned int field)
    6359                 :             : {
    6360                 :         360 :   if (((SymbolTable_IsVarient (field)) || (SymbolTable_IsFieldVarient (field))) || (SymbolTable_IsRecordField (field)))
    6361                 :             :     {
    6362                 :         108 :       SymbolTable_PutDeclaredPacked (field, true);
    6363                 :             :     }
    6364                 :         360 : }
    6365                 :             : 
    6366                 :             : 
    6367                 :             : /*
    6368                 :             :    RecordPacked - indicates that record, sym, and its fields
    6369                 :             :                   are all packed.
    6370                 :             : */
    6371                 :             : 
    6372                 :          36 : static void RecordPacked (unsigned int sym)
    6373                 :             : {
    6374                 :          36 :   SymbolTable_PutDeclaredPacked (sym, true);
    6375                 :          36 :   WalkRecordDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) SetFieldPacked});
    6376                 :          36 : }
    6377                 :             : 
    6378                 :             : 
    6379                 :             : /*
    6380                 :             :    SetFieldNotPacked - sets Varient, VarientField and RecordField symbols
    6381                 :             :                        as not packed.
    6382                 :             : */
    6383                 :             : 
    6384                 :      651028 : static void SetFieldNotPacked (unsigned int field)
    6385                 :             : {
    6386                 :      651028 :   if (((SymbolTable_IsVarient (field)) || (SymbolTable_IsFieldVarient (field))) || (SymbolTable_IsRecordField (field)))
    6387                 :             :     {
    6388                 :      326060 :       SymbolTable_PutDeclaredPacked (field, false);
    6389                 :             :     }
    6390                 :      651028 : }
    6391                 :             : 
    6392                 :             : 
    6393                 :             : /*
    6394                 :             :    RecordNotPacked - indicates that record, sym, and its fields
    6395                 :             :                      are all not packed.
    6396                 :             : */
    6397                 :             : 
    6398                 :       81771 : static void RecordNotPacked (unsigned int sym)
    6399                 :             : {
    6400                 :       81771 :   SymbolTable_PutDeclaredPacked (sym, false);
    6401                 :       81771 :   WalkRecordDependants (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) SetFieldNotPacked});
    6402                 :       81771 : }
    6403                 :             : 
    6404                 :             : 
    6405                 :             : /*
    6406                 :             :    DetermineIfRecordPacked -
    6407                 :             : */
    6408                 :             : 
    6409                 :       81807 : static void DetermineIfRecordPacked (unsigned int sym)
    6410                 :             : {
    6411                 :       81807 :   unsigned int defaultAlignment;
    6412                 :             : 
    6413                 :       81807 :   defaultAlignment = SymbolTable_GetDefaultRecordFieldAlignment (sym);
    6414                 :       81807 :   if ((defaultAlignment != SymbolTable_NulSym) && (IsZero (defaultAlignment)))
    6415                 :             :     {
    6416                 :          36 :       RecordPacked (sym);
    6417                 :             :     }
    6418                 :             :   else
    6419                 :             :     {
    6420                 :       81771 :       RecordNotPacked (sym);
    6421                 :             :     }
    6422                 :       81807 : }
    6423                 :             : 
    6424                 :             : 
    6425                 :             : /*
    6426                 :             :    DeclarePackedSubrange -
    6427                 :             : */
    6428                 :             : 
    6429                 :          60 : static void DeclarePackedSubrange (unsigned int equiv, unsigned int sym)
    6430                 :             : {
    6431                 :          60 :   tree type;
    6432                 :          60 :   tree gccsym;
    6433                 :          60 :   unsigned int high;
    6434                 :          60 :   unsigned int low;
    6435                 :          60 :   location_t location;
    6436                 :             : 
    6437                 :          60 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    6438                 :          60 :   SymbolTable_GetSubrange (sym, &high, &low);
    6439                 :          60 :   type = m2type_BuildSmallestTypeRange (location, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
    6440                 :          60 :   gccsym = m2type_BuildSubrangeType (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym))), type, SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high));
    6441                 :          60 :   SymbolConversion_AddModGcc (equiv, gccsym);
    6442                 :          60 : }
    6443                 :             : 
    6444                 :             : 
    6445                 :             : /*
    6446                 :             :    DeclarePackedSet -
    6447                 :             : */
    6448                 :             : 
    6449                 :           0 : static void DeclarePackedSet (unsigned int equiv, unsigned int sym)
    6450                 :             : {
    6451                 :           0 :   tree highLimit;
    6452                 :           0 :   tree range;
    6453                 :           0 :   tree gccsym;
    6454                 :           0 :   unsigned int type;
    6455                 :           0 :   unsigned int high;
    6456                 :           0 :   unsigned int low;
    6457                 :           0 :   location_t location;
    6458                 :             : 
    6459                 :           0 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    6460                 :           0 :   M2Debug_Assert (SymbolTable_IsSet (sym));
    6461                 :           0 :   type = SymbolTable_GetDType (sym);
    6462                 :           0 :   low = M2GCCDeclare_GetTypeMin (type);
    6463                 :           0 :   high = M2GCCDeclare_GetTypeMax (type);
    6464                 :           0 :   highLimit = m2expr_BuildSub (location, SymbolConversion_Mod2Gcc (high), SymbolConversion_Mod2Gcc (low), false);
    6465                 :             :   /* --fixme-- we need to check that low <= WORDLENGTH.  */
    6466                 :           0 :   highLimit = m2expr_BuildLSL (location, m2expr_GetIntegerOne (location), highLimit, false);
    6467                 :           0 :   range = m2type_BuildSmallestTypeRange (location, m2expr_GetIntegerZero (location), highLimit);
    6468                 :           0 :   gccsym = m2type_BuildSubrangeType (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym))), range, m2expr_GetIntegerZero (location), highLimit);
    6469                 :           0 :   SymbolConversion_AddModGcc (equiv, gccsym);
    6470                 :           0 : }
    6471                 :             : 
    6472                 :         120 : static void DeclarePackedFieldEnumeration (unsigned int sym)
    6473                 :             : {
    6474                 :         120 :   unsigned int equiv;
    6475                 :         120 :   unsigned int type;
    6476                 :         120 :   tree field;
    6477                 :         120 :   tree enumlist;
    6478                 :             : 
    6479                 :             :   /* add relationship between gccSym and sym  */
    6480                 :         120 :   type = SymbolTable_GetSType (sym);
    6481                 :         120 :   equiv = SymbolTable_GetPackedEquivalent (type);
    6482                 :         120 :   enumlist = GetEnumList (equiv);
    6483                 :         120 :   SymbolTable_PushValue (sym);
    6484                 :         120 :   field = DeclareFieldValue (sym, M2ALU_PopIntegerTree (), &enumlist);
    6485                 :         120 :   M2Debug_Assert (field != NULL);
    6486                 :         120 :   PutEnumList (equiv, enumlist);
    6487                 :         120 : }
    6488                 :             : 
    6489                 :             : 
    6490                 :             : /*
    6491                 :             :    DeclarePackedEnumeration -
    6492                 :             : */
    6493                 :             : 
    6494                 :          36 : static void DeclarePackedEnumeration (unsigned int equiv, unsigned int sym)
    6495                 :             : {
    6496                 :          36 :   tree enumlist;
    6497                 :          36 :   tree gccenum;
    6498                 :          36 :   location_t location;
    6499                 :             : 
    6500                 :          36 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    6501                 :          36 :   gccenum = m2type_BuildStartEnumeration (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym))), true);
    6502                 :          36 :   SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DeclarePackedFieldEnumeration});
    6503                 :          36 :   enumlist = GetEnumList (equiv);
    6504                 :          36 :   gccenum = m2type_BuildEndEnumeration (location, gccenum, enumlist);
    6505                 :          36 :   SymbolConversion_AddModGcc (equiv, gccenum);
    6506                 :          36 : }
    6507                 :             : 
    6508                 :             : 
    6509                 :             : /*
    6510                 :             :    DeclarePackedType -
    6511                 :             : */
    6512                 :             : 
    6513                 :           0 : static void DeclarePackedType (unsigned int equiv, unsigned int sym)
    6514                 :             : {
    6515                 :           0 :   unsigned int type;
    6516                 :             : 
    6517                 :           0 :   type = SymbolTable_GetSType (sym);
    6518                 :           0 :   if (type == SymbolTable_NulSym)
    6519                 :             :     {
    6520                 :           0 :       if (sym == M2Base_Boolean)
    6521                 :             :         {
    6522                 :           0 :           SymbolConversion_AddModGcc (equiv, m2type_GetPackedBooleanType ());
    6523                 :             :         }
    6524                 :             :       else
    6525                 :             :         {
    6526                 :           0 :           SymbolConversion_AddModGcc (equiv, SymbolConversion_Mod2Gcc (sym));
    6527                 :             :         }
    6528                 :             :     }
    6529                 :             :   else
    6530                 :             :     {
    6531                 :           0 :       DeclarePackedType (SymbolTable_GetPackedEquivalent (type), type);
    6532                 :           0 :       SymbolConversion_AddModGcc (equiv, SymbolConversion_Mod2Gcc (SymbolTable_GetPackedEquivalent (type)));
    6533                 :             :     }
    6534                 :           0 : }
    6535                 :             : 
    6536                 :             : 
    6537                 :             : /*
    6538                 :             :    doDeclareEquivalent -
    6539                 :             : */
    6540                 :             : 
    6541                 :         216 : static tree doDeclareEquivalent (unsigned int sym, M2GCCDeclare_doDeclareProcedure p)
    6542                 :             : {
    6543                 :         216 :   unsigned int equiv;
    6544                 :             : 
    6545                 :         216 :   equiv = SymbolTable_GetPackedEquivalent (sym);
    6546                 :         216 :   if (! (SymbolConversion_GccKnowsAbout (equiv)))
    6547                 :             :     {
    6548                 :          96 :       (*p.proc) (equiv, sym);
    6549                 :          96 :       Sets_IncludeElementIntoSet (GlobalGroup->FullyDeclared, equiv);
    6550                 :             :     }
    6551                 :         216 :   return SymbolConversion_Mod2Gcc (equiv);
    6552                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6553                 :             :   __builtin_unreachable ();
    6554                 :             : }
    6555                 :             : 
    6556                 :             : 
    6557                 :             : /*
    6558                 :             :    PossiblyPacked -
    6559                 :             : */
    6560                 :             : 
    6561                 :      325148 : static tree PossiblyPacked (unsigned int sym, bool isPacked)
    6562                 :             : {
    6563                 :      325148 :   if (isPacked)
    6564                 :             :     {
    6565                 :             :       /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    6566                 :         108 :       if (SymbolTable_IsSubrange (sym))
    6567                 :             :         {
    6568                 :          60 :           return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedSubrange});
    6569                 :             :         }
    6570                 :          48 :       else if (SymbolTable_IsType (sym))
    6571                 :             :         {
    6572                 :             :           /* avoid dangling else.  */
    6573                 :           0 :           return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedType});
    6574                 :             :         }
    6575                 :          48 :       else if (SymbolTable_IsEnumeration (sym))
    6576                 :             :         {
    6577                 :             :           /* avoid dangling else.  */
    6578                 :          48 :           return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedEnumeration});
    6579                 :             :         }
    6580                 :           0 :       else if (SymbolTable_IsSet (sym))
    6581                 :             :         {
    6582                 :             :           /* avoid dangling else.  */
    6583                 :           0 :           return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedSet});
    6584                 :             :         }
    6585                 :             :     }
    6586                 :      325040 :   return SymbolConversion_Mod2Gcc (sym);
    6587                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6588                 :             :   __builtin_unreachable ();
    6589                 :             : }
    6590                 :             : 
    6591                 :             : 
    6592                 :             : /*
    6593                 :             :    GetPackedType - returns a possibly packed type for field.
    6594                 :             : */
    6595                 :             : 
    6596                 :         108 : static tree GetPackedType (unsigned int sym)
    6597                 :             : {
    6598                 :         108 :   if (SymbolTable_IsSubrange (sym))
    6599                 :             :     {
    6600                 :          60 :       return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedSubrange});
    6601                 :             :     }
    6602                 :          48 :   else if (SymbolTable_IsType (sym))
    6603                 :             :     {
    6604                 :             :       /* avoid dangling else.  */
    6605                 :           0 :       return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedType});
    6606                 :             :     }
    6607                 :          48 :   else if (SymbolTable_IsEnumeration (sym))
    6608                 :             :     {
    6609                 :             :       /* avoid dangling else.  */
    6610                 :          48 :       return doDeclareEquivalent (sym, (M2GCCDeclare_doDeclareProcedure) {(M2GCCDeclare_doDeclareProcedure_t) DeclarePackedEnumeration});
    6611                 :             :     }
    6612                 :           0 :   return SymbolConversion_Mod2Gcc (sym);
    6613                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6614                 :             :   __builtin_unreachable ();
    6615                 :             : }
    6616                 :             : 
    6617                 :             : 
    6618                 :             : /*
    6619                 :             :    MaybeAlignField - checks to see whether, field, is packed or aligned and it updates
    6620                 :             :                      the offsets if appropriate.
    6621                 :             : */
    6622                 :             : 
    6623                 :      325820 : static tree MaybeAlignField (unsigned int field, tree *byteOffset, tree *bitOffset)
    6624                 :             : {
    6625                 :      325820 :   tree f;
    6626                 :      325820 :   tree ftype;
    6627                 :      325820 :   tree nbits;
    6628                 :      325820 :   location_t location;
    6629                 :             : 
    6630                 :      325820 :   f = SymbolConversion_Mod2Gcc (field);
    6631                 :      325820 :   if (SymbolTable_IsDeclaredPacked (field))
    6632                 :             :     {
    6633                 :         108 :       location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (field));
    6634                 :         108 :       f = m2type_SetDeclPacked (f);
    6635                 :         108 :       ftype = GetPackedType (SymbolTable_GetSType (field));
    6636                 :         108 :       nbits = m2expr_BuildTBitSize (location, ftype);
    6637                 :         108 :       f = m2type_SetRecordFieldOffset (f, (*byteOffset), (*bitOffset), ftype, nbits);
    6638                 :         108 :       (*bitOffset) = m2expr_BuildAdd (location, (*bitOffset), nbits, false);
    6639                 :         108 :       return f;
    6640                 :             :     }
    6641                 :             :   else
    6642                 :             :     {
    6643                 :      325712 :       return CheckAlignment (f, field);
    6644                 :             :     }
    6645                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6646                 :             :   __builtin_unreachable ();
    6647                 :             : }
    6648                 :             : 
    6649                 :             : 
    6650                 :             : /*
    6651                 :             :    DeclareRecord - declares a record and its fields to gcc.
    6652                 :             :                    The final gcc record type is returned.
    6653                 :             : */
    6654                 :             : 
    6655                 :       81807 : static tree DeclareRecord (unsigned int Sym)
    6656                 :             : {
    6657                 :       81807 :   unsigned int Field;
    6658                 :       81807 :   unsigned int i;
    6659                 :       81807 :   tree nbits;
    6660                 :       81807 :   tree ftype;
    6661                 :       81807 :   tree field;
    6662                 :       81807 :   tree byteOffset;
    6663                 :       81807 :   tree bitOffset;
    6664                 :       81807 :   tree FieldList;
    6665                 :       81807 :   tree RecordType;
    6666                 :       81807 :   location_t location;
    6667                 :             : 
    6668                 :       81807 :   i = 1;
    6669                 :       81807 :   FieldList = (tree) (NULL);
    6670                 :       81807 :   RecordType = DoStartDeclaration (Sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartRecord});
    6671                 :       81807 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Sym));
    6672                 :       81807 :   byteOffset = m2expr_GetIntegerZero (location);
    6673                 :       81807 :   bitOffset = m2expr_GetIntegerZero (location);
    6674                 :      406529 :   do {
    6675                 :      406529 :     Field = SymbolTable_GetNth (Sym, i);
    6676                 :      406529 :     if (Field != SymbolTable_NulSym)
    6677                 :             :       {
    6678                 :             :         /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    6679                 :      324722 :         if (((SymbolTable_IsRecordField (Field)) && (SymbolTable_IsRecordFieldAVarientTag (Field))) && ((SymbolTable_GetSymName (Field)) == NameKey_NulName))
    6680                 :             :           {}  /* empty.  */
    6681                 :             :         /* do not include a nameless tag into the C struct  */
    6682                 :      324692 :         else if (SymbolTable_IsVarient (Field))
    6683                 :             :           {
    6684                 :             :             /* avoid dangling else.  */
    6685                 :         240 :             Field = Chained (Field);
    6686                 :         240 :             field = SymbolConversion_Mod2Gcc (Field);
    6687                 :         240 :             if (SymbolTable_IsDeclaredPacked (Field))
    6688                 :             :               {
    6689                 :           0 :                 location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Field));
    6690                 :           0 :                 field = m2type_SetDeclPacked (field);
    6691                 :           0 :                 ftype = GetPackedType (SymbolTable_GetSType (Field));
    6692                 :           0 :                 nbits = m2expr_BuildTBitSize (location, ftype);
    6693                 :           0 :                 field = m2type_SetRecordFieldOffset (field, byteOffset, bitOffset, ftype, nbits);
    6694                 :           0 :                 bitOffset = m2expr_BuildAdd (location, bitOffset, nbits, false);
    6695                 :           0 :                 byteOffset = m2expr_BuildAdd (location, byteOffset, m2expr_BuildDivTrunc (location, bitOffset, m2decl_BuildIntegerConstant (8), false), false);
    6696                 :           0 :                 bitOffset = m2expr_BuildModTrunc (location, bitOffset, m2decl_BuildIntegerConstant (8), false);
    6697                 :             :               }
    6698                 :         240 :             FieldList = m2type_ChainOn (FieldList, field);
    6699                 :             :           }
    6700                 :             :         else
    6701                 :             :           {
    6702                 :             :             /* avoid dangling else.  */
    6703                 :      324452 :             if (Debugging)
    6704                 :             :               {
    6705                 :             :                 M2Printf_printf0 ((const char *) "chaining ", 9);
    6706                 :             :                 PrintTerse (Field);
    6707                 :             :                 M2Printf_printf0 ((const char *) "\\n", 2);
    6708                 :             :               }
    6709                 :      324452 :             FieldList = m2type_ChainOn (FieldList, MaybeAlignField (Chained (Field), &byteOffset, &bitOffset));
    6710                 :             :           }
    6711                 :             :       }
    6712                 :      406529 :     i += 1;
    6713                 :      406529 :   } while (! (Field == SymbolTable_NulSym));
    6714                 :       81807 :   WatchRemoveList (Sym, M2GCCDeclare_partiallydeclared);
    6715                 :       81807 :   WatchRemoveList (Sym, M2GCCDeclare_heldbyalignment);
    6716                 :       81807 :   WatchRemoveList (Sym, M2GCCDeclare_finishedalignment);
    6717                 :       81807 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Sym));
    6718                 :       81807 :   return m2type_BuildEndRecord (location, RecordType, FieldList, SymbolTable_IsDeclaredPacked (Sym));
    6719                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6720                 :             :   __builtin_unreachable ();
    6721                 :             : }
    6722                 :             : 
    6723                 :             : 
    6724                 :             : /*
    6725                 :             :    DeclareRecordField -
    6726                 :             : */
    6727                 :             : 
    6728                 :      325148 : static tree DeclareRecordField (unsigned int sym)
    6729                 :             : {
    6730                 :      325148 :   tree field;
    6731                 :      325148 :   tree GccFieldType;
    6732                 :      325148 :   location_t location;
    6733                 :             : 
    6734                 :      325148 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    6735                 :      325148 :   GccFieldType = PossiblyPacked (SymbolTable_GetSType (sym), SymbolTable_IsDeclaredPacked (sym));
    6736                 :      325148 :   field = m2type_BuildFieldRecord (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (sym))), GccFieldType);
    6737                 :      325148 :   return field;
    6738                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6739                 :             :   __builtin_unreachable ();
    6740                 :             : }
    6741                 :             : 
    6742                 :             : 
    6743                 :             : /*
    6744                 :             :    DeclareVarient - declares a record and its fields to gcc.
    6745                 :             :                     The final gcc record type is returned.
    6746                 :             : */
    6747                 :             : 
    6748                 :         276 : static tree DeclareVarient (unsigned int sym)
    6749                 :             : {
    6750                 :         276 :   unsigned int Field;
    6751                 :         276 :   unsigned int i;
    6752                 :         276 :   tree byteOffset;
    6753                 :         276 :   tree bitOffset;
    6754                 :         276 :   tree FieldList;
    6755                 :         276 :   tree VarientType;
    6756                 :         276 :   location_t location;
    6757                 :             : 
    6758                 :         276 :   i = 1;
    6759                 :         276 :   FieldList = (tree) (NULL);
    6760                 :         276 :   VarientType = DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartVarient});
    6761                 :         276 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    6762                 :         276 :   byteOffset = m2expr_GetIntegerZero (location);
    6763                 :         276 :   bitOffset = m2expr_GetIntegerZero (location);
    6764                 :         942 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    6765                 :             :     {
    6766                 :         666 :       Field = SymbolTable_GetNth (sym, i);
    6767                 :         666 :       if (((SymbolTable_IsRecordField (Field)) && (SymbolTable_IsRecordFieldAVarientTag (Field))) && ((SymbolTable_GetSymName (Field)) == NameKey_NulName))
    6768                 :             :         {}  /* empty.  */
    6769                 :             :       else
    6770                 :             :         {
    6771                 :             :           /* do not include a nameless tag into the C struct  */
    6772                 :         666 :           if (Debugging)
    6773                 :             :             {
    6774                 :             :               M2Printf_printf0 ((const char *) "chaining ", 9);
    6775                 :             :               PrintTerse (Field);
    6776                 :             :               M2Printf_printf0 ((const char *) "\\n", 2);
    6777                 :             :             }
    6778                 :         666 :           FieldList = m2type_ChainOn (FieldList, MaybeAlignField (Chained (Field), &byteOffset, &bitOffset));
    6779                 :             :         }
    6780                 :         666 :       i += 1;
    6781                 :             :     }
    6782                 :         276 :   WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
    6783                 :         276 :   WatchRemoveList (sym, M2GCCDeclare_heldbyalignment);
    6784                 :         276 :   WatchRemoveList (sym, M2GCCDeclare_finishedalignment);
    6785                 :         276 :   VarientType = m2type_BuildEndVarient (location, VarientType, FieldList, SymbolTable_IsDeclaredPacked (sym));
    6786                 :         276 :   return VarientType;
    6787                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6788                 :             :   __builtin_unreachable ();
    6789                 :             : }
    6790                 :             : 
    6791                 :             : 
    6792                 :             : /*
    6793                 :             :    DeclareFieldVarient -
    6794                 :             : */
    6795                 :             : 
    6796                 :         666 : static tree DeclareFieldVarient (unsigned int sym)
    6797                 :             : {
    6798                 :         666 :   unsigned int i;
    6799                 :         666 :   unsigned int f;
    6800                 :         666 :   tree VarientList;
    6801                 :         666 :   tree VarientType;
    6802                 :         666 :   tree byteOffset;
    6803                 :         666 :   tree bitOffset;
    6804                 :         666 :   tree GccFieldType;
    6805                 :         666 :   location_t location;
    6806                 :             : 
    6807                 :         666 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    6808                 :         666 :   i = 1;
    6809                 :         666 :   VarientList = (tree) (NULL);
    6810                 :         666 :   VarientType = DoStartDeclaration (sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartFieldVarient});
    6811                 :             :   /* no need to store the [sym, RecordType] tuple as it is stored by DeclareRecord which calls us  */
    6812                 :         666 :   byteOffset = m2expr_GetIntegerZero (location);
    6813                 :         666 :   bitOffset = m2expr_GetIntegerZero (location);
    6814                 :        1368 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    6815                 :             :     {
    6816                 :         702 :       f = SymbolTable_GetNth (sym, i);
    6817                 :         702 :       if ((SymbolTable_IsFieldVarient (f)) && (SymbolTable_IsEmptyFieldVarient (f)))
    6818                 :             :         {}  /* empty.  */
    6819                 :             :       else
    6820                 :             :         {
    6821                 :             :           /* do not include empty varient fields (created via 'else end' in variant records  */
    6822                 :         702 :           if (Debugging)
    6823                 :             :             {
    6824                 :             :               M2Printf_printf0 ((const char *) "chaining ", 9);
    6825                 :             :               PrintTerse (f);
    6826                 :             :               M2Printf_printf0 ((const char *) "\\n", 2);
    6827                 :             :             }
    6828                 :         702 :           VarientList = m2type_ChainOn (VarientList, MaybeAlignField (Chained (f), &byteOffset, &bitOffset));
    6829                 :             :         }
    6830                 :         702 :       i += 1;
    6831                 :             :     }
    6832                 :         666 :   WatchRemoveList (sym, M2GCCDeclare_partiallydeclared);
    6833                 :         666 :   GccFieldType = m2type_BuildEndFieldVarient (location, VarientType, VarientList, SymbolTable_IsDeclaredPacked (sym));
    6834                 :         666 :   return GccFieldType;
    6835                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6836                 :             :   __builtin_unreachable ();
    6837                 :             : }
    6838                 :             : 
    6839                 :             : 
    6840                 :             : /*
    6841                 :             :    DeclarePointer - declares a pointer type to gcc and returns the Tree.
    6842                 :             : */
    6843                 :             : 
    6844                 :      132258 : static tree DeclarePointer (unsigned int sym)
    6845                 :             : {
    6846                 :      132258 :   return m2type_BuildPointerType (SymbolConversion_Mod2Gcc (SymbolTable_GetSType (sym)));
    6847                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6848                 :             :   __builtin_unreachable ();
    6849                 :             : }
    6850                 :             : 
    6851                 :             : 
    6852                 :             : /*
    6853                 :             :    DeclareUnbounded - builds an unbounded type and returns the gcc tree.
    6854                 :             : */
    6855                 :             : 
    6856                 :       31858 : static tree DeclareUnbounded (unsigned int sym)
    6857                 :             : {
    6858                 :       31858 :   unsigned int record;
    6859                 :             : 
    6860                 :       31858 :   M2Debug_Assert (SymbolTable_IsUnbounded (sym));
    6861                 :       31858 :   if (SymbolConversion_GccKnowsAbout (sym))
    6862                 :             :     {
    6863                 :           0 :       return SymbolConversion_Mod2Gcc (sym);
    6864                 :             :     }
    6865                 :             :   else
    6866                 :             :     {
    6867                 :       31858 :       record = SymbolTable_GetUnboundedRecordType (sym);
    6868                 :       31858 :       M2Debug_Assert (SymbolTable_IsRecord (record));
    6869                 :       31858 :       M2Debug_Assert (AllDependantsFullyDeclared (record));
    6870                 :       31858 :       if (! (SymbolConversion_GccKnowsAbout (record)))
    6871                 :             :         {
    6872                 :           0 :           DeclareTypeConstFully (record);
    6873                 :           0 :           WatchRemoveList (record, M2GCCDeclare_todolist);
    6874                 :             :         }
    6875                 :       31858 :       return SymbolConversion_Mod2Gcc (record);
    6876                 :             :     }
    6877                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6878                 :             :   __builtin_unreachable ();
    6879                 :             : }
    6880                 :             : 
    6881                 :             : 
    6882                 :             : /*
    6883                 :             :    BuildIndex -
    6884                 :             : */
    6885                 :             : 
    6886                 :       32870 : static tree BuildIndex (unsigned int tokenno, unsigned int array)
    6887                 :             : {
    6888                 :       32870 :   unsigned int Subscript;
    6889                 :       32870 :   unsigned int Type;
    6890                 :       32870 :   unsigned int High;
    6891                 :       32870 :   unsigned int Low;
    6892                 :       32870 :   tree n;
    6893                 :       32870 :   tree low;
    6894                 :       32870 :   tree high;
    6895                 :       32870 :   location_t location;
    6896                 :             : 
    6897                 :       32870 :   location = M2LexBuf_TokenToLocation (tokenno);
    6898                 :       32870 :   Subscript = SymbolTable_GetArraySubscript (array);
    6899                 :       32870 :   M2Debug_Assert (SymbolTable_IsSubscript (Subscript));
    6900                 :       32870 :   Type = SymbolTable_GetDType (Subscript);
    6901                 :       32870 :   Low = M2GCCDeclare_GetTypeMin (Type);
    6902                 :       32870 :   High = M2GCCDeclare_GetTypeMax (Type);
    6903                 :       32870 :   M2GCCDeclare_DeclareConstant (tokenno, Low);
    6904                 :       32870 :   M2GCCDeclare_DeclareConstant (tokenno, High);
    6905                 :       32870 :   low = SymbolConversion_Mod2Gcc (Low);
    6906                 :       32870 :   high = SymbolConversion_Mod2Gcc (High);
    6907                 :       32870 :   if (m2type_ExceedsTypeRange (m2type_GetIntegerType (), low, high))
    6908                 :             :     {
    6909                 :          24 :       location = M2LexBuf_TokenToLocation (tokenno);
    6910                 :          24 :       n = m2convert_BuildConvert (location, m2type_GetIntegerType (), m2expr_BuildSub (location, high, low, false), false);
    6911                 :          24 :       if ((m2expr_TreeOverflow (n)) || (m2type_ValueOutOfTypeRange (m2type_GetIntegerType (), n)))
    6912                 :             :         {
    6913                 :           0 :           M2MetaError_MetaError3 ((const char *) "implementation restriction, array is too large {%1EDM}, the range {%2ad}..{%3ad} exceeds the integer range", 106, array, Low, High);
    6914                 :           0 :           return m2type_BuildArrayIndexType (m2expr_GetIntegerZero (location), m2expr_GetIntegerZero (location));
    6915                 :             :         }
    6916                 :             :       else
    6917                 :             :         {
    6918                 :          24 :           SymbolTable_PutArrayLarge (array);
    6919                 :          24 :           return m2type_BuildArrayIndexType (m2expr_GetIntegerZero (location), n);
    6920                 :             :         }
    6921                 :             :     }
    6922                 :             :   else
    6923                 :             :     {
    6924                 :       32846 :       low = m2convert_BuildConvert (location, m2type_GetIntegerType (), low, false);
    6925                 :       32846 :       high = m2convert_BuildConvert (location, m2type_GetIntegerType (), high, false);
    6926                 :       32846 :       return m2type_BuildArrayIndexType (low, high);
    6927                 :             :     }
    6928                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6929                 :             :   __builtin_unreachable ();
    6930                 :             : }
    6931                 :             : 
    6932                 :             : 
    6933                 :             : /*
    6934                 :             :    DeclareArray - declares an array to gcc and returns the gcc tree.
    6935                 :             : */
    6936                 :             : 
    6937                 :       25414 : static tree DeclareArray (unsigned int Sym)
    6938                 :             : {
    6939                 :       25414 :   unsigned int typeOfArray;
    6940                 :       25414 :   tree ArrayType;
    6941                 :       25414 :   tree GccArray;
    6942                 :       25414 :   tree GccIndex;
    6943                 :       25414 :   unsigned int Subscript;
    6944                 :       25414 :   unsigned int tokenno;
    6945                 :       25414 :   location_t location;
    6946                 :             : 
    6947                 :       25414 :   M2Debug_Assert (SymbolTable_IsArray (Sym));
    6948                 :       25414 :   tokenno = SymbolTable_GetDeclaredMod (Sym);
    6949                 :       25414 :   location = M2LexBuf_TokenToLocation (tokenno);
    6950                 :       25414 :   Subscript = SymbolTable_GetArraySubscript (Sym);
    6951                 :       25414 :   typeOfArray = SymbolTable_GetDType (Sym);
    6952                 :       25414 :   GccArray = SymbolConversion_Mod2Gcc (typeOfArray);
    6953                 :       25414 :   GccIndex = BuildIndex (tokenno, Sym);
    6954                 :       25414 :   if (SymbolConversion_GccKnowsAbout (Sym))
    6955                 :             :     {
    6956                 :        6752 :       ArrayType = SymbolConversion_Mod2Gcc (Sym);
    6957                 :             :     }
    6958                 :             :   else
    6959                 :             :     {
    6960                 :       18662 :       ArrayType = m2type_BuildStartArrayType (GccIndex, GccArray, static_cast<int> (typeOfArray));
    6961                 :       18662 :       PreAddModGcc (Sym, ArrayType);
    6962                 :             :     }
    6963                 :       25414 :   PreAddModGcc (Subscript, GccArray);  /* we save the type of this array as the subscript  */
    6964                 :       25414 :   M2ALU_PushIntegerTree (m2expr_BuildSize (location, GccArray, false));  /* and the size of this array so far  */
    6965                 :       25414 :   SymbolTable_PopSize (Subscript);  /* and the size of this array so far  */
    6966                 :       25414 :   GccArray = m2type_BuildEndArrayType (ArrayType, GccArray, GccIndex, static_cast<int> (typeOfArray));
    6967                 :       25414 :   M2Debug_Assert (GccArray == ArrayType);
    6968                 :       25414 :   return GccArray;
    6969                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    6970                 :             :   __builtin_unreachable ();
    6971                 :             : }
    6972                 :             : 
    6973                 :             : 
    6974                 :             : /*
    6975                 :             :    DeclareProcType - declares a procedure type to gcc and returns the gcc type tree.
    6976                 :             : */
    6977                 :             : 
    6978                 :       54412 : static tree DeclareProcType (unsigned int Sym)
    6979                 :             : {
    6980                 :       54412 :   unsigned int i;
    6981                 :       54412 :   unsigned int p;
    6982                 :       54412 :   unsigned int Parameter;
    6983                 :       54412 :   unsigned int ReturnType;
    6984                 :       54412 :   tree func;
    6985                 :       54412 :   tree GccParam;
    6986                 :       54412 :   location_t location;
    6987                 :             : 
    6988                 :       54412 :   ReturnType = SymbolTable_GetSType (Sym);
    6989                 :       54412 :   func = DoStartDeclaration (Sym, (M2GCCDeclare_StartProcedure) {(M2GCCDeclare_StartProcedure_t) m2type_BuildStartFunctionType});
    6990                 :       54412 :   m2type_InitFunctionTypeParameters ();
    6991                 :       54412 :   p = SymbolTable_NoOfParamAny (Sym);
    6992                 :       54412 :   i = p;
    6993                 :      186231 :   while (i > 0)
    6994                 :             :     {
    6995                 :       77407 :       Parameter = SymbolTable_GetNthParamAny (Sym, i);
    6996                 :       77407 :       location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (Parameter));
    6997                 :       77407 :       GccParam = m2type_BuildProcTypeParameterDeclaration (location, SymbolConversion_Mod2Gcc (SymbolTable_GetSType (Parameter)), SymbolTable_IsVarParamAny (Sym, i));
    6998                 :       77407 :       PreAddModGcc (Parameter, GccParam);
    6999                 :       77407 :       i -= 1;
    7000                 :             :     }
    7001                 :       54412 :   if (ReturnType == SymbolTable_NulSym)
    7002                 :             :     {
    7003                 :       46940 :       return m2type_BuildEndFunctionType (func, NULL, SymbolTable_UsesVarArgs (Sym));
    7004                 :             :     }
    7005                 :             :   else
    7006                 :             :     {
    7007                 :        7472 :       return m2type_BuildEndFunctionType (func, SymbolConversion_Mod2Gcc (ReturnType), SymbolTable_UsesVarArgs (Sym));
    7008                 :             :     }
    7009                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7010                 :             :   __builtin_unreachable ();
    7011                 :             : }
    7012                 :             : 
    7013                 :             : 
    7014                 :             : /*
    7015                 :             :    FindMinMaxEnum - finds the minimum and maximum enumeration fields.
    7016                 :             : */
    7017                 :             : 
    7018                 :     4149936 : static void FindMinMaxEnum (unsigned int field)
    7019                 :             : {
    7020                 :     4149936 :   if (MaxEnumerationField == SymbolTable_NulSym)
    7021                 :             :     {
    7022                 :      606432 :       MaxEnumerationField = static_cast<unsigned int> (field);
    7023                 :             :     }
    7024                 :             :   else
    7025                 :             :     {
    7026                 :     3543504 :       SymbolTable_PushValue (field);
    7027                 :     3543504 :       SymbolTable_PushValue (MaxEnumerationField);
    7028                 :     3543504 :       if (M2ALU_Gre (SymbolTable_GetDeclaredMod (field)))
    7029                 :             :         {
    7030                 :      259204 :           MaxEnumerationField = static_cast<unsigned int> (field);
    7031                 :             :         }
    7032                 :             :     }
    7033                 :     4149936 :   if (MinEnumerationField == SymbolTable_NulSym)
    7034                 :             :     {
    7035                 :      606432 :       MinEnumerationField = static_cast<unsigned int> (field);
    7036                 :             :     }
    7037                 :             :   else
    7038                 :             :     {
    7039                 :     3543504 :       SymbolTable_PushValue (field);
    7040                 :     3543504 :       SymbolTable_PushValue (MinEnumerationField);
    7041                 :     3543504 :       if (M2ALU_Less (SymbolTable_GetDeclaredMod (field)))
    7042                 :             :         {
    7043                 :     2755428 :           MinEnumerationField = static_cast<unsigned int> (field);
    7044                 :             :         }
    7045                 :             :     }
    7046                 :     4149936 : }
    7047                 :             : 
    7048                 :             : 
    7049                 :             : /*
    7050                 :             :    PushNoOfBits - pushes the integer value of the number of bits required
    7051                 :             :                   to maintain a set of type.
    7052                 :             : */
    7053                 :             : 
    7054                 :        2558 : static void PushNoOfBits (unsigned int type, unsigned int low, unsigned int high)
    7055                 :             : {
    7056                 :        2558 :   SymbolTable_PushValue (high);
    7057                 :        2558 :   M2ALU_ConvertToType (type);
    7058                 :        2558 :   SymbolTable_PushValue (low);
    7059                 :        2558 :   M2ALU_ConvertToType (type);
    7060                 :        2558 :   M2ALU_Sub ();
    7061                 :        2558 :   M2ALU_ConvertToType (M2Base_Cardinal);
    7062                 :        2558 : }
    7063                 :             : 
    7064                 :             : 
    7065                 :             : /*
    7066                 :             :    DeclareLargeSet - n is the name of the set.
    7067                 :             :                      type is the subrange type (or simple type)
    7068                 :             :                      low and high are the limits of the subrange.
    7069                 :             : */
    7070                 :             : 
    7071                 :         732 : static tree DeclareLargeSet (NameKey_Name n, unsigned int type, unsigned int low, unsigned int high)
    7072                 :             : {
    7073                 :         732 :   tree lowtree;
    7074                 :         732 :   tree hightree;
    7075                 :         732 :   tree BitsInSet;
    7076                 :         732 :   tree RecordType;
    7077                 :         732 :   tree GccField;
    7078                 :         732 :   tree FieldList;
    7079                 :         732 :   unsigned int bpw;
    7080                 :         732 :   location_t location;
    7081                 :             : 
    7082                 :         732 :   location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (type));
    7083                 :         732 :   bpw = m2decl_GetBitsPerBitset ();
    7084                 :         732 :   SymbolTable_PushValue (low);
    7085                 :         732 :   lowtree = M2ALU_PopIntegerTree ();
    7086                 :         732 :   SymbolTable_PushValue (high);
    7087                 :         732 :   hightree = M2ALU_PopIntegerTree ();
    7088                 :         732 :   FieldList = (tree) (NULL);
    7089                 :         732 :   RecordType = m2type_BuildStartRecord (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (n)));  /* no problem with recursive types here  */
    7090                 :         732 :   PushNoOfBits (type, low, high);  /* no problem with recursive types here  */
    7091                 :         732 :   M2ALU_PushCard (1);
    7092                 :         732 :   M2ALU_Addn ();
    7093                 :         732 :   BitsInSet = M2ALU_PopIntegerTree ();
    7094                 :         732 :   M2ALU_PushIntegerTree (BitsInSet);
    7095                 :         732 :   M2ALU_PushCard (0);
    7096                 :       26914 :   while (M2ALU_Gre (SymbolTable_GetDeclaredMod (type)))
    7097                 :             :     {
    7098                 :       25450 :       M2ALU_PushIntegerTree (BitsInSet);
    7099                 :       25450 :       M2ALU_PushCard (bpw-1);
    7100                 :       25450 :       if (M2ALU_GreEqu (SymbolTable_GetDeclaredMod (type)))
    7101                 :             :         {
    7102                 :       25286 :           M2ALU_PushIntegerTree (lowtree);
    7103                 :       25286 :           M2ALU_PushCard (bpw-1);
    7104                 :       25286 :           M2ALU_Addn ();
    7105                 :       25286 :           GccField = m2type_BuildFieldRecord (location, NULL, m2type_BuildSetType (location, NULL, SymbolConversion_Mod2Gcc (type), lowtree, M2ALU_PopIntegerTree (), false));
    7106                 :       25286 :           M2ALU_PushIntegerTree (lowtree);
    7107                 :       25286 :           M2ALU_PushCard (bpw);
    7108                 :       25286 :           M2ALU_Addn ();
    7109                 :       25286 :           lowtree = M2ALU_PopIntegerTree ();
    7110                 :       25286 :           M2ALU_PushIntegerTree (BitsInSet);
    7111                 :       25286 :           M2ALU_PushCard (bpw);
    7112                 :       25286 :           M2ALU_Sub ();
    7113                 :       25286 :           BitsInSet = M2ALU_PopIntegerTree ();
    7114                 :             :         }
    7115                 :             :       else
    7116                 :             :         {
    7117                 :             :           /* printf2('range is %a..%a
    7118                 :             :           ', GetSymName(low), GetSymName(high)) ;  */
    7119                 :         164 :           GccField = m2type_BuildFieldRecord (location, NULL, m2type_BuildSetType (location, NULL, SymbolConversion_Mod2Gcc (type), lowtree, hightree, false));
    7120                 :         164 :           M2ALU_PushCard (0);
    7121                 :         164 :           BitsInSet = M2ALU_PopIntegerTree ();
    7122                 :             :         }
    7123                 :       25450 :       FieldList = m2type_ChainOn (FieldList, GccField);
    7124                 :       25450 :       M2ALU_PushIntegerTree (BitsInSet);
    7125                 :       25450 :       M2ALU_PushCard (0);
    7126                 :             :     }
    7127                 :         732 :   return m2type_BuildEndRecord (location, RecordType, FieldList, false);
    7128                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7129                 :             :   __builtin_unreachable ();
    7130                 :             : }
    7131                 :             : 
    7132                 :             : 
    7133                 :             : /*
    7134                 :             :    DeclareLargeOrSmallSet - works out whether the set will exceed TSIZE(WORD). If it does
    7135                 :             :                             we manufacture a set using:
    7136                 :             : 
    7137                 :             :                             settype = RECORD
    7138                 :             :                                          w1: SET OF [...]
    7139                 :             :                                          w2: SET OF [...]
    7140                 :             :                                       END
    7141                 :             : 
    7142                 :             :                             We do this as GCC and GDB (stabs) only knows about WORD sized sets.
    7143                 :             :                             If the set will fit into a WORD then we call gccgm2 directly.
    7144                 :             : */
    7145                 :             : 
    7146                 :        1826 : static tree DeclareLargeOrSmallSet (unsigned int sym, NameKey_Name n, unsigned int type, unsigned int low, unsigned int high)
    7147                 :             : {
    7148                 :        1826 :   location_t location;
    7149                 :        1826 :   bool packed;
    7150                 :             : 
    7151                 :        1826 :   PushNoOfBits (type, low, high);
    7152                 :        1826 :   M2ALU_PushCard (static_cast<unsigned int> (m2decl_GetBitsPerBitset ()));
    7153                 :        1826 :   packed = SymbolTable_IsSetPacked (sym);
    7154                 :        1826 :   if (M2ALU_Less (SymbolTable_GetDeclaredMod (type)))
    7155                 :             :     {
    7156                 :        1094 :       location = M2LexBuf_TokenToLocation (SymbolTable_GetDeclaredMod (sym));
    7157                 :             :       /* PutSetSmall(sym) ;  */
    7158                 :        1094 :       return m2type_BuildSetType (location, reinterpret_cast <char * > (NameKey_KeyToCharStar (n)), SymbolConversion_Mod2Gcc (type), SymbolConversion_Mod2Gcc (low), SymbolConversion_Mod2Gcc (high), packed);
    7159                 :             :     }
    7160                 :             :   else
    7161                 :             :     {
    7162                 :         732 :       return DeclareLargeSet (n, type, low, high);  /* --fixme-- finish packed here as well.  */
    7163                 :             :     }
    7164                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7165                 :             :   __builtin_unreachable ();
    7166                 :             : }
    7167                 :             : 
    7168                 :             : 
    7169                 :             : /*
    7170                 :             :    DeclareSet - declares a set type to gcc and returns a Tree.
    7171                 :             : */
    7172                 :             : 
    7173                 :        1826 : static tree DeclareSet (unsigned int sym)
    7174                 :             : {
    7175                 :        1826 :   tree gccsym;
    7176                 :        1826 :   unsigned int type;
    7177                 :        1826 :   unsigned int high;
    7178                 :        1826 :   unsigned int low;
    7179                 :             : 
    7180                 :        1826 :   type = SymbolTable_GetDType (sym);
    7181                 :        1826 :   if (SymbolTable_IsSubrange (type))
    7182                 :             :     {
    7183                 :        1040 :       SymbolTable_GetSubrange (type, &high, &low);
    7184                 :        1040 :       gccsym = DeclareLargeOrSmallSet (sym, M2AsmUtil_GetFullSymName (sym), SymbolTable_GetSType (type), low, high);
    7185                 :             :     }
    7186                 :             :   else
    7187                 :             :     {
    7188                 :         786 :       gccsym = DeclareLargeOrSmallSet (sym, M2AsmUtil_GetFullSymName (sym), type, M2GCCDeclare_GetTypeMin (type), M2GCCDeclare_GetTypeMax (type));
    7189                 :             :     }
    7190                 :        1826 :   return gccsym;
    7191                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7192                 :             :   __builtin_unreachable ();
    7193                 :             : }
    7194                 :             : 
    7195                 :             : 
    7196                 :             : /*
    7197                 :             :    CheckResolveSubrange - checks to see whether we can determine
    7198                 :             :                           the subrange type.  We are able to do
    7199                 :             :                           this once low, high and the type are known.
    7200                 :             : */
    7201                 :             : 
    7202                 :     1316257 : static void CheckResolveSubrange (unsigned int sym)
    7203                 :             : {
    7204                 :     1316257 :   unsigned int tokenno;
    7205                 :     1316257 :   unsigned int size;
    7206                 :     1316257 :   unsigned int high;
    7207                 :     1316257 :   unsigned int low;
    7208                 :     1316257 :   unsigned int type;
    7209                 :             : 
    7210                 :     1316257 :   SymbolTable_GetSubrange (sym, &high, &low);
    7211                 :     1316257 :   tokenno = SymbolTable_GetDeclaredMod (sym);
    7212                 :     1316257 :   type = SymbolTable_GetSType (sym);
    7213                 :     1316257 :   if (type == SymbolTable_NulSym)
    7214                 :             :     {
    7215                 :      277702 :       if ((SymbolConversion_GccKnowsAbout (low)) && (SymbolConversion_GccKnowsAbout (high)))
    7216                 :             :         {
    7217                 :             :           /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    7218                 :       21940 :           if ((SymbolTable_IsConstString (low)) && (SymbolTable_IsConstStringKnown (low)))
    7219                 :             :             {
    7220                 :          72 :               size = SymbolTable_GetStringLength (tokenno, low);
    7221                 :          72 :               if (size <= 1)
    7222                 :             :                 {
    7223                 :          72 :                   SymbolTable_PutSubrange (sym, low, high, M2Base_Char);
    7224                 :             :                 }
    7225                 :             :               else
    7226                 :             :                 {
    7227                 :           0 :                   M2MetaError_MetaError1 ((const char *) "cannot have a subrange of a string type {%1Uad}", 47, sym);
    7228                 :             :                 }
    7229                 :             :             }
    7230                 :       21868 :           else if (SymbolTable_IsFieldEnumeration (low))
    7231                 :             :             {
    7232                 :             :               /* avoid dangling else.  */
    7233                 :         344 :               if ((SymbolTable_GetSType (low)) == (SymbolTable_GetSType (high)))
    7234                 :             :                 {
    7235                 :         344 :                   SymbolTable_PutSubrange (sym, low, high, SymbolTable_GetSType (low));
    7236                 :             :                 }
    7237                 :             :               else
    7238                 :             :                 {
    7239                 :           0 :                   M2MetaError_MetaError1 ((const char *) "subrange limits must be of the same type {%1Uad}", 48, sym);
    7240                 :             :                 }
    7241                 :             :             }
    7242                 :       21524 :           else if (SymbolTable_IsValueSolved (low))
    7243                 :             :             {
    7244                 :             :               /* avoid dangling else.  */
    7245                 :       21524 :               if ((SymbolTable_GetSType (low)) == M2Base_LongReal)
    7246                 :             :                 {
    7247                 :           0 :                   M2MetaError_MetaError1 ((const char *) "cannot have a subrange of a SHORTREAL, REAL or LONGREAL type {%1Uad}", 68, sym);
    7248                 :             :                 }
    7249                 :             :               else
    7250                 :             :                 {
    7251                 :       21524 :                   SymbolTable_PutSubrange (sym, low, high, M2Base_MixTypes (SymbolTable_GetSType (low), SymbolTable_GetSType (high), SymbolTable_GetDeclaredMod (sym)));
    7252                 :             :                 }
    7253                 :             :             }
    7254                 :             :         }
    7255                 :             :     }
    7256                 :     1316257 : }
    7257                 :             : 
    7258                 :             : 
    7259                 :             : /*
    7260                 :             :    TypeConstFullyDeclared - all, sym, dependents are declared, so create and
    7261                 :             :                             return the GCC Tree equivalent.
    7262                 :             : */
    7263                 :             : 
    7264                 :     1186856 : static tree TypeConstFullyDeclared (unsigned int sym)
    7265                 :             : {
    7266                 :     1186856 :   tree t;
    7267                 :             : 
    7268                 :     1186856 :   if (SymbolTable_IsEnumeration (sym))
    7269                 :             :     {
    7270                 :       23238 :       t = DeclareEnumeration (sym);
    7271                 :             :     }
    7272                 :     1163618 :   else if (SymbolTable_IsFieldEnumeration (sym))
    7273                 :             :     {
    7274                 :             :       /* avoid dangling else.  */
    7275                 :      423822 :       t = DeclareFieldEnumeration (sym);
    7276                 :             :     }
    7277                 :      739796 :   else if (SymbolTable_IsSubrange (sym))
    7278                 :             :     {
    7279                 :             :       /* avoid dangling else.  */
    7280                 :       24558 :       t = DeclareSubrange (sym);
    7281                 :             :     }
    7282                 :      715238 :   else if (SymbolTable_IsRecord (sym))
    7283                 :             :     {
    7284                 :             :       /* avoid dangling else.  */
    7285                 :       81807 :       t = CheckPragma (DeclareRecord (sym), sym);
    7286                 :             :     }
    7287                 :      633431 :   else if (SymbolTable_IsRecordField (sym))
    7288                 :             :     {
    7289                 :             :       /* avoid dangling else.  */
    7290                 :      325148 :       t = CheckPragma (DeclareRecordField (sym), sym);
    7291                 :             :     }
    7292                 :      308283 :   else if (SymbolTable_IsFieldVarient (sym))
    7293                 :             :     {
    7294                 :             :       /* avoid dangling else.  */
    7295                 :         666 :       t = DeclareFieldVarient (sym);
    7296                 :             :     }
    7297                 :      307617 :   else if (SymbolTable_IsVarient (sym))
    7298                 :             :     {
    7299                 :             :       /* avoid dangling else.  */
    7300                 :         276 :       t = DeclareVarient (sym);
    7301                 :             :     }
    7302                 :      307341 :   else if (SymbolTable_IsPointer (sym))
    7303                 :             :     {
    7304                 :             :       /* avoid dangling else.  */
    7305                 :      115284 :       t = CheckAlignment (DeclarePointer (sym), sym);
    7306                 :             :     }
    7307                 :      192057 :   else if (SymbolTable_IsUnbounded (sym))
    7308                 :             :     {
    7309                 :             :       /* avoid dangling else.  */
    7310                 :       31858 :       t = DeclareUnbounded (sym);
    7311                 :             :     }
    7312                 :      160199 :   else if (SymbolTable_IsArray (sym))
    7313                 :             :     {
    7314                 :             :       /* avoid dangling else.  */
    7315                 :       25414 :       t = CheckAlignment (DeclareArray (sym), sym);
    7316                 :             :     }
    7317                 :      134785 :   else if (SymbolTable_IsProcType (sym))
    7318                 :             :     {
    7319                 :             :       /* avoid dangling else.  */
    7320                 :       48454 :       t = DeclareProcType (sym);
    7321                 :             :     }
    7322                 :       86331 :   else if (SymbolTable_IsSet (sym))
    7323                 :             :     {
    7324                 :             :       /* avoid dangling else.  */
    7325                 :        1826 :       t = DeclareSet (sym);
    7326                 :             :     }
    7327                 :       84505 :   else if (SymbolTable_IsConst (sym))
    7328                 :             :     {
    7329                 :             :       /* avoid dangling else.  */
    7330                 :       55954 :       if (SymbolTable_IsConstructor (sym))
    7331                 :             :         {
    7332                 :        7932 :           SymbolTable_PushValue (sym);
    7333                 :        7932 :           M2ALU_ChangeToConstructor (SymbolTable_GetDeclaredMod (sym), SymbolTable_GetSType (sym));
    7334                 :        7932 :           SymbolTable_PopValue (sym);
    7335                 :        7932 :           M2ALU_EvaluateValue (sym);
    7336                 :        7932 :           M2ALU_PutConstructorSolved (sym);
    7337                 :             :         }
    7338                 :       48022 :       else if (SymbolTable_IsConstSet (sym))
    7339                 :             :         {
    7340                 :             :           /* avoid dangling else.  */
    7341                 :           0 :           M2ALU_EvaluateValue (sym);
    7342                 :             :         }
    7343                 :       55954 :       if (! (SymbolTable_IsValueSolved (sym)))
    7344                 :             :         {
    7345                 :             :           return NULL;
    7346                 :             :         }
    7347                 :       55954 :       t = DeclareConst (SymbolTable_GetDeclaredMod (sym), sym);
    7348                 :       55954 :       M2Debug_Assert (t != NULL);
    7349                 :             :     }
    7350                 :       28551 :   else if (SymbolTable_IsConstructor (sym))
    7351                 :             :     {
    7352                 :             :       /* avoid dangling else.  */
    7353                 :             :       /* not yet known as a constant  */
    7354                 :             :       return NULL;
    7355                 :             :     }
    7356                 :             :   else
    7357                 :             :     {
    7358                 :             :       /* avoid dangling else.  */
    7359                 :       28551 :       t = DeclareType (sym);
    7360                 :       28551 :       if (SymbolTable_IsType (sym))
    7361                 :             :         {
    7362                 :       28551 :           t = CheckAlignment (t, sym);
    7363                 :             :         }
    7364                 :             :     }
    7365                 :     1186856 :   return m2block_RememberType (t);
    7366                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7367                 :             :   __builtin_unreachable ();
    7368                 :             : }
    7369                 :             : 
    7370                 :             : 
    7371                 :             : /*
    7372                 :             :    IsBaseType - returns true if a type, Sym, is a base type and
    7373                 :             :                 we use predefined GDB information to represent this
    7374                 :             :                 type.
    7375                 :             : */
    7376                 :             : 
    7377                 :       21862 : static bool IsBaseType (unsigned int Sym)
    7378                 :             : {
    7379                 :       21862 :   return (((Sym == M2Base_Cardinal) || (Sym == M2Base_Integer)) || (Sym == M2Base_Char)) || (Sym == M2Base_Proc);
    7380                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7381                 :             :   __builtin_unreachable ();
    7382                 :             : }
    7383                 :             : 
    7384                 :             : 
    7385                 :             : /*
    7386                 :             :    IsFieldEnumerationDependants - sets enumDeps to FALSE if action(Sym)
    7387                 :             :                                   is also FALSE.
    7388                 :             : */
    7389                 :             : 
    7390                 :     1014742 : static void IsFieldEnumerationDependants (unsigned int Sym)
    7391                 :             : {
    7392                 :     1014742 :   if (! ((*action.proc) (Sym)))
    7393                 :             :     {
    7394                 :      423634 :       enumDeps = false;
    7395                 :             :     }
    7396                 :     1014742 : }
    7397                 :             : 
    7398                 :             : 
    7399                 :             : /*
    7400                 :             :    IsEnumerationDependants - returns true if the enumeration
    7401                 :             :                              p(dependants) all return true.
    7402                 :             : */
    7403                 :             : 
    7404                 :      104625 : static bool IsEnumerationDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7405                 :             : {
    7406                 :      104625 :   action = q;
    7407                 :      104625 :   enumDeps = true;
    7408                 :      104625 :   SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) IsFieldEnumerationDependants});
    7409                 :      104625 :   return enumDeps;
    7410                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7411                 :             :   __builtin_unreachable ();
    7412                 :             : }
    7413                 :             : 
    7414                 :             : 
    7415                 :             : /*
    7416                 :             :    WalkEnumerationDependants - returns walks all dependants of Sym.
    7417                 :             : */
    7418                 :             : 
    7419                 :     2887152 : static void WalkEnumerationDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7420                 :             : {
    7421                 :     2887152 :   SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) p.proc});
    7422                 :           0 : }
    7423                 :             : 
    7424                 :             : 
    7425                 :             : /*
    7426                 :             :    WalkSubrangeDependants - calls p(dependants) for each dependant of, sym.
    7427                 :             : */
    7428                 :             : 
    7429                 :     1262763 : static void WalkSubrangeDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7430                 :             : {
    7431                 :     1262763 :   unsigned int type;
    7432                 :     1262763 :   unsigned int align;
    7433                 :     1262763 :   unsigned int high;
    7434                 :     1262763 :   unsigned int low;
    7435                 :             : 
    7436                 :     1262763 :   SymbolTable_GetSubrange (sym, &high, &low);
    7437                 :     1262763 :   CheckResolveSubrange (sym);
    7438                 :     1262763 :   type = SymbolTable_GetSType (sym);
    7439                 :     1262763 :   if (type != SymbolTable_NulSym)
    7440                 :             :     {
    7441                 :     1029743 :       (*p.proc) (type);
    7442                 :             :     }
    7443                 :             :   /* low and high are not types but constants and they are resolved by M2GenGCC  */
    7444                 :     1262763 :   (*p.proc) (low);
    7445                 :     1262763 :   (*p.proc) (high);
    7446                 :     1262763 :   align = SymbolTable_GetAlignment (sym);
    7447                 :     1262763 :   if (align != SymbolTable_NulSym)
    7448                 :             :     {
    7449                 :        7632 :       (*p.proc) (align);
    7450                 :             :     }
    7451                 :     1262763 : }
    7452                 :             : 
    7453                 :             : 
    7454                 :             : /*
    7455                 :             :    IsSubrangeDependants - returns TRUE if the subrange
    7456                 :             :                           q(dependants) all return TRUE.
    7457                 :             : */
    7458                 :             : 
    7459                 :       53494 : static bool IsSubrangeDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7460                 :             : {
    7461                 :       53494 :   bool result;
    7462                 :       53494 :   unsigned int align;
    7463                 :       53494 :   unsigned int type;
    7464                 :       53494 :   unsigned int high;
    7465                 :       53494 :   unsigned int low;
    7466                 :             : 
    7467                 :       53494 :   SymbolTable_GetSubrange (sym, &high, &low);
    7468                 :             :   /* low and high are not types but constants and they are resolved by M2GenGCC  */
    7469                 :       53494 :   CheckResolveSubrange (sym);
    7470                 :       53494 :   result = true;
    7471                 :       53494 :   type = SymbolTable_GetSType (sym);
    7472                 :       53494 :   if ((type == SymbolTable_NulSym) || (! ((*q.proc) (type))))
    7473                 :             :     {
    7474                 :             :       result = false;
    7475                 :             :     }
    7476                 :       53494 :   if (! ((*q.proc) (low)))
    7477                 :             :     {
    7478                 :       24452 :       result = false;
    7479                 :             :     }
    7480                 :       53494 :   if (! ((*q.proc) (high)))
    7481                 :             :     {
    7482                 :        8828 :       result = false;
    7483                 :             :     }
    7484                 :       53494 :   align = SymbolTable_GetAlignment (sym);
    7485                 :       53494 :   if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
    7486                 :             :     {
    7487                 :             :       result = false;
    7488                 :             :     }
    7489                 :       53494 :   return result;
    7490                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7491                 :             :   __builtin_unreachable ();
    7492                 :             : }
    7493                 :             : 
    7494                 :             : 
    7495                 :             : /*
    7496                 :             :    WalkComponentDependants -
    7497                 :             : */
    7498                 :             : 
    7499                 :      100062 : static void WalkComponentDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7500                 :             : {
    7501                 :      100062 :   unsigned int i;
    7502                 :      100062 :   unsigned int type;
    7503                 :             : 
    7504                 :             :   /* need to walk record and field  */
    7505                 :      100062 :   i = 1;
    7506                 :      300186 :   do {
    7507                 :      300186 :     type = SymbolTable_GetNth (sym, i);
    7508                 :      300186 :     if (type != SymbolTable_NulSym)
    7509                 :             :       {
    7510                 :      200124 :         if (SymbolTable_IsVar (type))
    7511                 :             :           {
    7512                 :      100062 :             (*p.proc) (SymbolTable_GetSType (type));
    7513                 :             :           }
    7514                 :             :         else
    7515                 :             :           {
    7516                 :      100062 :             (*p.proc) (type);
    7517                 :             :           }
    7518                 :      200124 :         i += 1;
    7519                 :             :       }
    7520                 :      300186 :   } while (! (type == SymbolTable_NulSym));
    7521                 :      100062 : }
    7522                 :             : 
    7523                 :             : 
    7524                 :             : /*
    7525                 :             :    IsComponentDependants -
    7526                 :             : */
    7527                 :             : 
    7528                 :           0 : static bool IsComponentDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7529                 :             : {
    7530                 :           0 :   unsigned int type;
    7531                 :           0 :   unsigned int i;
    7532                 :           0 :   bool result;
    7533                 :             : 
    7534                 :             :   /* need to check record is completely resolved  */
    7535                 :           0 :   result = true;
    7536                 :           0 :   i = 1;
    7537                 :           0 :   do {
    7538                 :           0 :     type = SymbolTable_GetNth (sym, i);
    7539                 :           0 :     if (type != SymbolTable_NulSym)
    7540                 :             :       {
    7541                 :           0 :         if (SymbolTable_IsVar (type))
    7542                 :             :           {
    7543                 :           0 :             type = SymbolTable_GetSType (type);
    7544                 :             :           }
    7545                 :           0 :         if (! ((*q.proc) (type)))
    7546                 :             :           {
    7547                 :           0 :             result = false;
    7548                 :             :           }
    7549                 :           0 :         i += 1;
    7550                 :             :       }
    7551                 :           0 :   } while (! (type == SymbolTable_NulSym));
    7552                 :           0 :   return result;
    7553                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7554                 :             :   __builtin_unreachable ();
    7555                 :             : }
    7556                 :             : 
    7557                 :             : 
    7558                 :             : /*
    7559                 :             :    WalkVarDependants - walks all dependants of sym.
    7560                 :             : */
    7561                 :             : 
    7562                 :      574864 : static void WalkVarDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7563                 :             : {
    7564                 :      574864 :   unsigned int type;
    7565                 :             : 
    7566                 :      574864 :   (*p.proc) (SymbolTable_GetSType (sym));
    7567                 :      574864 :   if (SymbolTable_IsComponent (sym))
    7568                 :             :     {
    7569                 :           0 :       WalkComponentDependants (sym, p);
    7570                 :             :     }
    7571                 :      574864 :   type = SymbolTable_GetVarBackEndType (sym);
    7572                 :      574864 :   if (type != SymbolTable_NulSym)
    7573                 :             :     {
    7574                 :       46086 :       (*p.proc) (type);
    7575                 :             :     }
    7576                 :      574864 : }
    7577                 :             : 
    7578                 :             : 
    7579                 :             : /*
    7580                 :             :    IsVarDependants - returns TRUE if the pointer symbol, sym,
    7581                 :             :                      p(dependants) all return TRUE.
    7582                 :             : */
    7583                 :             : 
    7584                 :           0 : static bool IsVarDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7585                 :             : {
    7586                 :           0 :   unsigned int type;
    7587                 :           0 :   bool result;
    7588                 :             : 
    7589                 :           0 :   result = true;
    7590                 :           0 :   if (! ((*q.proc) (SymbolTable_GetSType (sym))))
    7591                 :             :     {
    7592                 :             :       result = false;
    7593                 :             :     }
    7594                 :           0 :   if (SymbolTable_IsComponent (sym))
    7595                 :             :     {
    7596                 :           0 :       if (! (IsComponentDependants (sym, q)))
    7597                 :             :         {
    7598                 :           0 :           result = false;
    7599                 :             :         }
    7600                 :             :     }
    7601                 :           0 :   type = SymbolTable_GetVarBackEndType (sym);
    7602                 :           0 :   if (type != SymbolTable_NulSym)
    7603                 :             :     {
    7604                 :           0 :       if (! ((*q.proc) (type)))
    7605                 :             :         {
    7606                 :           0 :           result = false;
    7607                 :             :         }
    7608                 :             :     }
    7609                 :           0 :   return result;
    7610                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7611                 :             :   __builtin_unreachable ();
    7612                 :             : }
    7613                 :             : 
    7614                 :             : 
    7615                 :             : /*
    7616                 :             :    WalkPointerDependants - walks all dependants of sym.
    7617                 :             : */
    7618                 :             : 
    7619                 :    10468496 : static void WalkPointerDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7620                 :             : {
    7621                 :    10468496 :   unsigned int align;
    7622                 :             : 
    7623                 :    10468496 :   (*p.proc) (SymbolTable_GetSType (sym));
    7624                 :    10468496 :   align = SymbolTable_GetAlignment (sym);
    7625                 :    10468496 :   if (align != SymbolTable_NulSym)
    7626                 :             :     {
    7627                 :          24 :       (*p.proc) (align);
    7628                 :             :     }
    7629                 :    10468496 : }
    7630                 :             : 
    7631                 :             : 
    7632                 :             : /*
    7633                 :             :    IsPointerDependants - returns TRUE if the pointer symbol, sym,
    7634                 :             :                          p(dependants) all return TRUE.
    7635                 :             : */
    7636                 :             : 
    7637                 :      887917 : static bool IsPointerDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7638                 :             : {
    7639                 :      887917 :   unsigned int align;
    7640                 :      887917 :   bool final;
    7641                 :             : 
    7642                 :      887917 :   final = true;
    7643                 :      887917 :   if (! ((*q.proc) (SymbolTable_GetSType (sym))))
    7644                 :             :     {
    7645                 :             :       final = false;
    7646                 :             :     }
    7647                 :      887917 :   align = SymbolTable_GetAlignment (sym);
    7648                 :      887917 :   if (final && (align != SymbolTable_NulSym))
    7649                 :             :     {
    7650                 :          36 :       if (! ((*q.proc) (align)))
    7651                 :             :         {
    7652                 :             :           final = false;
    7653                 :             :         }
    7654                 :             :     }
    7655                 :      887917 :   return final;
    7656                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7657                 :             :   __builtin_unreachable ();
    7658                 :             : }
    7659                 :             : 
    7660                 :             : 
    7661                 :             : /*
    7662                 :             :    IsRecordAlignment -
    7663                 :             : */
    7664                 :             : 
    7665                 :      518909 : static bool IsRecordAlignment (unsigned int sym, M2GCCDeclare_IsAction q)
    7666                 :             : {
    7667                 :      518909 :   if ((SymbolTable_GetDefaultRecordFieldAlignment (sym)) != SymbolTable_NulSym)
    7668                 :             :     {
    7669                 :         180 :       if (! ((*q.proc) (SymbolTable_GetDefaultRecordFieldAlignment (sym))))
    7670                 :             :         {
    7671                 :             :           return false;
    7672                 :             :         }
    7673                 :             :     }
    7674                 :             :   return true;
    7675                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7676                 :             :   __builtin_unreachable ();
    7677                 :             : }
    7678                 :             : 
    7679                 :             : 
    7680                 :             : /*
    7681                 :             :    IsRecordDependants - returns TRUE if the symbol, sym,
    7682                 :             :                         q(dependants) all return TRUE.
    7683                 :             : */
    7684                 :             : 
    7685                 :      518909 : static bool IsRecordDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7686                 :             : {
    7687                 :      518909 :   bool result;
    7688                 :      518909 :   unsigned int i;
    7689                 :      518909 :   unsigned int field;
    7690                 :             : 
    7691                 :      518909 :   result = IsRecordAlignment (sym, q);
    7692                 :      518909 :   i = 1;
    7693                 :     2722639 :   do {
    7694                 :     2722639 :     field = SymbolTable_GetNth (sym, i);
    7695                 :     2722639 :     if (field != SymbolTable_NulSym)
    7696                 :             :       {
    7697                 :             :         /* avoid gcc warning by using compound statement even if not strictly necessary.  */
    7698                 :     2203730 :         if (SymbolTable_IsRecordField (field))
    7699                 :             :           {
    7700                 :             :             /* avoid dangling else.  */
    7701                 :     2201900 :             if ((! (SymbolTable_IsRecordFieldAVarientTag (field))) || ((SymbolTable_GetSymName (field)) != NameKey_NulName))
    7702                 :             :               {
    7703                 :     2201726 :                 if (! ((*q.proc) (field)))
    7704                 :             :                   {
    7705                 :     1041510 :                     result = false;
    7706                 :             :                   }
    7707                 :             :               }
    7708                 :             :           }
    7709                 :        1830 :         else if (SymbolTable_IsVarient (field))
    7710                 :             :           {
    7711                 :             :             /* avoid dangling else.  */
    7712                 :        1830 :             if (! ((*q.proc) (field)))
    7713                 :             :               {
    7714                 :     1041510 :                 result = false;
    7715                 :             :               }
    7716                 :             :           }
    7717                 :           0 :         else if (SymbolTable_IsFieldVarient (field))
    7718                 :             :           {
    7719                 :             :             /* avoid dangling else.  */
    7720                 :           0 :             M2Error_InternalError ((const char *) "should not see a field varient", 30);
    7721                 :             :           }
    7722                 :             :         else
    7723                 :             :           {
    7724                 :             :             /* avoid dangling else.  */
    7725                 :           0 :             M2Error_InternalError ((const char *) "unknown symbol in record", 24);
    7726                 :             :           }
    7727                 :             :       }
    7728                 :     2722639 :     i += 1;
    7729                 :     2722639 :   } while (! (field == SymbolTable_NulSym));
    7730                 :      518909 :   return result;
    7731                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7732                 :             :   __builtin_unreachable ();
    7733                 :             : }
    7734                 :             : 
    7735                 :             : 
    7736                 :             : /*
    7737                 :             :    WalkRecordAlignment - walks the alignment constant associated with
    7738                 :             :                          record, sym.
    7739                 :             : */
    7740                 :             : 
    7741                 :     7283420 : static void WalkRecordAlignment (unsigned int sym, M2GCCDeclare_WalkAction p)
    7742                 :             : {
    7743                 :     7283420 :   if ((SymbolTable_GetDefaultRecordFieldAlignment (sym)) != SymbolTable_NulSym)
    7744                 :             :     {
    7745                 :         216 :       (*p.proc) (SymbolTable_GetDefaultRecordFieldAlignment (sym));
    7746                 :             :     }
    7747                 :     7283420 : }
    7748                 :             : 
    7749                 :             : 
    7750                 :             : /*
    7751                 :             :    WalkRecordDependants - walks symbol, sym, dependants.  It only
    7752                 :             :                           walks the fields if the alignment is
    7753                 :             :                           unused or fully declared.
    7754                 :             : */
    7755                 :             : 
    7756                 :     7283420 : static void WalkRecordDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7757                 :             : {
    7758                 :     7283420 :   WalkRecordAlignment (sym, p);
    7759                 :     7283420 :   WalkRecordDependants2 (sym, p);
    7760                 :     7283420 : }
    7761                 :             : 
    7762                 :             : 
    7763                 :             : /*
    7764                 :             :    WalkRecordFieldDependants -
    7765                 :             : */
    7766                 :             : 
    7767                 :    41307280 : static void WalkRecordFieldDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7768                 :             : {
    7769                 :    41307280 :   unsigned int v;
    7770                 :    41307280 :   unsigned int align;
    7771                 :             : 
    7772                 :    41307280 :   M2Debug_Assert (SymbolTable_IsRecordField (sym));
    7773                 :    41307280 :   (*p.proc) (SymbolTable_GetSType (sym));
    7774                 :    41307280 :   v = SymbolTable_GetVarient (sym);
    7775                 :    41307280 :   if (v != SymbolTable_NulSym)
    7776                 :             :     {
    7777                 :       25944 :       (*p.proc) (v);
    7778                 :             :     }
    7779                 :    41307280 :   align = SymbolTable_GetAlignment (sym);
    7780                 :    41307280 :   if (align != SymbolTable_NulSym)
    7781                 :             :     {
    7782                 :        1320 :       (*p.proc) (align);
    7783                 :             :     }
    7784                 :    41307280 : }
    7785                 :             : 
    7786                 :             : 
    7787                 :             : /*
    7788                 :             :    WalkRecordDependants2 - walks the fields of record, sym, calling
    7789                 :             :                            p on every dependant.
    7790                 :             : */
    7791                 :             : 
    7792                 :     7283420 : static void WalkRecordDependants2 (unsigned int sym, M2GCCDeclare_WalkAction p)
    7793                 :             : {
    7794                 :     7283420 :   unsigned int i;
    7795                 :     7283420 :   unsigned int Field;
    7796                 :             : 
    7797                 :     7283420 :   i = 1;
    7798                 :    29373032 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    7799                 :             :     {
    7800                 :    22089612 :       Field = SymbolTable_GetNth (sym, i);
    7801                 :    22089612 :       (*p.proc) (Field);
    7802                 :    22089612 :       if (SymbolTable_IsRecordField (Field))
    7803                 :             :         {
    7804                 :    22085544 :           WalkRecordFieldDependants (Field, p);
    7805                 :             :         }
    7806                 :        4068 :       else if (SymbolTable_IsVarient (Field))
    7807                 :             :         {
    7808                 :             :           /* avoid dangling else.  */
    7809                 :        4068 :           WalkVarientDependants (Field, p);
    7810                 :             :         }
    7811                 :           0 :       else if (SymbolTable_IsFieldVarient (Field))
    7812                 :             :         {
    7813                 :             :           /* avoid dangling else.  */
    7814                 :           0 :           M2Error_InternalError ((const char *) "should not see a field varient", 30);
    7815                 :             :         }
    7816                 :             :       else
    7817                 :             :         {
    7818                 :             :           /* avoid dangling else.  */
    7819                 :           0 :           M2Error_InternalError ((const char *) "unknown symbol in record", 24);
    7820                 :             :         }
    7821                 :    22089612 :       i += 1;
    7822                 :             :     }
    7823                 :     7283420 : }
    7824                 :             : 
    7825                 :             : 
    7826                 :             : /*
    7827                 :             :    IsVarientAlignment -
    7828                 :             : */
    7829                 :             : 
    7830                 :        5844 : static bool IsVarientAlignment (unsigned int sym, M2GCCDeclare_IsAction q)
    7831                 :             : {
    7832                 :        5844 :   unsigned int align;
    7833                 :             : 
    7834                 :        5844 :   sym = GetRecordOfVarient (sym);
    7835                 :        5844 :   align = SymbolTable_GetDefaultRecordFieldAlignment (sym);
    7836                 :        5844 :   if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
    7837                 :             :     {
    7838                 :             :       return false;
    7839                 :             :     }
    7840                 :             :   return true;
    7841                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7842                 :             :   __builtin_unreachable ();
    7843                 :             : }
    7844                 :             : 
    7845                 :             : 
    7846                 :             : /*
    7847                 :             :    IsVarientDependants - returns TRUE if the symbol, sym,
    7848                 :             :                          q(dependants) all return TRUE.
    7849                 :             : */
    7850                 :             : 
    7851                 :        2190 : static bool IsVarientDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7852                 :             : {
    7853                 :        2190 :   bool result;
    7854                 :        2190 :   unsigned int i;
    7855                 :        2190 :   unsigned int Field;
    7856                 :             : 
    7857                 :        2190 :   result = IsVarientAlignment (sym, q);
    7858                 :        2190 :   i = 1;
    7859                 :        9618 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    7860                 :             :     {
    7861                 :        5238 :       Field = SymbolTable_GetNth (sym, i);
    7862                 :        5238 :       M2Debug_Assert (SymbolTable_IsFieldVarient (Field));
    7863                 :        5238 :       if (! ((*q.proc) (Field)))
    7864                 :             :         {
    7865                 :        3654 :           result = false;
    7866                 :             :         }
    7867                 :        5238 :       i += 1;
    7868                 :             :     }
    7869                 :        2190 :   return result;
    7870                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7871                 :             :   __builtin_unreachable ();
    7872                 :             : }
    7873                 :             : 
    7874                 :             : 
    7875                 :             : /*
    7876                 :             :    WalkVarientAlignment -
    7877                 :             : */
    7878                 :             : 
    7879                 :       59406 : static void WalkVarientAlignment (unsigned int sym, M2GCCDeclare_WalkAction p)
    7880                 :             : {
    7881                 :       59406 :   unsigned int align;
    7882                 :             : 
    7883                 :       59406 :   sym = GetRecordOfVarient (sym);
    7884                 :       59406 :   align = SymbolTable_GetDefaultRecordFieldAlignment (sym);
    7885                 :       59406 :   if (align != SymbolTable_NulSym)
    7886                 :             :     {
    7887                 :           0 :       (*p.proc) (align);
    7888                 :             :     }
    7889                 :       59406 : }
    7890                 :             : 
    7891                 :             : 
    7892                 :             : /*
    7893                 :             :    WalkVarientDependants - walks symbol, sym, dependants.
    7894                 :             : */
    7895                 :             : 
    7896                 :       11412 : static void WalkVarientDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7897                 :             : {
    7898                 :       11412 :   unsigned int i;
    7899                 :       11412 :   unsigned int v;
    7900                 :       11412 :   unsigned int Field;
    7901                 :             : 
    7902                 :       11412 :   WalkVarientAlignment (sym, p);
    7903                 :       11412 :   if ((SymbolTable_GetSType (sym)) != SymbolTable_NulSym)
    7904                 :             :     {
    7905                 :           0 :       (*p.proc) (SymbolTable_GetSType (sym));
    7906                 :             :     }
    7907                 :       11412 :   v = SymbolTable_GetVarient (sym);
    7908                 :       11412 :   if (v != SymbolTable_NulSym)
    7909                 :             :     {
    7910                 :        1104 :       (*p.proc) (v);
    7911                 :             :     }
    7912                 :             :   i = 1;
    7913                 :       40578 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    7914                 :             :     {
    7915                 :       29166 :       Field = SymbolTable_GetNth (sym, i);
    7916                 :       29166 :       M2Debug_Assert (SymbolTable_IsFieldVarient (Field));  /* field varients do _not_ have a type  */
    7917                 :       29166 :       (*p.proc) (Field);  /* field varients do _not_ have a type  */
    7918                 :       29166 :       WalkVarientFieldDependants (Field, p);
    7919                 :       29166 :       i += 1;
    7920                 :             :     }
    7921                 :       11412 : }
    7922                 :             : 
    7923                 :             : 
    7924                 :             : /*
    7925                 :             :    IsVarientFieldDependants - returns TRUE if the symbol, sym,
    7926                 :             :                               q(dependants) all return TRUE.
    7927                 :             : */
    7928                 :             : 
    7929                 :        3654 : static bool IsVarientFieldDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7930                 :             : {
    7931                 :        3654 :   unsigned int i;
    7932                 :        3654 :   unsigned int type;
    7933                 :        3654 :   unsigned int Field;
    7934                 :        3654 :   bool result;
    7935                 :             : 
    7936                 :        3654 :   i = 1;
    7937                 :        3654 :   result = IsVarientAlignment (sym, q);
    7938                 :       11766 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    7939                 :             :     {
    7940                 :        4458 :       Field = SymbolTable_GetNth (sym, i);
    7941                 :        4458 :       if (! ((*q.proc) (Field)))
    7942                 :             :         {
    7943                 :        3546 :           result = false;
    7944                 :             :         }
    7945                 :        4458 :       type = SymbolTable_GetSType (Field);
    7946                 :        4458 :       if (type != SymbolTable_NulSym)
    7947                 :             :         {
    7948                 :        4182 :           if (! ((*q.proc) (type)))
    7949                 :             :             {
    7950                 :        4458 :               result = false;
    7951                 :             :             }
    7952                 :             :         }
    7953                 :        4458 :       i += 1;
    7954                 :             :     }
    7955                 :        3654 :   return result;
    7956                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    7957                 :             :   __builtin_unreachable ();
    7958                 :             : }
    7959                 :             : 
    7960                 :             : 
    7961                 :             : /*
    7962                 :             :    WalkVarientFieldDependants -
    7963                 :             : */
    7964                 :             : 
    7965                 :       47994 : static void WalkVarientFieldDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    7966                 :             : {
    7967                 :       47994 :   unsigned int i;
    7968                 :       47994 :   unsigned int type;
    7969                 :       47994 :   unsigned int Field;
    7970                 :             : 
    7971                 :       47994 :   WalkVarientAlignment (sym, p);
    7972                 :       47994 :   i = 1;
    7973                 :      145500 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    7974                 :             :     {
    7975                 :       49512 :       Field = SymbolTable_GetNth (sym, i);
    7976                 :       49512 :       (*p.proc) (Field);
    7977                 :       49512 :       type = SymbolTable_GetSType (Field);
    7978                 :       49512 :       if (type != SymbolTable_NulSym)
    7979                 :             :         {
    7980                 :       46836 :           (*p.proc) (type);
    7981                 :             :         }
    7982                 :       49512 :       i += 1;
    7983                 :             :     }
    7984                 :       47994 : }
    7985                 :             : 
    7986                 :             : 
    7987                 :             : /*
    7988                 :             :    IsArrayDependants - returns TRUE if the symbol, sym,
    7989                 :             :                        q(dependants) all return TRUE.
    7990                 :             : 
    7991                 :             : */
    7992                 :             : 
    7993                 :      113622 : static bool IsArrayDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    7994                 :             : {
    7995                 :      113622 :   bool result;
    7996                 :      113622 :   unsigned int align;
    7997                 :      113622 :   unsigned int subscript;
    7998                 :      113622 :   unsigned int high;
    7999                 :      113622 :   unsigned int low;
    8000                 :      113622 :   unsigned int type;
    8001                 :             : 
    8002                 :      113622 :   result = true;
    8003                 :      113622 :   M2Debug_Assert (SymbolTable_IsArray (sym));
    8004                 :      113622 :   type = SymbolTable_GetSType (sym);
    8005                 :      113622 :   if (! ((*q.proc) (type)))
    8006                 :             :     {
    8007                 :             :       result = false;
    8008                 :             :     }
    8009                 :      113622 :   subscript = SymbolTable_GetArraySubscript (sym);
    8010                 :      113622 :   if (subscript != SymbolTable_NulSym)
    8011                 :             :     {
    8012                 :      113622 :       M2Debug_Assert (SymbolTable_IsSubscript (subscript));
    8013                 :      113622 :       type = SymbolTable_GetSType (subscript);
    8014                 :      113622 :       if (! ((*q.proc) (type)))
    8015                 :             :         {
    8016                 :       48900 :           result = false;
    8017                 :             :         }
    8018                 :      113622 :       type = SymbolTable_SkipType (type);
    8019                 :             :       /* the array might be declared as ARRAY type OF foo  */
    8020                 :      113622 :       low = M2GCCDeclare_GetTypeMin (type);
    8021                 :      113622 :       high = M2GCCDeclare_GetTypeMax (type);
    8022                 :      113622 :       if (! ((*q.proc) (low)))
    8023                 :             :         {
    8024                 :       23078 :           result = false;
    8025                 :             :         }
    8026                 :      113622 :       if (! ((*q.proc) (high)))
    8027                 :             :         {
    8028                 :        7438 :           result = false;
    8029                 :             :         }
    8030                 :      113622 :       align = SymbolTable_GetAlignment (sym);
    8031                 :      113622 :       if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
    8032                 :             :         {
    8033                 :             :           result = false;
    8034                 :             :         }
    8035                 :             :     }
    8036                 :      113622 :   return result;
    8037                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8038                 :             :   __builtin_unreachable ();
    8039                 :             : }
    8040                 :             : 
    8041                 :             : 
    8042                 :             : /*
    8043                 :             :    WalkArrayDependants - walks symbol, sym, dependants.
    8044                 :             : */
    8045                 :             : 
    8046                 :      678850 : static void WalkArrayDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    8047                 :             : {
    8048                 :      678850 :   unsigned int align;
    8049                 :      678850 :   unsigned int subscript;
    8050                 :      678850 :   unsigned int high;
    8051                 :      678850 :   unsigned int low;
    8052                 :      678850 :   unsigned int type;
    8053                 :             : 
    8054                 :      678850 :   M2Debug_Assert (SymbolTable_IsArray (sym));
    8055                 :      678850 :   type = SymbolTable_GetSType (sym);
    8056                 :      678850 :   (*p.proc) (type);
    8057                 :      678850 :   subscript = SymbolTable_GetArraySubscript (sym);
    8058                 :      678850 :   if (subscript != SymbolTable_NulSym)
    8059                 :             :     {
    8060                 :      678850 :       M2Debug_Assert (SymbolTable_IsSubscript (subscript));
    8061                 :      678850 :       type = SymbolTable_GetSType (subscript);
    8062                 :      678850 :       (*p.proc) (type);
    8063                 :      678850 :       type = SymbolTable_SkipType (type);
    8064                 :             :       /* the array might be declared as ARRAY type OF foo  */
    8065                 :      678850 :       low = M2GCCDeclare_GetTypeMin (type);
    8066                 :      678850 :       high = M2GCCDeclare_GetTypeMax (type);
    8067                 :      678850 :       (*p.proc) (low);
    8068                 :      678850 :       (*p.proc) (high);
    8069                 :      678850 :       align = SymbolTable_GetAlignment (sym);
    8070                 :      678850 :       if (align != SymbolTable_NulSym)
    8071                 :             :         {
    8072                 :          42 :           (*p.proc) (align);
    8073                 :             :         }
    8074                 :             :     }
    8075                 :      678850 : }
    8076                 :             : 
    8077                 :             : 
    8078                 :             : /*
    8079                 :             :    IsSetDependants - returns TRUE if the symbol, sym,
    8080                 :             :                      q(dependants) all return TRUE.
    8081                 :             : */
    8082                 :             : 
    8083                 :       21628 : static bool IsSetDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    8084                 :             : {
    8085                 :       21628 :   bool result;
    8086                 :       21628 :   unsigned int type;
    8087                 :       21628 :   unsigned int low;
    8088                 :       21628 :   unsigned int high;
    8089                 :             : 
    8090                 :       21628 :   result = true;
    8091                 :       21628 :   M2Debug_Assert (SymbolTable_IsSet (sym));
    8092                 :       21628 :   type = SymbolTable_GetDType (sym);
    8093                 :       21628 :   if (! ((*q.proc) (type)))
    8094                 :             :     {
    8095                 :             :       result = false;
    8096                 :             :     }
    8097                 :       21628 :   low = M2GCCDeclare_GetTypeMin (type);
    8098                 :       21628 :   high = M2GCCDeclare_GetTypeMax (type);
    8099                 :       21628 :   if (! ((*q.proc) (low)))
    8100                 :             :     {
    8101                 :        1024 :       result = false;
    8102                 :             :     }
    8103                 :       21628 :   if (! ((*q.proc) (high)))
    8104                 :             :     {
    8105                 :         656 :       result = false;
    8106                 :             :     }
    8107                 :       21628 :   return result;
    8108                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8109                 :             :   __builtin_unreachable ();
    8110                 :             : }
    8111                 :             : 
    8112                 :             : 
    8113                 :             : /*
    8114                 :             :    WalkSetDependants - walks dependants, sym.
    8115                 :             : */
    8116                 :             : 
    8117                 :     1184596 : static void WalkSetDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    8118                 :             : {
    8119                 :     1184596 :   unsigned int type;
    8120                 :     1184596 :   unsigned int low;
    8121                 :     1184596 :   unsigned int high;
    8122                 :             : 
    8123                 :     1184596 :   M2Debug_Assert (SymbolTable_IsSet (sym));
    8124                 :     1184596 :   type = SymbolTable_GetDType (sym);
    8125                 :     1184596 :   (*p.proc) (type);
    8126                 :     1184596 :   low = M2GCCDeclare_GetTypeMin (type);
    8127                 :     1184596 :   (*p.proc) (low);
    8128                 :     1184596 :   high = M2GCCDeclare_GetTypeMax (type);
    8129                 :     1184596 :   (*p.proc) (high);
    8130                 :     1184596 : }
    8131                 :             : 
    8132                 :             : 
    8133                 :             : /*
    8134                 :             :    IsProcTypeDependants -
    8135                 :             : */
    8136                 :             : 
    8137                 :      211642 : static bool IsProcTypeDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    8138                 :             : {
    8139                 :      211642 :   unsigned int i;
    8140                 :      211642 :   unsigned int p;
    8141                 :      211642 :   unsigned int son;
    8142                 :      211642 :   unsigned int ParamType;
    8143                 :      211642 :   unsigned int ReturnType;
    8144                 :      211642 :   bool result;
    8145                 :             : 
    8146                 :      211642 :   result = true;
    8147                 :      211642 :   M2Debug_Assert (SymbolTable_IsProcType (sym));
    8148                 :      211642 :   i = 1;
    8149                 :      211642 :   ReturnType = SymbolTable_GetSType (sym);
    8150                 :      211642 :   p = SymbolTable_NoOfParamAny (sym);
    8151                 :      631303 :   while (i <= p)
    8152                 :             :     {
    8153                 :      208019 :       son = SymbolTable_GetNthParamAny (sym, i);
    8154                 :      208019 :       ParamType = SymbolTable_GetSType (son);
    8155                 :      208019 :       if (! ((*q.proc) (ParamType)))
    8156                 :             :         {
    8157                 :       69148 :           result = false;
    8158                 :             :         }
    8159                 :      208019 :       i += 1;
    8160                 :             :     }
    8161                 :      211642 :   if ((ReturnType == SymbolTable_NulSym) || ((*q.proc) (ReturnType)))
    8162                 :             :     {
    8163                 :      211642 :       return result;
    8164                 :             :     }
    8165                 :             :   else
    8166                 :             :     {
    8167                 :             :       return false;
    8168                 :             :     }
    8169                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8170                 :             :   __builtin_unreachable ();
    8171                 :             : }
    8172                 :             : 
    8173                 :             : 
    8174                 :             : /*
    8175                 :             :    WalkProcTypeDependants - walks dependants, sym.
    8176                 :             : */
    8177                 :             : 
    8178                 :     2331832 : static void WalkProcTypeDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    8179                 :             : {
    8180                 :     2331832 :   unsigned int i;
    8181                 :     2331832 :   unsigned int n;
    8182                 :     2331832 :   unsigned int son;
    8183                 :     2331832 :   unsigned int ParamType;
    8184                 :     2331832 :   unsigned int ReturnType;
    8185                 :             : 
    8186                 :     2331832 :   M2Debug_Assert (SymbolTable_IsProcType (sym));
    8187                 :     2331832 :   i = 1;
    8188                 :     2331832 :   ReturnType = SymbolTable_GetSType (sym);
    8189                 :     2331832 :   n = SymbolTable_NoOfParamAny (sym);
    8190                 :     8711776 :   while (i <= n)
    8191                 :             :     {
    8192                 :     4048112 :       son = SymbolTable_GetNthParamAny (sym, i);
    8193                 :     4048112 :       ParamType = SymbolTable_GetSType (son);
    8194                 :     4048112 :       (*p.proc) (ParamType);
    8195                 :     4048112 :       i += 1;
    8196                 :             :     }
    8197                 :     2331832 :   if (ReturnType != SymbolTable_NulSym)
    8198                 :             :     {
    8199                 :      305432 :       (*p.proc) (ReturnType);
    8200                 :             :     }
    8201                 :     2331832 : }
    8202                 :             : 
    8203                 :             : 
    8204                 :             : /*
    8205                 :             :    IsProcedureDependants -
    8206                 :             : */
    8207                 :             : 
    8208                 :         426 : static bool IsProcedureDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    8209                 :             : {
    8210                 :         426 :   unsigned int i;
    8211                 :         426 :   unsigned int son;
    8212                 :         426 :   unsigned int type;
    8213                 :         426 :   unsigned int ReturnType;
    8214                 :         426 :   bool result;
    8215                 :             : 
    8216                 :         426 :   result = true;
    8217                 :         426 :   M2Debug_Assert (SymbolTable_IsProcedure (sym));
    8218                 :         426 :   i = 1;
    8219                 :         426 :   ReturnType = SymbolTable_GetSType (sym);
    8220                 :        1434 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    8221                 :             :     {
    8222                 :         582 :       son = SymbolTable_GetNth (sym, i);
    8223                 :         582 :       type = SymbolTable_GetSType (son);
    8224                 :         582 :       if (! ((*q.proc) (type)))
    8225                 :             :         {
    8226                 :          36 :           result = false;
    8227                 :             :         }
    8228                 :         582 :       i += 1;
    8229                 :             :     }
    8230                 :         426 :   if ((ReturnType == SymbolTable_NulSym) || ((*q.proc) (ReturnType)))
    8231                 :             :     {
    8232                 :         426 :       return result;
    8233                 :             :     }
    8234                 :             :   else
    8235                 :             :     {
    8236                 :             :       return false;
    8237                 :             :     }
    8238                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8239                 :             :   __builtin_unreachable ();
    8240                 :             : }
    8241                 :             : 
    8242                 :             : 
    8243                 :             : /*
    8244                 :             :    WalkProcedureDependants - walks dependants, sym.
    8245                 :             : */
    8246                 :             : 
    8247                 :         408 : static void WalkProcedureDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    8248                 :             : {
    8249                 :         408 :   unsigned int i;
    8250                 :         408 :   unsigned int son;
    8251                 :         408 :   unsigned int type;
    8252                 :         408 :   unsigned int ReturnType;
    8253                 :             : 
    8254                 :         408 :   M2Debug_Assert (SymbolTable_IsProcedure (sym));
    8255                 :         408 :   i = 1;
    8256                 :         408 :   ReturnType = SymbolTable_GetSType (sym);
    8257                 :        1362 :   while ((SymbolTable_GetNth (sym, i)) != SymbolTable_NulSym)
    8258                 :             :     {
    8259                 :         546 :       son = SymbolTable_GetNth (sym, i);
    8260                 :         546 :       type = SymbolTable_GetSType (son);
    8261                 :         546 :       (*p.proc) (type);
    8262                 :         546 :       i += 1;
    8263                 :             :     }
    8264                 :         408 :   if (ReturnType != SymbolTable_NulSym)
    8265                 :             :     {
    8266                 :          42 :       (*p.proc) (ReturnType);
    8267                 :             :     }
    8268                 :         408 : }
    8269                 :             : 
    8270                 :             : 
    8271                 :             : /*
    8272                 :             :    IsUnboundedDependants - returns TRUE if the symbol, sym,
    8273                 :             :                            q(dependants) all return TRUE.
    8274                 :             : */
    8275                 :             : 
    8276                 :      204648 : static bool IsUnboundedDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    8277                 :             : {
    8278                 :      204648 :   bool result;
    8279                 :             : 
    8280                 :      204648 :   result = true;
    8281                 :      204648 :   if (! ((*q.proc) (SymbolTable_GetUnboundedRecordType (sym))))
    8282                 :             :     {
    8283                 :             :       result = false;
    8284                 :             :     }
    8285                 :      204648 :   if (! ((*q.proc) (M2Base_Cardinal)))
    8286                 :             :     {
    8287                 :           0 :       result = false;
    8288                 :             :     }
    8289                 :      204648 :   if (! ((*q.proc) (SymbolTable_GetSType (sym))))
    8290                 :             :     {
    8291                 :          54 :       result = false;
    8292                 :             :     }
    8293                 :      204648 :   return result;
    8294                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8295                 :             :   __builtin_unreachable ();
    8296                 :             : }
    8297                 :             : 
    8298                 :             : 
    8299                 :             : /*
    8300                 :             :    WalkUnboundedDependants - walks the dependants of, sym.
    8301                 :             : */
    8302                 :             : 
    8303                 :     4602096 : static void WalkUnboundedDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    8304                 :             : {
    8305                 :     4602096 :   (*p.proc) (SymbolTable_GetUnboundedRecordType (sym));
    8306                 :     4602096 :   (*p.proc) (M2Base_Cardinal);
    8307                 :     4602096 :   (*p.proc) (SymbolTable_GetSType (sym));
    8308                 :     4602096 : }
    8309                 :             : 
    8310                 :             : 
    8311                 :             : /*
    8312                 :             :    IsTypeDependants - returns TRUE if all q(dependants) return
    8313                 :             :                       TRUE.
    8314                 :             : */
    8315                 :             : 
    8316                 :      506160 : static bool IsTypeDependants (unsigned int sym, M2GCCDeclare_IsAction q)
    8317                 :             : {
    8318                 :      506160 :   unsigned int align;
    8319                 :      506160 :   unsigned int type;
    8320                 :      506160 :   bool final;
    8321                 :             : 
    8322                 :      506160 :   type = SymbolTable_GetSType (sym);
    8323                 :      506160 :   final = true;
    8324                 :      506160 :   if ((type != SymbolTable_NulSym) && (! ((*q.proc) (type))))
    8325                 :             :     {
    8326                 :             :       final = false;
    8327                 :             :     }
    8328                 :      506160 :   align = SymbolTable_GetAlignment (sym);
    8329                 :      506160 :   if ((align != SymbolTable_NulSym) && (! ((*q.proc) (align))))
    8330                 :             :     {
    8331                 :             :       final = false;
    8332                 :             :     }
    8333                 :      506160 :   return final;
    8334                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8335                 :             :   __builtin_unreachable ();
    8336                 :             : }
    8337                 :             : 
    8338                 :             : 
    8339                 :             : /*
    8340                 :             :    WalkTypeDependants - walks all dependants of, sym.
    8341                 :             : */
    8342                 :             : 
    8343                 :    22754069 : static void WalkTypeDependants (unsigned int sym, M2GCCDeclare_WalkAction p)
    8344                 :             : {
    8345                 :    22754069 :   unsigned int align;
    8346                 :    22754069 :   unsigned int type;
    8347                 :             : 
    8348                 :    22754069 :   type = SymbolTable_GetSType (sym);
    8349                 :    22754069 :   if (type != SymbolTable_NulSym)
    8350                 :             :     {
    8351                 :      890856 :       (*p.proc) (type);
    8352                 :             :     }
    8353                 :    22754069 :   align = SymbolTable_GetAlignment (sym);
    8354                 :    22754069 :   if (align != SymbolTable_NulSym)
    8355                 :             :     {
    8356                 :          36 :       (*p.proc) (align);
    8357                 :             :     }
    8358                 :    22754069 : }
    8359                 :             : 
    8360                 :             : 
    8361                 :             : /*
    8362                 :             :    FoldConstants - a wrapper for ResolveConstantExpressions.
    8363                 :             : */
    8364                 :             : 
    8365                 :    52516275 : extern "C" void M2GCCDeclare_FoldConstants (M2BasicBlock_BasicBlock bb)
    8366                 :             : {
    8367                 :    52516275 :   if (M2GenGCC_ResolveConstantExpressions ((M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) DeclareConstFully}, bb))
    8368                 :             :     {
    8369                 :      125201 :       ConstantResolved = true;
    8370                 :             :     }
    8371                 :    52516101 : }
    8372                 :             : 
    8373                 :             : 
    8374                 :             : /*
    8375                 :             :    StartDeclareScope - declares types, variables associated with this scope.
    8376                 :             : */
    8377                 :             : 
    8378                 :       84233 : extern "C" void M2GCCDeclare_StartDeclareScope (unsigned int scope)
    8379                 :             : {
    8380                 :       84233 :   NameKey_Name n;
    8381                 :             : 
    8382                 :       84233 :   if (Debugging)
    8383                 :             :     {
    8384                 :             :       n = SymbolTable_GetSymName (scope);
    8385                 :             :       M2Printf_printf1 ((const char *) "declaring symbols in BLOCK %a\\n", 31, (const unsigned char *) &n, (sizeof (n)-1));
    8386                 :             :     }
    8387                 :       84233 :   if (SymbolTable_IsProcedure (scope))
    8388                 :             :     {
    8389                 :       69112 :       StartDeclareProcedureScope (scope);
    8390                 :             :     }
    8391                 :             :   else
    8392                 :             :     {
    8393                 :       15121 :       StartDeclareModuleScope (scope);
    8394                 :             :     }
    8395                 :       84167 :   if (Debugging)
    8396                 :             :     {
    8397                 :             :       n = SymbolTable_GetSymName (scope);
    8398                 :             :       M2Printf_printf1 ((const char *) "\\nEND declaring symbols in BLOCK %a\\n", 37, (const unsigned char *) &n, (sizeof (n)-1));
    8399                 :             :     }
    8400                 :       84167 : }
    8401                 :             : 
    8402                 :             : 
    8403                 :             : /*
    8404                 :             :    EndDeclareScope -
    8405                 :             : */
    8406                 :             : 
    8407                 :           0 : extern "C" void M2GCCDeclare_EndDeclareScope (void)
    8408                 :             : {
    8409                 :           0 : }
    8410                 :             : 
    8411                 :             : 
    8412                 :             : /*
    8413                 :             :    DeclareParameters -
    8414                 :             : */
    8415                 :             : 
    8416                 :      182906 : extern "C" void M2GCCDeclare_DeclareParameters (unsigned int sym)
    8417                 :             : {
    8418                 :      182906 :   DeclareUnboundedProcedureParameters (sym);
    8419                 :      182906 : }
    8420                 :             : 
    8421                 :             : 
    8422                 :             : /*
    8423                 :             :    DeclareConstant - checks to see whether, sym, is a constant and
    8424                 :             :                      declares the constant to gcc.
    8425                 :             : */
    8426                 :             : 
    8427                 :     1546405 : extern "C" void M2GCCDeclare_DeclareConstant (unsigned int tokenno, unsigned int sym)
    8428                 :             : {
    8429                 :     1546405 :   unsigned int type;
    8430                 :     1546405 :   tree t;
    8431                 :             : 
    8432                 :     1546405 :   if (SymbolTable_IsConst (sym))
    8433                 :             :     {
    8434                 :      754194 :       TraverseDependants (sym);
    8435                 :      754194 :       type = SymbolTable_GetSType (sym);
    8436                 :     1508388 :       M2Debug_Assert ((type == SymbolTable_NulSym) || (M2GCCDeclare_CompletelyResolved (type)));
    8437                 :     1508388 :       M2Debug_Assert ((! (SymbolTable_IsConstructor (sym))) || (SymbolTable_IsConstructorConstant (sym)));
    8438                 :     1508388 :       M2Debug_Assert ((type != SymbolTable_NulSym) || (! ((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym)))));
    8439                 :      754194 :       t = DeclareConst (tokenno, sym);
    8440                 :      754194 :       M2Debug_Assert (t != NULL);
    8441                 :             :     }
    8442                 :     1546405 : }
    8443                 :             : 
    8444                 :             : 
    8445                 :             : /*
    8446                 :             :    DeclareConstructor - declares a constructor.
    8447                 :             : */
    8448                 :             : 
    8449                 :     1283608 : extern "C" void M2GCCDeclare_DeclareConstructor (unsigned int tokenno, unsigned int quad, unsigned int sym)
    8450                 :             : {
    8451                 :     1283608 :   if (sym == SymbolTable_NulSym)
    8452                 :             :     {
    8453                 :           0 :       M2Error_InternalError ((const char *) "trying to declare the NulSym", 28);
    8454                 :             :     }
    8455                 :     1283608 :   if ((SymbolTable_IsConstructor (sym)) && (! (SymbolConversion_GccKnowsAbout (sym))))
    8456                 :             :     {
    8457                 :           0 :       WalkConstructor (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
    8458                 :           0 :       DeclareTypesConstantsProceduresInRange (SymbolTable_GetScope (sym), quad, quad);
    8459                 :           0 :       M2Debug_Assert (M2ALU_IsConstructorDependants (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared}));
    8460                 :           0 :       SymbolTable_PushValue (sym);
    8461                 :           0 :       DeclareConstantFromTree (sym, M2ALU_PopConstructorTree (tokenno));
    8462                 :             :     }
    8463                 :     1283608 : }
    8464                 :             : 
    8465                 :             : 
    8466                 :             : /*
    8467                 :             :    TryDeclareConstant - try and declare a constant.  If, sym, is a
    8468                 :             :                         constant try and declare it, if we cannot
    8469                 :             :                         then enter it into the to do list.
    8470                 :             : */
    8471                 :             : 
    8472                 :    28184278 : extern "C" void M2GCCDeclare_TryDeclareConstant (unsigned int tokenno, unsigned int sym)
    8473                 :             : {
    8474                 :    28184278 :   unsigned int type;
    8475                 :             : 
    8476                 :    28184278 :   M2GCCDeclare_TryDeclareConstructor (tokenno, sym);
    8477                 :    28184272 :   if (SymbolTable_IsConst (sym))
    8478                 :             :     {
    8479                 :     8206090 :       TraverseDependants (sym);
    8480                 :     8206090 :       type = SymbolTable_GetSType (sym);
    8481                 :     8206090 :       if ((type != SymbolTable_NulSym) && (! (M2GCCDeclare_CompletelyResolved (type))))
    8482                 :             :         {
    8483                 :       34400 :           TraverseDependants (sym);
    8484                 :       34400 :           return;
    8485                 :             :         }
    8486                 :     8171690 :       if ((SymbolTable_IsConstructor (sym)) && (! (SymbolTable_IsConstructorConstant (sym))))
    8487                 :             :         {
    8488                 :           0 :           TraverseDependants (sym);
    8489                 :           0 :           return;
    8490                 :             :         }
    8491                 :     8171690 :       if (((SymbolTable_IsConstructor (sym)) || (SymbolTable_IsConstSet (sym))) && (type == SymbolTable_NulSym))
    8492                 :             :         {
    8493                 :         378 :           TraverseDependants (sym);
    8494                 :         378 :           return;
    8495                 :             :         }
    8496                 :     8171312 :       if (Sets_IsElementInSet (GlobalGroup->ToBeSolvedByQuads, sym))
    8497                 :             :         {
    8498                 :             :           /* we allow the above rules to be executed even if it is fully declared
    8499                 :             :             so to ensure that types of compiler builtin constants (BitsetSize
    8500                 :             :             etc) are fully declared.
    8501                 :             : 
    8502                 :             :             However at this point if, sym, is fully declared we return
    8503                 :             :   */
    8504                 :      284110 :           if (IsFullyDeclared (sym))
    8505                 :             :             {
    8506                 :             :               return;
    8507                 :             :             }
    8508                 :      284080 :           TraverseDependants (sym);
    8509                 :             :         }
    8510                 :             :       else
    8511                 :             :         {
    8512                 :     7887202 :           TryDeclareConst (tokenno, sym);
    8513                 :             :         }
    8514                 :             :     }
    8515                 :             : }
    8516                 :             : 
    8517                 :             : 
    8518                 :             : /*
    8519                 :             :    TryDeclareType - try and declare a type.  If sym is a
    8520                 :             :                     type try and declare it, if we cannot
    8521                 :             :                     then enter it into the to do list.
    8522                 :             : */
    8523                 :             : 
    8524                 :          60 : extern "C" void M2GCCDeclare_TryDeclareType (unsigned int type)
    8525                 :             : {
    8526                 :          60 :   if ((type != SymbolTable_NulSym) && (IsAnyType (type)))
    8527                 :             :     {
    8528                 :           0 :       TraverseDependants (type);
    8529                 :             :     }
    8530                 :          60 : }
    8531                 :             : 
    8532                 :             : 
    8533                 :             : /*
    8534                 :             :    TryDeclareConstructor - try and declare a constructor.  If, sym, is a
    8535                 :             :                            constructor try and declare it, if we cannot
    8536                 :             :                            then enter it into the to do list.
    8537                 :             : */
    8538                 :             : 
    8539                 :    31808839 : extern "C" void M2GCCDeclare_TryDeclareConstructor (unsigned int tokenno, unsigned int sym)
    8540                 :             : {
    8541                 :    31808839 :   if (sym != SymbolTable_NulSym)
    8542                 :             :     {
    8543                 :    31808839 :       if ((SymbolTable_IsConstructor (sym)) && (! (SymbolConversion_GccKnowsAbout (sym))))
    8544                 :             :         {
    8545                 :       54094 :           WalkConstructor (sym, (M2GCCDeclare_WalkAction) {(M2GCCDeclare_WalkAction_t) TraverseDependants});
    8546                 :       54094 :           if (! (Sets_IsElementInSet (GlobalGroup->ToBeSolvedByQuads, sym)))
    8547                 :             :             {
    8548                 :       42520 :               M2ALU_TryEvaluateValue (sym);
    8549                 :       42514 :               if (M2ALU_IsConstructorDependants (sym, (M2GCCDeclare_IsAction) {(M2GCCDeclare_IsAction_t) IsFullyDeclared}))
    8550                 :             :                 {
    8551                 :        6324 :                   SymbolTable_PushValue (sym);
    8552                 :        6324 :                   DeclareConstantFromTree (sym, M2ALU_PopConstructorTree (tokenno));
    8553                 :             :                 }
    8554                 :             :             }
    8555                 :             :         }
    8556                 :             :     }
    8557                 :    31808833 : }
    8558                 :             : 
    8559                 :             : 
    8560                 :             : /*
    8561                 :             :    DeclareLocalVariables - declares Local variables for procedure.
    8562                 :             : */
    8563                 :             : 
    8564                 :       69112 : extern "C" void M2GCCDeclare_DeclareLocalVariables (unsigned int procedure)
    8565                 :             : {
    8566                 :       69112 :   unsigned int i;
    8567                 :       69112 :   unsigned int var;
    8568                 :             : 
    8569                 :       69112 :   i = (SymbolTable_NoOfParamAny (procedure))+1;
    8570                 :       69112 :   var = SymbolTable_GetNth (procedure, i);
    8571                 :      707905 :   while (var != SymbolTable_NulSym)
    8572                 :             :     {
    8573                 :      569681 :       M2Debug_Assert (procedure == (SymbolTable_GetScope (var)));
    8574                 :      569681 :       M2GCCDeclare_DeclareLocalVariable (var);
    8575                 :      569681 :       i += 1;
    8576                 :      569681 :       var = SymbolTable_GetNth (procedure, i);
    8577                 :             :     }
    8578                 :       69112 : }
    8579                 :             : 
    8580                 :             : 
    8581                 :             : /*
    8582                 :             :    DeclareLocalVariable - declare a local variable var.
    8583                 :             : */
    8584                 :             : 
    8585                 :      569681 : extern "C" void M2GCCDeclare_DeclareLocalVariable (unsigned int var)
    8586                 :             : {
    8587                 :      569681 :   DoVariableDeclaration (var, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (var)), false, false, SymbolTable_IsTemporary (var), false, SymbolConversion_Mod2Gcc (SymbolTable_GetScope (var)));  /* and are not global  */
    8588                 :      569681 : }
    8589                 :             : 
    8590                 :             : 
    8591                 :             : /*
    8592                 :             :    DeclareProcedure - declares procedure, sym, or all procedures inside
    8593                 :             :                       module sym.
    8594                 :             : */
    8595                 :             : 
    8596                 :     3930882 : extern "C" void M2GCCDeclare_DeclareProcedure (unsigned int sym)
    8597                 :             : {
    8598                 :     3930882 :   if (SymbolTable_IsProcedure (sym))
    8599                 :             :     {
    8600                 :     3764561 :       DeclareProcedureToGcc (sym);
    8601                 :             :     }
    8602                 :      166321 :   else if ((SymbolTable_IsModule (sym)) || (SymbolTable_IsDefImp (sym)))
    8603                 :             :     {
    8604                 :             :       /* avoid dangling else.  */
    8605                 :      166321 :       SymbolTable_ForeachProcedureDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_DeclareProcedure});
    8606                 :             :     }
    8607                 :             :   else
    8608                 :             :     {
    8609                 :             :       /* avoid dangling else.  */
    8610                 :           0 :       M2Error_InternalError ((const char *) "expecting procedure", 19);
    8611                 :             :     }
    8612                 :     3930882 : }
    8613                 :             : 
    8614                 :             : 
    8615                 :             : /*
    8616                 :             :    DeclareModuleVariables - declares Module variables for a module
    8617                 :             :                             which was declared inside a procedure.
    8618                 :             : */
    8619                 :             : 
    8620                 :         144 : extern "C" void M2GCCDeclare_DeclareModuleVariables (unsigned int sym)
    8621                 :             : {
    8622                 :         144 :   tree scope;
    8623                 :         144 :   unsigned int i;
    8624                 :         144 :   unsigned int Var;
    8625                 :             : 
    8626                 :         144 :   i = 1;
    8627                 :         144 :   scope = SymbolConversion_Mod2Gcc (SymbolTable_GetProcedureScope (sym));
    8628                 :         144 :   Var = SymbolTable_GetNth (sym, i);
    8629                 :         366 :   while (Var != SymbolTable_NulSym)
    8630                 :             :     {
    8631                 :          78 :       DoVariableDeclaration (Var, NameKey_KeyToCharStar (M2AsmUtil_GetFullSymName (Var)), false, false, SymbolTable_IsTemporary (Var), false, scope);  /* and are not global  */
    8632                 :          78 :       i += 1;
    8633                 :          78 :       Var = SymbolTable_GetNth (sym, i);
    8634                 :             :     }
    8635                 :         144 : }
    8636                 :             : 
    8637                 :             : 
    8638                 :             : /*
    8639                 :             :    IsProcedureGccNested - returns TRUE if procedure, sym, will be considered
    8640                 :             :                           as nested by GCC.
    8641                 :             :                           This will occur if either its outer defining scope
    8642                 :             :                           is a procedure or is a module which is inside a
    8643                 :             :                           procedure.
    8644                 :             : */
    8645                 :             : 
    8646                 :     2348690 : extern "C" bool M2GCCDeclare_IsProcedureGccNested (unsigned int sym)
    8647                 :             : {
    8648                 :     2348690 :   return (SymbolTable_IsProcedureNested (sym)) || ((SymbolTable_IsModule (SymbolTable_GetScope (sym))) && (SymbolTable_IsModuleWithinProcedure (SymbolTable_GetScope (sym))));
    8649                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8650                 :             :   __builtin_unreachable ();
    8651                 :             : }
    8652                 :             : 
    8653                 :             : 
    8654                 :             : /*
    8655                 :             :    PoisonSymbols - poisons all gcc symbols from procedure, sym.
    8656                 :             :                    A debugging aid.
    8657                 :             : */
    8658                 :             : 
    8659                 :       69100 : extern "C" void M2GCCDeclare_PoisonSymbols (unsigned int sym)
    8660                 :             : {
    8661                 :       69100 :   if (SymbolTable_IsProcedure (sym))
    8662                 :             :     {
    8663                 :       69100 :       SymbolTable_ForeachLocalSymDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) SymbolConversion_Poison});
    8664                 :             :     }
    8665                 :       69100 : }
    8666                 :             : 
    8667                 :             : 
    8668                 :             : /*
    8669                 :             :    PromoteToString - declare, sym, and then promote it to a string.
    8670                 :             :                      Note that if sym is a single character we do
    8671                 :             :                           *not* record it as a string
    8672                 :             :                           but as a char however we always
    8673                 :             :                           return a string constant.
    8674                 :             : */
    8675                 :             : 
    8676                 :       23421 : extern "C" tree M2GCCDeclare_PromoteToString (unsigned int tokenno, unsigned int sym)
    8677                 :             : {
    8678                 :       23421 :   unsigned int size;
    8679                 :       23421 :   char ch;
    8680                 :             : 
    8681                 :       23421 :   M2GCCDeclare_DeclareConstant (tokenno, sym);
    8682                 :       23421 :   if ((SymbolTable_IsConst (sym)) && ((SymbolTable_GetSType (sym)) == M2Base_Char))
    8683                 :             :     {
    8684                 :        1524 :       SymbolTable_PushValue (sym);
    8685                 :        1524 :       ch = M2ALU_PopChar (tokenno);
    8686                 :        1524 :       return m2decl_BuildCStringConstant (const_cast <const char * > (static_cast <char * > (DynamicStrings_string (DynamicStrings_InitStringChar (ch)))), 1);
    8687                 :             :     }
    8688                 :             :   else
    8689                 :             :     {
    8690                 :       21897 :       M2Debug_Assert (SymbolTable_IsConstStringKnown (sym));
    8691                 :       21897 :       size = SymbolTable_GetStringLength (tokenno, sym);
    8692                 :       21897 :       if (size > 1)
    8693                 :             :         {
    8694                 :             :           /* It will be already be declared as a string, so return it.  */
    8695                 :       21581 :           return (tree) (SymbolConversion_Mod2Gcc (sym));
    8696                 :             :         }
    8697                 :             :       else
    8698                 :             :         {
    8699                 :         316 :           return m2decl_BuildStringConstant (const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetString (sym)))), static_cast<int> (SymbolTable_GetStringLength (tokenno, sym)));
    8700                 :             :         }
    8701                 :             :     }
    8702                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8703                 :             :   __builtin_unreachable ();
    8704                 :             : }
    8705                 :             : 
    8706                 :             : 
    8707                 :             : /*
    8708                 :             :    PromoteToCString - declare, sym, and then promote it to a string.
    8709                 :             :                       Note that if sym is a single character we do
    8710                 :             :                           *not* record it as a string
    8711                 :             :                           but as a char however we always
    8712                 :             :                           return a string constant.
    8713                 :             : */
    8714                 :             : 
    8715                 :          60 : extern "C" tree M2GCCDeclare_PromoteToCString (unsigned int tokenno, unsigned int sym)
    8716                 :             : {
    8717                 :          60 :   unsigned int size;
    8718                 :          60 :   char ch;
    8719                 :             : 
    8720                 :          60 :   M2GCCDeclare_DeclareConstant (tokenno, sym);
    8721                 :          60 :   M2Debug_Assert (SymbolTable_IsConstStringKnown (sym));
    8722                 :          60 :   if ((SymbolTable_IsConst (sym)) && ((SymbolTable_GetSType (sym)) == M2Base_Char))
    8723                 :             :     {
    8724                 :          12 :       SymbolTable_PushValue (sym);
    8725                 :          12 :       ch = M2ALU_PopChar (tokenno);
    8726                 :          12 :       return m2decl_BuildCStringConstant (const_cast <const char * > (static_cast <char * > (DynamicStrings_string (DynamicStrings_InitStringChar (ch)))), 1);
    8727                 :             :     }
    8728                 :             :   else
    8729                 :             :     {
    8730                 :          48 :       size = SymbolTable_GetStringLength (tokenno, sym);
    8731                 :          48 :       return m2decl_BuildCStringConstant (const_cast <const char * > (static_cast <char * > (NameKey_KeyToCharStar (SymbolTable_GetString (sym)))), static_cast<int> (size));
    8732                 :             :     }
    8733                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8734                 :             :   __builtin_unreachable ();
    8735                 :             : }
    8736                 :             : 
    8737                 :             : 
    8738                 :             : /*
    8739                 :             :    CompletelyResolved - returns TRUE if a symbols has been completely resolved
    8740                 :             :                         and is not partically declared (such as a record).
    8741                 :             : */
    8742                 :             : 
    8743                 :     8941702 : extern "C" bool M2GCCDeclare_CompletelyResolved (unsigned int sym)
    8744                 :             : {
    8745                 :     8941702 :   return Sets_IsElementInSet (GlobalGroup->FullyDeclared, sym);
    8746                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8747                 :             :   __builtin_unreachable ();
    8748                 :             : }
    8749                 :             : 
    8750                 :             : 
    8751                 :             : /*
    8752                 :             :    ConstantKnownAndUsed -
    8753                 :             : */
    8754                 :             : 
    8755                 :          30 : extern "C" void M2GCCDeclare_ConstantKnownAndUsed (unsigned int sym, tree t)
    8756                 :             : {
    8757                 :          30 :   DeclareConstantFromTree (sym, m2block_RememberConstant (t));
    8758                 :          30 : }
    8759                 :             : 
    8760                 :             : 
    8761                 :             : /*
    8762                 :             :    PutToBeSolvedByQuads - places, sym, to this list and returns,
    8763                 :             :                           sym.
    8764                 :             : */
    8765                 :             : 
    8766                 :      300080 : extern "C" void M2GCCDeclare_PutToBeSolvedByQuads (unsigned int sym)
    8767                 :             : {
    8768                 :      300080 :   WatchIncludeList (sym, M2GCCDeclare_tobesolvedbyquads);
    8769                 :      300080 : }
    8770                 :             : 
    8771                 :             : 
    8772                 :             : /*
    8773                 :             :    MarkExported - tell GCC to mark all exported procedures in module sym.
    8774                 :             : */
    8775                 :             : 
    8776                 :       22357 : extern "C" void M2GCCDeclare_MarkExported (unsigned int sym)
    8777                 :             : {
    8778                 :       22357 :   if (M2Options_Optimizing)
    8779                 :             :     {
    8780                 :       14530 :       m2type_MarkFunctionReferenced (SymbolConversion_Mod2Gcc (sym));
    8781                 :       14530 :       if ((SymbolTable_IsDefImp (sym)) || (SymbolTable_IsModule (sym)))
    8782                 :             :         {
    8783                 :        6214 :           SymbolTable_ForeachExportedDo (sym, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) M2GCCDeclare_MarkExported});
    8784                 :             :         }
    8785                 :             :     }
    8786                 :       22357 : }
    8787                 :             : 
    8788                 :             : 
    8789                 :             : /*
    8790                 :             :    GetTypeMin -
    8791                 :             : */
    8792                 :             : 
    8793                 :     2183874 : extern "C" unsigned int M2GCCDeclare_GetTypeMin (unsigned int type)
    8794                 :             : {
    8795                 :     2186554 :   unsigned int min;
    8796                 :     2186554 :   unsigned int max;
    8797                 :             : 
    8798                 :     2186554 :   if (SymbolTable_IsSubrange (type))
    8799                 :             :     {
    8800                 :     1869236 :       SymbolTable_GetSubrange (type, &max, &min);
    8801                 :     1869236 :       return min;
    8802                 :             :     }
    8803                 :      317318 :   else if (SymbolTable_IsSet (type))
    8804                 :             :     {
    8805                 :             :       /* avoid dangling else.  */
    8806                 :        2662 :       return M2GCCDeclare_GetTypeMin (SymbolTable_GetSType (type));
    8807                 :             :     }
    8808                 :      314656 :   else if (SymbolTable_IsEnumeration (type))
    8809                 :             :     {
    8810                 :             :       /* avoid dangling else.  */
    8811                 :      303716 :       MinEnumerationField = SymbolTable_NulSym;
    8812                 :      303716 :       MaxEnumerationField = SymbolTable_NulSym;
    8813                 :      303716 :       SymbolTable_ForeachLocalSymDo (type, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) FindMinMaxEnum});
    8814                 :      303716 :       return MinEnumerationField;
    8815                 :             :     }
    8816                 :       10940 :   else if (IsBaseType (type))
    8817                 :             :     {
    8818                 :             :       /* avoid dangling else.  */
    8819                 :       10922 :       M2Base_GetBaseTypeMinMax (type, &min, &max);
    8820                 :       10922 :       return min;
    8821                 :             :     }
    8822                 :          18 :   else if (M2System_IsSystemType (type))
    8823                 :             :     {
    8824                 :             :       /* avoid dangling else.  */
    8825                 :           0 :       M2System_GetSystemTypeMinMax (type, &min, &max);
    8826                 :           0 :       return min;
    8827                 :             :     }
    8828                 :          18 :   else if ((SymbolTable_GetSType (type)) == SymbolTable_NulSym)
    8829                 :             :     {
    8830                 :             :       /* avoid dangling else.  */
    8831                 :           0 :       M2MetaError_MetaError1 ((const char *) "unable to obtain the MIN value for type {%1as}", 46, type);
    8832                 :           0 :       return SymbolTable_NulSym;
    8833                 :             :     }
    8834                 :             :   else
    8835                 :             :     {
    8836                 :             :       /* avoid dangling else.  */
    8837                 :          18 :       return M2GCCDeclare_GetTypeMin (SymbolTable_GetSType (type));
    8838                 :             :     }
    8839                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8840                 :             :   __builtin_unreachable ();
    8841                 :             : }
    8842                 :             : 
    8843                 :             : 
    8844                 :             : /*
    8845                 :             :    GetTypeMax -
    8846                 :             : */
    8847                 :             : 
    8848                 :     2142978 : extern "C" unsigned int M2GCCDeclare_GetTypeMax (unsigned int type)
    8849                 :             : {
    8850                 :     2145658 :   unsigned int min;
    8851                 :     2145658 :   unsigned int max;
    8852                 :             : 
    8853                 :     2145658 :   if (SymbolTable_IsSubrange (type))
    8854                 :             :     {
    8855                 :     1829358 :       SymbolTable_GetSubrange (type, &max, &min);
    8856                 :     1829358 :       return max;
    8857                 :             :     }
    8858                 :      316300 :   else if (SymbolTable_IsSet (type))
    8859                 :             :     {
    8860                 :             :       /* avoid dangling else.  */
    8861                 :        2662 :       return M2GCCDeclare_GetTypeMax (SymbolTable_GetSType (type));
    8862                 :             :     }
    8863                 :      313638 :   else if (SymbolTable_IsEnumeration (type))
    8864                 :             :     {
    8865                 :             :       /* avoid dangling else.  */
    8866                 :      302716 :       MinEnumerationField = SymbolTable_NulSym;
    8867                 :      302716 :       MaxEnumerationField = SymbolTable_NulSym;
    8868                 :      302716 :       SymbolTable_ForeachLocalSymDo (type, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) FindMinMaxEnum});
    8869                 :      302716 :       return MaxEnumerationField;
    8870                 :             :     }
    8871                 :       10922 :   else if (IsBaseType (type))
    8872                 :             :     {
    8873                 :             :       /* avoid dangling else.  */
    8874                 :       10904 :       M2Base_GetBaseTypeMinMax (type, &min, &max);
    8875                 :       10904 :       return max;
    8876                 :             :     }
    8877                 :          18 :   else if (M2System_IsSystemType (type))
    8878                 :             :     {
    8879                 :             :       /* avoid dangling else.  */
    8880                 :           0 :       M2System_GetSystemTypeMinMax (type, &min, &max);
    8881                 :           0 :       return max;
    8882                 :             :     }
    8883                 :          18 :   else if ((SymbolTable_GetSType (type)) == SymbolTable_NulSym)
    8884                 :             :     {
    8885                 :             :       /* avoid dangling else.  */
    8886                 :           0 :       M2MetaError_MetaError1 ((const char *) "unable to obtain the MAX value for type {%1as}", 46, type);
    8887                 :           0 :       return SymbolTable_NulSym;
    8888                 :             :     }
    8889                 :             :   else
    8890                 :             :     {
    8891                 :             :       /* avoid dangling else.  */
    8892                 :          18 :       return M2GCCDeclare_GetTypeMax (SymbolTable_GetSType (type));
    8893                 :             :     }
    8894                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
    8895                 :             :   __builtin_unreachable ();
    8896                 :             : }
    8897                 :             : 
    8898                 :             : 
    8899                 :             : /*
    8900                 :             :    PrintSym - prints limited information about a symbol.
    8901                 :             :               This procedure is externally visible.
    8902                 :             : */
    8903                 :             : 
    8904                 :           0 : extern "C" void M2GCCDeclare_PrintSym (unsigned int sym)
    8905                 :             : {
    8906                 :           0 :   M2Printf_printf1 ((const char *) "information about symbol: %d\\n", 30, (const unsigned char *) &sym, (sizeof (sym)-1));
    8907                 :           0 :   M2Printf_fprintf0 (M2LangDump_GetDumpFile (), (const char *) "==============================\\n", 32);
    8908                 :           0 :   PrintVerbose (sym);
    8909                 :           0 : }
    8910                 :             : 
    8911                 :             : 
    8912                 :             : /*
    8913                 :             :    IncludeDumpSymbol - include sym into the watch list and all syms dependants.
    8914                 :             : */
    8915                 :             : 
    8916                 :           0 : extern "C" void M2GCCDeclare_IncludeDumpSymbol (unsigned int sym)
    8917                 :             : {
    8918                 :           0 :   if (sym != SymbolTable_NulSym)
    8919                 :             :     {
    8920                 :             :       /* 
    8921                 :             :       fprintf0 (GetDumpFile (), "
    8922                 :             :       ") ;
    8923                 :             :       PrintVerbose (sym) ;
    8924                 :             :       fprintf0 (GetDumpFile (), "
    8925                 :             :       ")
    8926                 :             :   */
    8927                 :           0 :       AddSymToWatch (sym);
    8928                 :             :     }
    8929                 :           0 : }
    8930                 :             : 
    8931                 :             : 
    8932                 :             : /*
    8933                 :             :    DumpFilteredResolver - dumps the gimple or tree representation of all watched symbols.
    8934                 :             : */
    8935                 :             : 
    8936                 :           0 : extern "C" void M2GCCDeclare_DumpFilteredResolver (void)
    8937                 :             : {
    8938                 :           0 :   Sets_ForeachElementInSetDo (WatchList, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DumpResolver});
    8939                 :           0 : }
    8940                 :             : 
    8941                 :             : 
    8942                 :             : /*
    8943                 :             :    DumpFilteredDefinitive - dumps the gimple or tree representation of all watched symbols.
    8944                 :             : */
    8945                 :             : 
    8946                 :           0 : extern "C" void M2GCCDeclare_DumpFilteredDefinitive (void)
    8947                 :             : {
    8948                 :           0 :   Sets_ForeachElementInSetDo (WatchList, (SymbolKey_PerformOperation) {(SymbolKey_PerformOperation_t) DumpDefinitive});
    8949                 :           0 : }
    8950                 :             : 
    8951                 :             : 
    8952                 :             : /*
    8953                 :             :    InitDeclarations - initializes default types and the source filename.
    8954                 :             : */
    8955                 :             : 
    8956                 :       14329 : extern "C" void M2GCCDeclare_InitDeclarations (void)
    8957                 :             : {
    8958                 :       14329 :   DeclareDefaultTypes ();
    8959                 :       14329 :   DeclareDefaultConstants ();
    8960                 :       14329 : }
    8961                 :             : 
    8962                 :       15260 : extern "C" void _M2_M2GCCDeclare_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
    8963                 :             : {
    8964                 :       15260 :   FreeGroup = NULL;
    8965                 :       15260 :   GlobalGroup = InitGroup ();
    8966                 :       15260 :   ErrorDepList = Sets_InitSet (1);
    8967                 :       15260 :   ChainedList = Sets_InitSet (1);
    8968                 :       15260 :   WatchList = Sets_InitSet (1);
    8969                 :       15260 :   VisitedList = static_cast<Sets_Set> (NULL);
    8970                 :       15260 :   EnumerationIndex = Indexing_InitIndex (1);
    8971                 :       15260 :   HaveInitDefaultTypes = false;
    8972                 :       15260 :   recursionCaught = false;
    8973                 :       15260 : }
    8974                 :             : 
    8975                 :           0 : extern "C" void _M2_M2GCCDeclare_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
    8976                 :             : {
    8977                 :           0 : }
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.