Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
module.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 static char USMID[] = "\n@(#)5.0_pl/sources/module.c    5.17    09/30/99 15:47:54\n";
00037 
00038 # include "defines.h"           /* Machine dependent ifdefs */
00039 
00040 # include "host.m"              /* Host machine dependent macros.*/
00041 # include "host.h"              /* Host machine dependent header.*/
00042 # include "target.m"            /* Target machine dependent macros.*/
00043 # include "target.h"            /* Target machine dependent header.*/
00044 
00045 # include "globals.m"
00046 # include "tokens.m"
00047 # include "sytb.m"  
00048 # include "p_globals.m"  
00049 # include "debug.m"
00050 # include "module.m"
00051 
00052 # include "globals.h"
00053 # include "tokens.h"
00054 # include "sytb.h"
00055 # include "p_globals.h"
00056 # include "module.h"
00057 
00058 # include <ar.h>
00059 
00060 # include <sys/types.h>
00061 # include <sys/stat.h>
00062 
00063 # include <dirent.h>
00064 
00065 # include <errno.h>
00066 
00067 # if defined(GENERATE_WHIRL) && defined(_MODULE_TO_DOT_o)
00068 # include <fcntl.h>
00069 # include <libelf.h>
00070 # include <sys/elf.h>
00071 
00072   /* These are the originator string and .note type this program removes  */
00073   /* from files.                                                          */
00074 
00075 # define NOTE_ORIG_NAME  "Cray Research, Incorporated\0"
00076 # define NOTE_ORGNAM_LEN 28
00077 # define NOTE_TYPE        1
00078 
00079 # elif defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
00080 # include <fcntl.h>
00081 # include <libelf.h>
00082 # include <sys/elf_SPARC.h>
00083 
00084   /* These are the originator string and .note type this program removes  */
00085   /* from files.                                                          */
00086 
00087 # define NOTE_ORIG_NAME  "Cray Research, Incorporated\0"
00088 # define NOTE_ORGNAM_LEN 28
00089 # define NOTE_TYPE        1
00090 # endif
00091 
00092 # if !defined(AR_HDR_SIZE)
00093 # define        AR_HDR_SIZE     sizeof(ar_hdr_type)
00094 # endif
00095 
00096 /******************************************************************************\
00097 |*                                                                            *|
00098 |* Notes if a new field is added to the symbol tables.                        *|
00099 |*                                                                            *|
00100 |*   1) Add it to the appropriate set_mod_link_tbl_for ... routine            *|
00101 |*      This routine sets the KEEP_ME and IDX flags in the mod link table     *|
00102 |*      so that the table entry gets kept during compression.                 *|
00103 |*                                                                            *|
00104 |*   2) Add it to update_idxs_in_attr_entry or compress_tbls for non attr     *|
00105 |*      fields.  These routines do the actual compression and reset the       *|
00106 |*      fields.  compress_tbls calls update_idxs_in_attr_entry.               *|
00107 |*                                                                            *|
00108 |*   3) Add it to update_new_idxs_after_input.  This routine sets the indexes *|
00109 |*      after a module is read in.  When a module is in a file, all the table *|
00110 |*      indexes are 1 based.  When it is read in, each new table is           *|
00111 |*      concatenated to the existing table, so all the indexs need the table  *|
00112 |*      size before reading added to the index.  This is generally the        *|
00113 |*      location to correct for symbol table changes.                         *|
00114 |*                                                                            *|
00115 \******************************************************************************/
00116 
00117 
00118 /******************************************************************************\
00119 |*                                                                            *|
00120 |* Steps for compressing tables.  (Both partial and full compressions.)       *|
00121 |*                                                                            *|
00122 |*   These routines allow for full and partial compressions.  (See #2 to      *|
00123 |*   set indexes for a partial compression.  A full compression is everything *|
00124 |*   in a table.  A partial compression starts at a given index in a table    *|
00125 |*   and goes to the end of a table.  These routines will not do a compression*|
00126 |*   in the middle of a table.                                                *|
00127 |*                                                                            *|
00128 |*   1) Allocate the mod_link_tbl.  This table is allocated so that it is as  *|
00129 |*      big as the largest symbol/ir table.  If between marking the entries   *|
00130 |*      in the mod_link_tbl and the actual compression, any tables grow       *|
00131 |*      always make sure the mod_link_tbl size is still big enough to cover   *|
00132 |*      the new entries.  No matter what table is being compressed, the mod_  *|
00133 |*      link_tbl must be allocated as large as the largest table.             *|
00134 |*                                                                            *|
00135 |*   2) Set the zeroth entries in the mod_link_tbl to one less than the       *|
00136 |*      starting index for compression.  If this is a full compression, then  *|
00137 |*      they should be set to 0.  Anything in a table past this index is      *|
00138 |*      subject to compression.                                               *|
00139 |*                                                                            *|
00140 |*   3) Call set_mod_link_tbl_for_attr  each attr entry that needs to be kept.*|
00141 |*      If this is a partial compression, this only needs to be called for    *|
00142 |*      those attr entries in the part of the attr table to be compressed.    *|
00143 |*      This routine calls set_mod_link_tbl routines for other tables.  If the*|
00144 |*      local name table is to be compressed, these entries will have to be   *|
00145 |*      marked.  (See create_mod_info_tbl for how this is done for a full     *|
00146 |*      compression.)  This routine marks each table entry that needs to be   *|
00147 |*      kept in the mod_link_tbl, with its current index.  That way if the    *|
00148 |*      item being compressed points into a part of the table not being       *|
00149 |*      compressed, it will get the correct index out of the mod_link_tbl.    *|
00150 |*                                                                            *|
00151 |*   4) Call assign_new_idxs.  It will start at the point of compression for  *|
00152 |*      each table.  If the mod_link_tbl is set for that entry, it will be    *|
00153 |*      given a new index.  (The new index for a table starts at the index    *|
00154 |*      where compression starts and is incremented each time a table entry   *|
00155 |*      is kept.)  The new index is put into the mod_link_tbl for the entry.  *|
00156 |*                                                                            *|
00157 |*   5) Call compress_tbls to move the table entries to their new index spots.*|
00158 |*      This is where actual compression takes place.  As the entries are     *|
00159 |*      being moved, all their links are updated with the correct links from  *|
00160 |*      the mod_link_tbl.                                                     *|
00161 |*                                                                            *|
00162 |*   Example:  Compress the attr_tbl starting at index 65.  attr_tbl_idx = 70 *|
00163 |*             Entries  66, 68 and 70 are to be kept.                         *|
00164 |*             1) Allocate mod_link_tbl as large as the largest table.        *|
00165 |*             2) ML_AT_IDX(0) = 64  (65 - one)                               *|
00166 |*                The rest of the tables mod_link_tbl[0] entries are set to   *|
00167 |*                the current table indexes so that no other table compresses.*|
00168 |*             3) Call set_mod_link_tbl_for_attr for attr entries 66, 68 & 70.*|
00169 |*             4) Call assign_new_idxs.       Old Idx        New Idx          *|
00170 |*                                              66             65             *|
00171 |*                                              68             66             *|
00172 |*                                              70             67             *|
00173 |*             5) Call compress_tbls which moves the attr tbl entries.        *|
00174 |*                attr_tbl_idx is set to 67.                                  *|
00175 |*                                                                            *|
00176 |*   NOTE:  compress_tbls and assign_new_idxs will go through all the tables, *|
00177 |*      so in the above example, any references to attrs 66, 68 and 70 will   *|
00178 |*      be reset.  If there are references to attrs 67 or 69, these           *|
00179 |*      references will be set to NULL_IDX.  This is where alot of bugs are   *|
00180 |*      found during module processing.  Full compressions are done when      *|
00181 |*      files are written out for modules or inlining.  Partial compressions  *|
00182 |*      are done when files for module or inlining are read in and also for   *|
00183 |*      interface block compression.                                          *|
00184 |*                                                                            *|
00185 |*                                                                            *|
00186 \******************************************************************************/
00187 
00188 extern  boolean is_directory(char *);
00189 
00190 /*****************************************************************\
00191 |* function prototypes of static functions declared in this file *|
00192 \*****************************************************************/
00193 static  void    allocate_mod_link_tbl (int);
00194 static  void    assign_new_idxs (boolean);
00195 static  void    assign_new_idxs_after_input (int);
00196 static  void    check_ir_for_attrs (int);
00197 static  void    check_il_for_attrs (int);
00198 static  void    compress_tbls (int, boolean);
00199 static  void    compress_type_tbl (int);
00200 # if 0
00201 static  void    create_module_list_from_str_pool (void);
00202 # endif
00203 
00204 # if defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
00205 static  boolean do_elf_notes_section(Elf_Data *, int, int);
00206 static  boolean do_elf_object(Elf *, Elf32_Ehdr *, int, int);
00207 # endif
00208 
00209 /* # if defined(_DEBUG) */
00210 static  void    dump_pdt(FILE *);
00211 static  void    print_mod_tbl(void);
00212 /* # endif */
00213 
00214 static  void    find_files_in_directory(int);
00215 static  void    merge_interfaces (int, int);
00216 static  void    not_visible_semantics (int, int, int);
00217 static  int     ntr_file_in_fp_tbl(int, char *, int);
00218 static  FILE   *open_module_file (int, int);
00219 static  void    process_procs_for_inlining (int);
00220 static  boolean read_in_module_tbl (int, int, FILE *, char *);
00221 static  boolean read_module_tbl_header (int, int, FILE *);
00222 static  boolean read_sytb_from_module_file(int, FILE *, char *);
00223 static  boolean rename_only_semantics (int, boolean);
00224 static  boolean resolve_attr(int);
00225 static  void    resolve_all_components(int, int);
00226 static  void    resolve_used_modules (int);
00227 static  void    set_attr_flds_for_output (void);
00228 static  void    set_mod_link_tbl_for_attr (int);
00229 static  void    set_mod_link_tbl_for_bd (int);
00230 static  void    set_mod_link_tbl_for_cn (int);
00231 static  void    set_mod_link_tbl_for_ir (int);
00232 static  void    set_mod_link_tbl_for_il (int);
00233 static  void    set_mod_link_tbl_for_typ (int);
00234 static  boolean srch_ar_file_for_module_tbl (int, int *, int, FILE *);
00235 static  boolean srch_for_module_tbl (int, int *, int, int, FILE *);
00236 static  void    update_idxs_in_attr_entry (int, int);
00237 static  void    update_intrinsic (int);
00238 
00239 # if defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
00240 static  boolean srch_elf_file_for_module_tbl(int, int);
00241 # endif
00242 
00243 static char * module_suffix_fix = ".mod-whirl";
00244 
00245 
00246 /***********************************\
00247 |* Globals used only in this file  *|
00248 \***********************************/
00249 
00250 static  boolean alternate_entry;
00251 static  boolean count_derived_types;
00252 static  boolean only_update_new_tbl_entries;
00253 static  boolean inline_search;
00254 static  int     list_of_modules_in_module;
00255 static  long    mod_file_end_offset;
00256 static  long    num_module_derived_types;
00257 static  int     save_const_pool_idx;
00258 static  int     save_const_tbl_idx;
00259 static  boolean search_for_duplicate_attrs;
00260 
00261 extern  char    compiler_gen_date[];
00262 
00263 /******************************************************************************\
00264 |*                                                                            *|
00265 |* Description:                                                               *|
00266 |*      This routine enters a rename and/or only name for a USE statement     *|
00267 |*      into the rename only table.  All entries are kept in sorted order.    *|
00268 |*      Rename entries actually get two entries in the table.  The original   *|
00269 |*      name entry is the sorted one.  The new name entry is indexed off the  *|
00270 |*      original name entry.  The whole list of renames/only entries is       *|
00271 |*      indexed by ATP_USE_LIST for the module.                               *|
00272 |*                                                                            *|
00273 |* Input parameters:                                                          *|
00274 |*      module_idx - The attr index for the module specified in the use stmt. *|
00275 |*      ro_idx     - The new name index if this is a rename entry.   (This    *|
00276 |*                   routine is called to enter the new name first.  The ro   *|
00277 |*                   index is returned.  Then it is called again with the     *|
00278 |*                   original name and the ro index.  An entry is made for    *|
00279 |*                   the original name and the rename entry is hung off of it.*|
00280 |*      rename_entry -> TRUE if this is the new name.  It doesn't need to be  *|
00281 |*                      sorted or added to the list.                          *|
00282 |*                                                                            *|
00283 |* Output parameters:                                                         *|
00284 |*      NONE                                                                  *|
00285 |*                                                                            *|
00286 |* Returns:                                                                   *|
00287 |*      ro_idx just entered.                                                  *|
00288 |*                                                                            *|
00289 \******************************************************************************/
00290 int  make_ro_entry(int          module_idx,
00291                    int          ro_idx,
00292                    boolean      rename_entry)
00293 
00294 {
00295    int          cmp_idx;
00296    int          matched;
00297    int          np_idx;
00298    int          prev_idx;
00299 
00300 
00301    TRACE (Func_Entry, "make_ro_entry", NULL);
00302 
00303    if (ro_idx == NULL_IDX) {
00304       ++rename_only_tbl_idx;
00305       CHECK_TBL_ALLOC_SIZE(rename_only_tbl, rename_only_tbl_idx);
00306 
00307       ro_idx = rename_only_tbl_idx;
00308 
00309       CLEAR_TBL_NTRY(rename_only_tbl, ro_idx);
00310 
00311       NTR_NAME_POOL(TOKEN_ID(token).words, TOKEN_LEN(token), np_idx);
00312 
00313       RO_LINE_NUM(ro_idx)       = TOKEN_LINE(token);
00314       RO_COLUMN_NUM(ro_idx)     = TOKEN_COLUMN(token);
00315       RO_NAME_LEN(ro_idx)       = TOKEN_LEN(token);
00316       RO_NAME_IDX(ro_idx)       = np_idx;
00317    }
00318 
00319    if (rename_entry) {   /* Do not sort - assume it is a rename entry */
00320       RO_RENAME_NAME(ro_idx)    = TRUE;
00321    }
00322    else {  /* Find a sorted spot for it */
00323       RO_RENAME_NAME(ro_idx)    = FALSE;
00324 
00325       if (ATP_USE_LIST(module_idx) == NULL_IDX) {
00326          ATP_USE_LIST(module_idx) = ro_idx;
00327       }
00328       else {
00329          cmp_idx        = ATP_USE_LIST(module_idx);
00330          prev_idx       = NULL_IDX;
00331 
00332          for (;;) {
00333             matched = compare_names(RO_NAME_LONG(cmp_idx),
00334                                     RO_NAME_LEN(cmp_idx),
00335                                     TOKEN_ID(token).words,
00336                                     TOKEN_LEN(token));
00337 
00338             if (matched >= 0) {  
00339 
00340                /* Name in table is same or greater than new name.  Add the */
00341                /* new name before the current index.                       */
00342 
00343                RO_NEXT_IDX(ro_idx) = cmp_idx;
00344 
00345                if (prev_idx == NULL_IDX) {
00346                   ATP_USE_LIST(module_idx) = ro_idx;
00347                }
00348                else {
00349                   RO_NEXT_IDX(prev_idx) = ro_idx;
00350                }
00351                break;
00352             }
00353             else {
00354                prev_idx = cmp_idx;
00355                cmp_idx  = RO_NEXT_IDX(cmp_idx);
00356 
00357                if (cmp_idx == NULL_IDX) {  /* Add at end */
00358                   RO_NEXT_IDX(prev_idx) = ro_idx;
00359                   break;
00360                }
00361             }
00362          }
00363       }
00364    }
00365 
00366    TRACE (Func_Exit, "make_ro_entry", NULL);
00367 
00368    return(ro_idx);
00369 
00370 }   /* make_ro_entry */
00371 
00372 /******************************************************************************\
00373 |*                                                                            *|
00374 |* Description:                                                               *|
00375 |*      Search the renames table to see if this new name exists already.      *|
00376 |*      This would happen if the same name was used to rename something twice.*|
00377 |*      If it is found, RO_DUPLICATE_RENAME is set for both entries.  Errors  *|
00378 |*      will be issued during use_stmt_semantics.                             *|
00379 |*                                                                            *|
00380 |* Input parameters:                                                          *|
00381 |*      rename_idx -> The ro index for the name to search for.                *|
00382 |*                                                                            *|
00383 |* Output parameters:                                                         *|
00384 |*      NONE                                                                  *|
00385 |*                                                                            *|
00386 |* Returns:                                                                   *|
00387 |*      NOTHING                                                               *|
00388 |*                                                                            *|
00389 \******************************************************************************/
00390 void    check_for_duplicate_renames(int         rename_idx)
00391 
00392 {
00393    int          ro_idx;
00394 
00395 
00396    TRACE (Func_Entry, "check_for_duplicate_renames", NULL);
00397 
00398    for (ro_idx = 1; ro_idx < rename_only_tbl_idx; ro_idx++) {
00399 
00400       if (RO_RENAME_NAME(ro_idx) &&
00401           (compare_names(RO_NAME_LONG(rename_idx),
00402                          RO_NAME_LEN(rename_idx),
00403                          RO_NAME_LONG(ro_idx),
00404                          RO_NAME_LEN(ro_idx)) == 0) && ro_idx != rename_idx) {
00405         //         RO_DUPLICATE_RENAME(rename_idx)      = TRUE;
00406         //         RO_DUPLICATE_RENAME(ro_idx)          = TRUE;
00407          break;
00408       }
00409    }
00410 
00411    TRACE (Func_Exit, "check_for_duplicate_renames", NULL);
00412 
00413    return;
00414 
00415 }   /* check_for_duplicate_renames */
00416 
00417 /******************************************************************************\
00418 |*                                                                            *|
00419 |* Description:                                                               *|
00420 |*      Allocate and clear the module link table.  This is used for table     *|
00421 |*      compression.                                                          *|
00422 |*                                                                            *|
00423 |* Input parameters:                                                          *|
00424 |*      size -> Size to allocate.  If this is zero, we will calculate the     *|
00425 |*              size to allocate, by finding the largest table.               *|
00426 |*                                                                            *|
00427 |* Output parameters:                                                         *|
00428 |*      NONE                                                                  *|
00429 |*                                                                            *|
00430 |* Returns:                                                                   *|
00431 |*      NOTHING                                                               *|
00432 |*                                                                            *|
00433 \******************************************************************************/
00434 static  void allocate_mod_link_tbl(int          size)
00435 
00436 {
00437    long         *idx;
00438    long          new_size;
00439 
00440 
00441    TRACE (Func_Entry, "allocate_mod_link_tbl", NULL);
00442 
00443    if (size == 0) {
00444 
00445       /* Find the largest table and allocate the mod link table to this size. */
00446 
00447       new_size = (attr_tbl_idx > bounds_tbl_idx)? attr_tbl_idx : bounds_tbl_idx;
00448       new_size = (new_size > const_tbl_idx)     ? new_size : const_tbl_idx;
00449       new_size = (new_size > const_pool_idx)    ? new_size : const_pool_idx;
00450       new_size = (new_size > loc_name_tbl_idx)  ? new_size : loc_name_tbl_idx;
00451       new_size = (new_size > name_pool_idx)     ? new_size : name_pool_idx;
00452       new_size = (new_size > sec_name_tbl_idx)  ? new_size : sec_name_tbl_idx;
00453       new_size = (new_size > stor_blk_tbl_idx)  ? new_size : stor_blk_tbl_idx;
00454       new_size = (new_size > type_tbl_idx)      ? new_size : type_tbl_idx;
00455       new_size = (new_size > ir_tbl_idx)        ? new_size : ir_tbl_idx;
00456       new_size = (new_size > ir_list_tbl_idx)   ? new_size : ir_list_tbl_idx;
00457       new_size = (new_size > sh_tbl_idx)        ? new_size : sh_tbl_idx;
00458    }
00459    else {
00460       new_size  = size;
00461    }
00462 
00463    new_size++;          /* Do not use entry 0, so increase size by 1 */
00464 
00465    CHECK_TBL_ALLOC_SIZE(mod_link_tbl, new_size);
00466    mod_link_tbl_idx     = mod_link_tbl_size - 1;
00467 
00468    idx = ((long *) (&mod_link_tbl[0]));
00469 
00470    memset(idx, 0, mod_link_tbl_size * NUM_ML_WDS * TARGET_BYTES_PER_WORD);
00471 
00472    TRACE (Func_Exit, "allocate_mod_link_tbl", NULL);
00473 
00474    return;
00475 
00476 }  /* allocate_mod_link_tbl */
00477 
00478 /******************************************************************************\
00479 |*                                                                            *|
00480 |* Description:                                                               *|
00481 |*                                                                            *|
00482 |* Input parameters:                                                          *|
00483 |*      NONE                                                                  *|
00484 |*                                                                            *|
00485 |* Output parameters:                                                         *|
00486 |*      NONE                                                                  *|
00487 |*                                                                            *|
00488 |* Returns:                                                                   *|
00489 |*      NOTHING                                                               *|
00490 |*                                                                            *|
00491 \******************************************************************************/
00492 extern  void    create_mod_info_file(void)
00493 {
00494                 int              ga_idx=0;
00495                 FILE            *fp_file_ptr;
00496                 int              fp_idx                 = NULL_IDX;
00497                 int              idx;
00498                 int              length;
00499                 long            *mod_idx;
00500                 int              module_attr_idx;
00501                 int              name_idx;
00502                 long_type        offset;
00503    static       int              preinline_fp_idx       = NULL_IDX;
00504                 long            *ptr;
00505                 int              wd_len;
00506 
00507 # if defined(_MODULE_TO_DOT_M) || defined(_MODULE_TO_DOT_o)
00508                 char            *mod_name_ptr;
00509                 char            *src_name_ptr;
00510 # endif
00511 
00512 # if defined(_MODULE_TO_DOT_M)
00513                 FILE            *fp_file_ptr;
00514    static       int              m_file_fp_idx          = NULL_IDX;
00515 # endif
00516 
00517 
00518    TRACE (Func_Entry, "create_mod_info_file", NULL);
00519 
00520    module_attr_idx = SCP_ATTR_IDX(MAIN_SCP_IDX);
00521 
00522    /* The module is a global name, so it was entered into the global name   */
00523    /* table during parse_module_stmt.  The global name table entry contains */
00524    /* an index to the file path entry for this module, so that if we have   */
00525    /* a USE statement referencing the module during this compilation, we    */
00526    /* can find it in the file quickly by using the offset in its file path  */
00527    /* table entry.  We can also use it to detect duplicate modules.         */
00528 
00529    if (!srch_global_name_tbl(AT_OBJ_NAME_PTR(module_attr_idx),
00530                              AT_NAME_LEN(module_attr_idx),
00531                              &name_idx)) {
00532 
00533       if (num_prog_unit_errors == 0) {
00534          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1250, Internal,
00535                   AT_DEF_COLUMN(module_attr_idx),
00536                   AT_OBJ_NAME_PTR(module_attr_idx));
00537       }
00538       else if (ATP_PGM_UNIT(module_attr_idx) == Module ||
00539                !AT_DCL_ERR(module_attr_idx)) {
00540          ntr_global_name_tbl(module_attr_idx, NULL_IDX, name_idx);
00541       }
00542       else {  /* Error in attr for function name. - Bypass */
00543          ga_idx         = NULL_IDX;
00544          name_idx       = NULL_IDX;
00545       }
00546    }
00547 
00548    if (name_idx != NULL_IDX) {
00549       ga_idx    = GN_ATTR_IDX(name_idx);
00550 
00551       if (GA_OBJ_CLASS(ga_idx) == Common_Block) {
00552          ga_idx = GAC_PGM_UNIT_IDX(ga_idx);
00553 
00554          if (ga_idx == NULL_IDX && num_prog_unit_errors == 0) {
00555             PRINTMSG(AT_DEF_LINE(module_attr_idx), 1250, Internal,
00556                      AT_DEF_COLUMN(module_attr_idx),
00557                      AT_OBJ_NAME_PTR(module_attr_idx));
00558          }
00559          else {  /* Name must have been in error situation.  Make an entry. */
00560             ntr_global_name_tbl(module_attr_idx, NULL_IDX, name_idx);
00561             ga_idx      = GN_ATTR_IDX(name_idx);
00562          }
00563       }
00564    }
00565 
00566    if (num_prog_unit_errors > 0) {
00567 
00568       if (ga_idx != NULL_IDX && GAP_FP_IDX(ga_idx) != NULL_IDX) {
00569 
00570          /* We already have a module by this name and have created a mod */
00571          /* file for it.  Set SCP_IN_ERR so we don't write out a another */
00572          /* module table.  We would never find this one, because the     */
00573          /* search would always hit the first one.                       */
00574 
00575          SCP_IN_ERR(MAIN_SCP_IDX) = TRUE;
00576       }
00577 
00578       AT_DCL_ERR(module_attr_idx)    = TRUE;
00579 
00580       if (ATP_PGM_UNIT(module_attr_idx) == Module) {
00581          PRINTMSG(AT_DEF_LINE(module_attr_idx), 855, Error,
00582                   AT_DEF_COLUMN(module_attr_idx),
00583                   AT_OBJ_NAME_PTR(module_attr_idx));
00584 
00585          if (SCP_IN_ERR(MAIN_SCP_IDX)) {
00586             return;
00587          }
00588       }
00589       else {  /* Inline information file */
00590          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1322, Error,
00591                   AT_DEF_COLUMN(module_attr_idx),
00592                   AT_OBJ_NAME_PTR(module_attr_idx));
00593       }
00594    }
00595 
00596    offset = 0;
00597 
00598    /* If we are in a preinline compile, everything goes out to the       */
00599    /* preinline_file including modules.                                  */
00600 
00601    if (dump_flags.preinline) {
00602 
00603       if (preinline_fp_idx != NULL_IDX) {
00604          fp_idx         = preinline_fp_idx;
00605          fp_file_ptr    = fopen(FP_NAME_PTR(fp_idx), "ab");
00606          offset         = ftell(fp_file_ptr);
00607          fclose(fp_file_ptr);
00608       }
00609       else {
00610          TBL_REALLOC_CK(file_path_tbl, 1);
00611          CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00612 
00613          fp_idx                         = file_path_tbl_idx;      
00614          preinline_fp_idx               = fp_idx;
00615          FP_NAME_LEN(fp_idx)            = strlen(preinline_file);
00616          FP_NAME_IDX(fp_idx)            = str_pool_idx + 1;
00617          FP_SRCH_THE_FILE(fp_idx)       = FALSE;
00618          length                         = WORD_LEN(FP_NAME_LEN(fp_idx));
00619 
00620          /* We do not do inlining in a preinline   */
00621          /* compile, so this, can just be File_Fp. */
00622 
00623          FP_CLASS(fp_idx)               = File_Fp;
00624 
00625          TBL_REALLOC_CK(str_pool, length);
00626 
00627          ptr = (long *) (&str_pool[FP_NAME_IDX(fp_idx)].name_long);
00628 
00629          memset(ptr, 0, length * TARGET_BYTES_PER_WORD);
00630 
00631          strcpy(FP_NAME_PTR(fp_idx), preinline_file);
00632 
00633          /* We do not do inlining in a preinline compile so always    */
00634          /* put this on the module path in case it contains a module. */
00635 
00636          FP_NEXT_FILE_IDX(fp_idx) = module_path_idx;
00637       }
00638    }
00639 
00640    /* This creates a name for the module output file.  These are not     */
00641    /* true temp files because they need to last beyond the frontend.     */
00642 
00643    /* There are three naming schemes: _MODULE_TO_DOT_o, _MODULE_TO_DOT_M */
00644    /* and module to .mod (-em). If it is DOT_o, temp files are created   */
00645    /* for each module called .file.module.m.  The file names are passed  */
00646    /* thru the interface, where the backend puts the files where it      */
00647    /* wants.  If the file ends with .m, the backend must clean the file  */
00648    /* up.  If it ends with .mn, the frontend must remove the file.       */
00649    /* If DOT_M, the modules are all put in the same file.M file.  If     */
00650    /* .mod), the modules are each put to a file called modulename.mod.   */
00651 
00652    /* How the commandline option and defines work together:  If -dm is   */
00653    /* specified then either _MODULE_TO_DOT_M or _MODULE_TO_DOT_o         */
00654    /* is the default.                                                    */
00655 
00656    if (on_off_flags.module_to_mod) {
00657 
00658       if (fp_idx == NULL_IDX) {
00659 
00660          /* Create module.mod for the name. */
00661          /* Also, check to see if user specified a dir for the .mod files. */
00662 
00663          if (cmd_line_flags.mod_out_path) {
00664             strcpy(&(mod_file_name[0]), mod_out_path);
00665             strcat(mod_file_name, "/");
00666             strcat(mod_file_name, AT_OBJ_NAME_PTR(module_attr_idx));
00667          }
00668          else {
00669             strcpy(&(mod_file_name[0]), AT_OBJ_NAME_PTR(module_attr_idx));
00670          }
00671          strcat(mod_file_name, module_suffix_fix);
00672          TBL_REALLOC_CK(file_path_tbl, 1);
00673          CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00674 
00675          fp_idx                   = file_path_tbl_idx;      
00676          FP_NEXT_FILE_IDX(fp_idx) = (ATP_PGM_UNIT(module_attr_idx) != Module) ? 
00677                                      inline_path_idx : module_path_idx;
00678          FP_NAME_LEN(fp_idx)      = strlen(mod_file_name);
00679          FP_NAME_IDX(fp_idx)      = str_pool_idx + 1;
00680          FP_SRCH_THE_FILE(fp_idx) = FALSE;
00681          length                   = WORD_LEN(FP_NAME_LEN(fp_idx));
00682          FP_CLASS(fp_idx)         = File_Fp;
00683 
00684          TBL_REALLOC_CK(str_pool, length);
00685 
00686          for (idx = FP_NAME_IDX(fp_idx); idx <= str_pool_idx; idx++) {        
00687             str_pool[idx].name_long = 0;
00688          }
00689 
00690          strcpy(FP_NAME_PTR(fp_idx), mod_file_name);
00691       }
00692    }
00693    else { /* Default to MODULE_TO_DOT_o or MODULE_TO_DOT_M */
00694 
00695 # if defined(_MODULE_TO_DOT_o)
00696 
00697       if (fp_idx == NULL_IDX) {
00698          mod_file_name[0]       = '.';
00699          mod_name_ptr   = &(mod_file_name[1]);
00700          src_name_ptr   = strrchr (src_file, SLASH);
00701          src_name_ptr   = (src_name_ptr == NULL) ? src_file : src_name_ptr+1;
00702 
00703          while (*mod_name_ptr++ = *src_name_ptr++);
00704 
00705          /* This returns a pointer to the last */
00706          /* occurence of dot in the file name  */
00707 
00708          src_name_ptr = strrchr (mod_file_name, DOT);
00709 
00710          if (src_name_ptr != NULL && 
00711              (EQUAL_STRS(src_name_ptr, ".f") ||
00712               EQUAL_STRS(src_name_ptr, ".f90"))){
00713              src_name_ptr++;
00714          }
00715          else {                  /* Just append module.m on */
00716              strcpy(src_name_ptr, ".");
00717              src_name_ptr++;
00718          }
00719 
00720          TBL_REALLOC_CK(file_path_tbl, 1);
00721 
00722          strncpy(src_name_ptr, 
00723                  AT_OBJ_NAME_PTR(module_attr_idx), 
00724                  AT_NAME_LEN(module_attr_idx));
00725 
00726          src_name_ptr   += AT_NAME_LEN(module_attr_idx);
00727 
00728          /* KAY - Use for running the frontend alone. */
00729 
00730 # if 0
00731          strcpy(src_name_ptr, ".m");      /* Backend will delete this. */
00732 # endif
00733 
00734          strcpy(src_name_ptr, ".mn");     /* Backend will not delete this. */
00735 
00736          TBL_REALLOC_CK(file_path_tbl, 1);
00737          CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00738 
00739          fp_idx                   = file_path_tbl_idx;      
00740          FP_NEXT_FILE_IDX(fp_idx) = (ATP_PGM_UNIT(module_attr_idx) != Module) ? 
00741                                      inline_path_idx : module_path_idx;
00742          FP_NAME_LEN(fp_idx)      = strlen(mod_file_name);
00743          FP_NAME_IDX(fp_idx)      = str_pool_idx + 1;
00744          FP_SRCH_THE_FILE(fp_idx) = FALSE;
00745          length                   = WORD_LEN(FP_NAME_LEN(fp_idx));
00746          FP_CLASS(fp_idx)         = File_Fp;
00747 
00748          /* This file will be read up and copied by the backend.  It will be  */
00749          /* deleted by the backend (if suffix is .m) or the frontend if       */
00750          /* suffix if the file name suffix is .mn.                            */
00751 
00752          FP_TMP_FILE(fp_idx)    = TRUE;
00753 
00754          TBL_REALLOC_CK(str_pool, length);
00755 
00756          ptr = (long *) (&str_pool[FP_NAME_IDX(fp_idx)].name_long);
00757 
00758          memset(ptr, 0, length * TARGET_BYTES_PER_WORD);
00759 
00760          strcpy(FP_NAME_PTR(fp_idx), mod_file_name);
00761 
00762          if (num_prog_unit_errors == 0 && !dump_flags.no_module_output) {
00763 
00764             /* Send file name through interface to be put into the .o file. */
00765    
00766             FP_OUTPUT_TO_O(fp_idx)      = cmd_line_flags.binary_output;
00767          }
00768       }
00769 
00770 # elif defined(_MODULE_TO_DOT_M)
00771 
00772       if (fp_idx != NULL_IDX) {
00773 
00774          /* intentionally blank */
00775 
00776       }
00777       else if (m_file_fp_idx != NULL_IDX) {
00778          fp_idx         = m_file_fp_idx;
00779          fp_file_ptr    = fopen(FP_NAME_PTR(fp_idx), "ab");
00780          offset         = ftell(fp_file_ptr);
00781          fclose(fp_file_ptr);
00782       }
00783       else {
00784          mod_name_ptr   = &(mod_file_name[0]);
00785          src_name_ptr   = strrchr (src_file, SLASH);
00786          src_name_ptr   = (src_name_ptr == NULL) ? src_file : src_name_ptr+1;
00787 
00788          while (*mod_name_ptr++ = *src_name_ptr++);
00789 
00790          /* This returns a pointer to the last */
00791          /* occurence of dot in the file name  */
00792 
00793          src_name_ptr = strrchr (mod_file_name, DOT);
00794 
00795          if (src_name_ptr != NULL && 
00796              (EQUAL_STRS(src_name_ptr, ".f") ||
00797               EQUAL_STRS(src_name_ptr, ".f90"))){
00798             src_name_ptr++;
00799          }
00800          else {                  /* Just append module.m on */
00801             strcpy(src_name_ptr, ".");
00802             src_name_ptr++;
00803          }
00804 
00805          strcpy(src_name_ptr, "M");
00806 
00807          TBL_REALLOC_CK(file_path_tbl, 1);
00808          CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00809 
00810          fp_idx                   = file_path_tbl_idx;      
00811          FP_NEXT_FILE_IDX(fp_idx) = (ATP_PGM_UNIT(module_attr_idx) != Module) ? 
00812                                    inline_path_idx : module_path_idx;
00813          FP_NAME_LEN(fp_idx)      = strlen(mod_file_name);
00814          FP_NAME_IDX(fp_idx)      = str_pool_idx + 1;
00815          FP_SRCH_THE_FILE(fp_idx) = FALSE;
00816          length                   = WORD_LEN(FP_NAME_LEN(fp_idx));
00817          FP_CLASS(fp_idx)         = File_Fp;
00818 
00819          TBL_REALLOC_CK(str_pool, length);
00820 
00821          for (idx = FP_NAME_IDX(fp_idx); idx <= str_pool_idx; idx++) {        
00822             str_pool[idx].name_long = 0;
00823          }
00824 
00825          strcpy(FP_NAME_PTR(fp_idx), mod_file_name);
00826 
00827          m_file_fp_idx  = fp_idx;
00828          fp_file_ptr    = fopen(mod_file_name, "wb");
00829          fclose(fp_file_ptr);
00830       }
00831 # endif
00832    }
00833 
00834    /* Keep track of the file index for the first module written out.  This */
00835    /* will get updated with a directory listing all modules in this file.  */
00836 
00837    if (ATP_PGM_UNIT(module_attr_idx) == Module) {
00838 
00839       if (module_path_idx == NULL_IDX) {
00840          module_path_idx        = fp_idx;
00841       }
00842    }
00843    else if (inline_path_idx == NULL_IDX && !dump_flags.preinline) {
00844       inline_path_idx           = fp_idx;
00845    }
00846 
00847    /* Create an entry for the module being written out.  fp_idx  */
00848    /* is the file path table index for the file entry.           */
00849 
00850    TBL_REALLOC_CK(file_path_tbl, 1);
00851    CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
00852 
00853    /* Put this module at the top of the list. */
00854 
00855    FP_MODULE_IDX(file_path_tbl_idx)     = FP_MODULE_IDX(fp_idx);
00856    FP_MODULE_IDX(fp_idx)                = file_path_tbl_idx;
00857 
00858    FP_NAME_LEN(file_path_tbl_idx)       = AT_NAME_LEN(module_attr_idx);
00859    FP_NAME_IDX(file_path_tbl_idx)       = str_pool_idx + 1;
00860    FP_OFFSET(file_path_tbl_idx)         = offset;
00861    FP_FILE_IDX(file_path_tbl_idx)       = fp_idx;     /* Link to file entry */
00862    FP_CLASS(file_path_tbl_idx)          = Current_Compile_Fp;
00863 
00864    mod_idx                              = &(mit_header.wd[0]);
00865 
00866    for (idx=0; idx < sizeof(mit_header_type) / TARGET_BYTES_PER_WORD; idx++) {
00867       *mod_idx = 0;
00868        mod_idx++;
00869    }
00870    if (ga_idx != NULL_IDX) {
00871       GAP_FP_IDX(ga_idx)        = file_path_tbl_idx;
00872    }
00873    name_idx             = AT_NAME_IDX(module_attr_idx);
00874    wd_len               = WORD_LEN(AT_NAME_LEN(module_attr_idx));
00875    mod_idx              = MD_NAME_LONG;
00876    MD_NAME_LEN          = AT_NAME_LEN(module_attr_idx);
00877 
00878    TBL_REALLOC_CK(str_pool, wd_len);
00879 
00880    for (idx = FP_NAME_IDX(file_path_tbl_idx); idx <= str_pool_idx; idx++) {
00881       *mod_idx                  = name_pool[name_idx].name_long;
00882       str_pool[idx].name_long   = name_pool[name_idx].name_long;
00883       name_idx++;
00884       mod_idx++;
00885    }
00886 
00887    SCP_FILE_PATH_IDX(curr_scp_idx)      = fp_idx;
00888 
00889    TRACE (Func_Exit, "create_mod_info_file", NULL);
00890 
00891    return;
00892 
00893 }  /* create_mod_info_file */
00894 
00895 /******************************************************************************\
00896 |*                                                                            *|
00897 |* Description:                                                               *|
00898 |*      Create the module link table, which is used to output the module      *|
00899 |*      information table.                                                    *|
00900 |*                                                                            *|
00901 |* Input parameters:                                                          *|
00902 |*      NONE                                                                  *|
00903 |*                                                                            *|
00904 |* Output parameters:                                                         *|
00905 |*      NONE                                                                  *|
00906 |*                                                                            *|
00907 |* Returns:                                                                   *|
00908 |*      NOTHING                                                               *|
00909 |*                                                                            *|
00910 \******************************************************************************/
00911 void  create_mod_info_tbl(void)
00912 
00913 {
00914    int          attr_idx;
00915    int          name_idx;
00916 
00917 
00918    TRACE (Func_Entry, "create_mod_info_tbl", NULL);
00919 
00920    if (dump_flags.preinline && num_prog_unit_errors > 0) {
00921 
00922       /* Do not write out any tables.  Just the mod header. */
00923 
00924       return;
00925    }
00926 
00927    allocate_mod_link_tbl(0);  /* Determine size from longest table. */
00928 
00929    /* global flag used to tell set_mod_link_tbl_for_attr */
00930    /* that it should check all attrs for duplicates.     */
00931 
00932    search_for_duplicate_attrs   = FALSE;  /* Do not search */
00933 
00934    for (name_idx = SCP_LN_FW_IDX(MAIN_SCP_IDX) + 1;
00935         name_idx < SCP_LN_LW_IDX(MAIN_SCP_IDX); 
00936         name_idx++) {
00937 
00938       attr_idx = LN_ATTR_IDX(name_idx);
00939 
00940       if (attr_idx == SCP_ATTR_IDX(MAIN_SCP_IDX)) {
00941          KEEP_ATTR(attr_idx);
00942          ML_LN_KEEP_ME(name_idx)        =  TRUE;
00943          ML_LN_IDX(name_idx)            =  name_idx;
00944       }
00945       else if (AT_PRIVATE(attr_idx) || AT_OBJ_CLASS(attr_idx) == Label) {
00946 
00947          /* If object is PRIVATE, the name must not go into the name table.  */
00948          /* Also, Labels do not go out for the module itself.                */
00949 
00950       }
00951       else if (IS_STMT_ENTITY(attr_idx)) {
00952 
00953          /* This item is only used as the loop control variable in    */
00954          /* an implied-do.  It is only in the scope of the implied-do */
00955          /* and should not be written out to the module file.         */
00956       }
00957       else if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
00958                ATD_SYMBOLIC_CONSTANT(attr_idx) &&
00959                ATD_CLASS(attr_idx) == Constant) {
00960 
00961          /* N$PES was specified as a constant.  Do not output the actual     */
00962          /* constant to the module.  It should have been replaced all over.  */
00963       }
00964       else if (AT_USE_ASSOCIATED(attr_idx) &&
00965                AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
00966                ATP_PGM_UNIT(attr_idx) == Module) {
00967 
00968          /* This module has been use associated into this scope.  We do not */
00969          /* want the name in the local name table, although we do want to   */
00970          /* have the attribute entry for the module go out.                 */
00971       }
00972       else if (!ML_AT_KEEP_ME(attr_idx)) {
00973 
00974          /* if ML_AT_KEEP_ME is set, this attr entry has been processed. */
00975          /* It got processed because it was indexed to by another attr.  */
00976          /* (For example:  A derived type.)  Check to see if we need to  */
00977          /* keep the local name or not in the next else clause.          */
00978 
00979          if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
00980              ATP_PROC(attr_idx) == Module_Proc &&
00981              !AT_USE_ASSOCIATED(attr_idx)) {
00982 
00983             /* This is a module procedure declared during this       */
00984             /* compilation.  We need to resolve out any duplicate    */
00985             /* attrs that were used to describe the interface for    */
00986             /* the module procedure.  An example of a duplicate is   */
00987             /* if the same module is USEd in the module and the      */
00988             /* module procedure.  If a type from the module is used  */
00989             /* to describe the module procedure interface, then      */
00990             /* there will be duplicate attrs for the derived type.   */
00991             /* This mechanism resolves them to the same attr.        */
00992 
00993             search_for_duplicate_attrs  = TRUE;
00994          }
00995 
00996          KEEP_ATTR(attr_idx);
00997          ML_LN_KEEP_ME(name_idx)        = TRUE;
00998          ML_LN_IDX(name_idx)            = name_idx;
00999          search_for_duplicate_attrs     = FALSE;
01000       }
01001       else {
01002          ML_LN_KEEP_ME(name_idx)        = TRUE;
01003          ML_LN_IDX(name_idx)            = name_idx;
01004 
01005          /* This name gets included because of a link with another attr. */
01006          /* Can be a derived type, function result, CRI pointee, ect...  */
01007          /* Its attr_idx has already been marked as being needed.        */
01008       }
01009    }
01010 
01011    TRACE (Func_Exit, "create_mod_info_tbl", NULL);
01012 
01013    return;
01014 
01015 }   /* create_mod_info_tbl */
01016 
01017 /******************************************************************************\
01018 |*                                                                            *|
01019 |* Description:                                                               *|
01020 |*      Clear these fields in the attr entry, before it is written out to the *|
01021 |*      module file.                                                          *|
01022 |*                                                                            *|
01023 |* Input parameters:                                                          *|
01024 |*      NONE                                                                  *|
01025 |*                                                                            *|
01026 |* Output parameters:                                                         *|
01027 |*      NONE                                                                  *|
01028 |*                                                                            *|
01029 |* Returns:                                                                   *|
01030 |*      NOTHING                                                               *|
01031 |*                                                                            *|
01032 \******************************************************************************/
01033 static void  set_attr_flds_for_output()
01034 
01035 {
01036    int          attr_idx;
01037 
01038 
01039    TRACE (Func_Entry, "set_attr_flds_for_output", NULL);
01040 
01041    for (attr_idx = 1; attr_idx <= attr_tbl_idx; attr_idx++) {
01042 
01043       if (AT_ORIG_NAME_IDX(attr_idx) == NULL_IDX) {
01044          AT_ORIG_NAME_IDX(attr_idx) = AT_NAME_IDX(attr_idx);
01045          AT_ORIG_NAME_LEN(attr_idx) = AT_NAME_LEN(attr_idx);
01046       }
01047 
01048       switch (AT_OBJ_CLASS(attr_idx)) {
01049       case Data_Obj:
01050 
01051          if (ATD_CLASS(attr_idx) == Compiler_Tmp) {
01052             ATD_TMP_GEN_ZERO(attr_idx)          = FALSE;
01053          }
01054 
01055          if (ATD_CLASS(attr_idx) == Dummy_Argument && ATD_SF_DARG(attr_idx)) {
01056             ATD_SF_ARG_IDX(attr_idx)    = NULL_IDX;
01057             ATD_SF_LINK(attr_idx)       = NULL_IDX;
01058          }
01059          break;
01060 
01061       case Pgm_Unit:
01062          ATP_SCP_IDX(attr_idx)                  = NULL_IDX;
01063 
01064          if (ATP_PGM_UNIT(attr_idx) == Module) {
01065             ATP_MODULE_STR_IDX(attr_idx)        = NULL_IDX;
01066          }
01067          else if (ATP_PROC(attr_idx) == Intrin_Proc) {
01068             ATP_INTERFACE_IDX(attr_idx)         = NULL_IDX;
01069          }
01070          break;
01071 
01072       case Derived_Type:
01073          AT_DEFINED(attr_idx)                   = FALSE;
01074          ATT_CIF_DT_ID(attr_idx)                = 0;
01075          ATT_SCP_IDX(attr_idx)                  = NULL_IDX;
01076          break;
01077 
01078       case Label:  /* Do not clear AT_DEFINED here. */
01079          break;
01080 
01081       case Interface:
01082          ATI_HAS_NON_MOD_PROC(attr_idx)         = FALSE;
01083          break;
01084 
01085       case Stmt_Func:
01086       case Namelist_Grp:
01087          break;
01088 
01089       }  /* End switch */
01090    }  /* End for */
01091 
01092 
01093    TRACE (Func_Exit, "set_attr_flds_for_output", NULL);
01094 
01095    return;
01096 
01097 }   /* set_attr_flds_for_output */
01098 
01099 /******************************************************************************\
01100 |*                                                                            *|
01101 |* Description:                                                               *|
01102 |*      All these attr entries must be included in the entries that will be   *|
01103 |*      compressed.  Mark this attr and everything it links to, as being      *|
01104 |*      saved during the compression.                                         *|
01105 |*                                                                            *|
01106 |* Input parameters:                                                          *|
01107 |*      attr_idx   -> Index of attribute to process.                          *|
01108 |*                                                                            *|
01109 |* Output parameters:                                                         *|
01110 |*      NONE                                                                  *|
01111 |*                                                                            *|
01112 |* Returns:                                                                   *|
01113 |*      NOTHING                                                               *|
01114 |*                                                                            *|
01115 \******************************************************************************/
01116 static  void  set_mod_link_tbl_for_attr(int     attr_idx)
01117 
01118 {
01119    int          bd_idx;
01120    int          il_idx;
01121    int          save_duplicate_attr_flag;
01122    int          sb_idx;
01123    int          sh_idx;
01124    int          sn_idx;
01125 
01126 
01127    TRACE (Func_Entry, "set_mod_link_tbl_for_attr", NULL);
01128 
01129    if (ML_AT_KEEP_ME(attr_idx)) {
01130 
01131       /* All the links for this attr have been set, plus */
01132       /* resolve_attr has been called, if need be.       */
01133 
01134       return;
01135    }
01136 
01137    if ((ML_AT_SEARCH_ME(attr_idx) ||
01138        search_for_duplicate_attrs) && !ML_AT_SEARCHED(attr_idx)) {
01139 
01140       if (AT_MODULE_IDX(attr_idx) != NULL_IDX) {
01141          AT_REFERENCED(AT_MODULE_IDX(attr_idx)) = Referenced;
01142       }
01143 
01144       if (resolve_attr(attr_idx)) {
01145 
01146          /* If resolve_attr returns TRUE, this object is in this scope  */
01147          /* already.  Do not set any links for this attr.  We will use  */
01148          /* the attr that is already in this scope.  Mark the attr      */
01149          /* resolved to, so that it gets kept.                          */
01150        
01151          KEEP_ATTR(ML_AT_IDX(attr_idx));
01152          return;
01153       }
01154    }
01155 
01156    if (ML_AT_IDX(attr_idx) != NULL_IDX && ML_AT_IDX(attr_idx) != attr_idx) {
01157 
01158       /* This attr is being replaced by the attr in ML_AT_IDX.  */
01159       /* Keep the attr in ML_AT_IDX.                            */
01160 
01161       KEEP_ATTR(ML_AT_IDX(attr_idx));
01162       return;
01163    }
01164 
01165    ML_AT_KEEP_ME(attr_idx)              = TRUE;
01166    ML_AT_IDX(attr_idx)                  = attr_idx;
01167    ML_NP_KEEP_ME(AT_NAME_IDX(attr_idx)) = TRUE;
01168    ML_NP_IDX(AT_NAME_IDX(attr_idx))     = AT_NAME_IDX(attr_idx);
01169    ML_NP_LEN(AT_NAME_IDX(attr_idx))     = AT_NAME_LEN(attr_idx);
01170 
01171    if (AT_ORIG_NAME_IDX(attr_idx) != NULL_IDX) {
01172       ML_NP_KEEP_ME(AT_ORIG_NAME_IDX(attr_idx)) = TRUE;
01173       ML_NP_IDX(AT_ORIG_NAME_IDX(attr_idx))     = AT_ORIG_NAME_IDX(attr_idx);
01174       ML_NP_LEN(AT_ORIG_NAME_IDX(attr_idx))     = AT_ORIG_NAME_LEN(attr_idx);
01175    }
01176 
01177    if (AT_ATTR_LINK(attr_idx) != NULL_IDX && !AT_IGNORE_ATTR_LINK(attr_idx)) {
01178       KEEP_ATTR(AT_ATTR_LINK(attr_idx));
01179    }
01180 
01181    if (AT_MODULE_IDX(attr_idx) != NULL_IDX) {
01182       KEEP_ATTR(AT_MODULE_IDX(attr_idx));
01183    }
01184 
01185    switch (AT_OBJ_CLASS(attr_idx)) {
01186    case Data_Obj:
01187 
01188 # if defined(COARRAY_FORTRAN)
01189       bd_idx    = ATD_PE_ARRAY_IDX(attr_idx);
01190 
01191       if (bd_idx != NULL_IDX && !ML_BD_KEEP_ME(bd_idx)) {
01192          set_mod_link_tbl_for_bd(bd_idx);
01193       }
01194 # endif
01195 
01196       bd_idx    = ATD_RESHAPE_ARRAY_IDX(attr_idx);
01197 
01198       if (bd_idx != NULL_IDX && !ML_BD_KEEP_ME(bd_idx)) {
01199          set_mod_link_tbl_for_bd(bd_idx);
01200       }
01201 
01202       bd_idx    = ATD_ARRAY_IDX(attr_idx);
01203       sb_idx    = ATD_STOR_BLK_IDX(attr_idx);
01204 
01205       if (bd_idx != NULL_IDX && !ML_BD_KEEP_ME(bd_idx)) {
01206          set_mod_link_tbl_for_bd(bd_idx);
01207       }
01208 
01209       bd_idx    = ATD_DISTRIBUTION_IDX(attr_idx);
01210 
01211       if (bd_idx != NULL_IDX && !ML_BD_KEEP_ME(bd_idx)) {
01212          set_mod_link_tbl_for_bd(bd_idx);
01213       }
01214 
01215       if (sb_idx != NULL_IDX) {
01216          ML_SB_KEEP_ME(sb_idx)                  = TRUE;
01217          ML_SB_IDX(sb_idx)                      = sb_idx;
01218          ML_NP_KEEP_ME(SB_NAME_IDX(sb_idx))     = TRUE;
01219          ML_NP_IDX(SB_NAME_IDX(sb_idx))         = SB_NAME_IDX(sb_idx);
01220          ML_NP_LEN(SB_NAME_IDX(sb_idx))         = SB_NAME_LEN(sb_idx);
01221 
01222          if (SB_FIRST_ATTR_IDX(sb_idx) != NULL_IDX) {
01223             KEEP_ATTR(SB_FIRST_ATTR_IDX(sb_idx));
01224          }
01225 
01226          switch (SB_LEN_FLD(sb_idx)) {
01227          case AT_Tbl_Idx:
01228             KEEP_ATTR(SB_LEN_IDX(sb_idx));
01229             break;
01230 
01231          case CN_Tbl_Idx:
01232             KEEP_CN(SB_LEN_IDX(sb_idx));
01233             break;
01234 
01235          case IR_Tbl_Idx:
01236             KEEP_IR(SB_LEN_IDX(sb_idx));
01237             break;
01238 
01239          case IL_Tbl_Idx:
01240             set_mod_link_tbl_for_il(SB_LEN_IDX(sb_idx));
01241             break;
01242          }
01243 
01244          if (SB_MODULE_IDX(sb_idx) != NULL_IDX) {
01245             KEEP_ATTR(SB_MODULE_IDX(sb_idx));
01246          }
01247       }
01248 
01249       switch (ATD_CLASS(attr_idx)) {
01250       case CRI__Pointee:
01251          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01252          KEEP_ATTR(ATD_PTR_IDX(attr_idx));
01253          break;
01254 
01255       case Dummy_Argument:
01256 
01257          if (!ATD_INTRIN_DARG(attr_idx)) {
01258             set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01259          }
01260          break;
01261 
01262       case Constant:
01263          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01264 
01265          if (ATD_FLD(attr_idx) == CN_Tbl_Idx) {
01266             KEEP_CN(ATD_CONST_IDX(attr_idx));
01267          }
01268          else {
01269 
01270             /* If we are resolving attrs, we do not search for this tmp   */
01271             /* attr because its name is the same as the constant.  These  */
01272             /* two are a pair so we do not need to do a seperate search.  */
01273 
01274             ML_AT_SEARCHED(ATD_CONST_IDX(attr_idx))     = TRUE;
01275             KEEP_ATTR(ATD_CONST_IDX(attr_idx));
01276          }
01277          break;
01278 
01279       case Compiler_Tmp:
01280 
01281          if (ATD_NEXT_MEMBER_IDX(attr_idx) != NULL_IDX) {
01282             KEEP_ATTR(ATD_NEXT_MEMBER_IDX(attr_idx));
01283          }
01284 
01285          if (ATD_DEFINING_ATTR_IDX(attr_idx) != NULL_IDX) {
01286             KEEP_ATTR(ATD_DEFINING_ATTR_IDX(attr_idx));
01287          }
01288 
01289          if (ATD_AUTOMATIC(attr_idx)) {
01290             KEEP_ATTR(ATD_AUTO_BASE_IDX(attr_idx));
01291          }
01292          else if (ATD_OFFSET_ASSIGNED(attr_idx)) {
01293 
01294             switch (ATD_OFFSET_FLD(attr_idx)) {
01295             case AT_Tbl_Idx:
01296                KEEP_ATTR(ATD_OFFSET_IDX(attr_idx));
01297                break;
01298             case CN_Tbl_Idx:
01299                KEEP_CN(ATD_OFFSET_IDX(attr_idx));
01300                break;
01301             case IR_Tbl_Idx:
01302                KEEP_IR(ATD_OFFSET_IDX(attr_idx));
01303                break;
01304             case IL_Tbl_Idx:
01305                set_mod_link_tbl_for_il(ATD_OFFSET_IDX(attr_idx));
01306                break;
01307             }
01308          }
01309 
01310          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01311 
01312          switch (ATD_FLD(attr_idx)) {
01313          case CN_Tbl_Idx:
01314             KEEP_CN(ATD_TMP_IDX(attr_idx));
01315             break;
01316 
01317          case AT_Tbl_Idx:
01318             KEEP_ATTR(ATD_TMP_IDX(attr_idx));
01319             break;
01320 
01321          case IL_Tbl_Idx:
01322             set_mod_link_tbl_for_il(ATD_TMP_IDX(attr_idx));
01323             break;
01324 
01325          case IR_Tbl_Idx:
01326             KEEP_IR(ATD_TMP_IDX(attr_idx));
01327             break;
01328          }
01329          break;
01330 
01331       case Function_Result:
01332 
01333          if (ATD_OFFSET_ASSIGNED(attr_idx)) {
01334 
01335             switch (ATD_OFFSET_FLD(attr_idx)) {
01336             case AT_Tbl_Idx:
01337                KEEP_ATTR(ATD_OFFSET_IDX(attr_idx));
01338                break;
01339             case CN_Tbl_Idx:
01340                KEEP_CN(ATD_OFFSET_IDX(attr_idx));
01341                break;
01342             case IR_Tbl_Idx:
01343                KEEP_IR(ATD_OFFSET_IDX(attr_idx));
01344                break;
01345             case IL_Tbl_Idx:
01346                set_mod_link_tbl_for_il(ATD_OFFSET_IDX(attr_idx));
01347                break;
01348             }
01349          }
01350          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01351          break;
01352         
01353 
01354       case Struct_Component:
01355 
01356          switch (ATD_OFFSET_FLD(attr_idx)) {
01357          case AT_Tbl_Idx:
01358             KEEP_ATTR(ATD_CPNT_OFFSET_IDX(attr_idx));
01359             break;
01360          case CN_Tbl_Idx:
01361             KEEP_CN(ATD_CPNT_OFFSET_IDX(attr_idx));
01362             break;
01363          case IR_Tbl_Idx:
01364             KEEP_IR(ATD_CPNT_OFFSET_IDX(attr_idx));
01365             break;
01366          case IL_Tbl_Idx:
01367             set_mod_link_tbl_for_il(ATD_CPNT_OFFSET_IDX(attr_idx));
01368             break;
01369          }
01370 
01371          if (ATD_CPNT_INIT_IDX(attr_idx) != NULL_IDX) {
01372 
01373             switch (ATD_FLD(attr_idx)) {
01374             case AT_Tbl_Idx:
01375                KEEP_ATTR(ATD_CPNT_INIT_IDX(attr_idx));
01376                break;
01377             case CN_Tbl_Idx:
01378                KEEP_CN(ATD_CPNT_INIT_IDX(attr_idx));
01379                break;
01380             case IR_Tbl_Idx:
01381                KEEP_IR(ATD_CPNT_INIT_IDX(attr_idx));
01382                break;
01383             case IL_Tbl_Idx:
01384                set_mod_link_tbl_for_il(ATD_CPNT_INIT_IDX(attr_idx));
01385                break;
01386             }
01387          }
01388 
01389          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01390          KEEP_ATTR(ATD_DERIVED_TYPE_IDX(attr_idx));
01391          break;
01392 
01393       case Variable:
01394 
01395          if (ATD_DATA_INIT(attr_idx)) {
01396 
01397             if (ATD_FLD(attr_idx) == NO_Tbl_Idx) {
01398                /* Intentionally blank */
01399             }
01400             else if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
01401 
01402                /* If we are resolving attrs, we do not search for this tmp   */
01403                /* attr because its name is the same as the variable.  These  */
01404                /* two are a pair so we do not need to do a seperate search.  */
01405 
01406                ML_AT_SEARCHED(ATD_VARIABLE_TMP_IDX(attr_idx))   = TRUE;
01407                KEEP_ATTR(ATD_VARIABLE_TMP_IDX(attr_idx));
01408             }
01409             else if (ATD_FLD(attr_idx) == IL_Tbl_Idx) {
01410 
01411                /* See previous note. */
01412 
01413                il_idx = ATD_VARIABLE_TMP_IDX(attr_idx);
01414 
01415                while (il_idx != NULL_IDX) {
01416    
01417                   if (IL_FLD(il_idx) == AT_Tbl_Idx) {
01418                      ML_AT_SEARCHED(IL_IDX(il_idx)) = TRUE;
01419                   }
01420                   il_idx = IL_NEXT_LIST_IDX(il_idx);
01421                }
01422 
01423                set_mod_link_tbl_for_il(ATD_VARIABLE_TMP_IDX(attr_idx));
01424             }
01425          }
01426          else if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
01427             KEEP_ATTR(ATD_VARIABLE_TMP_IDX(attr_idx));
01428          }
01429 
01430          if (ATD_NEXT_MEMBER_IDX(attr_idx) != NULL_IDX) {
01431             KEEP_ATTR(ATD_NEXT_MEMBER_IDX(attr_idx));
01432          }
01433 
01434          if (ATD_ASSIGN_TMP_IDX(attr_idx) != NULL_IDX) {
01435             KEEP_ATTR(ATD_ASSIGN_TMP_IDX(attr_idx));
01436          }
01437 
01438          if (ATD_AUTOMATIC(attr_idx)) {
01439             KEEP_ATTR(ATD_AUTO_BASE_IDX(attr_idx));
01440          }
01441          else if (ATD_OFFSET_ASSIGNED(attr_idx)) {
01442 
01443             switch (ATD_OFFSET_FLD(attr_idx)) {
01444             case AT_Tbl_Idx:
01445                KEEP_ATTR(ATD_OFFSET_IDX(attr_idx));
01446                break;
01447             case CN_Tbl_Idx:
01448                KEEP_CN(ATD_OFFSET_IDX(attr_idx));
01449                break;
01450             case IR_Tbl_Idx:
01451                KEEP_IR(ATD_OFFSET_IDX(attr_idx));
01452                break;
01453             case IL_Tbl_Idx:
01454                set_mod_link_tbl_for_il(ATD_OFFSET_IDX(attr_idx));
01455                break;
01456             }
01457          }
01458 
01459          /* Intentional fall through */
01460 
01461       default:
01462 
01463          set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01464          break;
01465       }
01466       break;
01467 
01468 
01469    case Pgm_Unit:
01470 
01471       ML_NP_KEEP_ME(ATP_EXT_NAME_IDX(attr_idx)) = TRUE;
01472       ML_NP_IDX(ATP_EXT_NAME_IDX(attr_idx))     = ATP_EXT_NAME_IDX(attr_idx);
01473       ML_NP_LEN(ATP_EXT_NAME_IDX(attr_idx))     = ATP_EXT_NAME_LEN(attr_idx);
01474 
01475       if (ATP_PGM_UNIT(attr_idx) == Module) {
01476 
01477          if (ATP_MOD_PATH_LEN(attr_idx) > 0) {
01478             ML_NP_KEEP_ME(ATP_MOD_PATH_IDX(attr_idx)) = TRUE;
01479             ML_NP_IDX(ATP_MOD_PATH_IDX(attr_idx)) = ATP_MOD_PATH_IDX(attr_idx);
01480             ML_NP_LEN(ATP_MOD_PATH_IDX(attr_idx)) = ATP_MOD_PATH_LEN(attr_idx);
01481          }
01482       }
01483       else {
01484 
01485          if (ATP_RSLT_IDX(attr_idx) != NULL_IDX) {
01486             KEEP_ATTR(ATP_RSLT_IDX(attr_idx));
01487          }
01488 
01489          if (ATP_NUM_DARGS(attr_idx) > 0) {
01490 
01491             for (sn_idx = ATP_FIRST_IDX(attr_idx); 
01492                  sn_idx < (ATP_FIRST_IDX(attr_idx) + ATP_NUM_DARGS(attr_idx));
01493                  sn_idx++) {
01494 
01495                ML_SN_KEEP_ME(sn_idx)    = TRUE;
01496                ML_SN_IDX(sn_idx)        = sn_idx;
01497 
01498                KEEP_ATTR(SN_ATTR_IDX(sn_idx));
01499             }
01500          }
01501 
01502          /* This flag works for all 3 uses of this routine.             */
01503 
01504          /* 1) It is called when a use statement is processed.          */
01505          /*    ATP_MAY_INLINE will be set for all procedures            */
01506          /*    coming from the module that carry IR/SH with them.       */
01507          /* 2) During interface processing, if there are any use        */
01508          /*    associated procedures, they will have the mod            */
01509          /*    inlinable flag set correctly.  If they are not, they     */
01510          /*    will not have the mod inlinable flag set.                */
01511          /* 3) During processing, to send module info out, only those   */
01512          /*    procedures that have the mod inlinable flag set, go out. */
01513 
01514          if (ATP_MAY_INLINE(attr_idx)) {
01515 
01516             /* This is the body of the module/internal procedure.  We   */
01517             /* do not want to search for duplicate attrs here.  If we   */
01518             /* do, we get things confused because of host association.  */
01519 
01520             save_duplicate_attr_flag    = search_for_duplicate_attrs;
01521             search_for_duplicate_attrs  = FALSE;
01522             sh_idx                      = ATP_FIRST_SH_IDX(attr_idx);
01523 
01524             while (sh_idx != NULL_IDX) {
01525                ML_SH_KEEP_ME(sh_idx)    = TRUE;
01526                ML_SH_IDX(sh_idx)        = sh_idx;
01527 
01528                if (SH_IR_IDX(sh_idx) != NULL_IDX) {
01529                   KEEP_IR(SH_IR_IDX(sh_idx));
01530                }
01531                sh_idx                   = SH_NEXT_IDX(sh_idx);
01532             }
01533 
01534             if (ATP_PROC(attr_idx) != Dummy_Proc &&
01535                 ATP_PROC(attr_idx) != Intrin_Proc) {
01536 
01537                if (ATP_PARENT_IDX(attr_idx) != NULL_IDX) {
01538                   KEEP_ATTR(ATP_PARENT_IDX(attr_idx));
01539                }
01540             }
01541             search_for_duplicate_attrs  = save_duplicate_attr_flag;
01542          }
01543          else if (ATP_PROC(attr_idx) != Intrin_Proc) {
01544             ATP_FIRST_SH_IDX(attr_idx)  = NULL_IDX;
01545          }
01546       }
01547       break;
01548 
01549    case Label:
01550 
01551       if (ATL_CLASS(attr_idx) == Lbl_Format) {
01552          KEEP_ATTR(ATL_PP_FORMAT_TMP(attr_idx));
01553          KEEP_ATTR(ATL_FORMAT_TMP(attr_idx));
01554       }
01555       else if (ATL_DIRECTIVE_LIST(attr_idx) != NULL_IDX) {
01556          set_mod_link_tbl_for_il(ATL_DIRECTIVE_LIST(attr_idx));
01557       }
01558 
01559       if (ATL_NEXT_ASG_LBL_IDX(attr_idx) != NULL_IDX) {
01560          KEEP_ATTR(ATL_NEXT_ASG_LBL_IDX(attr_idx));
01561       }
01562       break;
01563 
01564    case Interface:
01565       set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01566 
01567       /* During resolve_attrs we do not search for interface names.  */
01568       /* We cannot gurantee they are the same because of merging.    */
01569 
01570       if (ATI_PROC_IDX(attr_idx) != NULL_IDX) {
01571 
01572          /* If we are resolving attrs, we do not search for this proc */
01573          /* attr because it has the same name as the interface name.  */
01574 
01575          ML_AT_SEARCHED(ATI_PROC_IDX(attr_idx)) = TRUE;
01576       }
01577 
01578       sn_idx = ATI_FIRST_SPECIFIC_IDX(attr_idx);
01579 
01580       while (sn_idx != NULL_IDX) {
01581          ML_SN_KEEP_ME(sn_idx)  = TRUE;
01582          ML_SN_IDX(sn_idx)      = sn_idx;
01583          KEEP_ATTR(SN_ATTR_IDX(sn_idx));
01584          sn_idx                 = SN_SIBLING_LINK(sn_idx);
01585       }
01586       break;
01587 
01588    case Derived_Type:
01589 
01590       switch (ATT_STRUCT_BIT_LEN_FLD(attr_idx)) {
01591       case AT_Tbl_Idx:
01592          KEEP_ATTR(ATT_STRUCT_BIT_LEN_IDX(attr_idx));
01593          break;
01594 
01595       case CN_Tbl_Idx:
01596          KEEP_CN(ATT_STRUCT_BIT_LEN_IDX(attr_idx));
01597          break;
01598 
01599       case IR_Tbl_Idx:
01600          KEEP_IR(ATT_STRUCT_BIT_LEN_IDX(attr_idx));
01601          break;
01602 
01603       case IL_Tbl_Idx:
01604          set_mod_link_tbl_for_il(ATT_STRUCT_BIT_LEN_IDX(attr_idx));
01605          break;
01606       }
01607 
01608       sn_idx                    = ATT_FIRST_CPNT_IDX(attr_idx);
01609 
01610       while (sn_idx != NULL_IDX) {
01611          ML_SN_KEEP_ME(sn_idx)  = TRUE;
01612          ML_SN_IDX(sn_idx)      = sn_idx;
01613 
01614          /* We do not resolve components, because the name are not unique. */
01615 
01616          ML_AT_SEARCHED(SN_ATTR_IDX(sn_idx)) = TRUE;
01617          KEEP_ATTR(SN_ATTR_IDX(sn_idx));
01618          sn_idx = SN_SIBLING_LINK(sn_idx);
01619       }
01620       break;
01621 
01622    case Namelist_Grp:
01623       sn_idx = ATN_FIRST_NAMELIST_IDX(attr_idx);
01624 
01625       while (sn_idx != NULL_IDX) {
01626          ML_SN_KEEP_ME(sn_idx)  = TRUE;
01627          ML_SN_IDX(sn_idx)      = sn_idx;
01628          KEEP_ATTR (SN_ATTR_IDX(sn_idx));
01629          sn_idx                 = SN_SIBLING_LINK(sn_idx);
01630       }
01631 
01632       if (ATN_NAMELIST_DESC(attr_idx) != NULL_IDX) {
01633          KEEP_ATTR(ATN_NAMELIST_DESC(attr_idx));
01634       }
01635       break;
01636 
01637 
01638    case Stmt_Func:
01639       set_mod_link_tbl_for_typ(ATD_TYPE_IDX(attr_idx));
01640 
01641       if (ATP_NUM_DARGS(attr_idx) > 0) {
01642 
01643          for (sn_idx = ATP_FIRST_IDX(attr_idx); 
01644               sn_idx < (ATP_FIRST_IDX(attr_idx) +ATP_NUM_DARGS(attr_idx));
01645               sn_idx++) {
01646 
01647             ML_SN_KEEP_ME(sn_idx)       = TRUE;
01648             ML_SN_IDX(sn_idx)           = sn_idx;
01649             KEEP_ATTR(SN_ATTR_IDX(sn_idx));
01650          }
01651       }
01652 
01653       switch (ATS_SF_FLD(attr_idx)) {
01654       case CN_Tbl_Idx:
01655          KEEP_CN(ATS_SF_IDX(attr_idx));
01656          break;
01657 
01658       case AT_Tbl_Idx:
01659          KEEP_ATTR(ATS_SF_IDX(attr_idx));
01660          break;
01661 
01662       case IL_Tbl_Idx:
01663          set_mod_link_tbl_for_il(ATS_SF_IDX(attr_idx));
01664          break;
01665 
01666       case IR_Tbl_Idx:
01667          KEEP_IR(ATS_SF_IDX(attr_idx));
01668          break;
01669       }
01670       break;
01671 
01672    }  /* End switch */
01673 
01674    TRACE (Func_Exit, "set_mod_link_tbl_for_attr ", NULL);
01675 
01676    return;
01677 
01678 }   /* set_mod_link_tbl_for_attr  */
01679 
01680 /******************************************************************************\
01681 |*                                                                            *|
01682 |* Description:                                                               *|
01683 |*      Set fields in the module link table for BD.                           *|
01684 |*                                                                            *|
01685 |* Input parameters:                                                          *|
01686 |*      bd_idx      => Index to set link fields for.                          *|
01687 |*                                                                            *|
01688 |* Output parameters:                                                         *|
01689 |*      NONE                                                                  *|
01690 |*                                                                            *|
01691 |* Returns:                                                                   *|
01692 |*      NOTHING                                                               *|
01693 |*                                                                            *|
01694 \******************************************************************************/
01695 static  void  set_mod_link_tbl_for_bd(int       bd_idx)
01696 
01697 {
01698    int          dim;
01699 
01700 
01701    TRACE (Func_Entry, "set_mod_link_tbl_for_bd ", NULL);
01702 
01703    ML_BD_KEEP_ME(bd_idx)        = TRUE;
01704    ML_BD_IDX(bd_idx)            = bd_idx;
01705 
01706    if (BD_DIST_NTRY(bd_idx)) {
01707 
01708       for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
01709 
01710          if (BD_CYCLIC_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01711             KEEP_CN(BD_CYCLIC_IDX(bd_idx, dim));
01712          }
01713          else if (BD_CYCLIC_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01714             KEEP_ATTR(BD_CYCLIC_IDX(bd_idx, dim));
01715          }
01716 
01717          if (BD_ONTO_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01718             KEEP_CN(BD_ONTO_IDX(bd_idx, dim));
01719          }
01720          else if (BD_ONTO_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01721             KEEP_ATTR(BD_ONTO_IDX(bd_idx, dim));
01722          }
01723       }
01724    }
01725    else if (BD_ARRAY_CLASS(bd_idx) != Deferred_Shape) {
01726 
01727       if (BD_LEN_FLD(bd_idx) == CN_Tbl_Idx) {
01728          KEEP_CN(BD_LEN_IDX(bd_idx));
01729       }
01730       else if (BD_LEN_FLD(bd_idx) == AT_Tbl_Idx) {
01731          KEEP_ATTR(BD_LEN_IDX(bd_idx));
01732       }
01733 
01734       for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
01735 
01736          if (BD_LB_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01737             KEEP_CN(BD_LB_IDX(bd_idx, dim));
01738          }
01739          else if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01740             KEEP_ATTR(BD_LB_IDX(bd_idx, dim));
01741          }
01742 
01743          if (BD_UB_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01744             KEEP_CN(BD_UB_IDX(bd_idx, dim));
01745          }
01746          else if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01747             KEEP_ATTR(BD_UB_IDX(bd_idx, dim));
01748          }
01749 
01750          if (BD_XT_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01751             if (BD_XT_IDX(bd_idx, dim)) {
01752               KEEP_CN(BD_XT_IDX(bd_idx, dim));
01753             }
01754          }
01755          else if (BD_XT_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01756             KEEP_ATTR(BD_XT_IDX(bd_idx, dim));
01757          }
01758 
01759          if (BD_SM_FLD(bd_idx, dim) == CN_Tbl_Idx) {
01760             KEEP_CN(BD_SM_IDX(bd_idx, dim));
01761          }
01762          else if (BD_SM_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01763             KEEP_ATTR(BD_SM_IDX(bd_idx, dim));
01764          }
01765       }
01766    }
01767 
01768    TRACE (Func_Exit, "set_mod_link_tbl_for_bd ", NULL);
01769 
01770    return;
01771 
01772 }   /* set_mod_link_tbl_for_bd  */
01773 
01774 /******************************************************************************\
01775 |*                                                                            *|
01776 |* Description:                                                               *|
01777 |*      Set fields in the module link table for IR.                           *|
01778 |*                                                                            *|
01779 |* Input parameters:                                                          *|
01780 |*      ir_idx      => Index to set link fields for.                          *|
01781 |*                                                                            *|
01782 |* Output parameters:                                                         *|
01783 |*      NONE                                                                  *|
01784 |*                                                                            *|
01785 |* Returns:                                                                   *|
01786 |*      NOTHING                                                               *|
01787 |*                                                                            *|
01788 \******************************************************************************/
01789 static  void  set_mod_link_tbl_for_ir(int       ir_idx)
01790 
01791 {
01792 
01793    TRACE (Func_Entry, "set_mod_link_tbl_for_ir", NULL);
01794 
01795    if (ML_IR_KEEP_ME(ir_idx)) {
01796       return;
01797    }
01798 
01799    ML_IR_KEEP_ME(ir_idx)        = TRUE;
01800    ML_IR_IDX(ir_idx)            = ir_idx;
01801 
01802    set_mod_link_tbl_for_typ(IR_TYPE_IDX(ir_idx));
01803 
01804    switch (IR_FLD_L(ir_idx)) {
01805    case CN_Tbl_Idx:
01806       KEEP_CN(IR_IDX_L(ir_idx));
01807       break;
01808 
01809    case AT_Tbl_Idx:
01810       KEEP_ATTR(IR_IDX_L(ir_idx));
01811       break;
01812 
01813    case IR_Tbl_Idx:
01814       KEEP_IR(IR_IDX_L(ir_idx));
01815       break;
01816 
01817    case IL_Tbl_Idx:
01818       set_mod_link_tbl_for_il(IR_IDX_L(ir_idx));
01819       break;
01820 
01821    case NO_Tbl_Idx:
01822    case SH_Tbl_Idx:
01823       break;
01824    }
01825 
01826    switch (IR_FLD_R(ir_idx)) {
01827    case CN_Tbl_Idx:
01828       KEEP_CN(IR_IDX_R(ir_idx));
01829       break;
01830 
01831    case AT_Tbl_Idx:
01832       KEEP_ATTR(IR_IDX_R(ir_idx));
01833       break;
01834 
01835    case IR_Tbl_Idx:
01836       KEEP_IR(IR_IDX_R(ir_idx));
01837       break;
01838 
01839    case IL_Tbl_Idx:
01840       set_mod_link_tbl_for_il(IR_IDX_R(ir_idx));
01841       break;
01842 
01843    case NO_Tbl_Idx:
01844    case SH_Tbl_Idx:
01845       break;
01846    }
01847    
01848    TRACE (Func_Exit, "set_mod_link_tbl_for_ir", NULL);
01849 
01850    return;
01851 
01852 }   /* set_mod_link_tbl_for_ir */
01853 
01854 /******************************************************************************\
01855 |*                                                                            *|
01856 |* Description:                                                               *|
01857 |*      Set fields in the module link table for IL.                           *|
01858 |*                                                                            *|
01859 |* Input parameters:                                                          *|
01860 |*      list_idx    => Index to set link fields for.                          *|
01861 |*                                                                            *|
01862 |* Output parameters:                                                         *|
01863 |*      NONE                                                                  *|
01864 |*                                                                            *|
01865 |* Returns:                                                                   *|
01866 |*      NOTHING                                                               *|
01867 |*                                                                            *|
01868 \******************************************************************************/
01869 static  void  set_mod_link_tbl_for_il(int       list_idx)
01870 
01871 {
01872 
01873    TRACE (Func_Entry, "set_mod_link_tbl_for_il", NULL);
01874 
01875    if (ML_IL_KEEP_ME(list_idx)) {
01876       return;
01877    }
01878 
01879    while (list_idx != NULL_IDX) {
01880       ML_IL_KEEP_ME(list_idx)   = TRUE;
01881       ML_IL_IDX(list_idx)       = list_idx;
01882 
01883       switch (IL_FLD(list_idx)) {
01884          case CN_Tbl_Idx:
01885             KEEP_CN(IL_IDX(list_idx));
01886             break;
01887 
01888          case AT_Tbl_Idx:
01889             KEEP_ATTR(IL_IDX(list_idx));
01890             break;
01891 
01892          case IR_Tbl_Idx:
01893             KEEP_IR(IL_IDX(list_idx));
01894             break;
01895 
01896          case IL_Tbl_Idx:
01897             set_mod_link_tbl_for_il(IL_IDX(list_idx));
01898             break;
01899 
01900          case NO_Tbl_Idx:
01901          case SH_Tbl_Idx:
01902             break;
01903       }
01904       list_idx = IL_NEXT_LIST_IDX(list_idx);
01905    }
01906    
01907    TRACE (Func_Exit, "set_mod_link_tbl_for_il", NULL);
01908 
01909    return;
01910 
01911 }   /* set_mod_link_tbl_for_il */
01912 
01913 /******************************************************************************\
01914 |*                                                                            *|
01915 |* Description:                                                               *|
01916 |*      Set fields in the module link table for a constant table entry.       *|
01917 |*                                                                            *|
01918 |* Input parameters:                                                          *|
01919 |*      cn_idx => Index of constant table entry to have links set.            *|
01920 |*                                                                            *|
01921 |* Output parameters:                                                         *|
01922 |*      NONE                                                                  *|
01923 |*                                                                            *|
01924 |* Returns:                                                                   *|
01925 |*      NOTHING                                                               *|
01926 |*                                                                            *|
01927 \******************************************************************************/
01928 static  void  set_mod_link_tbl_for_cn(int       cn_idx)
01929 
01930 {
01931    size_offset_type     len;
01932    long                 length;
01933    int                  type_idx;
01934 
01935 
01936    TRACE (Func_Entry, "set_mod_link_tbl_for_cn", NULL);
01937 
01938    /* KAY - TEMPORARY - REPLACE WITH INTERNAL ERROR               */
01939    /*       If cn_idx is NULL, it should be an internal situation */
01940 
01941    if (cn_idx == NULL_IDX) {
01942       PRINTMSG(stmt_start_line, 626, Internal, stmt_start_col,
01943                "non zero cn_idx",
01944                "set_mod_link_tbl_for_cn");
01945    }
01946 
01947    if (!ML_CN_KEEP_ME(cn_idx)) {
01948       ML_CN_KEEP_ME(cn_idx)     = TRUE;
01949       ML_CN_IDX(cn_idx)         = cn_idx;
01950       type_idx                  = CN_TYPE_IDX(cn_idx);
01951 
01952       set_mod_link_tbl_for_typ(type_idx);
01953 
01954       switch (TYP_TYPE(type_idx)) {
01955       case Typeless:
01956          length = (long) (CN_EXTRA_ZERO_WORD(cn_idx) ?
01957                               STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx)) + 1 :
01958                               STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx)));
01959          break;
01960 
01961       case Character:
01962          len.idx        = TYP_IDX(type_idx);
01963          len.fld        = CN_Tbl_Idx;
01964 
01965          BYTES_TO_WORDS(len, TARGET_BITS_PER_WORD);
01966 
01967          if (len.fld == CN_Tbl_Idx) {
01968             length = (long) CN_INT_TO_C(len.idx);  /* KAYKAY */
01969          }
01970          else {
01971             length = (long) F_INT_TO_C(len.constant, TYP_LINEAR(len.type_idx));
01972          }
01973          length = CN_EXTRA_ZERO_WORD(cn_idx) ? length + 1: length;
01974          break;
01975 
01976 # if defined(_TARGET_OS_MAX)
01977       case Complex:
01978          if (TYP_LINEAR(type_idx) == Complex_4) {
01979 
01980             /* Complex_4 constants are stored in two words on t3e */
01981 
01982             length = 2;
01983          }
01984          else {
01985             length = TARGET_BITS_TO_WORDS(
01986                   storage_bit_size_tbl[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]);
01987          }
01988          break;
01989 # endif
01990 
01991       default:
01992          length = TARGET_BITS_TO_WORDS(
01993                   storage_bit_size_tbl[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]);
01994          break;
01995       }
01996 
01997       ML_CP_LEN(CN_POOL_IDX(cn_idx))            = length;
01998       ML_CP_KEEP_ME(CN_POOL_IDX(cn_idx))        = TRUE;
01999       ML_CP_IDX(CN_POOL_IDX(cn_idx))            = CN_POOL_IDX(cn_idx);
02000 
02001 # if defined(_HOST32) 
02002 
02003       if (DALIGN_TEST_CONDITION(type_idx)) {
02004           ML_CP_DALIGN_ME(CN_POOL_IDX(cn_idx))  = TRUE;
02005       }
02006 
02007 # endif
02008    }
02009 
02010    TRACE (Func_Exit, "set_mod_link_tbl_for_cn", NULL);
02011 
02012    return;
02013 
02014 }   /* set_mod_link_tbl_for_cn */
02015 
02016 /******************************************************************************\
02017 |*                                                                            *|
02018 |* Description:                                                               *|
02019 |*      Set fields in the module link table for TYP.                          *|
02020 |*                                                                            *|
02021 |* Input parameters:                                                          *|
02022 |*      typ_idx     => Index to set link fields for.                          *|
02023 |*                                                                            *|
02024 |* Output parameters:                                                         *|
02025 |*      NONE                                                                  *|
02026 |*                                                                            *|
02027 |* Returns:                                                                   *|
02028 |*      NOTHING                                                               *|
02029 |*                                                                            *|
02030 \******************************************************************************/
02031 static  void  set_mod_link_tbl_for_typ(int      typ_idx)
02032 
02033 {
02034    int          attr_idx;
02035 
02036 
02037    TRACE (Func_Entry, "set_mod_link_tbl_for_typ", NULL);
02038 
02039    if (typ_idx != NULL_IDX && !ML_TYP_KEEP_ME(typ_idx)) {
02040       ML_TYP_KEEP_ME(typ_idx)   = TRUE;
02041       ML_TYP_IDX(typ_idx)       = typ_idx;
02042 
02043       if (TYP_TYPE(typ_idx) == Character) {
02044 
02045          if (TYP_FLD(typ_idx) == CN_Tbl_Idx) {
02046             KEEP_CN(TYP_IDX(typ_idx));
02047          }
02048          else if (TYP_FLD(typ_idx) == AT_Tbl_Idx) {
02049             KEEP_ATTR(TYP_IDX(typ_idx));
02050          }
02051       }
02052       else if (TYP_TYPE(typ_idx) == Structure) {
02053          attr_idx = TYP_IDX(typ_idx);
02054    
02055          while (AT_ATTR_LINK(attr_idx) != NULL_IDX) {
02056             attr_idx = AT_ATTR_LINK(attr_idx);
02057          }
02058    
02059          TYP_IDX(typ_idx) = attr_idx;
02060 
02061          KEEP_ATTR(attr_idx);
02062       }
02063    }
02064 
02065    TRACE (Func_Exit, "set_mod_link_tbl_for_typ", NULL);
02066 
02067    return;
02068 
02069 }  /* set_mod_link_tbl_for_typ */
02070 
02071 /******************************************************************************\
02072 |*                                                                            *|
02073 |* Description:                                                               *|
02074 |*      Go through the module link table, assigning new indexes to all        *|
02075 |*      entries that must be left in the compressed tables.                   *|
02076 |*      The zeroth entry of the mod link table contains the index to start    *|
02077 |*      for each of the tables.  This is the mod link index to start with     *|
02078 |*      and the tbl index to start assigning with.                            *|
02079 |*                                                                            *|
02080 |* Input parameters:                                                          *|
02081 |*      NONE                                                                  *|
02082 |*                                                                            *|
02083 |* Output parameters:                                                         *|
02084 |*      NONE                                                                  *|
02085 |*                                                                            *|
02086 |* Returns:                                                                   *|
02087 |*      NOTHING                                                               *|
02088 |*                                                                            *|
02089 \******************************************************************************/
02090 static void  assign_new_idxs(boolean    resolving_duplicates)
02091 
02092 {
02093    int          at_new_tbl_idx  = ML_AT_IDX(0) + 1;
02094    int          bd_new_tbl_idx  = ML_BD_IDX(0) + 1;
02095    int          cn_new_tbl_idx  = ML_CN_IDX(0) + 1;
02096    int          cp_new_tbl_idx  = ML_CP_IDX(0) + 1;
02097    int          end_idx;
02098    int          idx;
02099    int          il_new_tbl_idx  = ML_IL_IDX(0) + 1;
02100    int          ir_new_tbl_idx  = ML_IR_IDX(0) + 1;
02101    int          ln_new_tbl_idx  = ML_LN_IDX(0) + 1;
02102    int          mod_idx;
02103    int          new_idx;
02104    int          np_new_tbl_idx  = ML_NP_IDX(0) + 1;
02105    int          sb_new_tbl_idx  = ML_SB_IDX(0) + 1;
02106    int          sh_new_tbl_idx  = ML_SH_IDX(0) + 1;
02107    int          sn_new_tbl_idx  = ML_SN_IDX(0) + 1;
02108    int          typ_new_tbl_idx = ML_TYP_IDX(0)+ 1;
02109 
02110 
02111    /* All the ML_xx_IDX(0) are the last used indexes for the tables */
02112 
02113 
02114    TRACE (Func_Entry, "assign_new_idxs", NULL);
02115 
02116    if (save_const_tbl_idx != NULL_IDX) {
02117 
02118       /* We are processing an incoming module.  We have left room */
02119       /* for a copy of the full constant table and constant pool. */
02120 
02121       end_idx           = const_tbl_idx;
02122       const_tbl_idx     = save_const_tbl_idx;
02123       const_pool_idx    = save_const_pool_idx;
02124 
02125   Pragma("_CRI ivdep")        
02126 
02127       for (mod_idx = 1; mod_idx < cn_new_tbl_idx; mod_idx++) {
02128          ML_CN_IDX(mod_idx)     = mod_idx;
02129       }
02130 
02131   Pragma("_CRI ivdep")        
02132 
02133       for (mod_idx = 1; mod_idx < cp_new_tbl_idx; mod_idx++) {
02134          ML_CP_IDX(mod_idx)     = mod_idx;
02135       }
02136 
02137       for (mod_idx = cn_new_tbl_idx; mod_idx <= end_idx; mod_idx++) {
02138 
02139          if (ML_CN_KEEP_ME(mod_idx)) {
02140             new_idx             = ntr_const_tbl(CN_TYPE_IDX(mod_idx),
02141                                                 CN_EXTRA_ZERO_WORD(mod_idx),
02142                                                 &CN_CONST(mod_idx));
02143             ML_CN_IDX(mod_idx)  = new_idx;
02144          }
02145       }
02146 
02147       ML_CN_IDX(0)      = const_tbl_idx;
02148       ML_CP_IDX(0)      = const_pool_idx;
02149    }
02150 
02151   Pragma("_CRI ivdep")        
02152    for (mod_idx = 1; mod_idx < at_new_tbl_idx; mod_idx++) {
02153       ML_AT_IDX(mod_idx)                = mod_idx;
02154       ML_AT_COMPRESSED_IDX(mod_idx)     = TRUE;
02155       ML_AT_KEEP_ME(mod_idx)            = TRUE;
02156    }
02157 
02158    if (resolving_duplicates) {
02159 
02160       for (mod_idx = at_new_tbl_idx; mod_idx <= attr_tbl_idx; mod_idx++) {
02161 
02162          if (ML_AT_KEEP_ME(mod_idx)) {
02163             ML_AT_IDX(mod_idx)                  = at_new_tbl_idx;
02164             ML_AT_COMPRESSED_IDX(mod_idx)       = TRUE;
02165             at_new_tbl_idx++;
02166          }
02167          else if (ML_AT_IDX(mod_idx) != mod_idx && 
02168                   ML_AT_IDX(mod_idx) != NULL_IDX) {
02169 
02170             /* This attr has been resolved to another attr.  Find out if    */
02171             /* any attr in this chain needs to be kept.  If the attr does   */
02172             /* not need to be kept, just skip to the next attr.             */
02173 
02174             idx = mod_idx;
02175 
02176             /* Search until we find the attr that gets kept in this chain.  */
02177             /* If ML_AT_KEEP_ME is set, we've found the attr that gets kept */
02178             /* in the chain.  If ML_AT_COMPRESSED_IDX is set, this attr in  */
02179             /* the chain has already been changed to index to its new       */
02180             /* compressed index.  Following is an example of how this can   */
02181             /* happen:     ML_AT_IDX(344) = 1268.  ML_AT_KEEP_ME(1268) = T  */
02182             /* We enter this code with 344.  After this code sequence,      */
02183             /* ML_AT_IDX(1268) = 344, ML_AT_KEEP_ME(1268) = FALSE.          */
02184             /* ML_AT_IDX(344) = 20 (The new compressed index.)              */
02185             /* ML_AT_KEEP_ME(344) = TRUE.  ML_AT_COMPRESSED_IDX(344) = TRUE.*/
02186             /*                                                              */
02187             /* We enter this code with 1268.  After this code sequence,     */
02188             /* ML_AT_IDX(1268) = 20 and ML_AT_COMPRESSED_IDX(1268) = TRUE.  */
02189             /*                                                              */
02190             /* Now, suppose we also have ML_AT_IDX(3000) = 1268.            */
02191             /* We enter this code with 3000.  We will do the following loop,*/
02192             /* but will stop at 1268, because it already has its compressed */
02193             /* index.  We will then use that index.  So in conclusion,      */
02194             /* attrs 3000, 1268 and 344 are all the same.  What we want is  */
02195             /* just one copy of this attr at index 20, when compression is  */
02196             /* finished.                                                    */
02197 
02198             while (idx != NULL_IDX &&
02199                    !ML_AT_KEEP_ME(idx) &&
02200                    !ML_AT_COMPRESSED_IDX(idx)) {
02201                idx = ML_AT_IDX(idx);
02202             }
02203 
02204             if (idx > mod_idx) {
02205 
02206                /* The duplicate attr being kept has not been assigned a new */
02207                /* index yet.  Switch the attrs that are being kept, since   */
02208                /* we are ready to assign a new index to this attr.          */
02209 
02210                /* Since these are the same thing - switch the actual info   */
02211                /* in the attr, so that all information about which entries  */
02212                /* in which tables should be kept will remain okay.          */
02213 
02214                COPY_ATTR_NTRY(AT_WORK_IDX, mod_idx);
02215                COPY_ATTR_NTRY(mod_idx, idx);
02216                COPY_ATTR_NTRY(idx, AT_WORK_IDX);
02217 
02218                ML_AT_KEEP_ME(idx)       = FALSE;
02219                ML_AT_KEEP_ME(mod_idx)   = TRUE;
02220 
02221                /* Set the higher duplicate attr ML_AT_IDX to lower duplicate */
02222                /* attr index.  When the higher duplicate attr comes up, it   */
02223                /* will fall through here but take the else clause instead of */
02224                /* this clause.  That will get its ML_AT_IDX set correctly.   */
02225                /* We cannot set ML_AT_IDX directly, because when the higher  */
02226                /* attr comes through, it won't know that its ML_AT_IDX has   */
02227                /* already been adjusted.                                     */
02228 
02229                ML_AT_IDX(idx)                   = mod_idx;
02230                ML_AT_IDX(mod_idx)               = at_new_tbl_idx;
02231                ML_AT_COMPRESSED_IDX(mod_idx)    = TRUE;
02232                at_new_tbl_idx++;
02233             }
02234             else if (idx != NULL_IDX) {
02235                ML_AT_IDX(mod_idx)               = ML_AT_IDX(idx);
02236                ML_AT_COMPRESSED_IDX(mod_idx)    = TRUE;
02237             }
02238          }
02239       }
02240    }
02241    else {
02242 
02243   Pragma("_CRI ivdep")        
02244       for (mod_idx = at_new_tbl_idx; mod_idx <= attr_tbl_idx; mod_idx++) {
02245 
02246          if (ML_AT_KEEP_ME(mod_idx)) {
02247             ML_AT_IDX(mod_idx)  = at_new_tbl_idx;
02248             at_new_tbl_idx++;
02249          }
02250       }
02251    }
02252 
02253   Pragma("_CRI ivdep")        
02254    for (mod_idx = 1; mod_idx < bd_new_tbl_idx; mod_idx++) {
02255       ML_BD_IDX(mod_idx)        = mod_idx;
02256    }
02257 
02258   Pragma("_CRI ivdep")        
02259    for (mod_idx = bd_new_tbl_idx; mod_idx <= bounds_tbl_idx; mod_idx++) {
02260 
02261       if (ML_BD_KEEP_ME(mod_idx)) {
02262          ML_BD_IDX(mod_idx)     = bd_new_tbl_idx;
02263          bd_new_tbl_idx         = bd_new_tbl_idx + BD_NTRY_SIZE(mod_idx);
02264       }
02265    }
02266 
02267    if (save_const_tbl_idx == NULL_IDX) {
02268 
02269   Pragma("_CRI ivdep")        
02270       for (mod_idx = 1; mod_idx < cn_new_tbl_idx; mod_idx++) {
02271          ML_CN_IDX(mod_idx)     = mod_idx;
02272       }
02273    
02274   Pragma("_CRI ivdep")        
02275       for (mod_idx = cn_new_tbl_idx; mod_idx <= const_tbl_idx; mod_idx++) {
02276    
02277          if (ML_CN_KEEP_ME(mod_idx)) {
02278             ML_CN_IDX(mod_idx)  = cn_new_tbl_idx;
02279             cn_new_tbl_idx++;
02280          }
02281       }
02282 
02283   Pragma("_CRI ivdep")        
02284       for (mod_idx = 1; mod_idx < cp_new_tbl_idx; mod_idx++) {
02285          ML_CP_IDX(mod_idx)     = mod_idx;
02286       }
02287 
02288       end_idx = const_pool_idx;
02289 
02290       for (mod_idx = cp_new_tbl_idx; mod_idx <= end_idx; mod_idx++) {
02291 
02292          if (ML_CP_KEEP_ME(mod_idx)) {
02293 
02294 # if defined(_HOST32)
02295    
02296             if (ML_CP_DALIGN_ME(mod_idx)) {
02297 
02298                while ((((long)&const_pool[cp_new_tbl_idx]) % 8) != 0) {
02299                   cp_new_tbl_idx++;
02300                   TBL_REALLOC_CK(const_pool, 1);
02301                }
02302    
02303                if (const_pool_idx > mod_link_tbl_idx) {
02304                   idx = mod_link_tbl_idx;
02305                   TBL_REALLOC_CK(mod_link_tbl, const_pool_idx);
02306    
02307                   for (; idx <= mod_link_tbl_idx; idx++) {
02308                      CLEAR_TBL_NTRY(mod_link_tbl, idx);
02309                   }
02310                }
02311    
02312             }
02313    
02314 # endif
02315             ML_CP_IDX(mod_idx)  = cp_new_tbl_idx;
02316             cp_new_tbl_idx              += ML_CP_LEN(mod_idx);
02317          }
02318       }
02319    }
02320 
02321   Pragma("_CRI ivdep")        
02322    for (mod_idx = 1; mod_idx < il_new_tbl_idx; mod_idx++) {
02323       ML_IL_IDX(mod_idx)        = mod_idx;
02324    }
02325 
02326   Pragma("_CRI ivdep")        
02327    for (mod_idx = il_new_tbl_idx; mod_idx <= ir_list_tbl_idx; mod_idx++) {
02328 
02329       if (ML_IL_KEEP_ME(mod_idx)) {
02330          ML_IL_IDX(mod_idx) = il_new_tbl_idx;
02331          il_new_tbl_idx++;
02332       }
02333    }
02334 
02335   Pragma("_CRI ivdep")        
02336    for (mod_idx = 1; mod_idx < ir_new_tbl_idx; mod_idx++) {
02337       ML_IR_IDX(mod_idx)        = mod_idx;
02338    }
02339 
02340   Pragma("_CRI ivdep")        
02341    for (mod_idx = ir_new_tbl_idx; mod_idx <= ir_tbl_idx; mod_idx++) {
02342 
02343       if (ML_IR_KEEP_ME(mod_idx)) {
02344          ML_IR_IDX(mod_idx) = ir_new_tbl_idx;
02345          ir_new_tbl_idx++;
02346       }
02347    }
02348 
02349   Pragma("_CRI ivdep")        
02350    for (mod_idx = 1; mod_idx < ln_new_tbl_idx; mod_idx++) {
02351       ML_LN_IDX(mod_idx)        = mod_idx;
02352    }
02353 
02354   Pragma("_CRI ivdep")        
02355    for (mod_idx = ln_new_tbl_idx; mod_idx <= loc_name_tbl_idx; mod_idx++) {
02356 
02357       if (ML_LN_KEEP_ME(mod_idx)) {
02358          ML_LN_IDX(mod_idx) = ln_new_tbl_idx;
02359          ln_new_tbl_idx++;
02360       }
02361    }
02362 
02363   Pragma("_CRI ivdep")        
02364    for (mod_idx = 1; mod_idx < np_new_tbl_idx; mod_idx++) {
02365       ML_NP_IDX(mod_idx)        = mod_idx;
02366    }
02367 
02368   Pragma("_CRI ivdep")        
02369    for (mod_idx = np_new_tbl_idx; mod_idx <= name_pool_idx; mod_idx++) {
02370 
02371       if (ML_NP_KEEP_ME(mod_idx)) {
02372          ML_NP_IDX(mod_idx)     = np_new_tbl_idx;
02373          ML_NP_LEN(mod_idx)     = WORD_LEN(ML_NP_LEN(mod_idx));
02374          np_new_tbl_idx         += ML_NP_LEN(mod_idx);
02375       }
02376    }
02377 
02378   Pragma("_CRI ivdep")        
02379    for (mod_idx = 1; mod_idx < sb_new_tbl_idx; mod_idx++) {
02380       ML_SB_IDX(mod_idx)        = mod_idx;
02381    }
02382 
02383   Pragma("_CRI ivdep")        
02384    for (mod_idx = sb_new_tbl_idx; mod_idx <= stor_blk_tbl_idx; mod_idx++) {
02385 
02386       if (ML_SB_KEEP_ME(mod_idx)) {
02387          ML_SB_IDX(mod_idx)     = sb_new_tbl_idx;
02388          sb_new_tbl_idx++;
02389       }
02390    }
02391 
02392   Pragma("_CRI ivdep")        
02393    for (mod_idx = 1; mod_idx < sn_new_tbl_idx; mod_idx++) {
02394       ML_SN_IDX(mod_idx)        = mod_idx;
02395    }
02396 
02397   Pragma("_CRI ivdep")        
02398    for (mod_idx = sn_new_tbl_idx; mod_idx <= sec_name_tbl_idx; mod_idx++) {
02399 
02400       if (ML_SN_KEEP_ME(mod_idx)) {
02401          ML_SN_IDX(mod_idx)     = sn_new_tbl_idx;
02402          sn_new_tbl_idx++;
02403       }
02404    }
02405 
02406   Pragma("_CRI ivdep")        
02407    for (mod_idx = 1; mod_idx < sh_new_tbl_idx; mod_idx++) {
02408       ML_SH_IDX(mod_idx)        = mod_idx;
02409    }
02410 
02411   Pragma("_CRI ivdep")        
02412    for (mod_idx = sh_new_tbl_idx; mod_idx <= sh_tbl_idx; mod_idx++) {
02413 
02414       if (ML_SH_KEEP_ME(mod_idx)) {
02415          ML_SH_IDX(mod_idx)     = sh_new_tbl_idx;
02416          sh_new_tbl_idx++;
02417       }
02418    }
02419 
02420   Pragma("_CRI ivdep")        
02421    for (mod_idx = 1; mod_idx < typ_new_tbl_idx; mod_idx++) {
02422       ML_TYP_IDX(mod_idx)       = mod_idx;
02423    }
02424 
02425    /* Assigning typ indexes is handled in compress_typ_table */
02426 
02427    TRACE (Func_Exit, "assign_new_idxs", NULL);
02428 
02429    return;
02430 
02431 }   /* assign_new_idxs */
02432 
02433 /******************************************************************************\
02434 |*                                                                            *|
02435 |* Description:                                                               *|
02436 |*      This moves the tables, writing over entries that should be compressed *|
02437 |*      out.                                                                  *|
02438 |*                                                                            *|
02439 |* Input parameters:                                                          *|
02440 |*      al_idx -> Index to start checking attr_list_tbl for updating the      *|
02441 |*                AL_ATTR_IDX.                                                *|
02442 |*                                                                            *|
02443 |* Output parameters:                                                         *|
02444 |*      NONE                                                                  *|
02445 |*                                                                            *|
02446 |* Returns:                                                                   *|
02447 |*      NOTHING                                                               *|
02448 |*                                                                            *|
02449 \******************************************************************************/
02450 static void  compress_tbls(int          al_idx,
02451                            boolean      from_interface)
02452 {
02453    int          at_idx;
02454    int          bd_idx;
02455    int          cn_idx;
02456    int          cp_idx;
02457    int          dim;
02458    int          end_idx;
02459    int          idx;
02460    int          il_idx;
02461    int          ir_idx;
02462    int          ln_idx;
02463    int          mod_idx;
02464    int          np_idx;
02465    int          sb_idx;
02466    int          sh_idx;
02467    int          sn_idx;
02468    int          start_idx;
02469    int          typ_idx;
02470 
02471 # if 0
02472    int          end_old_idx;
02473    int          start_old_idx;
02474 # endif
02475 
02476 
02477    TRACE (Func_Entry, "compress_tbls", NULL);
02478 
02479    /* The zeroth entry in the module link table contains the starting index   */
02480    /* for each table.  This allows partial compression at the end of tables.  */
02481    /* After this field is saved, clear these entries.  They must be NULL_IDX  */
02482    /* so that if a field has NULL_IDX in it, it will not change.   All other  */
02483    /* fields are required to be set correctly or they will end up NULL.       */
02484 
02485    at_idx = ML_AT_IDX(0);
02486    bd_idx = ML_BD_IDX(0);
02487    cn_idx = ML_CN_IDX(0);
02488    cp_idx = ML_CP_IDX(0);
02489    il_idx = ML_IL_IDX(0);
02490    ir_idx = ML_IR_IDX(0);
02491    ln_idx = ML_LN_IDX(0);
02492    np_idx = ML_NP_IDX(0);
02493    sb_idx = ML_SB_IDX(0);
02494    sh_idx = ML_SH_IDX(0);
02495    sn_idx = ML_SN_IDX(0);
02496    typ_idx= ML_TYP_IDX(0);
02497 
02498    CLEAR_TBL_NTRY(mod_link_tbl, NULL_IDX);
02499 
02500    /* Compresses the type table, by sharing duplicate entries */
02501    /* and collapsing out unneeded type entries.               */
02502 
02503    compress_type_tbl(typ_idx);
02504 
02505    if (!only_update_new_tbl_entries) {
02506       update_idxs_in_attr_entry(1,at_idx);
02507    }
02508 
02509    start_idx    = at_idx+1;
02510 
02511 # if 0
02512    mod_idx      = start_idx;
02513 
02514    do {
02515 
02516       while (mod_idx <= attr_tbl_idx && !ML_AT_KEEP_ME(mod_idx)) {
02517          mod_idx++;
02518       }
02519 
02520       if (mod_idx <= attr_tbl_idx) {
02521          start_old_idx  = mod_idx;
02522 
02523          while (mod_idx <= attr_tbl_idx && ML_AT_KEEP_ME(mod_idx)) {
02524             mod_idx++;
02525          }
02526 
02527          end_old_idx    = mod_idx - 1;
02528          ++at_idx;
02529 
02530          if (start_old_idx != at_idx) {
02531             (void) memmove ((void *) &attr_tbl[at_idx],
02532                             (void *) &attr_tbl[start_old_idx],
02533                             (end_old_idx - start_old_idx +1) * NUM_AT_WDS * 8);
02534          }
02535          at_idx        += end_old_idx - start_old_idx;
02536                          
02537          /* The last one checked is either too high   */
02538          /* or has !ML_AT_KEEP_ME set.  Skip past it. */
02539 
02540          ++mod_idx;
02541       }
02542    }
02543    while (mod_idx <= attr_tbl_idx);
02544 
02545 # endif
02546 
02547    for (mod_idx = start_idx; mod_idx <= attr_tbl_idx; mod_idx++) {
02548 
02549       if (ML_AT_KEEP_ME(mod_idx)) {
02550          ++at_idx;
02551          COPY_ATTR_NTRY(at_idx, mod_idx);
02552       }
02553    }
02554 
02555    update_idxs_in_attr_entry(start_idx, at_idx);
02556 
02557    if (count_derived_types) {
02558 
02559       for (mod_idx = start_idx; mod_idx <= at_idx; mod_idx++) {
02560          if (AT_OBJ_CLASS(mod_idx) == Derived_Type) {
02561             num_module_derived_types++;
02562          }
02563       }
02564    }
02565 
02566    /* mod_idx   = (only_update_new_tbl_entries) ? bd_idx + 1 : 1; */
02567    mod_idx      = 1;
02568 
02569    while (mod_idx <= bd_idx && BD_NTRY_SIZE(mod_idx)!= 0) {
02570 
02571 /* for some reason some deferred shape array BD_NTRY_SIZE(mod_idx)
02572    is 0; need to read the code
02573    fzhao
02574  */
02575 
02576       if (!BD_USED_NTRY(mod_idx)) {  /* Entry from the free list */
02577          BD_NEXT_FREE_NTRY(mod_idx)     = ML_BD_IDX(BD_NEXT_FREE_NTRY(mod_idx));
02578          mod_idx = mod_idx + BD_NTRY_SIZE(mod_idx);
02579       }
02580       else if (BD_DIST_NTRY(mod_idx)) {
02581 
02582          for (dim = 1; dim <= BD_RANK(mod_idx); dim++) {
02583 
02584             if (BD_CYCLIC_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02585                BD_CYCLIC_IDX(mod_idx, dim) = 
02586                                   ML_CN_IDX(BD_CYCLIC_IDX(mod_idx, dim));
02587             }
02588             else if (BD_CYCLIC_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02589                BD_CYCLIC_IDX(mod_idx, dim) = 
02590                                   ML_AT_IDX(BD_CYCLIC_IDX(mod_idx, dim));
02591             }
02592 
02593             if (BD_ONTO_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02594                BD_ONTO_IDX(mod_idx, dim) = 
02595                                   ML_CN_IDX(BD_ONTO_IDX(mod_idx, dim));
02596             }
02597             else if (BD_ONTO_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02598                BD_ONTO_IDX(mod_idx, dim) = 
02599                                   ML_AT_IDX(BD_ONTO_IDX(mod_idx, dim));
02600             }
02601          }
02602          mod_idx = mod_idx + BD_RANK(mod_idx) + 1;  /* 1 for header */
02603       }
02604       else if (BD_ARRAY_CLASS(mod_idx) != Deferred_Shape) {
02605 
02606          if (BD_LEN_FLD(mod_idx) == CN_Tbl_Idx) {
02607             BD_LEN_IDX(mod_idx) = ML_CN_IDX(BD_LEN_IDX(mod_idx));
02608          }
02609          else if (BD_LEN_FLD(mod_idx) == AT_Tbl_Idx) {
02610             BD_LEN_IDX(mod_idx) = ML_AT_IDX(BD_LEN_IDX(mod_idx));
02611          }
02612 
02613          for (dim = 1; dim <= BD_RANK(mod_idx); dim++) {
02614 
02615             if (BD_LB_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02616                BD_LB_IDX(mod_idx, dim) = ML_CN_IDX(BD_LB_IDX(mod_idx, dim));
02617             }
02618             else if (BD_LB_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02619                BD_LB_IDX(mod_idx, dim) = ML_AT_IDX(BD_LB_IDX(mod_idx, dim));
02620             }
02621 
02622             if (BD_UB_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02623                BD_UB_IDX(mod_idx, dim) = ML_CN_IDX(BD_UB_IDX(mod_idx, dim));
02624             }
02625             else if (BD_UB_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02626                BD_UB_IDX(mod_idx, dim) = ML_AT_IDX(BD_UB_IDX(mod_idx, dim));
02627             }
02628 
02629             if (BD_XT_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02630                BD_XT_IDX(mod_idx, dim) = ML_CN_IDX(BD_XT_IDX(mod_idx, dim));
02631             }
02632             else if (BD_XT_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02633                BD_XT_IDX(mod_idx, dim) = ML_AT_IDX(BD_XT_IDX(mod_idx, dim));
02634             }
02635 
02636             if (BD_SM_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02637                BD_SM_IDX(mod_idx, dim) = ML_CN_IDX(BD_SM_IDX(mod_idx, dim));
02638             }
02639             else if (BD_SM_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02640                BD_SM_IDX(mod_idx, dim) = ML_AT_IDX(BD_SM_IDX(mod_idx, dim));
02641             }
02642          }
02643          mod_idx = mod_idx + BD_RANK(mod_idx) + 1;  /* 1 for header */
02644       }
02645       else {
02646         if (BD_NTRY_SIZE(mod_idx) == 0) {
02647            /* eraxxon & fzhao: fix for bug #76 */
02648            mod_idx = mod_idx + BD_RANK(mod_idx) + 1;
02649         }
02650         else {
02651            mod_idx++;
02652         }
02653       }
02654    }
02655 
02656    start_idx    = bd_idx+1;
02657 
02658    for (mod_idx = start_idx; mod_idx <= bounds_tbl_idx; mod_idx++) {
02659 
02660       if (ML_BD_KEEP_ME(mod_idx)) {
02661          ++bd_idx;
02662          COPY_BD_NTRY(bd_idx, mod_idx);
02663 
02664          if (BD_DIST_NTRY(bd_idx) ||
02665              BD_ARRAY_CLASS(bd_idx) != Deferred_Shape) {
02666 
02667             bd_idx = bd_idx + BD_RANK(bd_idx);
02668          }
02669       }
02670    }
02671 
02672    for (mod_idx = start_idx; mod_idx <= bd_idx; mod_idx++) {
02673 
02674       if (BD_DIST_NTRY(mod_idx)) {
02675 
02676          for (dim = 1; dim <= BD_RANK(mod_idx); dim++) {
02677 
02678             if (BD_CYCLIC_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02679                BD_CYCLIC_IDX(mod_idx, dim) =
02680                                   ML_CN_IDX(BD_CYCLIC_IDX(mod_idx, dim));
02681             }
02682             else if (BD_CYCLIC_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02683                BD_CYCLIC_IDX(mod_idx, dim) =
02684                                   ML_AT_IDX(BD_CYCLIC_IDX(mod_idx, dim));
02685             }
02686 
02687             if (BD_ONTO_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02688                BD_ONTO_IDX(mod_idx, dim) =
02689                                   ML_CN_IDX(BD_ONTO_IDX(mod_idx, dim));
02690             }
02691             else if (BD_ONTO_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02692                BD_ONTO_IDX(mod_idx, dim) =
02693                                   ML_AT_IDX(BD_ONTO_IDX(mod_idx, dim));
02694             }
02695          }
02696          mod_idx = mod_idx + BD_RANK(mod_idx);
02697       }
02698       else if (BD_ARRAY_CLASS(mod_idx) != Deferred_Shape) {
02699 
02700          if (BD_LEN_FLD(mod_idx) == CN_Tbl_Idx) {
02701             BD_LEN_IDX(mod_idx) = ML_CN_IDX(BD_LEN_IDX(mod_idx));
02702          }
02703          else if (BD_LEN_FLD(mod_idx) == AT_Tbl_Idx) {
02704             BD_LEN_IDX(mod_idx) = ML_AT_IDX(BD_LEN_IDX(mod_idx));
02705          }
02706 
02707          for (dim = 1; dim <= BD_RANK(mod_idx); dim++) {
02708 
02709             if (BD_LB_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02710                BD_LB_IDX(mod_idx, dim) = ML_CN_IDX(BD_LB_IDX(mod_idx, dim));
02711             }
02712             else if (BD_LB_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02713                BD_LB_IDX(mod_idx, dim) = ML_AT_IDX(BD_LB_IDX(mod_idx, dim));
02714             }
02715 
02716             if (BD_UB_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02717                BD_UB_IDX(mod_idx, dim) = ML_CN_IDX(BD_UB_IDX(mod_idx, dim));
02718             }
02719             else if (BD_UB_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02720                BD_UB_IDX(mod_idx, dim) = ML_AT_IDX(BD_UB_IDX(mod_idx, dim));
02721             }
02722 
02723             if (BD_XT_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02724                BD_XT_IDX(mod_idx, dim) = ML_CN_IDX(BD_XT_IDX(mod_idx, dim));
02725             }
02726             else if (BD_XT_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02727                BD_XT_IDX(mod_idx, dim) = ML_AT_IDX(BD_XT_IDX(mod_idx, dim));
02728             }
02729 
02730             if (BD_SM_FLD(mod_idx, dim) == CN_Tbl_Idx) {
02731                BD_SM_IDX(mod_idx, dim) = ML_CN_IDX(BD_SM_IDX(mod_idx, dim));
02732             }
02733             else if (BD_SM_FLD(mod_idx, dim) == AT_Tbl_Idx) {
02734                BD_SM_IDX(mod_idx, dim) = ML_AT_IDX(BD_SM_IDX(mod_idx, dim));
02735             }
02736          }
02737          mod_idx = mod_idx + BD_RANK(mod_idx);
02738       }
02739    }
02740 
02741    start_idx    = cn_idx+1;
02742 
02743   Pragma("_CRI ivdep")        
02744    for (mod_idx = cn_idx+1; mod_idx <= const_tbl_idx; mod_idx++) {
02745 
02746       if (ML_CN_KEEP_ME(mod_idx)) {
02747          const_tbl[++cn_idx]    = const_tbl[mod_idx];
02748       }
02749    }
02750 
02751 # if defined(_DEBUG)
02752    for (mod_idx = 1; mod_idx <= const_tbl_idx; mod_idx++) {
02753 
02754       if (CN_POOL_IDX(mod_idx) == NULL_IDX) {
02755          PRINTMSG(stmt_start_line, 1349, Internal, 0, mod_idx);
02756       }
02757    }
02758 # endif
02759 
02760 
02761    for (mod_idx = 1; mod_idx <= cn_idx; mod_idx++) {
02762       CN_TYPE_IDX(mod_idx)      = ML_TYP_IDX(CN_TYPE_IDX(mod_idx));
02763       CN_POOL_IDX(mod_idx)      = ML_CP_IDX(CN_POOL_IDX(mod_idx));
02764    }
02765 
02766    for (mod_idx = cp_idx+1; mod_idx <= const_pool_idx; mod_idx++) {
02767 
02768       if (ML_CP_KEEP_ME(mod_idx)) {
02769 
02770 # if defined(_HOST32) 
02771 
02772          if (ML_CP_DALIGN_ME(mod_idx)) {
02773             cp_idx = ML_CP_IDX(mod_idx) - 1;
02774          }
02775 # endif
02776 
02777          for (idx = 0; idx < ML_CP_LEN(mod_idx); idx++) {
02778             const_pool[++cp_idx]        = const_pool[mod_idx+idx];
02779          }
02780       }
02781    }
02782 
02783    for (mod_idx = (from_interface || !only_update_new_tbl_entries) ?
02784                   1 : (il_idx+1); mod_idx <= il_idx; mod_idx++) {
02785       IL_NEXT_LIST_IDX(mod_idx) = ML_IL_IDX(IL_NEXT_LIST_IDX(mod_idx));
02786 
02787       if (!IL_ARG_DESC_VARIANT(mod_idx)) {
02788          IL_PREV_LIST_IDX(mod_idx) = ML_IL_IDX(IL_PREV_LIST_IDX(mod_idx));
02789       }
02790 
02791       switch (IL_FLD(mod_idx)) {
02792       case CN_Tbl_Idx:
02793          IL_IDX(mod_idx) = ML_CN_IDX(IL_IDX(mod_idx));
02794          break;
02795 
02796       case AT_Tbl_Idx:
02797          IL_IDX(mod_idx) = ML_AT_IDX(IL_IDX(mod_idx));
02798          break;
02799       
02800       case IL_Tbl_Idx:
02801          IL_IDX(mod_idx) = ML_IL_IDX(IL_IDX(mod_idx));
02802          break;
02803 
02804       case IR_Tbl_Idx:
02805          IL_IDX(mod_idx) = ML_IR_IDX(IL_IDX(mod_idx));
02806          break;
02807       }
02808    }
02809 
02810    start_idx    = il_idx + 1;
02811 
02812    for (mod_idx = start_idx; mod_idx <= ir_list_tbl_idx; mod_idx++) {
02813 
02814       if (ML_IL_KEEP_ME(mod_idx)) {
02815          ir_list_tbl[++il_idx]          = ir_list_tbl[mod_idx];
02816       }
02817    }
02818 
02819    for (mod_idx = start_idx; mod_idx <= il_idx; mod_idx++) {
02820       IL_NEXT_LIST_IDX(mod_idx) = ML_IL_IDX(IL_NEXT_LIST_IDX(mod_idx));
02821 
02822       if (!IL_ARG_DESC_VARIANT(mod_idx)) {
02823          IL_PREV_LIST_IDX(mod_idx) = ML_IL_IDX(IL_PREV_LIST_IDX(mod_idx));
02824       }
02825 
02826       switch (IL_FLD(mod_idx)) {
02827       case CN_Tbl_Idx:
02828          IL_IDX(mod_idx) = ML_CN_IDX(IL_IDX(mod_idx));
02829          break;
02830 
02831       case AT_Tbl_Idx:
02832          IL_IDX(mod_idx) = ML_AT_IDX(IL_IDX(mod_idx));
02833          break;
02834       
02835       case IL_Tbl_Idx:
02836          IL_IDX(mod_idx) = ML_IL_IDX(IL_IDX(mod_idx));
02837          break;
02838 
02839       case IR_Tbl_Idx:
02840          IL_IDX(mod_idx) = ML_IR_IDX(IL_IDX(mod_idx));
02841          break;
02842       }
02843    }
02844 
02845    for (mod_idx = (from_interface || !only_update_new_tbl_entries) ?
02846                   1 : (ir_idx + 1); mod_idx <= ir_idx; mod_idx++) {
02847       IR_TYPE_IDX(mod_idx)      = ML_TYP_IDX(IR_TYPE_IDX(mod_idx));
02848 
02849       switch (IR_FLD_L(mod_idx)) {
02850       case CN_Tbl_Idx:
02851          IR_IDX_L(mod_idx) = ML_CN_IDX(IR_IDX_L(mod_idx));
02852          break;
02853 
02854       case AT_Tbl_Idx:
02855          IR_IDX_L(mod_idx) = ML_AT_IDX(IR_IDX_L(mod_idx));
02856          break;
02857          
02858       case IL_Tbl_Idx:
02859          IR_IDX_L(mod_idx) = ML_IL_IDX(IR_IDX_L(mod_idx));
02860          break;
02861 
02862       case IR_Tbl_Idx:
02863          IR_IDX_L(mod_idx) = ML_IR_IDX(IR_IDX_L(mod_idx));
02864          break;
02865       }
02866 
02867       switch (IR_FLD_R(mod_idx)) {
02868       case CN_Tbl_Idx:
02869          IR_IDX_R(mod_idx) = ML_CN_IDX(IR_IDX_R(mod_idx));
02870          break;
02871 
02872       case AT_Tbl_Idx:
02873          IR_IDX_R(mod_idx) = ML_AT_IDX(IR_IDX_R(mod_idx));
02874          break;
02875          
02876       case IL_Tbl_Idx:
02877          IR_IDX_R(mod_idx) = ML_IL_IDX(IR_IDX_R(mod_idx));
02878          break;
02879 
02880       case IR_Tbl_Idx:
02881          IR_IDX_R(mod_idx) = ML_IR_IDX(IR_IDX_R(mod_idx));
02882          break;
02883       }
02884    }
02885 
02886    start_idx = ir_idx+1;
02887 
02888    for (mod_idx = start_idx; mod_idx <= ir_tbl_idx; mod_idx++) {
02889 
02890       if (ML_IR_KEEP_ME(mod_idx)) {
02891          ir_tbl[++ir_idx]       = ir_tbl[mod_idx];
02892       }
02893    }
02894 
02895    for (mod_idx = start_idx; mod_idx <= ir_idx; mod_idx++) {
02896       IR_TYPE_IDX(mod_idx)      = ML_TYP_IDX(IR_TYPE_IDX(mod_idx));
02897 
02898       switch (IR_FLD_L(mod_idx)) {
02899       case CN_Tbl_Idx:
02900          IR_IDX_L(mod_idx) = ML_CN_IDX(IR_IDX_L(mod_idx));
02901          break;
02902 
02903       case AT_Tbl_Idx:
02904          IR_IDX_L(mod_idx) = ML_AT_IDX(IR_IDX_L(mod_idx));
02905          break;
02906       
02907       case IL_Tbl_Idx:
02908          IR_IDX_L(mod_idx) = ML_IL_IDX(IR_IDX_L(mod_idx));
02909          break;
02910 
02911       case IR_Tbl_Idx:
02912          IR_IDX_L(mod_idx) = ML_IR_IDX(IR_IDX_L(mod_idx));
02913          break;
02914       }
02915 
02916       switch (IR_FLD_R(mod_idx)) {
02917       case CN_Tbl_Idx:
02918          IR_IDX_R(mod_idx) = ML_CN_IDX(IR_IDX_R(mod_idx));
02919          break;
02920 
02921       case AT_Tbl_Idx:
02922          IR_IDX_R(mod_idx) = ML_AT_IDX(IR_IDX_R(mod_idx));
02923          break;
02924       
02925       case IL_Tbl_Idx:
02926          IR_IDX_R(mod_idx) = ML_IL_IDX(IR_IDX_R(mod_idx));
02927          break;
02928 
02929       case IR_Tbl_Idx:
02930          IR_IDX_R(mod_idx) = ML_IR_IDX(IR_IDX_R(mod_idx));
02931          break;
02932       }
02933    }
02934 
02935    start_idx    = ln_idx+1;
02936 
02937    for (mod_idx = start_idx; mod_idx <= loc_name_tbl_idx; mod_idx++) {
02938 
02939       if (ML_LN_KEEP_ME(mod_idx)) {
02940          loc_name_tbl[++ln_idx] = loc_name_tbl[mod_idx];
02941       }
02942    }
02943 
02944    for (mod_idx = start_idx; mod_idx <= ln_idx; mod_idx++) {
02945 
02946      if (LN_ATTR_IDX(mod_idx) != NULL_IDX) {
02947         LN_ATTR_IDX(mod_idx)    = ML_AT_IDX(LN_ATTR_IDX(mod_idx));
02948         LN_NAME_IDX(mod_idx)    = AT_NAME_IDX(LN_ATTR_IDX(mod_idx));
02949         LN_NAME_LEN(mod_idx)    = AT_NAME_LEN(LN_ATTR_IDX(mod_idx));
02950      }
02951      else {
02952         LN_NAME_IDX(mod_idx)    = ML_NP_IDX(LN_NAME_IDX(mod_idx));
02953      }
02954    }
02955 
02956    for (mod_idx = np_idx+1; mod_idx <= name_pool_idx; mod_idx++) {
02957 
02958       if (ML_NP_KEEP_ME(mod_idx)) {
02959 
02960          for (idx = 0; idx < ML_NP_LEN(mod_idx); idx++) {
02961             name_pool[++np_idx].name_long = name_pool[mod_idx+idx].name_long;
02962          }
02963       }
02964    }
02965 
02966    /* for (mod_idx = (only_update_new_tbl_entries) ? (sb_idx + 1) : 1; */
02967    for (mod_idx = 1; mod_idx <= sb_idx; mod_idx++) {
02968       SB_NAME_IDX(mod_idx)              = ML_NP_IDX(SB_NAME_IDX(mod_idx));
02969       SB_MODULE_IDX(mod_idx)            = ML_AT_IDX(SB_MODULE_IDX(mod_idx));
02970 
02971       if (SB_FIRST_ATTR_IDX(mod_idx) != NULL_IDX) {
02972          SB_FIRST_ATTR_IDX(mod_idx) = ML_AT_IDX(SB_FIRST_ATTR_IDX(mod_idx));
02973       }
02974 
02975       switch (SB_LEN_FLD(mod_idx)) {
02976       case AT_Tbl_Idx:
02977          SB_LEN_IDX(mod_idx)            = ML_AT_IDX(SB_LEN_IDX(mod_idx));
02978          break;
02979      
02980       case CN_Tbl_Idx:
02981          SB_LEN_IDX(mod_idx)            = ML_CN_IDX(SB_LEN_IDX(mod_idx));
02982          break;
02983 
02984       case IL_Tbl_Idx:
02985          SB_LEN_IDX(mod_idx)            = ML_IL_IDX(SB_LEN_IDX(mod_idx));
02986          break;
02987 
02988       case IR_Tbl_Idx:
02989          SB_LEN_IDX(mod_idx)            = ML_IR_IDX(SB_LEN_IDX(mod_idx));
02990          break;
02991       }
02992    }
02993 
02994    start_idx = sb_idx + 1;
02995 
02996    for (mod_idx = start_idx; mod_idx <= stor_blk_tbl_idx; mod_idx++) {
02997 
02998       if (ML_SB_KEEP_ME(mod_idx)) {
02999          stor_blk_tbl[++sb_idx]         = stor_blk_tbl[mod_idx];
03000       }
03001    }
03002 
03003    for (mod_idx = start_idx; mod_idx <= sb_idx; mod_idx++) {
03004       SB_NAME_IDX(mod_idx)              = ML_NP_IDX(SB_NAME_IDX(mod_idx));
03005       SB_MODULE_IDX(mod_idx)            = ML_AT_IDX(SB_MODULE_IDX(mod_idx));
03006 
03007       if (SB_FIRST_ATTR_IDX(mod_idx) != NULL_IDX) {
03008          SB_FIRST_ATTR_IDX(mod_idx) = ML_AT_IDX(SB_FIRST_ATTR_IDX(mod_idx));
03009       }
03010 
03011       switch (SB_LEN_FLD(mod_idx)) {
03012       case AT_Tbl_Idx:
03013          SB_LEN_IDX(mod_idx)            = ML_AT_IDX(SB_LEN_IDX(mod_idx));
03014          break;
03015      
03016       case CN_Tbl_Idx:
03017          SB_LEN_IDX(mod_idx)            = ML_CN_IDX(SB_LEN_IDX(mod_idx));
03018          break;
03019 
03020       case IL_Tbl_Idx:
03021          SB_LEN_IDX(mod_idx)            = ML_IL_IDX(SB_LEN_IDX(mod_idx));
03022          break;
03023 
03024       case IR_Tbl_Idx:
03025          SB_LEN_IDX(mod_idx)            = ML_IR_IDX(SB_LEN_IDX(mod_idx));
03026          break;
03027       }
03028    }
03029 
03030    for (mod_idx = (from_interface || !only_update_new_tbl_entries) ?
03031                   1 : (sh_idx + 1); mod_idx <= sh_idx; mod_idx++) {
03032       SH_NEXT_IDX(mod_idx)              = ML_SH_IDX(SH_NEXT_IDX(mod_idx));
03033       SH_PREV_IDX(mod_idx)              = ML_SH_IDX(SH_PREV_IDX(mod_idx));
03034       SH_IR_IDX(mod_idx)                = ML_IR_IDX(SH_IR_IDX(mod_idx));
03035 
03036       if (SH_STMT_TYPE(mod_idx) != Statement_Num_Stmt) {
03037          SH_PARENT_BLK_IDX(mod_idx)     = ML_SH_IDX(SH_PARENT_BLK_IDX(mod_idx));
03038       }
03039    }
03040 
03041    start_idx = sh_idx + 1;
03042 
03043    for (mod_idx = start_idx; mod_idx <= sh_tbl_idx; mod_idx++) {
03044 
03045       if (ML_SH_KEEP_ME(mod_idx)) {
03046          sh_tbl[++sh_idx]               = sh_tbl[mod_idx];
03047       }
03048    }
03049 
03050 
03051    for (mod_idx = start_idx; mod_idx <= sh_idx; mod_idx++) {
03052       SH_NEXT_IDX(mod_idx)              = ML_SH_IDX(SH_NEXT_IDX(mod_idx));
03053       SH_PREV_IDX(mod_idx)              = ML_SH_IDX(SH_PREV_IDX(mod_idx));
03054       SH_IR_IDX(mod_idx)                = ML_IR_IDX(SH_IR_IDX(mod_idx));
03055 
03056       if (SH_STMT_TYPE(mod_idx) != Statement_Num_Stmt) {
03057          SH_PARENT_BLK_IDX(mod_idx)     = ML_SH_IDX(SH_PARENT_BLK_IDX(mod_idx));
03058       }
03059    }
03060 
03061    /* Need SN_NAME_LEN because of renames situations. */
03062 
03063    /* for (mod_idx = (only_update_new_tbl_entries) ? (sn_idx+1) : 1;  */
03064    for (mod_idx = 1; mod_idx <= sn_idx; mod_idx++) {
03065       SN_ATTR_IDX(mod_idx)      = ML_AT_IDX(SN_ATTR_IDX(mod_idx));
03066       SN_NAME_IDX(mod_idx)      = AT_NAME_IDX(SN_ATTR_IDX(mod_idx));
03067       SN_NAME_LEN(mod_idx)      = AT_NAME_LEN(SN_ATTR_IDX(mod_idx));
03068       SN_SIBLING_LINK(mod_idx)  = ML_SN_IDX(SN_SIBLING_LINK(mod_idx));
03069    }
03070 
03071    start_idx = sn_idx + 1;
03072 
03073    for (mod_idx = start_idx; mod_idx <= sec_name_tbl_idx; mod_idx++) {
03074 
03075       if (ML_SN_KEEP_ME(mod_idx)) {
03076          sec_name_tbl[++sn_idx]         = sec_name_tbl[mod_idx];
03077       }
03078    }
03079 
03080    for (mod_idx = start_idx; mod_idx <= sec_name_tbl_idx; mod_idx++) {
03081       SN_ATTR_IDX(mod_idx)              = ML_AT_IDX(SN_ATTR_IDX(mod_idx));
03082       SN_NAME_IDX(mod_idx)              = AT_NAME_IDX(SN_ATTR_IDX(mod_idx));
03083       SN_NAME_LEN(mod_idx)              = AT_NAME_LEN(SN_ATTR_IDX(mod_idx));
03084       SN_SIBLING_LINK(mod_idx)          = ML_SN_IDX(SN_SIBLING_LINK(mod_idx));
03085    }
03086 
03087    attr_tbl_idx         = at_idx;
03088    attr_aux_tbl_idx     = at_idx;
03089    bounds_tbl_idx       = bd_idx;
03090    const_tbl_idx        = cn_idx;
03091    const_pool_idx       = cp_idx;
03092    loc_name_tbl_idx     = ln_idx;
03093    ir_list_tbl_idx      = il_idx;
03094    ir_tbl_idx           = ir_idx;
03095    name_pool_idx        = np_idx;
03096    stor_blk_tbl_idx     = sb_idx;
03097    sec_name_tbl_idx     = sn_idx;
03098    sh_tbl_idx           = sh_idx;
03099 
03100    /* If this is a partial compression, the only entries added to the */
03101    /* attr_list_tbl must point to new attributes coming in during USE */
03102    /* processing.                                                     */
03103 
03104    for (mod_idx = al_idx+1; mod_idx <= attr_list_tbl_idx; mod_idx++) {
03105       
03106 # if defined(_DEBUG)
03107      end_idx    = ML_AT_IDX(AL_ATTR_IDX(mod_idx));
03108 
03109      if (!AL_FREE(mod_idx) &&
03110           AL_ATTR_IDX(mod_idx) != NULL_IDX &&
03111          !ML_AT_KEEP_ME(AL_ATTR_IDX(mod_idx)) &&
03112          !ML_AT_COMPRESSED_IDX(AL_ATTR_IDX(mod_idx))) {
03113 
03114 
03115         /* This attr is not being kept.  It should have been cleared. */
03116 
03117         PRINTMSG(stmt_start_line, 1321, Internal, 0, mod_idx, 
03118                  AL_ATTR_IDX(mod_idx));
03119      }
03120 
03121 # endif
03122 
03123       AL_ATTR_IDX(mod_idx) = ML_AT_IDX(AL_ATTR_IDX(mod_idx));
03124    }
03125 
03126    mod_idx = SCP_HN_FW_IDX(curr_scp_idx) + 1;
03127    end_idx = SCP_HN_LW_IDX(curr_scp_idx);
03128 
03129    while (mod_idx < end_idx) {
03130 
03131       if (!ML_AT_KEEP_ME(HN_ATTR_IDX(mod_idx))) {
03132 
03133          if (!ML_AT_COMPRESSED_IDX(HN_ATTR_IDX(mod_idx))) {
03134             remove_hidden_name_ntry(mod_idx);
03135             end_idx = SCP_HN_LW_IDX(curr_scp_idx);
03136          }
03137       }
03138       mod_idx++;
03139    }
03140 
03141 
03142    for (mod_idx = SCP_HN_FW_IDX(curr_scp_idx) + 1;
03143         mod_idx < SCP_HN_LW_IDX(curr_scp_idx); mod_idx++) {
03144       HN_ATTR_IDX(mod_idx)      = ML_AT_IDX(HN_ATTR_IDX(mod_idx));
03145       HN_NAME_IDX(mod_idx)      = ML_NP_IDX(HN_NAME_IDX(mod_idx));
03146    }
03147 
03148    /* This updates the scp attr index, but be careful, because        */
03149    /* everything else in the scope table could be bad pointers.       */
03150 
03151    SCP_ATTR_IDX(curr_scp_idx) = ML_AT_IDX(SCP_ATTR_IDX(curr_scp_idx));
03152 
03153    TRACE (Func_Exit, "compress_tbls", NULL);
03154 
03155    return;
03156 
03157 }   /* compress_tbls */
03158 
03159 /******************************************************************************\
03160 |*                                                                            *|
03161 |* Description:                                                               *|
03162 |*                                                                            *|
03163 |* Input parameters:                                                          *|
03164 |*      NONE                                                                  *|
03165 |*                                                                            *|
03166 |* Output parameters:                                                         *|
03167 |*      NONE                                                                  *|
03168 |*                                                                            *|
03169 |* Returns:                                                                   *|
03170 |*      NOTHING                                                               *|
03171 |*                                                                            *|
03172 \******************************************************************************/
03173 static  void  update_idxs_in_attr_entry(int     start_idx,
03174                                         int     end_idx)
03175 {
03176    int          at_idx;
03177 
03178 
03179    TRACE (Func_Entry, "update_idxs_in_attr_entry", NULL);
03180 
03181    for (at_idx  = start_idx; at_idx <= end_idx; at_idx++) {
03182 
03183    if (!AT_IGNORE_ATTR_LINK(at_idx)) {
03184        AT_ATTR_LINK(at_idx)     = ML_AT_IDX(AT_ATTR_LINK(at_idx));
03185    }
03186 
03187    AT_NAME_IDX(at_idx)          = ML_NP_IDX(AT_NAME_IDX(at_idx));
03188    AT_ORIG_NAME_IDX(at_idx)     = ML_NP_IDX(AT_ORIG_NAME_IDX(at_idx));
03189    AT_MODULE_IDX(at_idx)        = ML_AT_IDX(AT_MODULE_IDX(at_idx));
03190 
03191    switch (AT_OBJ_CLASS(at_idx)) {
03192    case Data_Obj:
03193       ATD_ARRAY_IDX(at_idx)        = ML_BD_IDX(ATD_ARRAY_IDX(at_idx));
03194       ATD_DISTRIBUTION_IDX(at_idx) = ML_BD_IDX(ATD_DISTRIBUTION_IDX(at_idx));
03195       ATD_STOR_BLK_IDX(at_idx)     = ML_SB_IDX(ATD_STOR_BLK_IDX(at_idx));
03196       ATD_RESHAPE_ARRAY_IDX(at_idx)= ML_BD_IDX(ATD_RESHAPE_ARRAY_IDX(at_idx));
03197 
03198 # if defined(COARRAY_FORTRAN)
03199       ATD_PE_ARRAY_IDX(at_idx)     = ML_BD_IDX(ATD_PE_ARRAY_IDX(at_idx));
03200 # endif
03201 
03202       switch (ATD_CLASS(at_idx)) {
03203       case Function_Result:
03204 
03205          if (ATD_OFFSET_ASSIGNED(at_idx)) {
03206 
03207             switch (ATD_OFFSET_FLD(at_idx)) {
03208             case AT_Tbl_Idx:
03209                ATD_OFFSET_IDX(at_idx) = ML_AT_IDX(ATD_OFFSET_IDX(at_idx));
03210                break;
03211 
03212             case CN_Tbl_Idx:
03213                ATD_OFFSET_IDX(at_idx) = ML_CN_IDX(ATD_OFFSET_IDX(at_idx));
03214                break;
03215 
03216             case IR_Tbl_Idx:
03217                ATD_OFFSET_IDX(at_idx) = ML_IR_IDX(ATD_OFFSET_IDX(at_idx));
03218                break;
03219 
03220             case IL_Tbl_Idx:
03221                ATD_OFFSET_IDX(at_idx) = ML_IL_IDX(ATD_OFFSET_IDX(at_idx));
03222                break;
03223             }
03224          }
03225 
03226          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03227          ATD_FUNC_IDX(at_idx)   = ML_AT_IDX(ATD_FUNC_IDX(at_idx));
03228          break;
03229 
03230 
03231       case Constant:
03232 
03233          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03234 
03235          switch (ATD_FLD(at_idx)) {
03236          case AT_Tbl_Idx:
03237             ATD_CONST_IDX(at_idx) = ML_AT_IDX(ATD_CONST_IDX(at_idx));
03238             break;
03239  
03240          default:
03241             ATD_CONST_IDX(at_idx) = ML_CN_IDX(ATD_CONST_IDX(at_idx));
03242             break;
03243          }
03244          break;
03245 
03246 
03247       case CRI__Pointee:
03248          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03249          ATD_PTR_IDX(at_idx)    = ML_AT_IDX(ATD_PTR_IDX(at_idx));
03250          break;
03251 
03252       case Compiler_Tmp:
03253 
03254          ATD_NEXT_MEMBER_IDX(at_idx)  = ML_AT_IDX(ATD_NEXT_MEMBER_IDX(at_idx));
03255          ATD_DEFINING_ATTR_IDX(at_idx)=ML_AT_IDX(ATD_DEFINING_ATTR_IDX(at_idx));
03256 
03257          if (ATD_AUTOMATIC(at_idx)) {
03258             ATD_AUTO_BASE_IDX(at_idx) = ML_AT_IDX(ATD_AUTO_BASE_IDX(at_idx));
03259          }
03260          else if (ATD_OFFSET_ASSIGNED(at_idx)) {
03261 
03262             switch (ATD_OFFSET_FLD(at_idx)) {
03263             case AT_Tbl_Idx:
03264                ATD_OFFSET_IDX(at_idx) = ML_AT_IDX(ATD_OFFSET_IDX(at_idx));
03265                break;
03266 
03267             case CN_Tbl_Idx:
03268                ATD_OFFSET_IDX(at_idx) = ML_CN_IDX(ATD_OFFSET_IDX(at_idx));
03269                break;
03270 
03271             case IR_Tbl_Idx:
03272                ATD_OFFSET_IDX(at_idx) = ML_IR_IDX(ATD_OFFSET_IDX(at_idx));
03273                break;
03274 
03275             case IL_Tbl_Idx:
03276                ATD_OFFSET_IDX(at_idx) = ML_IL_IDX(ATD_OFFSET_IDX(at_idx));
03277                break;
03278             }
03279          }
03280 
03281          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03282 
03283          switch (ATD_FLD(at_idx)) {
03284          case CN_Tbl_Idx:
03285             ATD_TMP_IDX(at_idx)   = ML_CN_IDX(ATD_TMP_IDX(at_idx));
03286             break;
03287 
03288          case AT_Tbl_Idx:
03289             ATD_TMP_IDX(at_idx)   = ML_AT_IDX(ATD_TMP_IDX(at_idx));
03290             break;
03291 
03292          case IR_Tbl_Idx:
03293             ATD_TMP_IDX(at_idx)   = ML_IR_IDX(ATD_TMP_IDX(at_idx));
03294             break;
03295 
03296          case IL_Tbl_Idx:
03297             ATD_TMP_IDX(at_idx)   = ML_IL_IDX(ATD_TMP_IDX(at_idx));
03298             break;
03299          }
03300          break;
03301 
03302 
03303       case Dummy_Argument:
03304 
03305          if (!ATD_INTRIN_DARG(at_idx)) {
03306             ATD_TYPE_IDX(at_idx)        = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03307          }
03308          break;
03309 
03310 
03311       case Struct_Component:
03312 
03313          switch (ATD_OFFSET_FLD(at_idx)) {
03314          case AT_Tbl_Idx:
03315             ATD_CPNT_OFFSET_IDX(at_idx) =ML_AT_IDX(ATD_CPNT_OFFSET_IDX(at_idx));
03316             break;
03317 
03318          case CN_Tbl_Idx:
03319             ATD_CPNT_OFFSET_IDX(at_idx) =ML_CN_IDX(ATD_CPNT_OFFSET_IDX(at_idx));
03320             break;
03321 
03322          case IR_Tbl_Idx:
03323             ATD_CPNT_OFFSET_IDX(at_idx) =ML_IR_IDX(ATD_CPNT_OFFSET_IDX(at_idx));
03324             break;
03325 
03326          case IL_Tbl_Idx:
03327             ATD_CPNT_OFFSET_IDX(at_idx) =ML_IL_IDX(ATD_CPNT_OFFSET_IDX(at_idx));
03328             break;
03329          }
03330 
03331          switch (ATD_FLD(at_idx)) {
03332          case AT_Tbl_Idx:
03333             ATD_CPNT_INIT_IDX(at_idx)   = ML_AT_IDX(ATD_CPNT_INIT_IDX(at_idx));
03334             break;
03335 
03336          case CN_Tbl_Idx:
03337             ATD_CPNT_INIT_IDX(at_idx)   = ML_CN_IDX(ATD_CPNT_INIT_IDX(at_idx));
03338             break;
03339 
03340          case IR_Tbl_Idx:
03341             ATD_CPNT_INIT_IDX(at_idx)   = ML_IR_IDX(ATD_CPNT_INIT_IDX(at_idx));
03342             break;
03343 
03344          case IL_Tbl_Idx:
03345             ATD_CPNT_INIT_IDX(at_idx)   = ML_IL_IDX(ATD_CPNT_INIT_IDX(at_idx));
03346             break;
03347          }
03348          ATD_TYPE_IDX(at_idx)         = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03349          ATD_DERIVED_TYPE_IDX(at_idx) = ML_AT_IDX(ATD_DERIVED_TYPE_IDX(at_idx));
03350          break;
03351 
03352 
03353       case Variable:
03354 
03355          switch (ATD_FLD(at_idx)) {
03356          case AT_Tbl_Idx:
03357             ATD_VARIABLE_TMP_IDX(at_idx) =
03358                          ML_AT_IDX(ATD_VARIABLE_TMP_IDX(at_idx));
03359             break;
03360 
03361          case IL_Tbl_Idx:
03362             ATD_VARIABLE_TMP_IDX(at_idx) =
03363                          ML_IL_IDX(ATD_VARIABLE_TMP_IDX(at_idx));
03364             break;
03365          }
03366 
03367          ATD_ASSIGN_TMP_IDX(at_idx)   = ML_AT_IDX(ATD_ASSIGN_TMP_IDX(at_idx));
03368          ATD_NEXT_MEMBER_IDX(at_idx)  = ML_AT_IDX(ATD_NEXT_MEMBER_IDX(at_idx));
03369 
03370          if (ATD_AUTOMATIC(at_idx)) {
03371             ATD_AUTO_BASE_IDX(at_idx) = ML_AT_IDX(ATD_AUTO_BASE_IDX(at_idx));
03372          }
03373          else if (ATD_OFFSET_ASSIGNED(at_idx)) {
03374 
03375             switch (ATD_OFFSET_FLD(at_idx)) {
03376             case AT_Tbl_Idx:
03377                ATD_OFFSET_IDX(at_idx) = ML_AT_IDX(ATD_OFFSET_IDX(at_idx));
03378                break;
03379 
03380             case CN_Tbl_Idx:
03381                ATD_OFFSET_IDX(at_idx) = ML_CN_IDX(ATD_OFFSET_IDX(at_idx));
03382                break;
03383 
03384             case IR_Tbl_Idx:
03385                ATD_OFFSET_IDX(at_idx) = ML_IR_IDX(ATD_OFFSET_IDX(at_idx));
03386                break;
03387 
03388             case IL_Tbl_Idx:
03389                ATD_OFFSET_IDX(at_idx) = ML_IL_IDX(ATD_OFFSET_IDX(at_idx));
03390                break;
03391             }
03392          }
03393 
03394          /* Intentional fall through */
03395 
03396       default:
03397          ATD_TYPE_IDX(at_idx)   = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03398          break;
03399 
03400       }  /* End switch */
03401       break;
03402 
03403    case Pgm_Unit:
03404 
03405       if (ATP_PGM_UNIT(at_idx) == Module) {
03406          ATP_MOD_PATH_IDX(at_idx) = ML_NP_IDX(ATP_MOD_PATH_IDX(at_idx));
03407       }
03408       else {
03409          ATP_RSLT_IDX(at_idx)   = ML_AT_IDX(ATP_RSLT_IDX(at_idx));
03410          ATP_FIRST_IDX(at_idx)  = ML_SN_IDX(ATP_FIRST_IDX(at_idx));
03411 
03412          if (ATP_PROC(at_idx) != Intrin_Proc && ATP_PROC(at_idx) != Dummy_Proc){
03413             ATP_FIRST_SH_IDX(at_idx)= ML_SH_IDX(ATP_FIRST_SH_IDX(at_idx));
03414             ATP_PARENT_IDX(at_idx)  = ML_AT_IDX(ATP_PARENT_IDX(at_idx));
03415          }
03416       }
03417 
03418       ATP_EXT_NAME_IDX(at_idx)  = ML_NP_IDX(ATP_EXT_NAME_IDX(at_idx));
03419       break;
03420 
03421    case Label:
03422 
03423       ATL_NEXT_ASG_LBL_IDX(at_idx) = ML_AT_IDX(ATL_NEXT_ASG_LBL_IDX(at_idx));
03424 
03425       if (AT_DEFINED(at_idx)) {
03426          ATL_DEF_STMT_IDX(at_idx)  = ML_SH_IDX(ATL_DEF_STMT_IDX(at_idx));
03427       }
03428 
03429       if (ATL_CLASS(at_idx) == Lbl_Format) {
03430          ATL_PP_FORMAT_TMP(at_idx) = ML_AT_IDX(ATL_PP_FORMAT_TMP(at_idx));
03431          ATL_FORMAT_TMP(at_idx)    = ML_AT_IDX(ATL_FORMAT_TMP(at_idx));
03432       }
03433       else {
03434          ATL_DIRECTIVE_LIST(at_idx)= ML_IL_IDX(ATL_DIRECTIVE_LIST(at_idx));
03435 
03436          if (ATL_CLASS(at_idx) == Lbl_User) {
03437             ATL_BLK_STMT_IDX(at_idx)  = ML_SH_IDX(ATL_BLK_STMT_IDX(at_idx));
03438          }
03439       }
03440       break;
03441 
03442 
03443    case Derived_Type:
03444 
03445       if (ATT_STRUCT_BIT_LEN_IDX(at_idx) != NULL_IDX) {
03446 
03447          switch (ATT_STRUCT_BIT_LEN_FLD(at_idx)) {
03448          case CN_Tbl_Idx:
03449             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03450                                  ML_CN_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03451             break;
03452 
03453          case AT_Tbl_Idx:
03454             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03455                                  ML_AT_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03456             break;
03457 
03458          case IL_Tbl_Idx:
03459             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03460                                  ML_IL_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03461             break;
03462 
03463          case IR_Tbl_Idx:
03464             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03465                                  ML_IR_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03466             break;
03467 
03468          case NO_Tbl_Idx:
03469             ATT_STRUCT_BIT_LEN_FLD(at_idx) = CN_Tbl_Idx;
03470             ATT_STRUCT_BIT_LEN_IDX(at_idx) = 
03471                                  ML_CN_IDX(ATT_STRUCT_BIT_LEN_IDX(at_idx));
03472             break;
03473          }
03474       }
03475 
03476       ATT_FIRST_CPNT_IDX(at_idx)        = ML_SN_IDX(ATT_FIRST_CPNT_IDX(at_idx));
03477       break;
03478 
03479    case Interface:
03480 
03481       ATI_FIRST_SPECIFIC_IDX(at_idx) =ML_SN_IDX(ATI_FIRST_SPECIFIC_IDX(at_idx));
03482       ATI_PROC_IDX(at_idx)              = ML_AT_IDX(ATI_PROC_IDX(at_idx));
03483       ATD_TYPE_IDX(at_idx)              = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03484       break;
03485 
03486    case Namelist_Grp:
03487 
03488       ATN_FIRST_NAMELIST_IDX(at_idx) =ML_SN_IDX(ATN_FIRST_NAMELIST_IDX(at_idx));
03489       ATN_LAST_NAMELIST_IDX(at_idx)  = ML_SN_IDX(ATN_LAST_NAMELIST_IDX(at_idx));
03490 
03491       if (ATN_NAMELIST_DESC(at_idx) != NULL_IDX) {
03492          ATN_NAMELIST_DESC(at_idx)   = ML_AT_IDX(ATN_NAMELIST_DESC(at_idx));
03493       }
03494       break;
03495 
03496    case Stmt_Func:
03497 
03498       ATD_TYPE_IDX(at_idx) = ML_TYP_IDX(ATD_TYPE_IDX(at_idx));
03499       ATP_FIRST_IDX(at_idx) = ML_SN_IDX(ATP_FIRST_IDX(at_idx));
03500 
03501       switch (ATS_SF_FLD(at_idx)) {
03502       case CN_Tbl_Idx:
03503          ATS_SF_IDX(at_idx) = ML_CN_IDX(ATS_SF_IDX(at_idx));
03504          break;
03505 
03506       case AT_Tbl_Idx:
03507          ATS_SF_IDX(at_idx) = ML_AT_IDX(ATS_SF_IDX(at_idx));
03508          break;
03509 
03510       case IR_Tbl_Idx:
03511          ATS_SF_IDX(at_idx) = ML_IR_IDX(ATS_SF_IDX(at_idx));
03512          break;
03513 
03514       case IL_Tbl_Idx:
03515          ATS_SF_IDX(at_idx) = ML_IL_IDX(ATS_SF_IDX(at_idx));
03516          break;
03517       }
03518       break;
03519    }  /* End switch */
03520    }  /* End For */
03521 
03522    TRACE (Func_Exit, "update_idxs_in_attr_entry", NULL);
03523 
03524    return;
03525 
03526 }   /* update_idxs_in_attr_entry */
03527 
03528 /******************************************************************************\
03529 |*                                                                            *|
03530 |* Description:                                                               *|
03531 |*                                                                            *|
03532 |* Input parameters:                                                          *|
03533 |*      NONE                                                                  *|
03534 |*                                                                            *|
03535 |* Output parameters:                                                         *|
03536 |*      NONE                                                                  *|
03537 |*                                                                            *|
03538 |* Returns:                                                                   *|
03539 |*      NOTHING                                                               *|
03540 |*                                                                            *|
03541 \******************************************************************************/
03542 extern  void  output_mod_info_file(void)
03543 
03544 {
03545    int           al_idx;
03546    int           idx;
03547    int           module_attr_idx;
03548    FILE         *mod_file_ptr           = NULL;
03549    long         *mod_idx;
03550    int           name_idx;
03551    int           sb_idx;
03552    int           wd_len;
03553 
03554 
03555    TRACE (Func_Entry, "output_mod_info_file", NULL);
03556 
03557    module_attr_idx      = SCP_ATTR_IDX(curr_scp_idx);
03558 
03559    if (dump_flags.preinline) {  /* Append these files */
03560       mod_file_ptr = fopen(FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)), "ab");
03561    }
03562    else if (on_off_flags.module_to_mod) {
03563       mod_file_ptr = fopen(FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)), "wb");
03564    }
03565    else {
03566 
03567 #     if defined(_MODULE_TO_DOT_M)      /* These are all appended */
03568          mod_file_ptr = fopen(FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)),
03569                               "ab");
03570 #     else
03571          mod_file_ptr = fopen(FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)),
03572                               "wb");
03573 #     endif
03574    }
03575 
03576    SCP_FILE_PATH_IDX(curr_scp_idx) = NULL_IDX;
03577 
03578    if (ATP_PGM_UNIT(module_attr_idx) == Module) {
03579       ATP_MOD_PATH_IDX(module_attr_idx) = NULL_IDX;
03580       ATP_MOD_PATH_LEN(module_attr_idx) = 0;
03581    }
03582 
03583    if (mod_file_ptr == NULL) {
03584       PRINTMSG(AT_DEF_LINE(module_attr_idx), 1665, Error,
03585                AT_DEF_COLUMN(module_attr_idx),
03586                AT_OBJ_NAME_PTR(module_attr_idx),
03587                FP_NAME_PTR(SCP_FILE_PATH_IDX(curr_scp_idx)));
03588       goto EXIT;
03589    }
03590 
03591    MD_PDT_HDR_TYPE              = COMPILER_INFO_TABLE_TYPE;
03592    MD_VERSION_NUM               = MD_CURRENT_VERSION;
03593    MD_TARGET                    = target_os;
03594    MD_ENABLE_DOUBLE_PRECISION   = on_off_flags.enable_double_precision;
03595    MD_DEFAULT_INTEGER_TYPE      = INTEGER_DEFAULT_TYPE;
03596    MD_HAS_ERRORS                = (num_prog_unit_errors > 0);
03597    MD_DALIGN                    = cmd_line_flags.dalign;
03598    MD_CF77TYPES                 = cmd_line_flags.s_cf77types;
03599    MD_DEFAULT32                 = cmd_line_flags.s_default32;
03600    MD_DEFAULT64                 = cmd_line_flags.s_default64;
03601    MD_FLOAT64                   = cmd_line_flags.s_float64;
03602 
03603    MD_NEW_CONST_TBL             = TRUE;
03604 
03605    /* At this point, if we're outputing for inlining we need to check for   */
03606    /* alternate entries.  If they exist, an md_header_descriptor is written */
03607    /* out for each.  The actual tables for the alternate entry follow in    */
03608    /* main entry and can can be found by reading the 026 table until the    */
03609    /* next main entry is found.                                             */
03610 
03611    if (ATP_MAY_INLINE(SCP_ATTR_IDX(MAIN_SCP_IDX)) && 
03612        SCP_ENTRY_IDX(MAIN_SCP_IDX) != NULL_IDX) {
03613       al_idx            = SCP_ENTRY_IDX(MAIN_SCP_IDX);
03614       MD_ALTERNATE_ENTRY= TRUE;
03615       MD_PDT_HDR_LEN    = sizeof(mit_header_type)/TARGET_BYTES_PER_WORD;
03616 
03617 # if defined(_HOST32) && defined(_TARGET64)
03618 
03619       /* PDT size must be in 64 bit increment sizes. */
03620 
03621       MD_PDT_HDR_LEN = (MD_PDT_HDR_LEN + 1) / 2;
03622 # endif
03623 
03624       while (al_idx != NULL_IDX) {
03625          name_idx       = AT_NAME_IDX(AL_ATTR_IDX(al_idx));
03626          MD_NAME_LEN    = AT_NAME_LEN(AL_ATTR_IDX(al_idx));
03627          wd_len         = WORD_LEN(MD_NAME_LEN);
03628          mod_idx        = MD_NAME_LONG;
03629 
03630          for (idx = 0; idx < wd_len; idx++) {
03631             *mod_idx    = name_pool[name_idx].name_long;
03632             name_idx++;
03633             mod_idx++;
03634          }
03635 
03636          fwrite(&mit_header, sizeof(mit_header_type), 1, mod_file_ptr);
03637          al_idx         = AL_NEXT_IDX(al_idx);
03638       }
03639 
03640       /* Reset the original name in the header. */
03641 
03642       name_idx          = AT_NAME_IDX(module_attr_idx);
03643       MD_NAME_LEN       = AT_NAME_LEN(module_attr_idx);
03644       wd_len            = WORD_LEN(MD_NAME_LEN);
03645       mod_idx           = MD_NAME_LONG;
03646 
03647       for (idx = 0; idx < wd_len; idx++) {
03648          *mod_idx       = name_pool[name_idx].name_long;
03649          name_idx++;
03650          mod_idx++;
03651       }
03652    }
03653 
03654    MD_ALTERNATE_ENTRY           = FALSE;
03655 
03656    if (dump_flags.preinline && num_prog_unit_errors > 0) {
03657 
03658       /* Do not write out any tables.  Just a header with error set. */
03659 
03660       attr_tbl_idx      = NULL_IDX;
03661       attr_aux_tbl_idx  = NULL_IDX;
03662       bounds_tbl_idx    = NULL_IDX;
03663       const_tbl_idx     = NULL_IDX;
03664       const_pool_idx    = NULL_IDX;
03665       ir_tbl_idx        = NULL_IDX;
03666       ir_list_tbl_idx   = NULL_IDX;
03667       loc_name_tbl_idx  = NULL_IDX;
03668       name_pool_idx     = NULL_IDX;
03669       sec_name_tbl_idx  = NULL_IDX;
03670       stor_blk_tbl_idx  = NULL_IDX;
03671       type_tbl_idx      = NULL_IDX;
03672       sh_tbl_idx        = NULL_IDX;
03673    }
03674    else {
03675 
03676       /* Do not write out any tables.  Just the mod header. */
03677 
03678       /* In error situations, module_attr_idx may not be in the local name    */
03679       /* table so it has to be specifically included for output.  This module */
03680       /* output is only used to finish this compilation because of errors.    */
03681 
03682       ML_AT_IDX(module_attr_idx)        = module_attr_idx;
03683 
03684       /* assign_new_idxs needs to have ML_AT_IDX(0) = NULL_IDX, ML_BD_IDX(0)  */
03685       /* = NULL_IDX -  ect..  The zeroth entry of the mod link table contains */
03686       /* the index to start compression at for each table.  When compressing  */
03687       /* tables for module output, everything gets compressed, so the zeroth  */
03688       /* entry should be all zeros to signify that everything gets compressed.*/
03689       /* The zeroth entry is set to all NULL_IDX's when the table is allocated*/
03690 
03691       /* Resolve duplicate attr idxs in mod link table.         */
03692 
03693       save_const_pool_idx       = NULL_IDX;
03694       save_const_tbl_idx        = NULL_IDX;
03695 
03696       /* If we're not creating a preinline file and if MODINLINE is not on    */
03697       /* for this module, then we will not be writing out the SH table, so    */
03698       /* set ML_SH_IDX equal to sh_tbl_idx, so we do nothing in assign_new..  */
03699       /* Then clear sh_tbl_idx and ML_SH_IDX so we do nothing in compress_..  */
03700 
03701       if (!ATP_MAY_INLINE(SCP_ATTR_IDX(MAIN_SCP_IDX))) {
03702          ML_SH_IDX(0)   = sh_tbl_idx;  /* SH table not needed.  */
03703          assign_new_idxs(TRUE);
03704          ML_SH_IDX(0)   = NULL_IDX;
03705          sh_tbl_idx     = NULL_IDX;
03706       }
03707       else {
03708          assign_new_idxs(TRUE);
03709       }
03710 
03711       /* Do table compression, but do not update the attribute entries in the */
03712       /* attr_list_tbl.  Stop updating from happening, by passing the last    */
03713       /* used index in attr_list_tbl.  compress_tbls goes through the attr    */
03714       /* list table starting at the entry past the entry passed in.           */
03715 
03716       num_module_derived_types  = 0;  /* Not used - clear to prevent overflow */
03717       count_derived_types       = FALSE;
03718       compress_tbls(attr_list_tbl_idx, FALSE); 
03719 
03720       /* module_attr_idx may have been moved during compression. */
03721 
03722       module_attr_idx           = ML_AT_IDX(module_attr_idx);
03723 
03724       /* Certain flds in the attr table need to be cleared, such as line      */
03725       /* numbers cif ids, the referenced flag ect..                           */
03726       /* Also, if alternate entries, reset ATP_FIRST_SH_IDX to the main       */
03727       /* entry's ATP_FIRST                                                    */
03728 
03729       set_attr_flds_for_output();
03730 
03731       /* Any bounds table free list is destroyed. */
03732 
03733       BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX)       = NULL_IDX;
03734 
03735       /* Set ATP_SCP_ALIVE for the module attr, so that it can be recognized  */
03736       /* when the module is read in again.  ATP_SCP_ALIVE is turned off for   */
03737       /* everything after the semantic pass in s_driver.                      */
03738 
03739       ATP_SCP_ALIVE(module_attr_idx)    = TRUE;
03740 
03741       for (sb_idx       = 1; sb_idx <= stor_blk_tbl_idx; sb_idx++) {
03742          SB_CIF_SYMBOL_ID(sb_idx)    = NULL_IDX;
03743       }
03744    }
03745 
03746    /* Note on table sizes.  tbl_idx is the last used item in the table.       */
03747    /* The 0th entry should not be written out to the module info table,       */
03748    /* so using tbl_idx as the size of the table to write out is correct.      */
03749    /* That is also why when the tables are written they start at [1].         */
03750 
03751    MD_TBL_TYPE(Attr_Tbl)        = Attr_Tbl;
03752    MD_NUM_ENTRIES(Attr_Tbl)     = attr_tbl_idx;
03753    MD_TBL_TYPE(Bounds_Tbl)      = Bounds_Tbl;
03754    MD_NUM_ENTRIES(Bounds_Tbl)   = bounds_tbl_idx;
03755    MD_TBL_TYPE(Const_Tbl)       = Const_Tbl;
03756    MD_NUM_ENTRIES(Const_Tbl)    = const_tbl_idx;
03757    MD_TBL_TYPE(Const_Pool)      = Const_Pool;
03758    MD_NUM_ENTRIES(Const_Pool)   = const_pool_idx;
03759    MD_TBL_TYPE(Ir_Tbl)          = Ir_Tbl;
03760    MD_NUM_ENTRIES(Ir_Tbl)       = ir_tbl_idx;
03761    MD_TBL_TYPE(Ir_List_Tbl)     = Ir_List_Tbl;
03762    MD_NUM_ENTRIES(Ir_List_Tbl)  = ir_list_tbl_idx;
03763    MD_TBL_TYPE(Loc_Name_Tbl)    = Loc_Name_Tbl;
03764    MD_NUM_ENTRIES(Loc_Name_Tbl) = loc_name_tbl_idx;
03765    MD_TBL_TYPE(Name_Pool)       = Name_Pool;
03766    MD_NUM_ENTRIES(Name_Pool)    = name_pool_idx;
03767    MD_TBL_TYPE(Sec_Name_Tbl)    = Sec_Name_Tbl;
03768    MD_NUM_ENTRIES(Sec_Name_Tbl) = sec_name_tbl_idx;
03769    MD_TBL_TYPE(Stor_Blk_Tbl)    = Stor_Blk_Tbl;
03770    MD_NUM_ENTRIES(Stor_Blk_Tbl) = stor_blk_tbl_idx;
03771    MD_TBL_TYPE(Type_Tbl)        = Type_Tbl;
03772    MD_NUM_ENTRIES(Type_Tbl)     = type_tbl_idx;
03773    MD_TBL_TYPE(Sh_Tbl)          = Sh_Tbl;
03774    MD_NUM_ENTRIES(Sh_Tbl)       = sh_tbl_idx;
03775 
03776    MD_PDT_HDR_LEN               = (attr_tbl_idx * NUM_AT_WDS) +
03777                                   (bounds_tbl_idx * NUM_BD_WDS) +
03778                                   (const_tbl_idx * NUM_CN_WDS) +
03779                                   (const_pool_idx * NUM_CP_WDS) +
03780                                   (ir_list_tbl_idx * NUM_IL_WDS) +
03781                                   (ir_tbl_idx * NUM_IR_WDS) +
03782                                   (loc_name_tbl_idx * NUM_LN_WDS) +
03783                                   (name_pool_idx * NUM_NP_WDS) +
03784                                   (sec_name_tbl_idx * NUM_SN_WDS) +
03785                                   (stor_blk_tbl_idx * NUM_SB_WDS) +
03786                                   (type_tbl_idx * NUM_TYP_WDS) +
03787                                   (sh_tbl_idx * NUM_SH_WDS) +
03788                                   (MD_TBL_BYTE_SIZE/TARGET_BYTES_PER_WORD) +
03789                                   ((sizeof(mit_descriptor_type) / 
03790                                       TARGET_BYTES_PER_WORD) * Num_Of_Tbls);
03791 
03792 /* KAY */
03793 
03794    /* PDT size must be in 64 bit increment sizes. */
03795 
03796 # if defined(_HOST32) && defined(_TARGET64)
03797    MD_PDT_HDR_LEN = (MD_PDT_HDR_LEN + 1) / 2;
03798 # endif
03799 
03800    fwrite(&mit_header, sizeof(mit_header_type), 1, mod_file_ptr);
03801 
03802    fwrite(&mit_descriptor[1], 
03803           sizeof(mit_descriptor_type),
03804           Num_Of_Tbls,
03805           mod_file_ptr);
03806 
03807    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, name_pool);
03808    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, loc_name_tbl);
03809    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, attr_tbl);
03810    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, bounds_tbl);
03811    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, const_tbl);
03812    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, const_pool);
03813    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, sec_name_tbl);
03814    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, stor_blk_tbl);
03815    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, type_tbl);
03816    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, ir_tbl);
03817    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, ir_list_tbl);
03818    OUTPUT_TBL_TO_MODULE(mod_file_ptr, module_attr_idx, sh_tbl);
03819 
03820    fflush(mod_file_ptr);
03821    fclose(mod_file_ptr);
03822 
03823    const_tbl_idx++;  /* Adjust so it is set to next available index */
03824 
03825 EXIT:
03826 
03827    TBL_FREE(mod_link_tbl);
03828 
03829    TRACE (Func_Exit, "output_mod_info_file", NULL);
03830 
03831    return;
03832 
03833 }  /* output_mod_info_file */
03834 
03835 /******************************************************************************\
03836 |*                                                                            *|
03837 |* Description:                                                               *|
03838 |*                                                                            *|
03839 |* Input parameters:                                                          *|
03840 |*      NONE                                                                  *|
03841 |*                                                                            *|
03842 |* Output parameters:                                                         *|
03843 |*      NONE                                                                  *|
03844 |*                                                                            *|
03845 |* Returns:                                                                   *|
03846 |*      NOTHING                                                               *|
03847 |*                                                                            *|
03848 \******************************************************************************/
03849 void    use_stmt_semantics(void)
03850                                 
03851 {
03852    int           al_idx;
03853    int           attr_idx;
03854    int           attr_list_free_list;
03855    int           bd_idx;
03856    int           host_attr_idx;
03857    int           host_name_idx;
03858    int           interface_list;
03859    int           ln_idx;  
03860    int           match;
03861    int           module_attr_idx;
03862    int           module_list_idx;
03863    int           name_idx;
03864    int           new_name_idx;
03865    int           new_sn_idx;
03866    int           save_attr_list_tbl_idx;
03867    int           srch_attr_idx;
03868    int           start_ln_idx;
03869    boolean       use_only;
03870    int           use_ir_idx;
03871    int           ro_idx;
03872    boolean       error_break=0;
03873 
03874    TRACE (Func_Entry, "use_stmt_semantics", NULL);
03875 
03876    /* global flag used to tell set_mod_link_tbl_for_attr */
03877    /* that it should check all attrs for duplicates.     */
03878    /* This refers to search_for_duplicate_attrs          */
03879 
03880    list_of_modules_in_module    = NULL_IDX;
03881    module_list_idx              = SCP_USED_MODULE_LIST(curr_scp_idx);
03882    attr_list_free_list          = AL_NEXT_IDX(NULL_IDX);
03883    interface_list               = NULL_IDX;
03884 
03885    keep_module_procs = (opt_flags.inline_lvl > Inline_Lvl_0) ||
03886                         ATP_MAY_INLINE(SCP_ATTR_IDX(MAIN_SCP_IDX));
03887 
03888    /* Find the last module on the list.  This is really the first module   */
03889    /* specified on a USE list.  This way we get the ordering correct, plus */
03890    /* since we are backing up the list and the list is extended at the     */
03891    /* bottom, we don't end up trying to process the newly added indirectly */
03892    /* referenced modules.  The list is extended in resolve_used_modules.   */
03893    /* All modules that are indirectly brought in during USE association    */
03894    /* are added to this list.  This helps get messages issued correctly    */
03895    /* and keeps CIF happy.  See resolve_used_modules for more details.     */
03896    /* All the modules specified on the USE statement are specifed on this  */
03897    /* list first, because these are the attr indexes we want to use.       */
03898 
03899    while (AL_NEXT_IDX(module_list_idx) != NULL_IDX) {
03900       module_list_idx   = AL_NEXT_IDX(module_list_idx);
03901    }
03902 
03903    while (module_list_idx != NULL_IDX) {
03904       error_break=0;  
03905       module_attr_idx                   = AL_ATTR_IDX(module_list_idx);
03906       only_update_new_tbl_entries       = TRUE;
03907 
03908       /* For next iteration */
03909 
03910       module_list_idx   = AL_PREV_MODULE_IDX(module_list_idx); 
03911 
03912       if (ATP_IMPLICIT_USE_MODULE(module_attr_idx)) {
03913 
03914          /* Need to generate the Use_Opr - Have a curr_stmt_sh - use it */
03915 
03916         /* Generate IR for this USE statement.  Need to keep the attr so that */
03917         /* it can be passed thru the PDGCS interface during IR conversion.    */
03918         /* Do not need pass2 semantics for this statement.                    */
03919 
03920         NTR_IR_TBL(use_ir_idx);
03921         IR_OPR(use_ir_idx)              = Use_Opr;
03922         IR_TYPE_IDX(use_ir_idx)         = TYPELESS_DEFAULT_TYPE;
03923         IR_LINE_NUM(use_ir_idx)         = stmt_start_line;
03924         IR_COL_NUM(use_ir_idx)          = stmt_start_col;
03925         IR_IDX_L(use_ir_idx)            = module_attr_idx;
03926         IR_FLD_L(use_ir_idx)            = AT_Tbl_Idx;
03927         IR_LINE_NUM_L(use_ir_idx)       = stmt_start_line;
03928         IR_COL_NUM_L(use_ir_idx)        = stmt_start_col;
03929 
03930         gen_sh(Before,
03931                Use_Stmt,
03932                stmt_start_line,
03933                stmt_start_col,
03934                FALSE,
03935                FALSE,
03936                TRUE); /* Compiler gen'd */
03937 
03938         SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx))    = TRUE;
03939         SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx))        = use_ir_idx;
03940       }
03941 
03942       if (on_off_flags.issue_ansi_messages ||
03943           GET_MESSAGE_TBL(message_warning_tbl, 953) ||
03944           GET_MESSAGE_TBL(message_error_tbl, 953)) {
03945 
03946          /* Non standard to let a module have the same name as a local */
03947          /* entity in a parent scope.  Don't issue if the entity in    */
03948          /* parent scope is a module.  This means we are using the     */
03949          /* module in several scopes and is legal and standard.        */
03950 
03951          srch_attr_idx = srch_host_sym_tbl(AT_OBJ_NAME_PTR(module_attr_idx),
03952                                            AT_NAME_LEN(module_attr_idx),
03953                                            &name_idx,
03954                                            FALSE);
03955 
03956          if (srch_attr_idx != NULL_IDX && 
03957              (AT_OBJ_CLASS(srch_attr_idx) != Pgm_Unit ||
03958               ATP_PGM_UNIT(srch_attr_idx) != Module)) {
03959             PRINTMSG(AT_DEF_LINE(module_attr_idx), 953, Ansi,
03960                      AT_DEF_COLUMN(module_attr_idx),
03961                      AT_OBJ_NAME_PTR(module_attr_idx));
03962          }
03963       }
03964 
03965       save_attr_list_tbl_idx    = attr_list_tbl_idx;
03966 
03967       /* Force all new attr list table entries to the end so we can */
03968       /* find the new ones for compression.                         */
03969 
03970       AL_NEXT_IDX(NULL_IDX)     = NULL_IDX;
03971       use_only                  = ATP_USE_TYPE(module_attr_idx) == Use_Only;
03972 
03973       if (!find_prog_unit_tbl(module_attr_idx)) {
03974 
03975          /* Couldn't find the module or bad reads */
03976          error_break = 1;
03977 
03978          goto EXIT;
03979       }
03980 
03981       start_ln_idx      = loc_name_tbl_idx - MD_NUM_ENTRIES(Loc_Name_Tbl) + 1;
03982       attr_idx          = attr_tbl_idx - MD_NUM_ENTRIES(Attr_Tbl) + 1;
03983 
03984 # ifdef _DEBUG
03985       if (start_ln_idx <= 0) {
03986          PRINTMSG(1, 626, Internal, 0, "positive start_ln_idx",
03987                   "use_stmt_semantics");
03988       }
03989       if (attr_idx <= 0) {
03990          PRINTMSG(1, 626, Internal, 0, "positive attr_idx",
03991                   "use_stmt_semantics");
03992       }
03993 # endif
03994 
03995       if (ATP_USE_LIST(module_attr_idx) != NULL_IDX) {
03996          rename_only_semantics(module_attr_idx, use_only);
03997       }
03998 
03999       /* Go through all new entries in the local name table.  Decide which */
04000       /* ones to keep and which to toss.  This merges the new entries into */
04001       /* the old local name table as it goes through.  Since the new       */
04002       /* entries follow the old, as the old table grows the new table      */
04003       /* shrinks.  Both tables are in alphabetical order and we start at   */
04004       /* the top of the new table.  If we are keeping the new entry we     */
04005       /* move it up to its proper position in the old table.  We enter it  */
04006       /* by moving everything down in the old table after its proper       */
04007       /* position.  One entry of space has been left between the old and   */
04008       /* new tables to make sure that as the old table grows it does not   */
04009       /* write over the current entry being processed from the new table.  */
04010 
04011       ln_idx            = SCP_LN_FW_IDX(curr_scp_idx) + 1;
04012 
04013       for (new_name_idx = start_ln_idx;
04014            new_name_idx <= loc_name_tbl_idx; 
04015            new_name_idx++) {
04016 
04017          if (use_only) {
04018 
04019             /* This module is brought in with an ONLY.  Throw out       */
04020             /* everything that is not specified on the ONLY statement.  */
04021             /* If this is a renamed item from an ONLY list, LN_NEW_NAME */
04022             /* will be set, but LN_IN_ONLY_LIST will not be set, unless */
04023             /* the name itself is specified in the only list.           */
04024 
04025             if (!LN_IN_ONLY_LIST(new_name_idx) && 
04026                 !LN_NEW_NAME(new_name_idx)) {
04027                continue;
04028             }
04029 
04030             ML_LN_KEEP_ME(new_name_idx)         = TRUE;
04031             LN_IN_ONLY_LIST(new_name_idx)       = FALSE;
04032             LN_NEW_NAME(new_name_idx)           = FALSE;
04033             LN_RENAMED(new_name_idx)            = FALSE;
04034          }
04035          else {  /* Possible renames */
04036 
04037             if (LN_RENAMED(new_name_idx)) {
04038                continue;   /* This has been renamed.  Throw out. */
04039             }
04040 
04041             ML_LN_KEEP_ME(new_name_idx) = TRUE;
04042             LN_NEW_NAME(new_name_idx)   = FALSE;
04043          }
04044 
04045          attr_idx       = LN_ATTR_IDX(new_name_idx);
04046 
04047          /* Find the new entries position in the old local name table. */
04048 
04049          do {
04050 
04051             if (ln_idx >= SCP_LN_LW_IDX(curr_scp_idx)) {
04052                ln_idx = SCP_LN_LW_IDX(curr_scp_idx);
04053                match  = -1;
04054             }
04055             else {
04056                match = compare_names(LN_NAME_LONG(new_name_idx),
04057                                      LN_NAME_LEN(new_name_idx),
04058                                      LN_NAME_LONG(ln_idx),
04059                                      LN_NAME_LEN(ln_idx));
04060 
04061                if (match > 0) {
04062                   ln_idx++;
04063                } 
04064             } 
04065          } 
04066          while (match > 0);
04067 
04068          if (match == 0) {
04069             not_visible_semantics(attr_idx,          /* new attr index  */
04070                                   ln_idx,            /* Old name index  */
04071                                   module_attr_idx);
04072             AT_REFERENCED(AT_MODULE_IDX(attr_idx)) = Referenced;
04073          }
04074          else {
04075             (SCP_LN_LW_IDX(curr_scp_idx))++;
04076 
04077             NTR_NAME_IN_LN_TBL(ln_idx, new_name_idx);
04078 
04079             LN_DEF_LOC(new_name_idx)    = TRUE;
04080 
04081             if (!ML_AT_SEARCHED(attr_idx) && resolve_attr(attr_idx)) {
04082 
04083                /* If resolve attr is TRUE, we are not keeping the attr */
04084                /* entry, because the same object is already in this    */
04085                /* scope and we are going to use that attr entry.       */
04086 
04087                KEEP_ATTR(ML_AT_IDX(attr_idx));
04088             }
04089             else {
04090 
04091                /* If we are keeping this attr, set_mod_link_tbl_for_attr */
04092                /* will call resolve_attr for all the dependent attrs.    */
04093 
04094                AT_REFERENCED(AT_MODULE_IDX(attr_idx)) = Referenced;
04095 
04096                KEEP_ATTR(attr_idx);
04097 
04098                if (AT_OBJ_CLASS(attr_idx) == Interface &&
04099                    !AT_IS_INTRIN(attr_idx) &&
04100                    SCP_PARENT_IDX(curr_scp_idx) != NULL_IDX &&
04101                    !SCP_IS_INTERFACE(curr_scp_idx)) {
04102 
04103                   /* Add to the top of the interface list. */
04104 
04105                   /* The following code implements interp 99                */
04106                   /* If two or more generic interfaces that are accessible  */
04107                   /* in a scoping unit have the same name, ..., they are    */
04108                   /* interpreted as a single generic interface.             */
04109 
04110                   /* We actually do the host association after all the use  */
04111                   /* statements for this scope are processed.  If we don't  */
04112                   /* wait, we end up putting new scopes after the current   */
04113                   /* scopes.                                                */
04114 
04115                   NTR_ATTR_LIST_TBL(al_idx);
04116                   AL_ATTR_IDX(al_idx)   = attr_idx;
04117                   AL_NEXT_IDX(al_idx)   = interface_list;
04118                   interface_list        = al_idx;
04119                }
04120             }
04121          }
04122 
04123          if (AT_NAME_IDX(attr_idx) != AT_ORIG_NAME_IDX(attr_idx)) { /* Renamed*/
04124 
04125             if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
04126 
04127                if (ATD_STOR_BLK_IDX(attr_idx) != NULL_IDX) {
04128                   SB_HAS_RENAMES(ATD_STOR_BLK_IDX(attr_idx)) = TRUE;
04129                }
04130             }
04131             else if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
04132                      ATP_PROC(attr_idx) == Function &&
04133                      !ATP_RSLT_NAME(attr_idx)  &&
04134                      ATD_STOR_BLK_IDX(ATP_RSLT_IDX(attr_idx)) != NULL_IDX) {
04135                SB_HAS_RENAMES(ATD_STOR_BLK_IDX(ATP_RSLT_IDX(attr_idx))) = TRUE;
04136             }
04137          }
04138       }
04139 
04140       /* At this point, all new attribute entries have been checked to see */
04141       /* if they already exist in this scope, because of a previous use    */
04142       /* statement.  If the attr will get put into the new local name      */
04143       /* table, it has not been checked yet for not visible semantics.     */
04144       /* That is done as the old an new entries are merged.  If the attr   */
04145       /* will not go in the new local name table, both the local name tbl  */
04146       /* and the hidden name table were searched for the attr entry.  If   */
04147       /* it was found already in either table, the attr is marked so that  */
04148       /* the new attr idx becomes the old.  Any new attrs are entered into */
04149       /* the hidden name table.                                            */
04150 
04151 
04152       /* resolve_used_modules will issue CIF records and messages where    */
04153       /* necessary for all the modules brought in via this USE statement.  */
04154 
04155       resolve_used_modules(module_attr_idx);
04156 
04157       loc_name_tbl_idx = SCP_LN_LW_IDX(curr_scp_idx);
04158 
04159       /* The compression is a partial compression.  It only compresses the */
04160       /* tables just read in from the module table.  It is compressing out */
04161       /* entries not needed after the ONLY list(s) have been processed.    */
04162       /* These entries may point into the section of the tables not being  */
04163       /* compressed.  The compression algorithm handles this, but entries  */
04164       /* that are being kept cannot index to entries that are being        */
04165       /* compressed out.                                                   */
04166 
04167 
04168       /* At this point the local name table does not contain anything that */
04169       /* needs to be compressed out.  Do not compress the ln table.        */
04170 
04171       ML_LN_IDX(0) = SCP_LN_LW_IDX(curr_scp_idx);
04172 
04173       /* Keep everything on the bounds table free list.  It's easier to    */
04174       /* keep it, than to attempt to collapse it out, because we do not    */
04175       /* know if the free entries are in the area being collapsed or in    */
04176       /* the area being left alone.                                        */
04177 
04178       bd_idx       = BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX);
04179 
04180       while (bd_idx != NULL_IDX) {
04181          ML_BD_KEEP_ME(bd_idx)  = TRUE;
04182          bd_idx                 = BD_NEXT_FREE_NTRY(bd_idx);
04183       }
04184 
04185       /* Resolve duplicate entries and share constant table entries. */
04186 
04187       assign_new_idxs(TRUE);
04188 
04189       save_const_pool_idx       = NULL_IDX;
04190       save_const_tbl_idx        = NULL_IDX;
04191       num_module_derived_types  = 0;
04192       count_derived_types       = TRUE;
04193 
04194       compress_tbls(save_attr_list_tbl_idx, FALSE);
04195 
04196       if (CURR_BLK != Interface_Body_Blk) {
04197 
04198          /* Interface_Body_Blk stuff is counted during interface collapse. */
04199 
04200          num_of_derived_types   += num_module_derived_types;
04201       }
04202 
04203       num_module_derived_types  = 0;
04204 
04205       BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX) = 
04206                                 ML_BD_IDX(BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX));
04207 
04208       for (new_name_idx = SCP_LN_FW_IDX(curr_scp_idx) + 1;
04209            new_name_idx < SCP_LN_LW_IDX(curr_scp_idx); new_name_idx++) {
04210          LN_ATTR_IDX(new_name_idx) = ML_AT_IDX(LN_ATTR_IDX(new_name_idx));
04211          LN_NAME_IDX(new_name_idx) = AT_NAME_IDX(LN_ATTR_IDX(new_name_idx));
04212          LN_NAME_LEN(new_name_idx) = AT_NAME_LEN(LN_ATTR_IDX(new_name_idx));
04213       }
04214 
04215 EXIT:
04216       ATP_SCP_ALIVE(module_attr_idx)    = FALSE;
04217       if (!error_break) {
04218         ro_idx = ATP_USE_LIST(module_attr_idx);
04219         while (ro_idx!=NULL_IDX) {
04220           RO_NAME_ATTR(ro_idx)= ML_AT_IDX(RO_NAME_ATTR(ro_idx));
04221           ro_idx =  RO_NEXT_IDX(ro_idx);
04222         }  
04223       }
04224       TBL_FREE(mod_link_tbl);
04225    }
04226 
04227    al_idx       = interface_list;
04228 
04229    while (al_idx != NULL_IDX) {
04230       attr_idx          = AL_ATTR_IDX(al_idx);
04231       host_attr_idx     = srch_host_sym_tbl(AT_OBJ_NAME_PTR(attr_idx),
04232                                             AT_NAME_LEN(attr_idx),
04233                                             &host_name_idx,
04234                                             TRUE);
04235 
04236       if (host_attr_idx != NULL_IDX &&
04237           !AT_NOT_VISIBLE(host_attr_idx) &&
04238            AT_OBJ_CLASS(host_attr_idx) == Interface) {
04239 
04240          /* Found this in a host scope.  Just concatenate the */
04241          /* hosted one following the new one from the module. */
04242          /* Based on concatenation rules we do not check for  */
04243          /* duplicates.  Duplicates should get errors.        */
04244          /* Duplicates that are actually from the same module */
04245          /* are ignored during semantic checking of the block.*/
04246 
04247          new_sn_idx     = ATI_FIRST_SPECIFIC_IDX(attr_idx);
04248 
04249          while (SN_SIBLING_LINK(new_sn_idx) != NULL_IDX) {
04250             new_sn_idx  = SN_SIBLING_LINK(new_sn_idx);
04251          }
04252 
04253          SN_SIBLING_LINK(new_sn_idx) = ATI_FIRST_SPECIFIC_IDX(host_attr_idx);
04254          ATI_NUM_SPECIFICS(attr_idx) = ATI_NUM_SPECIFICS(attr_idx) +
04255                                        ATI_NUM_SPECIFICS(host_attr_idx); 
04256       }
04257       al_idx    = AL_NEXT_IDX(al_idx);
04258    }
04259 
04260    al_idx = SCP_USED_MODULE_LIST(curr_scp_idx);
04261 
04262    while (al_idx != NULL_IDX) {
04263 
04264       if (ATP_INDIRECT_MODULE(AL_ATTR_IDX(al_idx))) {
04265          ADD_ATTR_TO_LOCAL_LIST(AL_ATTR_IDX(al_idx));
04266       }
04267       al_idx    = AL_NEXT_IDX(al_idx);
04268    }
04269 
04270    free_attr_list(interface_list);
04271    free_attr_list(attr_list_free_list);
04272    free_attr_list(SCP_USED_MODULE_LIST(curr_scp_idx));
04273 
04274    SCP_USED_MODULE_LIST(curr_scp_idx)   = NULL_IDX;
04275 
04276 /* TBL_FREE(rename_only_tbl); */
04277 
04278    keep_module_procs                    = FALSE;
04279 
04280    TRACE (Func_Exit, "use_stmt_semantics", NULL);
04281 
04282    return;
04283 
04284 }   /* use_stmt_semantics */
04285 
04286 /******************************************************************************\
04287 |*                                                                            *|
04288 |* Description:                                                               *|
04289 |*      This routine processes the rename only list.  It checks to make sure  *|
04290 |*      all the specified names are in the incoming module and marks them if  *|
04291 |*      they are specified in an ONLY list.  If they are renamed, it adds a   *|
04292 |*      new entry for the new name to the incoming local name table.          *|
04293 |*                                                                            *|
04294 |* Input parameters:                                                          *|
04295 |*      module_attr_idx -> The module being processed.                        *|
04296 |*                                                                            *|
04297 |* Output parameters:                                                         *|
04298 |*      NONE                                                                  *|
04299 |*                                                                            *|
04300 |* Returns:                                                                   *|
04301 |*      NOTHING                                                               *|
04302 |*                                                                            *|
04303 \******************************************************************************/
04304 static  boolean rename_only_semantics(int       module_attr_idx,
04305                                       boolean   use_only)
04306 {
04307    int           attr_idx;
04308    int           begin_idx;
04309    int           cif_symbol_id=0;
04310    int           end_idx;
04311    int           func_idx;
04312    boolean       has_renames            = FALSE;
04313    int           i;
04314    int           idx;
04315    int           length;
04316    int           ln_idx;
04317    int           match;
04318    int           name_idx=0;
04319    int           new_attr_idx;
04320    int           new_name_idx;
04321    int           np_idx;
04322    int           rename_idx;
04323    int           ro_idx;
04324 
04325 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
04326    long         *name_tbl_base;         /* name table base address */
04327 # endif
04328 
04329 
04330    TRACE (Func_Entry, "rename_only_semantics", NULL);
04331 
04332    ro_idx       = ATP_USE_LIST(module_attr_idx);
04333    ln_idx       = loc_name_tbl_idx - MD_NUM_ENTRIES(Loc_Name_Tbl) + 1;
04334    begin_idx    = SCP_LN_FW_IDX(curr_scp_idx);
04335    end_idx      = SCP_LN_LW_IDX(curr_scp_idx);
04336 
04337    /* Add a word for the all 1's word for table searches.  A word  */
04338    /* was left for the all 0's word, when the modules was read in. */
04339 
04340    TBL_REALLOC_CK(loc_name_tbl, 1);
04341 
04342    /* Set the current scope to the incoming local name table. */
04343 
04344    SCP_LN_FW_IDX(curr_scp_idx)          = ln_idx - 1;
04345    SCP_LN_LW_IDX(curr_scp_idx)          = loc_name_tbl_idx;
04346    loc_name_tbl[ln_idx-1]               = loc_name_tbl[begin_idx];
04347    loc_name_tbl[loc_name_tbl_idx]       = loc_name_tbl[end_idx];
04348 
04349    while (ro_idx != NULL_IDX) {
04350       rename_idx        = RO_RENAME_IDX(ro_idx);
04351       attr_idx          = NULL_IDX;
04352    
04353       /* This WHILE finds the specified name in the local */
04354       /* name table of the module being read in.          */
04355 
04356       for (;;) {
04357 
04358          if (ln_idx >= loc_name_tbl_idx) {
04359 
04360             /* The name in the ONLY/rename list is larger than the last */
04361             /* name in the USEd module list.  This means it won't be    */
04362             /* found.  Set match to not found and take the error path.  */
04363 
04364             ln_idx = loc_name_tbl_idx;
04365             match  = -1;
04366             break;
04367          }
04368 
04369          match = compare_names(RO_NAME_LONG(ro_idx),
04370                                RO_NAME_LEN(ro_idx),
04371                                LN_NAME_LONG(ln_idx),
04372                                LN_NAME_LEN(ln_idx));
04373 
04374          if (match > 0) {
04375 
04376             /* The name in the ONLY/rename list is larger than the name */
04377             /* in the USEd module list.  Clear ML_AT_LN_NAME in case    */
04378             /* this attr gets used indirectly. (ie:  It's a type attr.) */
04379             /* Keep looping and looking.                                */
04380 
04381             ML_AT_LN_NAME(LN_ATTR_IDX(ln_idx)) = !use_only;
04382 
04383             ln_idx++;
04384 
04385          } 
04386          else if (LN_NEW_NAME(ln_idx)) {
04387 
04388             /* This is a new name added during this while processing    */
04389             /* from a rename list.  Keep looping and looking.           */
04390 
04391             ln_idx++;
04392          } 
04393          else {
04394             break;
04395          } 
04396       }  /* end for - match is always <= 0 */ 
04397 
04398 
04399       if (match == 0) {  /* Found the name in the module */
04400          attr_idx       = LN_ATTR_IDX(ln_idx);
04401          name_idx       = ln_idx;
04402          RO_NAME_ATTR(ro_idx) = attr_idx;  
04403 
04404          /* If the name is a USE'd module, then the name was NOT found.    */
04405          /* We keep any USE'd modules in the attribute table for           */
04406          /* bookkeeping purposes, but the module name cannot be specified  */
04407          /* on a rename or ONLY list.                                      */
04408 
04409          if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
04410              ATP_PGM_UNIT(attr_idx) == Module) {
04411              match = -1;
04412          }
04413       }
04414          
04415       if (match < 0) {  /* Didn't find the name in the module */
04416          name_idx       = ln_idx;
04417 
04418          if (attr_idx != NULL_IDX) {  /* Module name */
04419             AT_DCL_ERR(attr_idx)        = TRUE;
04420 
04421             if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
04422                 ATP_PGM_UNIT(attr_idx) == Module && ATP_SCP_ALIVE(attr_idx)) {
04423 
04424                /* Cannot specify the module name in a rename only list     */
04425                /* Continue to the next item in the ro list.  If we renamed */
04426                /* the current module, it would just cause problems.        */
04427 
04428                PRINTMSG(RO_LINE_NUM(ro_idx), 1098, Error,
04429                         RO_COLUMN_NUM(ro_idx),
04430                         RO_NAME_PTR(ro_idx));
04431                ro_idx   = RO_NEXT_IDX(ro_idx);
04432                continue;
04433             }
04434             else {
04435                PRINTMSG(RO_LINE_NUM(ro_idx), 732, Error,
04436                         RO_COLUMN_NUM(ro_idx),
04437                         RO_NAME_PTR(ro_idx),
04438                         AT_OBJ_NAME_PTR(module_attr_idx));
04439 
04440 
04441                /* This module is a hidden module.  (indirectly used.)     */
04442                /* Make a new attr for the rename name for error recovery. */
04443 
04444                NTR_ATTR_TBL(attr_idx);
04445 
04446                idx      = attr_tbl_idx;
04447 
04448                if (idx > mod_link_tbl_idx) {
04449                   length = idx - mod_link_tbl_idx;
04450                   idx    = mod_link_tbl_idx + 1;
04451                   TBL_REALLOC_CK(mod_link_tbl, length);
04452 
04453                   for (; idx <= mod_link_tbl_idx; idx++) {
04454                      CLEAR_TBL_NTRY(mod_link_tbl, idx);
04455                   }
04456                }
04457 
04458                ML_AT_LN_NAME(attr_idx)          = TRUE;
04459                AT_DCL_ERR(attr_idx)             = TRUE;
04460                AT_NAME_IDX(attr_idx)            = RO_NAME_IDX(ro_idx);
04461                AT_NAME_LEN(attr_idx)            = RO_NAME_LEN(ro_idx);
04462                AT_ORIG_NAME_IDX(attr_idx)       = RO_NAME_IDX(ro_idx);
04463                AT_ORIG_NAME_LEN(attr_idx)       = RO_NAME_LEN(ro_idx);
04464 
04465                /* Need to set this as USE ASSOCIATED from the module */
04466                /* to prevent bad error recovery problems.            */
04467 
04468                AT_USE_ASSOCIATED(attr_idx)      = TRUE;
04469                AT_MODULE_IDX(attr_idx)          = module_attr_idx;
04470 
04471                /* Give it an intrinsic type */
04472 
04473                SET_IMPL_TYPE(attr_idx);
04474             }
04475          }
04476          else {
04477             PRINTMSG(RO_LINE_NUM(ro_idx), 732, Error,
04478                      RO_COLUMN_NUM(ro_idx),
04479                      RO_NAME_PTR(ro_idx),
04480                      AT_OBJ_NAME_PTR(module_attr_idx));
04481 
04482             NTR_NAME_POOL(RO_NAME_LONG(ro_idx),
04483                           RO_NAME_LEN(ro_idx),
04484                           np_idx);
04485 
04486             /* Make an error entry into the local name table. */
04487 
04488             TBL_REALLOC_CK(loc_name_tbl, 1);
04489 
04490             /* Adding to local name table for last (most recent) scope.  No   */
04491             /* adjusting of other scope local name table entries is necessary.*/
04492 
04493             SCP_LN_LW_IDX(curr_scp_idx) = loc_name_tbl_idx;
04494 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
04495             name_tbl_base               = (long *) loc_name_tbl;
04496 # endif
04497 
04498             for (i = loc_name_tbl_idx; i >= name_idx; i--) {
04499 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
04500                name_tbl_base [i] = name_tbl_base [i-1];
04501 # else
04502                loc_name_tbl [i]  = loc_name_tbl [i-1];
04503 # endif
04504             }
04505 
04506             NTR_ATTR_TBL(attr_idx);
04507 
04508             idx = (attr_tbl_idx > name_pool_idx) ? attr_tbl_idx : name_pool_idx;
04509 
04510             if (idx > mod_link_tbl_idx) {
04511                length = idx - mod_link_tbl_idx;
04512                idx    = mod_link_tbl_idx + 1;
04513                TBL_REALLOC_CK(mod_link_tbl, length);
04514 
04515                for (; idx <= mod_link_tbl_idx; idx++) {
04516                   CLEAR_TBL_NTRY(mod_link_tbl, idx);
04517                }
04518             }
04519 
04520             ML_AT_LN_NAME(attr_idx)     = TRUE;
04521             LN_ATTR_IDX(name_idx)       = attr_idx;
04522             LN_NAME_IDX(name_idx)       = np_idx;
04523             LN_NAME_LEN(name_idx)       = RO_NAME_LEN(ro_idx);
04524             AT_DCL_ERR(attr_idx)        = TRUE;
04525             AT_NAME_IDX(attr_idx)       = np_idx;
04526             AT_NAME_LEN(attr_idx)       = RO_NAME_LEN(ro_idx);
04527             AT_ORIG_NAME_IDX(attr_idx)  = np_idx;
04528             AT_ORIG_NAME_LEN(attr_idx)  = RO_NAME_LEN(ro_idx);
04529 
04530             /* Need to set this as USE ASSOCIATED from the module */
04531             /* to prevent bad error recovery problems.            */
04532 
04533             AT_USE_ASSOCIATED(attr_idx) = TRUE;
04534             AT_MODULE_IDX(attr_idx)     = module_attr_idx;
04535 
04536             /* Give it an intrinsic type */
04537 
04538             SET_IMPL_TYPE(attr_idx);
04539          }
04540       }
04541 
04542       if (cif_flags & BASIC_RECS) {
04543 
04544          if (!LN_RENAMED(name_idx) && !LN_IN_ONLY_LIST(name_idx)) {
04545 
04546             /* The RO records are alphabetized by name.  If this name has  */
04547             /* been seen in an ONLY list or RENAMED, it already has a CIF  */
04548             /* symbol id, otherwise it needs a new symbol id.  Pass 0 as   */
04549             /* the symbol id, so cif_rename_rec will generate a new symbol */
04550             /* id.                                                        */
04551 
04552             cif_symbol_id = 0;
04553          }
04554       }
04555 
04556 
04557       if (rename_idx == NULL_IDX) {  /* ONLY without a renames. */
04558 
04559          if (LN_RENAMED(name_idx)) {
04560 
04561             /* This has been renamed already.  There are two local name  */
04562             /* entries that point to the same attr.  The original name   */
04563             /* and the renamed name.  Copy the attr entry so that the    */
04564             /* renamed local name gets its own attr.  Need to set        */
04565             /* ATD_EQUIV on both attr entries, because there are now two */
04566             /* objects with different name.  They are effectively        */
04567             /* equivalenced.  Need to reset the name on the attr.  It    */
04568             /* It is set to the new name.                                */
04569 
04570             /* before:                                                   */
04571             /*   name from module => old_attr     (input from module)    */
04572             /*   new_name         => old_attr     (RENAME specified)     */
04573             /* after:                                                    */
04574             /*   name from module => new_attr     (ONLY specified)       */
04575             /*   new_name         => old_attr     (RENAME specified)     */
04576 
04577             NTR_ATTR_TBL(new_attr_idx);
04578 
04579             if (attr_tbl_idx > mod_link_tbl_idx) {
04580                length = attr_tbl_idx - mod_link_tbl_idx;
04581                idx    = mod_link_tbl_idx + 1;
04582                TBL_REALLOC_CK(mod_link_tbl, length);
04583 
04584                for (; idx <= mod_link_tbl_idx; idx++) {
04585                   CLEAR_TBL_NTRY(mod_link_tbl, idx);
04586                }
04587             }
04588 
04589             if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
04590                ATD_EQUIV(attr_idx)              = TRUE;
04591             }
04592 
04593             COPY_ATTR_NTRY(new_attr_idx, attr_idx);
04594             AT_CIF_SYMBOL_ID(new_attr_idx)      = 0;
04595             AT_NAME_IDX(new_attr_idx)           = LN_NAME_IDX(name_idx);
04596             AT_NAME_LEN(new_attr_idx)           = LN_NAME_LEN(name_idx);
04597             attr_idx                            = new_attr_idx;
04598             LN_ATTR_IDX(name_idx)               = attr_idx;
04599             ML_AT_LN_NAME(attr_idx)             = TRUE;
04600          }
04601 
04602          LN_IN_ONLY_LIST(name_idx)      = TRUE;
04603          AT_DEF_LINE(attr_idx)          = RO_LINE_NUM(ro_idx);
04604          AT_DEF_COLUMN(attr_idx)        = RO_COLUMN_NUM(ro_idx);
04605 
04606          if ((cif_flags & XREF_RECS) != 0) {  /* Only */
04607             cif_usage_rec(attr_idx,
04608                           AT_Tbl_Idx,
04609                           RO_LINE_NUM(ro_idx),
04610                           RO_COLUMN_NUM(ro_idx),
04611                           CIF_Symbol_Reference);
04612          }
04613       }
04614       else { /* Put new name into incoming symbol table. */
04615          has_renames    = TRUE;
04616 
04617          if (RO_DUPLICATE_RENAME(rename_idx) &&
04618              AT_OBJ_CLASS(attr_idx) != Interface) {
04619 
04620             /* This rename name has been specified twice in the rename list */
04621 
04622             PRINTMSG(RO_LINE_NUM(rename_idx), 1015, Error,
04623                      RO_COLUMN_NUM(rename_idx),
04624                      RO_NAME_PTR(rename_idx));
04625          }
04626 
04627          if (LN_RENAMED(name_idx) || LN_IN_ONLY_LIST(name_idx)) {
04628 
04629             /* This has been renamed or specified in an ONLY list already.   */
04630             /* Need a new attr entry.  If this is renamed there are two      */
04631             /* local entries pointing to the same attr.  (See comment above).*/
04632             /* If this is specified in an ONLY list we need to make a new    */
04633             /* local name/attr combination because of the different name.    */
04634 
04635             NTR_ATTR_TBL(new_attr_idx);
04636 
04637             if (attr_tbl_idx > mod_link_tbl_idx) {
04638                length = attr_tbl_idx - mod_link_tbl_idx;
04639                idx    = mod_link_tbl_idx + 1;
04640                TBL_REALLOC_CK(mod_link_tbl, length);
04641 
04642                for (; idx <= mod_link_tbl_idx; idx++) {
04643                   CLEAR_TBL_NTRY(mod_link_tbl, idx);
04644                }
04645             }
04646 
04647             if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
04648                ATD_EQUIV(attr_idx)      = TRUE;
04649             }
04650             COPY_ATTR_NTRY(new_attr_idx, attr_idx);
04651             attr_idx                    = new_attr_idx;
04652             AT_CIF_SYMBOL_ID(attr_idx)  = 0;
04653          }
04654 
04655          LN_RENAMED(name_idx)           = TRUE;
04656          ML_AT_LN_NAME(attr_idx)        = TRUE;
04657 
04658          /* The current scopes SCP_LN_FW_IDX and SCP_LN_LW_IDX have been */
04659          /* set to point to the new scope.  It may not be NULL, but that */
04660          /* is okay.  We are just looking for a place to put the name.   */
04661 
04662          new_attr_idx   = srch_sym_tbl(RO_NAME_PTR(rename_idx),
04663                                        RO_NAME_LEN(rename_idx),
04664                                        &new_name_idx);
04665 
04666          TBL_REALLOC_CK(loc_name_tbl, 1);
04667 
04668          if (loc_name_tbl_idx > mod_link_tbl_idx) {
04669             length = loc_name_tbl_idx - mod_link_tbl_idx;
04670             idx    = mod_link_tbl_idx + 1;
04671             TBL_REALLOC_CK(mod_link_tbl, length);
04672 
04673             for (; idx <= mod_link_tbl_idx; idx++) {
04674                CLEAR_TBL_NTRY(mod_link_tbl, idx);
04675             }
04676          }
04677 
04678          /* Adding to local name table for last (most recent) scope.  No   */
04679          /* adjusting of other scope local name table entries is necessary.*/
04680 
04681          SCP_LN_LW_IDX(curr_scp_idx)    = loc_name_tbl_idx;
04682 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
04683          name_tbl_base                  = (long *) loc_name_tbl;
04684 # endif
04685 
04686          for (i = loc_name_tbl_idx; i >= new_name_idx; i--) {
04687 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
04688             name_tbl_base [i] = name_tbl_base [i-1];
04689 # else
04690             loc_name_tbl [i]  = loc_name_tbl [i-1];
04691 # endif
04692          }
04693 
04694          /* Adjust ln_idx from the match loop.  ln_idx is used to search */
04695          /* through this local name table.  Members of the table have    */
04696          /* just shifted, so ln_idx must shift as well.                  */
04697 
04698          if (new_name_idx < ln_idx) {
04699             ln_idx++;
04700          }
04701 
04702          LN_ATTR_IDX(new_name_idx)      = attr_idx;
04703          LN_NAME_IDX(new_name_idx)      = RO_NAME_IDX(rename_idx);
04704          LN_NAME_LEN(new_name_idx)      = RO_NAME_LEN(rename_idx);
04705          LN_DEF_LOC(new_name_idx)       = TRUE;
04706          LN_NEW_NAME(new_name_idx)      = TRUE;
04707          LN_RENAMED(new_name_idx)       = FALSE;
04708          AT_DEF_LINE(attr_idx)          = RO_LINE_NUM(rename_idx);
04709          AT_DEF_COLUMN(attr_idx)        = RO_COLUMN_NUM(rename_idx);
04710 
04711          RO_NAME_ATTR(ro_idx) = LN_ATTR_IDX(new_name_idx);
04712 
04713          if (cif_flags & BASIC_RECS) {
04714             cif_symbol_id = cif_rename_rec(ro_idx,
04715                                            cif_symbol_id,
04716                                            attr_idx,
04717                                            module_attr_idx);
04718 
04719             if ((cif_flags & XREF_RECS) != 0) {
04720                cif_usage_rec(cif_symbol_id,
04721                              NO_Tbl_Idx,
04722                              RO_LINE_NUM(ro_idx),
04723                              RO_COLUMN_NUM(ro_idx),
04724                              CIF_Symbol_Reference);
04725 
04726                cif_usage_rec(attr_idx,
04727                              AT_Tbl_Idx,
04728                              RO_LINE_NUM(rename_idx),
04729                              RO_COLUMN_NUM(rename_idx),
04730                              CIF_Symbol_Declaration);
04731             }
04732          }
04733 
04734          AT_NAME_IDX(attr_idx)          = LN_NAME_IDX(new_name_idx);
04735          AT_NAME_LEN(attr_idx)          = LN_NAME_LEN(new_name_idx);
04736          AT_ORIG_MODULE_IDX(attr_idx)   = module_attr_idx;
04737 
04738          if (AT_OBJ_CLASS(attr_idx) == Interface ||
04739              AT_OBJ_CLASS(attr_idx) == Pgm_Unit) {
04740             func_idx    = attr_idx;
04741 
04742             if (AT_OBJ_CLASS(func_idx) == Interface &&
04743                 ATI_PROC_IDX(func_idx) != NULL_IDX) {
04744                func_idx                 = ATI_PROC_IDX(func_idx);
04745                AT_NAME_IDX(func_idx)    = LN_NAME_IDX(new_name_idx);
04746                AT_NAME_LEN(func_idx)    = LN_NAME_LEN(new_name_idx);
04747                AT_DEF_LINE(func_idx)    = AT_DEF_LINE(attr_idx);
04748                AT_DEF_COLUMN(func_idx)  = AT_DEF_COLUMN(attr_idx);
04749             }
04750 
04751             if (AT_OBJ_CLASS(func_idx) == Pgm_Unit &&
04752                 !ATP_RSLT_NAME(func_idx) &&
04753                 ATP_PGM_UNIT(func_idx) != Module &&
04754                 ATP_RSLT_IDX(func_idx) != NULL_IDX) {
04755                func_idx                 = ATP_RSLT_IDX(func_idx);
04756                AT_NAME_IDX(func_idx)    = LN_NAME_IDX(new_name_idx);
04757                AT_NAME_LEN(func_idx)    = LN_NAME_LEN(new_name_idx);
04758                AT_DEF_LINE(func_idx)    = AT_DEF_LINE(attr_idx);
04759                AT_DEF_COLUMN(func_idx)  = AT_DEF_COLUMN(attr_idx);
04760             }
04761          }
04762          else if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
04763                   ATD_CLASS(attr_idx) == Constant &&
04764                   ATD_FLD(attr_idx) == AT_Tbl_Idx) {
04765             AT_NAME_IDX(ATD_CONST_IDX(attr_idx)) = LN_NAME_IDX(new_name_idx);
04766             AT_NAME_LEN(ATD_CONST_IDX(attr_idx)) = LN_NAME_LEN(new_name_idx);
04767          }
04768       }
04769       ro_idx                    = RO_NEXT_IDX(ro_idx);
04770    }
04771 
04772    SCP_LN_FW_IDX(curr_scp_idx)  = begin_idx;
04773    SCP_LN_LW_IDX(curr_scp_idx)  = end_idx;
04774    loc_name_tbl_idx--;          /* Don't need all ones entry anymore */
04775 
04776    TRACE (Func_Exit, "rename_only_semantics", NULL);
04777 
04778    return(has_renames);
04779 
04780 }   /* rename_only_semantics */
04781 
04782 /******************************************************************************\
04783 |*                                                                            *|
04784 |* Description:                                                               *|
04785 |*      Open and search the input file looking for a module info table.       *|
04786 |*                                                                            *|
04787 |* Input parameters:                                                          *|
04788 |*      NONE                                                                  *|
04789 |*                                                                            *|
04790 |* Output parameters:                                                         *|
04791 |*      NONE                                                                  *|
04792 |*                                                                            *|
04793 |* Returns:                                                                   *|
04794 |*      TRUE if program unit is found.                                        *|
04795 |*                                                                            *|
04796 \******************************************************************************/
04797 boolean find_prog_unit_tbl(int  module_attr_idx)
04798 
04799 {
04800    boolean      archive;
04801    char         ar_string[SARMAG];
04802    boolean      found           = FALSE;
04803    char         file_name[40];
04804    char        *file_name_ptr;
04805    int          fn_length;
04806    int          fp_file_idx;
04807    int          fp_module_idx;
04808    int          ga_idx;
04809    FILE        *mod_file_ptr;
04810    int          name_idx;
04811    int          next_fp_module_idx;
04812    int          num_recs_read;
04813    boolean      save_keep_module_procs;
04814 
04815 
04816    TRACE (Func_Entry, "find_prog_unit_tbl", NULL);
04817 
04818    alternate_entry              = FALSE;
04819    save_keep_module_procs       = keep_module_procs;
04820 
04821    if (ATP_PGM_UNIT(module_attr_idx) == Module) {
04822       inline_search     = FALSE;
04823    }
04824    else if (ATP_PROC(module_attr_idx) == Module_Proc ||
04825             ATP_PROC(module_attr_idx) == Intern_Proc) {
04826 
04827       /* Don't waste time searching for these.  The Intern_Proc would */
04828       /* be an internal error situation and the module_proc is not    */
04829       /* available because the module was not compiled with modinline */
04830 
04831       goto DONE;
04832    }
04833    else {
04834       inline_search     = TRUE;
04835    }
04836 
04837    /* Finding the module shortcut:  Once we see a module or write out */
04838    /* a module, we retain the information as to file name and offset  */
04839    /* into file, so that we can quickly find it again.  We search the */
04840    /* global name table to find the module and then see if we have    */
04841    /* file information about it.                                      */
04842 
04843    if (srch_global_name_tbl(AT_OBJ_NAME_PTR(module_attr_idx),
04844                             AT_NAME_LEN(module_attr_idx),
04845                             &name_idx)) {
04846       ga_idx    = GN_ATTR_IDX(name_idx);
04847 
04848       if (GA_OBJ_CLASS(ga_idx) == Common_Block) {
04849          ga_idx = GAC_PGM_UNIT_IDX(ga_idx);
04850       }
04851 
04852       if (ga_idx != NULL_IDX && GAP_FP_IDX(ga_idx) != NULL_IDX) {
04853 
04854          /* The file and the position in that file for this module are known */
04855          /* already, so just open the file and seek to that position.        */
04856 
04857          fp_module_idx  = GAP_FP_IDX(ga_idx);
04858          fp_file_idx    = FP_FILE_IDX(fp_module_idx);
04859          mod_file_ptr   = open_module_file(module_attr_idx,fp_file_idx);
04860          found          = (mod_file_ptr == NULL) ? FALSE :
04861                                         read_module_tbl_header(module_attr_idx,
04862                                                                fp_module_idx,
04863                                                                mod_file_ptr);
04864 
04865          if (found) {
04866             ATP_IN_CURRENT_COMPILE(module_attr_idx) = 
04867                            FP_CLASS(fp_module_idx) == Current_Compile_Fp;
04868             goto FOUND;
04869          }
04870          else {
04871 
04872             /* There's a potential file problem here.  If this is supposed */
04873             /* to be in the current compilation, issue a LIMIT.  Something */
04874             /* is wrong.  Otherwise issue a not found error.  We could get */
04875             /* fancy and redo the search again.  Maybe later.  (KAY)       */
04876 
04877             if (FP_CLASS(fp_module_idx) == Current_Compile_Fp &&
04878                 !inline_search) {
04879                PRINTMSG(AT_DEF_LINE(module_attr_idx), 1249, Limit,
04880                         AT_DEF_COLUMN(module_attr_idx),
04881                         AT_OBJ_NAME_PTR(module_attr_idx));
04882             }
04883             else {
04884                goto ERROR;
04885             }
04886          }
04887       }
04888       else if (ATP_PGM_UNIT(module_attr_idx) == GAP_PGM_UNIT(ga_idx) && 
04889                ATP_PGM_UNIT(module_attr_idx) == Module &&
04890                !inline_search && GA_DEFINED(GN_ATTR_IDX(name_idx))) {
04891  
04892          /* Found this name in the global name table.  Check to see if it */
04893          /* is defined.  If so, there must have been scoping problems or  */
04894          /* errors (if not a MODULE), so no program unit was written out. */
04895 
04896          goto ERROR;
04897       }
04898    }
04899 
04900    fp_file_idx = (inline_search) ? inline_path_idx : module_path_idx;
04901 
04902    if (on_off_flags.module_to_mod && !inline_search) {
04903       strcpy(file_name, AT_OBJ_NAME_PTR(module_attr_idx));
04904       fn_length                 = AT_NAME_LEN(module_attr_idx);
04905       file_name[fn_length++]    = '.';
04906       file_name[fn_length++]    = 'm';
04907       file_name[fn_length++]    = 'o';
04908       file_name[fn_length++]    = 'd';
04909    }
04910    else {
04911       fn_length                 = 0;
04912    }
04913    file_name[fn_length] = '\0';
04914 
04915    while (fp_file_idx != NULL_IDX) {
04916       fp_module_idx             = NULL_IDX;
04917       next_fp_module_idx        = FP_MODULE_IDX(fp_file_idx); /* 1st module */
04918 
04919       while (next_fp_module_idx != NULL_IDX) {
04920          fp_module_idx          = next_fp_module_idx;
04921          next_fp_module_idx     = FP_MODULE_IDX(fp_module_idx);
04922 
04923          if (compare_names(AT_OBJ_NAME_LONG(module_attr_idx),
04924                            AT_NAME_LEN(module_attr_idx),
04925                            FP_NAME_LONG(fp_module_idx),
04926                            FP_NAME_LEN(fp_module_idx)) == 0) {
04927 
04928             /* Found the matching module.  Open the file and read header. */
04929 
04930             mod_file_ptr = open_module_file(module_attr_idx,
04931                                             fp_file_idx);
04932             
04933 
04934             found = (mod_file_ptr == NULL) ?
04935                      FALSE : read_module_tbl_header(module_attr_idx,
04936                                                     fp_module_idx,
04937                                                     mod_file_ptr);
04938             goto FOUND;
04939          }
04940       }  /* End while - looking through module names in same file. */
04941 
04942       if (FP_SRCH_THE_FILE(fp_file_idx)) {
04943 
04944          /* All files specified on the commandline will come through as  */
04945          /* Unknown_Fp.  Here is where we determine what they are.       */
04946 
04947          if (FP_CLASS(fp_file_idx) == Unknown_Fp) {
04948 
04949             /* Determine if this is a directory or a file.  */
04950             /* If directory, convert to list of files.   If */
04951             /* file, they will be marked as Elf files if on */
04952             /* solaris and as regular files if not solaris. */
04953 
04954             find_files_in_directory(fp_file_idx);
04955 
04956             if (FP_CLASS(fp_file_idx) == Directory_Fp) {
04957 
04958                /* Skip the directory and go the next file or dir in the    */
04959                /* file path table.  This is most likely a file specified   */
04960                /* in the directory, but if the directory is empty, then    */
04961                /* this is the file or dir following the directory.         */
04962 
04963                fp_file_idx      = FP_NEXT_FILE_IDX(fp_file_idx);
04964                continue;
04965             }
04966          }
04967 
04968 # if defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
04969 
04970          if (FP_CLASS(fp_file_idx) == Elf_File_Fp ||
04971              FP_CLASS(fp_file_idx) == Unknown_Fp) {
04972 
04973             if (srch_elf_file_for_module_tbl(module_attr_idx, fp_file_idx)) {
04974                found    = TRUE;
04975                goto FOUND;
04976             }
04977 
04978             /* Either this is not an elf file, or we really didn't find it. */
04979             /* If this is an Elf file, it will be marked as such by routine */
04980             /* srch_elf_file_for_module_tbl.                                */
04981 
04982          }
04983 # endif
04984 
04985          switch (FP_CLASS(fp_file_idx)) {
04986          case Mod_File_Fp:
04987 
04988             if (on_off_flags.module_to_mod && !inline_search) {
04989                file_name_ptr = NULL;
04990                file_name_ptr = strrchr(FP_NAME_PTR(fp_file_idx), SLASH);
04991 
04992                if (file_name_ptr == NULL) {  /* No path before name */
04993                   file_name_ptr = FP_NAME_PTR(fp_file_idx);
04994                }
04995                else {
04996                   ++file_name_ptr;  /* Skip slash */
04997                }
04998 
04999                if (strncmp(file_name, file_name_ptr, fn_length) == 0) {
05000 
05001                   /* Found file_name.mod */
05002 
05003                   mod_file_ptr = open_module_file(module_attr_idx, fp_file_idx);
05004 
05005                   if (mod_file_ptr == NULL) {       /* Not able to open file. */
05006                      continue;                      /* Try the next file.     */
05007                   }
05008 
05009                   if (srch_for_module_tbl(module_attr_idx,
05010                                           &fp_module_idx,
05011                                           fp_file_idx,
05012                                           0,
05013                                           mod_file_ptr)) {
05014                      found      = TRUE;
05015                      goto FOUND;
05016                   }
05017                }
05018             }
05019             break;
05020 
05021          case File_Fp:
05022          case Archive_File_Fp:
05023          case Unknown_Fp:         /* Look for modules in the Non-Elf files. */
05024 
05025             mod_file_ptr = open_module_file(module_attr_idx, fp_file_idx);
05026 
05027             if (mod_file_ptr == NULL) {       /* Not able to open file. */
05028                continue;                      /* Try the next file.     */
05029             }
05030 
05031             if (FP_OFFSET(fp_file_idx) > 0) {
05032 
05033                /* Assume this must be set to File_Fp or Archive_Fp.   */
05034 
05035                archive = (FP_CLASS(fp_file_idx) == Archive_File_Fp);
05036             }
05037             else {  /* we don't know what kind of file this is yet. */
05038 
05039                for (num_recs_read = 0; num_recs_read < SARMAG; num_recs_read++){
05040                   ar_string[num_recs_read] = '\n';
05041                }
05042 
05043                num_recs_read = fread((char *) ar_string, 
05044                                      sizeof(char),
05045                                      (size_t) SARMAG, 
05046                                      mod_file_ptr);
05047             
05048                if (num_recs_read == (size_t) SARMAG){
05049                    archive = (strncmp(ar_string, ARMAG, (size_t) SARMAG) == 0);
05050                }
05051                else {
05052                   archive = FALSE;
05053                }
05054 
05055                if (archive) {
05056                   FP_CLASS(fp_file_idx) = Archive_File_Fp;
05057                }
05058                else {
05059                   FP_CLASS(fp_file_idx) = File_Fp;
05060 
05061                   if (!FSEEK(mod_file_ptr, 0, SEEK_SET)) {
05062 
05063                      /* Reset to file start failed.  Skip to next file. */
05064 
05065                      fclose(mod_file_ptr);
05066                      fp_file_idx        = FP_NEXT_FILE_IDX(fp_file_idx);
05067                      continue;
05068                   }
05069                }
05070             }
05071 
05072             if (!archive) {
05073 
05074                if (FP_OFFSET(fp_file_idx) > 0 &&
05075                    !FSEEK(mod_file_ptr, FP_OFFSET(fp_file_idx), SEEK_CUR)) {
05076 
05077                   /* Seek failed.  Try the next file. */
05078 
05079                   fclose(mod_file_ptr);
05080                   fp_file_idx   = FP_NEXT_FILE_IDX(fp_file_idx);
05081                   continue; 
05082                }
05083 
05084                if (srch_for_module_tbl(module_attr_idx,
05085                                        &fp_module_idx,
05086                                        fp_file_idx,
05087                                        0,
05088                                        mod_file_ptr)) {
05089                   found = TRUE;
05090                   goto FOUND;
05091                }
05092             }
05093             else if (srch_ar_file_for_module_tbl(module_attr_idx,
05094                                                  &fp_module_idx,
05095                                                  fp_file_idx,
05096                                                  mod_file_ptr)) {
05097                found    = TRUE;
05098                goto FOUND;
05099             }
05100 
05101             fclose(mod_file_ptr);
05102             break;
05103 
05104          default:
05105             break;
05106 
05107          }  /* end switch */
05108       }
05109       fp_file_idx       = FP_NEXT_FILE_IDX(fp_file_idx);
05110    }
05111 
05112 ERROR:
05113 
05114    /* Program unit is not found.  If this is a MODULE, issue an error.  If   */
05115    /* If we're searching for a program unit for inlining, just return FALSE. */
05116 
05117    if (!AT_DCL_ERR(module_attr_idx) && !inline_search) {
05118       AT_DCL_ERR(module_attr_idx) = TRUE;
05119 
05120       if (compare_names(AT_OBJ_NAME_LONG(module_attr_idx),
05121                         AT_NAME_LEN(module_attr_idx),
05122                         AT_OBJ_NAME_LONG(SCP_ATTR_IDX(MAIN_SCP_IDX)),
05123                         AT_NAME_LEN(SCP_ATTR_IDX(MAIN_SCP_IDX))) == 0) {
05124 
05125          /* Trying to include the current module */
05126 
05127          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1027, Error,
05128                   AT_DEF_COLUMN(module_attr_idx),
05129                   AT_OBJ_NAME_PTR(module_attr_idx));
05130       }
05131       else {
05132          PRINTMSG(AT_DEF_LINE(module_attr_idx), 292, Error,
05133                   AT_DEF_COLUMN(module_attr_idx),
05134                   AT_OBJ_NAME_PTR(module_attr_idx));
05135       }
05136    }
05137 
05138    return(FALSE);
05139 
05140 FOUND:
05141 
05142    if (!inline_search && (cif_flags & BASIC_RECS)) {
05143       cif_use_module_rec(module_attr_idx,
05144                          fp_file_idx,
05145                          FALSE);
05146    }
05147 
05148    if (dump_flags.mod_version) {  /* Print out the module version */
05149 
05150       printf("Module %s is compiled with module version number %d. \n",
05151              AT_OBJ_NAME_PTR(module_attr_idx), MD_VERSION_NUM);
05152 
05153    }
05154 
05155    /* This module is in this compilation unit, but it has compile time errors.*/
05156    /* Issue a not found message - but read in the module for error recovery.  */
05157 
05158    if (MD_HAS_ERRORS) {
05159 
05160       if (!inline_search) {
05161          PRINTMSG(AT_DEF_LINE(module_attr_idx), 894, Error,
05162                   AT_DEF_COLUMN(module_attr_idx),
05163                   AT_OBJ_NAME_PTR(module_attr_idx));
05164          AT_DCL_ERR(module_attr_idx) = TRUE;
05165       }
05166       else {
05167          found = FALSE;
05168       }
05169    }
05170 
05171    if (MD_VERSION_NUM > MD_CURRENT_VERSION) {
05172       PRINTMSG(AT_DEF_LINE(module_attr_idx), 1181, Error,
05173                AT_DEF_COLUMN(module_attr_idx),
05174                FP_NAME_PTR(fp_file_idx));
05175       AT_DCL_ERR(module_attr_idx) = TRUE;
05176       found = FALSE;
05177    }
05178 
05179    if (MD_VERSION_NUM <= MD_LAST_3_0_VERSION) {
05180       PRINTMSG(AT_DEF_LINE(module_attr_idx), 1181, Error,
05181                AT_DEF_COLUMN(module_attr_idx),
05182                FP_NAME_PTR(fp_file_idx));
05183       AT_DCL_ERR(module_attr_idx) = TRUE;
05184       found = FALSE;
05185    }
05186    else if (MD_VERSION_NUM <= MD_LAST_4_0_VERSION) {
05187 
05188       /* Warning that this is an older module version and will not  */
05189       /* be supported in the following release.                     */
05190 
05191       PRINTMSG(AT_DEF_LINE(module_attr_idx), 1157, Warning,
05192                AT_DEF_COLUMN(module_attr_idx),
05193                FP_NAME_PTR(fp_file_idx));
05194    }
05195 
05196 
05197 #if defined(_HOST32) && defined(_TARGET64)
05198 
05199    if (MD_TARGET != target_os) {
05200 
05201       if (ATP_PGM_UNIT(module_attr_idx) == Module) {
05202          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1055, Error,
05203                   AT_DEF_COLUMN(module_attr_idx),
05204                   FP_NAME_PTR(fp_file_idx));
05205          AT_DCL_ERR(module_attr_idx) = TRUE;
05206          found = FALSE;
05207       }
05208       else {
05209          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1246, Error,
05210                   AT_DEF_COLUMN(module_attr_idx),
05211                   FP_NAME_PTR(fp_file_idx));
05212          AT_DCL_ERR(module_attr_idx) = TRUE;
05213          found = FALSE;
05214       }
05215    }
05216 # else
05217 
05218    if (MD_TARGET != target_os) {
05219 
05220       if (ATP_PGM_UNIT(module_attr_idx) == Module) {
05221          PRINTMSG(AT_DEF_LINE(module_attr_idx), 725, Error,
05222                   AT_DEF_COLUMN(module_attr_idx),
05223                   AT_OBJ_NAME_PTR(module_attr_idx));
05224          AT_DCL_ERR(module_attr_idx) = TRUE;
05225       }
05226       else {
05227          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1247, Error,
05228                   AT_DEF_COLUMN(module_attr_idx),
05229                   AT_OBJ_NAME_PTR(module_attr_idx));
05230          AT_DCL_ERR(module_attr_idx) = TRUE;
05231       }
05232    }
05233 # endif
05234 
05235    if (!FP_SYSTEM_FILE(fp_file_idx)) {
05236 
05237       if (MD_CF77TYPES != cmd_line_flags.s_cf77types) {
05238          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1248, Error,
05239                   AT_DEF_COLUMN(module_attr_idx),
05240                   AT_OBJ_NAME_PTR(module_attr_idx),
05241                   "-s i");
05242          AT_DCL_ERR(module_attr_idx) = TRUE;
05243       }
05244       else if (MD_DEFAULT32 != cmd_line_flags.s_default32) {
05245          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1248, Error,
05246                   AT_DEF_COLUMN(module_attr_idx),
05247                   AT_OBJ_NAME_PTR(module_attr_idx),
05248                   "-s default32");
05249          AT_DCL_ERR(module_attr_idx) = TRUE;
05250       }
05251       else if (MD_DEFAULT64 != cmd_line_flags.s_default64) {
05252          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1248, Error,
05253                   AT_DEF_COLUMN(module_attr_idx),
05254                   AT_OBJ_NAME_PTR(module_attr_idx),
05255                   "-s default64");
05256          AT_DCL_ERR(module_attr_idx) = TRUE;
05257       }
05258       else if (MD_FLOAT64 != cmd_line_flags.s_float64) {
05259          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1248, Error,
05260                   AT_DEF_COLUMN(module_attr_idx),
05261                   AT_OBJ_NAME_PTR(module_attr_idx),
05262                   "-s float64");
05263          AT_DCL_ERR(module_attr_idx) = TRUE;
05264       }
05265       else if (MD_DEFAULT_INTEGER_TYPE != INTEGER_DEFAULT_TYPE) {
05266          PRINTMSG(AT_DEF_LINE(module_attr_idx), 623, Error,
05267                   AT_DEF_COLUMN(module_attr_idx),
05268                   AT_OBJ_NAME_PTR(module_attr_idx));
05269          AT_DCL_ERR(module_attr_idx) = TRUE;
05270       }
05271 
05272       if (MD_ENABLE_DOUBLE_PRECISION != on_off_flags.enable_double_precision) {
05273          PRINTMSG(AT_DEF_LINE(module_attr_idx), 618, Error,
05274                   AT_DEF_COLUMN(module_attr_idx),
05275                   AT_OBJ_NAME_PTR(module_attr_idx));
05276          AT_DCL_ERR(module_attr_idx) = TRUE;
05277       }
05278 
05279 #if defined(_ACCEPT_CMD_a_dalign)
05280 
05281       if (MD_DALIGN != cmd_line_flags.dalign) {
05282          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1011, Error,
05283                   AT_DEF_COLUMN(module_attr_idx),
05284                   AT_OBJ_NAME_PTR(module_attr_idx));
05285          AT_DCL_ERR(module_attr_idx) = TRUE;
05286       }
05287 # endif
05288 
05289    }
05290 
05291    if (FP_CLASS(fp_file_idx) != Elf_File_Fp) {
05292 
05293       /* Elf files were read in during the elf search */
05294 
05295       if (found) {
05296          if (!read_in_module_tbl(fp_file_idx, 
05297                                  module_attr_idx, 
05298                                  mod_file_ptr, 
05299                                  NULL)) {
05300             found       = FALSE;
05301          }
05302       }
05303       fclose(mod_file_ptr);
05304    }
05305 
05306    if (ATP_PGM_UNIT(module_attr_idx) != Module) {
05307 
05308       if (found && AT_ATTR_LINK(module_attr_idx) != NULL_IDX) {
05309          ATP_FIRST_SH_IDX(module_attr_idx) = 
05310                           ATP_FIRST_SH_IDX(AT_ATTR_LINK(module_attr_idx));
05311       }
05312       else {
05313          found = FALSE;
05314       }
05315       TBL_FREE(mod_link_tbl);
05316    }
05317 
05318 DONE:
05319 
05320    alternate_entry      = FALSE;
05321    keep_module_procs    = save_keep_module_procs;
05322    inline_search        = FALSE;
05323 
05324    TRACE (Func_Exit, "find_prog_unit_tbl", NULL);
05325 
05326    return(found);
05327 
05328 }  /* find_prog_unit_tbl */
05329 
05330 /******************************************************************************\
05331 |*                                                                            *|
05332 |* Description:                                                               *|
05333 |*      Open the module file for reading.  Issue an error if there are        *|
05334 |*      problems.                                                             *|
05335 |*                                                                            *|
05336 |* Input parameters:                                                          *|
05337 |*      module_attr_idx -> Attr index describing module being USEd.           *|
05338 |*      fp_file_idx     -> Index to file path table of file to open.          *|
05339 |*                                                                            *|
05340 |* Output parameters:                                                         *|
05341 |*      NONE                                                                  *|
05342 |*                                                                            *|
05343 |* Returns:                                                                   *|
05344 |*      the file pointer to the file just opened.                             *|
05345 |*                                                                            *|
05346 \******************************************************************************/
05347 static  FILE    *open_module_file(int   module_attr_idx,
05348                                   int   fp_file_idx)
05349 
05350 {
05351    char         *lib_error;
05352    FILE         *mod_file_ptr;
05353 
05354 
05355    TRACE (Func_Entry, "open_module_file", NULL);
05356 
05357    mod_file_ptr = fopen(FP_NAME_PTR(fp_file_idx), "rb");
05358 
05359    if (mod_file_ptr == NULL_IDX) {
05360 
05361       if (FP_FILE_IDX(fp_file_idx) != NULL_IDX &&
05362           FP_CLASS(FP_FILE_IDX(fp_file_idx)) != Directory_Fp) {
05363   
05364          /* Don't issue an error for individual files in directories. */
05365 
05366          lib_error = strerror(errno);
05367 
05368          PRINTMSG(AT_DEF_LINE(module_attr_idx), 1132, Warning,
05369                   AT_DEF_COLUMN(module_attr_idx),
05370                   FP_NAME_PTR(fp_file_idx),
05371                   lib_error,
05372                   AT_OBJ_NAME_PTR(module_attr_idx));
05373       }
05374       FP_SRCH_THE_FILE(fp_file_idx)     = FALSE;
05375       mod_file_end_offset               = 0;
05376    }
05377    else {
05378 
05379       /* Do not use FSEEK macro here, because this is where we are       */
05380       /* setting mod_file_end_offset, which is used by the FSEEK macro.  */
05381 
05382       fseek(mod_file_ptr, 0, SEEK_END); /* Seek to end of file */
05383 
05384       mod_file_end_offset = ftell(mod_file_ptr);
05385 
05386       fseek(mod_file_ptr, 0, SEEK_SET); /* Seek to start of file */
05387    }
05388 
05389    TRACE (Func_Exit, "open_module_file", NULL);
05390 
05391    return(mod_file_ptr);
05392 
05393 }  /* open_module_file */
05394 
05395 /******************************************************************************\
05396 |*                                                                            *|
05397 |* Description:                                                               *|
05398 |*      srch_ar_file_for_module_tbl searches archival libraries for module    *|
05399 |*      information tables.  This routine can search archival libraries that  *|
05400 |*      have the Cray format or the sparc format.  (These differ for member   *|
05401 |*      names over 15 characters.)  This will search one archive file for a   *|
05402 |*      specific module name.  If it finds the module, mod_file_ptr will be   *|
05403 |*      left pointing to the start of the module and TRUE will be returned.   *|
05404 |*      If it finds a problem with the file or it doesn't find the module     *|
05405 |*      FALSE will be returned.                                               *|
05406 |*                                                                            *|
05407 |* Input parameters:                                                          *|
05408 |*      module_attr_idx -> Attr index of module to search for.                *|
05409 |*      fp_file_idx     -> File path table index to entry describing archive  *|
05410 |*                         library to seach.                                  *|
05411 |*      fp_module_idx   -> If this a resumed search, this is a file path      *|
05412 |*                         table index for the last module found in this      *|
05413 |*                         library.  If no modules have been found or if this *|
05414 |*                         is not a resumed search, then this index is NULL.  *|
05415 |*      module_file_ptr -> FILE pointer to archive library to read from.      *|
05416 |*                                                                            *|
05417 |* Output parameters:                                                         *|
05418 |*      NONE                                                                  *|
05419 |*                                                                            *|
05420 |* Returns:                                                                   *|
05421 |*      TRUE  -> The module has been found.  mod_file_ptr will be set to      *|
05422 |*               start of module information table.                           *|
05423 |*      FALSE -> The module was not found.                                    *|
05424 |*                                                                            *|
05425 \******************************************************************************/
05426 static  boolean srch_ar_file_for_module_tbl(int          module_attr_idx,
05427                                             int         *fp_module_idx,
05428                                             int          fp_file_idx,
05429                                             FILE        *mod_file_ptr)
05430 
05431 {
05432    typedef      struct          ar_hdr  ar_hdr_type;
05433 
05434                 ar_hdr_type     ar_header;
05435    static       char            ar_name[256];
05436                 boolean         found;
05437                 int             idx;
05438                 boolean         in_middle_of_file;
05439                 long_type       member_start_offset;
05440                 int             name_length=0;
05441                 long_type       name_tbl_offset;
05442                 int             num_recs_read;
05443                 long_type       offset;
05444                 int             size;
05445 
05446 
05447    TRACE (Func_Entry, "srch_ar_file_for_module_tbl", NULL);
05448 
05449    /* At entry, we are either starting the search in a new archive library */
05450    /* or resuming the search from a given offset.  If we are resuming the  */
05451    /* search we are pointing to whatever follows a module information      */
05452    /* table entry.  This may be a new archive member or a new Cray PDT     */
05453    /* member.  If FP_OFFSET for the file is non-zero we are resuming the   */
05454    /* search.  If the search is being resumed, then mod_file_ptr is set to */
05455    /* the start of the file.  It needs to skip ARMAG, the archive magic    */
05456    /* header string.  If this is a new file being searched, mod_file_ptr   */
05457    /* is set just past ARMAG.                                              */
05458 
05459    offset               = FP_OFFSET(fp_file_idx);
05460 
05461    if (offset > 0) {
05462 
05463       if (!FSEEK(mod_file_ptr, SARMAG, SEEK_SET)) {
05464          return(FALSE);     /* Seek failed.  Exit to look in another file. */
05465       }
05466       in_middle_of_file = TRUE;
05467    }
05468    else {
05469       in_middle_of_file = FALSE;
05470    }
05471 
05472    found                = FALSE;
05473 
05474    /* name_tbl_offset contains the offset in the archive of the // table.  */
05475    /* The // archive holds names of archive members which are greater than */
05476    /* 15 characters.  This table always preceeds all normal member files.  */
05477    /* The only table which may preceed this table, is the symbol table,    */
05478    /* a special table created if there are relocatables in the archive.    */
05479    /* This special table can be ignored by this search.  The // table is   */
05480    /* found in archives for sparcs systems.                                */
05481 
05482    name_tbl_offset      = 0;
05483 
05484    while (!found) {   /* Loop through archival members. */
05485       num_recs_read     = fread(&ar_header,
05486                                 AR_HDR_SIZE, /* Macro from ar.h */
05487                                 1,
05488                                 mod_file_ptr);
05489 
05490       if (feof(mod_file_ptr)) {
05491          FP_SRCH_THE_FILE(fp_file_idx)  = FALSE;
05492          break;
05493       }
05494 
05495       member_start_offset       = ftell(mod_file_ptr);
05496 
05497       if (num_recs_read != 1) {
05498          PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
05499                   AT_DEF_COLUMN(module_attr_idx),
05500                   AT_OBJ_NAME_PTR(module_attr_idx));
05501          FP_SRCH_THE_FILE(fp_file_idx)  = FALSE;
05502          break;
05503       }
05504 
05505       /* Calculate actual size of member.  */
05506 
05507       size      = (size_t) atoi(&ar_header.ar_size[0]);
05508 
05509       /* Skip known non module files within the archive.  On */
05510       /* Solaris, the string table is //.  Keep the offset   */
05511       /* into the // table, in case we hit names that are    */
05512       /* longer than 15 chars and need to access them.  On   */
05513       /* Crays, skip .relotable, .cldtable and .directory.   */
05514 
05515       if (strncmp (ar_header.ar_name, "// ", 3) == 0) {
05516          name_tbl_offset = member_start_offset;
05517 
05518          if (!FSEEK(mod_file_ptr, size, SEEK_CUR)) {
05519             break;
05520          }
05521       }
05522       else if (in_middle_of_file && 
05523               (size + AR_HDR_SIZE + member_start_offset) < offset) {
05524 
05525          /* If this is a resumed search we need to find which member we */
05526          /* are searching in.  We do this by reading up each member and */
05527          /* checking to see if the offset falls within that particular  */
05528          /* member.  We need to do this, because we cannot tell how     */
05529          /* far we are from the end of the member when we resume.  We   */
05530          /* need the members header to tell us the size of the member.  */
05531          /* Once we are in the correct member, we calculate the size    */
05532          /* left in the member by taking the offset to be resumed to    */
05533          /* and subtracting off the offset of the start of the member.  */
05534          /* Then we take the size of the member and subtract off how    */
05535          /* far we are inside the member.  In this else clause, we      */
05536          /* haven't reached the correct member yet, so skip this one.   */
05537 
05538          if (!FSEEK(mod_file_ptr, size, SEEK_CUR)) {
05539             break;
05540          }
05541       }
05542       else if ((strncmp (ar_header.ar_name, ".directory", 10) == 0) ||
05543                 (strncmp (ar_header.ar_name, ".cldtable", 9) == 0) ||
05544                 (strncmp (ar_header.ar_name, ".relotable", 10) == 0)) {
05545 
05546          if (!FSEEK(mod_file_ptr, size, SEEK_CUR)) {
05547             break;
05548          }
05549       }
05550       else {  /* Assume a searchable member. */
05551 
05552          if (in_middle_of_file) {
05553 
05554             /* We have found the member where we are going to resume */
05555             /* the search.  Set size to how much of this member we   */
05556             /* have to search through yet and then set mod_file_ptr  */
05557             /* to the point where we resume the search.              */
05558 
05559             size                = size - (offset - member_start_offset);
05560             in_middle_of_file   = FALSE;
05561 
05562             if (!FSEEK(mod_file_ptr, offset, SEEK_SET)) {
05563                break;
05564             }
05565          }
05566          else {  /* Find the name of the member. */
05567 
05568             if (strncmp(ar_header.ar_name, "#1/", 3) == 0) {
05569 
05570                /* On Crays, if the member name is greater than 15 characters */
05571                /* ar_name contains #1/length of name.  The name follows      */
05572                /* ar_header before the member starts.  This section reads in */
05573                /* the name.                                                  */
05574 
05575                ar_header.ar_name[sizeof (ar_header.ar_name) - 1]= '\0';
05576                name_length      = (size_t) atoi(&ar_header.ar_name[3]);
05577                num_recs_read    = fread(&ar_name, name_length, 1, mod_file_ptr);
05578 
05579                /* Subtract off any filename chars that may appear after */
05580                /* the header.  This is a Cray specific thing.           */
05581 
05582                size                     = size - name_length;
05583                member_start_offset      = ftell(mod_file_ptr);
05584 
05585                if (num_recs_read != 1) {
05586                   PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
05587                            AT_DEF_COLUMN(module_attr_idx),
05588                            AT_OBJ_NAME_PTR(module_attr_idx));
05589                   FP_SRCH_THE_FILE(fp_file_idx) = FALSE;
05590                   break;
05591                }
05592             }
05593 
05594             else if (ar_header.ar_name[0] == '/') {
05595 
05596                /* On sparc systems, if the name is longer than 15 characters */
05597                /* ar_name contains /number, where number is an index into    */
05598                /* the // string table of the name of the member.  This       */
05599                /* section reads up that name and determines its length.      */
05600 
05601                switch (ar_header.ar_name[1]) {
05602                case '0':
05603                case '1':
05604                case '2':
05605                case '3':
05606                case '4':
05607                case '5':
05608                case '6':
05609                case '7':
05610                case '8':
05611                case '9':
05612 
05613                   /* This is an index to the // entry of the name.  */
05614                   /* The name is longer than 15 characters.         */
05615                   /* The // archive member (name_tbl_offset) should */
05616                   /* always be first or second before any named     */
05617                   /* normal members.  If we don't have a // archive */
05618                   /* member then there's a file problem, so issue   */
05619                   /* an error.                                      */
05620 
05621                   if (name_tbl_offset == 0) {
05622                      PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
05623                               AT_DEF_COLUMN(module_attr_idx),
05624                               AT_OBJ_NAME_PTR(module_attr_idx));
05625                      FP_SRCH_THE_FILE(fp_file_idx)      = FALSE;
05626                      goto EXIT;
05627                   }
05628 
05629                   idx   = (size_t) atoi(&ar_header.ar_name[1]);
05630 
05631                   if (!FSEEK(mod_file_ptr, (name_tbl_offset + idx), SEEK_SET)) {
05632                      goto EXIT;
05633                   }
05634 
05635                   if (fgets(ar_name, sizeof(ar_name), mod_file_ptr) == NULL) {
05636                      goto EXIT;
05637                   }
05638 
05639                   if (!FSEEK(mod_file_ptr, member_start_offset, SEEK_SET)) {
05640                      goto EXIT;
05641                   }
05642 
05643                   for (idx = 0; idx < sizeof(ar_name); idx++) {
05644 
05645                      /* ar has a BUG. Not all file names are '/' terminated */
05646                      /* some are blank terminated. */
05647 
05648                      if (ar_name[idx] == '/' ||
05649                          ar_name[idx] == ' ') {
05650                         name_length = idx;
05651                         break;
05652                      }
05653                      else if (ar_name[idx] == '\n') {
05654                         break;
05655                      }
05656                   }
05657                   break;
05658                }
05659             }
05660             else {
05661 
05662                /* This is a plain old < 15 characters name of a member. */
05663                /* Determine the length of the name.                     */
05664 
05665                (void) memcpy ((void *)ar_name, 
05666                               (void *)&ar_header.ar_name,
05667                               sizeof(ar_header.ar_name));
05668             
05669                /* Determine the actual length of this file name */
05670 
05671                for (idx = 0; idx < sizeof(ar_header.ar_name); idx++) {
05672 
05673                   /* ar has a BUG. Not all file names are '/' terminated */
05674                   /* some are blank terminated. */
05675 
05676                   if (ar_name[idx] == '/' ||
05677                       ar_name[idx] == ' ') {
05678                      name_length = idx;
05679                      break;
05680                   }
05681                }
05682             }
05683 
05684 # if defined(_MODULE_TO_DOT_o)
05685             if (on_off_flags.module_to_mod && !FP_SYSTEM_FILE(fp_file_idx)) {
05686 
05687                /* This module is created on systems that do not put their   */
05688                /* module information in the .o file, but in a .mod file.    */
05689                /* Play it safe while looking into archive files and only    */
05690                /* select out .mod files to search through.  Skip the rest.  */
05691    
05692                if (name_length < 5 ||
05693                   ar_name[name_length-1] != 'd' || 
05694                   ar_name[name_length-2] != 'o' || 
05695                   ar_name[name_length-3] != 'm' || 
05696                   ar_name[name_length-4] != '.') {
05697 
05698                   if (!FSEEK(mod_file_ptr, size, SEEK_CUR)) {
05699                      break;
05700                   }
05701                   size = 0;   /* Exit to next member. */
05702                }
05703             }
05704 
05705 # elif !defined(_MODULE_TO_DOT_M)
05706             if (on_off_flags.module_to_mod) {
05707 
05708                /* This module is created on systems that do not put their   */
05709                /* module information in the .o file, but in a .mod file.    */
05710                /* Play it safe while looking into archive files and only    */
05711                /* select out .mod files to search through.  Skip the rest.  */
05712    
05713                if (name_length < 5 ||
05714                   ar_name[name_length-1] != 'd' || 
05715                   ar_name[name_length-2] != 'o' || 
05716                   ar_name[name_length-3] != 'm' || 
05717                   ar_name[name_length-4] != '.') {
05718 
05719                   if (!FSEEK(mod_file_ptr, size, SEEK_CUR)) {
05720                      break;
05721                   }
05722                   size = 0;   /* Exit to next member. */
05723                }
05724             }
05725 # endif
05726 
05727 # if defined(_MODULE_TO_DOT_M)
05728 
05729             /* This module is created on systems that do not put their   */
05730             /* module information in the .o file, but in a .M file.      */
05731             /* Play it safe while looking into archive files and only    */
05732             /* select out .M files to search through.  Skip the rest.    */
05733 
05734             if (name_length < 3 ||
05735                ar_name[name_length-1] != 'M' ||
05736                ar_name[name_length-2] != '.') {
05737 
05738                if (!FSEEK(mod_file_ptr, size, SEEK_CUR)) {
05739                   break;
05740                }
05741                size = 0;   /* Exit to next member. */
05742             }
05743 # endif
05744          }
05745 
05746          found  = srch_for_module_tbl(module_attr_idx,
05747                                       fp_module_idx,
05748                                       fp_file_idx,
05749                                       size,
05750                                       mod_file_ptr);
05751       }
05752 
05753       /* Next archive header starts on an even byte boundary. */
05754 
05755       if (!found && (ftell(mod_file_ptr) & 01)) {
05756 
05757          if (!FSEEK(mod_file_ptr, 1L, SEEK_CUR)) {
05758             break;
05759          }
05760       }
05761    }
05762  
05763 EXIT:
05764 
05765    TRACE (Func_Exit, "srch_ar_file_for_module_tbl", NULL);
05766 
05767    return(found);
05768 
05769 }  /* srch_ar_file_for_module_tbl */
05770 
05771 /******************************************************************************\
05772 |*                                                                            *|
05773 |* Description:                                                               *|
05774 |*                                                                            *|
05775 |* Input parameters:                                                          *|
05776 |*      module_attr_idx -> Attr index of module being searched for.           *|
05777 |*      fp_module_idx   -> Fp index to entry describing module.  This routine *|
05778 |*                         changes the value as new modules are found.   This *|
05779 |*                         is NULL if we haven't found any modules in this    *|
05780 |*                         file yet.                                          *|
05781 |*      fp_file_idx     -> Fp index to entry describing file containing module*|
05782 |*      size            -> If this is an archive file, size if the size left  *|
05783 |*                         of this member in the archive file.                *|
05784 |*      mod_file_ptr    -> Ptr to open file holding module.                   *|
05785 |*                                                                            *|
05786 |* Output parameters:                                                         *|
05787 |*      NONE                                                                  *|
05788 |*                                                                            *|
05789 |* Returns:                                                                   *|
05790 |*      TRUE if we found the module.                                          *|
05791 |*                                                                            *|
05792 \******************************************************************************/
05793 static  boolean srch_for_module_tbl(int          module_attr_idx,
05794                                     int         *fp_module_idx,
05795                                     int          fp_file_idx,
05796                                     int          size,
05797                                     FILE        *mod_file_ptr)
05798 
05799 {
05800    boolean      found           = FALSE;
05801    int          idx;
05802    long        *mod_name_idx;
05803    int          name_len;
05804    int          num_recs_read;
05805    long_type    offset;
05806 
05807 
05808    TRACE (Func_Entry, "srch_for_module_tbl", NULL);
05809 
05810    /* On systems where the module table is buried in the .o files   */
05811    /* we have to search through the PDT loops for the module table. */
05812    /* If the module table is not buried in the .o files, but is its */
05813    /* own member, then this while loop will only be executed once.  */
05814 
05815 # if defined(_DEBUG)
05816 
05817    if (dump_flags.pdt_dump) {
05818       print_fp(fp_file_idx);
05819    }
05820 # endif
05821 
05822    while (!found) {
05823 
05824       if (FP_CLASS(fp_file_idx) == Archive_File_Fp && size <= 0) {
05825 
05826          /* Have reached end of this member.  Or we've gone off in the weeds */
05827 
05828          break;
05829       }
05830 
05831       offset            = ftell(mod_file_ptr);
05832       num_recs_read     = fread(&mit_header, 
05833                                 MD_PDT_HEADER_BYTE_SIZE,
05834                                 1,
05835                                 mod_file_ptr);
05836 
05837       if (feof(mod_file_ptr)) {
05838    
05839          /* Found the end of this file, but didn't find the module */
05840          /* Try the next file in the list.                         */
05841    
05842          FP_SRCH_THE_FILE(fp_file_idx) = FALSE;
05843          break;
05844       }
05845    
05846       if (num_recs_read != 1) {
05847          PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
05848                   AT_DEF_COLUMN(module_attr_idx),
05849                   AT_OBJ_NAME_PTR(module_attr_idx));
05850          FP_SRCH_THE_FILE(fp_file_idx)  = FALSE;
05851          break;
05852       }
05853 
05854       if (MD_PDT_HDR_TYPE != COMPILER_INFO_TABLE_TYPE) {
05855    
05856 # if defined(_DEBUG)
05857 
05858          if (dump_flags.pdt_dump) {
05859             dump_pdt(mod_file_ptr);
05860          }
05861 # endif
05862          /* Not a module information table.  Find the next loader */
05863          /* table in this file.  Reset to start of this table and */
05864          /* then seek to the end of this table.  If the header    */
05865          /* length is zero, we have stumbled on a bad file,       */
05866          /* perhaps another vendors mixed with ours???            */
05867    
05868          if (MD_PDT_HDR_LEN == 0 ||
05869              !FSEEK(mod_file_ptr, offset, SEEK_SET) ||
05870              !FSEEK(mod_file_ptr, (long) MD_PDT_HDR_LEN * TARGET_BYTES_PER_WORD,
05871                                   SEEK_CUR)) {
05872             FP_SRCH_THE_FILE(fp_file_idx) = FALSE;
05873             break;
05874          }
05875 
05876          /* Offset points to start of this table.  ftell returns */
05877          /* position of end of this table.  Decrease size by the */
05878          /* size of this table that we are skipping.             */
05879 
05880          if (FP_CLASS(fp_file_idx) == Archive_File_Fp) {
05881             size -= (ftell(mod_file_ptr) - offset);
05882           }
05883          continue;
05884       }
05885 
05886          /* Not a module information table.  Find the next loader */
05887 
05888       num_recs_read = fread(MD_AFTER_PDT,
05889                             MD_TBL_BYTE_SIZE - MD_PDT_HEADER_BYTE_SIZE,
05890                             1,
05891                             mod_file_ptr);
05892       
05893       if (feof(mod_file_ptr)) {
05894 
05895          /* Found the end of this file, but didn't find the module */
05896          /* Try the next file in the list.                         */
05897 
05898          FP_SRCH_THE_FILE(fp_file_idx) = FALSE;
05899          break;
05900       }
05901 
05902       if (num_recs_read != 1) {
05903          PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
05904                   AT_DEF_COLUMN(module_attr_idx),
05905                   AT_OBJ_NAME_PTR(module_attr_idx));
05906          FP_SRCH_THE_FILE(fp_file_idx) = FALSE;
05907          break;
05908       }
05909 
05910 # if defined(_DEBUG)
05911 
05912       if (dump_flags.pdt_dump) {
05913          dump_pdt(mod_file_ptr);
05914       }
05915 # endif
05916 
05917       /* Found a module.  Save the information in the file_path_tbl. */
05918       /* If it matches we need the info, if it doesn't it will be    */
05919       /* easier to search for next time.                             */
05920    
05921       TBL_REALLOC_CK(file_path_tbl, 1);
05922       CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
05923       name_len  = MD_NAME_LEN;
05924 
05925       if (*fp_module_idx == NULL_IDX) {
05926          *fp_module_idx                 = fp_file_idx;
05927          FP_MODULE_IDX(*fp_module_idx)  = file_path_tbl_idx;
05928          *fp_module_idx                 = file_path_tbl_idx;
05929          FP_NAME_LEN(*fp_module_idx)    = name_len;
05930          FP_NAME_IDX(*fp_module_idx)    = str_pool_idx + 1;
05931          FP_FILE_IDX(*fp_module_idx)    = fp_file_idx;
05932          FP_OFFSET(*fp_module_idx)      = offset;
05933          FP_CLASS(*fp_module_idx)       = (inline_search) ? Inline_Fp:Module_Fp;
05934          mod_name_idx                   = MD_NAME_LONG;
05935 
05936          TBL_REALLOC_CK(str_pool, WORD_LEN(name_len));
05937 
05938          for (idx = FP_NAME_IDX(*fp_module_idx); idx <= str_pool_idx; idx++) {
05939             str_pool[idx].name_long = *mod_name_idx;
05940                mod_name_idx++;
05941          }
05942       }
05943       else if (FP_OFFSET(*fp_module_idx) == -1) {
05944 
05945          /* Searching for this name.  Should be next in this file. */
05946 
05947          if (compare_names(AT_OBJ_NAME_LONG(module_attr_idx),
05948                            AT_NAME_LEN(module_attr_idx),
05949                            MD_NAME_LONG,
05950                            name_len) != 0) {
05951 
05952              /* Cute little problem here - kay */
05953 
05954          }
05955          else { /* Found module - update offset */
05956             FP_OFFSET(*fp_module_idx)   = offset;
05957          }
05958       }
05959       else {
05960 
05961         /* Found a module.  Do not have a list of modules. So make one. */
05962 
05963          FP_MODULE_IDX(*fp_module_idx)  = file_path_tbl_idx;
05964          *fp_module_idx                 = file_path_tbl_idx;
05965          FP_NAME_LEN(*fp_module_idx)    = name_len;
05966          FP_NAME_IDX(*fp_module_idx)    = str_pool_idx + 1;
05967          FP_FILE_IDX(*fp_module_idx)    = fp_file_idx;
05968          FP_OFFSET(*fp_module_idx)      = offset;
05969          FP_CLASS(*fp_module_idx)       = (inline_search) ? Inline_Fp:Module_Fp;
05970          mod_name_idx                   = MD_NAME_LONG;
05971 
05972          TBL_REALLOC_CK(str_pool, WORD_LEN(name_len));
05973 
05974          for (idx = FP_NAME_IDX(*fp_module_idx); idx <= str_pool_idx; idx++) {
05975             str_pool[idx].name_long = *mod_name_idx;
05976             mod_name_idx++;
05977          }
05978       }
05979 
05980       if (compare_names(AT_OBJ_NAME_LONG(module_attr_idx),
05981                         AT_NAME_LEN(module_attr_idx),
05982                         MD_NAME_LONG,
05983                         name_len) != 0) {
05984 
05985          /* Reset to start of this table and    */
05986          /* then seek to the end of this table. */
05987 
05988          if (!FSEEK(mod_file_ptr, offset, SEEK_SET) ||
05989               MD_PDT_HDR_LEN == 0 ||
05990              !FSEEK(mod_file_ptr, (long) MD_PDT_HDR_LEN * TARGET_BYTES_PER_WORD,
05991                                   SEEK_CUR)) {
05992             FP_SRCH_THE_FILE(fp_file_idx)       = FALSE;
05993             break;
05994          }
05995 
05996          /* Offset points to start of this table.  ftell returns */
05997          /* position of end of this table.  Decrease size by the */
05998          /* size of this table that we are skipping.             */
05999 
06000          if (FP_CLASS(fp_file_idx) == Archive_File_Fp) {
06001              size -= (ftell(mod_file_ptr) - offset);
06002          }
06003       }
06004       else {
06005 
06006          /* We found the module we are looking for.  Set FP_OFFSET */
06007          /* to the end of this module information table.  All      */
06008          /* modules that we have found before this module have     */
06009          /* been entered in the file path table so they can be     */
06010          /* found again really easy.  Thus we set FP_OFFSET to the */
06011          /* end of this table, because we have already searched    */
06012          /* and recorded all modules up to this point.  If we need */
06013          /* to search for a module and it is not already listed in */
06014          /* the file path table, we will resume our search at this */
06015          /* point.  MD_PDT_HDR_LEN is the length of this module    */
06016          /* information table.  It is kept in number of words and  */
06017          /* needs to be reset to bytes.                            */
06018 
06019          FP_OFFSET(fp_file_idx) = offset + 
06020                                  ((long)MD_PDT_HDR_LEN * TARGET_BYTES_PER_WORD);
06021          found = TRUE;
06022       }
06023    }
06024 
06025    TRACE (Func_Exit, "srch_for_module_tbl", NULL);
06026 
06027    return(found);
06028 
06029 } /* srch_for_module_tbl */
06030 
06031 /******************************************************************************\
06032 |*                                                                            *|
06033 |* Description:                                                               *|
06034 |*                                                                            *|
06035 |* Input parameters:                                                          *|
06036 |*      module_attr_idx -> Attr index of module being searched for.           *|
06037 |*      fp_module_idx   -> Fp index to entry describing module.               *|
06038 |*      mod_file_ptr    -> Ptr to open file holding module.                   *|
06039 |*                                                                            *|
06040 |* Output parameters:                                                         *|
06041 |*      NONE                                                                  *|
06042 |*                                                                            *|
06043 |* Returns:                                                                   *|
06044 |*      TRUE - if we found and read module header successfully.               *|
06045 |*                                                                            *|
06046 \******************************************************************************/
06047 static  boolean read_module_tbl_header(int      module_attr_idx,
06048                                        int      fp_module_idx,
06049                                        FILE    *mod_file_ptr)
06050 {
06051    boolean      found                   = FALSE;
06052    int          num_recs_read;
06053    long_type    offset;
06054 
06055 
06056    TRACE (Func_Entry, "read_module_tbl_header", NULL);
06057 
06058    if (FP_OFFSET(fp_module_idx) == -1) {
06059 
06060       /* This file has just been written out - Don't */
06061       /* know where the table is, so find it.        */
06062 
06063       offset = 0;
06064 
06065       while (!feof(mod_file_ptr)) {
06066          num_recs_read = fread(&mit_header,
06067                                MD_PDT_HEADER_BYTE_SIZE,
06068                                1,
06069                                mod_file_ptr);
06070 
06071          if (num_recs_read != 1 || feof(mod_file_ptr)) {
06072             fp_module_idx       = NULL_IDX;
06073             break;
06074          }
06075 
06076          if (MD_PDT_HDR_TYPE != COMPILER_INFO_TABLE_TYPE) {
06077             offset      = offset + ((long) MD_PDT_HDR_LEN * 
06078                                            TARGET_BYTES_PER_WORD);
06079 
06080             if (!FSEEK(mod_file_ptr,
06081                        (((long) MD_PDT_HDR_LEN * TARGET_BYTES_PER_WORD) - 
06082                          (long) MD_PDT_HEADER_BYTE_SIZE), SEEK_CUR)) {
06083                fp_module_idx = NULL_IDX;
06084                break;
06085             }
06086             continue;
06087          }
06088 
06089          num_recs_read = fread(MD_AFTER_PDT,
06090                                MD_TBL_BYTE_SIZE - MD_PDT_HEADER_BYTE_SIZE,
06091                                1,
06092                                mod_file_ptr);
06093 
06094          if (num_recs_read != 1 || feof(mod_file_ptr)) {
06095             fp_module_idx = NULL_IDX;
06096             break;
06097          }
06098 
06099          if (compare_names(AT_OBJ_NAME_LONG(module_attr_idx),
06100                            AT_NAME_LEN(module_attr_idx),
06101                            MD_NAME_LONG,
06102                            MD_NAME_LEN) == 0) {
06103             break;
06104          }
06105 
06106          offset = offset + ((long) MD_PDT_HDR_LEN * TARGET_BYTES_PER_WORD);
06107 
06108          if (!FSEEK(mod_file_ptr, 
06109                     ((long)MD_PDT_HDR_LEN * TARGET_BYTES_PER_WORD) - 
06110                                             (long) MD_TBL_BYTE_SIZE,
06111                     SEEK_CUR)) {
06112             fp_module_idx = NULL_IDX;
06113             break;
06114          }
06115       }
06116 
06117       if (fp_module_idx != NULL_IDX) {
06118          FP_OFFSET(fp_module_idx)       = offset;
06119          found                          = TRUE;
06120       }
06121    }
06122    else if (FSEEK(mod_file_ptr, FP_OFFSET(fp_module_idx), SEEK_CUR)) {
06123       num_recs_read = fread(&mit_header,
06124                             MD_TBL_BYTE_SIZE,
06125                             1,
06126                             mod_file_ptr);
06127 
06128       if (num_recs_read != 1) {
06129          PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
06130                   AT_DEF_COLUMN(module_attr_idx),
06131                   AT_OBJ_NAME_PTR(module_attr_idx));
06132       }
06133       else {
06134          found          = TRUE;
06135       }
06136    }
06137 
06138    TRACE (Func_Exit, "read_module_tbl_header", NULL);
06139 
06140    return(found);
06141 
06142 }  /* read_module_tbl_header */
06143 
06144 /******************************************************************************\
06145 |*                                                                            *|
06146 |* Description:                                                               *|
06147 |*      Read in the module information table if it is in a file.              *|
06148 |*      Copy in the module information table if it is in an elf buffer.       *|
06149 |*                                                                            *|
06150 |* Input parameters:                                                          *|
06151 |*      module_attr_idx => Attr index of the module to be read in.            *|
06152 |*      mod_file_ptr    => Pointer to file, it mod table is in file.          *|
06153 |*      mod_info_tbl    => Pointer to mod table in elf buffer.                *|
06154 |*                                                                            *|
06155 |* Output parameters:                                                         *|
06156 |*      NONE                                                                  *|
06157 |*                                                                            *|
06158 |* Returns:                                                                   *|
06159 |*      TRUE if a module info table was successfully brought in.              *|
06160 |*                                                                            *|
06161 \******************************************************************************/
06162 static  boolean  read_in_module_tbl(int          fp_file_idx,
06163                                     int          module_attr_idx,
06164                                     FILE        *mod_file_ptr,
06165                                     char        *mod_info_tbl)
06166 
06167 {
06168    int                  al_idx;
06169    int                  end_sb_idx;
06170    int                  idx;
06171    int                  ln_idx;
06172    int                  name_idx;
06173    int                  num_recs_read;
06174    boolean              ok                      = TRUE;
06175    int                  old_attr_tbl_idx        = attr_tbl_idx;
06176    int                  old_bounds_tbl_idx      = bounds_tbl_idx;
06177    int                  old_const_tbl_idx       = const_tbl_idx;
06178    int                  old_const_pool_idx      = const_pool_idx;
06179    int                  old_ir_tbl_idx          = ir_tbl_idx;
06180    int                  old_ir_list_tbl_idx     = ir_list_tbl_idx;
06181    int                  old_ln_idx;
06182    int                  old_name_pool_idx;
06183    int                  old_sec_name_tbl_idx    = sec_name_tbl_idx;
06184    int                  old_sh_tbl_idx          = sh_tbl_idx;
06185    int                  old_stor_blk_tbl_idx    = stor_blk_tbl_idx;
06186    int                  old_type_tbl_idx        = type_tbl_idx;
06187    boolean              only_stmt;
06188    int                  save_attr_list_start;
06189    int                  save_attr_list_end;
06190    int                  sb_idx;
06191    int                  srch_sb_idx;
06192 
06193 
06194    TRACE (Func_Entry, "read_in_module_tbl", NULL);
06195 
06196    if (MD_HAS_ERRORS && inline_search) {
06197 
06198       /* Do not read if not module and there is errors. */
06199 
06200       return(FALSE);
06201    }
06202 
06203    /* If this is an alternate entry, we need to seek forward */
06204    /* to find the table entries and the main entry.  There   */
06205    /* will be an mit_header for each alternate entry,        */
06206    /* followed by the main entry.                            */
06207 
06208    alternate_entry      = MD_ALTERNATE_ENTRY;
06209 
06210    while (MD_ALTERNATE_ENTRY) {
06211 
06212       if (mod_info_tbl != NULL) {  /* Copying from elf buffer */
06213          memcpy((void *) &mit_header.wd[0],
06214                 (char *) mod_info_tbl,
06215                 (sizeof(mit_header_type)));
06216 
06217         mod_info_tbl += (sizeof(mit_header_type));
06218       }
06219       else {
06220          num_recs_read = fread(&mit_header,
06221                                sizeof(mit_header_type),
06222                                1,
06223                                mod_file_ptr);
06224 # if defined(_DEBUG)
06225 
06226          if (dump_flags.pdt_dump) {
06227             dump_pdt(mod_file_ptr);
06228          }
06229 # endif
06230 
06231          if (num_recs_read != 1) {
06232             PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
06233                      AT_DEF_COLUMN(module_attr_idx),
06234                      AT_OBJ_NAME_PTR(module_attr_idx));
06235             ok  = FALSE;
06236             goto EXIT;
06237          }
06238       }
06239    }
06240 
06241    /* Store the module path into the name pool, before we read in the new     */
06242    /* module stuff into the name pool.  This way it won't get compressed out. */
06243 
06244    if (!inline_search) {
06245 
06246       if (!ATP_IN_CURRENT_COMPILE(module_attr_idx)) {
06247          ATP_MOD_PATH_LEN(module_attr_idx)       = FP_NAME_LEN(fp_file_idx);
06248          ATP_MOD_PATH_IDX(module_attr_idx)       = name_pool_idx + 1;
06249          name_idx                                = FP_NAME_IDX(fp_file_idx);
06250 
06251          TBL_REALLOC_CK(name_pool, WORD_LEN(FP_NAME_LEN(fp_file_idx)));
06252 
06253          for (idx = ATP_MOD_PATH_IDX(module_attr_idx);idx<=name_pool_idx;idx++){
06254             name_pool[idx].name_long = str_pool[name_idx].name_long;
06255             name_idx++;
06256          }
06257       }
06258       only_stmt         = ATP_USE_TYPE(module_attr_idx) == Use_Only;
06259  
06260    }
06261    else {
06262       only_stmt         = FALSE;
06263    }
06264  
06265    old_name_pool_idx    = name_pool_idx;
06266 
06267 
06268    if (mod_info_tbl != NULL) { /* Elf file - Will always be 3 or greater */
06269        memcpy((void *) &mit_descriptor[1].wd, 
06270               (char *) mod_info_tbl,
06271               (sizeof(mit_descriptor_type) * Num_Of_Tbls));
06272 
06273       mod_info_tbl += (sizeof(mit_descriptor_type) * Num_Of_Tbls);
06274    }
06275    else {
06276       num_recs_read = fread(&mit_descriptor[1],
06277                             sizeof(mit_descriptor_type),
06278                             Num_Of_Tbls,
06279                             mod_file_ptr);
06280 
06281       if (num_recs_read != Num_Of_Tbls) {
06282          PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
06283                   AT_DEF_COLUMN(module_attr_idx),
06284                   AT_OBJ_NAME_PTR(module_attr_idx));
06285          ok     = FALSE;
06286          goto EXIT;
06287       }
06288    }
06289 
06290 
06291    if (MD_NUM_ENTRIES(Loc_Name_Tbl) == 1 && !inline_search) { 
06292 
06293       /* There is always 1 entry - the name of the module */
06294 
06295       ok = FALSE;
06296 
06297       if (only_stmt) {
06298          PRINTMSG(AT_DEF_LINE(module_attr_idx), 793, Error,
06299                   AT_DEF_COLUMN(module_attr_idx),
06300                   AT_OBJ_NAME_PTR(module_attr_idx));
06301          AT_DCL_ERR(module_attr_idx) = TRUE;
06302       }
06303       else if (ATP_USE_LIST(module_attr_idx) != NULL_IDX) {  /* rename-list */
06304          PRINTMSG(AT_DEF_LINE(module_attr_idx), 934, Error,
06305                   AT_DEF_COLUMN(module_attr_idx),
06306                   AT_OBJ_NAME_PTR(module_attr_idx));
06307          AT_DCL_ERR(module_attr_idx) = TRUE;
06308       }
06309       else {
06310 
06311          /* There is no only-list or rename-list, so just issue */
06312          /* a warning that the module is empty.                 */
06313 /*Since some modules may only declare some constants   */
06314 /*whirl2f will dump out empty modules(constants are    */
06315 /*already folded in the all expressions which use the  */
06316 /*parameters).This should be OK----fzhao                */
06317 /*
06318          PRINTMSG(AT_DEF_LINE(module_attr_idx), 867, Warning,
06319                   AT_DEF_COLUMN(module_attr_idx),
06320                   AT_OBJ_NAME_PTR(module_attr_idx));
06321 */
06322          ;
06323       }
06324       goto EXIT;
06325    }
06326 
06327 # ifdef _DEBUG
06328    if (!inline_search && loc_name_tbl_idx != SCP_LN_LW_IDX(curr_scp_idx)) {
06329       PRINTMSG(AT_DEF_LINE(module_attr_idx), 832, Internal,
06330                AT_DEF_COLUMN(module_attr_idx),
06331                AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)));
06332    }
06333 # endif
06334 
06335    /* Add 2 buffer entries between the old and new local name tables.  One */
06336    /* of these is used to hold the all zero word, so that srch_sym_tbl can */
06337    /* be used with the new stuff from the module.                          */
06338 
06339    ++loc_name_tbl_idx;
06340    ++loc_name_tbl_idx;
06341 
06342    old_ln_idx           = loc_name_tbl_idx;
06343 
06344    if (!inline_search) {
06345 
06346       /* Leave space in the constant table so that we can use ntr_const_tbl   */
06347       /* to make sure everything is entered after the current constant table. */
06348 
06349       save_const_tbl_idx        = const_tbl_idx;
06350       const_tbl_idx            += (MD_NUM_ENTRIES(Const_Tbl) + 2);
06351       old_const_tbl_idx         = const_tbl_idx;
06352 
06353       save_const_pool_idx       = const_pool_idx;
06354       const_pool_idx           += (MD_NUM_ENTRIES(Const_Pool) + 2);
06355       old_const_pool_idx        = const_pool_idx;
06356    }
06357    else {
06358       save_const_tbl_idx        = NULL_IDX;
06359       save_const_pool_idx       = NULL_IDX;
06360    }
06361 
06362    /* KAY - What if we are at the end of the constant pool?  */
06363 
06364 # if defined(_HOST32) 
06365 
06366    /* If this is host32, the table always went out on the 1st index */
06367    /* so make sure it always comes in on a non-daligned index.      */
06368    /* Everything should come out okay that way.  If const_pool_idx  */
06369    /* is double aligned, then the address following it will be      */
06370    /* non-double aligned and exactly what we want.                  */
06371 
06372    while ((((long)&const_pool[const_pool_idx]) % 8) != 0) {
06373       const_pool_idx++;
06374    }
06375    old_const_pool_idx   = const_pool_idx;
06376 
06377 # endif
06378 
06379    if (!read_sytb_from_module_file(module_attr_idx,
06380                                    mod_file_ptr,
06381                                    mod_info_tbl)) {
06382 
06383       loc_name_tbl_idx = old_ln_idx - 2;
06384       ok = FALSE;
06385       goto EXIT;
06386    }
06387 
06388    /* Although a constant entry may be larger than one const_tbl entry,      */
06389    /* entries being read from the module info file are all treated as each   */
06390    /* being one const tbl entry in length.  First room must be made for all  */
06391    /* the new entries.  They must all be read in, because if we treated each */
06392    /* as individual entries, we couldn't determine their size, because type  */
06393    /* CHARACTER uses another const tbl entry to tell how long the char is.   */
06394 
06395    /* Allocate mod link table and clear all entries. */
06396 
06397    /* The mod_link_tbl will be used for compression and straightening out    */
06398    /* table indexes.  In simple use semantics, entries will be set, but they */
06399    /* will never be used.  We have to set table entries, because we do not   */
06400    /* know if we will use them until we process all tables in the module.    */
06401 
06402    allocate_mod_link_tbl(0);  /* Let routine determine size. */
06403 
06404    /* Loop and set the local name table entries.  ln_idx is set earlier.     */
06405 
06406 
06407    for (ln_idx = old_ln_idx+1; ln_idx <= loc_name_tbl_idx; ln_idx++) {
06408       LN_NAME_IDX(ln_idx)        = old_name_pool_idx + LN_NAME_IDX(ln_idx);
06409       LN_ATTR_IDX(ln_idx)        = old_attr_tbl_idx + LN_ATTR_IDX(ln_idx);
06410       ML_AT_LN_NAME(LN_ATTR_IDX(ln_idx))        = TRUE;
06411    }
06412 
06413    /* This loops thru the new storage block entries, looking for duplicates  */
06414    /* and also folding in the stack block to the parents and generally       */
06415    /* resolving the storage block entries.  At this point,                   */
06416    /* old_stor_blk_tbl_idx indexes to the end of the storage block table     */
06417    /* before the entries were read up from the module.  stor_blk_tbl_idx     */
06418    /* indexes to the end of the storage block table.  stor_blk_tbl_idx -     */
06419    /* old_stor_blk_tbl_idx, gives the number of new entries in the table.    */
06420    /* To get the original index of a storage block coming in from the module */
06421    /* take (idx - old_stor_blk_tbl_idx).  This is needed to set the correct  */
06422    /* entry in the mod_link_tbl, so that all the new module entries pointing */
06423    /* to the storage block table can be updated in assign_new_idxs_after_    */
06424    /* input.  Set the stor_blk_tbl_idx to the end of the old table, so that  */
06425    /* searches will not search the new entries.                              */
06426 
06427    end_sb_idx           = stor_blk_tbl_idx;
06428    stor_blk_tbl_idx     = old_stor_blk_tbl_idx;
06429 
06430    for (idx = stor_blk_tbl_idx+1; idx <= end_sb_idx; idx++) {
06431       SB_NAME_IDX(idx)          = old_name_pool_idx + SB_NAME_IDX(idx);
06432       SB_HAS_RENAMES(idx)       = FALSE;
06433       SB_DEF_LINE(idx)          = AT_DEF_LINE(module_attr_idx);
06434       SB_DEF_COLUMN(idx)        = AT_DEF_COLUMN(module_attr_idx);
06435       SB_SCP_IDX(idx)           = curr_scp_idx;
06436       SB_ORIG_SCP_IDX(idx)      = curr_scp_idx;
06437       SB_LAST_ATTR_LIST(idx)    = NULL_IDX;
06438 
06439       if (SB_FIRST_ATTR_IDX(idx) != NULL_IDX) {
06440          SB_FIRST_ATTR_IDX(idx) = old_attr_tbl_idx + SB_FIRST_ATTR_IDX(idx);
06441       }
06442 
06443       switch (SB_LEN_FLD(idx)) {
06444       case CN_Tbl_Idx:
06445          SB_LEN_IDX(idx)        = old_const_tbl_idx + SB_LEN_IDX(idx);
06446          break;
06447 
06448       case AT_Tbl_Idx:
06449          SB_LEN_IDX(idx)        = old_attr_tbl_idx + SB_LEN_IDX(idx);
06450          break;
06451 
06452       case IR_Tbl_Idx:
06453          SB_LEN_IDX(idx)        = old_ir_tbl_idx + SB_LEN_IDX(idx);
06454          break;
06455 
06456       case IL_Tbl_Idx:
06457          SB_LEN_IDX(idx)        = old_ir_list_tbl_idx + SB_LEN_IDX(idx);
06458          break;
06459 
06460       /* KAY - This case can be removed when we no longer support 3.0 */
06461 
06462       default:
06463          SB_LEN_FLD(idx)        = CN_Tbl_Idx;
06464          SB_LEN_IDX(idx)        = old_const_tbl_idx + SB_LEN_IDX(idx);
06465          break;
06466       }
06467 
06468       /* If we're inline searching we never want to mix storage blocks. */
06469 
06470       if (!inline_search) {
06471          SB_MODULE_IDX(idx)     = (SB_MODULE_IDX(idx) == NULL_IDX) ?
06472                                           module_attr_idx :
06473                                           old_attr_tbl_idx + SB_MODULE_IDX(idx);
06474          SB_USE_ASSOCIATED(idx) = TRUE;
06475          srch_sb_idx            = srch_stor_blk_tbl(SB_NAME_PTR(idx), 
06476                                                     SB_NAME_LEN(idx),
06477                                                     curr_scp_idx);
06478       }
06479       else {
06480          srch_sb_idx            = NULL_IDX;
06481 
06482          if (SB_MODULE_IDX(idx) != NULL_IDX) {
06483             SB_MODULE_IDX(idx)  = old_attr_tbl_idx + SB_MODULE_IDX(idx);
06484          }
06485       }
06486 
06487       if (srch_sb_idx == NULL_IDX) { 
06488          sb_idx                 = ++stor_blk_tbl_idx;
06489          stor_blk_tbl[sb_idx]   = stor_blk_tbl[idx];
06490 
06491       }
06492 
06493       /* If we find a common storage block, it can only have gotten here     */
06494       /* thru use association.   If we have   character*(i) function j()     */
06495       /* where i is host associated, i's storage block does not get copied   */
06496       /* down until attr resolution time.                                    */
06497 #if 0
06498       else if (SB_IS_COMMON(idx) &&
06499                (compare_names(AT_OBJ_NAME_LONG(SB_MODULE_IDX(srch_sb_idx)),
06500                               AT_NAME_LEN(SB_MODULE_IDX(srch_sb_idx)),
06501                               AT_OBJ_NAME_LONG(SB_MODULE_IDX(idx)),
06502                               AT_NAME_LEN(SB_MODULE_IDX(idx))) != 0)) {
06503 
06504          /* Mark the new storage block as being defined in multiple scopes.  */
06505          /* Also, mark it as hidden, so only the first storage block will be */
06506          /* found when searches are made for this storage block.  During     */
06507          /* storage_blk_resolution, when this block is found, SB_MERGED_BLK  */
06508          /* will be updated to the end (or start) of the SB_MERGED_BLK list. */
06509          /* Then the original block will be marked SB_DEF_MULT_SCPS.         */
06510          /* final_attr_resolution,  ATD_STOR_BLK_IDX will be updated to      */
06511          /* SB_MERGED_BLK and then SB_DEF_MULT_SCPS will be checked to see   */
06512          /* if ATD_EQUIV needs to be set.  If this is an only_stmt, nothing  */
06513          /* gets changed in the original block and the new block gets        */
06514          /* compressed out.                                                  */
06515 
06516          sb_idx                         = ++stor_blk_tbl_idx;
06517          stor_blk_tbl[sb_idx]           = stor_blk_tbl[idx];
06518          SB_DEF_MULT_SCPS(sb_idx)       = TRUE;
06519          SB_HIDDEN(sb_idx)              = TRUE;
06520          SB_MERGED_BLK_IDX(sb_idx)      = srch_sb_idx;
06521       }
06522 #endif
06523       else { /* This is the same common block from the same module or it     */
06524              /* is a static based or darg block.  Share the block.           */
06525 
06526          sb_idx = srch_sb_idx;
06527       }
06528       
06529       ML_SB_IDX(idx - old_stor_blk_tbl_idx)     = sb_idx;
06530    }
06531 
06532    if (keep_module_procs) {
06533 
06534       /* Create a list of all module procedures that can be inlined.       */
06535       /* Save attr_list_idx so we can delete the new list when we're done. */
06536 
06537       save_attr_list_start              = SCP_ATTR_LIST(curr_scp_idx);
06538       save_attr_list_end                = SCP_ATTR_LIST_END(curr_scp_idx);
06539       SCP_ATTR_LIST(curr_scp_idx)       = NULL_IDX;
06540       SCP_ATTR_LIST_END(curr_scp_idx)   = NULL_IDX;
06541 
06542       assign_new_idxs_after_input(module_attr_idx);
06543 
06544       al_idx                            = SCP_ATTR_LIST(curr_scp_idx);
06545       SCP_ATTR_LIST(curr_scp_idx)       = save_attr_list_start;
06546       SCP_ATTR_LIST_END(curr_scp_idx)   = save_attr_list_end;
06547 
06548       /* Have module procedures to use for inlining.  Mark the  */
06549       /* attrs so they do not get checked for duplicate attrs.  */
06550 
06551       process_procs_for_inlining(al_idx);
06552       free_attr_list(al_idx);
06553    }
06554    else {
06555       assign_new_idxs_after_input(module_attr_idx);
06556    }
06557 
06558    /* We want to use MD_NUM_ENTRIES(Stor_Blk_Tbl) here because we allocated */
06559    /* space for that many entries when we started.  The actual number of    */
06560    /* stor blk entries is most likely less because we collapsed the store   */
06561    /* block table previously.                                               */
06562 
06563    for (idx = 0; idx <= MD_NUM_ENTRIES(Stor_Blk_Tbl); idx++) {
06564       ML_SB_IDX(idx)    = NULL_IDX;
06565    }
06566 
06567 # ifdef _DEBUG
06568    for (sb_idx = old_stor_blk_tbl_idx + 1;
06569            sb_idx <= stor_blk_tbl_idx; sb_idx++) {
06570 
06571       if (SB_LEN_FLD(sb_idx) == CN_Tbl_Idx &&
06572           TYP_TYPE(CN_TYPE_IDX(SB_LEN_IDX(sb_idx))) != Integer) {
06573          print_sb(sb_idx);
06574          print_cn(SB_LEN_IDX(sb_idx));
06575          PRINTMSG(1, 626, Internal, 0, "integer constant SB_LEN_IDX",
06576                   "read_in_module_tbl");
06577       }
06578    }
06579 # endif
06580 
06581    ML_AT_IDX(0)         = old_attr_tbl_idx;
06582    ML_BD_IDX(0)         = old_bounds_tbl_idx;
06583    ML_CN_IDX(0)         = old_const_tbl_idx;
06584    ML_CP_IDX(0)         = old_const_pool_idx;
06585    ML_IL_IDX(0)         = old_ir_list_tbl_idx;
06586    ML_IR_IDX(0)         = old_ir_tbl_idx;
06587    ML_LN_IDX(0)         = SCP_LN_FW_IDX(curr_scp_idx);
06588    ML_NP_IDX(0)         = old_name_pool_idx;
06589    ML_SB_IDX(0)         = old_stor_blk_tbl_idx;
06590    ML_SN_IDX(0)         = old_sec_name_tbl_idx;
06591    ML_SH_IDX(0)         = old_sh_tbl_idx;
06592    ML_TYP_IDX(0)        = old_type_tbl_idx;
06593 
06594 EXIT: 
06595 
06596    TRACE (Func_Exit, "read_in_module_tbl", NULL);
06597 
06598    return(ok);
06599 
06600 }   /* read_in_module_tbl */
06601 
06602 /******************************************************************************\
06603 |*                                                                            *|
06604 |* Description:                                                               *|
06605 |*                                                                            *|
06606 |* Input parameters:                                                          *|
06607 |*                                                                            *|
06608 |* Output parameters:                                                         *|
06609 |*      NONE                                                                  *|
06610 |*                                                                            *|
06611 |* Returns:                                                                   *|
06612 |*                                                                            *|
06613 \******************************************************************************/
06614 static  boolean read_sytb_from_module_file(int                  module_attr_idx,
06615                                            FILE                *mod_file_ptr,
06616                                            char                *mod_info_tbl)
06617 
06618 {
06619    long                 *from_idx;
06620    int                   i;
06621    int                   idx;
06622    int                   j;
06623    int                   num_entries;
06624    int                   num_recs_read;
06625    boolean               ok             = TRUE;
06626    old_const_tbl_type   *old_cn_tbl     = NULL;
06627    old_ir_tbl_type      *old_ir_tbl     = NULL;
06628    int                   save_const_tbl_idx=0;
06629    int                   save_ir_tbl_idx=0;
06630    int                   size;
06631    void                 *tbl=0;
06632    tbl_type_type         tbl_type;
06633    long                 *to_idx;
06634 
06635 
06636    TRACE (Func_Entry, "read_sytb_from_module_file", NULL);
06637 
06638    /* WARNING:  CHECK_TBL_ALLOC_SIZE may move the table. */
06639 
06640    for (idx = 1; idx <= Num_Of_Tbls; idx++) {
06641       tbl_type          = MD_TBL_TYPE(idx);
06642       num_entries       = MD_NUM_ENTRIES(idx);
06643 
06644       if (num_entries > 0) {
06645 
06646          switch (tbl_type) {
06647 
06648          case Attr_Tbl:
06649 
06650             /* If we're reading up a smaller version of the attr table, we */
06651             /* still want to make space for everything.  We'll adjust the  */
06652             /* older version after it has been read in.                    */
06653 
06654             CHECK_TBL_ALLOC_SIZE(attr_tbl, attr_tbl_idx + num_entries);
06655             CHECK_TBL_ALLOC_SIZE(attr_aux_tbl, attr_aux_tbl_idx + num_entries);
06656 
06657             size                = sizeof(attr_tbl_type);
06658             tbl                 = &attr_tbl[attr_tbl_idx + 1];
06659             attr_tbl_idx       += num_entries;
06660             attr_aux_tbl_idx   += num_entries;
06661             break;
06662 
06663          case Bounds_Tbl:
06664             CHECK_TBL_ALLOC_SIZE(bounds_tbl, bounds_tbl_idx + num_entries);
06665             size                = sizeof(bounds_tbl_type);
06666             tbl                 = &bounds_tbl[bounds_tbl_idx + 1];
06667             bounds_tbl_idx     += num_entries;
06668             break;
06669 
06670          case Const_Tbl:
06671             CHECK_TBL_ALLOC_SIZE(const_tbl, const_tbl_idx + num_entries);
06672 
06673             if (! MD_NEW_CONST_TBL) {  /* KAY - What version ?? */
06674                size     = sizeof(old_const_tbl_type);
06675                old_cn_tbl = (old_const_tbl_type *)malloc(size * num_entries);
06676                tbl      = old_cn_tbl;
06677                save_const_tbl_idx = const_tbl_idx + 1;
06678             }
06679             else {
06680                size     = sizeof(const_tbl_type);
06681                tbl      = &const_tbl[const_tbl_idx + 1];
06682             }
06683             const_tbl_idx      += num_entries;
06684             break;
06685 
06686          case Const_Pool:
06687             CHECK_TBL_ALLOC_SIZE(const_pool, const_pool_idx + num_entries);
06688             size                = sizeof(const_pool_type);
06689             tbl                 = &const_pool[const_pool_idx + 1];
06690             const_pool_idx     += num_entries;
06691             break;
06692 
06693          case Ir_List_Tbl:
06694             CHECK_TBL_ALLOC_SIZE(ir_list_tbl, ir_list_tbl_idx + num_entries);
06695             size                = sizeof(ir_list_tbl_type);
06696             tbl                 = &ir_list_tbl[ir_list_tbl_idx + 1];
06697             ir_list_tbl_idx    += num_entries;
06698             break;
06699 
06700          case Ir_Tbl:
06701             CHECK_TBL_ALLOC_SIZE(ir_tbl, ir_tbl_idx + num_entries);
06702 
06703             if (MD_VERSION_NUM > MD_LAST_4_0_VERSION) {
06704                size             = sizeof(ir_tbl_type);
06705                tbl              = &ir_tbl[ir_tbl_idx + 1];
06706             }
06707             else {
06708                size             = sizeof(old_ir_tbl_type);
06709                old_ir_tbl       = (old_ir_tbl_type *)malloc(size * num_entries);
06710                tbl              = old_ir_tbl;
06711                save_ir_tbl_idx  = ir_tbl_idx + 1;
06712             }
06713             ir_tbl_idx         += num_entries;
06714             break;
06715 
06716          case Name_Pool:
06717             CHECK_TBL_ALLOC_SIZE(name_pool, name_pool_idx + num_entries);
06718             size                = sizeof(name_pool_type);
06719             tbl                 = &name_pool[name_pool_idx + 1];
06720             name_pool_idx      += num_entries;
06721             break;
06722 
06723          case Sec_Name_Tbl:
06724             CHECK_TBL_ALLOC_SIZE(sec_name_tbl, sec_name_tbl_idx + num_entries);
06725             size                = sizeof(sec_name_tbl_type);
06726             tbl                 = &sec_name_tbl[sec_name_tbl_idx + 1];
06727             sec_name_tbl_idx   += num_entries;
06728             break;
06729 
06730          case Sh_Tbl:
06731             size                = sizeof(sh_tbl_type);
06732 
06733             if (keep_module_procs || inline_search) {
06734                CHECK_TBL_ALLOC_SIZE(sh_tbl, sh_tbl_idx + num_entries);
06735                tbl              = &sh_tbl[sh_tbl_idx + 1];
06736                sh_tbl_idx      += num_entries;
06737             }
06738             else {  /* Skip this table - Not getting module procedures. */
06739 
06740                if (mod_info_tbl != NULL) {  /* Copying from elf buffer */
06741                   mod_info_tbl += (size * num_entries);
06742                   continue;
06743                }
06744                else if (!FSEEK(mod_file_ptr, (size * num_entries), SEEK_CUR)) {
06745                   ok = FALSE;  /* Let error message issue.  Bad file. */
06746                }
06747                else {
06748                   continue;
06749                }
06750                break;
06751             }
06752             break;
06753 
06754          case Stor_Blk_Tbl:
06755             CHECK_TBL_ALLOC_SIZE(stor_blk_tbl, stor_blk_tbl_idx + num_entries);
06756             size                = sizeof(stor_blk_tbl_type);
06757             tbl                 = &stor_blk_tbl[stor_blk_tbl_idx + 1];
06758             stor_blk_tbl_idx   += num_entries;
06759             break;
06760 
06761          case Type_Tbl:
06762             CHECK_TBL_ALLOC_SIZE(type_tbl, type_tbl_idx + num_entries);
06763             size                = sizeof(type_tbl_type);
06764             tbl                 = &type_tbl[type_tbl_idx + 1];
06765             type_tbl_idx       += num_entries;
06766             break;
06767 
06768          case Loc_Name_Tbl:
06769             CHECK_TBL_ALLOC_SIZE(loc_name_tbl, loc_name_tbl_idx + num_entries);
06770             size                = sizeof(loc_name_tbl_type);
06771             tbl                 = &loc_name_tbl[loc_name_tbl_idx + 1];
06772             loc_name_tbl_idx   += num_entries;
06773             break;
06774 
06775          default:
06776             ok = FALSE;
06777             PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
06778                      AT_DEF_COLUMN(module_attr_idx),
06779                      AT_OBJ_NAME_PTR(module_attr_idx));
06780             goto EXIT;
06781          }
06782    
06783          if (mod_info_tbl != NULL) {  /* Copying from elf buffer */
06784             (void) memcpy(tbl,
06785                          (char *) mod_info_tbl,
06786                          size * num_entries);
06787             mod_info_tbl += (size * num_entries);
06788          }
06789          else {
06790             num_recs_read = fread(tbl,
06791                                   size,
06792                                   num_entries,
06793                                   mod_file_ptr);
06794 
06795             if (num_recs_read != num_entries) {
06796                ok = FALSE;
06797                PRINTMSG(AT_DEF_LINE(module_attr_idx), 726, Error,
06798                         AT_DEF_COLUMN(module_attr_idx),
06799                         AT_OBJ_NAME_PTR(module_attr_idx));
06800                break;  /* File is bad - exit */
06801             }
06802          }
06803 
06804          if (tbl_type == Ir_Tbl && MD_VERSION_NUM <= MD_LAST_4_0_VERSION) {
06805 
06806             for (i = 0; i < num_entries; i++) {
06807                to_idx   = (long *) &(ir_tbl[save_ir_tbl_idx+i]);
06808                from_idx = (long *) &(old_ir_tbl[i]);
06809 
06810 # if defined(_HOST32)
06811                to_idx[0] = from_idx[0];
06812                to_idx[1] = from_idx[1];
06813                to_idx[2] = 0;
06814                to_idx[3] = 0;
06815                to_idx[4] = from_idx[2];
06816                to_idx[5] = from_idx[3];
06817                to_idx[6] = from_idx[4];
06818                to_idx[7] = from_idx[5];
06819 # else
06820                to_idx[0] = from_idx[0];
06821                to_idx[1] = 0;
06822                to_idx[2] = from_idx[1];
06823                to_idx[3] = from_idx[2];
06824 # endif
06825                IR_RANK(save_ir_tbl_idx+i)       = OLD_IR_RANK(i);
06826                IR_DV_DIM(save_ir_tbl_idx+i)     = OLD_IR_DV_DIM(i);
06827                IR_OPR(save_ir_tbl_idx+i)        = OLD_IR_OPR(i);
06828             }
06829             free(old_ir_tbl);
06830          }
06831 
06832          if (tbl_type == Const_Tbl) {
06833             if (! MD_NEW_CONST_TBL &&
06834                 old_cn_tbl != NULL) {
06835                for (i = 0; i < num_entries; i++) {
06836                   to_idx = (long *) &(const_tbl[save_const_tbl_idx+i]);
06837                   from_idx = (long *) &(old_cn_tbl[i]);
06838                   Pragma("_CRI shortloop")
06839                   for (j = 0; j < OLD_NUM_CN_WDS; j++) {
06840                      to_idx[j] = from_idx[j];
06841                   }
06842                }
06843                free(old_cn_tbl);
06844             }
06845          }
06846       }
06847    }
06848 
06849 EXIT:
06850 
06851    TRACE (Func_Exit, "read_sytb_from_module_file", NULL);
06852 
06853    return(ok);
06854 
06855 }  /* read_sytb_from_module_file */
06856 
06857 # if defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
06858 
06859 /******************************************************************************\
06860 |*                                                                            *|
06861 |* Description:                                                               *|
06862 |*      srch_elf_file_for_module_tbl searches SPARC elf files for module      *|
06863 |*      information tables.                                                   *|
06864 |*                                                                            *|
06865 |* Input parameters:                                                          *|
06866 |*      module_attr_idx -> Attr index of module to search for.                *|
06867 |*      fp_file_idx     -> File path table index to entry describing elf file *|
06868 |*                         to seach.                                          *|
06869 |*                                                                            *|
06870 |* Output parameters:                                                         *|
06871 |*      NONE                                                                  *|
06872 |*                                                                            *|
06873 |* Returns:                                                                   *|
06874 |*      TRUE  -> The module has been found.  Mod information table has been   *|
06875 |*               completely read in.                                          *|
06876 |*      FALSE -> The module was not found.                                    *|
06877 |*                                                                            *|
06878 \******************************************************************************/
06879 static  boolean srch_elf_file_for_module_tbl(int         module_attr_idx,
06880                                              int         fp_file_idx)
06881 
06882 {
06883    int           fd;            /* File descriptor of ELF file      */
06884    boolean       found          = FALSE;
06885 
06886    Elf          *file_elfd;     /* ELF descriptor for whole file    */
06887    Elf          *obj_elfd;      /* ELF descriptor for curr. object  */
06888    Elf_Cmd       elf_cmd;       /* ELF command to read from file    */
06889    Elf32_Ehdr   *ehdr;          /* Header from current object       */
06890 
06891 
06892    TRACE (Func_Entry, "srch_elf_file_for_module_tbl", NULL);
06893 
06894    if ((fd = open(FP_NAME_PTR(fp_file_idx), O_RDONLY, 0)) == -1) {
06895 
06896       /* BHJ - need my 126 message here to say bad file. */
06897 
06898       return(found);
06899    }
06900 
06901    /* Check ELF version.   See elf(3E).  */
06902    
06903    /* Notice that the elf_version() call is the very first call to the ELF */
06904    /* library in the whole program.  It has no idea that a file has been   */
06905    /* opened, much less that the resulting fd is going to get passed to    */
06906    /* the ELF library.  It's just a check between the version of ELF the   */
06907    /* code was compiled with (from the <libelf.h> #include file), and the  */
06908    /* version of ELF the ELF library it's linked with was compiled with.   */
06909 
06910    if (elf_version(EV_CURRENT) == EV_NONE) {
06911 
06912       /* BHJ - Something is wrong with the file.  - See above comment.     */
06913       /*       May want a more descriptive message, like something is      */
06914       /*       wrong with the file.                                        */
06915 
06916       return(found);
06917    }
06918 
06919    /* Process the file, which may be either a simple file or an archive of */
06920    /* files.  The outer while{} loop will iterate once for a simple file,  */
06921    /* and as many times as there are files in the archive for an archive   */
06922    /* file.  In either case, anything that is not an ELF object file will  */
06923    /* be skipped, due to the elf32_getehdr() call returning zero.          */
06924 
06925    /* See elf(3E), elf_begin(3E), elf32_getehdr(3E), elf_next(3E),         */
06926    /* elf_end(3E).                                                         */
06927 
06928    /* This needs to be ELF_C_READ so that we can process archive files.    */
06929    /* If it is switched to ELF_C_RDWR, this code will not allow archive    */
06930    /* files here.                                                          */
06931 
06932    elf_cmd      = ELF_C_READ;
06933    file_elfd    = elf_begin(fd, elf_cmd, ((Elf *) NULL));
06934 
06935    while ((obj_elfd = elf_begin(fd, elf_cmd, file_elfd)) != ((Elf *) NULL)) {
06936 
06937       /* If you're not working with an ELF file, it's the elf32_getehdr()  */
06938       /* call that tells you so.  It yields back a ((Elf32_Ehdr *) NULL)   */
06939       /* in that case.  Actually, I think I may have coded it as a check   */
06940       /* against a 0 (zero) return value, but it's really a NULL pointer.  */
06941 
06942 
06943       if ((ehdr = elf32_getehdr(obj_elfd)) != 0) {
06944 
06945          /* This is an ELF object file.  Process it. */
06946 
06947          FP_CLASS(fp_file_idx)  = Elf_File_Fp;
06948 
06949          if (do_elf_object(obj_elfd, 
06950                            ehdr, 
06951                            module_attr_idx,
06952                            fp_file_idx)) {
06953             found = TRUE;
06954             break;
06955          }
06956       }
06957 
06958       elf_cmd = elf_next(obj_elfd);
06959       elf_end(obj_elfd);
06960    }
06961 
06962    elf_end(file_elfd);
06963    close(fd);
06964 
06965    TRACE (Func_Exit, "srch_elf_file_for_module_tbl", NULL);
06966 
06967    return(found);
06968 
06969 } /* srch_elf_file_for_module_tbl */
06970 # endif
06971 
06972 /******************************************************************************\
06973 |*                                                                            *|
06974 |* Description:                                                               *|
06975 |*      Process one object module from an ELF file.                           *|
06976 |*                                                                            *|
06977 |* Input parameters:                                                          *|
06978 |*      obj_elfd        -> Elf descriptor for current object.                 *|
06979 |*      ehdr            -> Elf header for current object.                     *|
06980 |*      module_attr_idx -> Attr index of module to search for.                *|
06981 |*                                                                            *|
06982 |* Output parameters:                                                         *|
06983 |*      NONE                                                                  *|
06984 |*                                                                            *|
06985 |* Returns:                                                                   *|
06986 |*      TRUE  -> The module has been found.  Mod information table has been   *|
06987 |*               completely read in.                                          *|
06988 |*      FALSE -> The module was not found.                                    *|
06989 |*                                                                            *|
06990 \******************************************************************************/
06991 # if defined(_TARGET_OS_SOLARIS) && defined(_MODULE_TO_DOT_o)
06992 static  boolean do_elf_object(Elf               *obj_elfd,
06993                               Elf32_Ehdr        *ehdr,
06994                               int                module_attr_idx,
06995                               int                fp_file_idx)
06996 {
06997 
06998    Elf_Data             *data;  /* Current section's data           */
06999    boolean               found  = FALSE;
07000    Elf_Scn              *scn;   /* Current section                  */
07001    Elf32_Shdr           *shdr;  /* Current section's header         */
07002 
07003 
07004    TRACE (Func_Entry, "do_elf_object", NULL);
07005 
07006    /* Process each section of the current object.  * See elf_nextscn(3E). */
07007 
07008    scn = (Elf_Scn *) NULL;
07009 
07010    while ((scn = elf_nextscn(obj_elfd, scn)) != ((Elf_Scn *) NULL)) {
07011 
07012       /* If this section isn't for us, skip it.  * See elf32_getshdr(3E). */
07013 
07014       if ((shdr = elf32_getshdr(scn)) == ((Elf32_Shdr *) NULL)) {
07015           continue;
07016       }
07017 
07018 # if 0
07019       {
07020          char       *s_name;
07021 
07022          /* Tell the section's name.  It's stored in the section header */
07023          /* string table.   See elf_strptr(3E).                         */
07024 
07025          s_name = elf_strptr(obj_elfd, ehdr->e_shstrndx,
07026                              ((size_t) shdr->sh_name));
07027          printf("Elf section: '%s', type %u, flags %#x, size %u\n",
07028                 ((s_name == ((char *) NULL)) ? "(none)" : s_name),
07029                 shdr->sh_type, shdr->sh_flags, shdr->sh_size);
07030       }
07031 # endif
07032 
07033       /* Skip sections that aren't .note ones. See /usr/include/sys/elf.h. */
07034 
07035       if (shdr->sh_type != SHT_NOTE) {
07036           continue;
07037       }
07038 
07039 # if 0
07040       printf("This is a NOTES section.  Contents:\n");
07041 # endif
07042 
07043       /* Go through each data object in the section.  Typically,   */
07044       /* this loop will execute exactly once.  The only time it    */
07045       /* would iterate more than one time would be if the section  */
07046       /* were currently being built up by multiple calls to the    */
07047       /* elf_newdata(3E) routine during the creation of a new      */
07048       /* Elf file.                                                 */
07049 
07050       /* We skip data blocks that aren't made of plain vanilla     */
07051       /* bytes, because we don't know how to handle them.  They    */
07052       /* wouldn't be ours, anyway, so it's okay to do this.        */
07053       /* See elf_getdata(3E).                                      */
07054 
07055       data = ((Elf_Data *) NULL);
07056 
07057       while ((data = elf_getdata(scn, data)) != ((Elf_Data *) NULL)) {
07058 
07059          if (data->d_type == ELF_T_BYTE) {
07060 
07061             if (do_elf_notes_section(data, module_attr_idx, fp_file_idx)) {
07062                found = TRUE;
07063                break;
07064             }
07065          }
07066       }
07067    }  /* once-per-section loop */
07068 
07069    TRACE (Func_Exit, "do_elf_object", NULL);
07070 
07071    return(found);
07072 
07073 } /* do_elf_object */
07074 
07075 /******************************************************************************\
07076 |*                                                                            *|
07077 |* Description:                                                               *|
07078 |*      Process one .notes section from an ELF file.                          *|
07079 |*                                                                            *|
07080 |*      Process each successive note in this .note section.  A                *|
07081 |*      single note looks like this:                                          *|
07082 |*                                                                            *|
07083 |*        1 32-bit word:   length of name (below)                             *|
07084 |*        1 32-bit word:   length of descriptor (below)                       *|
07085 |*        1 32-bit word:   type of note                                       *|
07086 |*        0 or more bytes: name, padded with bytes of zero to                 *|
07087 |*                         the next 32-bit word boundary                      *|
07088 |*        0 or more bytes: descriptor (the data in this note),                *|
07089 |*                         padded with bytes of zero to the                   *|
07090 |*                         next 32-bit boundary                               *|
07091 |*                                                                            *|
07092 |*      The name and descriptor lengths (the first two words)                 *|
07093 |*      do not include the trailing padding bytes for the name                *|
07094 |*      and the descriptor.  If the name (or descriptor) is an                *|
07095 |*      even multiple of 32-bit words long (including zero),                  *|
07096 |*      no padding is added.  Name, descriptor, and type are                  *|
07097 |*      all chosen by the originator.  The name is typically                  *|
07098 |*      that of the originator.  The type can be used by an                   *|
07099 |*      originator to differentiate amongst multiple kinds of                 *|
07100 |*      data that said originator might place in the descriptor.              *|
07101 |*                                                                            *|
07102 |*      Multiple notes, from multiple originators, may occur in               *|
07103 |*      a .note section.  When traversing the notes in a section,             *|
07104 |*      programs should pay attention to those they understand,               *|
07105 |*      and skip those they don't.                                            *|
07106 |*                                                                            *|
07107 |*      This particular program removes entries that match "Cray              *|
07108 |*      Research, Incorporated", and have type NOTE_TYPE.  Such               *|
07109 |*      entries contain module information that originated in                 *|
07110 |*      .o files created by the SPARC f90 compiler, and was                   *|
07111 |*      included in an executable by ld(1).  Since such module                *|
07112 |*      information is of no use in an executable, this utility               *|
07113 |*      was created to remove it.                                             *|
07114 |*                                                                            *|
07115 |*      See /usr/include/sys/elf.h, _SunOS 5.3 Linker and                     *|
07116 |*          Libraries Manual_ (hardcopy or AnswerBook),                       *|
07117 |*          chapter 5, page 137 ("Note Section").                             *|
07118 |*                                                                            *|
07119 |*                                                                            *|
07120 |* Input parameters:                                                          *|
07121 |*      data            -> Pointer to in copy memory of whole notes section.  *|
07122 |*      module_attr_idx -> Attr index of module to search for.                *|
07123 |*                                                                            *|
07124 |* Output parameters:                                                         *|
07125 |*      NONE                                                                  *|
07126 |*                                                                            *|
07127 |* Returns:                                                                   *|
07128 |*      TRUE  -> The module has been found.  Mod information table has been   *|
07129 |*               completely read in.                                          *|
07130 |*      FALSE -> The module was not found.                                    *|
07131 |*                                                                            *|
07132 \******************************************************************************/
07133 static  boolean do_elf_notes_section(Elf_Data           *data,
07134                                      int                 module_attr_idx,
07135                                      int                 fp_file_idx)
07136 {
07137 
07138    Elf32_Word            data_off_src;  /* # of source data bytes done      */
07139    boolean               found;         /* TRUE if found module             */
07140    char                 *mod_info_tbl;  /* Ptr to .note descriptor          */
07141    Elf32_Nhdr           *n_hdr;         /* .note block header               */
07142    char                 *n_name_ptr;    /* Pointer to name in .note block   */
07143    unsigned int          namesz;        /* Bytes of name to print           */
07144    Elf32_Word            note_size;     /* Size of this .note               */
07145 
07146 
07147    /* RUP_BYTES() rounds a byte count up to the next Elf32_Word boundary.  */
07148 
07149 # define BRND_SIZE      (sizeof(Elf32_Word))
07150 # define RUP_BYTES(n)   (((n) + BRND_SIZE - 1) & ~(BRND_SIZE - 1))
07151 
07152 
07153    TRACE (Func_Entry, "do_elf_notes_section", NULL);
07154 
07155 # if 0
07156 
07157    /* Tell about the size of the data block.  See /usr/include/libelf.h.  */
07158 
07159    printf("  %d bytes at section offset %u:\n", data->d_size, data->d_off);
07160 
07161 # endif
07162 
07163    data_off_src = 0;
07164    found        = FALSE;
07165 
07166    while (data_off_src < data->d_size) {
07167 
07168       /* Based on the note header that starts at the current    */
07169       /* location in this data block, find the size of the      */
07170       /* entry, and get a pointer to the name.                  */
07171 
07172       n_hdr      = (Elf32_Nhdr *) (((char *) data->d_buf) + data_off_src);
07173       note_size  = sizeof(Elf32_Nhdr)
07174                    + RUP_BYTES(n_hdr->n_namesz)
07175                    + RUP_BYTES(n_hdr->n_descsz);
07176       n_name_ptr = (char *) ((void *) (n_hdr + 1));
07177       namesz     = n_hdr->n_namesz
07178                      - ((*(n_name_ptr + n_hdr->n_namesz - 1) == '\0') ? 1 : 0);
07179       mod_info_tbl = n_name_ptr + RUP_BYTES(n_hdr->n_namesz);
07180 
07181 #     if 0
07182 
07183       {
07184          unsigned int    namesz;     /* Bytes of name to print           */
07185          unsigned int    len;        /* Bytes of .note descriptor done   */
07186 
07187          if (data_off_src != 0) {
07188              printf("\n");
07189          printf("    Name len: %u\n", n_hdr->n_namesz);
07190          printf("    Data len: %u\n", n_hdr->n_descsz);
07191          printf("    Type:     %u\n", n_hdr->n_type);
07192 
07193          /*
07194           * Adjust for a possible trailing NUL byte on the
07195           * originator name.  We don't want to send it to
07196           * printf(3C).
07197           */
07198          printf("    Name:     '%*.*s'\n", namesz, namesz, n_name_ptr);
07199 
07200          /* Report the descriptor, 8 bytes per line. */
07201 
07202 
07203          for (len = 0; len < n_hdr->n_descsz; len++, n_desc_ptr++) {
07204 
07205              if (len == 0) {
07206                  printf("    Desc:    ");
07207              }
07208              else if ((len & 0x7) == 0) {
07209                  printf("\n             ");
07210              }
07211              printf(" %02x", (((int) *n_desc_ptr) & 0xFF));
07212          }
07213          if (len != 0)
07214              printf("\n");
07215          }
07216       }
07217 # endif
07218 
07219       /* Is this CRI SPARC f90 module information? */
07220 
07221       if (n_hdr->n_type == NOTE_TYPE
07222          && memcmp(n_name_ptr, NOTE_ORIG_NAME, NOTE_ORGNAM_LEN) == 0) {
07223 
07224          /* note_size bytes is the size of the module information.         */
07225          /* The elf data routine brings in the whole table to memory.      */
07226          /* Check the name to see if this is the module we're looking for. */
07227 
07228          (void) memcpy((long *) &mit_header.wd[0], 
07229                        ((char *) mod_info_tbl),
07230                        sizeof(mit_header_type));
07231 
07232          if (compare_names(AT_OBJ_NAME_LONG(module_attr_idx),
07233                            AT_NAME_LEN(module_attr_idx),
07234                            MD_NAME_LONG,
07235                            MD_NAME_LEN) == 0) {
07236 
07237            /* Found it.  Copy memory so we can use it. */
07238            /* Bump the pointer past mit_header.        */
07239 
07240            mod_info_tbl += sizeof(mit_header_type);
07241 
07242            read_in_module_tbl(fp_file_idx,
07243                               module_attr_idx,
07244                               NULL,              /* No file pointer */
07245                               mod_info_tbl);
07246            found = TRUE;
07247            break;
07248         }
07249      }
07250 
07251      /* Find the next note's offset.                           */
07252      /* note_size is the size of the module information table. */
07253 
07254      data_off_src += note_size;
07255 
07256    }  /* once-per-note loop */
07257 
07258    TRACE (Func_Exit, "do_elf_notes_section", NULL);
07259 
07260    return(found);
07261 
07262 } /* do_elf_notes_section */
07263 # endif
07264 
07265 /******************************************************************************\
07266 |*                                                                            *|
07267 |* Description:                                                               *|
07268 |*      Reassigns the indexes in the tables after a module has been read in.  *|
07269 |*                                                                            *|
07270 |* Input parameters:                                                          *|
07271 |*      NONE                                                                  *|
07272 |*                                                                            *|
07273 |* Output parameters:                                                         *|
07274 |*      NONE                                                                  *|
07275 |*                                                                            *|
07276 |* Returns:                                                                   *|
07277 |*      NOTHING                                                               *|
07278 |*                                                                            *|
07279 \******************************************************************************/
07280 static void  assign_new_idxs_after_input(int    module_attr_idx)
07281 
07282 {
07283    int          al_idx;
07284    int          at_idx          = attr_tbl_idx - MD_NUM_ENTRIES(Attr_Tbl);
07285    int          attr_idx;
07286    int          bd_idx          = bounds_tbl_idx - MD_NUM_ENTRIES(Bounds_Tbl);
07287    int          bounds_idx;
07288    int          cn_idx          = const_tbl_idx - MD_NUM_ENTRIES(Const_Tbl);
07289    int          column;
07290    int          const_idx;
07291    int          cp_idx          = const_pool_idx - MD_NUM_ENTRIES(Const_Pool);
07292    int          dim;
07293    int          il_idx          = ir_list_tbl_idx - MD_NUM_ENTRIES(Ir_List_Tbl);
07294    int          ir_idx          = ir_tbl_idx - MD_NUM_ENTRIES(Ir_Tbl);
07295    int          line;
07296    int          list_idx;
07297    int          mod_idx;
07298    int          name_idx;
07299    int          new_module_idx;
07300    int          np_idx          = name_pool_idx - MD_NUM_ENTRIES(Name_Pool);
07301    int          old_cn_idx;
07302    int          old_il_idx;
07303    int          save_il_free_list;
07304    int          sh_idx;
07305    int          sn_idx          = sec_name_tbl_idx-MD_NUM_ENTRIES(Sec_Name_Tbl);
07306    int          sn_name_idx;
07307    int          stmt_idx;
07308    int          typ_idx         = type_tbl_idx - MD_NUM_ENTRIES(Type_Tbl);
07309    int          type_idx;
07310 
07311 
07312    TRACE (Func_Entry, "assign_new_idxs_after_input", NULL);
07313 
07314    line         = AT_DEF_LINE(module_attr_idx);
07315    column       = AT_DEF_COLUMN(module_attr_idx);
07316 
07317    if (keep_module_procs || inline_search) {
07318       sh_idx    =  sh_tbl_idx - MD_NUM_ENTRIES(Sh_Tbl);
07319    }
07320    else {
07321       sh_idx    = NULL_IDX;
07322    }
07323 
07324 # ifdef _DEBUG
07325    if (at_idx < 0) {
07326       PRINTMSG(1, 626, Internal, 0, "positive at_idx",
07327                "assign_new_idxs_after_input");
07328    }
07329 
07330    if (bd_idx < 0) {
07331       PRINTMSG(1, 626, Internal, 0, "positive bd_idx",
07332                "assign_new_idxs_after_input");
07333    }
07334 
07335    if (cn_idx < 0) {
07336       PRINTMSG(1, 626, Internal, 0, "positive cn_idx",
07337                "assign_new_idxs_after_input");
07338    }
07339 
07340    if (cp_idx < 0) {
07341       PRINTMSG(1, 626, Internal, 0, "positive cp_idx",
07342                "assign_new_idxs_after_input");
07343    }
07344 
07345    if (il_idx < 0) {
07346       PRINTMSG(1, 626, Internal, 0, "positive il_idx",
07347                "assign_new_idxs_after_input");
07348    }
07349 
07350    if (ir_idx < 0) {
07351       PRINTMSG(1, 626, Internal, 0, "positive ir_idx",
07352                "assign_new_idxs_after_input");
07353    }
07354 
07355    if (np_idx < 0) {
07356       PRINTMSG(1, 626, Internal, 0, "positive np_idx",
07357                "assign_new_idxs_after_input");
07358    }
07359 
07360    if (sn_idx < 0) {
07361       PRINTMSG(1, 626, Internal, 0, "positive sn_idx",
07362                "assign_new_idxs_after_input");
07363    }
07364 
07365    if (typ_idx < 0) {
07366       PRINTMSG(1, 626, Internal, 0, "positive typ_idx",
07367                "assign_new_idxs_after_input");
07368    }
07369 # endif
07370 
07371 
07372    /* Keep old_cn_idx because we will be increasing the size of the constant */
07373    /* table entry and we don't want to overwrite those indexes.              */
07374    /* Also keep old_il_idx for the same reason.                              */
07375 
07376    old_cn_idx   = const_tbl_idx;
07377    old_il_idx   = ir_list_tbl_idx;
07378 
07379    /* Also - clear the IL free list pointer, to force the new lists to go  */
07380    /* to the end of the ir list table, rather than in the middle.          */
07381 
07382    save_il_free_list            = IL_NEXT_LIST_IDX(NULL_IDX);
07383    IL_NEXT_LIST_IDX(NULL_IDX)   = NULL_IDX;
07384 
07385    /* At this pointer the zeroth entry of the mod link table is all zeros. */
07386    /* If a field accessing the ML table is zero, it will remain zero,      */
07387    /* because ML_xx_IDX(0) = 0.                                            */
07388 
07389    new_module_idx = (inline_search) ? NULL_IDX : module_attr_idx;
07390 
07391    for (attr_idx = at_idx+1; attr_idx <= attr_tbl_idx; attr_idx++) {
07392       CLEAR_TBL_NTRY(attr_aux_tbl, attr_idx);
07393    }
07394 
07395    for (attr_idx = at_idx+1; attr_idx <= attr_tbl_idx; attr_idx++) {
07396       ML_AT_SEARCH_ME(attr_idx)         = TRUE;
07397       AT_DEF_LINE(attr_idx)             = line;
07398       AT_DEF_COLUMN(attr_idx)           = column;
07399       AT_NAME_IDX(attr_idx)             = np_idx + AT_NAME_IDX(attr_idx);
07400       AT_ORIG_NAME_IDX(attr_idx)        = np_idx + AT_ORIG_NAME_IDX(attr_idx);
07401       AT_ATTR_LINK(attr_idx)            = (AT_ATTR_LINK(attr_idx) == NULL_IDX) ?
07402                                          NULL_IDX:at_idx+AT_ATTR_LINK(attr_idx);
07403       if (!inline_search) {
07404          AT_USE_ASSOCIATED(attr_idx)    = TRUE;
07405       }
07406 
07407       if (AT_MODULE_IDX(attr_idx) == NULL_IDX) {
07408          AT_MODULE_IDX(attr_idx)        = new_module_idx; 
07409          AT_ORIG_MODULE_IDX(attr_idx)   = new_module_idx; 
07410       }
07411       else {
07412          AT_MODULE_IDX(attr_idx)        = at_idx + AT_MODULE_IDX(attr_idx); 
07413          AT_ORIG_MODULE_IDX(attr_idx)   = at_idx + AT_ORIG_MODULE_IDX(attr_idx);
07414       }
07415 
07416       switch (AT_OBJ_CLASS(attr_idx)) {
07417       case Data_Obj:
07418 
07419          if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
07420             ATD_ARRAY_IDX(attr_idx) += bd_idx;
07421 
07422             /* Share the deferred shape entries with the default entries. */
07423 
07424             if (BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Deferred_Shape) {
07425                ATD_ARRAY_IDX(attr_idx) = BD_RANK(ATD_ARRAY_IDX(attr_idx));
07426             }
07427          }
07428 
07429 # if defined(COARRAY_FORTRAN)
07430          if (ATD_PE_ARRAY_IDX(attr_idx) != NULL_IDX) {
07431             ATD_PE_ARRAY_IDX(attr_idx)  += bd_idx;
07432          }
07433 # endif
07434 
07435          /* As the storage blocks are read in, they are resolved.  The new    */
07436          /* storage block index is kept in the module link table and is       */
07437          /* updated here.                                                     */
07438 
07439          ATD_STOR_BLK_IDX(attr_idx) = ML_SB_IDX(ATD_STOR_BLK_IDX(attr_idx));
07440 
07441          if (ATD_TYPE_IDX(attr_idx) != NULL_IDX) {
07442             ATD_TYPE_IDX(attr_idx) += typ_idx;
07443          }
07444 
07445          if (ATD_DISTRIBUTION_IDX(attr_idx) != NULL_IDX) {
07446             ATD_DISTRIBUTION_IDX(attr_idx) += bd_idx;
07447          }
07448 
07449          if (ATD_RESHAPE_ARRAY_IDX(attr_idx) != NULL_IDX) {
07450             ATD_RESHAPE_ARRAY_IDX(attr_idx)     += bd_idx;
07451          }
07452 
07453          switch (ATD_CLASS(attr_idx)) {
07454 
07455          case Function_Result:
07456 
07457             ATD_FUNC_IDX(attr_idx) = at_idx + ATD_FUNC_IDX(attr_idx);
07458 
07459             if (ATD_OFFSET_ASSIGNED(attr_idx)) {
07460 
07461                switch (ATD_OFFSET_FLD(attr_idx)) {
07462                case AT_Tbl_Idx:
07463                   ATD_OFFSET_IDX(attr_idx) += at_idx;
07464                      break;
07465 
07466                case CN_Tbl_Idx:
07467                   ATD_OFFSET_IDX(attr_idx) += cn_idx;
07468                   break;
07469 
07470                case IR_Tbl_Idx:
07471                   ATD_OFFSET_IDX(attr_idx) += ir_idx;
07472                   break;
07473 
07474                case IL_Tbl_Idx:
07475                   ATD_OFFSET_IDX(attr_idx) += il_idx;
07476                   break;
07477 
07478                case NO_Tbl_Idx:
07479                   break;
07480                }
07481             }
07482             break;
07483 
07484          case Constant:
07485 
07486             ATD_CONST_IDX(attr_idx) += (ATD_FLD(attr_idx) == AT_Tbl_Idx) ?
07487                                        at_idx : cn_idx;
07488             break;
07489 
07490          case CRI__Pointee:
07491 
07492             ATD_PTR_IDX(attr_idx)   += at_idx;
07493             break;
07494 
07495          case Compiler_Tmp:
07496 
07497             if (ATD_NEXT_MEMBER_IDX(attr_idx) != NULL_IDX) {
07498                ATD_NEXT_MEMBER_IDX(attr_idx) += at_idx;
07499             }
07500 
07501             if (ATD_DEFINING_ATTR_IDX(attr_idx) != NULL_IDX) {
07502                ATD_DEFINING_ATTR_IDX(attr_idx) += at_idx;
07503             }
07504 
07505             if (ATD_AUTOMATIC(attr_idx)) {
07506                ATD_AUTO_BASE_IDX(attr_idx) += at_idx;
07507             }
07508             else if (ATD_OFFSET_ASSIGNED(attr_idx)) {
07509 
07510                switch (ATD_OFFSET_FLD(attr_idx)) {
07511                case AT_Tbl_Idx:
07512                   ATD_OFFSET_IDX(attr_idx) += at_idx;
07513                   break;
07514 
07515                case CN_Tbl_Idx:
07516                   ATD_OFFSET_IDX(attr_idx) += cn_idx;
07517                   break;
07518 
07519                case IR_Tbl_Idx:
07520                   ATD_OFFSET_IDX(attr_idx) += ir_idx;
07521                   break;
07522 
07523                case IL_Tbl_Idx:
07524                   ATD_OFFSET_IDX(attr_idx) += il_idx;
07525                   break;
07526 
07527                case NO_Tbl_Idx:
07528                   ATD_OFFSET_IDX(attr_idx) += cn_idx;
07529                   ATD_OFFSET_FLD(attr_idx)  = CN_Tbl_Idx;
07530                   break;
07531                }
07532             }
07533 
07534             switch (ATD_FLD(attr_idx)) {
07535             case CN_Tbl_Idx:
07536                ATD_TMP_IDX(attr_idx) = cn_idx + ATD_TMP_IDX(attr_idx);
07537                break;
07538 
07539             case AT_Tbl_Idx:
07540                ATD_TMP_IDX(attr_idx) = at_idx + ATD_TMP_IDX(attr_idx);
07541                break;
07542 
07543             case IR_Tbl_Idx:
07544                ATD_TMP_IDX(attr_idx) = ir_idx + ATD_TMP_IDX(attr_idx);
07545                break;
07546 
07547             case IL_Tbl_Idx:
07548                ATD_TMP_IDX(attr_idx) = il_idx + ATD_TMP_IDX(attr_idx);
07549                break;
07550 
07551             }
07552 
07553             break;
07554 
07555          case Struct_Component:
07556 
07557             switch (ATD_OFFSET_FLD(attr_idx)) {
07558             case AT_Tbl_Idx:
07559                ATD_CPNT_OFFSET_IDX(attr_idx) += at_idx;
07560                break;
07561 
07562             case CN_Tbl_Idx:
07563                ATD_CPNT_OFFSET_IDX(attr_idx) += cn_idx;
07564                break;
07565 
07566             case IR_Tbl_Idx:
07567                ATD_CPNT_OFFSET_IDX(attr_idx) += ir_idx;
07568                break;
07569 
07570             case IL_Tbl_Idx:
07571                ATD_CPNT_OFFSET_IDX(attr_idx) += il_idx;
07572                break;
07573 
07574             case NO_Tbl_Idx:
07575                ATD_CPNT_OFFSET_IDX(attr_idx) += cn_idx;
07576                ATD_OFFSET_FLD(attr_idx)  = CN_Tbl_Idx;
07577                break;
07578             }
07579 
07580             if (ATD_CPNT_INIT_IDX(attr_idx) != NULL_IDX) {
07581 
07582                switch (ATD_FLD(attr_idx)) {
07583                case AT_Tbl_Idx:
07584                   ATD_CPNT_INIT_IDX(attr_idx) += at_idx;
07585                   break;
07586 
07587                case CN_Tbl_Idx:
07588                   ATD_CPNT_INIT_IDX(attr_idx) += cn_idx;
07589                   break;
07590 
07591                case IR_Tbl_Idx:
07592                   ATD_CPNT_INIT_IDX(attr_idx) += ir_idx;
07593                   break;
07594 
07595                case IL_Tbl_Idx:
07596                   ATD_CPNT_INIT_IDX(attr_idx) += il_idx;
07597                   break;
07598                }
07599             }
07600 
07601             ATD_DERIVED_TYPE_IDX(attr_idx) += at_idx;
07602 
07603             break;
07604 
07605          case Dummy_Argument:
07606 
07607 #ifdef _TARGET_OS_UNICOS
07608 
07609             /* Unicos released earlier than everything else.  The following  */
07610             /* only needs to be done for the very first release.             */
07611 
07612             /* Version 1 has a bad type in this field - BHJ    */
07613             /* Remove this when we no longer support version 1 */
07614 
07615             if (ATD_INTRIN_DARG(attr_idx)) {
07616                ATD_TYPE_IDX(attr_idx)   = NULL_IDX;
07617             }
07618 # endif
07619 
07620             break;
07621 
07622          case Variable:
07623 
07624             if (ATD_FLD(attr_idx) == NO_Tbl_Idx) {
07625 
07626                /* Intentionally blank */
07627 
07628             }
07629             else if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
07630                ATD_VARIABLE_TMP_IDX(attr_idx) += at_idx;
07631             }
07632             else if (ATD_FLD(attr_idx) == IL_Tbl_Idx) {
07633                ATD_VARIABLE_TMP_IDX(attr_idx) += il_idx;
07634             }
07635 
07636             if (ATD_ASSIGN_TMP_IDX(attr_idx) != NULL_IDX) {
07637                ATD_ASSIGN_TMP_IDX(attr_idx) += at_idx;
07638             }
07639 
07640             if (ATD_NEXT_MEMBER_IDX(attr_idx) != NULL_IDX) {
07641                ATD_NEXT_MEMBER_IDX(attr_idx) += at_idx;
07642             }
07643 
07644             if (ATD_AUTOMATIC(attr_idx)) {
07645                ATD_AUTO_BASE_IDX(attr_idx) += at_idx;
07646             }
07647             else if (ATD_OFFSET_ASSIGNED(attr_idx)) {
07648 
07649                switch (ATD_OFFSET_FLD(attr_idx)) {
07650                case AT_Tbl_Idx:
07651                   ATD_OFFSET_IDX(attr_idx) += at_idx;
07652                   break;
07653 
07654                case CN_Tbl_Idx:
07655                   ATD_OFFSET_IDX(attr_idx) += cn_idx;
07656                   break;
07657 
07658                case IR_Tbl_Idx:
07659                   ATD_OFFSET_IDX(attr_idx) += ir_idx;
07660                   break;
07661 
07662                case IL_Tbl_Idx:
07663                   ATD_OFFSET_IDX(attr_idx) += il_idx;
07664                   break;
07665 
07666                case NO_Tbl_Idx:
07667                   ATD_OFFSET_IDX(attr_idx) += cn_idx;
07668                   ATD_OFFSET_FLD(attr_idx)  = CN_Tbl_Idx;
07669                   break;
07670                }
07671             }
07672 
07673          default:
07674             break;
07675 
07676          }  /* End switch */
07677 
07678          break;
07679 
07680       case Pgm_Unit:
07681 
07682 # if 0
07683          ATP_SCP_IDX(attr_idx)          = curr_scp_idx;
07684 # endif
07685 
07686          ATP_EXT_NAME_IDX(attr_idx)     = np_idx + ATP_EXT_NAME_IDX(attr_idx);
07687 
07688          if (ATP_PGM_UNIT(attr_idx) == Module) {
07689 
07690             if (ATP_MOD_PATH_LEN(attr_idx) > 0) {
07691                ATP_MOD_PATH_IDX(attr_idx) = np_idx + ATP_MOD_PATH_IDX(attr_idx);
07692             }
07693 
07694             if (!inline_search) {
07695 
07696                /* CLear - this will be set if this module is referenced as */
07697                /* stuff is brought in.                                     */
07698 
07699                AT_REFERENCED(attr_idx)  = Not_Referenced;
07700 
07701 
07702                /* One of these is the module being read in.  The rest  */
07703                /* are modules indirectly referenced via this module.   */
07704 
07705                if (ATP_SCP_ALIVE(attr_idx)) { 
07706 
07707                   /* The module being USE associated */
07708 
07709                   AT_ATTR_LINK(attr_idx)        = module_attr_idx;
07710                   AT_IGNORE_ATTR_LINK(attr_idx) = TRUE;
07711                   ATP_MODULE_STR_IDX(attr_idx)  =
07712                                      ATP_MODULE_STR_IDX(module_attr_idx);
07713                }
07714                else {
07715 
07716                   /* Is this module already in this scope, via a previous    */
07717                   /* use statement, either indirectly or directly?           */
07718 
07719                   list_idx = SCP_USED_MODULE_LIST(curr_scp_idx);
07720 
07721                   while (list_idx != NULL_IDX) {
07722 
07723 # ifdef _DEBUG
07724                      if (AL_ATTR_IDX(list_idx) == NULL_IDX) {
07725                         PRINTMSG(stmt_start_line, 626, Internal, 0,
07726                                  "nonzero AL_ATTR_IDX", 
07727                                  "assign_new_idxs_after_input");
07728                      }
07729 # endif
07730                      if (compare_names(AT_OBJ_NAME_LONG(attr_idx),
07731                                     AT_NAME_LEN(attr_idx),
07732                                     AT_OBJ_NAME_LONG(AL_ATTR_IDX(list_idx)),
07733                                     AT_NAME_LEN(AL_ATTR_IDX(list_idx))) == 0) {
07734 
07735                      /* Found the same module.  Temporarily link the two  */
07736                      /* modules together via AT_ATTR_LINK.  We need this  */
07737                      /* link, because we need to retain information about */
07738                      /* where both copies of the same module came from    */
07739                      /* until we find out if this copy of the module      */
07740                      /* stays here.  If it does, we will issue a caution  */
07741                      /* message and a CIF record.                         */
07742    
07743                         if (ATP_PGM_UNIT(module_attr_idx) == Module) {
07744                            AT_ATTR_LINK(attr_idx) = AL_ATTR_IDX(list_idx);
07745                            AT_IGNORE_ATTR_LINK(attr_idx) = TRUE;
07746                         }
07747                         ATP_MODULE_STR_IDX(attr_idx) = 
07748                                       ATP_MODULE_STR_IDX(AL_ATTR_IDX(list_idx));
07749                         break;
07750                      }
07751                      list_idx   = AL_NEXT_IDX(list_idx);
07752                   }
07753                 
07754                   if (ATP_MODULE_STR_IDX(attr_idx) == NULL_IDX) {
07755                      name_idx = check_global_pgm_unit(attr_idx);
07756                      ATP_MODULE_STR_IDX(attr_idx) =  GN_NAME_IDX(name_idx);
07757                   }
07758 
07759                   ATP_INDIRECT_MODULE(attr_idx) = TRUE;
07760                }
07761 
07762                /* Add to the top of the local list.                       */
07763 
07764                NTR_ATTR_LIST_TBL(al_idx);
07765                AL_ATTR_IDX(al_idx)      = attr_idx;
07766 
07767                AL_NEXT_IDX(al_idx)      = list_of_modules_in_module;
07768 
07769                if (list_of_modules_in_module != NULL_IDX) {
07770                   AL_PREV_MODULE_IDX(list_of_modules_in_module) = al_idx;
07771                }
07772                list_of_modules_in_module                        = al_idx;
07773             }
07774          }
07775          else {
07776 
07777             if (ATP_SCP_ALIVE(attr_idx)) { /* The pgm unit being searched for */
07778                AT_ATTR_LINK(module_attr_idx)            = attr_idx;
07779                AT_IGNORE_ATTR_LINK(module_attr_idx)     = TRUE;
07780             }
07781 
07782             /* We could be searching for this alternate entry.  Check */
07783 
07784             if (ATP_ALT_ENTRY(attr_idx) && alternate_entry &&
07785                 (compare_names(AT_OBJ_NAME_LONG(attr_idx),
07786                                AT_NAME_LEN(attr_idx),
07787                                AT_OBJ_NAME_LONG(module_attr_idx),
07788                                AT_NAME_LEN(module_attr_idx)) == 0)) {
07789                AT_ATTR_LINK(module_attr_idx)            = attr_idx;
07790                AT_IGNORE_ATTR_LINK(module_attr_idx)     = TRUE;
07791             }
07792 
07793             if (ATP_FIRST_IDX(attr_idx) != NULL_IDX) {
07794                ATP_FIRST_IDX(attr_idx) = sn_idx + ATP_FIRST_IDX(attr_idx);
07795             }
07796 
07797             if (ATP_RSLT_IDX(attr_idx) != NULL_IDX) {
07798                ATP_RSLT_IDX(attr_idx) = at_idx + ATP_RSLT_IDX(attr_idx);
07799             }
07800 
07801             if (AT_IS_INTRIN(attr_idx)) {
07802                ML_AT_SEARCHED(attr_idx)    = TRUE;
07803             }
07804 
07805             if (ATP_PROC(attr_idx) != Intrin_Proc &&
07806                 ATP_PROC(attr_idx) != Dummy_Proc) {
07807 
07808                if ((keep_module_procs || 
07809                     ATP_PGM_UNIT(module_attr_idx) != Module) &&
07810                    ATP_FIRST_SH_IDX(attr_idx) != NULL_IDX) {
07811 
07812                   /* Here is where we decide whether to keep the IR/SH for */
07813                   /* the procedure.  If -O inlinable and this is a module  */ 
07814                   /* or if -O inline[1-3] is specified.                    */ 
07815                   /* Inlining may be on for this compilation, but that     */
07816                   /* doesn't mean that the module procedure being read in  */
07817                   /* actually had IR/SH saved for it.                      */
07818 
07819 # if 0
07820                   /* We are keeping IR/SH for module and internal procedures */
07821                   /* for inlining purposes.  Check the global name table to  */
07822                   /* see if we already have this procedure.                  */
07823 
07824                   if (srch_global_name_tbl(ATP_EXT_NAME_PTR(attr_idx),
07825                                            ATP_EXT_NAME_LEN(attr_idx),
07826                                            &name_idx) &&
07827                       GN_HAVE_INLINABLE_PROC(name_idx)) {
07828                      ATP_FIRST_SH_IDX(attr_idx) = NULL_IDX;
07829                      ATP_PARENT_IDX(attr_idx)   = NULL_IDX;
07830                   }
07831                   else {
07832                      ATP_FIRST_SH_IDX(attr_idx) += sh_idx;
07833                      ATP_PARENT_IDX(attr_idx)   += at_idx;
07834                   }
07835 # endif
07836 
07837                   ATP_FIRST_SH_IDX(attr_idx)    += sh_idx;
07838 
07839                   ATP_PARENT_IDX(attr_idx)      += at_idx;
07840 
07841                   /* Add to list of procedures to send  */
07842                   /* across if inlining is turned on.   */
07843 
07844 
07845                   /* Should we be adding alternate entry points here KAY */
07846 
07847                   if (opt_flags.inline_lvl > Inline_Lvl_0) {
07848 
07849                      /* The module procedure must be first in the list,  */
07850 
07851                      if (ATP_PROC(attr_idx) == Module_Proc) {
07852                         NTR_ATTR_LIST_TBL(al_idx);
07853                         AL_ATTR_IDX(al_idx)     = attr_idx;
07854                         AL_NEXT_IDX(al_idx)     = SCP_ATTR_LIST(curr_scp_idx);
07855                         SCP_ATTR_LIST(curr_scp_idx)     = al_idx;
07856                      }
07857                      else {
07858                         ADD_ATTR_TO_LOCAL_LIST(attr_idx);
07859                      }
07860                   }
07861                }
07862                else {
07863                   ATP_PARENT_IDX(attr_idx)      = NULL_IDX;
07864                   ATP_FIRST_SH_IDX(attr_idx)    = NULL_IDX;
07865                }
07866             }
07867 
07868          }
07869 
07870          break;
07871 
07872       case Label:
07873 
07874          if (!keep_module_procs && !inline_search) {
07875             break;     /* Will throw out all labels */
07876          }
07877 
07878          if (ATL_DIRECTIVE_LIST(attr_idx) != NULL_IDX) {
07879             ATL_DIRECTIVE_LIST(attr_idx)  += il_idx;
07880          }
07881 
07882          if (ATL_NEXT_ASG_LBL_IDX(attr_idx) != NULL_IDX) {
07883             ATL_NEXT_ASG_LBL_IDX(attr_idx) += at_idx;
07884          }
07885 
07886          if (AT_DEFINED(attr_idx) && ATL_DEF_STMT_IDX(attr_idx) != NULL_IDX) {
07887             ATL_DEF_STMT_IDX(attr_idx)  += sh_idx;
07888          }
07889 
07890 
07891          if (ATL_CLASS(attr_idx) == Lbl_Format) {
07892             ATL_PP_FORMAT_TMP(attr_idx) += at_idx;
07893             ATL_FORMAT_TMP(attr_idx)    += at_idx;
07894          }
07895          else if (ATL_CLASS(attr_idx) == Lbl_User &&
07896                   ATL_BLK_STMT_IDX(attr_idx) != NULL_IDX) {
07897             ATL_BLK_STMT_IDX(attr_idx) += sh_idx;
07898          }
07899          break;
07900 
07901       case Derived_Type:
07902 
07903          AT_DEFINED(attr_idx)   = TRUE;
07904          ATT_SCP_IDX(attr_idx)  = curr_scp_idx;
07905 
07906          if (ATT_FIRST_CPNT_IDX(attr_idx) != NULL_IDX) {
07907             ATT_FIRST_CPNT_IDX(attr_idx)        += sn_idx;
07908          }
07909 
07910          if (!ATP_IN_CURRENT_COMPILE(module_attr_idx)) {
07911 
07912             /* If this module was created during this compilation, the index  */
07913             /* in this field is a valid index, because the global type table  */
07914             /* stays around for the whole compilation.  By maintaining this   */
07915             /* index, we save alot of time from searching the global type     */
07916             /* table to see if this type exists already.  If this module was  */
07917             /* created in a different compilation, this field must be clared. */
07918 
07919             ATT_GLOBAL_TYPE_IDX(attr_idx)       = NULL_IDX;
07920          }
07921 
07922          switch (ATT_STRUCT_BIT_LEN_FLD(attr_idx)) {
07923          case AT_Tbl_Idx:
07924             ATT_STRUCT_BIT_LEN_IDX(attr_idx) += at_idx;
07925             break;
07926 
07927          case CN_Tbl_Idx:
07928             ATT_STRUCT_BIT_LEN_IDX(attr_idx) += cn_idx;
07929             break;
07930 
07931          case IR_Tbl_Idx:
07932             ATT_STRUCT_BIT_LEN_IDX(attr_idx) += ir_idx;
07933             break;
07934 
07935          case IL_Tbl_Idx:
07936             ATT_STRUCT_BIT_LEN_IDX(attr_idx) += il_idx;
07937             break;
07938 
07939          case NO_Tbl_Idx:
07940             ATT_STRUCT_BIT_LEN_FLD(attr_idx)  = CN_Tbl_Idx;
07941             ATT_STRUCT_BIT_LEN_IDX(attr_idx) += cn_idx;
07942             break;
07943          }
07944          break;
07945 
07946       case Interface:
07947 
07948          /* We do not search for duplicate interface blocks, because */
07949          /* these blocks get concatenated, so we have to go through  */
07950          /* all the specific interfaces and throw out duplicates.    */
07951 
07952          ML_AT_SEARCHED(attr_idx)          = TRUE;
07953          ATI_FIRST_SPECIFIC_IDX(attr_idx) += sn_idx; 
07954 
07955          if (ATD_TYPE_IDX(attr_idx) != NULL_IDX) {
07956             ATD_TYPE_IDX(attr_idx)        += typ_idx;
07957          }
07958 
07959          if (ATI_PROC_IDX(attr_idx) != NULL_IDX) {
07960             ATI_PROC_IDX(attr_idx)        += at_idx;
07961          }
07962 
07963          break;
07964 
07965       case Namelist_Grp:
07966    
07967          if (ATN_NAMELIST_DESC(attr_idx) != NULL_IDX) {
07968             ATN_NAMELIST_DESC(attr_idx)  = at_idx + ATN_NAMELIST_DESC(attr_idx);
07969          }
07970 
07971          ATN_FIRST_NAMELIST_IDX(attr_idx)       += sn_idx;
07972          ATN_LAST_NAMELIST_IDX(attr_idx)        += sn_idx; 
07973          break;
07974 
07975       case Stmt_Func:
07976 
07977          if (ATD_TYPE_IDX(attr_idx) != NULL_IDX) {
07978             ATD_TYPE_IDX(attr_idx)        += typ_idx;
07979          }
07980 
07981          if (ATP_FIRST_IDX(attr_idx) != NULL_IDX) {
07982             ATP_FIRST_IDX(attr_idx) = sn_idx + ATP_FIRST_IDX(attr_idx);
07983          }
07984 
07985          switch (ATS_SF_FLD(attr_idx)) {
07986          case CN_Tbl_Idx:
07987             ATS_SF_IDX(attr_idx) = cn_idx + ATS_SF_IDX(attr_idx);
07988             break;
07989 
07990          case AT_Tbl_Idx:
07991             ATS_SF_IDX(attr_idx) = at_idx + ATS_SF_IDX(attr_idx);
07992             break;
07993 
07994          case IR_Tbl_Idx:
07995             ATS_SF_IDX(attr_idx) = ir_idx + ATS_SF_IDX(attr_idx);
07996             break;
07997 
07998          case IL_Tbl_Idx:
07999             ATS_SF_IDX(attr_idx) = il_idx + ATS_SF_IDX(attr_idx);
08000             break;
08001          }
08002 
08003          break;
08004       }  /* End switch */
08005    }
08006 
08007    bounds_idx = bd_idx + 1;
08008 
08009    while (bounds_idx <= bounds_tbl_idx) {
08010       BD_LINE_NUM(bounds_idx)   = line;
08011       BD_COLUMN_NUM(bounds_idx) = column;
08012 
08013       if (!ATP_IN_CURRENT_COMPILE(module_attr_idx)) {
08014 
08015          /* If this module was created during this compilation, the index  */
08016          /* in this field is a valid index, because the global bounds table*/
08017          /* stays around for the whole compilation.  By maintaining this   */
08018          /* index, we save alot of time from searching the global bounds   */
08019          /* table to see if this bound exists already.  If this module was */
08020          /* created in a different compilation, this field must be clared. */
08021 
08022          BD_GLOBAL_IDX(bounds_idx)   = NULL_IDX;
08023       }
08024 
08025       if (BD_DIST_NTRY(bounds_idx)) {
08026 
08027          for (dim = 1; dim <= BD_RANK(bounds_idx); dim++) {
08028 
08029             if (BD_CYCLIC_FLD(bounds_idx, dim) == CN_Tbl_Idx) {
08030                BD_CYCLIC_IDX(bounds_idx, dim) = 
08031                                   cn_idx + BD_CYCLIC_IDX(bounds_idx, dim);
08032             }
08033             else if (BD_CYCLIC_FLD(bounds_idx, dim) == AT_Tbl_Idx) {
08034                BD_CYCLIC_IDX(bounds_idx, dim) = 
08035                                   at_idx + BD_CYCLIC_IDX(bounds_idx, dim);
08036             }
08037 
08038             if (BD_ONTO_FLD(bounds_idx, dim) == CN_Tbl_Idx) {
08039                BD_ONTO_IDX(bounds_idx, dim) = 
08040                                   cn_idx + BD_ONTO_IDX(bounds_idx, dim);
08041             }
08042             else if (BD_ONTO_FLD(bounds_idx, dim) == AT_Tbl_Idx) {
08043                BD_ONTO_IDX(bounds_idx, dim) = 
08044                                   at_idx + BD_ONTO_IDX(bounds_idx, dim);
08045             }
08046          }
08047          bounds_idx = bounds_idx + BD_RANK(bounds_idx);
08048       }
08049       else if (BD_ARRAY_CLASS(bounds_idx) != Deferred_Shape) {
08050 
08051          if (BD_LEN_FLD(bounds_idx) == CN_Tbl_Idx) {
08052             BD_LEN_IDX(bounds_idx) = cn_idx + BD_LEN_IDX(bounds_idx);
08053          }
08054          else if (BD_LEN_FLD(bounds_idx) == AT_Tbl_Idx) {
08055             BD_LEN_IDX(bounds_idx) = at_idx + BD_LEN_IDX(bounds_idx);
08056          }
08057 
08058          for (dim = 1; dim <= BD_RANK(bounds_idx); dim++) {
08059 
08060             if (BD_LB_FLD(bounds_idx, dim) == CN_Tbl_Idx) {
08061                BD_LB_IDX(bounds_idx, dim) = cn_idx + BD_LB_IDX(bounds_idx, dim);
08062             }
08063             else if (BD_LB_FLD(bounds_idx, dim) == AT_Tbl_Idx) {
08064                BD_LB_IDX(bounds_idx, dim) = at_idx + BD_LB_IDX(bounds_idx, dim);
08065             }
08066 
08067             if (BD_UB_FLD(bounds_idx, dim) == CN_Tbl_Idx) {
08068                BD_UB_IDX(bounds_idx, dim) = cn_idx + BD_UB_IDX(bounds_idx, dim);
08069             }
08070             else if (BD_UB_FLD(bounds_idx, dim) == AT_Tbl_Idx) {
08071                BD_UB_IDX(bounds_idx, dim) = at_idx + BD_UB_IDX(bounds_idx, dim);
08072             }
08073 
08074             if (BD_XT_FLD(bounds_idx, dim) == CN_Tbl_Idx) {
08075                BD_XT_IDX(bounds_idx, dim) = cn_idx + BD_XT_IDX(bounds_idx, dim);
08076             }
08077             else if (BD_XT_FLD(bounds_idx, dim) == AT_Tbl_Idx) {
08078                BD_XT_IDX(bounds_idx, dim) = at_idx + BD_XT_IDX(bounds_idx, dim);
08079             }
08080 
08081             if (BD_SM_FLD(bounds_idx, dim) == CN_Tbl_Idx) {
08082                BD_SM_IDX(bounds_idx, dim) = cn_idx + BD_SM_IDX(bounds_idx, dim);
08083             }
08084             else if (BD_SM_FLD(bounds_idx, dim) == AT_Tbl_Idx) {
08085                BD_SM_IDX(bounds_idx, dim) = at_idx + BD_SM_IDX(bounds_idx, dim);
08086             }
08087          }
08088          bounds_idx = bounds_idx + BD_RANK(bounds_idx);
08089       }
08090       ++bounds_idx;
08091    }
08092 
08093    for (sn_name_idx = sn_idx+1; sn_name_idx <= sec_name_tbl_idx; sn_name_idx++){
08094       SN_LINE_NUM(sn_name_idx)  = line;
08095       SN_COLUMN_NUM(sn_name_idx)= column;
08096       SN_NAME_IDX(sn_name_idx)  = np_idx + SN_NAME_IDX(sn_name_idx);
08097       SN_ATTR_IDX(sn_name_idx)  = at_idx + SN_ATTR_IDX(sn_name_idx);
08098 
08099       if (SN_SIBLING_LINK(sn_name_idx) != NULL_IDX) {
08100          SN_SIBLING_LINK(sn_name_idx) = sn_idx + SN_SIBLING_LINK(sn_name_idx);
08101       }
08102    }
08103 
08104 # if defined(_DEBUG)
08105    for (const_idx = cn_idx+1; const_idx <= old_cn_idx; const_idx++) {
08106 
08107       if (CN_POOL_IDX(const_idx) == NULL_IDX) {
08108          PRINTMSG(stmt_start_line, 1349, Internal, 0, const_idx);
08109       }
08110    }
08111 # endif
08112 
08113    for (const_idx = cn_idx+1; const_idx <= old_cn_idx; const_idx++) {
08114       CN_TYPE_IDX(const_idx)    = typ_idx + CN_TYPE_IDX(const_idx);
08115       CN_POOL_IDX(const_idx)    = cp_idx + CN_POOL_IDX(const_idx);
08116    }
08117 
08118    for (type_idx = typ_idx+1; type_idx <= type_tbl_idx; type_idx++) {
08119 
08120       if (TYP_TYPE(type_idx) == Character) {
08121 
08122          if (TYP_FLD(type_idx) == AT_Tbl_Idx) {
08123             TYP_IDX(type_idx) = at_idx + TYP_IDX(type_idx);
08124 
08125             if (TYP_ORIG_LEN_IDX(type_idx) != NULL_IDX) {
08126                TYP_ORIG_LEN_IDX(type_idx) = at_idx + TYP_ORIG_LEN_IDX(type_idx);
08127             }
08128          }
08129          else if (TYP_FLD(type_idx) == CN_Tbl_Idx) {
08130             TYP_IDX(type_idx) = cn_idx + TYP_IDX(type_idx);
08131          }
08132       }
08133       else if (TYP_TYPE(type_idx) == Structure) {
08134          TYP_IDX(type_idx)   = at_idx + TYP_IDX(type_idx);
08135       }
08136 
08137 # if defined(_HOST32) && defined(_TARGET32)
08138 
08139       else if (MD_VERSION_NUM <= MD_LAST_4_0_VERSION && 
08140                TYP_TYPE(type_idx) == Typeless) {
08141 
08142          /* A 32 bit compile now carries a 64 bit type length */
08143 
08144          TYP_BIT_LEN(type_idx) = (long64) type_tbl[type_idx].wd1.old_bit_len;
08145       }
08146 # endif
08147    }
08148 
08149    for (list_idx = il_idx+1; list_idx <= old_il_idx; list_idx++) {
08150 
08151       if (IL_NEXT_LIST_IDX(list_idx) != NULL_IDX) {
08152          IL_NEXT_LIST_IDX(list_idx) = il_idx + IL_NEXT_LIST_IDX(list_idx);
08153       }
08154 
08155       if (IL_ARG_DESC_VARIANT(list_idx)) {
08156          IL_ARG_DESC_IDX(list_idx)      = NULL_IDX;
08157       }
08158       else if (IL_PREV_LIST_IDX(list_idx) != NULL_IDX) {
08159          IL_PREV_LIST_IDX(list_idx) = il_idx + IL_PREV_LIST_IDX(list_idx);
08160       }
08161 
08162       switch (IL_FLD(list_idx)) {
08163       case CN_Tbl_Idx:
08164          IL_IDX(list_idx)       = cn_idx + IL_IDX(list_idx);
08165          IL_LINE_NUM(list_idx)  = line;
08166          IL_COL_NUM(list_idx)   = column;
08167          break;
08168 
08169       case AT_Tbl_Idx:
08170          IL_IDX(list_idx)       = at_idx + IL_IDX(list_idx);
08171          IL_LINE_NUM(list_idx)  = line;
08172          IL_COL_NUM(list_idx)   = column;
08173          break;
08174       
08175       case IL_Tbl_Idx:
08176          IL_IDX(list_idx)       = il_idx + IL_IDX(list_idx);
08177 
08178          /* Do not update line num.  It's not a line number */
08179 
08180          break;
08181 
08182       case IR_Tbl_Idx:
08183          IL_IDX(list_idx)       = ir_idx + IL_IDX(list_idx);
08184          IL_LINE_NUM(list_idx)  = line;
08185          IL_COL_NUM(list_idx)   = column;
08186          break;
08187       }
08188    }
08189 
08190    if (keep_module_procs || inline_search) {
08191 
08192       for (stmt_idx = sh_idx+1; stmt_idx <= sh_tbl_idx; stmt_idx++) {
08193          SH_GLB_LINE(stmt_idx)  = line;
08194          SH_COL_NUM(stmt_idx)   = column;
08195 
08196          if (SH_NEXT_IDX(stmt_idx) != NULL_IDX) {
08197             SH_NEXT_IDX(stmt_idx) = sh_idx + SH_NEXT_IDX(stmt_idx);
08198          }
08199 
08200          if (SH_PREV_IDX(stmt_idx) != NULL_IDX) {
08201             SH_PREV_IDX(stmt_idx) = sh_idx + SH_PREV_IDX(stmt_idx);
08202          }
08203 
08204          if (SH_PARENT_BLK_IDX(stmt_idx) != NULL_IDX &&
08205              SH_STMT_TYPE(stmt_idx) != Statement_Num_Stmt) {
08206             SH_PARENT_BLK_IDX(stmt_idx) = sh_idx + SH_PARENT_BLK_IDX(stmt_idx);
08207          }
08208 
08209          if (SH_IR_IDX(stmt_idx) != NULL_IDX) {
08210             SH_IR_IDX(stmt_idx) = ir_idx + SH_IR_IDX(stmt_idx);
08211          }
08212       }
08213    }
08214 
08215    
08216 
08217    for (mod_idx = ir_idx+1; mod_idx <= ir_tbl_idx; mod_idx++) {
08218 
08219       if (IR_TYPE_IDX(mod_idx) != NULL_IDX) {
08220          IR_TYPE_IDX(mod_idx)   = typ_idx + IR_TYPE_IDX(mod_idx);
08221       }
08222       IR_LINE_NUM(mod_idx)      = line;
08223       IR_COL_NUM(mod_idx)       = column;
08224 
08225       switch (IR_FLD_L(mod_idx)) {
08226       case CN_Tbl_Idx:
08227          IR_IDX_L(mod_idx)      = cn_idx + IR_IDX_L(mod_idx);
08228          IR_LINE_NUM_L(mod_idx) = line;
08229          IR_COL_NUM_L(mod_idx)  = column;
08230          break;
08231 
08232       case AT_Tbl_Idx:
08233          IR_IDX_L(mod_idx) = at_idx + IR_IDX_L(mod_idx);
08234          IR_LINE_NUM_L(mod_idx) = line;
08235          IR_COL_NUM_L(mod_idx)  = column;
08236          break;
08237       
08238       case IL_Tbl_Idx:
08239          IR_IDX_L(mod_idx) = il_idx + IR_IDX_L(mod_idx);
08240 
08241          /* Do not update line num.  It's not a line number */
08242 
08243          break;
08244 
08245       case IR_Tbl_Idx:
08246          IR_IDX_L(mod_idx) = ir_idx + IR_IDX_L(mod_idx);
08247          IR_LINE_NUM_L(mod_idx) = line;
08248          IR_COL_NUM_L(mod_idx)  = column;
08249          break;
08250 
08251       case SH_Tbl_Idx:
08252          IR_IDX_L(mod_idx) = sh_idx + IR_IDX_L(mod_idx);
08253          IR_LINE_NUM_L(mod_idx) = line;
08254          IR_COL_NUM_L(mod_idx)  = column;
08255          break;
08256       }
08257 
08258       switch (IR_FLD_R(mod_idx)) {
08259       case CN_Tbl_Idx:
08260          IR_IDX_R(mod_idx) = cn_idx + IR_IDX_R(mod_idx);
08261          IR_LINE_NUM_R(mod_idx) = line;
08262          IR_COL_NUM_R(mod_idx)  = column;
08263          break;
08264 
08265       case AT_Tbl_Idx:
08266          IR_IDX_R(mod_idx) = at_idx + IR_IDX_R(mod_idx);
08267          IR_LINE_NUM_R(mod_idx) = line;
08268          IR_COL_NUM_R(mod_idx)  = column;
08269          break;
08270       
08271       case IL_Tbl_Idx:
08272          IR_IDX_R(mod_idx) = il_idx + IR_IDX_R(mod_idx);
08273 
08274          /* Do not update line num.  It's not a line number */
08275 
08276          break;
08277 
08278       case IR_Tbl_Idx:
08279          IR_IDX_R(mod_idx) = ir_idx + IR_IDX_R(mod_idx);
08280          IR_LINE_NUM_R(mod_idx) = line;
08281          IR_COL_NUM_R(mod_idx)  = column;
08282          break;
08283 
08284       case SH_Tbl_Idx:
08285          IR_IDX_R(mod_idx) = sh_idx + IR_IDX_R(mod_idx);
08286          IR_LINE_NUM_R(mod_idx) = line;
08287          IR_COL_NUM_R(mod_idx)  = column;
08288          break;
08289       }
08290    }
08291 
08292    for (attr_idx = at_idx+1; attr_idx <= attr_tbl_idx; attr_idx++) {
08293 
08294       if (AT_IS_INTRIN(attr_idx) && AT_OBJ_CLASS(attr_idx) == Interface) {
08295 
08296          /* Find this intrinsic in the current table.  Bring it in */
08297          /* and merge this interface with the intrinsic interface  */
08298          /* so old types, enums and indexes get set correctly.     */
08299 
08300          update_intrinsic(attr_idx);
08301       }
08302    }
08303 
08304    IL_NEXT_LIST_IDX(NULL_IDX)   = save_il_free_list;
08305 
08306    TRACE (Func_Exit, "assign_new_idxs_after_input", NULL);
08307 
08308    return;
08309 
08310 }   /* assign_new_idxs_after_input */
08311 
08312 /******************************************************************************\
08313 |*                                                                            *|
08314 |* Description:                                                               *|
08315 |*      This routine resolves two items with the same name in the local name  *|
08316 |*      table during USE processing.  This resolves the MODULE name, concats  *|
08317 |*      interfaces, checks to see if the program unit name or dummy arg names *|
08318 |*      are being USED and finds out if this item is really NOT VISIBLE.  If  *|
08319 |*      the item is from the same original module and has the same name, it   *|
08320 |*      is VISIBLE.  This routine checks all of the above things and returns  *|
08321 |*      TRUE it the new_attr is used.  It returns FALSE, if the new_attr is   *|
08322 |*      not used.  Following is an example of NOT_VISIBLE code.               *|
08323 |*                                                                            *|
08324 |*              MODULE A                                                      *|
08325 |*                integer B(100)                                              *|
08326 |*              END MODULE A                                                  *|
08327 |*              MODULE Z                                                      *|
08328 |*                use A                                                       *|
08329 |*              END MODULE Z                                                  *|
08330 |*              MODULE Y                                                      *|
08331 |*                use A                                                       *|
08332 |*                use Z        ! This is legal and B is visible               *|
08333 |*              END MODULE Y                                                  *|
08334 |*                                                                            *|
08335 |*              MODULE A                                                      *|
08336 |*                integer B(100)                                              *|
08337 |*              END MODULE A                                                  *|
08338 |*              MODULE Z                                                      *|
08339 |*              use A, C=>B                                                   *|
08340 |*              END MODULE Z                                                  *|
08341 |*              MODULE Y                                                      *|
08342 |*                use A                                                       *|
08343 |*                use Z, B=>C  ! This is legal and B is visible               *|
08344 |*              END MODULE Y                                                  *|
08345 |*                                                                            *|
08346 |* Input parameters:                                                          *|
08347 |*      new_attr_idx    => The attr index of the attr from the USE module.    *|
08348 |*      old_name_idx    => The local name tabl index of the attr found in the *|
08349 |*                         current scope's name table.                        *|
08350 |*      module_attr_idx => The attr index of the USE module.                  *|
08351 |*                                                                            *|
08352 |* Output parameters:                                                         *|
08353 |*      NONE                                                                  *|
08354 |*                                                                            *|
08355 |* Returns:                                                                   *|
08356 |*      NONE                                                                  *|
08357 |*                                                                            *|
08358 \******************************************************************************/
08359 static void     not_visible_semantics(int       new_attr_idx,
08360                                       int       old_name_idx,
08361                                       int       module_attr_idx)
08362 
08363 {
08364    int                  il_idx;
08365    int                  old_attr_idx;
08366    boolean              same_module;
08367    int                  save_new_attr;
08368    int                  sn_attr_idx;
08369    int                  sn_idx;
08370    int                  srch_il_idx;
08371    int                  srch_sn_idx;
08372 
08373 
08374    TRACE (Func_Entry, "not_visible_semantics", NULL);
08375 
08376    old_attr_idx                 = LN_ATTR_IDX(old_name_idx);
08377    save_new_attr                = NULL_IDX;
08378    only_update_new_tbl_entries  = FALSE;
08379 
08380    if (AT_OBJ_CLASS(new_attr_idx) == Interface &&
08381        AT_OBJ_CLASS(old_attr_idx) == Pgm_Unit &&
08382        ATI_PROC_IDX(new_attr_idx) != NULL_IDX) {
08383       save_new_attr     = new_attr_idx;
08384       new_attr_idx      = ATI_PROC_IDX(new_attr_idx);
08385    }
08386    else if (AT_OBJ_CLASS(old_attr_idx) == Interface &&
08387             AT_OBJ_CLASS(new_attr_idx) == Pgm_Unit &&
08388             ATI_PROC_IDX(old_attr_idx) != NULL_IDX) {
08389       old_attr_idx = ATI_PROC_IDX(old_attr_idx);
08390    }
08391 
08392    if (ML_AT_IDX(new_attr_idx) == old_attr_idx) {
08393 
08394       /* Resolve_attr found that this object is the same object.     */
08395       /* All references to this attr will be replaced with the       */
08396       /* old attr.  This local name entry does not have to be        */
08397       /* entered because one already exists, so just extt.           */
08398 
08399       /* Intentionally blank.                                        */
08400    }
08401    else if (AT_OBJ_CLASS(new_attr_idx) == Pgm_Unit &&
08402             ATP_PGM_UNIT(new_attr_idx) == Module) {
08403 
08404       /* Resolve_used_modules handles module names.                  */
08405 
08406       /* Intentionally blank.                                        */
08407 
08408    }
08409    else if (AT_USE_ASSOCIATED(old_attr_idx)) {
08410 
08411       /* We know the attrs have the same name.  Check if they are    */
08412       /* from the same module and have the same original name index. */
08413 
08414       same_module = (ATP_MODULE_STR_IDX(AT_MODULE_IDX(new_attr_idx)) == 
08415                      ATP_MODULE_STR_IDX(AT_MODULE_IDX(old_attr_idx)) ||
08416                      AT_ATTR_LINK(AT_MODULE_IDX(new_attr_idx)) == 
08417                                   AT_MODULE_IDX(old_attr_idx));
08418 
08419       if (same_module &&
08420           (compare_names(AT_ORIG_NAME_LONG(new_attr_idx),
08421                          AT_ORIG_NAME_LEN(new_attr_idx),
08422                          AT_ORIG_NAME_LONG(old_attr_idx),
08423                          AT_ORIG_NAME_LEN(old_attr_idx)) == 0)) {
08424 
08425          if (AT_OBJ_CLASS(old_attr_idx) == Interface) {
08426             merge_interfaces(new_attr_idx, old_attr_idx);
08427             KEEP_ATTR(old_attr_idx);
08428          }
08429          else {
08430 
08431             if (save_new_attr != NULL_IDX) {
08432 
08433                /* Specific case when the new attr is an interface */
08434                /* with the same name as the old attr.             */
08435 
08436                LN_ATTR_IDX(old_name_idx) = save_new_attr;
08437                LN_NAME_IDX(old_name_idx) = AT_NAME_IDX(save_new_attr);
08438 
08439                KEEP_ATTR(save_new_attr);
08440             }
08441 
08442             /* All references to this attr will be replaced with the    */
08443             /* old attr.  This local name entry does not have to be     */
08444             /* entered because one already exists, so just exit.        */
08445 
08446             ML_AT_IDX(new_attr_idx)     = old_attr_idx;
08447             ML_AT_KEEP_ME(new_attr_idx) = FALSE;
08448 
08449             KEEP_ATTR(old_attr_idx);
08450 
08451             /* There may be references to associated attrs.  These attrs  */
08452             /* need to get set so that they will point to there new attr. */
08453 
08454             switch (AT_OBJ_CLASS(new_attr_idx)) {
08455             case Data_Obj:
08456          
08457                if (ATD_CLASS(new_attr_idx) == Variable && 
08458                    ATD_VARIABLE_TMP_IDX(new_attr_idx) != NULL_IDX) {
08459 
08460                   if (ATD_FLD(new_attr_idx) == AT_Tbl_Idx) {
08461                      ML_AT_IDX(ATD_VARIABLE_TMP_IDX(new_attr_idx)) =
08462                                ATD_VARIABLE_TMP_IDX(old_attr_idx);
08463                      ML_AT_KEEP_ME(ATD_VARIABLE_TMP_IDX(new_attr_idx))  = FALSE;
08464                   }
08465                   else if (ATD_FLD(new_attr_idx) == IL_Tbl_Idx) {
08466                      il_idx             = ATD_VARIABLE_TMP_IDX(new_attr_idx);
08467                      srch_il_idx        = ATD_VARIABLE_TMP_IDX(old_attr_idx);
08468 
08469                      while (il_idx != NULL_IDX) {
08470                         ML_AT_IDX(IL_IDX(il_idx))       = IL_IDX(srch_il_idx);
08471                         ML_AT_KEEP_ME(IL_IDX(il_idx))   = FALSE;
08472                         il_idx          = IL_NEXT_LIST_IDX(il_idx);
08473                         srch_il_idx     = IL_NEXT_LIST_IDX(srch_il_idx);
08474                      }
08475                   }
08476                }
08477 
08478                if (ATD_CLASS(new_attr_idx) == Constant && 
08479                                        ATD_FLD(new_attr_idx) == AT_Tbl_Idx) {
08480                   ML_AT_IDX(ATD_CONST_IDX(new_attr_idx)) = 
08481                                               ATD_CONST_IDX(old_attr_idx);
08482                   ML_AT_KEEP_ME(ATD_CONST_IDX(new_attr_idx))    = FALSE;
08483                }
08484                break;
08485 
08486             case Pgm_Unit:
08487 
08488                if (ATP_PGM_UNIT(new_attr_idx) == Function ||
08489                    ATP_PGM_UNIT(new_attr_idx) == Subroutine) {
08490                   srch_sn_idx   = ATP_FIRST_IDX(old_attr_idx);
08491 
08492                   for (sn_idx = ATP_FIRST_IDX(new_attr_idx); 
08493                        sn_idx < (ATP_FIRST_IDX(new_attr_idx) + 
08494                                  ATP_NUM_DARGS(new_attr_idx));
08495                        sn_idx++) {
08496 
08497                      ML_AT_IDX(SN_ATTR_IDX(sn_idx)) = SN_ATTR_IDX(srch_sn_idx);
08498                      ML_AT_KEEP_ME(SN_ATTR_IDX(sn_idx)) = FALSE;
08499                      srch_sn_idx++;
08500                   }
08501 
08502                   if (ATP_PGM_UNIT(new_attr_idx) == Function){
08503                      ML_AT_IDX(ATP_RSLT_IDX(new_attr_idx)) =
08504                                ATP_RSLT_IDX(old_attr_idx);
08505                      ML_AT_KEEP_ME(ATP_RSLT_IDX(new_attr_idx)) = FALSE;
08506                   }
08507                }
08508                break;
08509 
08510             case Derived_Type:
08511                sn_idx           = ATT_FIRST_CPNT_IDX(new_attr_idx);
08512                srch_sn_idx      = ATT_FIRST_CPNT_IDX(old_attr_idx);
08513 
08514                while (sn_idx != NULL_IDX && srch_sn_idx != NULL_IDX) {
08515                   ML_AT_IDX(SN_ATTR_IDX(sn_idx)) = SN_ATTR_IDX(srch_sn_idx);
08516                   ML_AT_KEEP_ME(SN_ATTR_IDX(sn_idx))    = FALSE;
08517                   sn_idx        = SN_SIBLING_LINK(sn_idx);
08518                   srch_sn_idx   = SN_SIBLING_LINK(srch_sn_idx);
08519                }
08520                break;
08521 
08522             }  /* End switch */
08523          }
08524       }
08525       else if (AT_OBJ_CLASS(old_attr_idx) == Interface &&
08526                AT_OBJ_CLASS(new_attr_idx) == Interface &&
08527                ATI_DEFINED_OPR(old_attr_idx) == ATI_DEFINED_OPR(new_attr_idx) &&
08528                ATI_INTERFACE_CLASS(old_attr_idx) == 
08529                ATI_INTERFACE_CLASS(new_attr_idx)) {
08530          merge_interfaces(new_attr_idx, old_attr_idx);
08531          KEEP_ATTR(old_attr_idx);
08532       }
08533       else if (AT_OBJ_CLASS(old_attr_idx) == Pgm_Unit &&
08534                ATP_IN_CURRENT_COMPILE(old_attr_idx)) {
08535          PRINTMSG(AT_DEF_LINE(new_attr_idx), 1053, Error,
08536                   AT_DEF_COLUMN(new_attr_idx),
08537                   AT_OBJ_NAME_PTR(new_attr_idx),
08538                   AT_OBJ_NAME_PTR(AT_MODULE_IDX(old_attr_idx)));
08539          AT_DCL_ERR(old_attr_idx)       = TRUE;
08540          AT_DCL_ERR(new_attr_idx)       = TRUE;
08541 
08542          /* Need to keep new attribute in case other new stuff uses it. */
08543 
08544          KEEP_ATTR(new_attr_idx);
08545       }
08546       else {
08547          AT_NOT_VISIBLE(old_attr_idx)   = TRUE;
08548          AT_NOT_VISIBLE(new_attr_idx)   = TRUE;
08549 
08550          if (AT_OBJ_CLASS(old_attr_idx) == Interface &&
08551              ATI_PROC_IDX(old_attr_idx) != NULL_IDX) {
08552             old_attr_idx = ATI_PROC_IDX(old_attr_idx);
08553             AT_NOT_VISIBLE(old_attr_idx) = TRUE;
08554          }
08555 
08556          if (AT_OBJ_CLASS(new_attr_idx) == Interface &&
08557              ATI_PROC_IDX(new_attr_idx) != NULL_IDX) {
08558             new_attr_idx = ATI_PROC_IDX(new_attr_idx);
08559             AT_NOT_VISIBLE(new_attr_idx) = TRUE;
08560          }
08561 
08562          if (AT_OBJ_CLASS(old_attr_idx) == Pgm_Unit &&
08563              ATP_PGM_UNIT(old_attr_idx) == Function &&
08564              !ATP_RSLT_NAME(old_attr_idx)) {
08565             AT_NOT_VISIBLE(ATP_RSLT_IDX(old_attr_idx)) = TRUE;
08566          }
08567 
08568          if (AT_OBJ_CLASS(new_attr_idx) == Pgm_Unit &&
08569              ATP_PGM_UNIT(new_attr_idx) == Function &&
08570              !ATP_RSLT_NAME(new_attr_idx)) {
08571             AT_NOT_VISIBLE(ATP_RSLT_IDX(new_attr_idx)) = TRUE;
08572          }
08573 
08574          /* Need to keep new attribute in case other new stuff uses it. */
08575 
08576          KEEP_ATTR(new_attr_idx);
08577       }
08578    }
08579    else {
08580 
08581       if (AT_OBJ_CLASS(old_attr_idx) == Data_Obj &&
08582           ATD_SYMBOLIC_CONSTANT(old_attr_idx) &&
08583           AT_OBJ_CLASS(new_attr_idx) == Data_Obj &&
08584           ATD_SYMBOLIC_CONSTANT(new_attr_idx)) {
08585 
08586          /* All references to new attr will be replaced with old attr. */
08587 
08588          ML_AT_IDX(new_attr_idx)        = old_attr_idx;
08589          ML_AT_KEEP_ME(new_attr_idx)    = FALSE;
08590 
08591          KEEP_ATTR(old_attr_idx);
08592       }
08593       else if (old_attr_idx == SCP_ATTR_IDX(curr_scp_idx)) {
08594          PRINTMSG(AT_DEF_LINE(module_attr_idx), 736, Error, 
08595                   AT_DEF_COLUMN(module_attr_idx),
08596                   AT_OBJ_NAME_PTR(old_attr_idx),
08597                   AT_OBJ_NAME_PTR(module_attr_idx));
08598          AT_DCL_ERR(old_attr_idx) = TRUE;
08599          AT_DCL_ERR(new_attr_idx) = TRUE;
08600 
08601          /* Need to keep new attribute in case other new stuff uses it. */
08602 
08603          KEEP_ATTR(new_attr_idx);
08604       }
08605       else if (AT_OBJ_CLASS(old_attr_idx) == Data_Obj &&
08606                ATD_CLASS(old_attr_idx) == Dummy_Argument) {
08607          
08608 # ifdef _DEBUG
08609          sn_attr_idx = srch_kwd_name(AT_OBJ_NAME_PTR(old_attr_idx),
08610                                      AT_NAME_LEN(old_attr_idx),
08611                                      SCP_ATTR_IDX(curr_scp_idx),
08612                                      &sn_idx);
08613 
08614          if (sn_attr_idx == NULL_IDX) {
08615             PRINTMSG(AT_DEF_LINE(old_attr_idx), 989, Internal, 
08616                      AT_DEF_COLUMN(old_attr_idx),
08617                      AT_OBJ_NAME_PTR(old_attr_idx));
08618          }
08619 # endif
08620          PRINTMSG(AT_DEF_LINE(module_attr_idx), 731, Error, 
08621                   AT_DEF_COLUMN(module_attr_idx),
08622                   AT_OBJ_NAME_PTR(old_attr_idx),
08623                   AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)),
08624                   AT_OBJ_NAME_PTR(module_attr_idx));
08625          AT_DCL_ERR(old_attr_idx) = TRUE;
08626          AT_DCL_ERR(new_attr_idx) = TRUE;
08627 
08628          /* Need to keep new attribute in case other new stuff uses it. */
08629 
08630          KEEP_ATTR(new_attr_idx);
08631       }
08632       else if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Function &&
08633                ATP_RSLT_IDX(SCP_ATTR_IDX(curr_scp_idx)) == old_attr_idx) {
08634 
08635          PRINTMSG(AT_DEF_LINE(module_attr_idx), 988, Error, 
08636                   AT_DEF_COLUMN(module_attr_idx),
08637                   AT_OBJ_NAME_PTR(old_attr_idx),
08638                   AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)),
08639                   AT_OBJ_NAME_PTR(module_attr_idx));
08640          AT_DCL_ERR(old_attr_idx)               = TRUE;
08641          AT_DCL_ERR(new_attr_idx)               = TRUE;
08642          AT_DCL_ERR(SCP_ATTR_IDX(curr_scp_idx)) = TRUE;
08643 
08644          /* Need to keep new attribute in case other new stuff uses it. */
08645 
08646          KEEP_ATTR(new_attr_idx);
08647       }
08648       else if (AT_OBJ_CLASS(old_attr_idx) == Derived_Type ||
08649                AT_REFERENCED(old_attr_idx) != Not_Referenced) {
08650 
08651          /* If this is a derived type it was used to declare the function's */
08652          /* type.  Copy the new attribute information to the old attribute  */
08653          /* and keep the old attribute.  Do not keep the new attribute.     */
08654 
08655          /* Otherwise this object was used in a declaration bound for the   */
08656          /* function.  Copy the new attribute information to the old attr   */
08657          /* and keep the old attribute.  Do not keep the new attribute.     */
08658 
08659          /* BHJ - Currently all old_attr_idx's get all their indexes updated. */
08660 
08661          COPY_ATTR_NTRY(AT_WORK_IDX, old_attr_idx);
08662          COPY_ATTR_NTRY(old_attr_idx, new_attr_idx); /* Old = new */
08663 
08664          AT_REFERENCED(old_attr_idx)    = AT_REFERENCED(AT_WORK_IDX);
08665          AT_DEF_LINE(old_attr_idx)      = AT_DEF_LINE(AT_WORK_IDX);
08666          AT_DEF_COLUMN(old_attr_idx)    = AT_DEF_COLUMN(AT_WORK_IDX);
08667          AT_DEFINED(old_attr_idx)       = AT_DEFINED(AT_WORK_IDX);
08668          AT_ACTUAL_ARG(old_attr_idx)    = AT_ACTUAL_ARG(AT_WORK_IDX);
08669          AT_CIF_SYMBOL_ID(old_attr_idx) = AT_CIF_SYMBOL_ID(AT_WORK_IDX);
08670          AT_DCL_ERR(old_attr_idx)       = AT_DCL_ERR(AT_WORK_IDX);
08671 
08672          KEEP_ATTR(new_attr_idx);
08673 
08674          ML_AT_KEEP_ME(new_attr_idx)    = FALSE;
08675 
08676          /* All references to new attr will be replaced with old attr. */
08677 
08678          ML_AT_IDX(new_attr_idx)        = old_attr_idx;
08679          LN_DEF_LOC(old_name_idx)       = TRUE;
08680          AT_DEFINED(old_attr_idx)       = TRUE;
08681       }
08682       else if (AT_OBJ_CLASS(old_attr_idx) == Label && 
08683                AT_DEF_LINE(old_attr_idx) == stmt_start_line) {
08684 
08685          /* Use stmts are not processed until the statement following them */
08686          /* is identified.  This stmt may have a construct name on it and  */
08687          /* that name is in the symbol table.  Call fnd_semantic_err to    */
08688          /* issue a message, because the construct name was declared after */
08689          /* the USE stmt that brought in the same-named item.  Mark        */
08690          /* AT_USE_ASSOCIATED flag so the correct message comes out.       */
08691 
08692          AT_USE_ASSOCIATED(old_attr_idx)        = TRUE;
08693 
08694          fnd_semantic_err(Obj_Construct,
08695                           AT_DEF_LINE(old_attr_idx),
08696                           AT_DEF_COLUMN(old_attr_idx),
08697                           old_attr_idx,
08698                           TRUE);
08699 
08700          /* Set local name table to point to new attr.  Old construct attr */
08701          /* is no longer in the name table.  Keep new attribute entry.     */
08702 
08703          LN_ATTR_IDX(old_name_idx)              = new_attr_idx;
08704          LN_NAME_IDX(old_name_idx)              = AT_NAME_IDX(new_attr_idx);
08705          LN_NAME_LEN(old_name_idx)              = AT_NAME_LEN(new_attr_idx);
08706          AT_DCL_ERR(new_attr_idx)               = TRUE;
08707          KEEP_ATTR(new_attr_idx);
08708       }
08709       else if (num_prog_unit_errors == 0) {
08710 
08711          /* There should not be anything in the local scope. */
08712 
08713          PRINTMSG(AT_DEF_LINE(module_attr_idx), 81, Internal, 
08714                   AT_DEF_COLUMN(module_attr_idx),
08715                   AT_OBJ_NAME_PTR(old_attr_idx),
08716                   old_attr_idx);
08717       }
08718       else {
08719 
08720          AT_DCL_ERR(new_attr_idx)       = TRUE;
08721 
08722          /* Need to keep new attribute in case other new stuff uses it. */
08723 
08724          KEEP_ATTR(new_attr_idx);
08725       }
08726    }
08727 
08728    TRACE (Func_Exit, "not_visible_semantics", NULL);
08729 
08730    return;
08731 
08732 }   /* not_visible_semantics */
08733 
08734 /******************************************************************************\
08735 |*                                                                            *|
08736 |* Description:                                                               *|
08737 |*      This routine goes through the list of specific routines attached to   *|
08738 |*      the new interface and matches them to the specific routines in the    *|
08739 |*      old interface.  All duplicate specifics are removed from the new      *|
08740 |*      list of specifics.  What is left on the new specific list is          *|
08741 |*      appended to the list of old specifics.                                *|
08742 |*                                                                            *|
08743 |* Input parameters:                                                          *|
08744 |*      old_interface_idx -> attr index for interface that already exists     *|
08745 |*                           in the local name table.                         *|
08746 |*      new_interface_idx -> attr index for interface with the same name as   *|
08747 |*                           old_interface_idx.  This interface is coming     *|
08748 |*                           in from the new module.                          *|
08749 |*                                                                            *|
08750 |* Output parameters:                                                         *|
08751 |*      NONE                                                                  *|
08752 |*                                                                            *|
08753 |* Returns:                                                                   *|
08754 |*      NOTHING                                                               *|
08755 |*                                                                            *|
08756 \******************************************************************************/
08757 static  void    merge_interfaces(int            new_interface_idx,
08758                                  int            old_interface_idx)
08759 
08760 {
08761    int          end_sn_idx=0;
08762    boolean      found_intrin    = FALSE;
08763    int          last_old_sn_idx;
08764    boolean      move_intrin     = FALSE;
08765    int          new_attr_idx;
08766    int          new_module_idx;
08767    int          new_sn_idx;
08768    int          num_interfaces;
08769    int          old_attr_idx;
08770    int          old_module_idx;
08771    int          old_sn_idx;
08772    int          prev_sn_idx;
08773    boolean      same_module;
08774    int          sn_idx;
08775 
08776 
08777    TRACE (Func_Entry, "merge_interfaces", NULL);
08778 
08779    new_sn_idx   = ATI_FIRST_SPECIFIC_IDX(new_interface_idx);
08780 
08781    while (new_sn_idx != NULL_IDX) {
08782       new_attr_idx      = SN_ATTR_IDX(new_sn_idx);
08783 
08784       /* This call to resolve attr is trying to match new procedures with */
08785       /* old procedures.  We are not to the stage of setting the keep me  */
08786       /* flag yet.  That will be done later.                              */
08787 
08788       if (!ML_AT_SEARCHED(new_attr_idx)) {
08789          resolve_attr(new_attr_idx);
08790       }
08791       new_sn_idx        = SN_SIBLING_LINK(new_sn_idx);
08792    }
08793 
08794    new_sn_idx           = ATI_FIRST_SPECIFIC_IDX(new_interface_idx);
08795    old_sn_idx           = ATI_FIRST_SPECIFIC_IDX(old_interface_idx);
08796    num_interfaces       = ATI_NUM_SPECIFICS(old_interface_idx) +
08797                           ATI_NUM_SPECIFICS(new_interface_idx);
08798    last_old_sn_idx      = old_sn_idx;
08799 
08800    while (old_sn_idx != NULL_IDX) {
08801       old_attr_idx      = SN_ATTR_IDX(old_sn_idx);
08802       sn_idx            = new_sn_idx;
08803       prev_sn_idx       = NULL_IDX;
08804       old_module_idx    = AT_MODULE_IDX(old_attr_idx);
08805 
08806       if (AT_IS_INTRIN(old_attr_idx)) {
08807          found_intrin   = TRUE;
08808       }
08809       else if (found_intrin) {
08810          move_intrin    = TRUE;
08811       }
08812 
08813       while (sn_idx != NULL_IDX) {
08814          new_attr_idx = SN_ATTR_IDX(sn_idx);
08815 
08816          if (AT_IS_INTRIN(new_attr_idx)) {
08817             found_intrin        = TRUE;
08818          }
08819          else if (found_intrin) {
08820             move_intrin = TRUE;
08821          }
08822 
08823          if ((old_attr_idx == ML_AT_IDX(new_attr_idx)) ||
08824              (AT_IS_INTRIN(old_attr_idx) && AT_IS_INTRIN(new_attr_idx))) {
08825               
08826             /* If intrinsic keep all the old intrinsics, otherwise  */
08827             /* this is the same attr as found in resolve_attr.      */
08828 
08829             num_interfaces--;
08830             ML_AT_IDX(new_attr_idx)     = old_attr_idx;
08831             ML_AT_KEEP_ME(new_attr_idx) = FALSE;
08832             sn_idx                      = SN_SIBLING_LINK(sn_idx);
08833 
08834             /* new_sn_idx is the start of the list of new specifics to keep. */
08835             /* prev_sn_idx is the last new specific to keep in the list.     */
08836             /* Skip this one by setting sn_idx to the next SN_SIBLING_LINK.  */
08837 
08838             if (prev_sn_idx == NULL_IDX) { 
08839                new_sn_idx                       = sn_idx;
08840             }
08841             else { 
08842                SN_SIBLING_LINK(prev_sn_idx)     = sn_idx;
08843             }
08844          }
08845          else if (old_module_idx != NULL_IDX) {
08846             new_module_idx = AT_MODULE_IDX(new_attr_idx);
08847 
08848             same_module = (ATP_MODULE_STR_IDX(new_module_idx) == 
08849                            ATP_MODULE_STR_IDX(old_module_idx)) ||
08850 
08851                            (AT_ATTR_LINK(new_module_idx) != NULL_IDX &&
08852                             ATP_MODULE_STR_IDX(AT_ATTR_LINK(new_module_idx)) ==
08853                             ATP_MODULE_STR_IDX(old_module_idx));
08854 
08855             if (same_module &&
08856                (compare_names(AT_ORIG_NAME_LONG(old_attr_idx),
08857                               AT_ORIG_NAME_LEN(old_attr_idx),
08858                               AT_ORIG_NAME_LONG(new_attr_idx),
08859                               AT_ORIG_NAME_LEN(new_attr_idx)) == 0)) {
08860 
08861                /* These are the same specific interfaces.  Throw out the new */
08862                /* specific.  Set merge links so that all references to the   */
08863                /* new specific will point to the old specific.               */
08864 
08865                num_interfaces--;
08866                ML_AT_IDX(new_attr_idx)          = old_attr_idx;
08867                ML_AT_KEEP_ME(new_attr_idx)      = FALSE;
08868                sn_idx                           = SN_SIBLING_LINK(sn_idx);
08869 
08870                /* new_sn_idx is the start of the list of new specifics  */
08871                /* to keep.   prev_sn_idx is the last new specific to    */
08872                /* keep in the list.  Skip this one by setting sn_idx    */
08873                /* to the next SN_SIBLING_LINK.                          */
08874 
08875                if (prev_sn_idx == NULL_IDX) { 
08876                   new_sn_idx                    = sn_idx;
08877                }
08878                else { 
08879                   SN_SIBLING_LINK(prev_sn_idx)  = sn_idx;
08880                }
08881             }
08882             else {
08883                prev_sn_idx      = sn_idx;
08884                sn_idx           = SN_SIBLING_LINK(sn_idx);
08885             }
08886          }
08887          else {
08888             prev_sn_idx = sn_idx;
08889             sn_idx      = SN_SIBLING_LINK(sn_idx);
08890          }
08891       }
08892 
08893       last_old_sn_idx   = old_sn_idx;
08894       old_sn_idx        = SN_SIBLING_LINK(old_sn_idx);
08895    }
08896 
08897    /* Attach the new interface procedures at the end */
08898    /* of the list of the old interface procedures.   */
08899 
08900    if (new_sn_idx != NULL_IDX) {
08901       SN_SIBLING_LINK(last_old_sn_idx)          = new_sn_idx;
08902       ATI_NUM_SPECIFICS(old_interface_idx)      = num_interfaces;
08903    }
08904 
08905    /* Need to replace references to new interface with old interface. */
08906    /* Clear ATI_FIRST_SPECIFIC_IDX because the list is destroyed as   */
08907    /* the new specific list was merged into the old specific list.    */
08908 
08909    ATI_FIRST_SPECIFIC_IDX(new_interface_idx)    = NULL_IDX;
08910    ATI_NUM_SPECIFICS(new_interface_idx)         = 0;
08911    ML_AT_IDX(new_interface_idx)                 = old_interface_idx;
08912    ML_AT_KEEP_ME(new_interface_idx)             = FALSE;
08913 
08914    if (move_intrin) {
08915 
08916       /* Need to move all intrinsics to the end of the interface. */
08917 
08918       new_sn_idx        = NULL_IDX;  /* The list of intrinsics */
08919       sn_idx            = NULL_IDX;  /* The end of the intrinsics */
08920       old_sn_idx        = ATI_FIRST_SPECIFIC_IDX(old_interface_idx);
08921       prev_sn_idx       = NULL_IDX;
08922 
08923       while (old_sn_idx != NULL_IDX) {
08924 
08925          if (AT_IS_INTRIN(SN_ATTR_IDX(old_sn_idx))) {
08926 
08927             if (new_sn_idx == NULL_IDX) {  /* Hook up to new list */
08928                new_sn_idx                       = old_sn_idx;    /* head */
08929             }
08930             else {
08931                SN_SIBLING_LINK(end_sn_idx)      = old_sn_idx;
08932             }
08933             end_sn_idx                          = old_sn_idx;    /* tail */
08934 
08935             if (prev_sn_idx == NULL_IDX) {
08936                ATI_FIRST_SPECIFIC_IDX(old_interface_idx) = 
08937                                           SN_SIBLING_LINK(old_sn_idx);
08938             }
08939             else {
08940                SN_SIBLING_LINK(prev_sn_idx)     = SN_SIBLING_LINK(old_sn_idx);
08941             }
08942             sn_idx                              = SN_SIBLING_LINK(old_sn_idx);
08943             SN_SIBLING_LINK(old_sn_idx)         = NULL_IDX;
08944             old_sn_idx                          = sn_idx;
08945          }
08946          else {
08947             prev_sn_idx = old_sn_idx;
08948             old_sn_idx  = SN_SIBLING_LINK(old_sn_idx);
08949          }
08950       }
08951 
08952       if (new_sn_idx != NULL_IDX) {
08953          SN_SIBLING_LINK(prev_sn_idx)   = new_sn_idx;
08954       }
08955    }
08956 
08957    TRACE (Func_Exit, "merge_interfaces", NULL);
08958 
08959    return;
08960 
08961 }  /* merge_interfaces */
08962 
08963 /******************************************************************************\
08964 |*                                                                            *|
08965 |* Description:                                                               *|
08966 |*       Combine list of new modules that came in with this module to the     *|
08967 |*       list of modules that came in, in previous USE statements.            *|
08968 |*       Issue any cautions about multiple uses of modules either             *|
08969 |*       indirectly or a directly/indirectly combination.  Also, issue        *|
08970 |*       CIF records for all indirectly used modules.                         *|
08971 |*                                                                            *|
08972 |* Input parameters:                                                          *|
08973 |*      NONE                                                                  *|
08974 |*                                                                            *|
08975 |* Output parameters:                                                         *|
08976 |*      NONE                                                                  *|
08977 |*                                                                            *|
08978 |* Returns:                                                                   *|
08979 |*      NOTHING                                                               *|
08980 |*                                                                            *|
08981 \******************************************************************************/
08982 static  void    resolve_used_modules(int        module_attr_idx)
08983 {
08984    int           attr_idx;
08985    int           list_idx;
08986    FILE         *m_ptr;
08987    int           next_idx;
08988    int           prev_idx;
08989 
08990 
08991    TRACE (Func_Entry, "resolve_used_modules", NULL);
08992 
08993    list_idx             = list_of_modules_in_module;
08994 
08995    while (list_idx != NULL_IDX) {
08996       attr_idx  = AL_ATTR_IDX(list_idx);
08997 
08998       if (ATP_SCP_ALIVE(attr_idx)) {  /* Current module */
08999          next_idx                       = AL_NEXT_IDX(list_idx);
09000 
09001          /* All occurences of attr_idx become AT_ATTR_LINK(attr_idx). */
09002 
09003 # ifdef _DEBUG
09004          if (AT_ATTR_LINK(attr_idx) == NULL_IDX) {
09005             PRINTMSG(1, 626, Internal, 0,
09006                      "nonzero AT_ATTR_LINK(attr_idx)",
09007                      "resolve_used_modules");
09008          }
09009 # endif
09010          ML_AT_IDX(attr_idx)            = AT_ATTR_LINK(attr_idx);
09011          ML_AT_KEEP_ME(attr_idx)        = FALSE;
09012          prev_idx                       = AL_PREV_MODULE_IDX(list_idx);
09013 
09014          if (prev_idx == NULL_IDX) {
09015             list_of_modules_in_module   = next_idx;
09016          }
09017          else {
09018             AL_NEXT_IDX(prev_idx)       = next_idx;
09019          }
09020 
09021          if (next_idx != NULL_IDX) {
09022             AL_PREV_MODULE_IDX(next_idx)= prev_idx;
09023          }
09024 
09025          AL_NEXT_IDX(list_idx)          = NULL_IDX;
09026          free_attr_list(list_idx);
09027          AT_ATTR_LINK(attr_idx)         = NULL_IDX;
09028          AT_IGNORE_ATTR_LINK(attr_idx)  = FALSE;
09029       }
09030       else if (AT_REFERENCED(attr_idx) == Not_Referenced ||
09031                (!ML_AT_KEEP_ME(attr_idx) && AT_ATTR_LINK(attr_idx)==NULL_IDX)) {
09032 
09033          /* This module came in multiple times and has been resolved */
09034          /* to the same module.  Remove this one from the list and   */
09035          /* only keep the resolved to module on the list.            */
09036 
09037          next_idx                       = AL_NEXT_IDX(list_idx);
09038          prev_idx                       = AL_PREV_MODULE_IDX(list_idx);
09039 
09040          /* Remove this attr from the list. */
09041 
09042          if (prev_idx == NULL_IDX) {
09043             list_of_modules_in_module   = next_idx;
09044          }
09045          else {
09046             AL_NEXT_IDX(prev_idx)       = next_idx;
09047          }
09048 
09049          if (next_idx != NULL_IDX) {
09050             AL_PREV_MODULE_IDX(next_idx)= prev_idx;
09051          }
09052 
09053          AL_NEXT_IDX(list_idx)          = NULL_IDX;
09054          free_attr_list(list_idx);
09055          AT_ATTR_LINK(attr_idx)         = NULL_IDX;
09056          AT_IGNORE_ATTR_LINK(attr_idx)  = FALSE;
09057       }
09058 
09059       /* Assumption:  Following are all indirect module references.  */
09060 
09061       else if (AT_ATTR_LINK(attr_idx) != NULL_IDX) {
09062          next_idx                       = AL_NEXT_IDX(list_idx);
09063 
09064          /* All occurences of attr_idx become AT_ATTR_LINK(attr_idx). */
09065 
09066 # ifdef _DEBUG
09067          if (AT_ATTR_LINK(attr_idx) == NULL_IDX) {
09068             PRINTMSG(1, 626, Internal, 0,
09069                      "nonzero AT_ATTR_LINK(attr_idx)",
09070                      "resolve_used_modules #2");
09071          }
09072 # endif
09073 
09074          ML_AT_IDX(attr_idx)            = AT_ATTR_LINK(attr_idx);
09075          ML_AT_KEEP_ME(attr_idx)        = FALSE;
09076 
09077          if (!ATP_INDIRECT_MODULE(attr_idx)) {
09078             ATP_INDIRECT_MODULE(AT_ATTR_LINK(attr_idx)) = FALSE;
09079          }
09080 
09081          /* Issue a caution, if this module has already been use'd */
09082          /* into this scope via another indirect reference or via  */
09083          /* a direct reference.  Remove from list.  Everything has */
09084          /* been updated to the original attr_idx already.         */
09085 
09086          PRINTMSG(AT_DEF_LINE(module_attr_idx), 878, Caution,
09087                   AT_DEF_COLUMN(module_attr_idx),
09088                   AT_OBJ_NAME_PTR(attr_idx));
09089 
09090          prev_idx                       = AL_PREV_MODULE_IDX(list_idx);
09091 
09092          if (prev_idx == NULL_IDX) {
09093             list_of_modules_in_module   = next_idx;
09094          }
09095          else {
09096             AL_NEXT_IDX(prev_idx)       = next_idx;
09097          }
09098 
09099          if (next_idx != NULL_IDX) {
09100             AL_PREV_MODULE_IDX(next_idx)= prev_idx;
09101          }
09102 
09103          AL_NEXT_IDX(list_idx)          = NULL_IDX;
09104          free_attr_list(list_idx);
09105          AT_ATTR_LINK(attr_idx)         = NULL_IDX;
09106          AT_IGNORE_ATTR_LINK(attr_idx)  = FALSE;
09107 
09108          if (cif_flags & BASIC_RECS) {  /* AT_ATTR_LINK must be NULL */
09109 
09110             /* Set so that we know this indirect module reference   */
09111             /* came thru this USE statement reference.              */
09112 
09113             AT_MODULE_IDX(attr_idx)     = module_attr_idx;
09114 
09115             cif_use_module_rec(attr_idx, NULL_IDX, TRUE);
09116 
09117             if ((cif_flags & XREF_RECS) != 0) {
09118                cif_usage_rec(attr_idx,
09119                              AT_Tbl_Idx,
09120                              AT_DEF_LINE(module_attr_idx),
09121                              AT_DEF_COLUMN(module_attr_idx),
09122                              CIF_Symbol_Is_Hidden_Used_Module);
09123             }
09124          }
09125       }
09126       else {
09127          next_idx                       = AL_NEXT_IDX(list_idx);
09128 
09129          /* Check if the compiled module file still exists.      */
09130 
09131          if (ATP_MOD_PATH_IDX(attr_idx) != NULL_IDX) {
09132             m_ptr = fopen(ATP_MOD_PATH_NAME_PTR(attr_idx), "rb");
09133 
09134             if (m_ptr == NULL) {
09135                PRINTMSG(AT_DEF_LINE(module_attr_idx), 1193, Caution,
09136                         AT_DEF_COLUMN(module_attr_idx),
09137                         AT_OBJ_NAME_PTR(attr_idx),
09138                         AT_OBJ_NAME_PTR(module_attr_idx),
09139                         ATP_MOD_PATH_NAME_PTR(attr_idx));
09140             }
09141             else {
09142                fclose(m_ptr);
09143             }
09144          }
09145 
09146          if (cif_flags & BASIC_RECS) {  /* AT_ATTR_LINK must be NULL */
09147 
09148             /* Set so that we know this indirect module reference   */
09149             /* came thru this USE statement reference.              */
09150 
09151             AT_MODULE_IDX(attr_idx)             = module_attr_idx;
09152             ATP_INDIRECT_MODULE(attr_idx)       = TRUE;
09153 
09154             cif_use_module_rec(attr_idx, NULL_IDX, TRUE);
09155 
09156             if ((cif_flags & XREF_RECS) != 0) {
09157                cif_usage_rec(attr_idx,
09158                              AT_Tbl_Idx,
09159                              AT_DEF_LINE(module_attr_idx),
09160                              AT_DEF_COLUMN(module_attr_idx),
09161                              CIF_Symbol_Is_Hidden_Used_Module);
09162             }
09163          }
09164       }
09165 
09166       list_idx          = next_idx;
09167    }
09168 
09169    /* Add modules brought in by this module to complete list of modules. */
09170 
09171    list_idx = SCP_USED_MODULE_LIST(curr_scp_idx);
09172 
09173    while (list_idx != NULL_IDX) {
09174 
09175       if (AL_NEXT_IDX(list_idx) == NULL_IDX) {
09176          AL_NEXT_IDX(list_idx) = list_of_modules_in_module;
09177          AL_PREV_MODULE_IDX(list_of_modules_in_module) = list_idx;
09178          break;
09179       }
09180       list_idx = AL_NEXT_IDX(list_idx);
09181    }
09182 
09183    list_of_modules_in_module = NULL_IDX;
09184 
09185    TRACE (Func_Exit, "resolve_used_modules", NULL);
09186 
09187    return;
09188 
09189 }  /* resolve_used_modules */
09190 
09191 /******************************************************************************\
09192 |*                                                                            *|
09193 |* Description:                                                               *|
09194 |*                                                                            *|
09195 |* Input parameters:                                                          *|
09196 |*                                                                            *|
09197 |* Output parameters:                                                         *|
09198 |*      NONE                                                                  *|
09199 |*                                                                            *|
09200 |* Returns:                                                                   *|
09201 |*      NOTHING                                                               *|
09202 |*                                                                            *|
09203 \******************************************************************************/
09204 static  boolean resolve_attr(int        attr_idx)
09205 
09206 {
09207    int          il_idx;
09208    boolean      found_attr      = FALSE;
09209    int          name_idx;
09210    int          np_idx;
09211    int          old_name_idx;
09212    int          sn_idx;
09213    int          srch_attr_idx;
09214    int          srch_il_idx;
09215    int          srch_sn_idx;
09216 
09217 
09218    TRACE (Func_Entry, "resolve_attr", NULL);
09219 
09220    /* Do not resolve attr linked objects.  What  */
09221    /* they are attr linked to will get resolved. */
09222 
09223    /* Also, we are only looking to resolve use associated variables. */
09224 
09225    if (!AT_MODULE_OBJECT(attr_idx) || AT_ATTR_LINK(attr_idx) != NULL_IDX) {
09226       goto EXIT;
09227    }
09228 
09229    switch (AT_OBJ_CLASS(attr_idx)) {
09230    case Data_Obj:
09231 
09232       switch (ATD_CLASS(attr_idx)) {
09233       case Function_Result:
09234       case Dummy_Argument:
09235       case Struct_Component:
09236          goto EXIT;
09237 
09238       case Constant:
09239 
09240          if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX ||
09241              TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure) {
09242 
09243              /* This is a structure or array constructor and has a tmp */
09244              /* associated with it that has the same name.  Search on  */
09245              /* the tmp, since the tmp points to this constant attr.   */
09246 
09247             goto EXIT;
09248          }
09249          break;
09250 
09251       default:
09252          break;
09253       }
09254       break;
09255 
09256    case Pgm_Unit:
09257 
09258       if (AT_IS_INTRIN(attr_idx) || ATP_PROC(attr_idx) == Dummy_Proc) {
09259          goto EXIT;
09260       }
09261       break;
09262 
09263    case Interface:
09264    case Label:
09265       goto EXIT;
09266 
09267    }  /* End switch */
09268 
09269    /* If this attr belongs in the local name table, do not search the local */
09270    /* name table for it.  If this is use stmt processing, the check is done */
09271    /* when the new name table entries are merged together.  If this is      */
09272    /* interface processing, the only entry that has ML_AT_LN_NAME set is    */
09273    /* interface body and we don't need to search for that, because the LN   */
09274    /* entry points to the same attr as the input attr entry.                */
09275 
09276    if (!ML_AT_LN_NAME(attr_idx)) {
09277       srch_attr_idx             = srch_sym_tbl(AT_OBJ_NAME_PTR(attr_idx),
09278                                                AT_NAME_LEN(attr_idx),
09279                                                &name_idx);
09280       if (srch_attr_idx != NULL_IDX) {
09281 
09282          if (srch_attr_idx == attr_idx) {
09283 
09284             /* Exit with FALSE, because we just found this attr. */
09285 
09286             goto EXIT;
09287          }
09288 
09289          if (AT_MODULE_OBJECT(srch_attr_idx) &&
09290              ATP_MODULE_STR_IDX(AT_MODULE_IDX(srch_attr_idx)) ==
09291                                 ATP_MODULE_STR_IDX(AT_MODULE_IDX(attr_idx))) {
09292 
09293             /* The attr from the local name table has the same local name and */
09294             /* is from the same module.  See if the orig name is the same.    */
09295 
09296             if (AT_OBJ_CLASS(srch_attr_idx) == AT_OBJ_CLASS(attr_idx) &&
09297                 (compare_names(AT_ORIG_NAME_LONG(srch_attr_idx),
09298                                AT_ORIG_NAME_LEN(srch_attr_idx),
09299                                AT_ORIG_NAME_LONG(attr_idx),
09300                                AT_ORIG_NAME_LEN(attr_idx)) == 0)) {
09301                 found_attr      = TRUE;
09302                 goto FOUND;
09303             }
09304          }
09305       }
09306    }
09307 
09308    /* This attr has come through once already.  Attrs may come through      */
09309    /* multiple times if they are associated with another attr and they      */
09310    /* have their own entries in the local name table.  The attr may come    */
09311    /* thru during the local name table search and then it may be referenced */
09312    /* as part of a bound expression for another attr entry.  This stops     */
09313    /* them from being searched twice.                                       */
09314 
09315    if (ML_AT_SEARCHED(attr_idx)) {
09316       goto EXIT;
09317    }
09318 
09319    srch_attr_idx = NULL_IDX;
09320    srch_attr_idx = srch_hidden_name_tbl(AT_OBJ_NAME_PTR(attr_idx),
09321                                         AT_NAME_LEN(attr_idx),
09322                                         srch_attr_idx,
09323                                         &np_idx,
09324                                         &name_idx);
09325 
09326    if (srch_attr_idx != NULL_IDX) {  /* Found the name in hidden name tbl. */
09327 
09328       /* Check to see if we can find the same object.  The hidden name */
09329       /* table may have the same name entered multiple times.          */
09330 
09331       do {
09332          srch_attr_idx  = HN_ATTR_IDX(name_idx);
09333 
09334          if (srch_attr_idx == attr_idx) {
09335 
09336             /* Exit with FALSE, because we just found this attr. */
09337 
09338             goto EXIT;
09339          }
09340 
09341          if (AT_OBJ_CLASS(srch_attr_idx) == AT_OBJ_CLASS(attr_idx) &&
09342              ATP_MODULE_STR_IDX(AT_MODULE_IDX(srch_attr_idx)) ==
09343                                 ATP_MODULE_STR_IDX(AT_MODULE_IDX(attr_idx)) &&
09344              (compare_names(AT_ORIG_NAME_LONG(srch_attr_idx),
09345                             AT_ORIG_NAME_LEN(srch_attr_idx),
09346                             AT_ORIG_NAME_LONG(attr_idx),
09347                             AT_ORIG_NAME_LEN(attr_idx)) == 0)) {
09348             found_attr = TRUE;
09349 
09350             /* This name is going to be in the local name      */
09351             /* table, so remove it from the hidden name table. */
09352 
09353             if (ML_AT_LN_NAME(attr_idx)) {
09354                remove_hidden_name_ntry(name_idx);
09355             }
09356             goto FOUND;
09357          }
09358          old_name_idx = name_idx;
09359          name_idx++;
09360       }
09361       while (HN_NAME_IDX(old_name_idx) == HN_NAME_IDX(name_idx));
09362 
09363       name_idx = old_name_idx;
09364    }
09365 
09366    /* Not in either table.  Put in hidden name table, if not in ln name tbl. */
09367 
09368    if (!ML_AT_LN_NAME(attr_idx)) {
09369       ntr_hidden_name_tbl(attr_idx,
09370                           np_idx,
09371                           name_idx);
09372    }
09373 
09374    goto EXIT;
09375 
09376 FOUND:
09377 
09378    ML_AT_IDX(attr_idx)          = srch_attr_idx;
09379    ML_AT_KEEP_ME(attr_idx)      = FALSE;
09380 
09381 
09382    switch (AT_OBJ_CLASS(attr_idx)) {
09383    case Data_Obj:
09384 
09385       if (ATD_CLASS(attr_idx) == Variable && 
09386           ATD_VARIABLE_TMP_IDX(attr_idx) != NULL_IDX) {
09387 
09388          if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
09389             ML_AT_IDX(ATD_VARIABLE_TMP_IDX(attr_idx)) =
09390                       ATD_VARIABLE_TMP_IDX(srch_attr_idx);
09391             ML_AT_KEEP_ME(ATD_VARIABLE_TMP_IDX(attr_idx))       = FALSE;
09392          }
09393          else if (ATD_FLD(attr_idx) == IL_Tbl_Idx) {
09394             il_idx      = ATD_VARIABLE_TMP_IDX(attr_idx);
09395             srch_il_idx = ATD_VARIABLE_TMP_IDX(srch_attr_idx);
09396 
09397             while (il_idx != NULL_IDX) {
09398                ML_AT_IDX(IL_IDX(il_idx))          = IL_IDX(srch_il_idx);
09399                ML_AT_KEEP_ME(IL_IDX(il_idx))      = FALSE;
09400                il_idx                   = IL_NEXT_LIST_IDX(il_idx);
09401                srch_il_idx              = IL_NEXT_LIST_IDX(srch_il_idx);
09402             }
09403          }
09404       }
09405 
09406       if (ATD_CLASS(attr_idx) == Constant && ATD_FLD(attr_idx) == AT_Tbl_Idx) {
09407          ML_AT_IDX(ATD_CONST_IDX(attr_idx))     = ATD_CONST_IDX(srch_attr_idx);
09408          ML_AT_KEEP_ME(ATD_CONST_IDX(attr_idx)) = FALSE;
09409       }
09410 
09411       if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure) {
09412          /* KAY, I added this because derived types were not always resolved */
09413          /*     BHJ */
09414 
09415          resolve_all_components(attr_idx, srch_attr_idx);
09416       }
09417 
09418       break;
09419 
09420    case Pgm_Unit:
09421 
09422       if (ATP_PGM_UNIT(attr_idx) == Function ||
09423           ATP_PGM_UNIT(attr_idx) == Subroutine) {
09424          srch_sn_idx    = ATP_FIRST_IDX(srch_attr_idx);
09425 
09426          for (sn_idx = ATP_FIRST_IDX(attr_idx); 
09427               sn_idx < (ATP_FIRST_IDX(attr_idx) + ATP_NUM_DARGS(attr_idx));
09428               sn_idx++) {
09429 
09430             ML_AT_IDX(SN_ATTR_IDX(sn_idx))      = SN_ATTR_IDX(srch_sn_idx);
09431             ML_AT_KEEP_ME(SN_ATTR_IDX(sn_idx))  = FALSE;
09432             srch_sn_idx++;
09433          }
09434 
09435          if (ATP_PGM_UNIT(attr_idx) == Function){
09436             ML_AT_IDX(ATP_RSLT_IDX(attr_idx))     = ATP_RSLT_IDX(srch_attr_idx);
09437             ML_AT_KEEP_ME(ATP_RSLT_IDX(attr_idx)) = FALSE;
09438          }
09439       }
09440       break;
09441 
09442    case Derived_Type:
09443       sn_idx            = ATT_FIRST_CPNT_IDX(attr_idx);
09444       srch_sn_idx       = ATT_FIRST_CPNT_IDX(srch_attr_idx);
09445 
09446       while (sn_idx != NULL_IDX && srch_sn_idx != NULL_IDX) {
09447          ML_AT_IDX(SN_ATTR_IDX(sn_idx))          = SN_ATTR_IDX(srch_sn_idx);
09448          ML_AT_KEEP_ME(SN_ATTR_IDX(sn_idx))      = FALSE;
09449          sn_idx                                  = SN_SIBLING_LINK(sn_idx);
09450          srch_sn_idx                             = SN_SIBLING_LINK(srch_sn_idx);
09451       }
09452       break;
09453 
09454    }  /* End switch */
09455 
09456 EXIT:
09457 
09458    ML_AT_SEARCHED(attr_idx)     = TRUE;
09459 
09460    TRACE (Func_Exit, "resolve_attr", NULL);
09461 
09462    return(found_attr);
09463 
09464 }  /* resolve_attr */
09465 
09466 /******************************************************************************\
09467 |*                                                                            *|
09468 |* Description:                                                               *|
09469 |*      <description>                                                         *|
09470 |*                                                                            *|
09471 |* Input parameters:                                                          *|
09472 |*      NONE                                                                  *|
09473 |*                                                                            *|
09474 |* Output parameters:                                                         *|
09475 |*      NONE                                                                  *|
09476 |*                                                                            *|
09477 |* Returns:                                                                   *|
09478 |*      NOTHING                                                               *|
09479 |*                                                                            *|
09480 \******************************************************************************/
09481 
09482 static void resolve_all_components(int          attr_idx,
09483                                    int          srch_attr_idx)
09484 
09485 {
09486    int          dt_idx;
09487    int          sn_idx;
09488    int          srch_dt_idx;
09489    int          srch_sn_idx;
09490 
09491    TRACE (Func_Entry, "resolve_all_components", NULL);
09492 
09493    dt_idx      = TYP_IDX(ATD_TYPE_IDX(attr_idx));
09494    srch_dt_idx = TYP_IDX(ATD_TYPE_IDX(srch_attr_idx));
09495 
09496    sn_idx      = ATT_FIRST_CPNT_IDX(dt_idx);
09497    srch_sn_idx = ATT_FIRST_CPNT_IDX(srch_dt_idx);
09498 
09499    while (sn_idx != NULL_IDX && srch_sn_idx != NULL_IDX) {
09500       ML_AT_IDX(SN_ATTR_IDX(sn_idx))     = SN_ATTR_IDX(srch_sn_idx);
09501       ML_AT_KEEP_ME(SN_ATTR_IDX(sn_idx)) = FALSE;
09502       
09503       if (TYP_TYPE(ATD_TYPE_IDX(SN_ATTR_IDX(sn_idx))) == Structure) {
09504          resolve_all_components(SN_ATTR_IDX(sn_idx), SN_ATTR_IDX(srch_sn_idx));
09505       }
09506       sn_idx                             = SN_SIBLING_LINK(sn_idx);
09507       srch_sn_idx                        = SN_SIBLING_LINK(srch_sn_idx);
09508    }
09509 
09510 
09511    TRACE (Func_Exit, "resolve_all_components", NULL);
09512 
09513    return;
09514 
09515 }  /* resolve_all_components */
09516 
09517 /******************************************************************************\
09518 |*                                                                            *|
09519 |* Description:                                                               *|
09520 |*                                                                            *|
09521 |* Input parameters:                                                          *|
09522 |*                                                                            *|
09523 |* Output parameters:                                                         *|
09524 |*      NONE                                                                  *|
09525 |*                                                                            *|
09526 |* Returns:                                                                   *|
09527 |*      NOTHING                                                               *|
09528 |*                                                                            *|
09529 \******************************************************************************/
09530 void    collapse_interface_blk(int      interface_idx)
09531 
09532 {
09533    int           al_idx;
09534    int           attr_idx;
09535    int           bd_idx;
09536    int           cn_idx;
09537    int           ln_idx;
09538    int           name_idx;
09539    int           sn_idx;
09540 
09541 
09542    TRACE (Func_Entry, "collapse_interface_blk", NULL);
09543 
09544    if (interface_idx == NULL_IDX) {
09545       return;
09546    }
09547 
09548    /* This is used to tell parts of module processing to keep IR and SH for */
09549    /* used module and internal procedures.  Since collapse_interface_blk    */
09550    /* also uses parts of module processing, this flag needs to be set if    */
09551    /* we're going to keep IR/SH for inlining.                               */
09552 
09553    keep_module_procs = (opt_flags.inline_lvl > Inline_Lvl_0) ||
09554                         ATP_MAY_INLINE(SCP_ATTR_IDX(MAIN_SCP_IDX));
09555 
09556    allocate_mod_link_tbl(0);  /* Let routine determine size. */
09557    only_update_new_tbl_entries  = TRUE;
09558 
09559    ML_AT_IDX(0)         = BLK_AT_IDX(blk_stk_idx);
09560    ML_BD_IDX(0)         = BLK_BD_IDX(blk_stk_idx);
09561    ML_NP_IDX(0)         = BLK_NP_IDX(blk_stk_idx);
09562    ML_SB_IDX(0)         = BLK_SB_IDX(blk_stk_idx);
09563    ML_SN_IDX(0)         = BLK_SN_IDX(blk_stk_idx);
09564    ML_TYP_IDX(0)        = BLK_TYP_IDX(blk_stk_idx);
09565 
09566    /* This prevents the SH, LN, IR, IL, and Constant tables, and the constant */
09567    /* pool from being compressed.                                             */
09568 
09569    ML_LN_IDX(0)         = SCP_LN_LW_IDX(curr_scp_idx);
09570    ML_IR_IDX(0)         = ir_tbl_idx;
09571    ML_IL_IDX(0)         = ir_list_tbl_idx;
09572    ML_SH_IDX(0)         = sh_tbl_idx;
09573    ML_CN_IDX(0)         = const_tbl_idx;
09574    ML_CP_IDX(0)         = const_pool_idx;
09575 
09576    /* Because we do not collapse the constant table, there are some obscure */
09577    /* cases where we keep a constant table, but not its type.  This takes   */
09578    /* care of that problem.                                                 */
09579 
09580    for (cn_idx = BLK_CN_IDX(blk_stk_idx); cn_idx <= const_tbl_idx; cn_idx++) {
09581       set_mod_link_tbl_for_typ(CN_TYPE_IDX(cn_idx));
09582    }
09583 
09584    /* BHJ - Temp - Force calls to resolve_attr */
09585 
09586    for (attr_idx = ML_AT_IDX(0); attr_idx <= attr_tbl_idx; attr_idx++) {
09587       ML_AT_SEARCH_ME(attr_idx) = TRUE;
09588    }
09589 
09590    /* There are a few obscure cases, like a label on the end interface that */
09591    /* gets added after the attr table index is trapped.  Catch any attrs    */
09592    /* that were added after the attr table index was trapped and make sure  */
09593    /* they get kept.                                                        */
09594 
09595    for (ln_idx = SCP_LN_FW_IDX(curr_scp_idx) + 1;
09596         ln_idx < SCP_LN_LW_IDX(curr_scp_idx); ln_idx++) {
09597 
09598       if (LN_ATTR_IDX(ln_idx) > ML_AT_IDX(0)) { 
09599          KEEP_ATTR(LN_ATTR_IDX(ln_idx));
09600       }
09601    }
09602 
09603    /* The interface body attr may be in the main table before we marked   */
09604    /* the start of the attr table for the interface body.  Set ML_AT_IDX  */
09605    /* just in case.  If it is in the compressed part it will get a new    */
09606    /* index.  Mark SN_KEEP_ME for the interface secondary entry, because  */
09607    /* it is added after the secondary name table start is marked for the  */
09608    /* interface body.  If we don't do this, the SN entry will get         */
09609    /* compressed out, because nothing in the interface body references it.*/
09610 
09611    sn_idx = ATI_FIRST_SPECIFIC_IDX(interface_idx);
09612 
09613    while (sn_idx != NULL_IDX) {
09614       ML_SN_KEEP_ME(sn_idx)     = TRUE;
09615       attr_idx                  = SN_ATTR_IDX(sn_idx);
09616       ML_AT_IDX(attr_idx)       = attr_idx;
09617 
09618       /* This name is in the local name table, so should not be hidden.   */
09619 
09620       ML_AT_LN_NAME(attr_idx)   = TRUE;
09621 
09622       /* The only non-hidden thing we need from this interface body is    */
09623       /* the name of the interface body.  set_mod_link_tbl_for_attr will  */
09624       /* call itself for all related attrs to this interface body attr.   */
09625 
09626       KEEP_ATTR(attr_idx);
09627 
09628       sn_idx                    = SN_SIBLING_LINK(sn_idx);
09629    }
09630 
09631    /* ATI_FIRST_SPECIFIC_IDX is set on the intrinsic entry if it has been */
09632    /* expanded.  These cannot be collapsed so we keep expanded_intrinsic_ */
09633    /* list so that we can make sure these entries get kept.               */
09634 
09635    al_idx       = expanded_intrinsic_list;
09636 
09637    while (al_idx != NULL_IDX) {
09638       KEEP_ATTR(AL_ATTR_IDX(al_idx));
09639       al_idx    = AL_NEXT_IDX(al_idx);
09640    }
09641 
09642    /* Keep everything on the bounds table free list.  It's easier to keep */
09643    /* it, than to attempt to collapse it out, because we do not know if   */
09644    /* the free entries are in the area being collapsed or in the area     */
09645    /* being left alone.                                                   */
09646 
09647    bd_idx       = BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX);
09648 
09649    while (bd_idx != NULL_IDX) {
09650       ML_BD_KEEP_ME(bd_idx)     = TRUE;
09651       bd_idx                    = BD_NEXT_FREE_NTRY(bd_idx);
09652    }
09653 
09654    save_const_pool_idx          = NULL_IDX;
09655    save_const_tbl_idx           = NULL_IDX;
09656    num_module_derived_types     = 0;
09657    count_derived_types          = TRUE;
09658 
09659    /* Resolve duplicate attrs. */
09660 
09661    assign_new_idxs(TRUE);
09662 
09663    /* Do table compression, but do not update the attribute entries in the    */
09664    /* attr_list_tbl.  Stop updating from happening, by passing the last       */
09665    /* used index in attr_list_tbl.  compress_tbls goes through the attr       */
09666    /* list table starting at the entry past the entry passed in.              */
09667 
09668    compress_tbls(NULL_IDX,      /* NULL means don't touch the attr_list_tbl.  */
09669                  TRUE);         /* Collapsing an interface block.             */
09670 
09671    num_of_derived_types        += num_module_derived_types;
09672    num_module_derived_types     = 0;
09673 
09674    /* We are looking for items in this list that are out of the collapse area */
09675    /* but might point into the collapsed area.  Update if they are found.     */
09676    /* Pick up sn_idx first so we can check if this sn entry needs updating.   */
09677 
09678    if (interface_idx <= BLK_AT_IDX(blk_stk_idx)) {
09679       update_idxs_in_attr_entry(interface_idx, interface_idx);
09680    }
09681 
09682    sn_idx       = ATI_FIRST_SPECIFIC_IDX(interface_idx);
09683 
09684    while (sn_idx != NULL_IDX) {
09685 
09686       if (sn_idx <= BLK_SN_IDX(blk_stk_idx)) {
09687          SN_SIBLING_LINK(sn_idx)        = ML_SN_IDX(SN_SIBLING_LINK(sn_idx));
09688          SN_ATTR_IDX(sn_idx)            = ML_AT_IDX(SN_ATTR_IDX(sn_idx));
09689       }
09690 
09691       if (SN_ATTR_IDX(sn_idx) <= BLK_AT_IDX(blk_stk_idx)) {
09692          update_idxs_in_attr_entry(SN_ATTR_IDX(sn_idx), SN_ATTR_IDX(sn_idx));
09693       }
09694       sn_idx = SN_SIBLING_LINK(sn_idx);
09695    }
09696 
09697    BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX) = 
09698                              ML_BD_IDX(BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX));
09699 
09700    /* attr_idx is the interface body.  Find its compressed index and      */
09701    /* replace the local name table entry with the compressed indexes.     */
09702 
09703    for (name_idx = SCP_LN_FW_IDX(curr_scp_idx) + 1;
09704         name_idx < SCP_LN_LW_IDX(curr_scp_idx); name_idx++) {
09705 
09706       /* Update local name table entries pointing to the interface bodies. */
09707       /* Since we didn't touch the LN table, these need to be updated.     */
09708 
09709       LN_ATTR_IDX(name_idx)     = ML_AT_IDX(LN_ATTR_IDX(name_idx));
09710       LN_NAME_IDX(name_idx)     = ML_NP_IDX(LN_NAME_IDX(name_idx));
09711 
09712 # ifdef _DEBUG
09713 
09714       if (LN_ATTR_IDX(name_idx) == NULL_IDX) {
09715          PRINTMSG(AT_DEF_LINE(SCP_ATTR_IDX(curr_scp_idx)), 1421, Internal,
09716                   AT_DEF_COLUMN(SCP_ATTR_IDX(curr_scp_idx)), name_idx);
09717       }
09718 # endif
09719      
09720    }
09721 
09722    al_idx       = expanded_intrinsic_list;
09723 
09724    while (al_idx != NULL_IDX) {
09725       sn_idx    = ATI_FIRST_SPECIFIC_IDX(AL_ATTR_IDX(al_idx));
09726 
09727       ATI_FIRST_SPECIFIC_IDX(AL_ATTR_IDX(al_idx)) = 
09728                          ML_SN_IDX(ATI_FIRST_SPECIFIC_IDX(AL_ATTR_IDX(al_idx)));
09729       ATI_PROC_IDX(interface_idx) = ML_AT_IDX(ATI_PROC_IDX(interface_idx));
09730       ATD_TYPE_IDX(interface_idx) = ML_TYP_IDX(ATD_TYPE_IDX(interface_idx));
09731 
09732 # if 0
09733       while (sn_idx != NULL_IDX) {
09734 
09735          if (sn_idx <= BLK_SN_IDX(blk_stk_idx)) {
09736             SN_SIBLING_LINK(sn_idx)     = ML_SN_IDX(SN_SIBLING_LINK(sn_idx));
09737             SN_ATTR_IDX(sn_idx)         = ML_AT_IDX(SN_ATTR_IDX(sn_idx));
09738          }
09739          sn_idx = SN_SIBLING_LINK(sn_idx);
09740       }
09741 # endif
09742 
09743       al_idx    = AL_NEXT_IDX(al_idx);
09744    }
09745 
09746    if (!SCP_IS_INTERFACE(curr_scp_idx)) {
09747 
09748       /* This is not a nested interface, so free the table. */
09749 
09750       TBL_FREE(mod_link_tbl);
09751    }
09752    else {
09753 
09754       /* Nested interface block.  We need to save the ML(0) entries to */
09755       /* compress the outer interface body blocks.                     */
09756 
09757       mod_link_tbl_idx = 1;
09758    }
09759 
09760    only_update_new_tbl_entries  = FALSE;
09761 
09762    TRACE (Func_Exit, "collapse_interface_blk", NULL);
09763 
09764    return;
09765 
09766 }  /* collapse_interface_blk */
09767 
09768 /******************************************************************************\
09769 |*                                                                            *|
09770 |* Description:                                                               *|
09771 |*                                                                            *|
09772 |* Input parameters:                                                          *|
09773 |*                                                                            *|
09774 |* Output parameters:                                                         *|
09775 |*      NONE                                                                  *|
09776 |*                                                                            *|
09777 |* Returns:                                                                   *|
09778 |*      NOTHING                                                               *|
09779 |*                                                                            *|
09780 \******************************************************************************/
09781 static  void    compress_type_tbl(int   start_type_idx)
09782 
09783 {
09784    int          i;
09785    int          idx;
09786    boolean      found;
09787    int          new_type_idx;
09788    long        *null_base;
09789    int          type_idx;
09790    long        *type_tbl_base;
09791 
09792 
09793    TRACE (Func_Entry, "compress_type_tbl", NULL);
09794 
09795    new_type_idx = start_type_idx + 1;
09796 
09797    for (type_idx = new_type_idx; type_idx <= type_tbl_idx; type_idx++) {
09798 
09799       if (!ML_TYP_KEEP_ME(type_idx)) {
09800          continue;
09801       }
09802 
09803       if (TYP_TYPE(type_idx) == Character) {
09804 
09805          if (TYP_FLD(type_idx) == CN_Tbl_Idx) {
09806             TYP_IDX(type_idx) = ML_CN_IDX(TYP_IDX(type_idx));
09807          }
09808          else if (TYP_FLD(type_idx) == AT_Tbl_Idx) {
09809             TYP_IDX(type_idx)           = ML_AT_IDX(TYP_IDX(type_idx));
09810             TYP_ORIG_LEN_IDX(type_idx)  = ML_AT_IDX(TYP_ORIG_LEN_IDX(type_idx));
09811          }
09812       }
09813       else if (TYP_TYPE(type_idx) == Structure) {
09814          TYP_IDX(type_idx) = ML_AT_IDX(TYP_IDX(type_idx));
09815       }
09816 
09817       found     = FALSE;
09818       null_base = (long *) &(type_tbl[type_idx]);
09819 
09820       for (idx = 1; idx <= start_type_idx; idx++) {
09821          found          = TRUE;
09822          type_tbl_base  = (long *) &(type_tbl[idx]);
09823 
09824          for (i = 0; i < NUM_TYP_WDS; i++) {
09825 
09826             if (null_base[i] != type_tbl_base[i]) {
09827                 found = FALSE;
09828             }
09829          }
09830 
09831          if (found) {
09832             break;
09833          }
09834       }
09835 
09836       if (!found) {
09837          idx            = new_type_idx++;
09838          type_tbl[idx]  = type_tbl[type_idx];
09839       }
09840       
09841       ML_TYP_IDX(type_idx)      = idx;
09842    }
09843 
09844    /* Set the correct end of the type table. */
09845 
09846    type_tbl_idx         = new_type_idx - 1;
09847 
09848    TRACE (Func_Exit, "compress_type_tbl", NULL);
09849 
09850    return;
09851 
09852 }  /* compress_type_tbl */
09853 
09854 /******************************************************************************\
09855 |*                                                                            *|
09856 |* Description:                                                               *|
09857 |*      find_files_in_directory checks each file in a directory for possible  *|
09858 |*                 search candidates for inline and module files.             *|
09859 |*                                                                            *|
09860 |* Input parameters:                                                          *|
09861 |*      dir_idx    Index to fp table of the directory to expand.              *|
09862 |*                                                                            *|
09863 |* Output parameters:                                                         *|
09864 |*      NONE                                                                  *|
09865 |*                                                                            *|
09866 |* Returns:                                                                   *|
09867 |*      NOTHING                                                               *|
09868 |*                                                                            *|
09869 \******************************************************************************/
09870 
09871 static  void    find_files_in_directory(int     dir_idx)
09872 
09873 {
09874 
09875 
09876                 DIR     *dirp;          /* Directory pointer */
09877    struct       dirent  *direntp;
09878                 int      fp_idx;
09879                 boolean  mod_file;
09880                 int      new_fp_idx;
09881                 boolean  okay;
09882                 char     path[1024];
09883    struct       stat     stat_buf;
09884                 char    *suffix;
09885 
09886 
09887    TRACE (Func_Entry, "find_files_in_directory", NULL);
09888 
09889    if (! is_directory(FP_NAME_PTR(dir_idx))) {
09890 
09891       /* Leave class as Unknown_Fp.  This will */
09892       /* get set in find_prog_unit_tbl.        */
09893 
09894       return;
09895    }
09896 
09897    dirp                 = opendir(FP_NAME_PTR(dir_idx));
09898    fp_idx               = NULL_IDX;
09899    FP_CLASS(dir_idx)    = Directory_Fp;
09900 
09901    while ( (direntp = readdir( dirp )) != NULL ) {
09902 
09903       /* Check to see if the file should be added to the list of files to  */
09904       /* search for modules and inline program units.  The check makes     */
09905       /* sure it is a regular file.  It throw out directories.             */
09906 
09907       /* Construct the full path name of the file.  Basically this is the  */
09908       /* directory name '/' file name.  If the directory name does not     */
09909       /* start with a '/', insert a './' to make it a relative path name.  */
09910 
09911       if (EQUAL_STRS(FP_NAME_PTR(dir_idx), "./")) {
09912          strcpy(path, FP_NAME_PTR(dir_idx));
09913       }
09914       else if (FP_NAME(dir_idx) != '/') {
09915          strcpy(path, "./");
09916          strcat(path, FP_NAME_PTR(dir_idx));
09917          strcat(path, "/");
09918       }
09919       else {
09920          strcpy(path, FP_NAME_PTR(dir_idx));
09921          strcat(path, "/");
09922       }
09923 
09924       strcat(path, direntp->d_name);
09925 
09926       stat(path, &stat_buf);
09927 
09928       if ((stat_buf.st_mode & S_IFMT) == S_IFREG) {
09929 
09930          /* This returns a pointer to the last occurence */
09931          /* of a dot in the path.                        */
09932 
09933          suffix = strrchr (direntp->d_name, DOT);
09934 
09935          /* The suffix can be .a, .inl, .o, .M  or .mod depending on the host */
09936          /* machine.  For example, .a is not recognized on IRIX machines.     */
09937 
09938          if (suffix != NULL) {
09939             okay        = FALSE;
09940             mod_file    = FALSE;
09941 
09942             if (inline_search && EQUAL_STRS(suffix, ".inl")) { 
09943                okay = TRUE;
09944             }
09945 
09946 # if !(defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX))
09947             else if (EQUAL_STRS(suffix, ".a")) {
09948                okay = TRUE;
09949             }
09950 # endif
09951 /* when running mfef90 on Solaris, it's default that 
09952  * on_off_flags.module_to_mod == FALSE, as a result, when compiling a .f
09953  * file containing "use ***", and that *** module is in a .mod file (since
09954  * we've already compiled it with -em flag), mfef90 will FAIL to find
09955  * that .mod file and retrieve that module ***.
09956  * So, we need to add -em flag even when compiling such files!
09957  */
09958             else if (on_off_flags.module_to_mod && EQUAL_STRS(suffix, module_suffix_fix)) {
09959                mod_file = TRUE;
09960                okay     = TRUE;
09961             }
09962 
09963 # if defined(_MODULE_TO_DOT_o)
09964             else if ((!on_off_flags.module_to_mod || FP_SYSTEM_FILE(dir_idx)) &&
09965                       EQUAL_STRS(suffix, ".o")) {
09966                okay = TRUE;
09967             }
09968 # elif defined(_MODULE_TO_DOT_M)
09969             else if (!on_off_flags.module_to_mod && EQUAL_STRS(suffix, ".M")) {
09970                okay = TRUE;
09971             }
09972 # endif
09973             if (okay) {
09974                new_fp_idx       = ntr_file_in_fp_tbl(dir_idx, path, fp_idx);
09975                fp_idx           = new_fp_idx;
09976 
09977                if (mod_file) {
09978                   FP_CLASS(fp_idx)      = Mod_File_Fp;
09979                }
09980             }
09981          }
09982       }
09983    }
09984 
09985    FP_SRCH_THE_FILE(dir_idx)    = FALSE;
09986 
09987    (void) closedir(dirp);
09988 
09989    TRACE (Func_Exit, "find_files_in_directory", NULL);
09990 
09991    return;
09992 
09993 } /* find_files_in_directory */
09994 
09995 /******************************************************************************\
09996 |*                                                                            *|
09997 |* Description:                                                               *|
09998 |*      ntr_file_in_fp_tbl adds a file to its directory in the file path tbl  *|
09999 |*                                                                            *|
10000 |* Input parameters:                                                          *|
10001 |*      dir_idx       fp table index describing directory being searched.     *|
10002 |*      path          path to directory being searched.                       *|
10003 |*      fp_idx        fp table index of prev file found in this dir.          *|
10004 |*                                                                            *|
10005 |* Output parameters:                                                         *|
10006 |*      NONE                                                                  *|
10007 |*                                                                            *|
10008 |* Returns:                                                                   *|
10009 |*      fp_idx        fp table index of file just added to this dir's list.   *|
10010 |*                                                                            *|
10011 \******************************************************************************/
10012 static  int     ntr_file_in_fp_tbl(int           dir_idx,
10013                                    char         *path,
10014                                    int          fp_idx)
10015 {
10016    long         length;
10017 
10018 
10019    TRACE (Func_Entry, "ntr_file_in_fp_tbl", NULL);
10020 
10021    TBL_REALLOC_CK(file_path_tbl, 1);
10022    CLEAR_TBL_NTRY(file_path_tbl, file_path_tbl_idx);
10023    FP_NAME_IDX(file_path_tbl_idx)       = str_pool_idx + 1;
10024    length                               = (long) strlen(path);
10025    FP_SYSTEM_FILE(file_path_tbl_idx)    = FP_SYSTEM_FILE(dir_idx);
10026    FP_SRCH_THE_FILE(file_path_tbl_idx)  = TRUE;
10027    FP_CLASS(file_path_tbl_idx)          = Unknown_Fp;
10028    FP_NAME_LEN(file_path_tbl_idx)       = length;
10029    FP_FILE_IDX(file_path_tbl_idx)       = dir_idx;
10030 
10031    TBL_REALLOC_CK(str_pool, WORD_LEN(length));
10032 
10033    str_pool[str_pool_idx].name_long     = 0; /* Zero out last word */
10034 
10035    strcpy(FP_NAME_PTR(file_path_tbl_idx), path);
10036 
10037    /* Insert after directory entry.  Must keep ordered */
10038 
10039    if (fp_idx == NULL_IDX) {
10040       fp_idx                            = file_path_tbl_idx;
10041       FP_NEXT_FILE_IDX(fp_idx)          = FP_NEXT_FILE_IDX(dir_idx);
10042       FP_NEXT_FILE_IDX(dir_idx)         = fp_idx;
10043    }
10044    else {
10045       FP_NEXT_FILE_IDX(file_path_tbl_idx)       = FP_NEXT_FILE_IDX(fp_idx);
10046       FP_NEXT_FILE_IDX(fp_idx)                  = file_path_tbl_idx;
10047       fp_idx                                    = file_path_tbl_idx;
10048    }
10049 
10050    TRACE (Func_Exit, "ntr_file_in_fp_tbl", NULL);
10051 
10052    return(fp_idx);
10053 
10054 } /* ntr_file_in_fp_tbl */
10055 
10056 /******************************************************************************\
10057 |*                                                                            *|
10058 |* Description:                                                               *|
10059 |*      Is this a directory or a file?                                        *|
10060 |*                                                                            *|
10061 |* Input parameters:                                                          *|
10062 |*      Path name to check                                                    *|
10063 |*                                                                            *|
10064 |* Output parameters:                                                         *|
10065 |*      NONE                                                                  *|
10066 |*                                                                            *|
10067 |* Returns:                                                                   *|
10068 |*      TRUE if directory, else FALSE                                         *|
10069 |*                                                                            *|
10070 \******************************************************************************/
10071 boolean is_directory (char *path)
10072 {
10073    struct       stat    statbuf;
10074 
10075 
10076    TRACE (Func_Entry, "is_directory", NULL);
10077 
10078    if (stat (path, &statbuf)) {
10079       return(FALSE);                   /* stat(2) failed */
10080    }
10081 
10082    if ((statbuf.st_mode & S_IFDIR) == S_IFDIR) {
10083        return (TRUE);
10084    }
10085 
10086    TRACE (Func_Exit, "is_directory", NULL);
10087 
10088    return (FALSE);
10089 
10090 } /* is_directory */
10091 
10092 # if 0
10093 /******************************************************************************\
10094 |*                                                                            *|
10095 |* Description:                                                               *|
10096 |*                                                                            *|
10097 |* Input parameters:                                                          *|
10098 |*                                                                            *|
10099 |* Output parameters:                                                         *|
10100 |*      NONE                                                                  *|
10101 |*                                                                            *|
10102 |* Returns:                                                                   *|
10103 |*                                                                            *|
10104 \******************************************************************************/
10105 static  void    create_module_list_from_str_pool(void)
10106 
10107 {
10108    int          fp_idx;
10109    int          idx;
10110    int          mod_idx;
10111    int          str_idx;
10112 
10113 
10114    TRACE (Func_Entry, "create_module_list_from_str_pool", NULL);
10115 
10116 
10117    allocate_mod_link_tbl(str_pool_idx);  /* Let routine determine size. */
10118 
10119    /* Mark the string pool entries to keep */
10120 
10121    for (fp_idx = 1; fp_idx <= file_path_tbl_idx; fp_idx++) {
10122 
10123       if (FP_CLASS(fp_idx) == Current_Compile_Fp) {
10124          ML_STR_IDX(FP_NAME_IDX(fp_idx))        = FP_NAME_IDX(fp_idx);
10125          ML_STR_LEN(FP_NAME_IDX(fp_idx))        = FP_NAME_LEN(fp_idx);
10126       }
10127    }
10128 
10129    str_idx      = 1;
10130 
10131    for (mod_idx = 1; mod_idx <= str_pool_idx; mod_idx++) {
10132 
10133       if (ML_STR_IDX(mod_idx) != NULL_IDX) {
10134          ML_STR_IDX(mod_idx)     = str_idx;
10135          ML_STR_LEN(mod_idx)     = WORD_LEN(ML_STR_LEN(mod_idx));
10136          str_idx                += ML_STR_LEN(mod_idx);
10137       }
10138    }
10139 
10140    str_idx      = 0;
10141 
10142    for (mod_idx = 1; mod_idx <= str_pool_idx; mod_idx++) {
10143 
10144       if (ML_STR_IDX(mod_idx) != NULL_IDX) {
10145 
10146          for (idx = 0; idx < ML_STR_LEN(mod_idx); idx++) {
10147             str_pool[++str_idx].name_long = str_pool[mod_idx+idx].name_long;
10148          }
10149       }
10150    }
10151 
10152    str_pool_idx = str_idx;
10153 
10154 
10155    TRACE (Func_Exit, "create_module_list_from_str_pool", NULL);
10156 
10157    return;
10158 
10159 } /* create_module_list_from_str_pool */
10160 # endif
10161 
10162 /******************************************************************************\
10163 |*                                                                            *|
10164 |* Description:                                                               *|
10165 |*                                                                            *|
10166 |* Input parameters:                                                          *|
10167 |*                                                                            *|
10168 |* Output parameters:                                                         *|
10169 |*      NONE                                                                  *|
10170 |*                                                                            *|
10171 |* Returns:                                                                   *|
10172 |*                                                                            *|
10173 \******************************************************************************/
10174 extern  void    clean_up_module_files(void)
10175 
10176 {
10177 # if defined(_MODULE_TO_DOT_o) 
10178 
10179    int           fp_idx;
10180 
10181 
10182    TRACE (Func_Entry, "clean_up_module_files", NULL);
10183 
10184    /* KAY - This is not needed when we're running a standalone frontend. */
10185 
10186    if (!on_off_flags.module_to_mod) {
10187 
10188       for (fp_idx = 1; fp_idx <= file_path_tbl_idx; fp_idx++) {
10189 
10190           if (FP_TMP_FILE(fp_idx)) {
10191              remove(FP_NAME_PTR(fp_idx));
10192          }
10193       }
10194    }
10195 
10196 
10197    TRACE (Func_Exit, "clean_up_module_files", NULL);
10198 # endif
10199 
10200    return;
10201 
10202 } /* clean_up_module_files */
10203 
10204 /******************************************************************************\
10205 |*                                                                            *|
10206 |* Description:                                                               *|
10207 |*      This routine takes an intrinsic interface coming in from a module and *|
10208 |*      updates it to use the new intrinsic interface for this version.       *|
10209 |*                                                                            *|
10210 |* Input parameters:                                                          *|
10211 |*      mod_interface_idx -> attr index for interface from module.            *|
10212 |*                                                                            *|
10213 |* Output parameters:                                                         *|
10214 |*      NONE                                                                  *|
10215 |*                                                                            *|
10216 |* Returns:                                                                   *|
10217 |*      NOTHING                                                               *|
10218 |*                                                                            *|
10219 \******************************************************************************/
10220 static  void    update_intrinsic(int            mod_interface_idx)
10221 
10222 {
10223 # if 0
10224    boolean      clear_intrin    = FALSE;
10225 # endif
10226    int          idx;
10227    int          intrin_interface_idx;
10228    int          intrin_sn_idx;
10229    long         length;
10230    int          mod_sn_idx;
10231    int          name_idx;
10232    int          num_interfaces;
10233    int          prev_sn_idx;
10234    int          save_expanded;
10235    int          save_first_specific;
10236    int          save_num_specifics;
10237    int          scp_idx;
10238 
10239 
10240    TRACE (Func_Entry, "update_intrinsic", NULL);
10241 
10242    scp_idx              = curr_scp_idx;
10243    curr_scp_idx         = INTRINSIC_SCP_IDX;
10244    intrin_interface_idx = srch_sym_tbl(AT_OBJ_NAME_PTR(mod_interface_idx),
10245                                        AT_NAME_LEN(mod_interface_idx),
10246                                        &name_idx);
10247    save_expanded        = expanded_intrinsic_list;
10248 
10249    if (intrin_interface_idx == NULL_IDX) {
10250 
10251       /* We will get here if the intrinsic has been renamed. */
10252 
10253       if (AT_ORIG_NAME_IDX(mod_interface_idx) != 
10254           AT_NAME_IDX(mod_interface_idx)) {
10255          intrin_interface_idx = srch_sym_tbl(
10256                                          AT_ORIG_NAME_PTR(mod_interface_idx),
10257                                          AT_ORIG_NAME_LEN(mod_interface_idx),
10258                                         &name_idx);
10259       }
10260 
10261       if (intrin_interface_idx == NULL_IDX) {
10262           PRINTMSG(stmt_start_line, 626, Internal, 0,
10263                    "to find intrinsic",
10264                    "update_intrinsic");
10265       }
10266 
10267       /*                                                */
10268       /*  module module_intrinsics                      */
10269       /*  intrinsic alog                                */
10270       /*  end module module_intrinsics                  */
10271 
10272       /*  module module_machine                         */
10273       /*  use module_intrinsics, draco_alog => alog     */
10274       /*  end module module_machine                     */
10275 
10276       /*  subroutine mhderes                            */
10277       /*  use module_machine, ONLY: draco_alog          */
10278       /*  end subroutine mhderes                        */
10279   
10280    }
10281 
10282    curr_scp_idx         = scp_idx;
10283    save_first_specific  = ATI_FIRST_SPECIFIC_IDX(intrin_interface_idx);
10284    save_num_specifics   = ATI_NUM_SPECIFICS(intrin_interface_idx);
10285 
10286    ATI_FIRST_SPECIFIC_IDX(intrin_interface_idx) = NULL_IDX;
10287    ATI_NUM_SPECIFICS(intrin_interface_idx)      = 0;
10288 
10289    complete_intrinsic_definition(intrin_interface_idx);
10290 
10291    /* KAY - need to check more tables than this. */
10292 
10293    idx = (attr_tbl_idx > name_pool_idx) ? attr_tbl_idx : name_pool_idx;
10294    idx = (idx > sec_name_tbl_idx) ? idx : sec_name_tbl_idx;
10295 
10296    if (idx > mod_link_tbl_idx) {
10297       length = idx - mod_link_tbl_idx;
10298       idx    = mod_link_tbl_idx + 1;
10299       TBL_REALLOC_CK(mod_link_tbl, length);
10300 
10301       for (; idx <= mod_link_tbl_idx; idx++) {
10302          CLEAR_TBL_NTRY(mod_link_tbl, idx);
10303       }
10304    }
10305 
10306    /* Since multiple copies of a generic interface share sn entries,   */
10307    /* it turns out that the ATI_NUM_SPECIFICS may not match the actual */
10308    /* number of sn entries. So, count them. BHJ                        */
10309 
10310    mod_sn_idx           = ATI_FIRST_SPECIFIC_IDX(mod_interface_idx);
10311 
10312    num_interfaces = 0;
10313 
10314    while (mod_sn_idx != NULL_IDX) {
10315       num_interfaces++;
10316       mod_sn_idx = SN_SIBLING_LINK(mod_sn_idx);
10317    }
10318 
10319    mod_sn_idx           = ATI_FIRST_SPECIFIC_IDX(mod_interface_idx);
10320    intrin_sn_idx        = ATI_FIRST_SPECIFIC_IDX(intrin_interface_idx);
10321    ATI_NUM_SPECIFICS(mod_interface_idx) = num_interfaces;
10322    prev_sn_idx          = NULL_IDX;
10323 
10324    /* The assumption is that user definitions can be before or after  */
10325    /* the intrinsics, but all the intrinsic definitions are together. */
10326    /* Throw out the intrinsic specifics from the module and replace   */
10327    /* with the intrinsic specifics from this compiler.                */
10328 
10329    /* We can just reset the attrs in the secondary name table.  In    */
10330    /* general the number of specifics should be the same.  We'll take */
10331    /* care of odd cases after this loop.                              */
10332 
10333    while (mod_sn_idx != NULL_IDX && intrin_sn_idx != NULL_IDX) {
10334 
10335       if (AT_IS_INTRIN(SN_ATTR_IDX(mod_sn_idx))) {
10336          ML_AT_IDX(SN_ATTR_IDX(mod_sn_idx)) = SN_ATTR_IDX(intrin_sn_idx);
10337          intrin_sn_idx                      = SN_SIBLING_LINK(intrin_sn_idx);
10338       }
10339 
10340       prev_sn_idx       = mod_sn_idx;
10341       mod_sn_idx        = SN_SIBLING_LINK(mod_sn_idx);
10342    }
10343 
10344    while (mod_sn_idx != NULL_IDX) {  /* intrin_sn_idx must be NULL */
10345 
10346       /* These could be extra intrinsics coming from the module or they */
10347       /* could be user defines.  If they are specific intrinsics, just  */
10348       /* remove them.  They would be unavailable in this compilation.   */
10349       /* This could be a potential problem when we're reading old       */
10350       /* modules in and something has changed.                          */
10351 
10352       if (AT_IS_INTRIN(SN_ATTR_IDX(mod_sn_idx))) {
10353 
10354          /* Extra intrinsic - remove it? */
10355 
10356          if (prev_sn_idx == NULL_IDX) {
10357 
10358             /* mod_sn_idx is set to the first item */
10359 
10360             ATI_FIRST_SPECIFIC_IDX(mod_interface_idx) =
10361                                                   SN_SIBLING_LINK(mod_sn_idx);
10362          }
10363          else {
10364             SN_SIBLING_LINK(prev_sn_idx) = SN_SIBLING_LINK(mod_sn_idx);
10365          }
10366 
10367          mod_sn_idx = SN_SIBLING_LINK(mod_sn_idx);
10368          num_interfaces--;
10369       }
10370       else {  /* User defined specific - skip it */
10371          prev_sn_idx    = mod_sn_idx;
10372          mod_sn_idx     = SN_SIBLING_LINK(mod_sn_idx);
10373       }
10374    }
10375 
10376    if (intrin_sn_idx != NULL_IDX) {  /* mod_sn_idx is NULL */
10377 # if 0
10378       clear_intrin      = TRUE;
10379 # endif
10380 
10381       /* Have more intrinsics than old ones.  Add to end of list */
10382 
10383       if (prev_sn_idx == NULL_IDX) {  /* This shouldn't happen */
10384          ATI_FIRST_SPECIFIC_IDX(mod_interface_idx) = intrin_sn_idx;
10385       }
10386       else {
10387          SN_SIBLING_LINK(prev_sn_idx)   = intrin_sn_idx;
10388       }
10389 
10390       while (intrin_sn_idx != NULL_IDX) {
10391          num_interfaces++;
10392          intrin_sn_idx  = SN_SIBLING_LINK(intrin_sn_idx);
10393       }
10394    }
10395 
10396 # if 0
10397    if (clear_intrin) {
10398 
10399       /* Clear the intrinsic, because we have added new intrinsics */
10400       /* from the list and we don't want the expanded intrinsic    */
10401       /* getting caught in the compression stuff.                  */
10402 # endif
10403 
10404    ATI_FIRST_SPECIFIC_IDX(intrin_interface_idx) = save_first_specific;
10405    ATI_NUM_SPECIFICS(intrin_interface_idx)      = save_num_specifics;
10406 
10407    ATI_NUM_SPECIFICS(mod_interface_idx)         = num_interfaces;
10408    ATI_INTRIN_TBL_IDX(mod_interface_idx)        = 
10409                       ATI_INTRIN_TBL_IDX(intrin_interface_idx);
10410 
10411    expanded_intrinsic_list                      = save_expanded;
10412 
10413    TRACE (Func_Exit, "update_intrinsic", NULL);
10414 
10415    return;
10416 
10417 }  /* update_intrinsic */
10418 
10419 /******************************************************************************\
10420 |*                                                                            *|
10421 |* Description:                                                               *|
10422 |*                                                                            *|
10423 |* Input parameters:                                                          *|
10424 |*      NONE                                                                  *|
10425 |*                                                                            *|
10426 |* Output parameters:                                                         *|
10427 |*      NONE                                                                  *|
10428 |*                                                                            *|
10429 |* Returns:                                                                   *|
10430 |*      NOTHING                                                               *|
10431 |*                                                                            *|
10432 \******************************************************************************/
10433 static  void    process_procs_for_inlining(int  list_idx)
10434 
10435 {
10436    int          al_idx;
10437    int          attr_idx;
10438    int          sh_idx;
10439 
10440 
10441    TRACE (Func_Entry, "process_procs_for_inlining", NULL);
10442 
10443    if (list_idx == NULL_IDX || num_prog_unit_errors != 0) {
10444       return;
10445    }
10446 
10447    al_idx               = list_idx;
10448 
10449    while (al_idx != NULL_IDX) {
10450       attr_idx  = AL_ATTR_IDX(al_idx);
10451       sh_idx    = ATP_FIRST_SH_IDX(attr_idx);
10452 
10453       while (sh_idx != NULL_IDX) {
10454 
10455          /* This is only used to set ML_AT_SEARCHED               */
10456 
10457          check_ir_for_attrs(SH_IR_IDX(sh_idx));
10458          sh_idx = SH_NEXT_IDX(sh_idx);
10459       }
10460       al_idx                    = AL_NEXT_IDX(al_idx);
10461    }
10462 
10463    TRACE (Func_Exit, "process_procs_for_inlining", NULL);
10464 
10465    return;
10466 
10467 }  /* process_procs_for_inlining */
10468 
10469 /******************************************************************************\
10470 |*                                                                            *|
10471 |* Description:                                                               *|
10472 |*                                                                            *|
10473 |* Input parameters:                                                          *|
10474 |*      NONE                                                                  *|
10475 |*                                                                            *|
10476 |* Output parameters:                                                         *|
10477 |*      NONE                                                                  *|
10478 |*                                                                            *|
10479 |* Returns:                                                                   *|
10480 |*      NOTHING                                                               *|
10481 |*                                                                            *|
10482 \******************************************************************************/
10483 static  void  check_ir_for_attrs(int    ir_idx)
10484 
10485 {
10486    boolean      first;
10487    int          fld;
10488    int          idx;
10489 
10490 
10491    TRACE (Func_Entry, "check_ir_for_attrs", NULL);
10492 
10493    first        = TRUE;
10494    idx          = IR_IDX_L(ir_idx);
10495    fld          = IR_FLD_L(ir_idx);
10496 
10497 AGAIN:
10498 
10499    switch (fld) {
10500    case CN_Tbl_Idx:
10501    case NO_Tbl_Idx:
10502    case SH_Tbl_Idx:
10503       break;
10504 
10505    case AT_Tbl_Idx:
10506 
10507       ML_AT_SEARCHED(idx)       = TRUE;
10508       break;
10509 
10510    case IR_Tbl_Idx:
10511       check_ir_for_attrs(idx);
10512       break;
10513 
10514    case IL_Tbl_Idx:
10515       check_il_for_attrs(idx);
10516       break;
10517    }
10518 
10519    if (first) {
10520       first     = FALSE;
10521       idx       = IR_IDX_R(ir_idx);
10522       fld       = IR_FLD_R(ir_idx);
10523       goto AGAIN;
10524    }
10525    
10526    TRACE (Func_Exit, "check_ir_for_attrs", NULL);
10527 
10528    return;
10529 
10530 }   /* check_ir_for_attrs */
10531 
10532 /******************************************************************************\
10533 |*                                                                            *|
10534 |* Description:                                                               *|
10535 |*                                                                            *|
10536 |* Input parameters:                                                          *|
10537 |*      NONE                                                                  *|
10538 |*                                                                            *|
10539 |* Output parameters:                                                         *|
10540 |*      NONE                                                                  *|
10541 |*                                                                            *|
10542 |* Returns:                                                                   *|
10543 |*      NOTHING                                                               *|
10544 |*                                                                            *|
10545 \******************************************************************************/
10546 static  void  check_il_for_attrs(int    list_idx)
10547 
10548 {
10549 
10550    TRACE (Func_Entry, "check_il_for_attrs", NULL);
10551 
10552    while (list_idx != NULL_IDX) {
10553 
10554       switch (IL_FLD(list_idx)) {
10555       case CN_Tbl_Idx:
10556       case NO_Tbl_Idx:
10557       case SH_Tbl_Idx:
10558          break;
10559 
10560       case AT_Tbl_Idx:
10561 
10562          ML_AT_SEARCHED(IL_IDX(list_idx)) = TRUE;
10563          break;
10564 
10565       case IR_Tbl_Idx:
10566          check_ir_for_attrs(IL_IDX(list_idx));
10567          break;
10568 
10569       case IL_Tbl_Idx:
10570          check_il_for_attrs(IL_IDX(list_idx));
10571          break;
10572       }
10573       list_idx = IL_NEXT_LIST_IDX(list_idx);
10574    }
10575    
10576    TRACE (Func_Exit, "check_il_for_attrs", NULL);
10577 
10578    return;
10579 
10580 }   /* check_il_for_attrs */
10581 
10582 /******************************************************************************\
10583 |*                                                                            *|
10584 |* Description:                                                               *|
10585 |*                                                                            *|
10586 |* Input parameters:                                                          *|
10587 |*                                                                            *|
10588 |* Output parameters:                                                         *|
10589 |*      NONE                                                                  *|
10590 |*                                                                            *|
10591 |* Returns:                                                                   *|
10592 |*      NOTHING                                                               *|
10593 |*                                                                            *|
10594 \******************************************************************************/
10595 # if defined(_DEBUG)
10596 
10597 static  void    dump_pdt(FILE   *mod_file_ptr)
10598 {
10599 
10600 # if defined(_HOST_OS_UNICOS) || defined(_HOST_OS_MAX)
10601 # include <relo.h>
10602 
10603    typedef      struct  pdttabl pdt_table_type;
10604 
10605    struct       p_table {pdt_table_type pdt_static_table;
10606                          Uint           unused  : 32;
10607                          Uint           unused1 : 8;
10608                          Uint           pdtmul  : 8;
10609                          Uint           pdtcmtl : 8;
10610                          Uint           pdtmtl  : 8;
10611                         };
10612 
10613    typedef      struct  p_table p_table_type;
10614    
10615 
10616    int                  file_wd_length;
10617    char                 mod_file_name[256];
10618    long                 offset;
10619    int                  name_wd_length;
10620    char                *out;
10621    p_table_type         pdt_table;
10622    long                 use_file_length;
10623    long                 use_name_length;
10624    long                 use_file_wd_length;
10625    long                 use_name_wd_length;
10626 
10627 
10628 
10629    TRACE (Func_Entry, "dump_pdt", NULL);
10630 
10631    /* Dump each table as we look through it. */
10632 
10633    init_debug_file();  /* Check to see if debug output is open. */
10634 
10635    switch (MD_PDT_HDR_TYPE) {
10636    case PDT_TYPE:
10637       out = "Program descriptor table";
10638       break;
10639    case TXT_TYPE:
10640       out = "Text table";
10641       break;
10642    case REL_TYPE:
10643       out = "Relocation table";
10644       break;
10645    case XRL_TYPE:
10646       out = "Extended Relocation table";
10647       break;
10648    case MTT_TYPE:
10649       out = "Module Termination table";
10650       break;
10651    case LHT_TYPE:
10652       out = "Library (build) header table";
10653       break;
10654    case BLD_TYPE:
10655       out = "Build directory table";
10656       break;
10657    case SYM_TYPE:
10658       out = "Module symbol table";
10659       break;
10660    case CMB_TYPE:
10661       out = "Common block symbol table";
10662       break;
10663    case DMT_TYPE:
10664       out = "Extended debug map table";
10665       break;
10666    case GNT_TYPE:
10667       out = "Global symbol table";
10668       break;
10669    case PAS_TYPE:
10670       out = "Fortran 90 module table";
10671       break;
10672    default:
10673       out = "unknown";
10674       break;
10675    }
10676 
10677    fprintf(debug_file, "%-14s= %-6d  %-14s= %-40s\n",
10678                        "PDT_TABLE_LEN",  MD_PDT_HDR_LEN,
10679                        "PDT_TABLE_TYPE", out);
10680 
10681    if (MD_PDT_HDR_TYPE == PAS_TYPE) {
10682       fprintf(debug_file, "%-24s%-40s\n", " ", MD_NAME_PTR);
10683    }
10684       
10685    if (MD_PDT_HDR_TYPE != PDT_TYPE) {
10686       return;
10687    }
10688 
10689    offset               = ftell(mod_file_ptr) - TARGET_BYTES_PER_WORD;
10690 
10691    fseek(mod_file_ptr, offset, SEEK_SET);
10692 
10693    fread(&pdt_table, sizeof(pdt_table), 1, mod_file_ptr);
10694    name_wd_length = 0;
10695    file_wd_length = 0;
10696 
10697    if (pdt_table.pdt_static_table.pdtmnl != 0) {
10698       name_wd_length = (pdt_table.pdt_static_table.pdtmnl+7)/8;
10699    }
10700       
10701    if (pdt_table.pdt_static_table.pdtfnl != 0) {
10702       file_wd_length = (pdt_table.pdt_static_table.pdtfnl+7)/8;
10703    }
10704 
10705    if ((pdt_table.pdt_static_table.pdthdsz + name_wd_length + file_wd_length) 
10706         > 10 && pdt_table.pdtmul > 0) {
10707 
10708       /* Has module use paths. */
10709 
10710       fseek(mod_file_ptr, 
10711             (pdt_table.pdtcmtl + pdt_table.pdtmtl) * TARGET_BYTES_PER_WORD,
10712             SEEK_CUR);
10713 
10714       while (pdt_table.pdtmul > 0) {
10715          fread(&use_name_length, sizeof(long), 1, mod_file_ptr);
10716 
10717          use_file_length    = (0377 & use_name_length);
10718          use_name_length    = (use_name_length >> 8);
10719          use_file_wd_length = (use_file_length > 0)?((use_file_length+7)/8):0;
10720          use_name_wd_length = (use_name_length > 0)?((use_name_length+7)/8):0;
10721 
10722          fread(mod_file_name,
10723                use_file_wd_length * TARGET_BYTES_PER_WORD,
10724                1,
10725                mod_file_ptr);
10726 
10727          fprintf(debug_file, "%-14s= %-6d  %-14s= %-40s\n",
10728                              "path length ", use_file_length,
10729                              "module path", mod_file_name);
10730 
10731          fread(mod_file_name,
10732                use_name_wd_length * TARGET_BYTES_PER_WORD,
10733                1,
10734                mod_file_ptr);
10735 
10736          fprintf(debug_file, "%-14s= %-6d  %-14s= %-40s\n",
10737                              "name length ", use_name_length,
10738                              "module name", mod_file_name);
10739 
10740          pdt_table.pdtmul = pdt_table.pdtmul - 
10741                             (use_file_wd_length + use_name_wd_length + 1);
10742       }
10743    }
10744 
10745    if (file_wd_length > 0) {
10746       fseek(mod_file_ptr, 
10747             offset + 
10748             ((MD_PDT_HDR_LEN - (name_wd_length + file_wd_length)) *
10749               TARGET_BYTES_PER_WORD),
10750             SEEK_SET);
10751       fread(mod_file_name, 
10752             file_wd_length * TARGET_BYTES_PER_WORD,
10753             1, 
10754             mod_file_ptr);
10755 
10756       fprintf(debug_file, "%-14s= %-6d  %-14s= %-40s\n",
10757                           "length ", pdt_table.pdt_static_table.pdtfnl,
10758                           "module file", mod_file_name);
10759    }
10760 
10761    if (name_wd_length > 0) {
10762       fseek(mod_file_ptr, 
10763             offset + ((MD_PDT_HDR_LEN - name_wd_length)*TARGET_BYTES_PER_WORD),
10764             SEEK_SET);
10765 
10766       fread(mod_file_name, 
10767             name_wd_length * TARGET_BYTES_PER_WORD,
10768             1, 
10769             mod_file_ptr);
10770 
10771       fprintf(debug_file, "%-14s= %-6d  %-14s= %-40s\n",
10772                           "length ", pdt_table.pdt_static_table.pdtmnl,
10773                           "module name", mod_file_name);
10774    }
10775 
10776    fseek(mod_file_ptr, offset + TARGET_BYTES_PER_WORD, SEEK_SET);
10777 
10778 # endif
10779 
10780    TRACE (Func_Exit, "dump_pdt", NULL);
10781 
10782    return;
10783 
10784 }   /* dump_pdt */
10785 
10786 /******************************************************************************\
10787 |*                                                                            *|
10788 |* Description:                                                               *|
10789 |*                                                                            *|
10790 |* Input parameters:                                                          *|
10791 |*                                                                            *|
10792 |* Output parameters:                                                         *|
10793 |*      NONE                                                                  *|
10794 |*                                                                            *|
10795 |* Returns:                                                                   *|
10796 |*      NOTHING                                                               *|
10797 |*                                                                            *|
10798 \******************************************************************************/
10799 
10800 static  void    print_mod_tbl()
10801 {
10802    int          idx;
10803    char        *boolean_str[]          = { "F", "T" };
10804 
10805 
10806    TRACE (Func_Entry, "print_mod_tbl", NULL);
10807 
10808    init_debug_file();  /* Check to see if debug output is open. */
10809 
10810    fprintf(debug_file, "%-16s= %-7d %-16s= %-7d %-16s= %-8s\n",
10811            "MD_PDT_HDR_TYPE", MD_PDT_HDR_TYPE,
10812            "MD_PDT_HDR_LEN", MD_PDT_HDR_LEN,
10813            "MD_ALTERNATE_ENT", boolean_str[MD_ALTERNATE_ENTRY]);
10814 
10815    fprintf(debug_file, "%-16s= %-7s %-16s= %-7s %-16s= %-8s\n",
10816            "MD_CF77TYPES", boolean_str[MD_CF77TYPES],
10817            "MD_DALIGN", boolean_str[MD_DALIGN],
10818            "MD_DEFAULT_INTEGER_TYPE", boolean_str[MD_DEFAULT_INTEGER_TYPE]);
10819 
10820    fprintf(debug_file, "%-16s= %-7s %-16s= %-7s %-16s= %-8s\n",
10821            "MD_DEFAULT32", boolean_str[MD_DEFAULT32],
10822            "MD_FLOAT64", boolean_str[MD_FLOAT64],
10823            "MD_ENABLE_DOUBLE", boolean_str[MD_ENABLE_DOUBLE_PRECISION]);
10824 
10825    fprintf(debug_file, "%-16s= %-7s %-16s= %-7s %-16s= %-8d\n",
10826            "MD_HAS_ERRORS", boolean_str[MD_HAS_ERRORS],
10827            "MD_MODULE", boolean_str[MD_MODULE],
10828            "MD_NAME_LEN", MD_NAME_LEN);
10829 
10830    fprintf(debug_file, "%-16s= %-s\n",
10831            "MD_NAME_LONG", MD_NAME_PTR);
10832 
10833    fprintf(debug_file, "%-16s= %-7s %-16s= %-7d %-16s= %-8d\n",
10834            "MD_POINTER8", boolean_str[MD_POINTER8],
10835            "MD_TARGET", MD_TARGET,
10836            "MD_VERSION_NUM", MD_VERSION_NUM);
10837 
10838    for (idx = 1; idx <= Num_Of_Tbls; idx++) {
10839 
10840       if (MD_TBL_TYPE(idx) <= Num_Of_Tbls) {
10841          fprintf(debug_file, "%-16s= %-33s %-16s= %-8d\n",
10842                  "MD_TBL_TYPE", tbl_type_str[MD_TBL_TYPE(idx)],
10843                  "MD_NUM_ENTRIES", MD_NUM_ENTRIES(idx));
10844       }
10845       else {
10846          fprintf(debug_file, "%-16s= %-33s %-16s= %-8d\n",
10847                  "MD_TBL_TYPE", "ERROR",
10848                  "MD_NUM_ENTRIES", MD_NUM_ENTRIES(idx));
10849       }
10850    }
10851 
10852    TRACE (Func_Exit, "print_mod_tbl", NULL);
10853 
10854    return;
10855 
10856 }   /* print_mod_tbl */
10857 
10858 # endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines