s_driver.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 
00037 static char USMID[] = "\n@(#)5.0_pl/sources/s_driver.c  5.13    10/26/99 13:48:21\n";
00038 
00039 # include "defines.h"           /* Machine dependent ifdefs */
00040 
00041 # include "host.m"              /* Host machine dependent macros.*/
00042 # include "host.h"              /* Host machine dependent header.*/
00043 # include "target.m"            /* Target machine dependent macros.*/
00044 # include "target.h"            /* Target machine dependent header.*/
00045 
00046 # include "globals.m"
00047 # include "tokens.m"
00048 # include "sytb.m"
00049 # include "s_globals.m"
00050 # include "debug.m"
00051 
00052 # include "globals.h"
00053 # include "tokens.h"
00054 # include "sytb.h"
00055 # include "s_globals.h"
00056 # include "s_driver.h"
00057 
00058 
00059 /*****************************************************************\
00060 |* Function prototypes of static functions declared in this file *|
00061 \*****************************************************************/
00062 
00063 static void     attr_link_resolution(void);
00064 static void     check_and_allocate_common_storage(int);
00065 static boolean  compare_global_args(int, int, int, int, int);
00066 static boolean  compare_global_array(int, int, int);
00067 static boolean  compare_global_derived_type(int, int, int);
00068 static boolean  compare_global_type_rank(int, int, int, int, boolean);
00069 static void     decl_semantics_driver(void);
00070 static void     free_stmt_tmp_tbl(void);
00071 static void     final_attr_semantics(int);
00072 static void     final_decl_semantics(void);
00073 static void     final_equivalence_semantics(void);
00074 static void     find_host_associated_attrs_in_il(int);
00075 static void     find_host_associated_attrs_in_ir(int);
00076 static void     init_call_structs(void);
00077 static void     pgm_unit_semantics(void);
00078 static void     reset_stmt_tmp_tbl(void);
00079 static void     storage_blk_resolution(void);
00080 
00081 # if defined(GENERATE_WHIRL)
00082 static void     gen_user_code_start_opr(void);
00083 static void     insert_global_sh(void);
00084 # endif
00085 
00086 # ifdef _SEPARATE_FUNCTION_RETURNS
00087 static void     check_multiple_entry_func(void);
00088 # endif
00089 
00090 
00091 /***********************************\
00092 |* Globals used only in this file  *|
00093 \***********************************/
00094 
00095 static  int     symbolic_constant_array_list;
00096 
00097 
00098 /******************************************************************************\
00099 |*                                                                            *|
00100 |* Description:                                                               *|
00101 |*      This procedure is the semantics pass driver.                          *|
00102 |*                                                                            *|
00103 |* Input parameters:                                                          *|
00104 |*      NONE                                                                  *|
00105 |*                                                                            *|
00106 |* Output parameters:                                                         *|
00107 |*      NONE                                                                  *|
00108 |*                                                                            *|
00109 |* Returns:                                                                   *|
00110 |*      NOTHING                                                               *|
00111 |*                                                                            *|
00112 |* Algorithm note:                                                            *|
00113 |*      The global variable curr_scp_idx is saved and restored so that it can *|
00114 |*      be used by the Semantics Pass routines and other utility routines     *|
00115 |*      are used by both passes.                                              *|
00116 |*                                                                            *|
00117 \******************************************************************************/
00118 
00119 void semantics_pass_driver (void)
00120 
00121 {
00122    int          save_curr_scp_idx;
00123    
00124 
00125    TRACE (Func_Entry, "semantics_pass_driver", NULL);
00126 
00127    /*  init_semantics_pass();  */
00128 
00129    init_call_structs();
00130 
00131    reset_stmt_tmp_tbl();
00132 
00133    /* reinitialize cdir_switches */
00134 
00135    init_directive(2);
00136 
00137    save_curr_scp_idx    = curr_scp_idx;
00138    pgm_unit_start_line  = SH_GLB_LINE(SCP_FIRST_SH_IDX(curr_scp_idx));
00139 
00140    decl_semantics_driver();
00141 
00142    curr_scp_idx = save_curr_scp_idx;
00143 
00144 # if defined(GENERATE_WHIRL)
00145    if (insert_global_directives &&
00146        global_stmt_sh_idx != NULL_IDX) {
00147 
00148       insert_global_sh();
00149    }
00150 # endif
00151    pgm_unit_semantics();
00152 
00153    curr_scp_idx = save_curr_scp_idx;
00154 
00155    PRINT_EQV_TBL;
00156 
00157    TBL_FREE(equiv_tbl);
00158 
00159    /* free up the call site tables */
00160 
00161    if (arg_list != NULL) {
00162       MEM_FREE(arg_list);
00163       arg_list          = NULL;
00164       arg_list_size     = 0;
00165    }
00166 
00167    if (arg_info_list != NULL) {
00168       MEM_FREE(arg_info_list);
00169       arg_info_list     = NULL;
00170       arg_info_list_size        = 0;
00171    }
00172 
00173    /* free up the derived type compare table. */
00174 
00175    if (dt_cmp_tbl != NULL) {
00176       MEM_FREE(dt_cmp_tbl);
00177       dt_cmp_tbl        = NULL;
00178    }
00179 
00180    TRACE (Func_Exit, "semantics_pass_driver", NULL);
00181 
00182    return;
00183 
00184 }  /*  semantics_pass_driver  */
00185 
00186 
00187 /******************************************************************************\
00188 |*                                                                            *|
00189 |* Description:                                                               *|
00190 |*      This procedure visits all SCP entries for the current scope and any   *|
00191 |*      contained scopes.  It drives the semantic analysis of all statements  *|
00192 |*      by calling a semantic routine for each statement type (if the State-  *|
00193 |*      ment Header is not marked in error).                                  *|
00194 |*                                                                            *|
00195 |* Input parameters:                                                          *|
00196 |*      NONE                                                                  *|
00197 |*                                                                            *|
00198 |* Output parameters:                                                         *|
00199 |*      NONE                                                                  *|
00200 |*                                                                            *|
00201 |* Returns:                                                                   *|
00202 |*      NOTHING                                                               *|
00203 |*                                                                            *|
00204 |* Algorithm note:                                                            *|
00205 |*      If the current scope contains a child scope, this procedure is called *|
00206 |*      recursively to process the child's statements.  However, if the       *|
00207 |*      current scope has a sibling scope, the statements are processed by    *|
00208 |*      simply jumping to the top of this procedure.  Recursion is not used   *|
00209 |*      for sibling scopes in order to reduce recursion on anticipated large  *|
00210 |*      modules that implement programming libraries with many module         *|
00211 |*      procedures in a single module (see for example the ISO Varying String *|
00212 |*      Module).                                                              *|
00213 |*                                                                            *|
00214 \******************************************************************************/
00215 
00216 static void pgm_unit_semantics (void)
00217 
00218 {
00219    boolean      actual_arg;
00220    boolean      func_defined;
00221    boolean      func_ptr_defined;
00222    int          idx;
00223    boolean      inline_it;
00224    boolean      is_function;
00225    int          pgm_attr_idx;
00226    int          save_curr_scp_idx;
00227    int          sh_idx;
00228 
00229 
00230    TRACE (Func_Entry, "pgm_unit_semantics", NULL);
00231 
00232 PROCESS_SIBLING:
00233 
00234    TRACE (PU_Start, NULL, "Semantics");
00235 
00236    ATP_SCP_ALIVE(SCP_ATTR_IDX(curr_scp_idx))    = TRUE;
00237    idx                                          = SCP_ENTRY_IDX(curr_scp_idx);
00238 
00239    while (idx) {
00240       ATP_SCP_ALIVE(AL_ATTR_IDX(idx))           = TRUE;
00241       idx                                       = AL_NEXT_IDX(idx);
00242    }
00243 
00244    if (! SCP_IN_ERR(curr_scp_idx) ) {
00245 
00246       /* clear out the stmt_tmp_tbl for reusing short lived tmps. */
00247 
00248       free_stmt_tmp_tbl();
00249 
00250       curr_stmt_sh_idx  = SCP_FIRST_SH_IDX(curr_scp_idx);
00251       comp_phase        = Pass2_Semantics;
00252 
00253       while (curr_stmt_sh_idx != NULL_IDX) {
00254       
00255          if (SH_STMT_TYPE(curr_stmt_sh_idx) == Statement_Num_Stmt) {
00256 
00257             /* Set statement_number from the SH_PARENT_BLK_IDX field, get the */
00258             /* line and column for the last character of a DO loop            */
00259             /* (stmt_end_line and stmt_end_col are only used to produce the   */
00260             /* CIF Loop Definition record as of now), and delete the          */
00261             /* Statement_Number SH.                                           */
00262 
00263             stmt_end_line    = SH_GLB_LINE(curr_stmt_sh_idx);
00264             stmt_end_col     = SH_COL_NUM(curr_stmt_sh_idx);
00265             statement_number = SH_PARENT_BLK_IDX(curr_stmt_sh_idx);
00266             sh_idx = curr_stmt_sh_idx;
00267             SH_PREV_IDX(SH_NEXT_IDX(sh_idx)) = SH_PREV_IDX(sh_idx);
00268             SH_NEXT_IDX(SH_PREV_IDX(sh_idx)) = SH_NEXT_IDX(sh_idx);
00269             curr_stmt_sh_idx = SH_NEXT_IDX(sh_idx);
00270             FREE_SH_NODE(sh_idx);
00271             continue;
00272          }
00273 
00274          TRACE_NEW_STMT ("Semantics");
00275 
00276          sh_idx = curr_stmt_sh_idx;
00277 
00278          if (!SH_ERR_FLG(curr_stmt_sh_idx)     &&
00279              !SH_P2_SKIP_ME(curr_stmt_sh_idx)) {
00280             stmt_type       = SH_STMT_TYPE(curr_stmt_sh_idx);
00281             stmt_start_line = SH_GLB_LINE(curr_stmt_sh_idx);
00282             stmt_start_col  = SH_COL_NUM(curr_stmt_sh_idx);
00283 
00284             (*stmt_semantics[SH_STMT_TYPE(curr_stmt_sh_idx)])();
00285          }
00286          else if (SH_STMT_TYPE(curr_stmt_sh_idx) == End_Where_Stmt) {
00287             /* must go to the end where stmt semantics routine anyway */
00288             /* since it does clean up for the where block (and nothing*/
00289             /* else ).                                                */
00290 
00291             stmt_type       = SH_STMT_TYPE(curr_stmt_sh_idx);
00292             stmt_start_line = SH_GLB_LINE(curr_stmt_sh_idx);
00293             stmt_start_col  = SH_COL_NUM(curr_stmt_sh_idx);
00294 
00295             (*stmt_semantics[SH_STMT_TYPE(curr_stmt_sh_idx)])();
00296          }
00297 
00298          /* reset expression descriptor tables to zero */
00299          
00300          arg_info_list_base = NULL_IDX;
00301          arg_info_list_top  = NULL_IDX;
00302 
00303          if (SH_DOALL_LOOP_END(sh_idx)) {
00304             doall_end_semantics();
00305          }
00306 
00307          if (SH_LOOP_END(sh_idx)) {
00308             gen_loop_end_ir();
00309          }
00310              
00311          curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
00312       }
00313 
00314       final_decl_semantics();
00315 
00316       PRINT_DBG_SYTB;           /* Print scp if SCP_DBG_PRINT_SYTB = TRUE */
00317       PRINT_DBG_STMT;           /* Print scp if SCP_DBG_PRINT_STMT = TRUE */
00318    }
00319    else if (cif_flags & BASIC_RECS) {
00320 
00321       /* CIF still wants output, even if the scope is in error.              */
00322       /* Check CIF option to see if symbol table needs to be written to CIF. */
00323       /* Need to use BASIC_RECS to output the Entry Info and Common Block    */
00324       /* records if the user just specifies "-cf".                           */
00325 
00326       cif_send_sytb();
00327    }
00328 
00329    if (SCP_FIRST_CHILD_IDX(curr_scp_idx) != NULL_IDX) {
00330       save_curr_scp_idx         = curr_scp_idx;
00331       curr_scp_idx              = SCP_FIRST_CHILD_IDX(curr_scp_idx);
00332       pgm_unit_semantics();
00333       curr_scp_idx              = save_curr_scp_idx;
00334    }
00335 
00336    /* if this scope is a function, check if the result var has been defined */
00337    /* if the function is a pointer, check that the pointer as been assigned */
00338    /* or allocated.  Clear ATP_SCP_ALIVE.                                   */
00339 
00340    pgm_attr_idx                 = SCP_ATTR_IDX(curr_scp_idx);
00341    ATP_SCP_ALIVE(pgm_attr_idx)  = FALSE;
00342    is_function                  = FALSE;
00343 
00344    if (ATP_PGM_UNIT(pgm_attr_idx) == Function  &&
00345        ! AT_DCL_ERR(pgm_attr_idx)              &&
00346        ! SCP_IN_ERR(curr_scp_idx))              {
00347 
00348       is_function       = TRUE;
00349       func_defined      = AT_DEFINED(pgm_attr_idx);
00350       actual_arg        = AT_ACTUAL_ARG(pgm_attr_idx) || 
00351                           AT_ACTUAL_ARG(ATP_RSLT_IDX(pgm_attr_idx));
00352       func_ptr_defined  = ATD_PTR_ASSIGNED(ATP_RSLT_IDX(pgm_attr_idx));
00353    }
00354 
00355    idx    = SCP_ENTRY_IDX(curr_scp_idx);
00356 
00357    inline_it = (opt_flags.inline_lvl > Inline_Lvl_0) || 
00358                 ATP_MAY_INLINE(pgm_attr_idx);
00359 
00360    /* We keep more ir than we actually write out.  In the case of   */
00361    /* internal procedures, we want to use the current compile.      */  
00362 
00363    /* KAY  To get rid of the forward reference problem, we need     */
00364    /* to search for the internal procedures in the inline file,     */
00365    /* like we do with the module procedures.  We can get the name   */
00366    /* of the internal procedure's parent from the mangled procedure */
00367    /* name and search for it and then fill in the ATP_FIRST_SH_IDX. */
00368 
00369    while (idx) {
00370 
00371       if (is_function) {
00372          func_defined     |= AT_DEFINED(AL_ATTR_IDX(idx));
00373          actual_arg       |= AT_ACTUAL_ARG(AL_ATTR_IDX(idx)) ||
00374                              AT_ACTUAL_ARG(ATP_RSLT_IDX(AL_ATTR_IDX(idx)));
00375          func_ptr_defined |=ATD_PTR_ASSIGNED(ATP_RSLT_IDX(AL_ATTR_IDX(idx)));
00376       }
00377 
00378       ATP_SCP_ALIVE(AL_ATTR_IDX(idx))    = FALSE;
00379       ATP_FIRST_SH_IDX(AL_ATTR_IDX(idx)) = (inline_it) ? 
00380                                SCP_FIRST_SH_IDX(curr_scp_idx) : NULL_IDX;
00381       idx = AL_NEXT_IDX(idx);
00382        
00383    }
00384 
00385    if (is_function && !actual_arg) {
00386 
00387       if (!func_defined) {
00388          PRINTMSG(AT_DEF_LINE(ATP_RSLT_IDX(pgm_attr_idx)), 287, Warning, 
00389                   AT_DEF_COLUMN(ATP_RSLT_IDX(pgm_attr_idx)),
00390                   AT_OBJ_NAME_PTR(ATP_RSLT_IDX(pgm_attr_idx)));
00391       }
00392       else if (ATD_POINTER(ATP_RSLT_IDX(pgm_attr_idx)) && !func_ptr_defined){
00393          PRINTMSG(AT_DEF_LINE(ATP_RSLT_IDX(pgm_attr_idx)), 918, Warning, 
00394                   AT_DEF_COLUMN(ATP_RSLT_IDX(pgm_attr_idx)),
00395                   AT_OBJ_NAME_PTR(ATP_RSLT_IDX(pgm_attr_idx)));
00396       }
00397    }
00398 
00399    if (ATP_PGM_UNIT(pgm_attr_idx) != Module) {
00400       ATP_FIRST_SH_IDX(pgm_attr_idx) = inline_it?SCP_FIRST_SH_IDX(curr_scp_idx):
00401                                                 NULL_IDX;
00402    }
00403 
00404    if (SCP_SIBLING_IDX(curr_scp_idx) != NULL_IDX) {
00405       curr_scp_idx = SCP_SIBLING_IDX(curr_scp_idx);
00406       goto PROCESS_SIBLING;
00407    }
00408 
00409    TRACE (Func_Exit, "pgm_unit_semantics", NULL);
00410 
00411    return;
00412 
00413 }  /*  pgm_unit_semantics  */
00414 
00415 
00416 /******************************************************************************\
00417 |*                                                                            *|
00418 |* Description:                                                               *|
00419 |*      This is the driver for decl_semantics. All scopes are processed.      *|
00420 |*      NOTE:  The assumption is made that we go from outer scope to inner    *|
00421 |*             scope.  decl_semantics, name resolution and assign storage     *|
00422 |*             all require this.                                              *|
00423 |*                                                                            *|
00424 |* Input parameters:                                                          *|
00425 |*      NONE                                                                  *|
00426 |*                                                                            *|
00427 |* Output parameters:                                                         *|
00428 |*      NONE                                                                  *|
00429 |*                                                                            *|
00430 |* Returns:                                                                   *|
00431 |*      NOTHING                                                               *|
00432 |*                                                                            *|
00433 \******************************************************************************/
00434 
00435 static void decl_semantics_driver(void)
00436 
00437 {
00438    int          idx;
00439    int          save_curr_scp_idx;
00440 
00441    TRACE (Func_Entry, "decl_semantics_driver", NULL);
00442 
00443 PROCESS_SIBLING:
00444 
00445    comp_phase                                   = Decl_Semantics;
00446    ATP_SCP_ALIVE(SCP_ATTR_IDX(curr_scp_idx))    = TRUE;
00447    idx                                          = SCP_ENTRY_IDX(curr_scp_idx);
00448 
00449    while (idx) {
00450       ATP_SCP_ALIVE(AL_ATTR_IDX(idx))           = TRUE;
00451       idx                                       = AL_NEXT_IDX(idx);
00452    }
00453 
00454 # if defined(GENERATE_WHIRL) 
00455    gen_user_code_start_opr();
00456 # endif
00457 
00458    if (! SCP_IN_ERR(curr_scp_idx) ) {
00459       attr_link_resolution();
00460       curr_stmt_sh_idx  = SCP_FIRST_SH_IDX(curr_scp_idx);
00461       stmt_start_line   = SH_GLB_LINE(curr_stmt_sh_idx);
00462       stmt_start_col    = SH_COL_NUM(curr_stmt_sh_idx);
00463       need_new_sh       = TRUE;
00464 
00465       decl_semantics();
00466 
00467       if (cif_flags & BASIC_RECS) {
00468          cif_scope_info_rec();
00469       }
00470 
00471 # ifdef _SEPARATE_FUNCTION_RETURNS
00472       if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Function &&
00473           SCP_ALT_ENTRY_CNT(curr_scp_idx) != 0                 &&
00474           !ATD_IM_A_DOPE(ATP_RSLT_IDX(SCP_ATTR_IDX(curr_scp_idx))) &&
00475           ATD_ARRAY_IDX(ATP_RSLT_IDX(SCP_ATTR_IDX(curr_scp_idx))) == NULL_IDX &&
00476           TYP_TYPE(ATD_TYPE_IDX(ATP_RSLT_IDX(SCP_ATTR_IDX(curr_scp_idx)))) 
00477                                                       != Structure &&
00478           TYP_TYPE(ATD_TYPE_IDX(ATP_RSLT_IDX(SCP_ATTR_IDX(curr_scp_idx)))) 
00479                                                       != Character) {
00480  
00481          check_multiple_entry_func();
00482       }
00483 # endif
00484 
00485    }
00486 
00487    if (SCP_FIRST_CHILD_IDX(curr_scp_idx) != NULL_IDX) {
00488       save_curr_scp_idx         = curr_scp_idx;
00489       curr_scp_idx              = SCP_FIRST_CHILD_IDX(curr_scp_idx);
00490       decl_semantics_driver();
00491       curr_scp_idx              = save_curr_scp_idx;
00492    }
00493 
00494    ATP_SCP_ALIVE(SCP_ATTR_IDX(curr_scp_idx)) = FALSE;
00495 
00496    idx = SCP_ENTRY_IDX(curr_scp_idx);
00497 
00498    while (idx) {
00499 
00500       ATP_SCP_ALIVE(AL_ATTR_IDX(idx))   = FALSE;
00501       idx                               = AL_NEXT_IDX(idx);
00502    }
00503 
00504    if (SCP_SIBLING_IDX(curr_scp_idx) != NULL_IDX) {
00505       curr_scp_idx = SCP_SIBLING_IDX(curr_scp_idx);
00506       goto PROCESS_SIBLING;
00507    }
00508 
00509 
00510    TRACE (Func_Exit, "decl_semantics_driver", NULL);
00511 
00512    return;
00513 
00514 }  /* decl_semantics_driver */
00515 
00516 /******************************************************************************\
00517 |*                                                                            *|
00518 |* Description:                                                               *|
00519 |*      This procedure should never be called.  Its only purpose is to issue  *|
00520 |*      an internal error message if a bad (0) value of curr_stmt_sh_idx is   *|
00521 |*      encountered.                                                          *|
00522 |*                                                                            *|
00523 |* Input parameters:                                                          *|
00524 |*      NONE                                                                  *|
00525 |*                                                                            *|
00526 |* Output parameters:                                                         *|
00527 |*      NONE                                                                  *|
00528 |*                                                                            *|
00529 |* Returns:                                                                   *|
00530 |*      NOTHING                                                               *|
00531 |*                                                                            *|
00532 \******************************************************************************/
00533 
00534 void illegal_stmt_type (void)  
00535 
00536 {
00537 
00538    TRACE (Func_Entry, "illegal_stmt_type", NULL);
00539 
00540    PRINTMSG(SH_GLB_LINE(curr_stmt_sh_idx), 263, Internal, 0);
00541 
00542    TRACE (Func_Exit, "illegal_stmt_type", NULL);
00543 
00544    return;
00545 
00546 }  /* illegal_stmt_type */
00547 
00548 
00549 /******************************************************************************\
00550 |*                                                                            *|
00551 |* Description:                                                               *|
00552 |*      This procedure should never be called.  Its only purpose is to issue  *|
00553 |*      an internal error message if a Statement Header is encountered for    *|
00554 |*      which there is no semantic routine.                                   *|
00555 |*                                                                            *|
00556 |* Input parameters:                                                          *|
00557 |*      NONE                                                                  *|
00558 |*                                                                            *|
00559 |* Output parameters:                                                         *|
00560 |*      NONE                                                                  *|
00561 |*                                                                            *|
00562 |* Returns:                                                                   *|
00563 |*      NOTHING                                                               *|
00564 |*                                                                            *|
00565 \******************************************************************************/
00566 
00567 void no_semantics_routine (void)
00568 
00569 {
00570 
00571    TRACE (Func_Entry, "no_semantics_routine", NULL);
00572 
00573    PRINTMSG(SH_GLB_LINE(curr_stmt_sh_idx), 278, Internal, 0,
00574             stmt_type_str[stmt_type]);
00575 
00576    TRACE (Func_Exit, "no_semantics_routine", NULL);
00577 
00578    return;
00579 
00580 }  /* no_semantics_routine */
00581 
00582 /******************************************************************************\
00583 |*                                                                            *|
00584 |* Description:                                                               *|
00585 |*      This routine goes through the local name table for the current scope. *|
00586 |*      If the name is not locally defined(LN_DEF_LOC = FALSE), the host     *|
00587 |*      symbol tables are researched to make sure that AT_ATTR_LINK is        *|
00588 |*      pointing to the correct attribute entry.                              *|
00589 |*                                                                            *|
00590 |* Input parameters:                                                          *|
00591 |*      NONE                                                                  *|
00592 |*                                                                            *|
00593 |* Output parameters:                                                         *|
00594 |*      NONE                                                                  *|
00595 |*                                                                            *|
00596 |* Returns:                                                                   *|
00597 |*      NONE                                                                  *|
00598 |*                                                                            *|
00599 \******************************************************************************/
00600 static void     attr_link_resolution(void)
00601 {
00602    int          attr_idx;
00603    int          host_idx;
00604    int          host_name_idx;
00605    int          local_attr_idx;
00606    int          local_name_idx;
00607    int          name_idx;
00608    int          rslt_idx;
00609    int          save_curr_scp_idx;
00610    boolean      save_host_dcl_err;
00611    int          sn_idx;
00612    int          ultimate_idx;
00613    int          ultimate_scp_idx;
00614 
00615 
00616    TRACE (Func_Entry, "attr_link_resolution", NULL);
00617 
00618    /* Do not need to go thru SCP_ATTR_LIST, because everything on that list */
00619    /* should be resolved.  At the end of pass1, it should be tmps and       */
00620    /* library calls.                                                        */
00621 
00622    for (name_idx = SCP_LN_FW_IDX(curr_scp_idx) + 1; 
00623         name_idx < SCP_LN_LW_IDX(curr_scp_idx); name_idx++) {
00624 
00625 # ifdef _DEBUG
00626       if (name_idx < 0 || name_idx > loc_name_tbl_idx) {
00627          PRINTMSG(stmt_start_line, 34, Internal, stmt_start_col); 
00628       }
00629 # endif
00630 
00631       attr_idx = LN_ATTR_IDX(name_idx);
00632 # ifdef _DEBUG
00633       if (attr_idx <= 0 || attr_idx > attr_tbl_idx) {
00634          PRINTMSG(stmt_start_line, 34, Internal, stmt_start_col); 
00635       }
00636       if (LN_NAME_IDX(name_idx) != AT_NAME_IDX(attr_idx)) {
00637          PRINTMSG(AT_DEF_LINE(attr_idx), 516, Internal,
00638                   AT_DEF_COLUMN(attr_idx),
00639                   AT_OBJ_NAME_PTR(attr_idx),
00640                   name_idx,
00641                   attr_idx);
00642       }
00643 # endif
00644 
00645       if (AT_REFERENCED(attr_idx) != Not_Referenced) {
00646          AT_REFERENCED(attr_idx) = Referenced;
00647       }
00648 
00649       if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module &&
00650           !AT_ACCESS_SET(attr_idx)) {
00651 
00652          /* Set to default access */
00653 
00654          AT_PRIVATE(attr_idx) = AT_PRIVATE(SCP_ATTR_IDX(curr_scp_idx));
00655       }
00656 
00657       if (LN_DEF_LOC(name_idx)) {
00658          continue;
00659       }
00660 
00661       host_idx = srch_host_sym_tbl(&name_pool[LN_NAME_IDX(name_idx)].name_char,
00662                                    LN_NAME_LEN(name_idx),
00663                                    &host_name_idx,
00664                                    FALSE);
00665 
00666       if (host_idx == NULL_IDX) {
00667          AT_ATTR_LINK(attr_idx) = NULL_IDX;     
00668          continue;
00669       }
00670       else if (IS_STMT_ENTITY(host_idx)) {
00671 
00672          /* Don't host associate a stmt entity. */
00673 
00674          AT_ATTR_LINK(attr_idx) = NULL_IDX;
00675          continue;
00676       }
00677 
00678       if (AT_OBJ_CLASS(attr_idx) == Derived_Type) {
00679 
00680          /* Derived type host association */
00681 
00682          if ((AT_OBJ_CLASS(host_idx) != Derived_Type &&
00683               !AT_DCL_ERR(attr_idx)) ||
00684             AT_NOT_VISIBLE(attr_idx)) {
00685             save_host_dcl_err = AT_DCL_ERR(host_idx);
00686             fnd_semantic_err(Obj_Use_Derived_Type,
00687                              AT_DEF_LINE(attr_idx),
00688                              AT_DEF_COLUMN(attr_idx),
00689                              host_idx,
00690                              TRUE);
00691             AT_DCL_ERR(attr_idx) = TRUE; 
00692             AT_DCL_ERR(host_idx) = save_host_dcl_err; 
00693             host_idx             = NULL_IDX;  /* Break link */
00694          }
00695          else if (AT_OBJ_CLASS(host_idx) == Derived_Type) {
00696             AT_HOST_ASSOCIATED(attr_idx)        = TRUE;
00697             AT_HOST_ASSOCIATED(host_idx)        = TRUE;
00698             ATT_SCP_IDX(attr_idx)               = ATT_SCP_IDX(host_idx);
00699          }
00700       }
00701       else if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit) {
00702          ultimate_idx = host_idx;
00703 
00704          while (AT_ATTR_LINK(ultimate_idx)) {
00705             ultimate_idx = AT_ATTR_LINK(ultimate_idx);
00706          }
00707 
00708          /* Find the scope of the ultimate_idx */
00709 
00710          save_curr_scp_idx      = curr_scp_idx;
00711          ultimate_scp_idx       = curr_scp_idx;
00712 
00713          while (1) {  /* If scope is an interface block we're not here. */
00714             curr_scp_idx        = SCP_PARENT_IDX(curr_scp_idx);
00715 
00716             if (curr_scp_idx == 0) {  /* Intrinsic scope - exit */
00717                ultimate_scp_idx = NULL_IDX;
00718                break;
00719             }
00720 
00721             local_attr_idx = srch_sym_tbl(AT_OBJ_NAME_PTR(ultimate_idx),
00722                                           AT_NAME_LEN(ultimate_idx),
00723                                           &local_name_idx);
00724 
00725             if (local_attr_idx == ultimate_idx) {
00726                ultimate_scp_idx = curr_scp_idx;
00727                break;
00728             }
00729          }
00730 
00731          curr_scp_idx           = save_curr_scp_idx;
00732          ATP_SCP_IDX(attr_idx)  = ultimate_scp_idx;
00733 
00734          /* if we can change the ultimate attr to a pgm unit we do */
00735 
00736          if (AT_OBJ_CLASS(ultimate_idx) == Data_Obj &&
00737              ! AT_USE_ASSOCIATED(ultimate_idx)) {
00738 
00739             if (!fnd_semantic_err((ATP_PGM_UNIT(attr_idx) == Subroutine ?
00740                                                            Obj_Use_Extern_Subr :
00741                                                            Obj_Use_Extern_Func),
00742                                    AT_DEF_LINE(ultimate_idx),
00743                                    AT_DEF_COLUMN(ultimate_idx),
00744                                    ultimate_idx,
00745                                    FALSE)) {  /* Check - don't issue message */
00746 
00747                if (ATP_PGM_UNIT(attr_idx) == Function &&
00748                    ATD_CLASS(ultimate_idx) != Dummy_Argument &&
00749                    TYP_TYPE(ATD_TYPE_IDX(ultimate_idx)) == Character &&
00750                    TYP_CHAR_CLASS(ATD_TYPE_IDX(ultimate_idx)) ==
00751                                             Assumed_Size_Char) {
00752 
00753                    /* This would be an illegal situation, so treat */
00754                    /* as if fnd_semantic_err returned TRUE.        */
00755 
00756                    /* Intentionally blank */
00757                }
00758                else {
00759                   chg_data_obj_to_pgm_unit(ultimate_idx, (pgm_unit_type)
00760                                            ATP_PGM_UNIT(attr_idx),
00761                                            Extern_Proc);
00762                   ATP_SCP_IDX(ultimate_idx)     = ultimate_scp_idx;
00763 
00764                   if (ATP_PGM_UNIT(ultimate_idx) == Function) {
00765                      rslt_idx = ATP_RSLT_IDX(ultimate_idx);
00766    
00767                      if (ATD_ARRAY_IDX(rslt_idx) != NULL_IDX ||
00768                          ATD_IM_A_DOPE(rslt_idx) ||
00769                          TYP_TYPE(ATD_TYPE_IDX(rslt_idx)) == Structure ||
00770                          TYP_TYPE(ATD_TYPE_IDX(rslt_idx)) == Character) {
00771    
00772                         ATP_EXTRA_DARG(ultimate_idx) = TRUE;
00773    
00774                         if (ATP_EXPL_ITRFC(ultimate_idx)) {
00775                            ATD_STOR_BLK_IDX(rslt_idx) = 
00776                                      SCP_SB_DARG_IDX(ATP_SCP_IDX(ultimate_idx));
00777 
00778                            /* Insert the function result as the zero'th darg */
00779 
00780                            if (ATP_FIRST_IDX(ultimate_idx) == NULL_IDX) {
00781                               NTR_SN_TBL(sn_idx);
00782                            }
00783                            else {
00784                               sn_idx = ATP_FIRST_IDX(ultimate_idx) - 1;
00785                            }
00786                            ATP_FIRST_IDX(ultimate_idx)  = sn_idx;
00787                            ATP_NUM_DARGS(ultimate_idx) += 1;
00788                            SN_NAME_LEN(sn_idx)   = AT_NAME_LEN(rslt_idx);
00789                            SN_NAME_IDX(sn_idx)   = AT_NAME_IDX(rslt_idx);
00790                            SN_ATTR_IDX(sn_idx)   = rslt_idx;
00791                            SN_LINE_NUM(sn_idx)   = AT_DEF_LINE(rslt_idx);
00792                            SN_COLUMN_NUM(sn_idx) = AT_DEF_COLUMN(rslt_idx);
00793                         }
00794                      }
00795                   }
00796                }
00797             }
00798          }
00799       }
00800 
00801       if (attr_idx == host_idx) {
00802          PRINTMSG(AT_DEF_LINE(attr_idx), 72, Internal, AT_DEF_COLUMN(attr_idx),
00803                   AT_OBJ_NAME_PTR(attr_idx), attr_idx);
00804       }
00805 
00806       AT_ATTR_LINK(attr_idx)    = host_idx;
00807 
00808       host_associated_attr_semantics(attr_idx, FALSE);
00809    }
00810 
00811    TRACE (Func_Exit, "attr_link_resolution", NULL);
00812 
00813    return;
00814 
00815 }  /* attr_link_resolution */
00816 
00817 /******************************************************************************\
00818 |*                                                                            *|
00819 |* Description:                                                               *|
00820 |*      This routine handles the storage blocks for host associated attrs.    *|
00821 |*      All static storage blocks that will be host associated are copied     *|
00822 |*      and linked into the current scope.  There is no link in either        *|
00823 |*      direction.  The attr still points to the original storage block.      *|
00824 |*      The storage block needs to be put into the current scope so that it   *|
00825 |*      can be resolved by storage_blk_resolution before final_decl_semantics *|
00826 |*      During the PDGCS interface, when an attribute is sent across that     *|
00827 |*      references a storage block, not in the current scope, the current     *|
00828 |*      is searched for the storage block.  Then this is the block sent to    *|
00829 |*      PDG.  PDG_SB_IDX is updated for both the blocks so that the search    *|
00830 |*      only has to be done once per block in a program unit.                 *|
00831 |*      See send_stor_blk in i_cvrt.c for more details.                       *|
00832 |*                                                                            *|
00833 |* Input parameters:                                                          *|
00834 |*      attr_idx => The host associated attr with the stor blk that needs     *|
00835 |*                  resolving.                                                *|
00836 |*                                                                            *|
00837 |* Output parameters:                                                         *|
00838 |*      NONE                                                                  *|
00839 |*                                                                            *|
00840 |* Returns:                                                                   *|
00841 |*      NONE                                                                  *|
00842 |*                                                                            *|
00843 \******************************************************************************/
00844 void    host_associated_attr_semantics(int      attr_idx,
00845                                        boolean  add_to_attr_list)
00846 
00847 {
00848    int          bd_idx;
00849    boolean      defined;
00850    int          dim;
00851    int          eq_idx;
00852    int          first_eq;
00853    int          group_idx;
00854    int          il_idx;
00855    int          local_attr_idx;
00856    int          local_sb_idx;
00857    id_str_type  name;
00858    int          name_idx;
00859    char        *name_ptr;
00860    int          new_attr_idx;
00861    int          new_host_assoc          = FALSE;
00862    int          new_scp;
00863    int          new_sn_idx;
00864    int          referenced;
00865    int          sb_idx;
00866    int          sn_idx;
00867    int          type_idx;
00868 
00869 
00870    TRACE (Func_Entry, "host_associated_attr_semantics", NULL);
00871 
00872    /* Do not need to accumulate referenced and defined flags from     */
00873    /* intermediate attrs, because when each attr is processed, its    */
00874    /* flags are set into the original attr.  Save the flags, so they  */
00875    /* can be set if the attr is host associated.                      */
00876 
00877    referenced           = AT_REFERENCED(attr_idx);
00878    defined              = AT_DEFINED(attr_idx);
00879    local_attr_idx       = attr_idx;
00880 
00881    while (AT_ATTR_LINK(attr_idx) != NULL_IDX) {
00882       attr_idx  = AT_ATTR_LINK(attr_idx);
00883    }
00884 
00885    switch (AT_OBJ_CLASS(attr_idx)) {
00886    case Data_Obj:
00887 
00888       if (ATD_CLASS(attr_idx) == Constant) {
00889 
00890          /* If this is a structure or array, make sure the tmp associated */
00891          /* with the structure constructor is host associated.   At the   */
00892          /* moment stuff needs to be filled in for the temp, so just make */
00893          /* sure that the storage block gets created in the local scope.  */
00894 
00895          if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
00896             host_associated_attr_semantics(ATD_CONST_IDX(attr_idx), TRUE);
00897 
00898             if (referenced) {
00899                AT_REFERENCED(ATD_CONST_IDX(attr_idx)) = Referenced;
00900             }
00901          }
00902          break;
00903       }
00904 
00905 # if defined(GENERATE_WHIRL)
00906       if (ATD_IM_A_DOPE(attr_idx)                                   &&
00907              ATD_CLASS(attr_idx)                     == Dummy_Argument &&
00908              ATD_ARRAY_IDX(attr_idx)                                   &&
00909              BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Assumed_Shape &&
00910              ATD_SF_ARG_IDX(attr_idx) != NULL_IDX) {
00911 
00912          host_associated_attr_semantics(ATD_SF_ARG_IDX(attr_idx), TRUE);
00913 
00914          if (referenced) {
00915             AT_REFERENCED(ATD_SF_ARG_IDX(attr_idx)) = Referenced;
00916          }
00917       }
00918 # endif
00919 
00920       sb_idx = ATD_STOR_BLK_IDX(attr_idx);
00921 
00922       if (sb_idx == NULL_IDX || SB_SCP_IDX(sb_idx) == curr_scp_idx) {
00923          break;
00924       }
00925 
00926       /* The only FUNCTION results that can be host associated are those  */
00927       /* that are parents of the current program unit.  If this is a      */
00928       /* reference to a pgm_unit defined in an interface block or in a    */
00929       /* sibling, this is a call to the program unit.  That causes new    */
00930       /* tmps to be created.                                              */
00931 
00932       if (ATD_CLASS(attr_idx) == Function_Result && 
00933           !ATP_SCP_ALIVE(ATD_FUNC_IDX(attr_idx))) {
00934           break;
00935       }
00936          
00937       switch (SB_BLK_TYPE(sb_idx)) {
00938       case Common:
00939       case Task_Common:
00940       case Threadprivate:
00941 
00942          /* These are NOT host associated.  The storage block is copied into */
00943          /* the scope and these are treated as if the block was declared in  */
00944          /* each program unit.  Copy the attr down and break the link.       */
00945 
00946          local_sb_idx = srch_stor_blk_tbl(SB_NAME_PTR(sb_idx),
00947                                           SB_NAME_LEN(sb_idx),
00948                                           curr_scp_idx);
00949          if (local_sb_idx != NULL_IDX && 
00950              SB_HOST_ASSOCIATED(local_sb_idx) &&
00951              SB_ORIG_SCP_IDX(sb_idx) == SB_ORIG_SCP_IDX(local_sb_idx) &&
00952              SB_ORIG_SCP_IDX(sb_idx) != NULL_IDX) {
00953 
00954             /* This storage block has already been host associated into this */
00955             /* scope.  So do nothing.  Intentionally blank.                  */
00956          }
00957          else {
00958             TBL_REALLOC_CK(stor_blk_tbl, 1);
00959             stor_blk_tbl[stor_blk_tbl_idx]              = stor_blk_tbl[sb_idx];
00960             SB_ORIG_SCP_IDX(stor_blk_tbl_idx)           = SB_SCP_IDX(sb_idx);
00961             SB_SCP_IDX(stor_blk_tbl_idx)                = curr_scp_idx;
00962             SB_HOST_ASSOCIATED(stor_blk_tbl_idx)        = TRUE;
00963             SB_COMMON_NEEDS_OFFSET(stor_blk_tbl_idx)    = FALSE;
00964         
00965             if (local_sb_idx != NULL_IDX) { 
00966                SB_HIDDEN(stor_blk_tbl_idx)              = TRUE;
00967                SB_MERGED_BLK_IDX(stor_blk_tbl_idx)      = local_sb_idx;
00968 
00969                if (!SB_USE_ASSOCIATED(local_sb_idx) || 
00970                    !SB_USE_ASSOCIATED(sb_idx) ||
00971                     SB_HAS_RENAMES(local_sb_idx) ||
00972                     SB_HAS_RENAMES(sb_idx) ||
00973                    (compare_names(AT_OBJ_NAME_LONG(SB_MODULE_IDX(local_sb_idx)),
00974                                   AT_NAME_LEN(SB_MODULE_IDX(local_sb_idx)),
00975                                   AT_OBJ_NAME_LONG(SB_MODULE_IDX(sb_idx)),
00976                                   AT_NAME_LEN(SB_MODULE_IDX(sb_idx))) != 0)) {
00977                   SB_DEF_MULT_SCPS(stor_blk_tbl_idx)    = TRUE;
00978                   SB_DEF_MULT_SCPS(sb_idx)              = TRUE;
00979                }
00980             }
00981             else if (SB_MODULE(stor_blk_tbl_idx)) {
00982 
00983                if (SB_USE_ASSOCIATED(stor_blk_tbl_idx)) {
00984                   ADD_ATTR_TO_LOCAL_LIST(SB_MODULE_IDX(stor_blk_tbl_idx));
00985                }
00986             }
00987             local_sb_idx                        = stor_blk_tbl_idx;
00988          }
00989          break;
00990 
00991       case Static:
00992       case Static_Local:
00993       case Static_Named:
00994          if (SB_BLK_TYPE(sb_idx) == Static) {
00995 
00996             if (referenced) {
00997                AT_REFERENCED(attr_idx) = Referenced;
00998                AT_REF_IN_CHILD(attr_idx) = TRUE;
00999             }
01000 
01001             if (defined) {
01002                AT_REF_IN_CHILD(attr_idx) = TRUE;
01003             }  
01004 
01005          }
01006 
01007          /* These are NOT host associated.  This item needs to be in the     */
01008          /* host associated storage block for its scope.                     */
01009 
01010          if (!SB_USE_ASSOCIATED(sb_idx) &&
01011              (SB_BLK_TYPE(sb_idx) == Static_Local ||
01012               SB_BLK_TYPE(sb_idx) == Static_Named)) {
01013             new_scp = SB_SCP_IDX(sb_idx);
01014 
01015             if (SB_BLK_TYPE(sb_idx) == Static_Named) {
01016 
01017                if (SCP_SB_HOSTED_DATA_IDX(new_scp) == NULL_IDX) {
01018                   sb_idx = ntr_stor_blk_tbl(
01019                               SB_NAME_PTR(SCP_SB_STATIC_INIT_IDX(curr_scp_idx)),
01020                               SB_NAME_LEN(SCP_SB_STATIC_INIT_IDX(curr_scp_idx)),
01021                               AT_DEF_LINE(attr_idx),
01022                               AT_DEF_COLUMN(attr_idx),
01023                               Static);
01024    
01025                   name_ptr      = SB_NAME_PTR(sb_idx);
01026                   name_ptr[1]   = 'H';
01027                   name_ptr[2]   = 'O';
01028                   name_ptr[3]   = 'S';
01029                   name_ptr[4]   = 'T';
01030 
01031                   SB_SCP_IDX(sb_idx) = SB_SCP_IDX(ATD_STOR_BLK_IDX(attr_idx));
01032                   SB_ORIG_SCP_IDX(sb_idx) = 
01033                                   SB_ORIG_SCP_IDX(ATD_STOR_BLK_IDX(attr_idx));
01034                   SB_HOSTED_STATIC(sb_idx)              = TRUE;
01035                   SCP_SB_HOSTED_DATA_IDX(new_scp)       = sb_idx;
01036                   local_sb_idx                          = NULL_IDX;
01037                }
01038                else {
01039                   sb_idx        = SCP_SB_HOSTED_DATA_IDX(new_scp);
01040                   local_sb_idx  = srch_stor_blk_tbl(SB_NAME_PTR(sb_idx),
01041                                                             SB_NAME_LEN(sb_idx),
01042                                                             curr_scp_idx);
01043                }
01044             }
01045             else if (SCP_SB_HOSTED_STATIC_IDX(new_scp) == NULL_IDX) {
01046                sb_idx = ntr_stor_blk_tbl(
01047                                    SB_NAME_PTR(SCP_SB_STATIC_IDX(curr_scp_idx)),
01048                                    SB_NAME_LEN(SCP_SB_STATIC_IDX(curr_scp_idx)),
01049                                    AT_DEF_LINE(attr_idx),
01050                                    AT_DEF_COLUMN(attr_idx),
01051                                    Static);
01052 
01053                name_ptr         = SB_NAME_PTR(sb_idx);
01054                name_ptr[1]      = 'H';
01055                name_ptr[2]      = 'O';
01056                name_ptr[3]      = 'S';
01057                name_ptr[4]      = 'T';
01058 
01059                SB_SCP_IDX(sb_idx) = SB_SCP_IDX(ATD_STOR_BLK_IDX(attr_idx));
01060                SB_ORIG_SCP_IDX(sb_idx) = 
01061                                   SB_ORIG_SCP_IDX(ATD_STOR_BLK_IDX(attr_idx));
01062                SB_HOSTED_STATIC(sb_idx)         = TRUE;
01063                SCP_SB_HOSTED_STATIC_IDX(new_scp)= sb_idx;
01064                local_sb_idx                     = NULL_IDX;
01065             }
01066             else {
01067                sb_idx                   = SCP_SB_HOSTED_STATIC_IDX(new_scp);
01068                local_sb_idx             = srch_stor_blk_tbl(SB_NAME_PTR(sb_idx),
01069                                                             SB_NAME_LEN(sb_idx),
01070                                                             curr_scp_idx);
01071             }
01072 
01073             ATD_STOR_BLK_IDX(attr_idx)  = sb_idx;
01074 
01075             /* We've switched to a new storage block.  If this object is */
01076             /* equivalenced, we need to switch everything in this group  */
01077             /* to this new storage block.                                */
01078 
01079             if (ATD_EQUIV(attr_idx)) {
01080                group_idx = SCP_FIRST_EQUIV_GRP(new_scp);
01081 
01082                while (group_idx != NULL_IDX) {
01083                   eq_idx        = group_idx;
01084                   first_eq      = eq_idx;
01085                   group_idx     = EQ_NEXT_EQUIV_GRP(group_idx);
01086 
01087                   while (eq_idx != NULL_IDX) {
01088 
01089                      if (EQ_ATTR_IDX(eq_idx) == attr_idx) { /* Found */
01090                         eq_idx          = first_eq;
01091                         group_idx       = NULL_IDX;
01092 
01093                         while (eq_idx != NULL_IDX) {
01094                            host_associated_attr_semantics(EQ_ATTR_IDX(eq_idx),
01095                                                           FALSE);
01096                            eq_idx = EQ_NEXT_EQUIV_OBJ(eq_idx);
01097                         }
01098                      }
01099                      else {
01100                         eq_idx = EQ_NEXT_EQUIV_OBJ(eq_idx);
01101                      }
01102                   }
01103                }
01104             }
01105          }
01106          else {
01107             local_sb_idx = srch_stor_blk_tbl(SB_NAME_PTR(sb_idx),
01108                                              SB_NAME_LEN(sb_idx),
01109                                              curr_scp_idx);
01110          }
01111 
01112          if (local_sb_idx != NULL_IDX && 
01113              SB_HOST_ASSOCIATED(local_sb_idx) &&
01114              SB_ORIG_SCP_IDX(sb_idx) == SB_ORIG_SCP_IDX(local_sb_idx) &&
01115              SB_ORIG_SCP_IDX(sb_idx) != NULL_IDX) {
01116 
01117             /* This storage block has already been host associated into this */
01118             /* scope.  So do nothing.  Intentionally blank.                  */
01119          }
01120          else {
01121             TBL_REALLOC_CK(stor_blk_tbl, 1);
01122             stor_blk_tbl[stor_blk_tbl_idx]              = stor_blk_tbl[sb_idx];
01123             SB_ORIG_SCP_IDX(stor_blk_tbl_idx)           = SB_SCP_IDX(sb_idx);
01124             SB_SCP_IDX(stor_blk_tbl_idx)                = curr_scp_idx;
01125             SB_HOST_ASSOCIATED(stor_blk_tbl_idx)        = TRUE;
01126             SB_COMMON_NEEDS_OFFSET(stor_blk_tbl_idx)    = FALSE;
01127         
01128             if (local_sb_idx != NULL_IDX) { 
01129                SB_HIDDEN(stor_blk_tbl_idx)              = TRUE;
01130                SB_MERGED_BLK_IDX(stor_blk_tbl_idx)      = local_sb_idx;
01131 
01132                if (!SB_USE_ASSOCIATED(local_sb_idx) || 
01133                    !SB_USE_ASSOCIATED(sb_idx) ||
01134                     SB_HAS_RENAMES(local_sb_idx) ||
01135                     SB_HAS_RENAMES(sb_idx) ||
01136                    (compare_names(AT_OBJ_NAME_LONG(SB_MODULE_IDX(local_sb_idx)),
01137                                   AT_NAME_LEN(SB_MODULE_IDX(local_sb_idx)),
01138                                   AT_OBJ_NAME_LONG(SB_MODULE_IDX(sb_idx)),
01139                                   AT_NAME_LEN(SB_MODULE_IDX(sb_idx))) != 0)) {
01140                   SB_DEF_MULT_SCPS(stor_blk_tbl_idx)    = TRUE;
01141                   SB_DEF_MULT_SCPS(sb_idx)              = TRUE;
01142                }
01143             }
01144             else if (SB_MODULE(stor_blk_tbl_idx)) {
01145 
01146                if (SB_USE_ASSOCIATED(stor_blk_tbl_idx)) {
01147                   ADD_ATTR_TO_LOCAL_LIST(SB_MODULE_IDX(stor_blk_tbl_idx));
01148                }
01149          if (!AT_HOST_ASSOCIATED(local_attr_idx)) {
01150             AT_HOST_ASSOCIATED(attr_idx)        = TRUE;
01151             AT_HOST_ASSOCIATED(local_attr_idx)  = TRUE;
01152            }
01153          if (defined && ATD_CLASS(attr_idx) != Compiler_Tmp) {
01154             AT_DEFINED(attr_idx)        = TRUE;
01155             AT_DEF_IN_CHILD(attr_idx)   = TRUE;
01156           }
01157 
01158          if (referenced) {
01159             AT_REFERENCED(attr_idx)     = Referenced;
01160             AT_REF_IN_CHILD(attr_idx)   = TRUE;
01161           }
01162 
01163             }
01164             local_sb_idx = stor_blk_tbl_idx;
01165          }
01166          break;
01167 
01168       case Stack:
01169 
01170          if (!AT_HOST_ASSOCIATED(local_attr_idx)) {
01171             AT_HOST_ASSOCIATED(attr_idx)        = TRUE;
01172             AT_HOST_ASSOCIATED(local_attr_idx)  = TRUE;
01173             new_host_assoc                      = TRUE;
01174             new_scp                             = SB_SCP_IDX(sb_idx);
01175 
01176             if (SCP_SB_HOSTED_STACK_IDX(new_scp) == NULL_IDX) {
01177                CREATE_ID(name, sb_name[Stack_Host_Blk], sb_len[Stack_Host_Blk]);
01178                sb_idx = ntr_stor_blk_tbl(name.string,
01179                                          sb_len[Stack_Host_Blk],
01180                                          AT_DEF_LINE(attr_idx),
01181                                          AT_DEF_COLUMN(attr_idx),
01182                                          Stack);
01183                SB_SCP_IDX(sb_idx)               = new_scp;
01184                SB_HOSTED_STACK(sb_idx)          = TRUE;
01185                SCP_SB_HOSTED_STACK_IDX(new_scp) = sb_idx;
01186             }
01187             ATD_STOR_BLK_IDX(attr_idx)  = SCP_SB_HOSTED_STACK_IDX(new_scp);
01188          }
01189 
01190          /* If this is a compiler tmp, it should be a host associated   */
01191          /* bounds tmp.  That means it is only referenced in the child. */
01192 
01193          if (defined && ATD_CLASS(attr_idx) != Compiler_Tmp) {
01194             AT_DEFINED(attr_idx)        = TRUE;
01195             AT_DEF_IN_CHILD(attr_idx)   = TRUE;
01196          }
01197 
01198          if (referenced) {
01199             AT_REFERENCED(attr_idx)     = Referenced;
01200             AT_REF_IN_CHILD(attr_idx)   = TRUE;
01201          }
01202 
01203          break;
01204 
01205       case Equivalenced:
01206 
01207          if (!AT_HOST_ASSOCIATED(local_attr_idx)) {
01208             new_host_assoc                      = TRUE;
01209             AT_HOST_ASSOCIATED(attr_idx)        = TRUE;
01210             AT_HOST_ASSOCIATED(local_attr_idx)  = TRUE;
01211          }
01212 
01213          AT_DEFINED(attr_idx)           = AT_DEFINED(attr_idx) | defined;
01214          AT_DEF_IN_CHILD(attr_idx)      = AT_DEF_IN_CHILD(attr_idx) | defined;
01215          SB_HOSTED_STACK(sb_idx)        = TRUE;
01216 
01217          if (referenced) {
01218             AT_REFERENCED(attr_idx)     = Referenced;
01219             AT_REF_IN_CHILD(attr_idx)   = TRUE;
01220          }
01221 
01222          break;
01223 
01224       case Formal:
01225 
01226          if (!AT_HOST_ASSOCIATED(local_attr_idx)) {
01227             new_host_assoc                      = TRUE;
01228             AT_HOST_ASSOCIATED(attr_idx)        = TRUE;
01229             AT_HOST_ASSOCIATED(local_attr_idx)  = TRUE;
01230          }
01231 
01232          AT_DEFINED(attr_idx)           = AT_DEFINED(attr_idx) | defined;
01233          AT_DEF_IN_CHILD(attr_idx)      = AT_DEF_IN_CHILD(attr_idx) | defined;
01234 
01235          if (referenced) {
01236             AT_REFERENCED(attr_idx)     = Referenced;
01237             AT_REF_IN_CHILD(attr_idx)   = TRUE;
01238          }
01239          break;
01240 
01241       case Based:
01242 
01243          if (ATD_AUTOMATIC(attr_idx)) {
01244             host_associated_attr_semantics(ATD_AUTO_BASE_IDX(attr_idx), TRUE);
01245          }
01246          else {       /* Should be a Cray_Pointee */
01247             host_associated_attr_semantics(ATD_PTR_IDX(attr_idx), TRUE);
01248          }
01249 
01250          if (!AT_HOST_ASSOCIATED(local_attr_idx)) {
01251             new_host_assoc                      = TRUE;
01252             AT_HOST_ASSOCIATED(attr_idx)        = TRUE;
01253             AT_HOST_ASSOCIATED(local_attr_idx)  = TRUE;
01254          }
01255 
01256          AT_DEFINED(attr_idx)           = AT_DEFINED(attr_idx) | defined;
01257          AT_DEF_IN_CHILD(attr_idx)      = AT_DEF_IN_CHILD(attr_idx) | defined;
01258 
01259          if (referenced) {
01260             AT_REFERENCED(attr_idx)     = Referenced;
01261             AT_REF_IN_CHILD(attr_idx)   = TRUE;
01262          }
01263 
01264          /* Carry the local based storage on the local attr, so that it can */
01265          /* be passed through the interface.  We don't want to use the host */
01266 
01267          ATD_STOR_BLK_IDX(local_attr_idx) = SCP_SB_BASED_IDX(curr_scp_idx);
01268          break;
01269 
01270       default:
01271 
01272          if (!AT_HOST_ASSOCIATED(local_attr_idx)) {
01273             new_host_assoc                      = TRUE;
01274             AT_HOST_ASSOCIATED(attr_idx)        = TRUE;
01275             AT_HOST_ASSOCIATED(local_attr_idx)  = TRUE;
01276          }
01277          AT_DEFINED(attr_idx)           = AT_DEFINED(attr_idx) | defined;
01278          AT_DEF_IN_CHILD(attr_idx)      = AT_DEF_IN_CHILD(attr_idx) | defined;
01279 
01280          if (referenced) {
01281             AT_REFERENCED(attr_idx)     = Referenced;
01282             AT_REF_IN_CHILD(attr_idx)   = TRUE;
01283          }
01284          break;
01285       }  /* End switch */
01286 
01287       if (new_host_assoc) {  /* This attr is now host associated */
01288 
01289          if (ATD_CLASS(attr_idx) == Variable &&
01290              ATD_FLD(attr_idx) != NO_Tbl_Idx) {
01291 
01292             /* This has data initialized tmps associated with it.  These can */
01293             /* get here if the attr is use associated and then hosted.       */
01294 
01295             if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
01296                host_associated_attr_semantics(ATD_VARIABLE_TMP_IDX(attr_idx), 
01297                                               TRUE);
01298             }
01299             else if (ATD_FLD(attr_idx) == IL_Tbl_Idx) {
01300 
01301                /* Must be structure - Have a list of tmps */
01302 
01303                il_idx = ATD_VARIABLE_TMP_IDX(attr_idx);
01304 
01305                while (il_idx != NULL_IDX) {
01306                   host_associated_attr_semantics(IL_IDX(il_idx), TRUE); 
01307                   il_idx = IL_NEXT_LIST_IDX(il_idx);
01308                }
01309             }
01310          }
01311 
01312          type_idx = ATD_TYPE_IDX(attr_idx);
01313    
01314          if (TYP_TYPE(type_idx) == Character &&
01315              TYP_FLD(type_idx) == AT_Tbl_Idx) {
01316             host_associated_attr_semantics(TYP_IDX(type_idx), TRUE);
01317          }
01318    
01319          bd_idx = ATD_ARRAY_IDX(attr_idx);
01320    
01321          if (bd_idx != NULL_IDX &&
01322              BD_ARRAY_SIZE(bd_idx) != Constant_Size && 
01323              BD_ARRAY_SIZE(bd_idx) != Unknown_Size     ) {
01324    
01325             for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
01326    
01327                if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01328                   host_associated_attr_semantics(BD_LB_IDX(bd_idx, dim), TRUE);
01329                }
01330    
01331                if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01332                   host_associated_attr_semantics(BD_UB_IDX(bd_idx, dim), TRUE);
01333                }
01334    
01335                if (BD_XT_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01336                   host_associated_attr_semantics(BD_XT_IDX(bd_idx, dim), TRUE);
01337                }
01338       
01339                if (BD_SM_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01340                   host_associated_attr_semantics(BD_SM_IDX(bd_idx, dim), TRUE);
01341                }
01342             }
01343    
01344             if (BD_LEN_FLD(bd_idx) == AT_Tbl_Idx) {
01345                host_associated_attr_semantics(BD_LEN_IDX(bd_idx), TRUE);
01346             }
01347          }
01348       }
01349       break;
01350 
01351    case Pgm_Unit:
01352 
01353       /* If ATP_SCP_ALIVE is set, then we are host associating the host's     */
01354       /* function result or we are calling the host.  Since we don't know for */
01355       /* sure what is going on, assume the function result is host associated.*/
01356 
01357       AT_DEFINED(attr_idx)      = AT_DEFINED(attr_idx) | defined;
01358       AT_DEF_IN_CHILD(attr_idx) = AT_DEF_IN_CHILD(attr_idx) | defined;
01359 
01360       if (referenced) {
01361          AT_REFERENCED(attr_idx)        = Referenced;
01362          AT_REF_IN_CHILD(attr_idx)      = TRUE;
01363       }
01364 
01365       if (ATP_PGM_UNIT(attr_idx) == Function &&
01366           ATP_SCP_ALIVE(attr_idx) && !ATP_RSLT_NAME(attr_idx)) {
01367          host_associated_attr_semantics(ATP_RSLT_IDX(attr_idx), FALSE);
01368       }
01369       break;
01370 
01371    case Namelist_Grp:
01372 
01373       COPY_ATTR_NTRY(local_attr_idx, attr_idx);
01374 
01375       /* Note that AT_CIF_SYMBOL_ID remains as the symbol id of the name in   */
01376       /* the host.  We need this to make all references resolve to the host   */
01377       /* so that CIF processing only sees one namelist group name (the one in */
01378       /* the host).                                                           */
01379 
01380       AT_ATTR_LINK(local_attr_idx)              = NULL_IDX;
01381       AT_REFERENCED(local_attr_idx)             = referenced;
01382       AT_DEFINED(local_attr_idx)                = defined;
01383       AT_HOST_ASSOCIATED(local_attr_idx)        = TRUE;
01384 
01385       if (ATN_NAMELIST_DESC(attr_idx) != NULL_IDX) {
01386          host_associated_attr_semantics(ATN_NAMELIST_DESC(attr_idx), TRUE);
01387       }
01388 
01389       sn_idx            = ATN_FIRST_NAMELIST_IDX(attr_idx);
01390       new_sn_idx        = NULL_IDX;
01391 
01392       while (sn_idx != NULL_IDX) {
01393 
01394          if (new_sn_idx == NULL_IDX) {
01395             NTR_SN_TBL(new_sn_idx);
01396             ATN_FIRST_NAMELIST_IDX(local_attr_idx)      = new_sn_idx;
01397          }
01398          else {
01399             NTR_SN_TBL(name_idx);
01400             SN_SIBLING_LINK(new_sn_idx) = name_idx;
01401             new_sn_idx                  = name_idx;
01402          }
01403 
01404          sec_name_tbl[new_sn_idx]       = sec_name_tbl[sn_idx];
01405 
01406          local_attr_idx = srch_sym_tbl(AT_OBJ_NAME_PTR(SN_ATTR_IDX(sn_idx)),
01407                                        AT_NAME_LEN(SN_ATTR_IDX(sn_idx)),
01408                                        &name_idx);
01409 
01410          if (local_attr_idx != NULL_IDX && 
01411              AT_ATTR_LINK(local_attr_idx) != NULL_IDX) {
01412 
01413             new_attr_idx = AT_ATTR_LINK(local_attr_idx);
01414 
01415             while (AT_ATTR_LINK(new_attr_idx) != NULL_IDX) {
01416                new_attr_idx = AT_ATTR_LINK(new_attr_idx);
01417             }
01418 
01419             if (new_attr_idx != SN_ATTR_IDX(sn_idx)) {
01420 
01421                /* If the attr indexes are equal, the attr_idx has already */
01422                /* been host associated into this scope, so use that attr. */
01423                /* Otherwise, host associate this attr into this scope.    */
01424 
01425                NTR_ATTR_TBL(local_attr_idx);
01426                AT_ATTR_LINK(local_attr_idx) = SN_ATTR_IDX(sn_idx);
01427                host_associated_attr_semantics(SN_ATTR_IDX(sn_idx), FALSE);
01428             }
01429          }
01430          else {
01431 
01432             /* Something by this name has not been host associated into   */
01433             /* this scope, so attr link this and host associate it in.    */
01434 
01435             NTR_ATTR_TBL(local_attr_idx);
01436             AT_ATTR_LINK(local_attr_idx) = SN_ATTR_IDX(sn_idx);
01437             host_associated_attr_semantics(SN_ATTR_IDX(sn_idx), FALSE);
01438          }
01439 
01440          SN_ATTR_IDX(new_sn_idx)        = local_attr_idx;
01441          sn_idx                         = SN_SIBLING_LINK(sn_idx);
01442       }
01443 
01444       break;
01445 
01446    case Interface:
01447 
01448       /* KAY - What does this mean.  If there is a program by the same name  */
01449       /*       as the interface, how do we know its been referenced?   Plus  */
01450       /*       interfaces are concatted together.  Research this.            */
01451       /*       What about referenced and defined?                            */
01452 
01453       break;
01454 
01455    case Stmt_Func:
01456 
01457       /* Need to check the statement function body for anything else that is */
01458       /* host associated.  ie:  Traverse the IR.                             */
01459 
01460       switch (ATS_SF_FLD(attr_idx)) {
01461       case AT_Tbl_Idx:
01462          host_associated_attr_semantics(ATS_SF_IDX(attr_idx), TRUE);
01463          break;
01464 
01465       case IR_Tbl_Idx:
01466          find_host_associated_attrs_in_ir(ATS_SF_IDX(attr_idx));
01467          break;
01468 
01469       case IL_Tbl_Idx:
01470          find_host_associated_attrs_in_il(ATS_SF_IDX(attr_idx));
01471          break;
01472       }
01473       break;
01474    }
01475 
01476    if (add_to_attr_list) {
01477       ADD_ATTR_TO_LOCAL_LIST(local_attr_idx);
01478    }
01479    
01480    TRACE (Func_Exit, "host_associated_attr_semantics", NULL);
01481 
01482    return;
01483 
01484 }  /* host_associated_attr_semantics */
01485 
01486 /******************************************************************************\
01487 |*                                                                            *|
01488 |* Description:                                                               *|
01489 |*                                                                            *|
01490 |* Input parameters:                                                          *|
01491 |*      NONE                                                                  *|
01492 |*                                                                            *|
01493 |* Output parameters:                                                         *|
01494 |*      NONE                                                                  *|
01495 |*                                                                            *|
01496 |* Returns:                                                                   *|
01497 |*      NOTHING                                                               *|
01498 |*                                                                            *|
01499 \******************************************************************************/
01500 
01501 static  void    find_host_associated_attrs_in_ir(int    ir_idx)
01502 
01503 {
01504 
01505    TRACE (Func_Entry, "find_host_associated_attrs_in_ir", NULL);
01506 
01507    switch (IR_FLD_L(ir_idx)) {
01508    case AT_Tbl_Idx:
01509       host_associated_attr_semantics(IR_IDX_L(ir_idx), TRUE);
01510       break;
01511 
01512    case IR_Tbl_Idx:
01513       find_host_associated_attrs_in_ir(IR_IDX_L(ir_idx));
01514       break;
01515 
01516    case IL_Tbl_Idx:
01517       find_host_associated_attrs_in_il(IR_IDX_L(ir_idx));
01518       break;
01519 
01520    case CN_Tbl_Idx:
01521    case NO_Tbl_Idx:
01522    case SH_Tbl_Idx:
01523       break;
01524    }
01525 
01526    switch (IR_FLD_R(ir_idx)) {
01527    case AT_Tbl_Idx:
01528       host_associated_attr_semantics(IR_IDX_R(ir_idx), TRUE);
01529       break;
01530 
01531    case IR_Tbl_Idx:
01532       find_host_associated_attrs_in_ir(IR_IDX_R(ir_idx));
01533       break;
01534 
01535    case IL_Tbl_Idx:
01536       find_host_associated_attrs_in_il(IR_IDX_R(ir_idx));
01537       break;
01538 
01539    case CN_Tbl_Idx:
01540    case NO_Tbl_Idx:
01541    case SH_Tbl_Idx:
01542       break;
01543    }
01544 
01545    TRACE (Func_Exit, "find_host_associated_attrs_in_ir", NULL);
01546 
01547    return;
01548 
01549 }  /* find_host_associated_attrs_in_ir */
01550 
01551 /******************************************************************************\
01552 |*                                                                            *|
01553 |* Description:                                                               *|
01554 |*                                                                            *|
01555 |* Input parameters:                                                          *|
01556 |*      NONE                                                                  *|
01557 |*                                                                            *|
01558 |* Output parameters:                                                         *|
01559 |*      NONE                                                                  *|
01560 |*                                                                            *|
01561 |* Returns:                                                                   *|
01562 |*      NOTHING                                                               *|
01563 |*                                                                            *|
01564 \******************************************************************************/
01565 
01566 static  void    find_host_associated_attrs_in_il(int    list_idx)
01567 
01568 {
01569    TRACE (Func_Entry, "find_host_associated_attrs_in_il", NULL);
01570 
01571    while (list_idx != NULL_IDX) {
01572 
01573       switch (IL_FLD(list_idx)) {
01574       case AT_Tbl_Idx:
01575          host_associated_attr_semantics(IL_IDX(list_idx), TRUE);
01576          break;
01577 
01578       case IR_Tbl_Idx:
01579          find_host_associated_attrs_in_ir(IL_IDX(list_idx));
01580          break;
01581 
01582       case IL_Tbl_Idx:
01583          find_host_associated_attrs_in_il(IL_IDX(list_idx));
01584          break;
01585 
01586       case NO_Tbl_Idx:
01587       case SH_Tbl_Idx:
01588       case CN_Tbl_Idx:
01589          break;
01590       }
01591       list_idx = IL_NEXT_LIST_IDX(list_idx);
01592    }
01593 
01594    TRACE (Func_Exit, "find_host_associated_attrs_in_il", NULL);
01595 
01596    return;
01597 
01598 }  /* find_host_associated_attrs_in_il */
01599 
01600 /******************************************************************************\
01601 |*                                                                            *|
01602 |* Description:                                                               *|
01603 |*      initialize the zero'd arg_info struct and the exp_desc struct for     *|
01604 |*      call list processing and expr_semantics.                              *|
01605 |*                                                                            *|
01606 |* Input parameters:                                                          *|
01607 |*      NONE                                                                  *|
01608 |*                                                                            *|
01609 |* Output parameters:                                                         *|
01610 |*      NONE                                                                  *|
01611 |*                                                                            *|
01612 |* Returns:                                                                   *|
01613 |*      NOTHING                                                               *|
01614 |*                                                                            *|
01615 \******************************************************************************/
01616 
01617 static void init_call_structs(void)
01618 
01619 {
01620    int          i;
01621 
01622    TRACE (Func_Entry, "init_call_structs", NULL);
01623 
01624    init_exp_desc.type_idx         = TYPELESS_DEFAULT_TYPE;
01625    init_exp_desc.rank             = 0;
01626    init_exp_desc.cif_id           = 0;
01627    init_exp_desc.type             = Typeless;
01628    init_exp_desc.linear_type      = Err_Res;
01629    init_exp_desc.kind0seen        = FALSE;
01630    init_exp_desc.kind0D0seen      = FALSE;
01631    init_exp_desc.percent_val_arg  = FALSE;
01632    init_exp_desc.constant         = FALSE;
01633    init_exp_desc.foldable         = FALSE;
01634    init_exp_desc.will_fold_later  = FALSE;
01635    init_exp_desc.pointer          = FALSE;
01636    init_exp_desc.target           = FALSE;
01637    init_exp_desc.vector_subscript = FALSE;
01638    init_exp_desc.reference        = FALSE;
01639    init_exp_desc.constructor      = FALSE;
01640    init_exp_desc.component        = FALSE;
01641    init_exp_desc.section          = FALSE;
01642    init_exp_desc.label            = FALSE;
01643    init_exp_desc.array_elt        = FALSE;
01644    init_exp_desc.assumed_shape    = FALSE;
01645    init_exp_desc.assumed_size     = FALSE;
01646    init_exp_desc.allocatable      = FALSE;
01647    init_exp_desc.dope_vector      = FALSE;
01648    init_exp_desc.tmp_reference    = FALSE;
01649    init_exp_desc.has_constructor  = FALSE;
01650    init_exp_desc.optional_darg    = FALSE;
01651    init_exp_desc.pe_dim_ref       = FALSE;
01652    init_exp_desc.contig_array     = FALSE;
01653    init_exp_desc.shape_known      = FALSE;
01654    init_exp_desc.tree_has_ranf    = FALSE;
01655    init_exp_desc.has_symbolic     = FALSE;
01656    init_exp_desc.dist_reshape_ref = FALSE;
01657    init_exp_desc.constructor_size_level = Unknown_Expr_Size;
01658 
01659    init_exp_desc.char_len = null_opnd;
01660 
01661    for (i = 0; i < 7; i++) {
01662       init_exp_desc.shape[i] = null_opnd;
01663    }
01664 
01665    init_arg_info.ed = init_exp_desc;
01666 
01667    init_arg_info.kwd                 = NULL_IDX;
01668    init_arg_info.line                = 0;
01669    init_arg_info.col                 = 0;
01670    init_arg_info.association         = 0;
01671    init_arg_info.arg_opnd            = null_opnd;
01672    init_arg_info.pgm_unit            = FALSE;
01673    init_arg_info.maybe_modified      = TRUE;
01674 
01675    TRACE (Func_Exit, "init_call_structs", NULL);
01676 
01677    return;
01678 
01679 }  /* init_call_structs */
01680 
01681 /******************************************************************************\
01682 |*                                                                            *|
01683 |* Description:                                                               *|
01684 |*      Check for a pending align cdir for a referenced user label.           *|
01685 |*                                                                            *|
01686 |* Input parameters:                                                          *|
01687 |*      NONE                                                                  *|
01688 |*                                                                            *|
01689 |* Output parameters:                                                         *|
01690 |*      NONE                                                                  *|
01691 |*                                                                            *|
01692 |* Returns:                                                                   *|
01693 |*      NOTHING                                                               *|
01694 |*                                                                            *|
01695 \******************************************************************************/
01696 
01697 void label_def_stmt_semantics(void)
01698 
01699 {
01700    int          label_idx;
01701 
01702    TRACE (Func_Entry, "label_def_stmt_semantics", NULL);
01703 
01704    label_idx = IR_IDX_L(SH_IR_IDX(curr_stmt_sh_idx));
01705 
01706    if (ATL_CLASS(label_idx) == Lbl_User &&
01707        AT_REFERENCED(label_idx) == Referenced && cdir_switches.align) {
01708 
01709       ATL_ALIGN(label_idx)      = TRUE;
01710       cdir_switches.align       = FALSE;
01711    }
01712 
01713    if (! cdir_switches.vector) {
01714       ATL_NOVECTOR(label_idx)  = TRUE;
01715    }
01716 
01717 # if defined(GENERATE_WHIRL)
01718    if (cdir_switches.notask_region) {
01719       ATL_NOTASK(label_idx)    = TRUE;
01720    }
01721 # else
01722    if (! cdir_switches.task) {
01723       ATL_NOTASK(label_idx)    = TRUE;
01724    }
01725 # endif
01726 
01727    if (! cdir_switches.vsearch) {
01728       ATL_NOVSEARCH(label_idx) = TRUE;
01729    }
01730 
01731    if (cdir_switches.bl) {
01732       ATL_BL(label_idx) = TRUE;
01733    }
01734 
01735    if (! cdir_switches.recurrence) {
01736       ATL_NORECURRENCE(label_idx) = TRUE;
01737    }
01738 
01739    if (cdir_switches.pattern) {
01740       ATL_PATTERN(label_idx) = TRUE;
01741    }
01742 
01743    TRACE (Func_Exit, "label_def_stmt_semantics", NULL);
01744 
01745    return;
01746 
01747 }  /* label_def_stmt_semantics */
01748 
01749 /******************************************************************************\
01750 |*                                                                            *|
01751 |* Description:                                                               *|
01752 |*      This assigns storage offsets at the end of the semantics pass.        *|
01753 |*      This assumes parents are processed before children.  This also        *|
01754 |*      assumes that tmps are assigned after all declared variables.  This is *|
01755 |*      needed for the data initialization array optimization.  ATD_TMP_IDX   *|
01756 |*      on the compiler tmps with ATD_DATA_INIT set is a pointer to the       *|
01757 |*      variable that is being data initialized.                              *|
01758 |*      If CIF records are being generated, it generates OBJECT records for   *|
01759 |*      everything in the local name table that CIF wants.                    *|
01760 |*                                                                            *|
01761 |* Input parameters:                                                          *|
01762 |*       NONE                                                                 *|
01763 |*                                                                            *|
01764 |* Output parameters:                                                         *|
01765 |*       NONE                                                                 *|
01766 |*                                                                            *|
01767 |* Returns:                                                                   *|
01768 |*       NONE                                                                 *|
01769 |*                                                                            *|
01770 \******************************************************************************/
01771 static  void    final_decl_semantics(void)
01772 
01773 {
01774    int                  al_idx;
01775    int                  attr_idx;
01776    int                  name_idx;
01777    int                  symbolic_constant       = NULL_IDX;
01778 
01779 
01780 # if defined(_ASSIGN_OFFSETS_TO_HOSTED_STACK)
01781    size_offset_type     length;
01782    int                  list_idx;
01783    size_offset_type     result;
01784    int                  sb_idx;
01785 # endif
01786 
01787 
01788    TRACE (Func_Entry, "final_decl_semantics", NULL);
01789 
01790    /* This holds a list of all arrays whose bounds are based on symbolic */
01791    /* constants that need to have offsets assigned.  (Except for common  */
01792    /* blocks.)  This ensures that in static and module blocks, all the   */
01793    /* symbolic constant based arrays are at the end of the block.  Then  */
01794    /* anything in the block that is not a symbolic constant based array  */
01795    /* can be equivalenced or data initialized.                           */
01796 
01797    symbolic_constant_array_list = NULL_IDX;
01798 
01799    /* Mark the start of the assign label chain, in case this procedure      */
01800    /* ends up going out for USE processing and coming back in for inlining. */
01801    /* We can then find the start of the chain without having a scope table. */
01802 
01803    if (SCP_ASSIGN_LBL_CHAIN(curr_scp_idx) != NULL_IDX) {
01804       ATL_ASG_LBL_CHAIN_START(SCP_ASSIGN_LBL_CHAIN(curr_scp_idx))       = TRUE;
01805    }
01806 
01807    /* Do final processing of equivalence groups, it there are no errors.    */
01808 
01809    if (num_prog_unit_errors == 0) {
01810       final_equivalence_semantics();
01811    }
01812 
01813    storage_blk_resolution();
01814 
01815    for (name_idx = SCP_LN_FW_IDX(curr_scp_idx) + 1; 
01816         name_idx < SCP_LN_LW_IDX(curr_scp_idx); name_idx++) {
01817 
01818       attr_idx = LN_ATTR_IDX(name_idx);
01819 
01820       if (!AT_DCL_ERR(attr_idx)) {
01821 
01822          if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
01823              ATD_SYMBOLIC_CONSTANT(attr_idx) &&
01824              (ATD_CLASS(attr_idx) == Constant ||
01825               ATD_CLASS(attr_idx) == Variable)) {
01826             symbolic_constant = attr_idx;
01827          }
01828          else {
01829             final_attr_semantics(attr_idx);
01830          }
01831       }
01832    }
01833 
01834 
01835    if (symbolic_constant != NULL_IDX &&
01836        (ATD_CLASS(symbolic_constant) == Constant ||
01837         AT_REFERENCED(symbolic_constant) == Not_Referenced)) {
01838 
01839       /* Remove N$PES from the name table here.  This is needed so N$PES   */
01840       /* doesn't cause problems in MODULE processing.                      */
01841 
01842       srch_sym_tbl(AT_OBJ_NAME_PTR(symbolic_constant),
01843                    AT_NAME_LEN(symbolic_constant),
01844                    &name_idx);
01845 
01846       remove_ln_ntry(name_idx);
01847    }
01848 
01849    al_idx       = SCP_ATTR_LIST(curr_scp_idx);
01850 
01851    while (al_idx != NULL_IDX) {
01852 
01853       if (!AT_DCL_ERR(AL_ATTR_IDX(al_idx))) {
01854          final_attr_semantics(AL_ATTR_IDX(al_idx));
01855       }
01856 
01857       al_idx = AL_NEXT_IDX(al_idx);
01858    }
01859 
01860    al_idx       = symbolic_constant_array_list;
01861 
01862    while (al_idx != NULL_IDX) {
01863       assign_offset(AL_ATTR_IDX(al_idx));  /* symbolic constants */
01864       al_idx = AL_NEXT_IDX(al_idx);
01865    }
01866 
01867 # if defined(_ASSIGN_OFFSETS_TO_HOSTED_STACK)
01868 
01869    if (SCP_SB_HOSTED_STACK_IDX(curr_scp_idx) != NULL_IDX) {
01870 
01871       /* Have stack items that are hosted.  Need to add a tmp for the */
01872       /* block length.  Any time this hosted stack is used, the tmp   */
01873       /* must be host associated as well.  Special case is the zero   */
01874       /* block length.  We do not need a tmp, because if nothing is   */
01875       /* hosted, the block doesn't get in.  If one or more things are */
01876       /* hosted, then the length will still be correct at zero.       */
01877 
01878       sb_idx                    = SCP_SB_HOSTED_STACK_IDX(curr_scp_idx);
01879 
01880       /* KAY - If this is set to AT_Tbl_Idx, it should not be 0. */
01881 
01882       if (SB_LEN_FLD(sb_idx) == AT_Tbl_Idx ||
01883           fold_relationals(SB_LEN_IDX(sb_idx), CN_INTEGER_ZERO_IDX, Ne_Opr)) {
01884 
01885          result.idx     = SB_LEN_IDX(sb_idx);
01886          result.fld     = SB_LEN_FLD(sb_idx);
01887 
01888          align_bit_length(&result, TARGET_BITS_PER_WORD);
01889 
01890          if (result.fld == NO_Tbl_Idx) {
01891             result.fld  = CN_Tbl_Idx;
01892             result.idx  = ntr_const_tbl(result.type_idx,
01893                                         FALSE, 
01894                                         result.constant);
01895          }
01896 
01897          SB_LEN_FLD(sb_idx)     = result.fld;
01898          SB_LEN_IDX(sb_idx)     = result.idx;
01899          attr_idx               = gen_compiler_tmp(SB_DEF_LINE(sb_idx),
01900                                                    SB_DEF_COLUMN(sb_idx),
01901                                                    Priv, TRUE);
01902 
01903          ATD_TYPE_IDX(attr_idx)         = TYPELESS_DEFAULT_TYPE;
01904          ATD_STOR_BLK_IDX(attr_idx)     = sb_idx;
01905          ATD_OFFSET_ASSIGNED(attr_idx)  = TRUE;
01906          AT_REFERENCED(attr_idx)        = Referenced;  /* Force thru PDGCS */
01907          AT_REF_IN_CHILD(attr_idx)      = TRUE;        /* Force thru PDGCS */
01908          NTR_ATTR_LIST_TBL(list_idx);
01909          AL_ATTR_IDX(list_idx)          = attr_idx;
01910          SB_LAST_ATTR_LIST(sb_idx)      = list_idx;
01911 
01912          /* This must be at least one word length, because  */
01913          /* the bit length has been word aligned.           */
01914 
01915          length.fld     = CN_Tbl_Idx;
01916          length.idx     = CN_INTEGER_BITS_PER_WORD_IDX;
01917 
01918          if (!size_offset_binary_calc(&result, &length, Minus_Opr, &result)) {
01919             AT_DCL_ERR(attr_idx) = TRUE;
01920          }
01921 
01922          if (result.fld == NO_Tbl_Idx) {
01923             ATD_OFFSET_FLD(attr_idx) = CN_Tbl_Idx;
01924             ATD_OFFSET_IDX(attr_idx) = ntr_const_tbl(result.type_idx,
01925                                                      FALSE,
01926                                                      result.constant);
01927          }
01928          else {
01929             ATD_OFFSET_FLD(attr_idx) = result.fld;
01930             ATD_OFFSET_IDX(attr_idx) = result.idx;
01931          }
01932       }
01933    }
01934 # endif
01935 
01936    /* Check CIF option to see if symbol table needs to be written to CIF.  */
01937    /* Need to use BASIC_RECS to output the Entry Info and Common Block     */
01938    /* records if the user just specifies "-cf".                            */
01939 
01940    if (cif_flags & BASIC_RECS) {
01941       cif_send_sytb();
01942    }
01943 
01944    TRACE (Func_Exit, "final_decl_semantics", NULL);
01945 
01946    return;
01947 
01948 }  /* final_decl_semantics */
01949 
01950 /******************************************************************************\
01951 |*                                                                            *|
01952 |* Description:                                                               *|
01953 |*      Allocates storage and offsets for all COMMON blocks.                  *|
01954 |*                                                                            *|
01955 |* Input parameters:                                                          *|
01956 |*      NONE                                                                  *|
01957 |*                                                                            *|
01958 |* Output parameters:                                                         *|
01959 |*      NONE                                                                  *|
01960 |*                                                                            *|
01961 |* Returns:                                                                   *|
01962 |*      NONE                                                                  *|
01963 |*                                                                            *|
01964 \******************************************************************************/
01965 static void     final_attr_semantics(int        attr_idx)
01966 
01967 {
01968                 int                     al_idx;
01969                 int                     darg_idx;
01970                 int                     i;
01971                 int                     il_idx;
01972                 int                     local_attr_idx;
01973                 int                     rslt_idx;
01974                 int                     sb_idx;
01975                 int                     sn_idx;
01976 
01977                 int                     type_idx;
01978 
01979 # if defined(_ASSIGN_OFFSETS_TO_HOSTED_STACK)
01980    static       int                     tmp_scp_idx     = NULL_IDX;
01981 # endif
01982 
01983 # if defined(_TMP_GIVES_COMMON_LENGTH)
01984                 size_offset_type        length;
01985                 size_offset_type        result;
01986                 size_offset_type        size;
01987                 size_offset_type        zero;
01988 # endif
01989 
01990    TRACE (Func_Entry, "final_attr_semantics", NULL);
01991 
01992    if (AT_ATTR_LINK(attr_idx) == NULL_IDX || AT_IGNORE_ATTR_LINK(attr_idx)) {
01993 
01994       switch (AT_OBJ_CLASS(attr_idx)) {
01995       case Data_Obj:
01996 
01997          if (ATD_EQUIV_LIST(attr_idx) != NULL_IDX) {
01998             free_attr_list(ATD_EQUIV_LIST(attr_idx));
01999             ATD_EQUIV_LIST(attr_idx)    = NULL_IDX;
02000          }
02001 
02002          if (ATD_NO_ENTRY_LIST(attr_idx) != NULL_IDX) {
02003             free_attr_list(ATD_NO_ENTRY_LIST(attr_idx));
02004             ATD_NO_ENTRY_LIST(attr_idx) = NULL_IDX;
02005          }
02006 
02007          switch (ATD_CLASS(attr_idx)) {
02008          case Constant:
02009 
02010 # ifdef _DEBUG
02011             if (ATD_FLD(attr_idx) == NO_Tbl_Idx) {
02012                PRINTMSG(AT_DEF_LINE(attr_idx), 893, Internal, 
02013                         AT_DEF_COLUMN(attr_idx),
02014                         "ATD_CONST_IDX",
02015                         "ATD_FLD",
02016                         "attr_tbl",
02017                         attr_idx);
02018             }
02019 # endif
02020 
02021             /* Mark the overlay tmp as Referenced.  Have to delay until this */
02022             /* point, because the tmp is not created yet.  Can't do it when  */
02023             /* the tmp is created, because this also must be done for        */
02024             /* use associated constants.                                     */
02025 
02026             if (ATD_FLD(attr_idx) == AT_Tbl_Idx && 
02027                AT_REFERENCED(attr_idx) != Not_Referenced) {
02028                AT_REFERENCED(ATD_CONST_IDX(attr_idx)) = Referenced;
02029             }
02030 
02031             attr_idx = NULL_IDX;
02032             break;
02033 
02034          case Struct_Component:
02035             attr_idx = NULL_IDX;
02036             break;
02037 
02038          case Function_Result:  /* These are done, when the Function is */
02039             attr_idx = NULL_IDX;
02040             break;
02041 
02042          case Compiler_Tmp:
02043 # ifdef _DEBUG
02044             if (ATD_FLD(attr_idx) == NO_Tbl_Idx &&
02045                 ATD_TMP_IDX(attr_idx) != NULL_IDX) {
02046                PRINTMSG(AT_DEF_LINE(attr_idx), 893, Internal, 
02047                         AT_DEF_COLUMN(attr_idx),
02048                         "ATD_TMP_IDX",
02049                         "ATD_FLD",
02050                         "attr_tbl",
02051                         attr_idx);
02052             }
02053 
02054 # endif
02055             if (ATD_TMP_INIT_NOT_DONE(attr_idx) &&
02056                 ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module) {
02057  
02058                 /* Have a default init temp.  Generate the init */
02059                 /* in the module, so it is ready to be used     */
02060                 /* wherever the module is used.                 */
02061 
02062                insert_init_stmt_for_tmp(attr_idx);
02063             }
02064 
02065             sb_idx = ATD_STOR_BLK_IDX(attr_idx);
02066 
02067 # if defined(_TMP_GIVES_COMMON_LENGTH)
02068 
02069             if (AT_REFERENCED(attr_idx) == Not_Referenced &&
02070                 !ATD_OFFSET_ASSIGNED(attr_idx) &&
02071                 sb_idx != NULL_IDX &&
02072                 (SB_USE_ASSOCIATED(sb_idx) || SB_HOST_ASSOCIATED(sb_idx)) ) {
02073 
02074                /* If block length is zero, we do not need the tmp, so do  */
02075                /* not set AT_REFERENCED and it will not get sent across.  */
02076 
02077                if (SB_LEN_FLD(sb_idx) == CN_Tbl_Idx &&
02078                    fold_relationals(SB_LEN_IDX(sb_idx), 
02079                                     CN_INTEGER_ZERO_IDX, Ne_Opr)) {
02080                   size.fld      = CN_Tbl_Idx;
02081                   size.idx      = CN_INTEGER_BITS_PER_WORD_IDX;
02082                   length.fld    = SB_LEN_FLD(sb_idx);
02083                   length.idx    = SB_LEN_IDX(sb_idx);
02084 
02085                   size_offset_binary_calc(&length, &size, Mod_Opr, &size);
02086 
02087                   /* Size should always be less than TARGET_BITS_PER_WORD */
02088 
02089                   zero.fld      = CN_Tbl_Idx;
02090                   zero.idx      = CN_INTEGER_ZERO_IDX;
02091 
02092                   size_offset_logical_calc(&size, &zero, Eq_Opr, &result);
02093 
02094                   if (THIS_IS_TRUE(result.constant, result.type_idx)) {
02095                      size.idx   = CN_INTEGER_BITS_PER_WORD_IDX;
02096                      size.fld   = CN_Tbl_Idx;
02097                   }
02098 
02099                   CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
02100                   TYP_TYPE(TYP_WORK_IDX)        = Typeless;
02101                   TYP_BIT_LEN(TYP_WORK_IDX)     = (size.fld == CN_Tbl_Idx) ?
02102                       CN_INT_TO_C(size.idx) : F_INT_TO_C(size.constant,
02103                                                 TYP_LINEAR(size.type_idx));
02104                   ATD_TYPE_IDX(attr_idx)        = ntr_type_tbl();
02105 
02106                   if (!size_offset_binary_calc(&length,
02107                                                &size,
02108                                                 Minus_Opr, 
02109                                                &result)) {
02110                      AT_DCL_ERR(attr_idx) = TRUE;
02111                   }
02112 
02113                   if (result.fld == NO_Tbl_Idx) {
02114                      ATD_OFFSET_FLD(attr_idx) = CN_Tbl_Idx;
02115                      ATD_OFFSET_IDX(attr_idx) = ntr_const_tbl(result.type_idx,
02116                                                               FALSE,
02117                                                               result.constant);
02118                   }
02119                   else {
02120                      ATD_OFFSET_FLD(attr_idx) = result.fld;
02121                      ATD_OFFSET_IDX(attr_idx) = result.idx;
02122                   }
02123                 
02124                   ATD_OFFSET_ASSIGNED(attr_idx) = TRUE;
02125                   AT_REFERENCED(attr_idx)       = Referenced;
02126                }
02127 
02128 # ifdef _DEBUG
02129                if (ATD_OFFSET_ASSIGNED(attr_idx) &&
02130                    ATD_OFFSET_FLD(attr_idx) == CN_Tbl_Idx &&
02131                    fold_relationals(ATD_OFFSET_IDX(attr_idx),
02132                                     CN_INTEGER_ZERO_IDX,
02133                                     Lt_Opr)) {
02134                   PRINTMSG(AT_DEF_LINE(attr_idx), 1004, Internal, 
02135                            AT_DEF_COLUMN(attr_idx),
02136                            AT_OBJ_NAME_PTR(attr_idx),
02137                            attr_idx);
02138                }
02139 # endif
02140 
02141                 /* KAY - Is this in the correct spot * */
02142 
02143                if (ATD_DEFINING_ATTR_IDX(attr_idx) == NULL_IDX &&
02144                    ATD_FLD(attr_idx) == IR_Tbl_Idx &&
02145                    IR_FLD_R(ATD_TMP_IDX(attr_idx)) == AT_Tbl_Idx &&
02146                    AT_OBJ_CLASS(IR_IDX_R(ATD_TMP_IDX(attr_idx))) == Data_Obj &&
02147                    ATD_CLASS(IR_IDX_R(ATD_TMP_IDX(attr_idx))) == Compiler_Tmp) {
02148                   ATD_DEFINING_ATTR_IDX(attr_idx) =
02149                          ATD_DEFINING_ATTR_IDX(IR_IDX_R(ATD_TMP_IDX(attr_idx)));
02150                }
02151 
02152                attr_idx                         = NULL_IDX;
02153             }
02154 # endif
02155             break;
02156 
02157          case Variable:
02158 
02159             if (ATD_SYMBOLIC_CONSTANT(attr_idx) && 
02160                 AT_REFERENCED(attr_idx) == Referenced) {
02161                PRINTMSG(AT_DEF_LINE(attr_idx), 1229, Ansi, 
02162                         AT_DEF_COLUMN(attr_idx),
02163                         AT_OBJ_NAME_PTR(attr_idx));
02164             }
02165                
02166             if (ATD_FLD(attr_idx) != NO_Tbl_Idx) {
02167 
02168                /* This has data initialized tmps associated with it */
02169 
02170                if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
02171                   final_attr_semantics(ATD_VARIABLE_TMP_IDX(attr_idx));
02172                }
02173                else if (ATD_FLD(attr_idx) == IL_Tbl_Idx) {
02174 
02175                   /* Must be structure - Have a list of tmps */
02176 
02177                   il_idx = ATD_VARIABLE_TMP_IDX(attr_idx);
02178 
02179                   while (il_idx != NULL_IDX) {
02180                      final_attr_semantics(IL_IDX(il_idx)); 
02181                      il_idx = IL_NEXT_LIST_IDX(il_idx);
02182                   }
02183                }
02184             }
02185 
02186             /* Intentional fall through */
02187 
02188          default:
02189             sb_idx      = ATD_STOR_BLK_IDX(attr_idx);
02190 
02191             if (sb_idx != NULL_IDX) {
02192                type_idx = ATD_TYPE_IDX(attr_idx);
02193 
02194                if (SB_VOLATILE(sb_idx)) {
02195                   ATD_VOLATILE(attr_idx) = TRUE;
02196                }
02197 
02198                if (ATD_EQUIV_IN_BNDS_EXPR(attr_idx) && 
02199                    !AT_HOST_ASSOCIATED(attr_idx) &&
02200                    !AT_USE_ASSOCIATED(attr_idx) &&
02201                    !SB_IS_COMMON(sb_idx) &&
02202                    !ATD_SYMBOLIC_CONSTANT(attr_idx)) {
02203 
02204                   /* If final_equivalence_semantics isn't called, then */
02205                   /* we may issue this message in bogus situations.    */
02206 
02207                   if (SCP_FIRST_EQUIV_GRP(curr_scp_idx) == NULL_IDX ||
02208                       num_prog_unit_errors == 0) {
02209                      PRINTMSG(AT_DEF_LINE(attr_idx), 521, Error,
02210                               AT_DEF_COLUMN(attr_idx),
02211                               AT_OBJ_NAME_PTR(attr_idx));
02212                   }
02213                }
02214 
02215                if (SB_AUXILIARY(sb_idx)) {
02216 
02217                   if (AT_NAMELIST_OBJ(attr_idx) && SB_IS_COMMON(sb_idx)) {
02218                      PRINTMSG(AT_DEF_LINE(attr_idx), 663, Error,
02219                               AT_DEF_COLUMN(attr_idx),
02220                               AT_OBJ_NAME_PTR(attr_idx),
02221                               SB_NAME_PTR(sb_idx));
02222                   }
02223 
02224                   if (!ATD_AUXILIARY(attr_idx) && 
02225                       SB_BLK_TYPE(sb_idx) != Formal) {
02226 
02227                      /* Formal dargs do not cause all the dargs to become aux */
02228 
02229                      if (TYP_TYPE(type_idx) == Character) {
02230                         PRINTMSG(AT_DEF_LINE(attr_idx), 535, Error,
02231                                  AT_DEF_COLUMN(attr_idx),
02232                                  AT_OBJ_NAME_PTR(attr_idx));
02233                         AT_DCL_ERR(attr_idx)  = TRUE;
02234                      }
02235                      else if (TYP_TYPE(type_idx) == Structure &&
02236                               (ATT_POINTER_CPNT(TYP_IDX(type_idx)) ||
02237                                ATT_CHAR_CPNT(TYP_IDX(type_idx)))) {
02238                         PRINTMSG(AT_DEF_LINE(attr_idx), 536, Error,
02239                                  AT_DEF_COLUMN(attr_idx),
02240                                  AT_OBJ_NAME_PTR(attr_idx),
02241                                  AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
02242                         AT_DCL_ERR(attr_idx)  = TRUE;
02243                      }
02244                      else if (ATD_TARGET(attr_idx) ||
02245                               ATD_DATA_INIT(attr_idx) ||
02246                               ATD_POINTER(attr_idx) ||
02247                               TYP_TYPE(type_idx) == CRI_Ptr) {
02248                         fnd_semantic_err(Obj_Auxiliary, 
02249                                          AT_DEF_LINE(attr_idx),
02250                                          AT_DEF_COLUMN(attr_idx), 
02251                                          attr_idx,
02252                                          TRUE);
02253                      }
02254                      else {
02255                         ATD_AUXILIARY(attr_idx) = TRUE;
02256                      }
02257                   }
02258                }
02259             }
02260             break;
02261          }
02262 
02263          break;
02264 
02265       case Pgm_Unit:
02266 
02267          if (attr_idx != SCP_ATTR_IDX(curr_scp_idx) &&
02268              ATP_IN_INTERFACE_BLK(attr_idx) &&
02269              !AT_HOST_ASSOCIATED(attr_idx) &&
02270              !AT_USE_ASSOCIATED(attr_idx)) {
02271 
02272             attr_idx = NULL_IDX;
02273             break;
02274          }
02275 
02276          switch (ATP_PGM_UNIT(attr_idx)) {
02277          case Function:
02278          case Pgm_Unknown:
02279          case Subroutine:
02280 
02281             if (ATP_GLOBAL_ATTR_IDX(attr_idx) == NULL_IDX &&
02282                 ATP_EXPL_ITRFC(attr_idx) &&
02283                 !AT_COMPILER_GEND(attr_idx) &&
02284                 !ATP_NAME_IN_STONE(attr_idx) &&
02285                 (ATP_PROC(attr_idx) == Unknown_Proc ||
02286                  ATP_PROC(attr_idx) == Extern_Proc ||
02287                  ATP_PROC(attr_idx) == Imported_Proc) &&
02288                 !AT_IS_INTRIN(attr_idx) &&
02289                 (attr_idx != glb_tbl_idx[Main_Attr_Idx])) {
02290 
02291                /* This has not been entered or resolved globally yet.  */
02292                /* This routine checks for this name in the global name */
02293                /* table.  It enters it, if it doesn't exist or checks  */
02294                /* for semantics errors if it does exist.               */
02295 
02296                check_global_pgm_unit(attr_idx);
02297             }
02298 
02299             if (ATP_NO_ENTRY_LIST(attr_idx) != NULL_IDX) {
02300                free_attr_list(ATP_NO_ENTRY_LIST(attr_idx));
02301                ATP_NO_ENTRY_LIST(attr_idx)      = NULL_IDX;
02302             }
02303 
02304             if (ATP_PROC(attr_idx) == Module_Proc) {
02305 
02306                if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module &&
02307                    !AT_PRIVATE(attr_idx) && !AT_DCL_ERR(attr_idx)) {
02308 
02309                   /* The function result type and all dummy argument types */
02310                   /* must be public types, if the procedure is public.     */
02311 
02312                   if (ATP_PGM_UNIT(attr_idx) == Function) {
02313                      type_idx = ATD_TYPE_IDX(ATP_RSLT_IDX(attr_idx));
02314 
02315                      if (TYP_TYPE(type_idx) == Structure &&
02316                          AT_PRIVATE(TYP_IDX(type_idx)) &&
02317                         !AT_USE_ASSOCIATED(TYP_IDX(type_idx)) ) {
02318 
02319                         /* Issue error if the Module procedure is PUBLIC,  */
02320                         /* but its function result is a PRIVATE type.      */
02321                         /* Unless interp 161 applies.                      */
02322 
02323                         PRINTMSG(AT_DEF_LINE(attr_idx), 684, Error,
02324                                  AT_DEF_COLUMN(attr_idx),
02325                                  AT_OBJ_NAME_PTR(attr_idx));
02326                         AT_DCL_ERR(attr_idx)    = TRUE;
02327                      }
02328                   }
02329 
02330                   for (i = (ATP_EXTRA_DARG(attr_idx) ? 1 : 0);
02331                        i < ATP_NUM_DARGS(attr_idx); i++) {
02332 
02333                      darg_idx = SN_ATTR_IDX(ATP_FIRST_IDX(attr_idx) + i);
02334 
02335                      if (AT_DCL_ERR(darg_idx)) {
02336                         continue;
02337                      }
02338 
02339 
02340                      /* Issue error if the Module procedure is PUBLIC, but */
02341                      /* one of its dummy arguments is a PRIVATE type.      */
02342 
02343                      if (AT_OBJ_CLASS(darg_idx) == Interface) {
02344                         darg_idx = ATI_PROC_IDX(darg_idx);
02345                      }
02346 
02347                      if (darg_idx != NULL_IDX &&
02348                         AT_OBJ_CLASS(darg_idx) == Pgm_Unit) {
02349 
02350                         if (ATP_PGM_UNIT(darg_idx) == Function) {
02351                            darg_idx = ATP_RSLT_IDX(darg_idx);
02352                         }
02353                         else {
02354                            darg_idx = NULL_IDX;
02355                         }
02356                      }
02357 
02358                      if (darg_idx != NULL_IDX &&
02359                          TYP_TYPE(ATD_TYPE_IDX(darg_idx)) == Structure &&
02360                          AT_PRIVATE(TYP_IDX(ATD_TYPE_IDX(darg_idx))) &&
02361                          !AT_USE_ASSOCIATED(TYP_IDX(ATD_TYPE_IDX(darg_idx))) ) {
02362                         PRINTMSG(AT_DEF_LINE(darg_idx), 685, Error,
02363                                  AT_DEF_COLUMN(darg_idx),
02364                                  AT_OBJ_NAME_PTR(attr_idx),
02365                                  AT_OBJ_NAME_PTR(darg_idx));
02366                         AT_DCL_ERR(attr_idx)    = TRUE;
02367                      }
02368                   }
02369                }
02370             }
02371 
02372             if (!AT_USE_ASSOCIATED(attr_idx)) {
02373 
02374                if (ATP_PROC(attr_idx) == Unknown_Proc) {
02375                   ATP_PROC(attr_idx) = Extern_Proc;
02376                }
02377 
02378                if (ATP_EXT_NAME_IDX(attr_idx) == NULL_IDX) {
02379 # ifdef _DEBUG
02380                   PRINTMSG(AT_DEF_LINE(attr_idx), 193, Internal,
02381                            AT_DEF_COLUMN(attr_idx),
02382                            0, "ATP_EXT_NAME_IDX", attr_idx);
02383 # endif
02384                   MAKE_EXTERNAL_NAME(attr_idx,
02385                                      AT_NAME_IDX(attr_idx),
02386                                      AT_NAME_LEN(attr_idx));
02387                }
02388 
02389                ATP_ALL_INTENT_IN(attr_idx) = TRUE;
02390 
02391                sn_idx = (ATP_EXTRA_DARG(attr_idx) && ATP_EXPL_ITRFC(attr_idx)) ?
02392                          ATP_FIRST_IDX(attr_idx)+1: ATP_FIRST_IDX(attr_idx);
02393 
02394                for (;sn_idx < (ATP_FIRST_IDX(attr_idx)+ATP_NUM_DARGS(attr_idx));
02395                      sn_idx++) {
02396 
02397                   if (AT_OBJ_CLASS(SN_ATTR_IDX(sn_idx)) != Data_Obj ||
02398                       ATD_CLASS(SN_ATTR_IDX(sn_idx)) != Dummy_Argument ||
02399                       ATD_INTENT(SN_ATTR_IDX(sn_idx)) != Intent_In) {
02400                      ATP_ALL_INTENT_IN(attr_idx) = FALSE;
02401                      break;
02402                   }
02403                }
02404             }
02405 
02406             if (ATP_HAS_ALT_RETURN(attr_idx)) {
02407 
02408                if (ATP_RSLT_IDX(attr_idx) == NULL_IDX) {
02409 
02410                   /* Create a function result as required */
02411                   /* by the PDGCS interface.              */
02412 
02413                   NTR_ATTR_TBL(rslt_idx);
02414                   COPY_ATTR_NTRY(rslt_idx, attr_idx);
02415                   CLEAR_VARIANT_ATTR_INFO(rslt_idx, Data_Obj);
02416                   ATD_CLASS(rslt_idx)        = Function_Result;
02417                   ATD_TYPE_IDX(rslt_idx)     = CG_INTEGER_DEFAULT_TYPE;
02418                   ATD_STOR_BLK_IDX(rslt_idx) = SCP_SB_STACK_IDX(curr_scp_idx);
02419                   ATP_RSLT_IDX(attr_idx)     = rslt_idx;
02420                }
02421                attr_idx = NULL_IDX;
02422             }
02423             else {
02424                attr_idx = ATP_RSLT_IDX(attr_idx);
02425             }
02426             break;
02427 
02428          case Blockdata:
02429          case Program:
02430 
02431             if (ATP_NO_ENTRY_LIST(attr_idx) != NULL_IDX) {
02432                free_attr_list(ATP_NO_ENTRY_LIST(attr_idx));
02433                ATP_NO_ENTRY_LIST(attr_idx)      = NULL_IDX;
02434             }
02435 
02436             /* Intentional fall through to next case */
02437 
02438          case Module:
02439 
02440             if (ATP_GLOBAL_ATTR_IDX(attr_idx) == NULL_IDX &&
02441                 !AT_COMPILER_GEND(attr_idx) &&
02442                 (attr_idx != glb_tbl_idx[Main_Attr_Idx]) &&
02443                 (ATP_PGM_UNIT(attr_idx) != Module ||
02444                  ATP_MODULE_STR_IDX(attr_idx) == NULL_IDX)) {
02445 
02446                /* This has not been entered or resolved globally yet.  */
02447                /* This routine checks for this name in the global name */
02448                /* table.  It enters it, if it doesn't exist or checks  */
02449                /* for semantics errors if it does exist.               */
02450 
02451                check_global_pgm_unit(attr_idx);
02452             }
02453 
02454             if (ATP_EXT_NAME_IDX(attr_idx) == NULL_IDX) {
02455                MAKE_EXTERNAL_NAME(attr_idx,
02456                                   AT_NAME_IDX(attr_idx),
02457                                   AT_NAME_LEN(attr_idx));
02458             }
02459             attr_idx = NULL_IDX;
02460             break;
02461 
02462          }  /* End switch */
02463          break;
02464 
02465       case Interface:
02466 
02467          attr_idx = ATI_PROC_IDX(attr_idx);
02468 
02469          if (attr_idx != NULL_IDX) {
02470 
02471             /* If we're in the module and processing a module procedure */
02472             /* and this procedure is declared inside this module, then  */
02473             /* skip processing until we see it in its own declaration.  */
02474 
02475             if (ATP_PROC(attr_idx) == Module_Proc &&
02476                 ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module &&
02477                 !AT_USE_ASSOCIATED(attr_idx)) {
02478                attr_idx = NULL_IDX;
02479             }
02480             else {
02481                attr_idx = ATP_RSLT_IDX(attr_idx);
02482             }
02483          }
02484          break;
02485 
02486       case Stmt_Func:
02487 
02488          if (!ATS_SF_SEMANTICS_DONE(attr_idx)) {
02489             stmt_func_semantics(attr_idx);
02490          }
02491          attr_idx = NULL_IDX;
02492          break;
02493 
02494       default:
02495          attr_idx = NULL_IDX;
02496          break;
02497       }
02498 
02499       if (attr_idx == NULL_IDX) { 
02500          goto EXIT;
02501       }
02502 
02503       if (!ATD_OFFSET_ASSIGNED(attr_idx)) {
02504 
02505 # ifdef _DEBUG
02506          if (ATD_CLASS(attr_idx) == Compiler_Tmp &&
02507              ATD_STOR_BLK_IDX(attr_idx) == NULL_IDX &&
02508              !ATD_SYMBOLIC_CONSTANT(attr_idx)) {
02509             PRINTMSG(AT_DEF_LINE(attr_idx), 836, Internal,
02510                      AT_DEF_COLUMN(attr_idx),
02511                      AT_OBJ_NAME_PTR(attr_idx));
02512          }
02513 # endif
02514 
02515          if (ATD_STOR_BLK_IDX(attr_idx) == NULL_IDX) {
02516             assign_storage_blk(attr_idx);
02517          }
02518 
02519          switch (SB_BLK_TYPE(ATD_STOR_BLK_IDX(attr_idx))) {
02520 
02521          case Static:
02522          case Static_Local:
02523          case Static_Named:
02524 
02525             if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX &&
02526                 BD_ARRAY_SIZE(ATD_ARRAY_IDX(attr_idx))==Symbolic_Constant_Size){
02527                NTR_ATTR_LIST_TBL(al_idx);
02528                AL_ATTR_IDX(al_idx)              = attr_idx;
02529                AL_NEXT_IDX(al_idx)              = symbolic_constant_array_list;
02530                symbolic_constant_array_list     = al_idx;
02531             }
02532             else {
02533                assign_offset(attr_idx);  /* assign offsets to static storage */
02534                ATD_OFFSET_ASSIGNED(attr_idx) = TRUE;
02535             }
02536             break;
02537 
02538          case Stack:
02539 
02540             if (SB_HOSTED_STACK(ATD_STOR_BLK_IDX(attr_idx))) {
02541 
02542                if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX &&
02543                    BD_ARRAY_SIZE(ATD_ARRAY_IDX(attr_idx)) == 
02544                                                Symbolic_Constant_Size) {
02545                   NTR_ATTR_LIST_TBL(al_idx);
02546                   AL_ATTR_IDX(al_idx)           = attr_idx;
02547                   AL_NEXT_IDX(al_idx)           = symbolic_constant_array_list;
02548                   symbolic_constant_array_list  = al_idx;
02549                }
02550                else {
02551 
02552 # if defined(_ASSIGN_OFFSETS_TO_HOSTED_STACK)
02553                   assign_offset(attr_idx);      /* Assign to hosted stack */
02554                   ATD_OFFSET_ASSIGNED(attr_idx) = TRUE;
02555 # else
02556                   /* Check so the item does not exceed max storage size */
02557 
02558                   stor_bit_size_of(attr_idx, TRUE, FALSE);
02559 # endif
02560                }
02561             }
02562             else if (!AT_DCL_ERR(attr_idx)) {
02563 
02564                /* Check so the item does not exceed max storage size */
02565 
02566                stor_bit_size_of(attr_idx, TRUE, FALSE);
02567             }
02568             break;
02569 
02570          case Equivalenced:
02571             break;
02572 
02573          case Task_Common:
02574          case Threadprivate:
02575 
02576             if (ATD_CLASS(attr_idx) == Compiler_Tmp &&
02577                 ATD_DATA_INIT(attr_idx) &&
02578                 ATD_FLD(attr_idx) == AT_Tbl_Idx) {
02579                ATD_OFFSET_FLD(attr_idx) = ATD_OFFSET_FLD(ATD_TMP_IDX(attr_idx));
02580                ATD_OFFSET_IDX(attr_idx) = ATD_OFFSET_IDX(ATD_TMP_IDX(attr_idx));
02581                ATD_OFFSET_ASSIGNED(attr_idx) = TRUE;
02582             }
02583             else {
02584                if (! ATD_OFFSET_ASSIGNED(attr_idx)) {
02585                   assign_offset(attr_idx);   /* Assign to task common */
02586                   ATD_OFFSET_ASSIGNED(attr_idx) = TRUE;
02587                }
02588             }
02589 
02590             break;
02591 
02592          case Based:
02593          case Formal:
02594          case Common:
02595 
02596             if (ATD_CLASS(attr_idx) == Compiler_Tmp &&
02597                 ATD_DATA_INIT(attr_idx) && 
02598                 ATD_FLD(attr_idx) == AT_Tbl_Idx) {
02599                ATD_OFFSET_FLD(attr_idx) = ATD_OFFSET_FLD(ATD_TMP_IDX(attr_idx));
02600                ATD_OFFSET_IDX(attr_idx) = ATD_OFFSET_IDX(ATD_TMP_IDX(attr_idx));
02601                ATD_OFFSET_ASSIGNED(attr_idx) = TRUE;
02602             }
02603             break;
02604 
02605          default:
02606             break;
02607          }
02608       }
02609 
02610       sb_idx = ATD_STOR_BLK_IDX(attr_idx);
02611 
02612       if (SB_MERGED_BLK_IDX(sb_idx) != NULL_IDX) {
02613          sb_idx                         = SB_MERGED_BLK_IDX(sb_idx);
02614          ATD_STOR_BLK_IDX(attr_idx)     = sb_idx;
02615       }
02616 
02617       if (SB_DEF_MULT_SCPS(sb_idx) || SB_HAS_RENAMES(sb_idx)) {
02618          ATD_EQUIV(attr_idx) = TRUE;
02619       }
02620 
02621 # if defined(_ASSIGN_OFFSETS_TO_HOSTED_STACK)
02622 
02623       if (SB_HOSTED_STACK(sb_idx) && 
02624           SB_SCP_IDX(sb_idx) != curr_scp_idx &&
02625           tmp_scp_idx != curr_scp_idx) {
02626 
02627          /* This is the host associated stack and it is host      */
02628          /* associated into this scope.  This is the first time   */
02629          /* this storage block has been seen in this scope        */
02630          /* because tmp_scp_idx != curr_scp_idx.  Add the storage */
02631          /* blocks tmp to this scope and set tmp_scp_idx to this  */
02632          /* scope.  When the scope change, tmp_scp_idx will not   */
02633          /* change until the tmp has been added to the new scope. */
02634          /* The storage block's tmp is a tmp whose offset is one  */
02635          /* storage word size less than the total length of the   */
02636          /* block, with a length of one storage word size.  This  */
02637          /* way, the ccg/rcg will get the length of the storage   */
02638          /* block correct.  (We do not pass them length, they     */
02639          /* calculate it themselves.)                             */
02640 
02641          if (SB_LAST_ATTR_LIST(sb_idx) != NULL_IDX) {
02642             ADD_ATTR_TO_LOCAL_LIST(AL_ATTR_IDX(SB_LAST_ATTR_LIST(sb_idx)));
02643             tmp_scp_idx = curr_scp_idx;
02644          }
02645       }
02646 # endif
02647 
02648 # ifdef _DEBUG
02649       if ((ATD_CLASS(attr_idx) == Variable ||
02650            ATD_CLASS(attr_idx) == Function_Result ||
02651            ATD_CLASS(attr_idx) == Compiler_Tmp) &&
02652           ATD_OFFSET_ASSIGNED(attr_idx) &&
02653           ATD_OFFSET_FLD(attr_idx) == CN_Tbl_Idx &&
02654           fold_relationals(ATD_OFFSET_IDX(attr_idx),
02655                            CN_INTEGER_ZERO_IDX,
02656                            Lt_Opr)) {
02657          PRINTMSG(AT_DEF_LINE(attr_idx), 1004, Internal, 
02658                   AT_DEF_COLUMN(attr_idx),
02659                   AT_OBJ_NAME_PTR(attr_idx),
02660                   attr_idx);
02661       }
02662 # endif
02663    }
02664    else {
02665       local_attr_idx    = attr_idx;
02666 
02667       while (AT_ATTR_LINK(attr_idx) != NULL_IDX &&
02668              ! AT_IGNORE_ATTR_LINK(attr_idx)) {
02669          attr_idx = AT_ATTR_LINK(attr_idx);
02670       }
02671 
02672 # if defined(COARRAY_FORTRAN)
02673 
02674       if (AT_OBJ_CLASS(attr_idx) == Data_Obj && 
02675           ATD_PE_ARRAY_IDX(attr_idx) &&
02676           (ATP_PURE(SCP_ATTR_IDX(curr_scp_idx)) ||
02677            ATP_ELEMENTAL(SCP_ATTR_IDX(curr_scp_idx)))) {
02678          PRINTMSG(AT_DEF_LINE(local_attr_idx), 1580, Error, 
02679                   AT_DEF_COLUMN(local_attr_idx),
02680                   AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)),
02681                   AT_OBJ_NAME_PTR(attr_idx));
02682       }
02683 # endif
02684 
02685       if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
02686           ATD_STOR_BLK_IDX(attr_idx) != NULL_IDX) {
02687          sb_idx = ATD_STOR_BLK_IDX(attr_idx);
02688 
02689 # if defined(_ASSIGN_OFFSETS_TO_HOSTED_STACK)
02690 
02691          if (SB_HOSTED_STACK(sb_idx) && 
02692              SB_SCP_IDX(sb_idx) != curr_scp_idx &&
02693              tmp_scp_idx != curr_scp_idx) {
02694 
02695             /* This is the host associated stack and it is host      */
02696             /* associated into this scope.  This is the first time   */
02697             /* this storage block has been seen in this scope        */
02698             /* because tmp_scp_idx != curr_scp_idx.  Add the storage */
02699             /* blocks tmp to this scope and set tmp_scp_idx to this  */
02700             /* scope.  When the scope change, tmp_scp_idx will not   */
02701             /* change until the tmp has been added to the new scope. */
02702             /* The storage block's tmp is a tmp whose offset is one  */
02703             /* storage word size less than the total length of the   */
02704             /* block, with a length of one storage word size.  This  */
02705             /* way, the ccg/rcg will get the length of the storage   */
02706             /* block correct.  (We do not pass them length, they     */
02707             /* calculate it themselves.)                             */
02708 
02709             /* WARNING - This tmp_scp scheme will only work if there */
02710             /*           is 1 hosted stack block.                    */
02711 
02712             if (SB_LAST_ATTR_LIST(sb_idx) != NULL_IDX) {
02713                ADD_ATTR_TO_LOCAL_LIST(AL_ATTR_IDX(SB_LAST_ATTR_LIST(sb_idx)));
02714                tmp_scp_idx      = curr_scp_idx;
02715             }
02716          }
02717 # endif
02718 
02719          if (ATD_AUXILIARY(attr_idx) || SB_AUXILIARY(sb_idx)) {
02720             PRINTMSG(AT_DEF_LINE(attr_idx), 607, Error,
02721                      AT_DEF_COLUMN(attr_idx),
02722                      AT_OBJ_NAME_PTR(attr_idx));
02723             AT_DCL_ERR(attr_idx)        = TRUE;
02724             AT_DCL_ERR(local_attr_idx)  = TRUE;
02725          }
02726 
02727 # ifdef _DEBUG
02728 
02729          /* Make sure if this is on the stack that it has been moved */
02730          /* to a host associated storage block.                      */
02731 
02732          if (SB_BLK_TYPE(sb_idx) == Stack &&
02733              SCP_SB_HOSTED_STACK_IDX(SB_SCP_IDX(sb_idx)) != sb_idx) {
02734             PRINTMSG(AT_DEF_LINE(attr_idx), 850, Internal,
02735                      AT_DEF_COLUMN(attr_idx),
02736                      AT_OBJ_NAME_PTR(attr_idx));
02737          }
02738 # endif
02739       }
02740    }
02741 
02742 EXIT:
02743 
02744    TRACE (Func_Exit, "final_attr_semantics", NULL);
02745 
02746    return;
02747 
02748 }  /* final_attr_semantics */
02749 
02750 /******************************************************************************\
02751 |*                                                                            *|
02752 |* Description:                                                               *|
02753 |*      Allocates storage and offsets for all COMMON blocks.                  *|
02754 |*                                                                            *|
02755 |* Input parameters:                                                          *|
02756 |*      NONE                                                                  *|
02757 |*                                                                            *|
02758 |* Output parameters:                                                         *|
02759 |*      NONE                                                                  *|
02760 |*                                                                            *|
02761 |* Returns:                                                                   *|
02762 |*      NONE                                                                  *|
02763 |*                                                                            *|
02764 \******************************************************************************/
02765 static void     check_and_allocate_common_storage(int   sb_idx)
02766 
02767 {
02768    size_offset_type     adjust_by;
02769    int                  attr_idx;
02770    boolean              equived;
02771    int                  group;
02772    int                  item;
02773    size_offset_type     largest_len;
02774    size_offset_type     left;
02775    size_offset_type     logical_result;
02776    int                  name_idx;
02777    size_offset_type     new_len;
02778    int                  next_attr_idx;
02779    size_offset_type     result;
02780    size_offset_type     save_offset;
02781 
02782 # if !defined(_TARGET_DOUBLE_ALIGN)
02783    size_offset_type     right;
02784 # else
02785    boolean              equal_zero;
02786    boolean              save_dalign_opt;
02787 # endif
02788 
02789 # if !defined(_ERROR_DUPLICATE_GLOBALS)
02790    boolean              issue_message;
02791 # endif
02792 
02793 
02794    TRACE (Func_Entry, "check_and_allocate_common_storage", NULL);
02795 
02796 # if defined(_ERROR_DUPLICATE_GLOBALS)
02797 
02798    attr_idx = srch_sym_tbl(SB_NAME_PTR(sb_idx),
02799                            SB_NAME_LEN(sb_idx),
02800                            &name_idx);
02801 
02802    if (attr_idx == NULL_IDX) {
02803       attr_idx = srch_host_sym_tbl(SB_NAME_PTR(sb_idx),
02804                                    SB_NAME_LEN(sb_idx),
02805                                    &name_idx,
02806                                    FALSE);
02807    }
02808 
02809    if (attr_idx != NULL_IDX) {
02810 
02811       switch (AT_OBJ_CLASS(attr_idx)) {
02812       case Data_Obj:
02813 
02814          if (ATD_CLASS(attr_idx) == Constant) {
02815 
02816             if (SB_USE_ASSOCIATED(sb_idx)) {
02817                PRINTMSG(AT_DEF_LINE(attr_idx), 1033, Ansi,
02818                         AT_DEF_COLUMN(attr_idx),
02819                         SB_NAME_PTR(sb_idx));
02820             }
02821             else if (SB_HOST_ASSOCIATED(sb_idx)) {
02822                PRINTMSG(AT_DEF_LINE(attr_idx), 1032, Ansi,
02823                         AT_DEF_COLUMN(attr_idx),
02824                         SB_NAME_PTR(sb_idx));
02825             }
02826             else {
02827                PRINTMSG(AT_DEF_LINE(attr_idx), 547, Ansi,
02828                         AT_DEF_COLUMN(attr_idx),
02829                         SB_NAME_PTR(sb_idx));
02830             }
02831          }
02832          break;
02833 
02834       case Pgm_Unit:
02835 
02836          if (ATP_PROC(attr_idx) == Intrin_Proc &&
02837              AT_REFERENCED(attr_idx) >= Dcl_Bound_Ref) {
02838 
02839             if (SB_USE_ASSOCIATED(sb_idx)) {
02840                PRINTMSG(AT_DEF_LINE(attr_idx), 1031, Error,
02841                         AT_DEF_COLUMN(attr_idx),
02842                         SB_NAME_PTR(sb_idx));
02843             }
02844             else if (SB_HOST_ASSOCIATED(sb_idx)) {
02845                PRINTMSG(AT_DEF_LINE(attr_idx), 1030, Error,
02846                         AT_DEF_COLUMN(attr_idx),
02847                         SB_NAME_PTR(sb_idx));
02848             }
02849             else {
02850                PRINTMSG(AT_DEF_LINE(attr_idx), 1005, Error,
02851                         AT_DEF_COLUMN(attr_idx),
02852                         SB_NAME_PTR(sb_idx));
02853             }
02854          }
02855          break;
02856 
02857       case Interface:
02858 
02859          if (AT_IS_INTRIN(attr_idx) && 
02860              AT_REFERENCED(attr_idx) >= Dcl_Bound_Ref) {
02861 
02862             if (SB_USE_ASSOCIATED(sb_idx)) {
02863                PRINTMSG(AT_DEF_LINE(attr_idx), 1031, Error,
02864                         AT_DEF_COLUMN(attr_idx),
02865                         SB_NAME_PTR(sb_idx));
02866             }
02867             else if (SB_HOST_ASSOCIATED(sb_idx)) {
02868                PRINTMSG(AT_DEF_LINE(attr_idx), 1030, Error,
02869                         AT_DEF_COLUMN(attr_idx),
02870                         SB_NAME_PTR(sb_idx));
02871             }
02872             else {
02873                PRINTMSG(AT_DEF_LINE(attr_idx), 1005, Error,
02874                         AT_DEF_COLUMN(attr_idx),
02875                         SB_NAME_PTR(sb_idx));
02876             }
02877          }
02878          break;
02879       }
02880    }
02881 
02882 # else
02883 
02884    issue_message = GET_MESSAGE_TBL(message_warning_tbl, 1033) ||
02885                    GET_MESSAGE_TBL(message_error_tbl, 1033) ||
02886                    GET_MESSAGE_TBL(message_warning_tbl, 1032) ||
02887                    GET_MESSAGE_TBL(message_error_tbl, 1032) ||
02888                    GET_MESSAGE_TBL(message_warning_tbl, 547) ||
02889                    GET_MESSAGE_TBL(message_error_tbl, 547) ||
02890                    GET_MESSAGE_TBL(message_warning_tbl, 1029) ||
02891                    GET_MESSAGE_TBL(message_error_tbl, 1029) ||
02892                    GET_MESSAGE_TBL(message_warning_tbl, 1028) ||
02893                    GET_MESSAGE_TBL(message_error_tbl, 1028) ||
02894                    GET_MESSAGE_TBL(message_warning_tbl, 714) ||
02895                    GET_MESSAGE_TBL(message_error_tbl, 714);
02896 
02897 
02898    if (issue_message || on_off_flags.issue_ansi_messages) {
02899       attr_idx = srch_sym_tbl(SB_NAME_PTR(sb_idx),
02900                               SB_NAME_LEN(sb_idx),
02901                               &name_idx);
02902 
02903       if (attr_idx == NULL_IDX) {
02904          attr_idx = srch_host_sym_tbl(SB_NAME_PTR(sb_idx),
02905                                       SB_NAME_LEN(sb_idx),
02906                                       &name_idx,
02907                                       FALSE);
02908       }
02909 
02910       if (attr_idx != NULL_IDX) {
02911 
02912          switch (AT_OBJ_CLASS(attr_idx)) {
02913          case Data_Obj:
02914 
02915             if (ATD_CLASS(attr_idx) == Constant) {
02916 
02917                if (SB_USE_ASSOCIATED(sb_idx)) {
02918                   PRINTMSG(AT_DEF_LINE(attr_idx), 1033, Ansi,
02919                            AT_DEF_COLUMN(attr_idx),
02920                            SB_NAME_PTR(sb_idx));
02921                }
02922                else if (SB_HOST_ASSOCIATED(sb_idx)) {
02923                   PRINTMSG(AT_DEF_LINE(attr_idx), 1032, Ansi,
02924                            AT_DEF_COLUMN(attr_idx),
02925                            SB_NAME_PTR(sb_idx));
02926                }
02927                else {
02928                   PRINTMSG(AT_DEF_LINE(attr_idx), 547, Ansi,
02929                            AT_DEF_COLUMN(attr_idx),
02930                            SB_NAME_PTR(sb_idx));
02931                }
02932             }
02933             break;
02934 
02935          case Pgm_Unit:
02936 
02937             if (ATP_PROC(attr_idx) == Intrin_Proc &&
02938                 AT_REFERENCED(attr_idx) >= Dcl_Bound_Ref) {
02939 
02940                if (SB_USE_ASSOCIATED(sb_idx)) {
02941                   PRINTMSG(AT_DEF_LINE(attr_idx), 1029, Ansi,
02942                            AT_DEF_COLUMN(attr_idx),
02943                            SB_NAME_PTR(sb_idx));
02944                }
02945                else if (SB_HOST_ASSOCIATED(sb_idx)) {
02946                   PRINTMSG(AT_DEF_LINE(attr_idx), 1028, Ansi,
02947                            AT_DEF_COLUMN(attr_idx),
02948                            SB_NAME_PTR(sb_idx));
02949                }
02950                else {
02951                   PRINTMSG(AT_DEF_LINE(attr_idx), 714, Ansi,
02952                            AT_DEF_COLUMN(attr_idx),
02953                            SB_NAME_PTR(sb_idx));
02954                }
02955             }
02956             break;
02957 
02958          case Interface:
02959 
02960             if (AT_IS_INTRIN(attr_idx) && 
02961                 AT_REFERENCED(attr_idx) >= Dcl_Bound_Ref) {
02962 
02963                if (SB_USE_ASSOCIATED(sb_idx)) {
02964                   PRINTMSG(AT_DEF_LINE(attr_idx), 1029, Ansi,
02965                            AT_DEF_COLUMN(attr_idx),
02966                            SB_NAME_PTR(sb_idx));
02967                }
02968                else if (SB_HOST_ASSOCIATED(sb_idx)) {
02969                   PRINTMSG(AT_DEF_LINE(attr_idx), 1028, Ansi,
02970                            AT_DEF_COLUMN(attr_idx),
02971                            SB_NAME_PTR(sb_idx));
02972                }
02973                else {
02974                   PRINTMSG(AT_DEF_LINE(attr_idx), 714, Ansi,
02975                            AT_DEF_COLUMN(attr_idx),
02976                            SB_NAME_PTR(sb_idx));
02977                }
02978             }
02979             break;
02980          }
02981       }
02982    }
02983 # endif
02984 
02985    if (SB_USE_ASSOCIATED(sb_idx) || !SB_COMMON_NEEDS_OFFSET(sb_idx)) {
02986       goto EXIT;
02987    }
02988 
02989    if (SB_FIRST_ATTR_IDX(sb_idx) == NULL_IDX && !SB_DCL_ERR(sb_idx)) {
02990 
02991       if (SB_SAVED(sb_idx)) {
02992 
02993          /* The common block was declared in a save statement, but */
02994          /* not as an actual common block.                         */
02995 
02996          PRINTMSG(SB_DEF_LINE(sb_idx), 688, Error,
02997                   SB_DEF_COLUMN(sb_idx), 
02998                   SB_NAME_PTR(sb_idx));
02999          SB_DCL_ERR(sb_idx)     = TRUE;
03000       }
03001       else if (SB_BLK_TYPE(sb_idx) == Threadprivate) {
03002          PRINTMSG(SB_DEF_LINE(sb_idx), 1502, Error,
03003                   SB_DEF_COLUMN(sb_idx), 
03004                   SB_NAME_PTR(sb_idx),
03005                   "THREAD_PRIVATE");
03006          SB_DCL_ERR(sb_idx)     = TRUE;
03007       }
03008       else if (SB_CACHE_ALIGN(sb_idx)) {
03009          PRINTMSG(SB_DEF_LINE(sb_idx), 1168, Error,
03010                   SB_DEF_COLUMN(sb_idx), 
03011                   SB_NAME_PTR(sb_idx));
03012          SB_DCL_ERR(sb_idx)     = TRUE;
03013       }
03014       else if (SB_SECTION_GP(sb_idx)) {
03015          PRINTMSG(SB_DEF_LINE(sb_idx), 1502, Error,
03016                   SB_DEF_COLUMN(sb_idx), 
03017                   SB_NAME_PTR(sb_idx),
03018                   "SECTION_GP");
03019          SB_DCL_ERR(sb_idx)     = TRUE;
03020       }
03021       else if (SB_SECTION_NON_GP(sb_idx)) {
03022          PRINTMSG(SB_DEF_LINE(sb_idx), 1502, Error,
03023                   SB_DEF_COLUMN(sb_idx), 
03024                   SB_NAME_PTR(sb_idx),
03025                   "SECTION_NON_GP");
03026          SB_DCL_ERR(sb_idx)     = TRUE;
03027       }
03028 # if 0
03029       else if (SB_ALIGN_SYMBOL(sb_idx)) {
03030          PRINTMSG(SB_DEF_LINE(sb_idx), 1502, Error,
03031                   SB_DEF_COLUMN(sb_idx), 
03032                   SB_NAME_PTR(sb_idx),
03033                   "ALIGN_SYMBOL");
03034          SB_DCL_ERR(sb_idx)     = TRUE;
03035       }
03036       else if (SB_FILL_SYMBOL(sb_idx)) {
03037          PRINTMSG(SB_DEF_LINE(sb_idx), 1502, Error,
03038                   SB_DEF_COLUMN(sb_idx), 
03039                   SB_NAME_PTR(sb_idx),
03040                   "FILL_SYMBOL");
03041          SB_DCL_ERR(sb_idx)     = TRUE;
03042       }
03043 # endif
03044       else if (SB_DCL_COMMON_DIR(sb_idx)) {
03045          SB_DCL_ERR(sb_idx)     = TRUE;
03046          PRINTMSG(SB_DEF_LINE(sb_idx), 1128, Error,
03047                   SB_DEF_COLUMN(sb_idx), 
03048                   SB_NAME_PTR(sb_idx));
03049       }
03050       else if (SB_BLK_TYPE(sb_idx) == Task_Common) {
03051          SB_DCL_ERR(sb_idx)     = TRUE;
03052          PRINTMSG(SB_DEF_LINE(sb_idx), 690, Error,
03053                   SB_DEF_COLUMN(sb_idx), 
03054                   SB_NAME_PTR(sb_idx));
03055       }
03056    }
03057 
03058    if (SB_DCL_COMMON_DIR(sb_idx) && SB_BLK_TYPE(sb_idx) == Task_Common) {
03059       SB_DCL_ERR(sb_idx)        = TRUE;
03060       PRINTMSG(SB_DEF_LINE(sb_idx), 1129, Error,
03061                SB_DEF_COLUMN(sb_idx), 
03062                SB_NAME_PTR(sb_idx));
03063    }
03064 
03065    attr_idx     = SB_FIRST_ATTR_IDX(sb_idx);
03066    equived      = FALSE;
03067 
03068    while (attr_idx != NULL_IDX && !equived) {
03069       equived   = equived || ATD_EQUIV(attr_idx);
03070       attr_idx  = ATD_NEXT_MEMBER_IDX(attr_idx);
03071    }
03072 
03073    if (SB_PAD_BLK(sb_idx) && equived) { /* -a pad and equiv don't go together */
03074       PRINTMSG(SB_DEF_LINE(sb_idx), 1351, Warning,
03075                SB_DEF_COLUMN(sb_idx), 
03076                SB_BLANK_COMMON(sb_idx) ?
03077                "" : SB_NAME_PTR(sb_idx));
03078       SB_PAD_BLK(sb_idx)= FALSE;
03079    }
03080 
03081    next_attr_idx        = SB_FIRST_ATTR_IDX(sb_idx);
03082    largest_len.fld      = SB_LEN_FLD(sb_idx);
03083    largest_len.idx      = SB_LEN_IDX(sb_idx);
03084 
03085    while (next_attr_idx != NULL_IDX) {
03086       attr_idx                  = next_attr_idx;
03087       next_attr_idx             = ATD_NEXT_MEMBER_IDX(attr_idx);
03088 
03089       if (AT_DCL_ERR(attr_idx)) {
03090 
03091          /* Error - Do not attempt to assign offset. */
03092 
03093       }
03094       else if (!ATD_EQUIV(attr_idx) || num_prog_unit_errors != 0) {
03095 
03096          /* We do not do equivalence processing if we found any errors in */
03097          /* this program unit.  Error recovery doesn't work too well.     */
03098 
03099          assign_offset(attr_idx);       /* Equivalence */
03100          ATD_OFFSET_ASSIGNED(attr_idx)  = TRUE;
03101          ATD_EQUIV(attr_idx)            = equived;
03102       }
03103       else {
03104 
03105          if (ATD_OFFSET_IDX(attr_idx) == NULL_IDX) {
03106             ATD_OFFSET_IDX(attr_idx) = CN_INTEGER_ZERO_IDX;
03107             ATD_OFFSET_FLD(attr_idx) = CN_Tbl_Idx;
03108          }
03109 
03110          save_offset.fld        = ATD_OFFSET_FLD(attr_idx);
03111          save_offset.idx        = ATD_OFFSET_IDX(attr_idx);
03112 
03113 # if defined(_TARGET_DOUBLE_ALIGN)
03114          save_dalign_opt        = cmd_line_flags.dalign;
03115          cmd_line_flags.dalign  = FALSE;
03116 
03117          /* Offset will not get daligned, because dalign flag = FALSE */
03118          /* If daligning is necessary, it will be done by hand here.  */
03119 
03120          assign_offset(attr_idx);   /* Equivalence */
03121 
03122          cmd_line_flags.dalign  = save_dalign_opt;
03123          left.fld               = ATD_OFFSET_FLD(attr_idx);
03124          left.idx               = ATD_OFFSET_IDX(attr_idx);
03125 
03126          if (!size_offset_binary_calc(&left,
03127                                       &save_offset, 
03128                                        Minus_Opr,
03129                                       &adjust_by)) {
03130             AT_DCL_ERR(attr_idx) = TRUE;
03131          }
03132 
03133 # else
03134          assign_offset(attr_idx);  /* Equivalence */
03135 
03136          left.fld               = ATD_OFFSET_FLD(attr_idx);
03137          left.idx               = ATD_OFFSET_IDX(attr_idx);
03138 
03139          if (!size_offset_binary_calc(&left,
03140                                       &save_offset, 
03141                                        Minus_Opr,
03142                                       &adjust_by)) {
03143             AT_DCL_ERR(attr_idx) = TRUE;
03144          }
03145 
03146          if (ATD_OFFSET_ASSIGNED(attr_idx)) {
03147             right.fld   = CN_Tbl_Idx;
03148             right.idx   = CN_INTEGER_ZERO_IDX;
03149 
03150             size_offset_logical_calc(&adjust_by, &right, Eq_Opr, &result);
03151 
03152              if (THIS_IS_TRUE(result.constant, result.type_idx)) {
03153 
03154                /* Offset for this attr is assigned already, because it is in */
03155                /* a previous equivalence group.  This offset should agree    */
03156                /* with the new offset just assigned.  If it doesn't continue */
03157                /* and issue an error later, when we can give a better line   */
03158                /* and column number.  If it is zero, continue to next attr.  */
03159 
03160                continue;
03161             }
03162          }
03163 # endif
03164 
03165          group = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
03166 
03167          while (group != NULL_IDX) {
03168             item                = group;
03169 
03170             while (item != NULL_IDX) {
03171 
03172 # if _DEBUG
03173                if (!ATD_EQUIV(EQ_ATTR_IDX(item)) && 
03174                    !AT_DCL_ERR(EQ_ATTR_IDX(item)) &&
03175                    ATD_CLASS(EQ_ATTR_IDX(item)) == Variable) {
03176                   PRINTMSG(AT_DEF_LINE(EQ_ATTR_IDX(item)), 
03177                            1019, 
03178                            Internal, 
03179                            AT_DEF_COLUMN(EQ_ATTR_IDX(item)),
03180                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
03181                }
03182 # endif
03183 
03184                if (EQ_ATTR_IDX(item) == attr_idx) {
03185                   goto FOUND;
03186                }
03187                item = EQ_NEXT_EQUIV_OBJ(item);
03188             }
03189             group = EQ_NEXT_EQUIV_GRP(group);
03190          }
03191 
03192          ATD_OFFSET_ASSIGNED(attr_idx)  = TRUE;
03193 
03194          /* This is a data initialized item.  It is equivalenced to a tmp. */
03195          /* The tmps offset gets set in final_attr_semantics.              */
03196 
03197          continue;    
03198 
03199 FOUND:
03200 
03201          if (ATD_OFFSET_ASSIGNED(attr_idx)) {
03202 
03203             if (fold_relationals(ATD_OFFSET_IDX(attr_idx),
03204                                  save_offset.idx,
03205                                  Ne_Opr)) {
03206                 PRINTMSG(EQ_LINE_NUM(item), 862, Error,
03207                          EQ_COLUMN_NUM(item),
03208                          AT_OBJ_NAME_PTR(attr_idx));
03209             }
03210             continue;
03211          }
03212 
03213 # if defined(_TARGET_DOUBLE_ALIGN)
03214 
03215          else {
03216             if (EQ_DALIGN_ME(item)) { 
03217                C_TO_F_INT(result.constant, TARGET_BITS_PER_WORD * 2,
03218                           CG_INTEGER_DEFAULT_TYPE);
03219                result.fld               = NO_Tbl_Idx;
03220                result.type_idx          = CG_INTEGER_DEFAULT_TYPE;
03221 
03222                if (!size_offset_binary_calc(&adjust_by,
03223                                             &result,
03224                                              Mod_Opr,
03225                                             &result)) {
03226                   AT_DCL_ERR(attr_idx)  = TRUE;
03227                }
03228 
03229                left.fld = CN_Tbl_Idx;
03230                left.idx = CN_INTEGER_ZERO_IDX;
03231 
03232                size_offset_logical_calc(&left, &result, Eq_Opr, &result);
03233 
03234                equal_zero = THIS_IS_TRUE(result.constant, result.type_idx);
03235 
03236                if ((equal_zero && EQ_DALIGN_SHIFT(item)) || 
03237                    (!equal_zero && !EQ_DALIGN_SHIFT(item))) { 
03238 
03239                   if (cmd_line_flags.dalign) {
03240 
03241                      /* If offset % TARGET_BITS == 0, the new offset is on a  */
03242                      /* double word boundary.  If !EQ_DALIGN_SHIFT then the   */
03243                      /* equivalence group is on a double word boundary.  What */
03244                      /* the above if statement says is that if both the new   */
03245                      /* offset and the equivalence group are on a double word */
03246                      /* boundary - do nothing.  If neither one is on a double */
03247                      /* word boundary, do nothing.  But if one is on a double */
03248                      /* word boundary and the other is not, adjust new offset.*/
03249 
03250                      result.fld = CN_Tbl_Idx;
03251                      result.idx = CN_INTEGER_BITS_PER_WORD_IDX;
03252 
03253                      if (!size_offset_binary_calc(&adjust_by,
03254                                                   &result,
03255                                                    Plus_Opr,
03256                                                   &adjust_by)) {
03257                         AT_DCL_ERR(attr_idx) = TRUE;
03258                      }
03259 
03260                      left.fld   = ATD_OFFSET_FLD(attr_idx);
03261                      left.idx   = ATD_OFFSET_IDX(attr_idx);
03262 
03263                      if (!size_offset_binary_calc(&left,
03264                                                   &result,
03265                                                    Plus_Opr,
03266                                                   &result)) {
03267                         AT_DCL_ERR(attr_idx) = TRUE;
03268                      }
03269 
03270                      if (result.fld == NO_Tbl_Idx) {
03271                         ATD_OFFSET_FLD(attr_idx) = CN_Tbl_Idx;
03272                         ATD_OFFSET_IDX(attr_idx) = ntr_const_tbl(
03273                                                              result.type_idx,
03274                                                              FALSE,
03275                                                              result.constant);
03276                      }
03277                      else {
03278                         ATD_OFFSET_FLD(attr_idx) = result.fld;
03279                         ATD_OFFSET_IDX(attr_idx) = result.idx;
03280                      }
03281 
03282                      result.fld = CN_Tbl_Idx;
03283                      result.idx = CN_INTEGER_BITS_PER_WORD_IDX;
03284                      left.fld   = SB_LEN_FLD(sb_idx);
03285                      left.idx   = SB_LEN_IDX(sb_idx);
03286 
03287                      if (!size_offset_binary_calc(&left,
03288                                                   &result,
03289                                                    Plus_Opr,
03290                                                   &result)) {
03291                         AT_DCL_ERR(attr_idx) = TRUE;
03292                      }
03293 
03294                      if (result.fld == NO_Tbl_Idx) {
03295                         SB_LEN_FLD(sb_idx) = CN_Tbl_Idx;
03296                         SB_LEN_IDX(sb_idx) = ntr_const_tbl(result.type_idx,
03297                                                            FALSE,
03298                                                            result.constant);
03299                      }
03300                      else {
03301                         SB_LEN_FLD(sb_idx)  = result.fld;
03302                         SB_LEN_IDX(sb_idx)  = result.idx;
03303                      }
03304 
03305 # if ! (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX))
03306 
03307                     /* -a dalign is always on for IRIX and there is no */
03308                     /* way to shut it off, so we do not need to issue  */
03309                     /* this warning for IRIX.                          */
03310 
03311                      PRINTMSG(AT_DEF_LINE(attr_idx), 1013, Warning, 
03312                               AT_DEF_COLUMN(attr_idx),
03313                               AT_OBJ_NAME_PTR(attr_idx),
03314                               SB_BLANK_COMMON(sb_idx) ?
03315                               "" : SB_NAME_PTR(sb_idx));
03316 # endif
03317                   } 
03318                   else {  /* Cannot double align */
03319                      PRINTMSG(AT_DEF_LINE(attr_idx), 1161, Caution, 
03320                               AT_DEF_COLUMN(attr_idx),
03321                               AT_OBJ_NAME_PTR(attr_idx),
03322                               SB_BLANK_COMMON(sb_idx) ?
03323                               "" : SB_NAME_PTR(sb_idx));
03324                   } 
03325                }
03326             }
03327          }
03328 # endif
03329 
03330          ATD_OFFSET_ASSIGNED(attr_idx)  = TRUE;
03331          item                           = group;
03332 
03333          while (item != NULL_IDX) {
03334 
03335             if (!ATD_OFFSET_ASSIGNED(EQ_ATTR_IDX(item))) {
03336 
03337                if (ATD_OFFSET_IDX(EQ_ATTR_IDX(item)) == NULL_IDX) {
03338                   ATD_OFFSET_FLD(EQ_ATTR_IDX(item)) = CN_Tbl_Idx;
03339                   ATD_OFFSET_IDX(EQ_ATTR_IDX(item)) = ntr_const_tbl(
03340                                                          adjust_by.type_idx,
03341                                                          FALSE,
03342                                                          adjust_by.constant);
03343                }
03344                else {
03345                   left.fld      = ATD_OFFSET_FLD(EQ_ATTR_IDX(item));
03346                   left.idx      = ATD_OFFSET_IDX(EQ_ATTR_IDX(item));
03347 
03348                   if (!size_offset_binary_calc(&left,
03349                                                &adjust_by,
03350                                                 Plus_Opr,
03351                                                &result)) {
03352                      AT_DCL_ERR(EQ_ATTR_IDX(item)) = TRUE;
03353                   }
03354 
03355                   if (result.fld == NO_Tbl_Idx) {
03356                      ATD_OFFSET_FLD(EQ_ATTR_IDX(item)) = CN_Tbl_Idx;
03357                      ATD_OFFSET_IDX(EQ_ATTR_IDX(item)) = ntr_const_tbl(
03358                                                              result.type_idx,
03359                                                              FALSE,
03360                                                              result.constant);
03361                   }
03362                   else {
03363                      ATD_OFFSET_FLD(EQ_ATTR_IDX(item)) = result.fld;
03364                      ATD_OFFSET_IDX(EQ_ATTR_IDX(item)) = result.idx;
03365                   }
03366                }
03367 
03368                ATD_OFFSET_ASSIGNED(EQ_ATTR_IDX(item))    = TRUE;
03369 
03370                if (fold_relationals(ATD_OFFSET_IDX(EQ_ATTR_IDX(item)),
03371                                     CN_INTEGER_ZERO_IDX,
03372                                     Lt_Opr)) {
03373                   PRINTMSG(SB_DEF_LINE(sb_idx), 526, Error,
03374                            SB_DEF_COLUMN(sb_idx),
03375                            SB_BLANK_COMMON(sb_idx) ?
03376                            "" : SB_NAME_PTR(sb_idx),
03377                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
03378                   ATD_OFFSET_IDX(EQ_ATTR_IDX(item))     = CN_INTEGER_ZERO_IDX;
03379                   ATD_OFFSET_FLD(EQ_ATTR_IDX(item))     = CN_Tbl_Idx;
03380                   AT_DCL_ERR(EQ_ATTR_IDX(item))         = TRUE;
03381                }
03382 
03383                new_len  = stor_bit_size_of(EQ_ATTR_IDX(item), TRUE, FALSE);
03384                left.fld = ATD_OFFSET_FLD(EQ_ATTR_IDX(item));
03385                left.idx = ATD_OFFSET_IDX(EQ_ATTR_IDX(item));
03386 
03387                if (!size_offset_binary_calc(&left, &new_len, Plus_Opr,&result)){
03388                   AT_DCL_ERR(EQ_ATTR_IDX(item)) = TRUE;
03389                }
03390 
03391                size_offset_logical_calc(&result, 
03392                                         &largest_len,
03393                                          Gt_Opr,
03394                                         &logical_result);
03395 
03396                if (THIS_IS_TRUE(logical_result.constant,
03397                                 logical_result.type_idx)) {
03398                   largest_len = result;
03399                }
03400             }
03401             else if (!ATD_IN_COMMON(EQ_ATTR_IDX(item))) {
03402                left.fld = EQ_OFFSET_FLD(item);
03403                left.idx = EQ_OFFSET_IDX(item);
03404 
03405                if (!size_offset_binary_calc(&left,&adjust_by,Plus_Opr,&result)){
03406                   AT_DCL_ERR(EQ_ATTR_IDX(item)) = TRUE;
03407                }
03408 
03409                left.fld = ATD_OFFSET_FLD(EQ_ATTR_IDX(item));
03410                left.idx = ATD_OFFSET_IDX(EQ_ATTR_IDX(item));
03411 
03412                size_offset_logical_calc(&left, &result, Ne_Opr,&logical_result);
03413 
03414                if (THIS_IS_TRUE(logical_result.constant,
03415                                 logical_result.type_idx)) {
03416                   PRINTMSG(EQ_LINE_NUM(item), 862, Error,
03417                            EQ_COLUMN_NUM(item),
03418                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
03419                }
03420             }
03421             item = EQ_NEXT_EQUIV_OBJ(item);
03422          }
03423       }
03424    }
03425    left.fld     = SB_LEN_FLD(sb_idx);
03426    left.idx     = SB_LEN_IDX(sb_idx);
03427 
03428    size_offset_logical_calc(&largest_len, &left, Gt_Opr, &logical_result);
03429 
03430    if (!THIS_IS_TRUE(logical_result.constant,
03431                      logical_result.type_idx)) {
03432       largest_len.idx   = SB_LEN_IDX(sb_idx);
03433       largest_len.fld   = SB_LEN_FLD(sb_idx);
03434    }
03435 
03436    align_bit_length(&largest_len, TARGET_BITS_PER_WORD);
03437 
03438    if (largest_len.fld == NO_Tbl_Idx) {
03439       largest_len.fld   = CN_Tbl_Idx;
03440       largest_len.idx   = ntr_const_tbl(largest_len.type_idx,
03441                                         FALSE,
03442                                         largest_len.constant);
03443    }
03444 
03445    SB_LEN_FLD(sb_idx) = largest_len.fld;
03446    SB_LEN_IDX(sb_idx) = largest_len.idx;
03447 
03448    SB_COMMON_NEEDS_OFFSET(sb_idx) = FALSE;
03449 
03450    if (cmd_line_flags.taskcommon && !SB_DCL_COMMON_DIR(sb_idx)) {
03451 
03452       /* Switch all common blocks to task common */
03453 
03454       SB_BLK_TYPE(sb_idx)       = Task_Common;
03455       SB_RUNTIME_INIT(sb_idx)   = FALSE;
03456    }
03457 
03458 EXIT:
03459 
03460    TRACE (Func_Exit, "check_and_allocate_common_storage", NULL);
03461 
03462    return;
03463 
03464 }  /* check_and_allocate_common_storage */
03465 
03466 /******************************************************************************\
03467 |*                                                                            *|
03468 |* Description:                                                               *|
03469 |*      Resolves multiple storage blocks in the current scope to one block.   *|
03470 |*                                                                            *|
03471 |* Input parameters:                                                          *|
03472 |*      NONE                                                                  *|
03473 |*                                                                            *|
03474 |* Output parameters:                                                         *|
03475 |*      NONE                                                                  *|
03476 |*                                                                            *|
03477 |* Returns:                                                                   *|
03478 |*      NONE                                                                  *|
03479 |*                                                                            *|
03480 \******************************************************************************/
03481 static void     storage_blk_resolution()
03482 {
03483    int                  attr_idx;
03484    int                  ga_idx;
03485    int                  gac_idx;
03486    int                  ga_pgm_idx;
03487    int                  host_sb_idx;
03488    msg_severities_type  msg_level;
03489    int                  name_idx;
03490    size_offset_type     result;
03491    boolean              same_common_block;
03492    int                  same_sb_idx;
03493    int                  sb_idx;
03494 
03495 # if !defined(_SEPARATE_NONCOMMON_EQUIV_GROUPS)
03496    int                  group;
03497    int                  item;
03498    id_str_type          name;
03499    int                  new_sb_idx;
03500    int                  np_idx;
03501    size_offset_type     offset;
03502 # endif
03503 
03504 # if defined(_TARGET_DOUBLE_ALIGN)
03505    size_offset_type     left;
03506 # endif
03507 
03508 
03509    TRACE (Func_Entry, "storage_blk_resolution", NULL);
03510 
03511    /* Set the data initialized flag for the static initialization stor blk */
03512 
03513    for (sb_idx = 1; sb_idx <= stor_blk_tbl_idx; sb_idx++) {
03514 
03515       if (SB_SCP_IDX(sb_idx) != curr_scp_idx) {
03516          continue;
03517       }
03518 
03519       if (SB_IS_COMMON(sb_idx)) {
03520          SB_PAD_BLK(sb_idx) = cmd_line_flags.pad;
03521 
03522          if (cmd_line_flags.pad_amount != 0) {
03523             SB_PAD_AMOUNT(sb_idx)       = cmd_line_flags.pad_amount;
03524             SB_PAD_AMOUNT_SET(sb_idx)   = TRUE;
03525          }
03526 
03527          check_and_allocate_common_storage(sb_idx);
03528   
03529          if (!SB_HIDDEN(sb_idx) && !SB_HOST_ASSOCIATED(sb_idx)) {
03530 
03531             if (srch_global_name_tbl(SB_NAME_PTR(sb_idx), 
03532                                      SB_NAME_LEN(sb_idx),
03533                                      &name_idx)) {
03534 
03535                gac_idx  = GN_ATTR_IDX(name_idx);
03536 
03537                if (GA_OBJ_CLASS(gac_idx) != Common_Block) {
03538 
03539                   /* Have a common and program unit with same name.  The    */
03540                   /* common entry is always first and then points to the    */
03541                   /* program unit.  Add a global attr for the common block. */
03542 
03543                   ga_pgm_idx    = gac_idx;
03544                   gac_idx       = ntr_common_in_global_attr_tbl(sb_idx, 
03545                                                                 name_idx);
03546 
03547                   GAC_PGM_UNIT_IDX(gac_idx) = ga_pgm_idx;
03548                   GN_ATTR_IDX(name_idx)     = gac_idx;
03549 
03550 # if defined(_ERROR_DUPLICATE_GLOBALS)
03551                   msg_level = Error;
03552 # else
03553                   msg_level = (GAP_PGM_UNIT(ga_pgm_idx) == Module) ?
03554                               Error : Ansi;
03555 # endif
03556                   PRINTMSG(SB_DEF_LINE(sb_idx), 1006, msg_level,
03557                            SB_DEF_COLUMN(sb_idx),
03558                            SB_NAME_PTR(sb_idx),
03559                            pgm_unit_str[GAP_PGM_UNIT(ga_pgm_idx)]);
03560                }
03561                else {
03562                   same_common_block = !SB_EQUIVALENCED(sb_idx) && 
03563                                       !GAC_EQUIVALENCED(gac_idx);
03564 
03565                   /* Common block used in another program unit. */
03566 
03567                   if (SB_AUXILIARY(sb_idx) ^ GAC_AUXILIARY(gac_idx)) {
03568                      same_common_block  = FALSE;
03569                      PRINTMSG(SB_DEF_LINE(sb_idx), 1276, Warning,
03570                               SB_DEF_COLUMN(sb_idx),
03571                               SB_NAME_PTR(sb_idx),
03572                               "AUXILIARY");
03573                   }
03574 
03575                   if ((SB_BLK_TYPE(sb_idx) == Task_Common && 
03576                       !GAC_TASK_COMMON(gac_idx)) ||
03577                       (SB_BLK_TYPE(sb_idx) != Task_Common && 
03578                        GAC_TASK_COMMON(gac_idx))) {
03579                      same_common_block  = FALSE;
03580           
03581                      PRINTMSG(SB_DEF_LINE(sb_idx), 1276, Warning,
03582                               SB_DEF_COLUMN(sb_idx),
03583                               SB_NAME_PTR(sb_idx),
03584                               "TASK_COMMON");
03585                   }
03586 
03587                   if (SB_ALIGN_SYMBOL(sb_idx) ^ GAC_ALIGN_SYMBOL(gac_idx)) {
03588                      same_common_block  = FALSE;
03589                      PRINTMSG(SB_DEF_LINE(sb_idx), 1602, Warning,
03590                               SB_DEF_COLUMN(sb_idx),
03591                               SB_NAME_PTR(sb_idx),
03592                               "ALIGN_SYMBOL");
03593                   }
03594 
03595                   if (SB_FILL_SYMBOL(sb_idx) ^ GAC_FILL_SYMBOL(gac_idx)) {
03596                      same_common_block  = FALSE;
03597                      PRINTMSG(SB_DEF_LINE(sb_idx), 1602, Warning,
03598                               SB_DEF_COLUMN(sb_idx),
03599                               SB_NAME_PTR(sb_idx),
03600                               "FILL_SYMBOL");
03601                   }
03602 
03603                   if (SB_SECTION_GP(sb_idx) ^ GAC_SECTION_GP(gac_idx)) {
03604                      same_common_block  = FALSE;
03605                      PRINTMSG(SB_DEF_LINE(sb_idx), 1602, Warning,
03606                               SB_DEF_COLUMN(sb_idx),
03607                               SB_NAME_PTR(sb_idx),
03608                               "SECTION_GP");
03609                   }
03610 
03611                   if (SB_SECTION_NON_GP(sb_idx) ^ GAC_SECTION_NON_GP(gac_idx)) {
03612                      same_common_block  = FALSE;
03613                      PRINTMSG(SB_DEF_LINE(sb_idx), 1602, Warning,
03614                               SB_DEF_COLUMN(sb_idx),
03615                               SB_NAME_PTR(sb_idx),
03616                               "SECTION_NON_GP");
03617                   }
03618 
03619                   if (SB_CACHE_ALIGN(sb_idx) ^ GAC_CACHE_ALIGN(gac_idx)) {
03620                      same_common_block  = FALSE;
03621                      PRINTMSG(SB_DEF_LINE(sb_idx), 1602, Warning,
03622                               SB_DEF_COLUMN(sb_idx),
03623                               SB_NAME_PTR(sb_idx),
03624                               "CACHE_ALIGN");
03625                   }
03626 
03627                   /* Check to make sure all the members have the same type */
03628                   /* kind and rank.   We'll check for same name too.       */
03629 
03630                   attr_idx      = SB_FIRST_ATTR_IDX(sb_idx);
03631                   ga_idx        = GAC_FIRST_MEMBER_IDX(gac_idx);
03632 
03633                   while (attr_idx != NULL_IDX && ga_idx != NULL_IDX) {
03634 
03635                      /* We are looking at all Common block objects, so */
03636                      /* we can assume that these are all Variables.    */
03637 
03638                      if (!compare_global_type_rank(ga_idx,
03639                                                    NULL_IDX,
03640                                                    attr_idx,
03641                                                    NULL_IDX,
03642                                                    TRUE)) {
03643                         same_common_block       = FALSE;
03644 # if 0
03645                         PRINTMSG(AT_DEF_LINE(attr_idx), 1603, Caution,
03646                                  AT_DEF_COLUMN(attr_idx),
03647                                  SB_NAME_PTR(sb_idx));
03648 # endif
03649                         break;
03650                      }
03651                      attr_idx   = ATD_NEXT_MEMBER_IDX(attr_idx);
03652                      ga_idx     = GAD_NEXT_IDX(ga_idx);
03653                   }
03654 
03655                   if (attr_idx != NULL_IDX || ga_idx != NULL_IDX) {
03656                      same_common_block  = FALSE;
03657                   }
03658 
03659                   if (!same_common_block) {
03660                      GAC_FOUND_DIFFS(gac_idx)           = TRUE;
03661                      SB_DUPLICATE_COMMON(sb_idx)        = FALSE;
03662                   }
03663                   else if (!GAC_FOUND_DIFFS(gac_idx)) {
03664                      SB_DUPLICATE_COMMON(sb_idx)        = TRUE;
03665                   }
03666                }
03667             }
03668             else {
03669                ntr_global_name_tbl(NULL_IDX, sb_idx, name_idx);
03670             }
03671          }
03672       }
03673       else if (cmd_line_flags.taskcommon) {
03674 
03675          /* All module blocks and all static blocks must be switched to      */
03676          /* taskcommon if the -a taskcommon commandline option is specified. */
03677 
03678          if (SB_MODULE(sb_idx) ||
03679              SB_BLK_TYPE(sb_idx) == Static ||
03680              SB_BLK_TYPE(sb_idx) == Static_Named ||
03681              SB_BLK_TYPE(sb_idx) == Static_Local) {
03682             SB_BLK_TYPE(sb_idx) = Task_Common;
03683          }
03684       }
03685       else if (cmd_line_flags.static_threadprivate) {
03686 
03687          /* All module blocks and all static blocks must be switched */
03688          /* to taskcommon if the -a static_threadprivate commandline */
03689          /* option is specified.                                     */
03690 
03691          if (SB_MODULE(sb_idx) ||
03692              SB_BLK_TYPE(sb_idx) == Static ||
03693              SB_BLK_TYPE(sb_idx) == Static_Named ||
03694              SB_BLK_TYPE(sb_idx) == Static_Local) {
03695             SB_BLK_TYPE(sb_idx) = Threadprivate;
03696          }
03697       }
03698 
03699 
03700       if (SB_BLK_TYPE(sb_idx) == Equivalenced && SB_HOSTED_STACK(sb_idx)) {
03701 
03702 # if defined(_DEBUG)
03703 
03704          if (SB_LEN_FLD(sb_idx) != CN_Tbl_Idx) {
03705             PRINTMSG(SB_DEF_LINE(sb_idx), 1201, Internal, SB_DEF_COLUMN(sb_idx),
03706                      SB_NAME_PTR(sb_idx));
03707          }
03708 # endif
03709 
03710          result.fld     = SB_LEN_FLD(sb_idx);
03711          result.idx     = SB_LEN_IDX(sb_idx);
03712 
03713          align_bit_length(&result, TARGET_BITS_PER_WORD);
03714 
03715          if (result.fld == NO_Tbl_Idx) {
03716             SB_LEN_FLD(sb_idx) = CN_Tbl_Idx;
03717             SB_LEN_IDX(sb_idx) = ntr_const_tbl(result.type_idx,
03718                                                FALSE,
03719                                                result.constant);
03720          }
03721          else {
03722             SB_LEN_FLD(sb_idx) = result.fld;
03723             SB_LEN_IDX(sb_idx) = result.idx;
03724          }
03725 
03726 # if !defined(_SEPARATE_NONCOMMON_EQUIV_GROUPS)
03727 
03728          /* Host associated stack equivalence group.  Merge this group with  */
03729          /* the host associated stack.  If there is no hosted group, just    */
03730          /* make this one the hosted stack group.                            */
03731 
03732          if (SCP_SB_HOSTED_STACK_IDX(curr_scp_idx) == NULL_IDX) {
03733             CREATE_ID(name, sb_name[Stack_Host_Blk], sb_len[Stack_Host_Blk]);
03734             NTR_NAME_POOL(&(name.words[0]), sb_len[Stack_Host_Blk], np_idx);
03735             SB_NAME_IDX(sb_idx)                   = np_idx;
03736             SB_NAME_LEN(sb_idx)                   = sb_len[Stack_Host_Blk];
03737             SB_BLK_TYPE(sb_idx)                   = Stack;
03738             SB_RUNTIME_INIT(sb_idx)               = TRUE;
03739             SCP_SB_HOSTED_STACK_IDX(curr_scp_idx) = sb_idx;
03740          }
03741          else {  /* Merge this group with the already existing @STACK_HOST    */
03742                  /* group.  Adjust all offsets and ATD_STOR_BLK_IDX's.        */
03743 
03744             new_sb_idx  = SCP_SB_HOSTED_STACK_IDX(curr_scp_idx);
03745 
03746             offset.fld  = SB_LEN_FLD(new_sb_idx);
03747             offset.idx  = SB_LEN_IDX(new_sb_idx);
03748 
03749             align_bit_length(&offset, TARGET_BITS_PER_WORD);
03750 
03751             group       = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
03752 
03753             while (ATD_STOR_BLK_IDX(EQ_ATTR_IDX(group)) != sb_idx) {
03754                group = EQ_NEXT_EQUIV_GRP(group);
03755             }
03756             item = group;
03757 
03758 # if defined(_TARGET_DOUBLE_ALIGN)
03759 
03760             if (EQ_DALIGN_ME(item)) {
03761                C_TO_F_INT(result.constant,
03762                           TARGET_BITS_PER_WORD * 2,
03763                           CG_INTEGER_DEFAULT_TYPE);
03764                result.fld               = NO_Tbl_Idx;
03765                result.type_idx          = CG_INTEGER_DEFAULT_TYPE;
03766                left.fld                 = CN_Tbl_Idx;
03767                left.idx                 = CN_INTEGER_ZERO_IDX;
03768 
03769                size_offset_binary_calc(&offset, &result, Mod_Opr, &result);
03770 
03771                size_offset_logical_calc(&result, &left, Ne_Opr, &result);
03772 
03773                if (THIS_IS_TRUE(result.constant, result.type_idx)) {
03774 
03775                   /* This is not on a double word boundary */
03776 
03777                   result.idx    = CN_INTEGER_BITS_PER_WORD_IDX;
03778                   result.fld    = CN_Tbl_Idx;
03779 
03780                   /* Rather than padding, remove the 32-bit pad */
03781                   /* added to the front of this equivalence group. */
03782 
03783                   size_offset_binary_calc(&offset,
03784                                           &result,
03785                                           EQ_DALIGN_SHIFT(item) ? Minus_Opr :
03786                                                                   Plus_Opr,
03787                                           &offset);
03788                }
03789             }
03790 # endif
03791 
03792             while (item != NULL_IDX) {
03793 
03794                if (ATD_STOR_BLK_IDX(EQ_ATTR_IDX(item)) == sb_idx) {
03795                   ATD_STOR_BLK_IDX(EQ_ATTR_IDX(item))   = new_sb_idx;
03796 
03797                   result.fld = ATD_OFFSET_FLD(EQ_ATTR_IDX(item));
03798                   result.idx = ATD_OFFSET_IDX(EQ_ATTR_IDX(item));
03799 
03800                   size_offset_binary_calc(&result, &offset, Plus_Opr, &result);
03801 
03802                   if (result.fld == NO_Tbl_Idx) {
03803                      ATD_OFFSET_FLD(EQ_ATTR_IDX(item)) = CN_Tbl_Idx;
03804                      ATD_OFFSET_IDX(EQ_ATTR_IDX(item)) =