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