• Main Page
  • Modules
  • Data Types
  • Files

osprey/crayf90/fe90/s_dcls.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008. PathScale, LLC. All Rights Reserved.
00003  */
00004 /*
00005  *  Copyright (C) 2006, 2007. QLogic Corporation. All Rights Reserved.
00006  */
00007 
00008 /*
00009  * Copyright 2004, 2005, 2006 PathScale, Inc.  All Rights Reserved.
00010  */
00011 
00012 /*
00013 
00014   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00015 
00016   This program is free software; you can redistribute it and/or modify it
00017   under the terms of version 2 of the GNU General Public License as
00018   published by the Free Software Foundation.
00019 
00020   This program is distributed in the hope that it would be useful, but
00021   WITHOUT ANY WARRANTY; without even the implied warranty of
00022   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00023 
00024   Further, this software is distributed without any warranty that it is
00025   free of the rightful claim of any third person regarding infringement 
00026   or the like.  Any license provided herein, whether implied or 
00027   otherwise, applies only to this software file.  Patent licenses, if 
00028   any, provided herein do not apply to combinations of this program with 
00029   other software, or any other product whatsoever.  
00030 
00031   You should have received a copy of the GNU General Public License along
00032   with this program; if not, write the Free Software Foundation, Inc., 59
00033   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00034 
00035   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00036   Mountain View, CA 94043, or:
00037 
00038   http://www.sgi.com
00039 
00040   For further information regarding this notice, see:
00041 
00042   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00043 
00044 */
00045 
00046 
00047 
00048 static char USMID[] = "\n@(#)5.0_pl/sources/s_dcls.c  5.7 09/29/99 17:38:13\n";
00049 
00050 # include "defines.h"   /* Machine dependent ifdefs */
00051 
00052 # include "host.m"    /* Host machine dependent macros.*/
00053 # include "host.h"    /* Host machine dependent header.*/
00054 # include "target.m"    /* Target machine dependent macros.*/
00055 # include "target.h"    /* Target machine dependent header.*/
00056 
00057 # include "globals.m"
00058 # include "tokens.m"
00059 # include "sytb.m"
00060 # include "s_globals.m"
00061 # include "debug.m"
00062 
00063 # include "globals.h"
00064 # include "tokens.h"
00065 # include "sytb.h"
00066 # include "s_globals.h"
00067 
00068 
00069 /*********************************************************\
00070 |* Globals used between decl_semantics and attr_semantics |
00071 \*********************************************************/
00072 
00073   int     allocatable_list_idx;
00074   int     alt_entry_equiv_blk;
00075   int     alt_entry_equiv_grp;
00076   int init_sh_start_idx;
00077   int init_sh_end_idx;
00078   int     namelist_list_idx;
00079   int     number_of_allocatables;
00080   int     pointee_based_blk;
00081   int     reshape_array_list;
00082 
00083 
00084 /*****************************************************************\
00085 |* Function prototypes of static functions declared in this file *|
00086 \*****************************************************************/
00087 
00088 static  void    assign_offsets_for_equiv_groups(void);
00089 static  void  attr_semantics(int, boolean);
00090 static  void  bound_resolution(int);
00091 static  boolean compare_darg_or_rslt_types(int, int);
00092 static  void  compare_duplicate_interface_bodies(int);
00093 static  void  compare_entry_to_func_rslt(int, int);
00094 static  boolean darg_in_entry_list(int, int);
00095 static  void    deallocate_local_allocatables(void);
00096 static  void  distribution_resolution(int);
00097 static  void  equivalence_semantics(void);
00098 static  void  gen_assumed_shape_copy(opnd_type *);
00099 static  int gen_auto_length(int, opnd_type *);
00100 static  void    gen_branch_around_ir(int, int, int);
00101 static  int     gen_darg_branch_test(int);
00102 static  boolean gen_ir_at_this_entry(int, int);
00103 #ifndef KEY /* Bug 4955 */
00104 static  void  gen_present_ir(int, int, int);
00105 #endif /* KEY Bug 4955 */
00106 static  void  gen_single_automatic_allocate(int);
00107 static  void  gen_tmp_eq_zero_ir(int);
00108 static  void  insert_argchck_calls(int, int);
00109 static  void  insert_sh_after_entries(int, int, int, boolean, boolean);
00110 static  void  linearize_list_for_equiv(int);
00111 static  int merge_entry_lists(int, int);
00112 static  int merge_entry_list_count(int, int);
00113 static  void  merge_equivalence_groups1(void);
00114 static  void  merge_equivalence_groups2(void);
00115 static  boolean must_reassign_XT_temp(opnd_type *);
00116 static  void  namelist_resolution(int);
00117 static  int ntr_bnds_sh_tmp_list(opnd_type *, int, int, boolean, int);
00118 static  void  reshape_array_semantics(void);
00119 static  void  tmp_il_resolution(int);
00120 static  void  tmp_ir_resolution(int);
00121 static  void  verify_interface (int);
00122 static  void  gen_allocatable_ptr_ptee(int);
00123 static  int set_up_bd_tmps(int, int, int, int, boolean);
00124 
00125 # if defined(_TARGET_WORD_ADDRESS) ||  \
00126      (defined(_HEAP_REQUEST_IN_WORDS) && defined(_TARGET_BYTE_ADDRESS))
00127 static  void  gen_word_align_byte_length_ir(opnd_type *);
00128 # endif
00129 
00130 # if !defined(_SINGLE_ALLOCS_FOR_AUTOMATIC)
00131 static  void  gen_multiple_automatic_allocate(int);
00132 # endif
00133 
00134 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
00135 # pragma inline create_equiv_stor_blk
00136 # else
00137 # pragma _CRI inline create_equiv_stor_blk
00138 # endif
00139 
00140 
00141 /******************************************************************************\
00142 |*                                                                            *|
00143 |* Description:                                                               *|
00144 |*      Perform semantic checks for EQUIVALENCE statements.                   *|
00145 |*                                                                            *|
00146 |* Input parameters:                                                          *|
00147 |*      NONE                                                                  *|
00148 |*                                                                            *|
00149 |* Output parameters:                                                         *|
00150 |*      NONE                                                                  *|
00151 |*                                                                            *|
00152 |* Returns:                                                                   *|
00153 |*      NONE                                                                  *|
00154 |*                                                                            *|
00155 \******************************************************************************/
00156 static void     equivalence_semantics(void)
00157 {
00158 
00159    int      attr_idx;
00160    boolean    automatic;
00161    int      common_attr_idx;
00162    int      common_sb_idx;
00163    boolean    default_numeric_sequence;
00164    boolean    default_numeric_type;
00165    boolean    default_character_sequence;
00166    boolean    default_character_type;
00167    int      group;
00168    int      il_idx;
00169    int      ir_idx;
00170    boolean    is_volatile;
00171    int      item;
00172    int      list_idx;
00173    int      new_idx;
00174    int      nondefault_sequence_type;
00175    int      nondefault_intrinsic_type;
00176    int      offset_idx;
00177    boolean    ok;
00178    opnd_type    opnd;
00179    expr_arg_type  opnd_desc;
00180    long_type    result[MAX_WORDS_FOR_INTEGER];
00181    cif_usage_code_type  save_xref_state;
00182    int      sb_idx;
00183    int      subscript_count;
00184    int      substring_list;
00185    int      type_idx;
00186 
00187 
00188    TRACE (Func_Entry, "equivalence_semantics", NULL);
00189 
00190    group = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
00191 
00192    while (group != NULL_IDX) {
00193       item    = group;
00194       common_attr_idx = NULL_IDX;
00195       common_sb_idx = NULL_IDX;
00196 
00197       while (item != NULL_IDX) {
00198 
00199          if (ATD_IN_COMMON(EQ_ATTR_IDX(item))) {
00200 
00201             if (common_sb_idx == NULL_IDX) {
00202                common_attr_idx  = EQ_ATTR_IDX(item);
00203                common_sb_idx  = ATD_STOR_BLK_IDX(common_attr_idx);
00204             }
00205             else if (common_sb_idx != ATD_STOR_BLK_IDX(common_attr_idx)) {
00206 
00207                /* Two different items from the same common */
00208                /* block are equivalenced together.         */
00209 
00210                PRINTMSG(EQ_LINE_NUM(item), 826, Error, EQ_COLUMN_NUM(item),
00211                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00212                         AT_OBJ_NAME_PTR(common_attr_idx));
00213             }
00214 
00215             if (SB_BLK_HAS_NPES(common_sb_idx)) {
00216                PRINTMSG(EQ_LINE_NUM(item), 1228, Error, EQ_COLUMN_NUM(item),
00217                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00218                         SB_BLANK_COMMON(common_sb_idx) ?
00219                         "" : SB_NAME_PTR(common_sb_idx));
00220                AT_DCL_ERR(EQ_ATTR_IDX(item))  = TRUE;
00221             }
00222 
00223 # if 0
00224             if (SB_ALIGN_SYMBOL(common_sb_idx) ||
00225                 SB_FILL_SYMBOL(common_sb_idx)) {
00226                AT_DCL_ERR(EQ_ATTR_IDX(item))  = TRUE;
00227                PRINTMSG(EQ_LINE_NUM(item), 1488, Error, EQ_COLUMN_NUM(item),
00228                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00229                         SB_NAME_PTR(common_sb_idx),
00230                         SB_ALIGN_SYMBOL(common_sb_idx) ? "ALIGN_SYMBOL" :
00231                                                          "FILL_SYMBOL");
00232             }
00233 # endif
00234          }
00235 # if 0
00236          else if (SB_MODULE(ATD_STOR_BLK_IDX(EQ_ATTR_IDX(item))) &&
00237                   (SB_ALIGN_SYMBOL(ATD_STOR_BLK_IDX(EQ_ATTR_IDX(item))) ||
00238                    SB_FILL_SYMBOL(ATD_STOR_BLK_IDX(EQ_ATTR_IDX(item))))) {
00239             AT_DCL_ERR(EQ_ATTR_IDX(item)) = TRUE;
00240             PRINTMSG(EQ_LINE_NUM(item), 1489, Error, EQ_COLUMN_NUM(item),
00241                      AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00242                      AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)),
00243                      SB_ALIGN_SYMBOL(ATD_STOR_BLK_IDX(EQ_ATTR_IDX(item))) ?
00244                                      "ALIGN_SYMBOL" : "FILL_SYMBOL");
00245          }
00246 # endif
00247 
00248          if (EQ_OPND_FLD(item) == NO_Tbl_Idx) {
00249 
00250             /* if stand alone name, then offset is set to 0 */
00251 
00252             NTR_IR_LIST_TBL(new_idx);
00253             EQ_LIST_IDX(item)   = new_idx;
00254             IL_FLD(new_idx)   = CN_Tbl_Idx;
00255             IL_IDX(new_idx)   = CN_INTEGER_ZERO_IDX;
00256             IL_LINE_NUM(new_idx)  = 1;
00257             IL_COL_NUM(new_idx)   = 0;
00258          }
00259          else if ((!EQ_SUBSTRINGED(item) && 
00260                    ATD_ARRAY_IDX(EQ_ATTR_IDX(item)) == NULL_IDX) ||
00261                   (EQ_SUBSTRINGED(item) &&
00262                    TYP_TYPE(ATD_TYPE_IDX(EQ_ATTR_IDX(item))) != Character)) {
00263             AT_DCL_ERR(EQ_ATTR_IDX(item)) = TRUE;
00264             PRINTMSG(EQ_LINE_NUM(item), 840, Error,
00265                      EQ_COLUMN_NUM(item),
00266                      AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00267             NTR_IR_LIST_TBL(new_idx);
00268             EQ_LIST_IDX(item)   = new_idx;
00269             IL_FLD(new_idx)   = CN_Tbl_Idx;
00270             IL_IDX(new_idx)   = CN_INTEGER_ZERO_IDX;
00271             IL_LINE_NUM(new_idx)  = 1;
00272             IL_COL_NUM(new_idx)   = 0;
00273          }
00274          else {
00275 
00276             /* this is true only if something follows the object */
00277             /* that is a subscript and or substring              */
00278 
00279             OPND_FLD(opnd)    = EQ_OPND_FLD(item);
00280             OPND_IDX(opnd)    = EQ_OPND_IDX(item);
00281             OPND_LINE_NUM(opnd)   = EQ_LINE_NUM(item);
00282             OPND_COL_NUM(opnd)    = EQ_COLUMN_NUM(item);
00283             opnd_desc.rank    = 0;
00284             expr_mode     = Initialization_Expr;
00285             save_xref_state   = xref_state;
00286             xref_state      = CIF_Symbol_Reference;
00287             attr_idx      = find_left_attr(&opnd);
00288             ATD_PARENT_OBJECT(attr_idx) = TRUE;
00289             ok        = expr_semantics(&opnd, &opnd_desc);
00290             xref_state      = save_xref_state;
00291             expr_mode     = Regular_Expr;
00292             ATD_PARENT_OBJECT(attr_idx) = FALSE;
00293 
00294             if (!ok) {
00295                EQ_LIST_IDX(item)= NULL_IDX;
00296                EQ_ERROR(item) = TRUE;
00297                item   = EQ_NEXT_EQUIV_OBJ(item);
00298                continue;
00299             }
00300 
00301             /* Break the subscripts and substrings up. */
00302 
00303             subscript_count = 0;
00304             substring_list  = NULL_IDX;
00305 
00306             ir_idx = (OPND_FLD(opnd) == IR_Tbl_Idx) ? OPND_IDX(opnd): NULL_IDX;
00307 
00308             if (ir_idx != NULL_IDX &&
00309                 (IR_OPR(ir_idx) == Substring_Opr ||
00310                  IR_OPR(ir_idx) == Whole_Substring_Opr)) {
00311                EQ_SUBSTRINGED(item) = TRUE;
00312                substring_list   = IR_IDX_R(ir_idx);
00313                ir_idx = (IR_FLD_L(ir_idx) == IR_Tbl_Idx) ? IR_IDX_L(ir_idx) :
00314                                                            NULL_IDX;
00315             }
00316 
00317             if (ir_idx != NULL_IDX &&
00318                  IR_OPR(ir_idx) == Whole_Subscript_Opr) {
00319                ir_idx = (IR_FLD_L(ir_idx) == IR_Tbl_Idx) ? IR_IDX_L(ir_idx) :
00320                                                            NULL_IDX;
00321             }
00322 
00323             if (ir_idx != NULL_IDX && 
00324                 (IR_OPR(ir_idx) == Section_Subscript_Opr ||
00325                  IR_OPR(ir_idx) == Struct_Opr)) {
00326 
00327                if (IR_OPR(ir_idx) == Section_Subscript_Opr) {
00328                   PRINTMSG(EQ_LINE_NUM(item), 250, Error, EQ_COLUMN_NUM(item));
00329                }
00330                else {
00331                   PRINTMSG(EQ_LINE_NUM(item), 1537, Error, EQ_COLUMN_NUM(item));
00332                }
00333 
00334 
00335                EQ_LIST_IDX(item)  = NULL_IDX;
00336                EQ_ERROR(item)   = TRUE;
00337                item     = EQ_NEXT_EQUIV_OBJ(item);
00338                continue;
00339             }
00340 
00341             if (ir_idx != NULL_IDX && 
00342                 (IR_OPR(ir_idx) == Subscript_Opr ||
00343                  IR_OPR(ir_idx) == Whole_Subscript_Opr ||
00344                  IR_OPR(ir_idx) == Section_Subscript_Opr)) {
00345                subscript_count   = IR_LIST_CNT_R(ir_idx);
00346                EQ_LIST_IDX(item) = IR_IDX_R(ir_idx);
00347             }
00348 
00349             if (substring_list != NULL_IDX) {  /* Add the substring list */
00350 
00351                if (EQ_LIST_IDX(item) == NULL_IDX) {
00352                   EQ_LIST_IDX(item) = substring_list;
00353                }
00354                else {
00355                   il_idx = EQ_LIST_IDX(item);
00356 
00357                   while (IL_NEXT_LIST_IDX(il_idx) != NULL_IDX) {
00358                      il_idx = IL_NEXT_LIST_IDX(il_idx);
00359                   }
00360                   IL_NEXT_LIST_IDX(il_idx) = substring_list;
00361                }
00362 
00363                il_idx = IL_NEXT_LIST_IDX(substring_list);  /* End substring*/
00364                il_idx = IL_NEXT_LIST_IDX(il_idx);
00365 
00366                /* il_idx is now the character length in the substring.  */
00367                /* This is not needed, but a NULL entry is, so clear it. */
00368                /* But check for a zero length substring first.          */
00369 
00370                if (IL_FLD(il_idx) == CN_Tbl_Idx) {
00371                   type_idx    = CG_LOGICAL_DEFAULT_TYPE;
00372 
00373                   folder_driver((char *) &CN_CONST(IL_IDX(il_idx)),
00374                                          CN_TYPE_IDX(IL_IDX(il_idx)),
00375                                 (char *) &CN_CONST(CN_INTEGER_ZERO_IDX),
00376                                          CN_TYPE_IDX(CN_INTEGER_ZERO_IDX),
00377                                          result,
00378                                          &type_idx,
00379                                          EQ_LINE_NUM(item),
00380                                          EQ_COLUMN_NUM(item),
00381                                          2,
00382                                          Le_Opr);
00383 
00384                  if (THIS_IS_TRUE(result, type_idx)) {
00385                     PRINTMSG(EQ_LINE_NUM(item), 1627,Error,EQ_COLUMN_NUM(item));
00386                  }
00387                }
00388                IL_OPND(il_idx) = null_opnd;
00389             }
00390             else if (EQ_LIST_IDX(item) != NULL_IDX) {
00391 
00392                /* Just have subscripts.  Find end of list and add NULL */
00393 
00394                il_idx = EQ_LIST_IDX(item);
00395 
00396                while (IL_NEXT_LIST_IDX(il_idx) != NULL_IDX) {
00397                   il_idx = IL_NEXT_LIST_IDX(il_idx);
00398                }
00399                NTR_IR_LIST_TBL(new_idx);
00400                IL_NEXT_LIST_IDX(il_idx) = new_idx;
00401                IL_OPND(new_idx)   = null_opnd;
00402                IL_LINE_NUM(new_idx) = EQ_LINE_NUM(item);
00403                IL_COL_NUM(new_idx)  = EQ_COLUMN_NUM(item);
00404             }
00405 
00406             EQ_OPND_FLD(item) = NO_Tbl_Idx;
00407             EQ_OPND_IDX(item) = NULL_IDX;
00408 
00409             if (ATD_ARRAY_IDX(EQ_ATTR_IDX(item)) > 0) {
00410 
00411                if (! dump_flags.no_dimension_padding &&
00412                    subscript_count < BD_RANK(ATD_ARRAY_IDX(EQ_ATTR_IDX(item)))){
00413                   PRINTMSG(EQ_LINE_NUM(item), 375, Warning, 
00414                            EQ_COLUMN_NUM(item));
00415                }
00416                else if (subscript_count > 
00417                         BD_RANK(ATD_ARRAY_IDX(EQ_ATTR_IDX(item)))) {
00418                   PRINTMSG(EQ_LINE_NUM(item), 204, Error, 
00419                            EQ_COLUMN_NUM(item));
00420 
00421                   /* Do not want to call linearize_list_for_equiv because the */
00422                   /* rank of the array is less than the number of dimension.  */
00423 
00424                   item = EQ_NEXT_EQUIV_OBJ(item);
00425                   continue;
00426                }
00427             }
00428 
00429             linearize_list_for_equiv(item);
00430          }
00431 
00432          item = EQ_NEXT_EQUIV_OBJ(item);
00433       }
00434       group = EQ_NEXT_EQUIV_GRP(group);
00435    }
00436 
00437    merge_equivalence_groups1();
00438 
00439    assign_offsets_for_equiv_groups();
00440 
00441    merge_equivalence_groups2();
00442 
00443    group = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
00444 
00445    while (group != NULL_IDX) {
00446       item    = group;
00447       sb_idx    = NULL_IDX;
00448       automatic   = FALSE;
00449       is_volatile = FALSE;
00450 
00451       while (item != NULL_IDX) {
00452 
00453          if (EQ_ERROR(item)) {
00454             item = EQ_NEXT_EQUIV_OBJ(item);
00455             continue;
00456          }
00457 
00458          attr_idx       = EQ_ATTR_IDX(item);
00459 
00460          if (!EQ_SEARCH_DONE(item) &&
00461              (ATD_CLASS(EQ_ATTR_IDX(item)) == Variable &&
00462               ATD_EQUIV_LIST(EQ_ATTR_IDX(item)) != NULL_IDX)) {
00463 
00464             /* This attr is in this equivalence group more than once. */
00465             /* All these items need to have the same offset.  We make */
00466             /* the assumption that the constant table shares entries, */
00467             /* so all these offset indexes should be the same.  If    */
00468             /* they are not, issue an error.                          */
00469 
00470             list_idx      = ATD_EQUIV_LIST(EQ_ATTR_IDX(item));
00471             offset_idx      = EQ_OFFSET_IDX(item);
00472             EQ_SEARCH_DONE(item)  = TRUE;
00473 
00474             while (list_idx != NULL_IDX) {
00475 
00476             if (fold_relationals(EQ_OFFSET_IDX(AL_EQ_IDX(list_idx)),
00477                                  offset_idx,
00478                                  Ne_Opr)) {
00479 
00480                   PRINTMSG(EQ_LINE_NUM(item), 528, Error,
00481                            EQ_COLUMN_NUM(item),
00482                            AT_OBJ_NAME_PTR(attr_idx));
00483                }
00484 
00485                list_idx = AL_NEXT_IDX(list_idx);
00486             }
00487          }
00488 
00489          if (sb_idx != NULL_IDX && sb_idx != ATD_STOR_BLK_IDX(attr_idx) &&
00490              SB_IS_COMMON(ATD_STOR_BLK_IDX(attr_idx)) &&
00491              SB_IS_COMMON(sb_idx)) {
00492             PRINTMSG(EQ_LINE_NUM(item), 823, Error,
00493                      EQ_COLUMN_NUM(item),
00494                      SB_BLANK_COMMON(sb_idx) ?
00495                      "" : SB_NAME_PTR(sb_idx),
00496                      SB_BLANK_COMMON(ATD_STOR_BLK_IDX(attr_idx)) ?
00497                      "" : SB_NAME_PTR(ATD_STOR_BLK_IDX(attr_idx)));
00498          }
00499 
00500          automatic   |= ATD_STACK(attr_idx);
00501          is_volatile |= ATD_VOLATILE(attr_idx);
00502 
00503          /* if item is in a common block move all items to that block */
00504 
00505          if (SB_IS_COMMON(ATD_STOR_BLK_IDX(attr_idx))) {
00506             sb_idx = ATD_STOR_BLK_IDX(attr_idx);
00507 
00508             /* If any item is in a common block and dalign is not     */
00509             /* specified on the commandline, none of the items in     */
00510             /* the equivalence group can be double aligned.           */
00511 
00512             EQ_DO_NOT_DALIGN(group) = !cmd_line_flags.dalign;
00513          }
00514          else if (SB_HOSTED_STATIC(ATD_STOR_BLK_IDX(attr_idx))) {
00515  
00516             if (sb_idx == NULL_IDX || !SB_IS_COMMON(sb_idx)) {
00517                sb_idx = ATD_STOR_BLK_IDX(attr_idx);
00518             }
00519          }
00520          else if (SB_HOSTED_STACK(ATD_STOR_BLK_IDX(attr_idx))) {
00521 
00522             if (sb_idx == NULL_IDX || 
00523                 (!SB_IS_COMMON(sb_idx) && !SB_HOSTED_STATIC(sb_idx))) {
00524                sb_idx = ATD_STOR_BLK_IDX(attr_idx);
00525             }
00526          }
00527          else if (SB_BLK_TYPE(ATD_STOR_BLK_IDX(attr_idx)) == Static ||
00528                   SB_BLK_TYPE(ATD_STOR_BLK_IDX(attr_idx)) == Static_Named ||
00529                   SB_BLK_TYPE(ATD_STOR_BLK_IDX(attr_idx)) == Static_Local) {
00530 
00531             if (sb_idx == NULL_IDX) {
00532 
00533                /* if no storage block yet and item is in @DATA */
00534                /* move all items to @DATA                      */
00535 
00536                sb_idx = ATD_STOR_BLK_IDX(attr_idx);
00537             }
00538          }
00539 
00540          if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure &&
00541              !cmd_line_flags.dalign &&
00542              ATT_DCL_NUMERIC_SEQ(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) {
00543             EQ_DO_NOT_DALIGN(group) = TRUE;
00544          }
00545 
00546          item = EQ_NEXT_EQUIV_OBJ(item);
00547       }
00548 
00549       if (sb_idx == NULL_IDX) {
00550          sb_idx = create_equiv_stor_blk(EQ_ATTR_IDX(group), Stack);
00551       }
00552 
00553 # if defined(_SEPARATE_NONCOMMON_EQUIV_GROUPS)
00554 
00555       else if (SB_HOSTED_STATIC(sb_idx)) {
00556          sb_idx = create_equiv_stor_blk(EQ_ATTR_IDX(group), Static);
00557          SB_HOSTED_STATIC(sb_idx) = TRUE;
00558       }
00559       else if (SB_HOSTED_STACK(sb_idx)) {
00560          sb_idx = create_equiv_stor_blk(EQ_ATTR_IDX(group), Stack);
00561          SB_HOSTED_STACK(sb_idx)  = TRUE;
00562       }
00563       else if ((SB_BLK_TYPE(sb_idx) == Static ||
00564                 SB_BLK_TYPE(sb_idx) == Static_Named ||
00565                 SB_BLK_TYPE(sb_idx) == Static_Local) &&
00566                !SB_MODULE(sb_idx)) {
00567          sb_idx = create_equiv_stor_blk(EQ_ATTR_IDX(group),SB_BLK_TYPE(sb_idx));
00568       }
00569 # endif
00570 
00571       SB_EQUIVALENCED(sb_idx)   = TRUE;
00572 
00573       if (SB_PAD_BLK(sb_idx) && !SB_IS_COMMON(sb_idx)) {
00574          PRINTMSG(EQ_LINE_NUM(group), 1352, Warning, EQ_COLUMN_NUM(group));
00575       }
00576 
00577       item        = group;
00578       default_numeric_sequence    = FALSE;
00579       default_numeric_type    = FALSE;
00580       default_character_sequence  = FALSE;
00581       default_character_type    = FALSE;
00582       nondefault_sequence_type    = NULL_IDX;
00583       nondefault_intrinsic_type   = NULL_IDX;
00584 
00585       /* An item in an equivalence group can be one of 6 type categories */
00586       /* according to the standard.  The standard only allows mixing of  */
00587       /* certain categories and Cray allows a few extra extensions.      */
00588 
00589       /* The categories are:                                             */
00590       /*   default_numeric_sequence   -> A derived type whose components */
00591       /*                                 are all default numeric types.  */
00592       /*   default_numeric_type       -> The type must be a default      */
00593       /*                                 numeric type.  (Not character,  */
00594       /*                                 derived type, or CRI pointer.)  */
00595       /*   default_character_sequence -> A derived type whose components */
00596       /*                                 are all default character types.*/
00597       /*   default_character_type     -> The type is default character.  */
00598       /*   nondefault_sequence_type   -> A derived type with mixed       */
00599       /*                                 components, both numeric and    */
00600       /*                                 character or non-default numeric*/
00601       /*   nondefault_intrinsic_type  -> The type is not a default type. */
00602 
00603 
00604       while (item != NULL_IDX) {
00605 
00606          if (EQ_ERROR(item)) {
00607             item = EQ_NEXT_EQUIV_OBJ(item);
00608             continue;
00609          }
00610 
00611          ATD_VOLATILE(EQ_ATTR_IDX(item))  = is_volatile;
00612 
00613          if (SB_IS_COMMON(sb_idx)) {
00614 
00615             if (ATD_SAVED(EQ_ATTR_IDX(item))) {
00616 
00617                /* An object with the SAVE attribute may not be */
00618                /* equivalenced to an object in a common block. */
00619 
00620                PRINTMSG(EQ_LINE_NUM(item), 1256, Error, EQ_COLUMN_NUM(item),
00621                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00622                         "SAVE");
00623             }
00624 
00625             if (ATD_STACK(EQ_ATTR_IDX(item))) {
00626 
00627                /* An object with the AUTOMATIC attribute may not be */
00628                /* equivalenced to an object in a common block.      */
00629 
00630                PRINTMSG(EQ_LINE_NUM(item), 1256, Error, EQ_COLUMN_NUM(item),
00631                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00632                         "AUTOMATIC");
00633             }
00634 
00635             if (TYP_TYPE(ATD_TYPE_IDX(EQ_ATTR_IDX(item))) == Structure &&
00636                ATT_DEFAULT_INITIALIZED(TYP_IDX(
00637                                        ATD_TYPE_IDX(EQ_ATTR_IDX(item))))) {
00638                PRINTMSG(EQ_LINE_NUM(item), 1591, Error, EQ_COLUMN_NUM(item),
00639                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00640                         AT_OBJ_NAME_PTR(TYP_IDX(
00641                                         ATD_TYPE_IDX(EQ_ATTR_IDX(item)))));
00642             }
00643          }
00644          else if (automatic && !ATD_STACK(EQ_ATTR_IDX(item))) {
00645 
00646             /* All must have the automatic attribute.  */
00647 
00648             PRINTMSG(EQ_LINE_NUM(item), 1257, Error, EQ_COLUMN_NUM(item),
00649                      AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00650                      "AUTOMATIC", "AUTOMATIC");
00651          }
00652 
00653          ATD_STOR_BLK_IDX(EQ_ATTR_IDX(item)) = sb_idx;
00654          type_idx          = ATD_TYPE_IDX(EQ_ATTR_IDX(item));
00655 
00656          if (TYP_TYPE(type_idx) == Structure) {
00657 
00658             if (!ATT_SEQUENCE_SET(TYP_IDX(type_idx))) {
00659                PRINTMSG(EQ_LINE_NUM(item), 294, Error,
00660                         EQ_COLUMN_NUM(item),
00661                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00662             }
00663 
00664             if (ATT_POINTER_CPNT(TYP_IDX(type_idx))
00665 #ifdef KEY /* Bug 6845 */
00666         || ATT_ALLOCATABLE_CPNT(TYP_IDX(type_idx))
00667 #endif /* KEY Bug 6845 */
00668       ) {
00669                PRINTMSG(EQ_LINE_NUM(item), 354, Error,
00670                         EQ_COLUMN_NUM(item),
00671                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00672             }
00673 
00674             if (ATT_CHAR_SEQ(TYP_IDX(type_idx))) {
00675 
00676                /* default_character_sequence */
00677 
00678                if (default_numeric_sequence || default_numeric_type) {
00679                   PRINTMSG(EQ_LINE_NUM(item), 1239, Error,
00680                            EQ_COLUMN_NUM(item),
00681                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00682                }
00683                else if (nondefault_sequence_type != NULL_IDX) {
00684                   PRINTMSG(EQ_LINE_NUM(nondefault_sequence_type), 1242, Error,
00685                            EQ_COLUMN_NUM(nondefault_sequence_type),
00686                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(
00687                                            nondefault_sequence_type)));
00688                }
00689                else if (nondefault_intrinsic_type != NULL_IDX) {
00690                   PRINTMSG(EQ_LINE_NUM(nondefault_intrinsic_type), 1241, Error,
00691                            EQ_COLUMN_NUM(nondefault_intrinsic_type),
00692                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(
00693                                            nondefault_intrinsic_type)));
00694                }
00695                else {
00696                   default_character_sequence  = TRUE;
00697                }
00698             }
00699             else if (!ATT_NON_DEFAULT_CPNT(TYP_IDX(type_idx)) &&
00700                       ATT_DCL_NUMERIC_SEQ(TYP_IDX(type_idx))) {
00701 
00702                /* default_numeric_sequence */
00703 
00704                if (default_character_sequence || default_character_type) {
00705                   PRINTMSG(EQ_LINE_NUM(item), 1240, Error,
00706                            EQ_COLUMN_NUM(item),
00707                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00708                }
00709                else if (nondefault_sequence_type != NULL_IDX) {
00710                   PRINTMSG(EQ_LINE_NUM(nondefault_sequence_type), 1242, Error,
00711                            EQ_COLUMN_NUM(nondefault_sequence_type),
00712                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(
00713                                            nondefault_sequence_type)));
00714                }
00715                else if (nondefault_intrinsic_type != NULL_IDX) {
00716                   PRINTMSG(EQ_LINE_NUM(nondefault_intrinsic_type), 1241, Error,
00717                            EQ_COLUMN_NUM(nondefault_intrinsic_type),
00718                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(
00719                                            nondefault_intrinsic_type)));
00720                }
00721 
00722                else {
00723 
00724 # if defined(_ACCEPT_CMD_s_32)
00725                   if (cmd_line_flags.s_default32) {
00726                      PRINTMSG(EQ_LINE_NUM(item), 1244, Warning,
00727                               EQ_COLUMN_NUM(item),
00728                               AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)),
00729                               AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
00730                   }
00731 # endif
00732                   default_numeric_sequence  = TRUE;
00733                }
00734             }
00735             else {  /* nondefault sequence type */
00736 
00737                if (default_character_sequence || default_character_type) {
00738                   PRINTMSG(EQ_LINE_NUM(item), 1240, Error,
00739                            EQ_COLUMN_NUM(item),
00740                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00741                }
00742                else if (default_numeric_sequence || default_numeric_type) {
00743                   PRINTMSG(EQ_LINE_NUM(item), 1239, Error,
00744                               EQ_COLUMN_NUM(item),
00745                               AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00746                }
00747                else if (nondefault_intrinsic_type != NULL_IDX) {
00748                   PRINTMSG(EQ_LINE_NUM(nondefault_intrinsic_type), 1241, Error,
00749                            EQ_COLUMN_NUM(nondefault_intrinsic_type),
00750                            AT_OBJ_NAME_PTR(EQ_ATTR_IDX(
00751                                            nondefault_intrinsic_type)));
00752                }
00753 #if 0
00754 /* 28Feb01[sos] : deleted for PV 816483 */
00755                else if (nondefault_sequence_type != NULL_IDX &&
00756                         !compare_derived_types(type_idx,
00757                          ATD_TYPE_IDX(EQ_ATTR_IDX(nondefault_sequence_type)))) {
00758                   PRINTMSG(EQ_LINE_NUM(nondefault_sequence_type), 1242, Error,
00759                            EQ_COLUMN_NUM(nondefault_sequence_type),
00760                            AT_OBJ_NAME_PTR(
00761                                   EQ_ATTR_IDX(nondefault_sequence_type)));
00762                }
00763 #endif
00764                else {
00765                   nondefault_sequence_type  = item;
00766                }
00767             }
00768          }
00769          else if (TYP_TYPE(type_idx) == Character) {
00770 
00771             if (default_numeric_sequence) {
00772                PRINTMSG(EQ_LINE_NUM(item), 1239, Error,
00773                         EQ_COLUMN_NUM(item),
00774                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00775             }
00776             else if (default_numeric_type) {
00777                PRINTMSG(EQ_LINE_NUM(item), 522, Ansi,
00778                         EQ_COLUMN_NUM(item));
00779                default_character_type   = TRUE;
00780             }
00781             else if (nondefault_sequence_type != NULL_IDX) {
00782                PRINTMSG(EQ_LINE_NUM(nondefault_sequence_type), 1242, Error,
00783                         EQ_COLUMN_NUM(nondefault_sequence_type),
00784                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(nondefault_sequence_type)));
00785             }
00786             else if (nondefault_intrinsic_type != NULL_IDX) {
00787 # if 0
00788                PRINTMSG(EQ_LINE_NUM(nondefault_intrinsic_type), 1241, Error,
00789                         EQ_COLUMN_NUM(nondefault_intrinsic_type),
00790                        AT_OBJ_NAME_PTR(EQ_ATTR_IDX(nondefault_intrinsic_type)));
00791 # endif
00792                PRINTMSG(EQ_LINE_NUM(nondefault_intrinsic_type), 522, Ansi,
00793                         EQ_COLUMN_NUM(nondefault_intrinsic_type));
00794                default_character_type = TRUE;
00795             }
00796             else {
00797                default_character_type = TRUE;
00798             }
00799          }
00800          else if (TYP_DESC(type_idx) == Default_Typed ||
00801                   TYP_LINEAR(type_idx) == INTEGER_DEFAULT_TYPE ||
00802                   TYP_LINEAR(type_idx) == LOGICAL_DEFAULT_TYPE ||
00803                   TYP_LINEAR(type_idx) == REAL_DEFAULT_TYPE ||
00804                   TYP_LINEAR(type_idx) == DOUBLE_DEFAULT_TYPE ||
00805                   TYP_LINEAR(type_idx) == COMPLEX_DEFAULT_TYPE) {
00806 
00807             if (default_character_sequence) {
00808                PRINTMSG(EQ_LINE_NUM(item), 1240, Error,
00809                         EQ_COLUMN_NUM(item),
00810                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00811             }
00812             else if (default_character_type) {
00813                PRINTMSG(EQ_LINE_NUM(item), 522, Ansi,
00814                         EQ_COLUMN_NUM(item));
00815                default_numeric_type             = TRUE;
00816             }
00817             else if (nondefault_sequence_type != NULL_IDX) {
00818                PRINTMSG(EQ_LINE_NUM(nondefault_sequence_type), 1242, Error,
00819                         EQ_COLUMN_NUM(nondefault_sequence_type),
00820                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(nondefault_sequence_type)));
00821             }
00822             else if (nondefault_intrinsic_type != NULL_IDX) {
00823 # if 0
00824                PRINTMSG(EQ_LINE_NUM(nondefault_intrinsic_type), 1241, Error,
00825                         EQ_COLUMN_NUM(nondefault_intrinsic_type),
00826                        AT_OBJ_NAME_PTR(EQ_ATTR_IDX(nondefault_intrinsic_type)));
00827 # endif
00828                PRINTMSG(EQ_LINE_NUM(nondefault_intrinsic_type), 1097, Ansi,
00829                         EQ_COLUMN_NUM(nondefault_intrinsic_type));
00830                default_numeric_type   = TRUE;
00831             }
00832             else {
00833                default_numeric_type   = TRUE;
00834             }
00835          }
00836          else {
00837 
00838             if (default_character_sequence) {
00839                PRINTMSG(EQ_LINE_NUM(item), 1240, Error,
00840                         EQ_COLUMN_NUM(item),
00841                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00842             }
00843             else if (default_character_type) {
00844                PRINTMSG(EQ_LINE_NUM(item), 522, Ansi, EQ_COLUMN_NUM(item));
00845                nondefault_intrinsic_type                = item;
00846             }
00847             else if (default_numeric_type) {
00848 # if 0
00849                PRINTMSG(EQ_LINE_NUM(item), 1239, Error,
00850                         EQ_COLUMN_NUM(item),
00851                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00852 # endif
00853                PRINTMSG(EQ_LINE_NUM(item), 1097, Ansi, EQ_COLUMN_NUM(item));
00854                nondefault_intrinsic_type    = item;
00855             }
00856             else if (default_numeric_sequence) {
00857                PRINTMSG(EQ_LINE_NUM(item), 1239, Error,
00858                         EQ_COLUMN_NUM(item),
00859                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(item)));
00860             }
00861 #if 0
00862 /* 28Feb01[sos] : deleted for PV 816483 */
00863             else if (nondefault_sequence_type != NULL_IDX) {
00864                PRINTMSG(EQ_LINE_NUM(nondefault_sequence_type), 1242, Error,
00865                         EQ_COLUMN_NUM(nondefault_sequence_type),
00866                         AT_OBJ_NAME_PTR(EQ_ATTR_IDX(nondefault_sequence_type)));
00867             }
00868 #endif
00869             else if (nondefault_intrinsic_type != NULL_IDX &&
00870                      TYP_LINEAR(ATD_TYPE_IDX(
00871                                 EQ_ATTR_IDX(nondefault_intrinsic_type))) !=
00872                      TYP_LINEAR(type_idx)) {
00873 # if 0
00874                PRINTMSG(EQ_LINE_NUM(nondefault_intrinsic_type), 1241, Error,
00875                         EQ_COLUMN_NUM(nondefault_intrinsic_type),
00876                        AT_OBJ_NAME_PTR(EQ_ATTR_IDX(nondefault_intrinsic_type)));
00877 # endif
00878                PRINTMSG(EQ_LINE_NUM(item), 1097, Ansi, EQ_COLUMN_NUM(item));
00879                nondefault_intrinsic_type    = item;
00880             }
00881             else {
00882                nondefault_intrinsic_type    = item;
00883             }
00884          }
00885          
00886          item = EQ_NEXT_EQUIV_OBJ(item);
00887       }
00888 
00889       group = EQ_NEXT_EQUIV_GRP(group);
00890    }
00891 
00892    TRACE (Func_Exit, "equivalence_semantics", NULL);
00893 
00894    return;
00895 
00896 }  /* equivalence_semantics */
00897 
00898 /******************************************************************************\
00899 |*                                                                            *|
00900 |* Description:                                                               *|
00901 |*      Linearize an EQUIVALENCE subscript/substring reference.               *|
00902 |*                                                                            *|
00903 |* Input parameters:                                                          *|
00904 |*      NONE                                                                  *|
00905 |*                                                                            *|
00906 |* Output parameters:                                                         *|
00907 |*      NONE                                                                  *|
00908 |*                                                                            *|
00909 |* Returns:                                                                   *|
00910 |*      NONE                                                                  *|
00911 |*                                                                            *|
00912 \******************************************************************************/
00913 static void     linearize_list_for_equiv(int  item)
00914 {
00915    int            attr_idx;
00916    int            bd_idx;
00917    size_offset_type bit_offset;
00918    int            dim;
00919    int            l_idx;
00920    int            list_idx;
00921    size_offset_type left;
00922    size_offset_type result;
00923    size_offset_type right;
00924    int            start_expr_idx;
00925 #ifdef KEY /* Bug 10177 */
00926    int            trail_l_idx = 0;
00927 #else /* KEY Bug 10177 */
00928    int            trail_l_idx;
00929 #endif /* KEY Bug 10177 */
00930 
00931 
00932    TRACE (Func_Entry, "linearize_list_for_equiv", NULL);
00933 
00934    attr_idx   = EQ_ATTR_IDX(item);
00935    list_idx   = EQ_LIST_IDX(item);
00936    bit_offset.fld = CN_Tbl_Idx;
00937    bit_offset.idx = CN_INTEGER_ZERO_IDX;
00938 
00939    if (list_idx != NULL_IDX) {
00940 
00941       if (!EQ_SUBSTRINGED(item)) {
00942 
00943          if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
00944             bd_idx  = ATD_ARRAY_IDX(attr_idx);
00945             dim   = 1;
00946             l_idx = list_idx;
00947 
00948             while (l_idx != NULL_IDX && IL_FLD(l_idx) != NO_Tbl_Idx) {
00949                right.fld  = BD_LB_FLD(bd_idx,dim);
00950                right.idx  = BD_LB_IDX(bd_idx,dim);
00951                left.fld   = IL_FLD(l_idx);
00952                left.idx   = IL_IDX(l_idx);
00953 
00954                if (!size_offset_binary_calc(&left, &right, Minus_Opr, &result)){
00955                   break;
00956                }
00957 
00958                left.fld   = BD_SM_FLD(bd_idx,dim);
00959                left.idx   = BD_SM_IDX(bd_idx,dim);
00960 
00961                if (!size_offset_binary_calc(&left, &result, Mult_Opr, &result)){
00962                   break;
00963                }
00964 
00965                if (!size_offset_binary_calc(&bit_offset,
00966                                             &result,
00967                                              Plus_Opr,
00968                                             &bit_offset)) {
00969                   break;
00970                }
00971 
00972                l_idx = IL_NEXT_LIST_IDX(l_idx);
00973                dim++;
00974             }
00975          }
00976       }
00977       else { /* it is substringed */
00978 
00979          if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
00980             l_idx = list_idx;
00981 
00982             while (l_idx != NULL_IDX && IL_FLD(l_idx) != NO_Tbl_Idx) {
00983                trail_l_idx  = l_idx;
00984                l_idx    = IL_NEXT_LIST_IDX(l_idx);
00985             }
00986 
00987             start_expr_idx  = IL_PREV_LIST_IDX(trail_l_idx); 
00988 
00989             left.fld    = IL_FLD(start_expr_idx);
00990             left.idx    = IL_IDX(start_expr_idx);
00991             right.fld   = CN_Tbl_Idx;
00992             right.idx   = CN_INTEGER_ONE_IDX;
00993 
00994             size_offset_binary_calc(&left, &right, Minus_Opr, &bit_offset);
00995 
00996             IL_FLD(start_expr_idx) = NO_Tbl_Idx;
00997 
00998             if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
00999 
01000                if (IL_FLD(list_idx) == NO_Tbl_Idx) {
01001                   AT_DCL_ERR(attr_idx)  = TRUE;
01002                   PRINTMSG(IL_LINE_NUM(list_idx), 250, Error,
01003                            IL_COL_NUM(list_idx));
01004                }
01005 
01006                bd_idx = ATD_ARRAY_IDX(attr_idx);
01007                dim  = 1;
01008                l_idx  = list_idx;
01009 
01010                while (l_idx != NULL_IDX && IL_FLD(l_idx) != NO_Tbl_Idx) {
01011 
01012                   left.fld  = IL_FLD(l_idx);
01013                   left.idx  = IL_IDX(l_idx);
01014                   right.fld = BD_LB_FLD(bd_idx, dim);
01015                   right.idx = BD_LB_IDX(bd_idx, dim);
01016 
01017                   if (!size_offset_binary_calc(&left, 
01018                                                &right,
01019                                                 Minus_Opr,
01020                                                &result)) {
01021                      break;
01022                   }
01023    
01024                   left.fld  = BD_SM_FLD(bd_idx, dim);
01025                   left.idx  = BD_SM_IDX(bd_idx, dim);
01026 
01027                   if (!size_offset_binary_calc(&left, 
01028                                                &result,
01029                                                 Mult_Opr,
01030                                                &result)) {
01031                      break;
01032                   }
01033    
01034                   if (!size_offset_binary_calc(&bit_offset,
01035                                                &result,
01036                                                 Plus_Opr,
01037                                                &bit_offset)) {
01038                      break;
01039                   }
01040    
01041                   l_idx = IL_NEXT_LIST_IDX(l_idx);
01042                   dim = dim + 1;
01043                }
01044             }
01045          }
01046       }  /* it is substringed */
01047    }
01048 
01049    if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
01050       result.fld  = CN_Tbl_Idx;
01051       result.idx  = CN_INTEGER_CHAR_BIT_IDX;
01052    }
01053    else {
01054       result.fld  = CN_Tbl_Idx;
01055       result.idx  = CN_INTEGER_BITS_PER_WORD_IDX;
01056 
01057 # if defined(_TARGET_OS_MAX) || defined(_WHIRL_HOST64_TARGET64)
01058 
01059       /* Complex_4 does not go here because it is aligned for 64 bits.     */
01060       /* The stride multiplier for one of these types is based on 32 bits  */
01061       /* not the standard 64 bits.  (MPP only)                             */
01062 
01063       if (PACK_HALF_WORD_TEST_CONDITION(ATD_TYPE_IDX(attr_idx))) {
01064          C_TO_F_INT(result.constant,
01065                     TARGET_BITS_PER_WORD / 2, 
01066                     CG_INTEGER_DEFAULT_TYPE);
01067          result.fld   = NO_Tbl_Idx;
01068          result.type_idx  = CG_INTEGER_DEFAULT_TYPE;
01069       }
01070 # endif
01071 
01072 # if defined(_INTEGER_1_AND_2)
01073 
01074       if (on_off_flags.integer_1_and_2) {
01075 
01076          if (PACK_8_BIT_TEST_CONDITION(ATD_TYPE_IDX(attr_idx))) {
01077             C_TO_F_INT(result.constant, 8, CG_INTEGER_DEFAULT_TYPE);
01078             result.fld    = NO_Tbl_Idx;
01079             result.type_idx = CG_INTEGER_DEFAULT_TYPE;
01080          }
01081          else if (PACK_16_BIT_TEST_CONDITION(ATD_TYPE_IDX(attr_idx))) {
01082             C_TO_F_INT(result.constant, 16, CG_INTEGER_DEFAULT_TYPE);
01083             result.fld    = NO_Tbl_Idx;
01084             result.type_idx = CG_INTEGER_DEFAULT_TYPE;
01085          }
01086       }
01087 
01088 # endif
01089    }
01090 
01091    size_offset_binary_calc(&bit_offset, &result, Mult_Opr, &bit_offset);
01092 
01093    if (bit_offset.fld == NO_Tbl_Idx) {
01094       IL_FLD(list_idx) = CN_Tbl_Idx;
01095       IL_IDX(list_idx) = ntr_const_tbl(bit_offset.type_idx,
01096                                        FALSE,
01097                                        bit_offset.constant);
01098    }
01099    else {
01100       IL_FLD(list_idx) = bit_offset.fld;
01101       IL_IDX(list_idx) = bit_offset.idx;
01102    }
01103 
01104    IL_LINE_NUM(list_idx) = 1;
01105    IL_COL_NUM(list_idx)  = 0;
01106 
01107    TRACE (Func_Exit, "linearize_list_for_equiv", NULL);
01108 
01109    return;
01110 
01111 }  /* linearize_list_for_equiv */
01112 
01113 
01114 /******************************************************************************\
01115 |*                                                                            *|
01116 |* Description:                                                               *|
01117 |*      This merge routine will search through two equivalence groups at a    *|
01118 |*      time.  If an identical object is found in both groups those two       *|
01119 |*      groups are merged into one equivalence group.   Identical means       *|
01120 |*      that we are looking at the same attr and the bit offset value is      *|
01121 |*      identical on these two objects.  Because we are merging only when     *|
01122 |*      the offsets on the two objects are identical there is no need to      *|
01123 |*      adjust offsets for the objects in the merged groups.                  *|
01124 |*                                                                            *|
01125 |* Input parameters:                                                          *|
01126 |*      NONE                                                                  *|
01127 |*                                                                            *|
01128 |* Output parameters:                                                         *|
01129 |*      NONE                                                                  *|
01130 |*                                                                            *|
01131 |* Returns:                                                                   *|
01132 |*      NONE                                                                  *|
01133 |*                                                                            *|
01134 \******************************************************************************/
01135 static void     merge_equivalence_groups1(void)
01136 {
01137 
01138    int           group;
01139    int           group_end;
01140    int           item;
01141    int           list_idx;
01142    int           list_item;
01143 #ifdef KEY /* Bug 10177 */
01144    int           prev_group = 0;
01145 #else /* KEY Bug 10177 */
01146    int           prev_group;
01147 #endif /* KEY Bug 10177 */
01148 
01149 
01150    TRACE (Func_Entry, "merge_equivalence_groups1", NULL);
01151 
01152    group = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
01153 
01154    while (group != NULL_IDX) {
01155 
01156       if (EQ_MERGED(group)) {
01157 
01158          /* This group has been merged with a previous   */
01159          /* group, so remove it from the group list.     */
01160          
01161          EQ_NEXT_EQUIV_GRP(prev_group) = EQ_NEXT_EQUIV_GRP(group);
01162       }
01163       else {
01164          group_end  = EQ_GRP_END_IDX(group);
01165          item   = group;
01166    
01167          while (item != NULL_IDX) {
01168 
01169             if (EQ_ERROR(item)) {
01170                item   = EQ_NEXT_EQUIV_OBJ(item);
01171                continue;
01172             }
01173 
01174             if (EQ_SEARCH_DONE(item)) {
01175 
01176                /* This item has been merged into this group because it */
01177                /* Matches another item in this group.  Do not search   */
01178                /* again.  It is a waste of time because we've already  */
01179                /* searched all occurences of this item.  We will not   */
01180                /* come across this eq item in this routine again,      */
01181                /* because we are doing only one pass through all       */
01182                /* groups and items, so turn off the flag so it can be  */
01183                /* used in the group2 merge later on.                   */
01184 
01185                EQ_SEARCH_DONE(item) = FALSE;
01186             }
01187             else if (ATD_CLASS(EQ_ATTR_IDX(item)) == Variable &&
01188                      ATD_EQUIV_LIST(EQ_ATTR_IDX(item)) != NULL_IDX) {
01189 
01190                /* This attr is in more than one equivalence group. */
01191 
01192                list_idx = ATD_EQUIV_LIST(EQ_ATTR_IDX(item));
01193 
01194                while (list_idx != NULL_IDX) {
01195                   list_item = AL_EQ_IDX(list_idx);
01196 
01197                   if (list_item != item && EQ_GRP_IDX(list_item) != group &&
01198                       (IL_IDX(EQ_LIST_IDX(list_item)) ==
01199                                 IL_IDX(EQ_LIST_IDX(item)))) {
01200 
01201                      /* Same attr with same offset.  Merge them.  Do not */
01202                      /* merge if this item is already in this group.     */
01203 
01204                      /* 1) Mark list item to prevent researching.        */
01205                      /* 2) Merge the new group to the end of the old.    */
01206                      /* 3) Mark the merged group as merged, so it can    */
01207                      /*    be removed from the group list.               */
01208                      /* 4) Set EQ_GRP_IDX for all members of new group.  */
01209 
01210                      EQ_SEARCH_DONE(list_item)    = TRUE;
01211                      EQ_NEXT_EQUIV_OBJ(group_end) = EQ_GRP_IDX(list_item);
01212                      EQ_MERGED(EQ_GRP_IDX(list_item)) = TRUE;
01213 
01214                      group_end  = EQ_GRP_END_IDX(EQ_GRP_IDX(list_item));
01215                      list_item  = EQ_GRP_IDX(list_item);  /* Group start */
01216 
01217                      while (list_item != NULL_IDX) {
01218                         EQ_GRP_IDX(list_item) = group;
01219                         list_item   = EQ_NEXT_EQUIV_OBJ(list_item);
01220                      }
01221                   }
01222                   list_idx  = AL_NEXT_IDX(list_idx);
01223                }
01224             }
01225             item    = EQ_NEXT_EQUIV_OBJ(item);
01226          }
01227          EQ_GRP_END_IDX(group)  = group_end;
01228          prev_group   = group;
01229       }
01230       group     = EQ_NEXT_EQUIV_GRP(group);
01231    }
01232 
01233    TRACE (Func_Exit, "merge_equivalence_groups1", NULL);
01234 
01235    return;
01236 
01237 }  /* merge_equivalence_groups1 */
01238 
01239 
01240 /******************************************************************************\
01241 |*                                                                            *|
01242 |* Description:                                                               *|
01243 |*      This merge routine is slightly different than             *|
01244 |*  merge_equivalence_groups1 in that two groups are merged if they       *|
01245 |*  contain an identical object regardless of the offset attached to      *|
01246 |*  that object.  At this point we know that the offsets attached to      *|
01247 |*  the objects are different so we will have to adjust all the offsets   *|
01248 |*  in one of the two groups by the difference in the offsets of the      *|
01249 |*  two identical objects.                              *|
01250 |*                                                                            *|
01251 |* Input parameters:                                                          *|
01252 |*      NONE                                                                  *|
01253 |*                                                                            *|
01254 |* Output parameters:                                                         *|
01255 |*      NONE                                                                  *|
01256 |*                                                                            *|
01257 |* Returns:                                                                   *|
01258 |*      NONE                                                                  *|
01259 |*                                                                            *|
01260 \******************************************************************************/
01261 static void     merge_equivalence_groups2(void)
01262 {
01263    boolean    adjust;
01264    size_offset_type adjust_by;
01265    int            group;
01266    int            group_end;
01267    int            item;
01268    size_offset_type left;
01269    int            list_idx;
01270    int            list_item;
01271 #ifdef KEY /* Bug 10177 */
01272    int            prev_group = 0;
01273 #else /* KEY Bug 10177 */
01274    int            prev_group;
01275 #endif /* KEY Bug 10177 */
01276    size_offset_type result;
01277    size_offset_type right;
01278 
01279 
01280    TRACE (Func_Entry, "merge_equivalence_groups2", NULL);
01281 
01282    group = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
01283 
01284    while (group != NULL_IDX) {
01285 
01286       if (EQ_MERGED(group)) {
01287 
01288          /* This group has been merged with a previous   */
01289          /* group, so remove it from the group list.     */
01290          
01291          EQ_NEXT_EQUIV_GRP(prev_group) = EQ_NEXT_EQUIV_GRP(group);
01292       }
01293       else {
01294          group_end  = EQ_GRP_END_IDX(group);
01295          item   = group;
01296    
01297          while (item != NULL_IDX) {
01298 
01299             if (EQ_ERROR(item)) {
01300                item   = EQ_NEXT_EQUIV_OBJ(item);
01301                continue;
01302             }
01303 
01304             if (ATD_CLASS(EQ_ATTR_IDX(item)) == Variable &&
01305                 ATD_EQUIV_LIST(EQ_ATTR_IDX(item)) != NULL_IDX) {
01306 
01307                /* This attr is in more than one equivalence group. */
01308 
01309                list_idx = ATD_EQUIV_LIST(EQ_ATTR_IDX(item));
01310 
01311                while (list_idx != NULL_IDX) {
01312                   list_item = AL_EQ_IDX(list_idx);
01313 
01314                   if (list_item != item && EQ_GRP_IDX(list_item) != group) {
01315 
01316                      /* Do not merge if item is already in this group.   */
01317 
01318                      /* 1) Merge the new group to the end of the old.    */
01319                      /* 2) Mark the merged group as merged, so it can    */
01320                      /*    be removed from the group list.               */
01321                      /* 3) Adjust the offsets for all groups if the      */
01322                      /*    offsets are different.                        */
01323 
01324                      if (EQ_OFFSET_IDX(list_item) != EQ_OFFSET_IDX(item) ||
01325                          EQ_OFFSET_FLD(list_item) != EQ_OFFSET_FLD(item)) {
01326                         left.fld  = EQ_OFFSET_FLD(list_item);
01327                         left.idx  = EQ_OFFSET_IDX(list_item);
01328                         right.fld = EQ_OFFSET_FLD(item);
01329                         right.idx = EQ_OFFSET_IDX(item);
01330 
01331                         if (!size_offset_binary_calc(&left,
01332                                                      &right,
01333                                                       Minus_Opr,
01334                                                      &adjust_by)) {
01335                            adjust = FALSE;
01336                            break;
01337                         }
01338                         adjust = TRUE;
01339                      }
01340                      else {
01341                         adjust = FALSE;
01342                      }
01343 
01344                      EQ_NEXT_EQUIV_OBJ(group_end) = EQ_GRP_IDX(list_item);
01345                      EQ_MERGED(EQ_GRP_IDX(list_item)) = TRUE;
01346 
01347                      group_end  = EQ_GRP_END_IDX(EQ_GRP_IDX(list_item));
01348                      list_item  = EQ_GRP_IDX(list_item);  /* Group start */
01349 
01350                      if (adjust) {
01351 
01352                         while (list_item != NULL_IDX) {
01353                            EQ_GRP_IDX(list_item)= group;
01354                            left.fld   = EQ_OFFSET_FLD(list_item);
01355                            left.idx   = EQ_OFFSET_IDX(list_item);
01356 
01357                            if (!size_offset_binary_calc(&left,
01358                                                         &adjust_by,
01359                                                          Minus_Opr,
01360                                                         &result)) {
01361                               break;
01362                            }
01363 
01364                            if (result.fld == NO_Tbl_Idx) {
01365                               EQ_OFFSET_FLD(list_item) = CN_Tbl_Idx;
01366                               EQ_OFFSET_IDX(list_item) = ntr_const_tbl(
01367                                                                result.type_idx,
01368                                                                FALSE,
01369                                                                result.constant);
01370                            }
01371                            else {
01372                               EQ_OFFSET_FLD(list_item) = result.fld;
01373                               EQ_OFFSET_IDX(list_item) = result.idx;
01374                            }
01375 
01376                            list_item    = EQ_NEXT_EQUIV_OBJ(list_item);
01377                         }
01378                      }
01379                      else {
01380                         while (list_item != NULL_IDX) {
01381                            EQ_GRP_IDX(list_item)  = group;
01382                            list_item    = EQ_NEXT_EQUIV_OBJ(list_item);
01383                         }
01384                      }
01385                   }
01386                   list_idx  = AL_NEXT_IDX(list_idx);
01387                }
01388             }
01389             item    = EQ_NEXT_EQUIV_OBJ(item);
01390          }
01391          EQ_GRP_END_IDX(group)  = group_end;
01392          prev_group   = group;
01393       }
01394       group     = EQ_NEXT_EQUIV_GRP(group);
01395    }
01396 
01397    TRACE (Func_Exit, "merge_equivalence_groups2", NULL);
01398 
01399    return;
01400 
01401 }  /* merge_equivalence_groups2 */
01402 
01403 /******************************************************************************\
01404 |*                                                                            *|
01405 |* Description:                                                               *|
01406 |*      Assign offsets to the items in equivalence groups.                    *|
01407 |*                                                                            *|
01408 |* Input parameters:                                                          *|
01409 |*      NONE                                                                  *|
01410 |*                                                                            *|
01411 |* Output parameters:                                                         *|
01412 |*      NONE                                                                  *|
01413 |*                                                                            *|
01414 |* Returns:                                                                   *|
01415 |*      NONE                                                                  *|
01416 |*                                                                            *|
01417 \******************************************************************************/
01418 static void     assign_offsets_for_equiv_groups(void)
01419 {
01420    int      group;
01421    int      item;
01422    size_offset_type largest_offset;
01423    size_offset_type result;
01424 
01425 
01426    TRACE (Func_Entry, "assign_offsets_for_equiv_groups", NULL);
01427 
01428    group = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
01429 
01430    while (group != NULL_IDX) {
01431 
01432       item     = group;
01433       largest_offset.idx = CN_INTEGER_ZERO_IDX;
01434       largest_offset.fld = CN_Tbl_Idx;
01435 
01436       while (item != NULL_IDX) {
01437 
01438          if (!EQ_ERROR(item) &&
01439              IL_IDX(EQ_LIST_IDX(item)) != CN_INTEGER_ZERO_IDX &&
01440              fold_relationals(IL_IDX(EQ_LIST_IDX(item)),
01441                               largest_offset.idx,
01442                               Ge_Opr)) {
01443             largest_offset.fld  = IL_FLD(EQ_LIST_IDX(item));
01444             largest_offset.idx  = IL_IDX(EQ_LIST_IDX(item));
01445          }
01446 
01447          item = EQ_NEXT_EQUIV_OBJ(item);
01448       }
01449 
01450       if (largest_offset.idx != CN_INTEGER_ZERO_IDX) {
01451 
01452          /* If the largest is zero - then they are all zero, */
01453          /* so we don't need to do the subtraction.          */
01454 
01455          item = group;
01456 
01457          while (item != NULL_IDX) {
01458 
01459             if (EQ_ERROR(item)) {
01460                item = EQ_NEXT_EQUIV_OBJ(item);
01461                continue;
01462             }
01463 
01464             /* largest_offset_idx - IL_IDX(EQ_LIST_IDX(item)) */
01465 
01466             if (fold_relationals(IL_IDX(EQ_LIST_IDX(item)),
01467                                  CN_INTEGER_ZERO_IDX,
01468                                  Eq_Opr)) {
01469                EQ_OFFSET_FLD(item)  = largest_offset.fld;
01470                EQ_OFFSET_IDX(item)  = largest_offset.idx;
01471             }
01472             else {
01473                result.fld   = IL_FLD(EQ_LIST_IDX(item));
01474                result.idx   = IL_IDX(EQ_LIST_IDX(item));
01475 
01476                if (size_offset_binary_calc(&largest_offset,
01477                                            &result,
01478                                             Minus_Opr,
01479                                            &result)) {
01480 
01481                   if (result.fld == NO_Tbl_Idx) {
01482                      EQ_OFFSET_FLD(item) = CN_Tbl_Idx;
01483                      EQ_OFFSET_IDX(item) = ntr_const_tbl(result.type_idx,
01484                                                          FALSE,
01485                                                          result.constant);
01486                   }
01487                   else {
01488                      EQ_OFFSET_FLD(item) = result.fld;
01489                      EQ_OFFSET_IDX(item) = result.idx;
01490                   }
01491                }
01492                else {
01493                    break;
01494                }
01495             }
01496             item = EQ_NEXT_EQUIV_OBJ(item);
01497          }
01498       }
01499 
01500       group = EQ_NEXT_EQUIV_GRP(group);
01501    }
01502 
01503 
01504    TRACE (Func_Exit, "assign_offsets_for_equiv_groups", NULL);
01505 
01506    return;
01507 
01508 }  /* assign_offsets_for_equiv_groups */
01509 
01510 /******************************************************************************\
01511 |*                        *|
01512 |* Description:                     *|
01513 |*  This routine resolves the lower and upper bounds to a constant or a   *|
01514 |*  temp.  Calculate the extent and stride multiplier for each dimension. *|
01515 |*                        *|
01516 |* Input parameters:                    *|
01517 |*      attr_idx -> Index to attribute for array.                             *|
01518 |*                        *|
01519 |* Output parameters:                   *|
01520 |*  NONE                      *|
01521 |*                        *|
01522 |* Returns:                     *|
01523 |*  NONE                      *|
01524 |*                        *|
01525 \******************************************************************************/
01526 void  array_dim_resolution(int  attr_idx,
01527            boolean  need_const_array)
01528 {
01529    bd_array_size_type array_size_type;
01530    int      at_idx;
01531    int      bd_idx;
01532    int      column;
01533    int      cvrt_idx;
01534    int      dim;
01535    int      entry_count;
01536    int      entry_list;
01537    expr_arg_type  expr_desc;
01538    int      extent_entry_idx  = NULL_IDX;
01539    fld_type   extent_fld;
01540    int      extent_idx;
01541    int      ir_idx;
01542    boolean    is_interface;
01543    int      len_ir_idx;
01544    int      length_idx;
01545    int      length_entry_idx  = NULL_IDX;
01546    int      line;
01547    int      mult_idx;
01548    int      new_bd_idx;
01549    int      next_ir_idx;
01550    opnd_type    opnd;
01551    int      sh_idx;
01552    int      stride_entry_idx  = NULL_IDX;
01553    int      stride_entry_count;
01554    size_offset_type stride;
01555 #ifdef KEY /* Bug 10177 */
01556    int      type = 0;
01557 #else /* KEY Bug 10177 */
01558    int      type;
01559 #endif /* KEY Bug 10177 */
01560 
01561 
01562    TRACE (Func_Entry, "array_dim_resolution", NULL);
01563 
01564    is_interface = SCP_IS_INTERFACE(curr_scp_idx);
01565    bd_idx = ATD_ARRAY_IDX(attr_idx);
01566 
01567    if (ATD_CLASS(attr_idx) == Function_Result) {
01568       entry_list  = ATP_NO_ENTRY_LIST(ATD_FUNC_IDX(attr_idx));
01569    }
01570    else {
01571       entry_list  = ATD_NO_ENTRY_LIST(attr_idx);
01572    }
01573 
01574    if (BD_ARRAY_CLASS(bd_idx) == Deferred_Shape) {
01575 
01576       /* This is called by PARAMETER processing.  This must be an explicit */
01577       /* shape constant size array.  PARAMETER processing will issue the   */
01578       /* error.  If this is needed elsewhere, it will come through again   */
01579       /* during decl_semantics.                                            */
01580 
01581       if (need_const_array) {
01582          goto EXIT;
01583       }
01584 
01585       if (ATD_CLASS(attr_idx) == Compiler_Tmp && ATD_IM_A_DOPE(attr_idx)) {
01586          goto EXIT;              /* everything is ok */
01587       }
01588 
01589       ATD_IM_A_DOPE(attr_idx) = TRUE;
01590 
01591 #ifdef KEY /* Bug 6845 */
01592       if (ATD_CLASS(attr_idx) == Dummy_Argument &&
01593         !(ATD_POINTER(attr_idx) || ATD_ALLOCATABLE(attr_idx)))
01594 #else /* KEY Bug 6845 */
01595       if (ATD_CLASS(attr_idx) == Dummy_Argument && !ATD_POINTER(attr_idx))
01596 #endif /* KEY Bug 6845 */
01597       {
01598 
01599          /* Don't convert intrinsic dargs to assumed shape */
01600 
01601          if (ATD_INTRIN_DARG(attr_idx)) {
01602             goto EXIT;
01603          }
01604 
01605          new_bd_idx     = reserve_array_ntry(BD_RANK(bd_idx));
01606          BD_RANK(new_bd_idx)    = BD_RANK(bd_idx);
01607          BD_DCL_ERR(new_bd_idx)   = BD_DCL_ERR(bd_idx);
01608          BD_ARRAY_CLASS(new_bd_idx) = Assumed_Shape;
01609          BD_ARRAY_SIZE(new_bd_idx)  = Constant_Size;
01610          BD_LINE_NUM(new_bd_idx)  = BD_LINE_NUM(bd_idx);
01611          BD_COLUMN_NUM(new_bd_idx)  = BD_COLUMN_NUM(bd_idx);
01612 
01613          for (dim = 1; dim <= BD_RANK(new_bd_idx); dim++) {
01614             BD_LB_FLD(new_bd_idx, dim)  = CN_Tbl_Idx;
01615             BD_LB_IDX(new_bd_idx, dim)  = CN_INTEGER_ONE_IDX;
01616          }
01617 
01618          bd_idx       = ntr_array_in_bd_tbl(new_bd_idx);
01619          BD_ARRAY_SIZE(bd_idx)    = Constant_Size;
01620          BD_RESOLVED(bd_idx)    = TRUE;
01621          ATD_ARRAY_IDX(attr_idx)  = bd_idx;
01622 
01623          if (ATD_IGNORE_TKR(attr_idx)) {
01624             AT_DCL_ERR(attr_idx)  = TRUE;
01625 #ifdef KEY /* Bug 5040 */
01626             PRINTMSG(AT_DEF_LINE(attr_idx), 1459, Error, 
01627                      AT_DEF_COLUMN(attr_idx),
01628                      AT_OBJ_NAME_PTR(attr_idx),
01629                      "IGNORE_TKR",
01630                      "assumed-shape DIMENSION",
01631          AT_DEF_LINE(attr_idx));
01632 #else /* KEY Bug 5040 */
01633             PRINTMSG(AT_DEF_LINE(attr_idx), 1459, Error, 
01634                      AT_DEF_COLUMN(attr_idx),
01635                      AT_OBJ_NAME_PTR(attr_idx),
01636                      "IGNORE_TKR",
01637                      "assumed-shape DIMENSION");
01638 #endif /* KEY Bug 5040 */
01639          }
01640 
01641 # if defined(_TARGET_OS_MAX)
01642          if (ATD_PE_ARRAY_IDX(attr_idx) != NULL_IDX) {
01643             AT_DCL_ERR(attr_idx)        = TRUE;
01644             PRINTMSG(BD_LINE_NUM(ATD_PE_ARRAY_IDX(attr_idx)), 1583, Error,
01645                      BD_COLUMN_NUM(ATD_PE_ARRAY_IDX(attr_idx)),
01646                      "co-array dimensions",
01647                      "assumed-shape arrays");
01648          }
01649 # endif
01650       }
01651       else if (!ATD_POINTER(attr_idx) && !ATD_ALLOCATABLE(attr_idx)) {
01652          AT_DCL_ERR(attr_idx)   = TRUE;
01653 
01654          if (ATD_CLASS(attr_idx) == Function_Result) {
01655             PRINTMSG(AT_DEF_LINE(attr_idx), 571, Error,
01656                      AT_DEF_COLUMN(attr_idx),
01657                      AT_OBJ_NAME_PTR(attr_idx));
01658          }
01659          else {
01660             PRINTMSG(AT_DEF_LINE(attr_idx), 353, Error,
01661                      AT_DEF_COLUMN(attr_idx),
01662                      AT_OBJ_NAME_PTR(attr_idx));
01663          }
01664       }
01665       else if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character &&
01666                TYP_CHAR_CLASS(ATD_TYPE_IDX(attr_idx)) == Var_Len_Char) {
01667          entry_list = merge_entry_lists(entry_list,
01668                            ATD_NO_ENTRY_LIST(TYP_IDX(ATD_TYPE_IDX(attr_idx))));
01669 
01670          if (entry_list != NULL_IDX &&
01671              (SCP_ALT_ENTRY_CNT(curr_scp_idx)+1) == AL_ENTRY_COUNT(entry_list)){
01672             PRINTMSG(AT_DEF_LINE(attr_idx), 662, Error,
01673                      AT_DEF_COLUMN(attr_idx), 
01674                      AT_OBJ_NAME_PTR(attr_idx));
01675             AT_DCL_ERR(attr_idx)  = TRUE;
01676          }
01677       }
01678       goto EXIT;
01679    }
01680 
01681    if (BD_ARRAY_CLASS(bd_idx) == Assumed_Shape) {
01682 
01683       /* This is called by PARAMETER processing.  This must be an explicit */
01684       /* shape constant size array.  PARAMETER processing will issue the   */
01685       /* error.  If this is needed elsewhere, it will come through again   */
01686       /* during decl_semantics.                                            */
01687 
01688       if (need_const_array) {
01689          goto EXIT;
01690       }
01691 
01692       /* These must always be dummy arguments, so they can never be automatic */
01693 
01694       ATD_IM_A_DOPE(attr_idx) = TRUE;
01695 
01696       if (!BD_RESOLVED(bd_idx)) {
01697          BD_RESOLVED(bd_idx)  = TRUE;
01698          array_size_type  = Constant_Size;
01699          length_entry_idx = NULL_IDX;
01700 
01701          for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
01702 
01703             if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01704                at_idx = BD_LB_IDX(bd_idx, dim);
01705 
01706                if (ATD_CLASS(at_idx) == Constant) {
01707                   BD_LB_FLD(bd_idx, dim)  = CN_Tbl_Idx;
01708                   BD_LB_IDX(bd_idx, dim)  = ATD_CONST_IDX(at_idx);
01709                }
01710                else if (ATD_SYMBOLIC_CONSTANT(at_idx)) {
01711                   array_size_type   = Symbolic_Constant_Size;
01712                }
01713                else {
01714                   length_entry_idx = merge_entry_lists(
01715                                       length_entry_idx,
01716                                       ATD_NO_ENTRY_LIST(BD_LB_IDX(bd_idx,dim)));
01717                   array_size_type  = Var_Len_Array;
01718                }
01719             }
01720          }
01721 
01722          BD_ARRAY_SIZE(bd_idx) = array_size_type;
01723 
01724          if (length_entry_idx != NULL_IDX) {
01725             entry_count = SCP_ALT_ENTRY_CNT(curr_scp_idx) + 1; 
01726 
01727             if (entry_count == AL_ENTRY_COUNT(length_entry_idx))  {
01728 
01729                /* Error if problem with lower and/or upper bounds coming in   */
01730                /* different entry points.  Bounds for this array declaration  */
01731                /* cannot be calculated at any entry point, because dummy args */
01732                /* used in the expression do not enter at all the same points. */
01733 
01734                PRINTMSG(AT_DEF_LINE(attr_idx), 660, Error,
01735                         AT_DEF_COLUMN(attr_idx), 
01736                         AT_OBJ_NAME_PTR(attr_idx));
01737                AT_DCL_ERR(attr_idx) = TRUE;
01738             }
01739             else {
01740 
01741                if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character &&
01742                    TYP_FLD(ATD_TYPE_IDX(attr_idx)) == AT_Tbl_Idx) {
01743 
01744                   length_entry_idx = merge_entry_lists(length_entry_idx,
01745                             ATD_NO_ENTRY_LIST(TYP_IDX(ATD_TYPE_IDX(attr_idx))));
01746 
01747                   if (entry_count == AL_ENTRY_COUNT(length_entry_idx))  {
01748 
01749                      /* Bounds for this array declaration cannot be calculated*/
01750                      /* at any entry point, because dummy arguments used in   */
01751                      /* the expression do not enter at all the same points.   */
01752 
01753                      PRINTMSG(AT_DEF_LINE(attr_idx), 661, Error,
01754                               AT_DEF_COLUMN(attr_idx), 
01755                               AT_OBJ_NAME_PTR(attr_idx));
01756                      AT_DCL_ERR(attr_idx) = TRUE;
01757                   }
01758                }
01759 
01760                if (!AT_DCL_ERR(attr_idx) && entry_list != NULL_IDX) {
01761                   length_entry_idx = merge_entry_lists(length_entry_idx,
01762                                                        entry_list);
01763 
01764                   if (length_entry_idx != NULL_IDX &&
01765                       entry_count == AL_ENTRY_COUNT(length_entry_idx))  {
01766 
01767                      /* This array and its bounds variables do not enter at   */
01768                      /* the same entry point.                                 */
01769 
01770                      PRINTMSG(AT_DEF_LINE(attr_idx), 662, Error,
01771                               AT_DEF_COLUMN(attr_idx), 
01772                               AT_OBJ_NAME_PTR(attr_idx));
01773                      AT_DCL_ERR(attr_idx) = TRUE;
01774                   }
01775                }
01776             }
01777          }
01778       }
01779              
01780       if (ATD_CLASS(attr_idx) != Dummy_Argument || ATD_POINTER(attr_idx)) {
01781          AT_DCL_ERR(attr_idx) = TRUE;
01782          PRINTMSG(AT_DEF_LINE(attr_idx), 351, Error,
01783                   AT_DEF_COLUMN(attr_idx),
01784                   AT_OBJ_NAME_PTR(attr_idx));
01785       }
01786 
01787       goto EXIT;
01788    }
01789 
01790    /* If this array bounds entry has already been resolved, skip the section  */
01791    /* that calculates the extent, length, and stride multiplier.              */
01792    /* The only array entries that are shared are of the same type.  Each attr */
01793    /* will have to calculate it's own automatic stuff.                        */
01794 
01795    if (BD_RESOLVED(bd_idx)) {
01796       goto NEXT;
01797    }
01798 
01799    array_size_type  = Constant_Size;
01800 
01801    for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
01802 
01803       if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01804 
01805          if (ATD_CLASS(BD_LB_IDX(bd_idx, dim)) == Constant) { 
01806             BD_LB_FLD(bd_idx, dim)  = CN_Tbl_Idx;
01807             BD_LB_IDX(bd_idx, dim)  = ATD_CONST_IDX(BD_LB_IDX(bd_idx, dim));
01808          }
01809          else if (ATD_SYMBOLIC_CONSTANT(BD_LB_IDX(bd_idx, dim))) {
01810             array_size_type = Symbolic_Constant_Size;
01811          }
01812          else {
01813             array_size_type = Var_Len_Array;
01814             OPND_FLD(opnd)  = BD_LB_FLD(bd_idx, dim);
01815             OPND_IDX(opnd)  = BD_LB_IDX(bd_idx, dim);
01816             OPND_LINE_NUM(opnd) = BD_LINE_NUM(bd_idx);
01817             OPND_COL_NUM(opnd)  = BD_COLUMN_NUM(bd_idx);
01818          }
01819       }
01820    
01821       if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01822 
01823          if (ATD_CLASS(BD_UB_IDX(bd_idx, dim)) == Constant) {
01824             BD_UB_FLD(bd_idx, dim)  = CN_Tbl_Idx;
01825             BD_UB_IDX(bd_idx, dim)  = ATD_CONST_IDX(BD_UB_IDX(bd_idx, dim));
01826          }
01827          else if (ATD_SYMBOLIC_CONSTANT(BD_UB_IDX(bd_idx, dim))) {
01828 
01829             if (array_size_type != Var_Len_Array) {
01830                array_size_type  = Symbolic_Constant_Size;
01831             }
01832          }
01833          else {
01834             array_size_type = Var_Len_Array;
01835             OPND_FLD(opnd)  = BD_UB_FLD(bd_idx, dim);
01836             OPND_IDX(opnd)  = BD_UB_IDX(bd_idx, dim);
01837             OPND_LINE_NUM(opnd) = BD_LINE_NUM(bd_idx);
01838             OPND_COL_NUM(opnd)  = BD_COLUMN_NUM(bd_idx);
01839          }
01840       }
01841    }
01842 
01843    if (BD_ARRAY_CLASS(bd_idx) == Assumed_Size) {
01844 
01845       /* This is called by PARAMETER processing.  This must be an explicit */
01846       /* shape constant size array.  PARAMETER processing will issue the   */
01847       /* error.  If this is needed elsewhere, it will come through again   */
01848       /* during decl_semantics.                                            */
01849 
01850       if (need_const_array) {
01851          goto EXIT;
01852       }
01853 
01854       BD_ARRAY_SIZE(bd_idx) = array_size_type;
01855    }
01856    else { 
01857       BD_ARRAY_SIZE(bd_idx) = array_size_type;
01858 
01859       if (array_size_type == Var_Len_Array) {
01860 
01861          BD_ARRAY_SIZE(bd_idx)  = Var_Len_Array;
01862 
01863          /* This is called by PARAMETER processing.  This must be an explicit */
01864          /* shape constant size array.  PARAMETER processing will issue the   */
01865          /* error.  If this is needed elsewhere, it will come through again   */
01866          /* during decl_semantics.                                            */
01867 
01868          if (need_const_array) {
01869             goto EXIT;
01870          }
01871 
01872          if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Function &&
01873              ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Subroutine) {
01874             PRINTMSG(AT_DEF_LINE(attr_idx), 131, Error,
01875                      AT_DEF_COLUMN(attr_idx), 
01876                      AT_OBJ_NAME_PTR(attr_idx));
01877             BD_DCL_ERR(bd_idx) = TRUE;
01878          }
01879       }
01880    }
01881 
01882    BD_RESOLVED(bd_idx)  = TRUE;
01883 
01884    set_stride_for_first_dim(ATD_TYPE_IDX(attr_idx), &stride);
01885 
01886    if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character &&
01887       stride.fld == AT_Tbl_Idx && 
01888       ATD_NO_ENTRY_LIST(stride.idx) != NULL_IDX) {
01889       stride_entry_idx  = merge_entry_lists(NULL_IDX,
01890                                             ATD_NO_ENTRY_LIST(stride.idx));
01891    }
01892    else {
01893       stride_entry_idx  = NULL_IDX;
01894    }
01895 
01896    NTR_IR_TBL(len_ir_idx);
01897    IR_TYPE_IDX(len_ir_idx) = SA_INTEGER_DEFAULT_TYPE;
01898 
01899    BD_LEN_IDX(bd_idx) = len_ir_idx;   /* Save this so it can be folded */
01900    BD_LEN_FLD(bd_idx) = IR_Tbl_Idx;
01901    length_entry_idx = NULL_IDX;
01902    line     = BD_LINE_NUM(bd_idx);
01903    column   = BD_COLUMN_NUM(bd_idx);
01904 
01905    for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
01906       BD_SM_FLD(bd_idx, dim)  = stride.fld;
01907       BD_SM_IDX(bd_idx, dim)  = stride.idx;
01908 
01909       if (extent_entry_idx != NULL_IDX) {
01910          free_attr_list(extent_entry_idx);
01911          extent_entry_idx = NULL_IDX;
01912       }
01913 
01914       if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01915          at_idx = BD_LB_IDX(bd_idx, dim);
01916 
01917          if (ATD_NO_ENTRY_LIST(at_idx) != NULL_IDX) {
01918             extent_entry_idx = merge_entry_lists(NULL_IDX, 
01919                                                  ATD_NO_ENTRY_LIST(at_idx));
01920          }
01921       }
01922    
01923       if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
01924          at_idx = BD_UB_IDX(bd_idx, dim);
01925 
01926          if (ATD_NO_ENTRY_LIST(at_idx) != NULL_IDX) {
01927             extent_entry_idx = merge_entry_lists(extent_entry_idx, 
01928                                                  ATD_NO_ENTRY_LIST(at_idx));
01929          }
01930       }
01931 
01932       if (BD_LB_FLD(bd_idx, dim) == CN_Tbl_Idx &&
01933           fold_relationals(BD_LB_IDX(bd_idx, dim),
01934                            CN_INTEGER_ONE_IDX,
01935                            Eq_Opr)) {
01936 
01937          /* If the lb is a one, just use the ub for the extent */
01938 
01939          extent_fld = BD_UB_FLD(bd_idx, dim);
01940          extent_idx = BD_UB_IDX(bd_idx, dim);
01941       }
01942       else {
01943          NTR_IR_TBL(ir_idx);      /* Create 1 - lower */
01944          IR_OPR(ir_idx)       = Minus_Opr;
01945          IR_TYPE_IDX(ir_idx)      = SA_INTEGER_DEFAULT_TYPE;
01946          IR_FLD_L(ir_idx)     = CN_Tbl_Idx;
01947          IR_IDX_L(ir_idx)     = CN_INTEGER_ONE_IDX;
01948          IR_LINE_NUM_L(ir_idx)      = line;
01949          IR_COL_NUM_L(ir_idx)     = column;
01950          IR_FLD_R(ir_idx)     = BD_LB_FLD(bd_idx, dim);
01951          IR_IDX_R(ir_idx)     = BD_LB_IDX(bd_idx, dim);
01952          IR_LINE_NUM_R(ir_idx)      = line;
01953          IR_COL_NUM_R(ir_idx)     = column;
01954          IR_LINE_NUM(ir_idx)      = line;
01955          IR_COL_NUM(ir_idx)     = column;
01956 
01957          NTR_IR_TBL(next_ir_idx);   /* Upper + (1 - lower) */
01958          IR_OPR(next_ir_idx)      = Plus_Opr;
01959          IR_TYPE_IDX(next_ir_idx)   = SA_INTEGER_DEFAULT_TYPE;
01960          IR_IDX_L(next_ir_idx)      = BD_UB_IDX(bd_idx, dim);
01961          IR_FLD_L(next_ir_idx)      = BD_UB_FLD(bd_idx, dim);
01962          IR_LINE_NUM_L(next_ir_idx)   = line;
01963          IR_COL_NUM_L(next_ir_idx)    = column;
01964          IR_FLD_R(next_ir_idx)      = IR_Tbl_Idx;
01965          IR_IDX_R(next_ir_idx)      = ir_idx;
01966          IR_LINE_NUM_R(next_ir_idx)   = line;
01967          IR_COL_NUM_R(next_ir_idx)    = column;
01968          IR_LINE_NUM(next_ir_idx)   = line;
01969          IR_COL_NUM(next_ir_idx)    = column;
01970 
01971          if (BD_ARRAY_SIZE(bd_idx) == Symbolic_Constant_Size) {
01972             IR_OPR(next_ir_idx) = Symbolic_Plus_Opr;
01973             IR_OPR(ir_idx)  = Symbolic_Minus_Opr;
01974             extent_idx    = gen_compiler_tmp(line, column, Priv, TRUE);
01975             extent_fld    = AT_Tbl_Idx;
01976 
01977             ATD_SYMBOLIC_CONSTANT(extent_idx) = TRUE;
01978             ATD_TYPE_IDX(extent_idx)    = SA_INTEGER_DEFAULT_TYPE;
01979             ATD_FLD(extent_idx)     = IR_Tbl_Idx;
01980             ATD_TMP_IDX(extent_idx)   = next_ir_idx;
01981 
01982 
01983             /* KAY - Some of this may be folded if they are both not */
01984             /*       symbolic constants.                             */
01985          }
01986          else {
01987 
01988             OPND_FLD(opnd)      = IR_Tbl_Idx;
01989             OPND_IDX(opnd)      = next_ir_idx;
01990             OPND_LINE_NUM(opnd)     = stmt_start_line;
01991             OPND_COL_NUM(opnd)      = stmt_start_col;
01992 
01993             sh_idx        = ntr_sh_tbl();
01994             SH_GLB_LINE(sh_idx)     = stmt_start_line;
01995             SH_COL_NUM(sh_idx)      = stmt_start_col;
01996             SH_STMT_TYPE(sh_idx)    = Automatic_Base_Size_Stmt;
01997             SH_COMPILER_GEN(sh_idx)   = TRUE;
01998             SH_P2_SKIP_ME(sh_idx)   = TRUE;
01999 
02000             expr_desc.rank = 0;
02001             xref_state     = CIF_No_Usage_Rec;
02002 
02003             /* This is in terms of tmps - so it will never   */
02004             /* generate more than one statement.             */
02005 
02006             issue_overflow_msg_719 = FALSE;
02007 
02008             if (!expr_semantics(&opnd, &expr_desc)) {
02009 
02010                if (need_to_issue_719) {
02011                       
02012                   need_to_issue_719 = FALSE;
02013                   PRINTMSG(AT_DEF_LINE(attr_idx), 951, Error,
02014                            AT_DEF_COLUMN(attr_idx), 
02015                            dim,
02016                            AT_OBJ_NAME_PTR(attr_idx));
02017                }
02018                AT_DCL_ERR(attr_idx) = TRUE;
02019             }
02020 
02021             if (OPND_FLD(opnd) == CN_Tbl_Idx) {
02022                extent_fld = CN_Tbl_Idx;
02023                extent_idx = OPND_IDX(opnd);
02024                FREE_SH_NODE(sh_idx);
02025             }
02026             else {
02027                extent_fld = AT_Tbl_Idx;
02028                extent_idx = ntr_bnds_sh_tmp_list(&opnd,
02029                                                  extent_entry_idx,
02030                                                  is_interface ? NULL_IDX:sh_idx,
02031                                                  FALSE,
02032                                                  SA_INTEGER_DEFAULT_TYPE);
02033             }
02034          }
02035       }
02036 
02037       if (extent_fld == CN_Tbl_Idx) {
02038 
02039          if (compare_cn_and_value(extent_idx, 0, Lt_Opr)) {
02040             extent_idx = CN_INTEGER_ZERO_IDX;
02041          }
02042       }
02043       else {  /* Generate  tmp = max(0, extent) */
02044 
02045          OPND_FLD(opnd)   = extent_fld;
02046          OPND_IDX(opnd)   = extent_idx;
02047          OPND_LINE_NUM(opnd)  = line;
02048          OPND_COL_NUM(opnd) = column;
02049 
02050          gen_tmp_equal_max_zero(&opnd, 
02051                                 SA_INTEGER_DEFAULT_TYPE,
02052                                 extent_entry_idx,
02053                                 (BD_ARRAY_SIZE(bd_idx)==Symbolic_Constant_Size),
02054                                 is_interface);
02055          extent_fld   = OPND_FLD(opnd);
02056          extent_idx   = OPND_IDX(opnd);
02057       }
02058 
02059       BD_XT_FLD(bd_idx, dim)  = extent_fld;
02060       BD_XT_IDX(bd_idx, dim)  = extent_idx;
02061 
02062       /* STRIDE = STRIDE * (EXTENT of previous dimension) */
02063       /* Fix stride for next dimension.                   */
02064       /* Calculate length.                                */
02065 
02066       if (dim < BD_RANK(bd_idx)) {
02067          NTR_IR_TBL(ir_idx);    /* Create Stride * Extent */
02068          IR_OPR(ir_idx)     = Mult_Opr;
02069          IR_TYPE_IDX(ir_idx)    = SA_INTEGER_DEFAULT_TYPE;
02070          IR_LINE_NUM(ir_idx)    = BD_LINE_NUM(bd_idx);
02071          IR_COL_NUM(ir_idx)   = BD_COLUMN_NUM(bd_idx);
02072          IR_FLD_L(ir_idx)   = stride.fld;
02073          IR_IDX_L(ir_idx)   = stride.idx;
02074          IR_LINE_NUM_L(ir_idx)    = BD_LINE_NUM(bd_idx);
02075          IR_COL_NUM_L(ir_idx)   = BD_COLUMN_NUM(bd_idx);
02076          IR_FLD_R(ir_idx)   = extent_fld;
02077          IR_IDX_R(ir_idx)   = extent_idx;
02078          IR_LINE_NUM_R(ir_idx)    = BD_LINE_NUM(bd_idx);
02079          IR_COL_NUM_R(ir_idx)   = BD_COLUMN_NUM(bd_idx);
02080 
02081          if (BD_ARRAY_SIZE(bd_idx) == Symbolic_Constant_Size) {
02082             IR_OPR(ir_idx)  = Symbolic_Mult_Opr;
02083             stride.fld    = AT_Tbl_Idx;
02084             stride.idx    = gen_compiler_tmp(line, column, Priv, TRUE);
02085 
02086             ATD_TYPE_IDX(stride.idx)    = SA_INTEGER_DEFAULT_TYPE;
02087             ATD_FLD(stride.idx)     = IR_Tbl_Idx;
02088             ATD_TMP_IDX(stride.idx)   = ir_idx;
02089             ATD_SYMBOLIC_CONSTANT(stride.idx) = TRUE;
02090          }
02091          else {
02092             OPND_FLD(opnd)    = IR_Tbl_Idx;
02093             OPND_IDX(opnd)    = ir_idx;
02094             OPND_LINE_NUM(opnd)   = stmt_start_line;
02095             OPND_COL_NUM(opnd)    = stmt_start_col;
02096 
02097             sh_idx      = ntr_sh_tbl();
02098             SH_STMT_TYPE(sh_idx)  = Automatic_Base_Size_Stmt;
02099             SH_COMPILER_GEN(sh_idx) = TRUE;
02100             SH_P2_SKIP_ME(sh_idx) = TRUE;
02101             SH_GLB_LINE(sh_idx)   = stmt_start_line;
02102             SH_COL_NUM(sh_idx)    = stmt_start_col;
02103 
02104             expr_desc.rank    = 0;
02105             xref_state        = CIF_No_Usage_Rec;
02106 
02107             expr_semantics(&opnd, &expr_desc);
02108 
02109             if (OPND_FLD(opnd) == CN_Tbl_Idx) {
02110                stride.fld   = CN_Tbl_Idx;
02111                stride.idx   = OPND_IDX(opnd);
02112                FREE_SH_NODE(sh_idx);
02113             }
02114             else {
02115 
02116                if (!is_interface) {
02117 
02118                   /* Stride must be non-constant, if extent is non-constant */
02119 
02120                   if (extent_entry_idx != NULL_IDX) {
02121                      stride_entry_idx = merge_entry_lists(stride_entry_idx, 
02122                                                           extent_entry_idx);
02123                      length_entry_idx = merge_entry_lists(length_entry_idx, 
02124                                                           extent_entry_idx);
02125                   }
02126                }
02127 
02128                stride.fld = AT_Tbl_Idx;
02129                stride.idx = ntr_bnds_sh_tmp_list(&opnd,
02130                                               stride_entry_idx,
02131                                               (is_interface) ? NULL_IDX: sh_idx,
02132                                               FALSE,
02133                                               SA_INTEGER_DEFAULT_TYPE);
02134             }
02135          }
02136 
02137          NTR_IR_TBL(mult_idx);   /* Create length = extent * extent */
02138          IR_LINE_NUM(mult_idx)    = BD_LINE_NUM(bd_idx);
02139          IR_COL_NUM(mult_idx)   = BD_COLUMN_NUM(bd_idx);
02140 
02141          if (BD_ARRAY_SIZE(bd_idx) == Symbolic_Constant_Size) {
02142             IR_OPR(mult_idx)    = Symbolic_Mult_Opr;
02143          }
02144          else {
02145             IR_OPR(mult_idx)    = Mult_Opr;
02146          }
02147 
02148          IR_TYPE_IDX(mult_idx)          = SA_INTEGER_DEFAULT_TYPE;
02149          IR_IDX_R(len_ir_idx)   = mult_idx;
02150          IR_FLD_R(len_ir_idx)   = IR_Tbl_Idx;
02151          IR_LINE_NUM_R(len_ir_idx)  = BD_LINE_NUM(bd_idx);
02152          IR_COL_NUM_R(len_ir_idx) = BD_COLUMN_NUM(bd_idx);
02153          IR_IDX_L(mult_idx)   = extent_idx;
02154          IR_FLD_L(mult_idx)   = extent_fld;
02155          IR_LINE_NUM_L(mult_idx)  = BD_LINE_NUM(bd_idx);
02156          IR_COL_NUM_L(mult_idx)   = BD_COLUMN_NUM(bd_idx);
02157          len_ir_idx     = mult_idx;
02158       }
02159       else if (dim == 1) {
02160 
02161          /* Last dimension is the only dimension, so length = xtent */
02162 
02163          BD_LEN_FLD(bd_idx) = extent_fld;
02164          BD_LEN_IDX(bd_idx) = extent_idx;
02165          length_entry_idx = extent_entry_idx;
02166          stride_entry_idx = merge_entry_lists(stride_entry_idx,
02167                                                     extent_entry_idx);
02168          extent_entry_idx = NULL_IDX;  /* List now pointed by length.. */
02169 
02170          if (length_entry_idx != NULL_IDX) {  /* Alt entries - need tmp = 0 */
02171             gen_tmp_eq_zero_ir(extent_idx);
02172          }
02173       }
02174 
02175       /* Last dimension */
02176 
02177       else if (BD_ARRAY_SIZE(bd_idx) == Symbolic_Constant_Size) {
02178          IR_IDX_R(len_ir_idx)   = extent_idx;
02179          IR_FLD_R(len_ir_idx)   = extent_fld;
02180          IR_LINE_NUM_R(len_ir_idx)  = BD_LINE_NUM(bd_idx);
02181          IR_COL_NUM_R(len_ir_idx) = BD_COLUMN_NUM(bd_idx);
02182          OPND_FLD(opnd)     = IR_FLD_R(BD_LEN_IDX(bd_idx));
02183          OPND_IDX(opnd)     = IR_IDX_R(BD_LEN_IDX(bd_idx));
02184 
02185          BD_LEN_FLD(bd_idx) = AT_Tbl_Idx;
02186          BD_LEN_IDX(bd_idx) = gen_compiler_tmp(line, column, Priv, TRUE);
02187 
02188          ATD_TYPE_IDX(BD_LEN_IDX(bd_idx)) = SA_INTEGER_DEFAULT_TYPE;
02189          ATD_FLD(BD_LEN_IDX(bd_idx))    = OPND_FLD(opnd);
02190          ATD_TMP_IDX(BD_LEN_IDX(bd_idx))  = OPND_IDX(opnd);
02191 
02192          ATD_SYMBOLIC_CONSTANT(BD_LEN_IDX(bd_idx))  = TRUE;
02193       }
02194       else {
02195          IR_IDX_R(len_ir_idx)   = extent_idx;
02196          IR_FLD_R(len_ir_idx)   = extent_fld;
02197          IR_LINE_NUM_R(len_ir_idx)  = BD_LINE_NUM(bd_idx);
02198          IR_COL_NUM_R(len_ir_idx) = BD_COLUMN_NUM(bd_idx);
02199          OPND_FLD(opnd)     = IR_FLD_R(BD_LEN_IDX(bd_idx));
02200          OPND_IDX(opnd)     = IR_IDX_R(BD_LEN_IDX(bd_idx));
02201          OPND_LINE_NUM(opnd)            = BD_LINE_NUM(bd_idx);
02202          OPND_COL_NUM(opnd)             = BD_COLUMN_NUM(bd_idx);
02203 
02204          sh_idx       = ntr_sh_tbl();
02205          SH_STMT_TYPE(sh_idx)   = Automatic_Base_Size_Stmt;
02206          SH_COMPILER_GEN(sh_idx)  = TRUE;
02207          SH_P2_SKIP_ME(sh_idx)    = TRUE;
02208          SH_GLB_LINE(sh_idx)    = stmt_start_line;
02209          SH_COL_NUM(sh_idx)   = stmt_start_col;
02210 
02211          /* expr_semantics needs curr_stmt_sh_idx set to something valid.  */
02212          /* It does not need SH_IR_IDX(curr_stmt_sh_idx) set to something. */
02213 
02214          expr_desc.rank = 0;
02215          xref_state     = CIF_No_Usage_Rec;
02216 
02217 # if defined(_CHECK_MAX_MEMORY)
02218 
02219          if (!target_t3e) {
02220             issue_overflow_msg_719 = FALSE;
02221          }
02222 # endif
02223 
02224          if (!expr_semantics(&opnd, &expr_desc)) {
02225 
02226             if (need_to_issue_719) {
02227 
02228                /* We have overflowed - Reattempt with a bigger int type */
02229 
02230                if (OPND_FLD(opnd) == IR_Tbl_Idx) {
02231                   IR_TYPE_IDX(OPND_IDX(opnd)) = SA_INTEGER_DEFAULT_TYPE;
02232 
02233                   switch (IR_FLD_L(OPND_IDX(opnd))) {
02234                   case AT_Tbl_Idx:
02235                      type = TYP_LINEAR(ATD_TYPE_IDX(IR_IDX_L(OPND_IDX(opnd))));
02236                      break;
02237 
02238                   case IR_Tbl_Idx:
02239                      type = TYP_LINEAR(IR_TYPE_IDX(IR_IDX_L(OPND_IDX(opnd))));
02240                      break;
02241 
02242                   case CN_Tbl_Idx:
02243                      type = TYP_LINEAR(CN_TYPE_IDX(IR_IDX_L(OPND_IDX(opnd))));
02244                      break;
02245                   }
02246 
02247                   if (type < SA_INTEGER_DEFAULT_TYPE) {
02248                      NTR_IR_TBL(cvrt_idx);
02249                      IR_OPR(cvrt_idx)            = Cvrt_Opr;
02250                      IR_TYPE_IDX(cvrt_idx)       = SA_INTEGER_DEFAULT_TYPE;
02251                      IR_LINE_NUM(cvrt_idx)       = BD_LINE_NUM(bd_idx);
02252                      IR_COL_NUM(cvrt_idx)        = BD_COLUMN_NUM(bd_idx);
02253                      COPY_OPND(IR_OPND_L(cvrt_idx), IR_OPND_L(OPND_IDX(opnd)));
02254                      IR_FLD_L(OPND_IDX(opnd))    = IR_Tbl_Idx;
02255                      IR_IDX_L(OPND_IDX(opnd))    = cvrt_idx;
02256                   }
02257 
02258                   switch (IR_FLD_R(OPND_IDX(opnd))) {
02259                   case AT_Tbl_Idx:
02260                      type = TYP_LINEAR(ATD_TYPE_IDX(IR_IDX_R(OPND_IDX(opnd))));
02261                      break;
02262 
02263                   case IR_Tbl_Idx:
02264                      type = TYP_LINEAR(IR_TYPE_IDX(IR_IDX_R(OPND_IDX(opnd))));
02265                      break;
02266 
02267                   case CN_Tbl_Idx:
02268                      type = TYP_LINEAR(CN_TYPE_IDX(IR_IDX_R(OPND_IDX(opnd))));
02269                      break;
02270                   }
02271 
02272                   if (type < SA_INTEGER_DEFAULT_TYPE) {
02273                      NTR_IR_TBL(cvrt_idx);
02274                      IR_OPR(cvrt_idx)            = Cvrt_Opr;
02275                      IR_TYPE_IDX(cvrt_idx)       = SA_INTEGER_DEFAULT_TYPE;
02276                      IR_LINE_NUM(cvrt_idx)       = BD_LINE_NUM(bd_idx);
02277                      IR_COL_NUM(cvrt_idx)        = BD_COLUMN_NUM(bd_idx);
02278                      COPY_OPND(IR_OPND_L(cvrt_idx), IR_OPND_R(OPND_IDX(opnd)));
02279                      IR_FLD_R(OPND_IDX(opnd))    = IR_Tbl_Idx;
02280                      IR_IDX_R(OPND_IDX(opnd))    = cvrt_idx;
02281                   }
02282                   need_to_issue_719 = FALSE;
02283                }
02284 
02285                if (!expr_semantics(&opnd, &expr_desc)) {
02286 
02287                   if (!target_t3e) {
02288                      AT_DCL_ERR(attr_idx) = TRUE;
02289                   }
02290                }
02291             }
02292             else if (!target_t3e) {
02293                AT_DCL_ERR(attr_idx) = TRUE;
02294             }
02295 
02296             if (need_to_issue_719) {
02297                need_to_issue_719  = FALSE;
02298                AT_DCL_ERR(attr_idx) = TRUE;
02299                ISSUE_STORAGE_SIZE_EXCEEDED_MSG(attr_idx, Error);
02300             }
02301          }
02302 
02303          if (OPND_FLD(opnd) == CN_Tbl_Idx) {
02304             BD_LEN_FLD(bd_idx)  = CN_Tbl_Idx;
02305             BD_LEN_IDX(bd_idx)  = OPND_IDX(opnd);
02306             FREE_SH_NODE(sh_idx);
02307          }
02308          else {
02309 
02310             if (!is_interface) {
02311 
02312                if (extent_entry_idx != NULL_IDX) {
02313                   stride_entry_idx = merge_entry_lists(stride_entry_idx, 
02314                                                        extent_entry_idx);
02315                   length_entry_idx = merge_entry_lists(length_entry_idx, 
02316                                                        extent_entry_idx);
02317                }
02318             }
02319 
02320             length_idx = ntr_bnds_sh_tmp_list(&opnd,
02321                                               length_entry_idx,
02322                                               (is_interface) ? NULL_IDX:sh_idx,
02323                                               TRUE,
02324                                               SA_INTEGER_DEFAULT_TYPE);
02325             BD_LEN_IDX(bd_idx) = length_idx;
02326             BD_LEN_FLD(bd_idx) = AT_Tbl_Idx;
02327          }
02328       }
02329    }
02330 
02331    /* After the dimensions are processed, stride_entry_idx contains a list   */
02332    /* of all bad entry points, for the array - including all extents and     */
02333    /* type information.  Stride is calculated from the (previous dimension's */
02334    /* extent) * (previous dimension's stride).  A stride_entry_idx is made   */
02335    /* for the last dimension, even though actual stride isn't calculated for */
02336    /* this dimension.                                                        */
02337 
02338    if (stride_entry_idx != NULL_IDX) {
02339       entry_count = SCP_ALT_ENTRY_CNT(curr_scp_idx) + 1; 
02340 
02341       if (length_entry_idx != NULL_IDX &&
02342           entry_count == AL_ENTRY_COUNT(length_entry_idx))  {
02343 
02344          /* Error if problem with lower and/or upper bounds coming in    */
02345          /* different entry points.  Bounds for this array declaration   */
02346          /* cannot be calculated at any entry point, because dummy args  */
02347          /* used in the expression do not enter at all the same points.  */
02348 
02349          PRINTMSG(AT_DEF_LINE(attr_idx), 660, Error,
02350                   AT_DEF_COLUMN(attr_idx), 
02351                   AT_OBJ_NAME_PTR(attr_idx));
02352          AT_DCL_ERR(attr_idx) = TRUE;
02353       }
02354       else if (entry_count == AL_ENTRY_COUNT(stride_entry_idx))  {
02355 
02356          /* If the length is okay, but there's a problem with the        */
02357          /* stride, that means that it's a character and a bound         */
02358          /* forming the char length, doesn't enter the same as all       */
02359          /* the dimension bounds.  Bounds for this array declaration     */
02360          /* cannot be calculated at any entry point, because dummy args  */
02361          /* used in the expression de not enter at all the same points.  */
02362 
02363          PRINTMSG(AT_DEF_LINE(attr_idx), 661, Error,
02364                   AT_DEF_COLUMN(attr_idx), 
02365                   AT_OBJ_NAME_PTR(attr_idx));
02366          AT_DCL_ERR(attr_idx) = TRUE;
02367       }
02368       else if (entry_list != NULL_IDX) {
02369          stride_entry_count = merge_entry_list_count(stride_entry_idx,
02370                                                      entry_list);
02371 
02372          if (entry_count == stride_entry_count) {
02373 
02374             /* This array and its bound variables do not enter at the  */
02375             /* same entry point.                                       */
02376 
02377             PRINTMSG(AT_DEF_LINE(attr_idx), 662, Error,
02378                      AT_DEF_COLUMN(attr_idx), 
02379                      AT_OBJ_NAME_PTR(attr_idx));
02380             AT_DCL_ERR(attr_idx)  = TRUE;
02381          }
02382       }
02383    }
02384 
02385 NEXT:
02386 
02387    /* Every array must have the following semantic checks.  So even if the   */
02388    /* bounds for the array are already resolved, it still must get these     */
02389    /* checks.                                                                */
02390 
02391    if (BD_ARRAY_CLASS(bd_idx) == Explicit_Shape &&
02392        BD_ARRAY_SIZE(bd_idx) == Constant_Size) {
02393 
02394       /* Check so the item does not exceed max storage size.  Do it here,     */
02395       /* even though it is also done in final_decl_semantics because this     */
02396       /* may be a constant array involved in data or parameter statements or  */
02397       /* it may get folded.                                                   */
02398 
02399       stor_bit_size_of(attr_idx, TRUE, TRUE);
02400    }
02401    else if (need_const_array) {  
02402 
02403       /* Need an explicit_shape constant size array for parameter processing */
02404       /* An error will be issued in PARAMETER processing if this isn't a     */
02405       /* constant size array.                                                */
02406 
02407       /* This if block is intentionally blank. */
02408    }
02409    else {
02410 
02411       if (BD_ARRAY_SIZE(bd_idx) == Symbolic_Constant_Size) {
02412          fnd_semantic_err(Obj_Sym_Constant_Arr,
02413                           AT_DEF_LINE(attr_idx),
02414                           AT_DEF_COLUMN(attr_idx),
02415                           attr_idx,
02416                           TRUE);
02417 
02418          if (ATD_STOR_BLK_IDX(attr_idx) != NULL_IDX) {
02419             SB_BLK_HAS_NPES(ATD_STOR_BLK_IDX(attr_idx)) = TRUE;
02420          }
02421 
02422          if (cmd_line_flags.malleable) {
02423             PRINTMSG(AT_DEF_LINE(attr_idx), 1232, Error,
02424                      AT_DEF_COLUMN(attr_idx));
02425          }
02426       }
02427 
02428       if (BD_ARRAY_CLASS(bd_idx) == Assumed_Size) {
02429 
02430          /* This is called by PARAMETER processing.  This must be an explicit */
02431          /* shape constant size array.  PARAMETER processing will issue the   */
02432          /* error.  If this is needed elsewhere, it will come through again   */
02433          /* during decl_semantics.                                            */
02434 
02435          if (ATD_CLASS(attr_idx) == CRI__Pointee) {
02436 
02437             if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module) {
02438                AT_DCL_ERR(attr_idx) = TRUE;
02439                PRINTMSG(AT_DEF_LINE(attr_idx), 1419, Error,
02440                         AT_DEF_COLUMN(attr_idx),
02441                         AT_OBJ_NAME_PTR(attr_idx));
02442             }
02443          }
02444          else if (ATD_CLASS(attr_idx) != Dummy_Argument) {
02445 
02446             /* Must be dummy arg or CRI pointee.  */
02447 
02448             if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
02449                AT_DCL_ERR(attr_idx) = TRUE;
02450                PRINTMSG(AT_DEF_LINE(attr_idx), 501, Error,
02451                         AT_DEF_COLUMN(attr_idx),
02452                         AT_OBJ_NAME_PTR(attr_idx));
02453             }
02454             else {
02455                AT_DCL_ERR(attr_idx) = TRUE;
02456                PRINTMSG(AT_DEF_LINE(attr_idx), 500, Error,
02457                         AT_DEF_COLUMN(attr_idx),
02458                         AT_OBJ_NAME_PTR(attr_idx));
02459             }
02460          }
02461 
02462 # if defined(_TARGET_OS_MAX)
02463          if (ATD_PE_ARRAY_IDX(attr_idx) != NULL_IDX) {
02464             AT_DCL_ERR(attr_idx)        = TRUE;
02465             PRINTMSG(BD_LINE_NUM(ATD_PE_ARRAY_IDX(attr_idx)), 1583, Error,
02466                      BD_COLUMN_NUM(ATD_PE_ARRAY_IDX(attr_idx)),
02467                      "co-array dimensions",
02468                      "assumed-size arrays");
02469          }
02470 # endif
02471       }
02472       else if (BD_ARRAY_SIZE(bd_idx) == Var_Len_Array) {
02473          fnd_semantic_err(Obj_Var_Len_Arr,
02474                           AT_DEF_LINE(attr_idx),
02475                           AT_DEF_COLUMN(attr_idx),
02476                           attr_idx,
02477                           TRUE);
02478 
02479          if (ATD_CLASS(attr_idx) == Variable) {
02480 
02481             if (ATD_PE_ARRAY_IDX(attr_idx) != NULL_IDX) {
02482                AT_DCL_ERR(attr_idx)     = TRUE;
02483                PRINTMSG(AT_DEF_LINE(attr_idx), 1577, Error,
02484                         AT_DEF_COLUMN(attr_idx),
02485                         AT_OBJ_NAME_PTR(attr_idx));
02486             }
02487             else {
02488                ATD_AUTOMATIC(attr_idx) = TRUE;
02489             }
02490 
02491             if (stride_entry_idx != NULL_IDX) {
02492                PRINTMSG(AT_DEF_LINE(attr_idx), 1046, Caution,
02493                         AT_DEF_COLUMN(attr_idx),
02494                         AT_OBJ_NAME_PTR(attr_idx));
02495             }
02496          }
02497       }
02498    }
02499  
02500 
02501 EXIT:
02502 
02503    if (stride_entry_idx != NULL_IDX) {
02504       free_attr_list(stride_entry_idx);
02505    }
02506 
02507    if (length_entry_idx != NULL_IDX) {
02508       free_attr_list(length_entry_idx);
02509    }
02510 
02511    if (ATD_CLASS(attr_idx) == Function_Result) {
02512       ATP_NO_ENTRY_LIST(ATD_FUNC_IDX(attr_idx)) = entry_list;
02513    }
02514    else {
02515       ATD_NO_ENTRY_LIST(attr_idx)   = entry_list;
02516    }
02517 
02518    TRACE (Func_Exit, "array_dim_resolution", NULL);
02519 
02520    return;
02521 
02522 }  /* array_dim_resolution */
02523 
02524 /******************************************************************************\
02525 |*                                                                            *|
02526 |* Description:                                                               *|
02527 |*      This routine resolves the lower and upper bounds to a constant or a   *|
02528 |*      temp.  Calculate the extent and stride multiplier for each dimension. *|
02529 |*                                                                            *|
02530 |* Input parameters:                                                          *|
02531 |*      attr_idx -> Index to attribute for array.                             *|
02532 |*                                                                            *|
02533 |* Output parameters:                                                         *|
02534 |*      NONE                                                                  *|
02535 |*                                                                            *|
02536 |* Returns:                                                                   *|
02537 |*      NONE                                                                  *|
02538 |*                                                                            *|
02539 \******************************************************************************/
02540 
02541 void    pe_array_dim_resolution(int        attr_idx)
02542 
02543 {
02544    bd_array_size_type   array_size_type;
02545    int                  at_idx;
02546    int                  bd_idx;
02547    int                  dim;
02548    int                  entry_count;
02549    int                  entry_list;
02550    expr_arg_type        expr_desc;
02551    int                  extent_entry_idx  = NULL_IDX;
02552    fld_type             extent_fld;
02553    int                  extent_idx;
02554    int                  ir_idx;
02555    boolean              is_interface;
02556    int                  len_ir_idx;
02557    int                  length_idx;
02558    int                  length_entry_idx  = NULL_IDX;
02559    int                  mult_idx;
02560    int                  next_ir_idx;
02561    opnd_type            opnd;
02562    int                  sh_idx;
02563    int                  stride_entry_idx        = NULL_IDX;
02564    int                  stride_entry_count;
02565    size_offset_type     stride;
02566 
02567 
02568    TRACE (Func_Entry, "pe_array_dim_resolution", NULL);
02569 
02570    is_interface = SCP_IS_INTERFACE(curr_scp_idx);
02571    bd_idx       = ATD_PE_ARRAY_IDX(attr_idx);
02572 
02573    if (ATD_CLASS(attr_idx) == Function_Result) {
02574       entry_list        = ATP_NO_ENTRY_LIST(ATD_FUNC_IDX(attr_idx));
02575    }
02576    else {
02577       entry_list        = ATD_NO_ENTRY_LIST(attr_idx);
02578    }
02579 
02580    if (BD_ARRAY_CLASS(bd_idx) == Deferred_Shape) {
02581 
02582       if (! ATD_ALLOCATABLE(attr_idx)) {
02583          PRINTMSG(AT_DEF_LINE(attr_idx), 1587, Error, AT_DEF_COLUMN(attr_idx),
02584                   AT_OBJ_NAME_PTR(attr_idx));
02585          BD_DCL_ERR(bd_idx) = TRUE;
02586          AT_DCL_ERR(attr_idx) = TRUE;
02587       }
02588 
02589       goto EXIT;
02590    }
02591 
02592    /* If this array bounds entry has already been resolved, skip the section  */
02593    /* that calculates the extent, length, and stride multiplier.              */
02594    /* The only array entries that are shared are of the same type.  Each attr */
02595    /* will have to calculate it's own automatic stuff.                        */
02596 
02597    if (BD_RESOLVED(bd_idx)) {
02598       goto NEXT;
02599    }
02600 
02601    array_size_type      = Constant_Size;
02602 
02603    for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
02604 
02605       if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
02606 
02607          if (ATD_CLASS(BD_LB_IDX(bd_idx, dim)) == Constant) {
02608             BD_LB_FLD(bd_idx, dim)      = CN_Tbl_Idx;
02609             BD_LB_IDX(bd_idx, dim)      = ATD_CONST_IDX(BD_LB_IDX(bd_idx, dim));
02610          }
02611          else if (ATD_SYMBOLIC_CONSTANT(BD_LB_IDX(bd_idx, dim))) {
02612             array_size_type     = Symbolic_Constant_Size;
02613          }
02614          else {
02615             array_size_type     = Var_Len_Array;
02616          }
02617       }
02618 
02619       if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
02620 
02621          if (ATD_CLASS(BD_UB_IDX(bd_idx, dim)) == Constant) {
02622             BD_UB_FLD(bd_idx, dim)      = CN_Tbl_Idx;
02623             BD_UB_IDX(bd_idx, dim)      = ATD_CONST_IDX(BD_UB_IDX(bd_idx, dim));
02624          }
02625          else if (ATD_SYMBOLIC_CONSTANT(BD_UB_IDX(bd_idx, dim))) {
02626 
02627             if (array_size_type != Var_Len_Array) {
02628                array_size_type  = Symbolic_Constant_Size;
02629             }
02630          }
02631          else {
02632             array_size_type     = Var_Len_Array;
02633          }
02634       }
02635    }
02636 
02637    if (BD_ARRAY_CLASS(bd_idx) == Assumed_Size) {
02638 
02639       /* This is called by PARAMETER processing.  This must be an explicit */
02640       /* shape constant size array.  PARAMETER processing will issue the   */
02641       /* error.  If this is needed elsewhere, it will come through again   */
02642       /* during decl_semantics.                                            */
02643 
02644       BD_ARRAY_SIZE(bd_idx)     = array_size_type;
02645    }
02646    else {
02647       BD_ARRAY_SIZE(bd_idx)     = array_size_type;
02648 
02649       if (array_size_type == Var_Len_Array) {
02650 
02651          BD_ARRAY_SIZE(bd_idx)  = Var_Len_Array;
02652 
02653          /* This is called by PARAMETER processing.  This must be an explicit */
02654          /* shape constant size array.  PARAMETER processing will issue the   */
02655          /* error.  If this is needed elsewhere, it will come through again   */
02656          /* during decl_semantics.                                            */
02657 
02658          if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Function &&
02659              ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Subroutine) {
02660             PRINTMSG(AT_DEF_LINE(attr_idx), 131, Error,
02661                      AT_DEF_COLUMN(attr_idx),
02662                      AT_OBJ_NAME_PTR(attr_idx));
02663             BD_DCL_ERR(bd_idx) = TRUE;
02664          }
02665       }
02666    }
02667 
02668    BD_RESOLVED(bd_idx)  = TRUE;
02669 
02670    /* stride for first pe dim is always 1 */
02671 
02672    stride.fld = CN_Tbl_Idx;
02673    stride.idx = CN_INTEGER_ONE_IDX;
02674 
02675    stride_entry_idx  = NULL_IDX;
02676 
02677    NTR_IR_TBL(len_ir_idx);
02678    IR_TYPE_IDX(len_ir_idx) = INTEGER_DEFAULT_TYPE;
02679 
02680    BD_LEN_IDX(bd_idx)   = len_ir_idx;   /* Save this so it can be folded */
02681    BD_LEN_FLD(bd_idx)   = IR_Tbl_Idx;
02682    length_entry_idx     = NULL_IDX;
02683 
02684    for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
02685       BD_SM_FLD(bd_idx, dim)    = stride.fld;
02686       BD_SM_IDX(bd_idx, dim)    = stride.idx;
02687 
02688       if (extent_entry_idx != NULL_IDX) {
02689          free_attr_list(extent_entry_idx);
02690          extent_entry_idx          = NULL_IDX;
02691       }
02692 
02693       if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
02694          at_idx = BD_LB_IDX(bd_idx, dim);
02695 
02696          if (ATD_NO_ENTRY_LIST(at_idx) != NULL_IDX) {
02697             extent_entry_idx = merge_entry_lists(NULL_IDX,
02698                                                  ATD_NO_ENTRY_LIST(at_idx));
02699          }
02700       }
02701 
02702       if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
02703          at_idx = BD_UB_IDX(bd_idx, dim);
02704 
02705          if (ATD_NO_ENTRY_LIST(at_idx) != NULL_IDX) {
02706             extent_entry_idx = merge_entry_lists(extent_entry_idx,
02707                                                  ATD_NO_ENTRY_LIST(at_idx));
02708          }
02709       }
02710 
02711       if (BD_LB_FLD(bd_idx, dim) == CN_Tbl_Idx &&
02712           fold_relationals(BD_LB_IDX(bd_idx, dim),
02713                            CN_INTEGER_ONE_IDX,
02714                            Eq_Opr)) {
02715 
02716          /* If the lb is a one, just use the ub for the extent */
02717 
02718          extent_fld = BD_UB_FLD(bd_idx, dim);
02719          extent_idx = BD_UB_IDX(bd_idx, dim);
02720       }
02721       else {
02722          NTR_IR_TBL(ir_idx);                    /* Create 1 - lower */
02723          IR_OPR(ir_idx)                         = Minus_Opr;
02724          IR_TYPE_IDX(ir_idx)                    = INTEGER_DEFAULT_TYPE;
02725          IR_FLD_L(ir_idx)                       = CN_Tbl_Idx;
02726          IR_IDX_L(ir_idx)                       = CN_INTEGER_ONE_IDX;
02727          IR_LINE_NUM_L(ir_idx)                  = BD_LINE_NUM(bd_idx);
02728          IR_COL_NUM_L(ir_idx)                   = BD_COLUMN_NUM(bd_idx);
02729          IR_FLD_R(ir_idx)                       = BD_LB_FLD(bd_idx, dim);
02730          IR_IDX_R(ir_idx)                       = BD_LB_IDX(bd_idx, dim);
02731          IR_LINE_NUM_R(ir_idx)                  = BD_LINE_NUM(bd_idx);
02732          IR_COL_NUM_R(ir_idx)                   = BD_COLUMN_NUM(bd_idx);
02733          IR_LINE_NUM(ir_idx)                    = BD_LINE_NUM(bd_idx);
02734          IR_COL_NUM(ir_idx)                     = BD_COLUMN_NUM(bd_idx);
02735 
02736          NTR_IR_TBL(next_ir_idx);               /* Upper + (1 - lower) */
02737          IR_OPR(next_ir_idx)                    = Plus_Opr;
02738          IR_TYPE_IDX(next_ir_idx)               = INTEGER_DEFAULT_TYPE;
02739          IR_IDX_L(next_ir_idx)                  = BD_UB_IDX(bd_idx, dim);
02740          IR_FLD_L(next_ir_idx)                  = BD_UB_FLD(bd_idx, dim);
02741          IR_LINE_NUM_L(next_ir_idx)             = BD_LINE_NUM(bd_idx);
02742          IR_COL_NUM_L(next_ir_idx)              = BD_COLUMN_NUM(bd_idx);
02743          IR_FLD_R(next_ir_idx)                  = IR_Tbl_Idx;
02744          IR_IDX_R(next_ir_idx)                  = ir_idx;
02745          IR_LINE_NUM_R(next_ir_idx)             = BD_LINE_NUM(bd_idx);
02746          IR_COL_NUM_R(next_ir_idx)              = BD_COLUMN_NUM(bd_idx);
02747          IR_LINE_NUM(next_ir_idx)               = BD_LINE_NUM(bd_idx);
02748          IR_COL_NUM(next_ir_idx)                = BD_COLUMN_NUM(bd_idx);
02749 
02750          if (BD_ARRAY_SIZE(bd_idx) == Symbolic_Constant_Size) {
02751             IR_OPR(next_ir_idx) = Symbolic_Plus_Opr;
02752             IR_OPR(ir_idx)      = Symbolic_Minus_Opr;
02753             extent_idx          = gen_compiler_tmp(BD_LINE_NUM(bd_idx),
02754                                                    BD_COLUMN_NUM(bd_idx),
02755                                                    Priv, TRUE);
02756             extent_fld          = AT_Tbl_Idx;
02757 
02758             ATD_SYMBOLIC_CONSTANT(extent_idx)   = TRUE;
02759             ATD_TYPE_IDX(extent_idx)            = CG_INTEGER_DEFAULT_TYPE;
02760             ATD_FLD(extent_idx)                 = IR_Tbl_Idx;
02761             ATD_TMP_IDX(extent_idx)             = next_ir_idx;
02762 
02763 
02764             /* KAY - Some of this may be folded if they are both not */
02765             /*       symbolic constants.                             */
02766          }
02767          else {
02768 
02769             OPND_FLD(opnd)                      = IR_Tbl_Idx;
02770             OPND_IDX(opnd)                      = next_ir_idx;
02771             OPND_LINE_NUM(opnd)                 = stmt_start_line;
02772             OPND_COL_NUM(opnd)                  = stmt_start_col;
02773 
02774             sh_idx                              = ntr_sh_tbl();
02775             SH_GLB_LINE(sh_idx)                 = stmt_start_line;
02776             SH_COL_NUM(sh_idx)                  = stmt_start_col;
02777             SH_STMT_TYPE(sh_idx)                = Automatic_Base_Size_Stmt;
02778             SH_COMPILER_GEN(sh_idx)             = TRUE;
02779             SH_P2_SKIP_ME(sh_idx)               = TRUE;
02780 
02781             expr_desc.rank = 0;
02782             xref_state     = CIF_No_Usage_Rec;
02783 
02784             /* This is in terms of tmps - so it will never   */
02785             /* generate more than one statement.             */
02786 
02787             if (!expr_semantics(&opnd, &expr_desc)) {
02788                PRINTMSG(AT_DEF_LINE(attr_idx), 951, Error,
02789                         AT_DEF_COLUMN(attr_idx),
02790                         dim,
02791                         AT_OBJ_NAME_PTR(attr_idx));
02792                AT_DCL_ERR(attr_idx)     = TRUE;
02793             }
02794 
02795             if (OPND_FLD(opnd) == CN_Tbl_Idx) {
02796                extent_fld       = CN_Tbl_Idx;
02797                extent_idx       = OPND_IDX(opnd);
02798                FREE_SH_NODE(sh_idx);
02799             }
02800             else {
02801                extent_fld       = AT_Tbl_Idx;
02802                extent_idx       = ntr_bnds_sh_tmp_list(&opnd,
02803                                                extent_entry_idx,
02804                                                (is_interface) ? NULL_IDX:sh_idx,
02805                                                FALSE,
02806                                                SA_INTEGER_DEFAULT_TYPE);
02807             }
02808          }
02809       }
02810 
02811       if (extent_fld == CN_Tbl_Idx) {
02812 
02813          if (compare_cn_and_value(extent_idx, 0, Lt_Opr)) {
02814             extent_idx = CN_INTEGER_ZERO_IDX;
02815          }
02816       }
02817       else {  /* Generate  tmp = max(0, extent) */
02818 
02819          OPND_FLD(opnd)   = extent_fld;
02820          OPND_IDX(opnd)   = extent_idx;
02821          OPND_LINE_NUM(opnd)  = BD_LINE_NUM(bd_idx);
02822          OPND_COL_NUM(opnd) = BD_COLUMN_NUM(bd_idx);
02823 
02824          gen_tmp_equal_max_zero(&opnd, 
02825                                 INTEGER_DEFAULT_TYPE,
02826                                 extent_entry_idx,
02827                                 (BD_ARRAY_SIZE(bd_idx)==Symbolic_Constant_Size),
02828                                 is_interface);
02829 
02830          extent_fld   = OPND_FLD(opnd);
02831          extent_idx   = OPND_IDX(opnd);
02832       }
02833 
02834       BD_XT_FLD(bd_idx, dim)    = extent_fld;
02835       BD_XT_IDX(bd_idx, dim)    = extent_idx;
02836 
02837       /* STRIDE = STRIDE * (EXTENT of previous dimension) */
02838       /* Fix stride for next dimension.                   */
02839       /* Calculate length.                                */
02840 
02841       if (dim < BD_RANK(bd_idx)) {
02842          NTR_IR_TBL(ir_idx);            /* Create Stride * Extent */
02843          IR_OPR(ir_idx)                 = Mult_Opr;
02844          IR_TYPE_IDX(ir_idx)            = INTEGER_DEFAULT_TYPE;
02845          IR_LINE_NUM(ir_idx)            = BD_LINE_NUM(bd_idx);
02846          IR_COL_NUM(ir_idx)             = BD_COLUMN_NUM(bd_idx);
02847          IR_FLD_L(ir_idx)               = stride.fld;
02848          IR_IDX_L(ir_idx)               = stride.idx;
02849          IR_LINE_NUM_L(ir_idx)          = BD_LINE_NUM(bd_idx);
02850          IR_COL_NUM_L(ir_idx)           = BD_COLUMN_NUM(bd_idx);
02851          IR_FLD_R(ir_idx)               = extent_fld;
02852          IR_IDX_R(ir_idx)               = extent_idx;
02853          IR_LINE_NUM_R(ir_idx)          = BD_LINE_NUM(bd_idx);
02854          IR_COL_NUM_R(ir_idx)           = BD_COLUMN_NUM(bd_idx);
02855 
02856          if ((extent_fld == AT_Tbl_Idx && ATD_SYMBOLIC_CONSTANT(extent_idx)) ||
02857              (stride.fld == AT_Tbl_Idx && ATD_SYMBOLIC_CONSTANT(stride.idx))) {
02858             IR_OPR(ir_idx)      = Symbolic_Mult_Opr;
02859             stride.fld          = AT_Tbl_Idx;
02860             stride.idx          = gen_compiler_tmp(BD_LINE_NUM(bd_idx),
02861                                                    BD_COLUMN_NUM(bd_idx),
02862                                                    Priv, TRUE);
02863 
02864             ATD_TYPE_IDX(stride.idx)            = CG_INTEGER_DEFAULT_TYPE;
02865             ATD_FLD(stride.idx)                 = IR_Tbl_Idx;
02866             ATD_TMP_IDX(stride.idx)             = ir_idx;
02867             ATD_SYMBOLIC_CONSTANT(stride.idx)   = TRUE;
02868          }
02869          else {
02870             OPND_FLD(opnd)              = IR_Tbl_Idx;
02871             OPND_IDX(opnd)              = ir_idx;
02872             OPND_LINE_NUM(opnd)         = stmt_start_line;
02873             OPND_COL_NUM(opnd)          = stmt_start_col;
02874 
02875             sh_idx                      = ntr_sh_tbl();
02876             SH_STMT_TYPE(sh_idx)        = Automatic_Base_Size_Stmt;
02877             SH_COMPILER_GEN(sh_idx)     = TRUE;
02878             SH_P2_SKIP_ME(sh_idx)       = TRUE;
02879             SH_GLB_LINE(sh_idx)         = stmt_start_line;
02880             SH_COL_NUM(sh_idx)          = stmt_start_col;
02881 
02882             expr_desc.rank              = 0;
02883             xref_state                  = CIF_No_Usage_Rec;
02884 
02885             expr_semantics(&opnd, &expr_desc);
02886 
02887             if (OPND_FLD(opnd) == CN_Tbl_Idx) {
02888                stride.fld               = CN_Tbl_Idx;
02889                stride.idx               = OPND_IDX(opnd);
02890                FREE_SH_NODE(sh_idx);
02891             }
02892             else {
02893 
02894                if (!is_interface) {
02895 
02896                   /* Stride must be non-constant, if extent is non-constant */
02897 
02898                   if (extent_entry_idx != NULL_IDX) {
02899                      stride_entry_idx = merge_entry_lists(stride_entry_idx,
02900                                                           extent_entry_idx);
02901                      length_entry_idx = merge_entry_lists(length_entry_idx,
02902                                                           extent_entry_idx);
02903                   }
02904                }
02905 
02906                stride.fld = AT_Tbl_Idx;
02907                stride.idx = ntr_bnds_sh_tmp_list(&opnd,
02908                                                  stride_entry_idx,
02909                                                  is_interface ? NULL_IDX:sh_idx,
02910                                                  FALSE,
02911                                                  SA_INTEGER_DEFAULT_TYPE);
02912             }
02913          }
02914 
02915          NTR_IR_TBL(mult_idx);   /* Create length = extent * extent */
02916          IR_LINE_NUM(mult_idx)          = BD_LINE_NUM(bd_idx);
02917          IR_COL_NUM(mult_idx)           = BD_COLUMN_NUM(bd_idx);
02918          IR_OPR(mult_idx)               = (extent_fld == AT_Tbl_Idx &&
02919                                           ATD_SYMBOLIC_CONSTANT(extent_idx)) ?
02920                                           Symbolic_Mult_Opr : Mult_Opr;
02921          IR_TYPE_IDX(mult_idx)          = INTEGER_DEFAULT_TYPE;
02922          IR_IDX_R(len_ir_idx)           = mult_idx;
02923          IR_FLD_R(len_ir_idx)           = IR_Tbl_Idx;
02924          IR_LINE_NUM_R(len_ir_idx)      = BD_LINE_NUM(bd_idx);
02925          IR_COL_NUM_R(len_ir_idx)       = BD_COLUMN_NUM(bd_idx);
02926          IR_IDX_L(mult_idx)             = extent_idx;
02927          IR_FLD_L(mult_idx)             = extent_fld;
02928          IR_LINE_NUM_L(mult_idx)        = BD_LINE_NUM(bd_idx);
02929          IR_COL_NUM_L(mult_idx)         = BD_COLUMN_NUM(bd_idx);
02930          len_ir_idx                     = mult_idx;
02931       }
02932       else if (dim == 1) {
02933 
02934          /* Last dimension is the only dimension, so length = xtent */
02935 
02936          BD_LEN_FLD(bd_idx)     = extent_fld;
02937          BD_LEN_IDX(bd_idx)     = extent_idx;
02938          length_entry_idx       = extent_entry_idx;
02939          stride_entry_idx       = merge_entry_lists(stride_entry_idx,
02940                                                     extent_entry_idx);
02941 
02942          extent_entry_idx = NULL_IDX;  /* Now length holds list */
02943 
02944          if (length_entry_idx != NULL_IDX) {  /* Alt entries - need tmp = 0 */
02945             gen_tmp_eq_zero_ir(extent_idx);
02946          }
02947       }
02948 
02949       /* Last dimension */
02950 
02951       else if (BD_ARRAY_SIZE(bd_idx) == Symbolic_Constant_Size) {
02952          IR_IDX_R(len_ir_idx)           = extent_idx;
02953          IR_FLD_R(len_ir_idx)           = extent_fld;
02954          IR_LINE_NUM_R(len_ir_idx)      = BD_LINE_NUM(bd_idx);
02955          IR_COL_NUM_R(len_ir_idx)       = BD_COLUMN_NUM(bd_idx);
02956 
02957          BD_LEN_FLD(bd_idx)     = AT_Tbl_Idx;
02958          BD_LEN_IDX(bd_idx)     = gen_compiler_tmp(BD_LINE_NUM(bd_idx),
02959                                                    BD_COLUMN_NUM(bd_idx),
02960                                                    Priv, TRUE);
02961          ATD_TYPE_IDX(BD_LEN_IDX(bd_idx))       = CG_INTEGER_DEFAULT_TYPE;
02962          ATD_FLD(BD_LEN_IDX(bd_idx))            = IR_FLD_R(BD_LEN_IDX(bd_idx));
02963          ATD_TMP_IDX(BD_LEN_IDX(bd_idx))        = IR_IDX_R(BD_LEN_IDX(bd_idx));
02964 
02965          ATD_SYMBOLIC_CONSTANT(BD_LEN_IDX(bd_idx))      = TRUE;
02966       }
02967       else {
02968          IR_IDX_R(len_ir_idx)           = extent_idx;
02969          IR_FLD_R(len_ir_idx)           = extent_fld;
02970          IR_LINE_NUM_R(len_ir_idx)      = BD_LINE_NUM(bd_idx);
02971          IR_COL_NUM_R(len_ir_idx)       = BD_COLUMN_NUM(bd_idx);
02972          OPND_FLD(opnd)                 = IR_FLD_R(BD_LEN_IDX(bd_idx));
02973          OPND_IDX(opnd)                 = IR_IDX_R(BD_LEN_IDX(bd_idx));
02974          OPND_LINE_NUM(opnd)            = BD_LINE_NUM(bd_idx);
02975          OPND_COL_NUM(opnd)             = BD_COLUMN_NUM(bd_idx);
02976 
02977          sh_idx                         = ntr_sh_tbl();
02978          SH_STMT_TYPE(sh_idx)           = Automatic_Base_Size_Stmt;
02979          SH_COMPILER_GEN(sh_idx)        = TRUE;
02980          SH_P2_SKIP_ME(sh_idx)          = TRUE;
02981          SH_GLB_LINE(sh_idx)            = stmt_start_line;
02982          SH_COL_NUM(sh_idx)             = stmt_start_col;
02983 
02984          /* expr_semantics needs curr_stmt_sh_idx set to something valid.  */
02985          /* It does not need SH_IR_IDX(curr_stmt_sh_idx) set to something. */
02986 
02987          expr_desc.rank = 0;
02988          xref_state     = CIF_No_Usage_Rec;
02989 
02990          if (!expr_semantics(&opnd, &expr_desc)) {
02991 
02992 # if defined(_CHECK_MAX_MEMORY)
02993 
02994             if (!target_t3e) {
02995                AT_DCL_ERR(attr_idx) = TRUE;
02996             }
02997 # endif
02998          }
02999 
03000          if (OPND_FLD(opnd) == CN_Tbl_Idx) {
03001             BD_LEN_FLD(bd_idx)  = CN_Tbl_Idx;
03002             BD_LEN_IDX(bd_idx)  = OPND_IDX(opnd);
03003             FREE_SH_NODE(sh_idx);
03004          }
03005          else {
03006 
03007             if (!is_interface) {
03008 
03009                if (extent_entry_idx != NULL_IDX) {
03010                   stride_entry_idx = merge_entry_lists(stride_entry_idx,
03011                                                        extent_entry_idx);
03012                   length_entry_idx = merge_entry_lists(length_entry_idx,
03013                                                        extent_entry_idx);
03014                }
03015             }
03016 
03017             length_idx = ntr_bnds_sh_tmp_list(&opnd,
03018                                               length_entry_idx,
03019                                               (is_interface) ? NULL_IDX:sh_idx,
03020                                               TRUE,
03021                                               SA_INTEGER_DEFAULT_TYPE);
03022             BD_LEN_IDX(bd_idx) = length_idx;
03023             BD_LEN_FLD(bd_idx) = AT_Tbl_Idx;
03024          }
03025       }
03026    }
03027 
03028    /* After the dimensions are processed, stride_entry_idx contains a list   */
03029    /* of all bad entry points, for the array - including all extents and     */
03030    /* type information.  Stride is calculated from the (previous dimension's */
03031    /* extent) * (previous dimension's stride).  A stride_entry_idx is made   */
03032    /* for the last dimension, even though actual stride isn't calculated for */
03033    /* this dimension.                                                        */
03034 
03035    if (stride_entry_idx != NULL_IDX) {
03036       entry_count       = SCP_ALT_ENTRY_CNT(curr_scp_idx) + 1;
03037 
03038       if (length_entry_idx != NULL_IDX &&
03039           entry_count == AL_ENTRY_COUNT(length_entry_idx))  {
03040 
03041          /* Error if problem with lower and/or upper bounds coming in    */
03042          /* different entry points.  Bounds for this array declaration   */
03043          /* cannot be calculated at any entry point, because dummy args  */
03044          /* used in the expression do not enter at all the same points.  */
03045 
03046          PRINTMSG(AT_DEF_LINE(attr_idx), 660, Error,
03047                   AT_DEF_COLUMN(attr_idx),
03048                   AT_OBJ_NAME_PTR(attr_idx));
03049          AT_DCL_ERR(attr_idx)   = TRUE;
03050       }
03051       else if (entry_count == AL_ENTRY_COUNT(stride_entry_idx))  {
03052 
03053          /* If the length is okay, but there's a problem with the        */
03054          /* stride, that means that it's a character and a bound         */
03055          /* forming the char length, doesn't enter the same as all       */
03056          /* the dimension bounds.  Bounds for this array declaration     */
03057          /* cannot be calculated at any entry point, because dummy args  */
03058          /* used in the expression de not enter at all the same points.  */
03059 
03060          PRINTMSG(AT_DEF_LINE(attr_idx), 661, Error,
03061                   AT_DEF_COLUMN(attr_idx),
03062                   AT_OBJ_NAME_PTR(attr_idx));
03063          AT_DCL_ERR(attr_idx)   = TRUE;
03064       }
03065       else if (entry_list != NULL_IDX) {
03066          stride_entry_count = merge_entry_list_count(stride_entry_idx,
03067                                                      entry_list);
03068 
03069          if (entry_count == stride_entry_count) {
03070 
03071             /* This array and its bound variables do not enter at the  */
03072             /* same entry point.                                       */
03073 
03074             PRINTMSG(AT_DEF_LINE(attr_idx), 662, Error,
03075                      AT_DEF_COLUMN(attr_idx),
03076                      AT_OBJ_NAME_PTR(attr_idx));
03077             AT_DCL_ERR(attr_idx)        = TRUE;
03078          }
03079       }
03080    }
03081 
03082 NEXT:
03083 
03084    /* Every array must have the following semantic checks.  So even if the   */
03085    /* bounds for the array are already resolved, it still must get these     */
03086    /* checks.                                                                */
03087 
03088 # if 0
03089    if (BD_ARRAY_CLASS(bd_idx) != Assumed_Size) {
03090       PRINTMSG(AT_DEF_LINE(attr_idx), 1576, Error,
03091                AT_DEF_COLUMN(attr_idx));
03092       AT_DCL_ERR(attr_idx)        = TRUE;
03093    }
03094 # endif
03095 
03096 EXIT:
03097 
03098    if (stride_entry_idx != NULL_IDX) {
03099       free_attr_list(stride_entry_idx);
03100    }
03101 
03102    if (length_entry_idx != NULL_IDX) {
03103       free_attr_list(length_entry_idx);
03104    }
03105 
03106    if (ATD_CLASS(attr_idx) == Function_Result) {
03107       ATP_NO_ENTRY_LIST(ATD_FUNC_IDX(attr_idx)) = entry_list;
03108    }
03109    else {
03110       ATD_NO_ENTRY_LIST(attr_idx)               = entry_list;
03111    }
03112 
03113    TRACE (Func_Exit, "pe_array_dim_resolution", NULL);
03114 
03115    return;
03116 
03117 }  /* pe_array_dim_resolution */
03118 
03119 /******************************************************************************\
03120 |*                        *|
03121 |* Description:                     *|
03122 |*  It does semantic checking and tries to fold the bound.  If the bound  *|
03123 |*  folds to a constant, ATD_FLD(tmp) is set to CN_Tbl_Idx and            *|
03124 |*  ATD_TMP_IDX(tmp) is set to the constant table index of the constant.  *|
03125 |*  AT_REFERENCED(tmp) = Not_Referenced, so the temp doesn't get added to *|
03126 |*      the IR stream at entry point processing.  array_dim_resolution and    *|
03127 |*      char_len_resolution then check ATD_FLD(tmp).  If it is CN_Tbl_Idx     *|
03128 |*      the item resolves to a constant bounded item.  If it doesn't resolve  *|
03129 |*  to a folded item, ATD_FLD(tmp) = SH_Tbl_Idx and ATD_TMP_IDX(tmp)      *|
03130 |*  is the index to the first statement header for the bound.  A bound    *|
03131 |*  may have more than one statement, after going through expr_semantics. *|
03132 |*  The statements are all linked together.                               *|
03133 |*                        *|
03134 |*  Assumption:  All non-interface blocks have a valid curr_stmt_sh_idx   *|
03135 |*  It is set to the Entry SH when decl_semantics is called.  All bounds  *|
03136 |*  IR SH's go in following this and curr_stmt_sh_idx is advanced.        *|
03137 |*                        *|
03138 |* Input parameters:                    *|
03139 |*  NONE                      *|
03140 |*                        *|
03141 |* Output parameters:                   *|
03142 |*  NONE                      *|
03143 |*                        *|
03144 |* Returns:                     *|
03145 |*  NONE                      *|
03146 |*                        *|
03147 \******************************************************************************/
03148 static  void  bound_resolution(int  attr_idx)
03149 
03150 {
03151    boolean    ansi;
03152    msg_lvl_type   save_msg_level;
03153    int      start_sh_idx;
03154 
03155 
03156    TRACE (Func_Entry, "bound_resolution", NULL);
03157 
03158    if (ATD_CLASS(attr_idx) == Constant) {
03159 
03160       /* Intentionally blank */
03161    }
03162    else if (AT_REFERENCED(attr_idx) == Not_Referenced) {
03163 
03164       /* These are tmps that are only here, because CIF generation is on. */
03165       /* These are shared tmps and normally would not have been kept      */
03166       /* around.  Call expr_semantics with them, so the proper CIF calls  */
03167       /* can be generated and then free the IR.                           */
03168 
03169       xref_state      = CIF_Symbol_Reference;
03170       cif_tmp_so_no_msg     = TRUE;
03171       no_func_expansion     = TRUE;
03172       save_msg_level      = cmd_line_flags.msg_lvl_suppressed;
03173       ansi        = on_off_flags.issue_ansi_messages;
03174       cmd_line_flags.msg_lvl_suppressed = Error_Lvl;
03175 
03176       bound_semantics(attr_idx, FALSE);          /* Don't get stmts */
03177 
03178       if (ATD_CLASS(attr_idx) != Constant) {
03179          ATD_TMP_IDX(attr_idx)    = NULL_IDX;
03180          ATD_FLD(attr_idx)    = NO_Tbl_Idx;
03181       }
03182 
03183       AT_REFERENCED(attr_idx)   = Not_Referenced;
03184       AT_DEFINED(attr_idx)    = FALSE;
03185       no_func_expansion     = FALSE;
03186       cmd_line_flags.msg_lvl_suppressed = save_msg_level;
03187       on_off_flags.issue_ansi_messages  = ansi;
03188       cif_tmp_so_no_msg     = FALSE;
03189    }
03190    else {
03191 
03192       if (ATD_TMP_SEMANTICS_DONE(attr_idx)) {
03193 
03194          /* These are tmps that were folded during pass1, because they were */
03195          /* referenced in a bound for a parameterized character or array.   */
03196          /* These did not fold to a constant, so they must be sent thru     */
03197          /* expression semantics, so that everything gets folded and/or     */
03198          /* expanded correctly.   Stop message issuing, because it has been */
03199          /* done once already.                                              */
03200 
03201          save_msg_level        = cmd_line_flags.msg_lvl_suppressed;
03202          ansi          = on_off_flags.issue_ansi_messages;
03203          cmd_line_flags.msg_lvl_suppressed = Error_Lvl;
03204 
03205          /* If this isn't an interface block - generate stmts after */
03206          /* curr_stmt_sh_idx for this bound.                        */
03207 
03208          start_sh_idx = bound_semantics(attr_idx,
03209                                         !SCP_IS_INTERFACE(curr_scp_idx));
03210 
03211          cmd_line_flags.msg_lvl_suppressed = save_msg_level;
03212          on_off_flags.issue_ansi_messages  = ansi;
03213       }
03214       else {
03215 
03216          /* If this isn't an interface block - generate stmts after */
03217          /* curr_stmt_sh_idx for this bound.                        */
03218 
03219          xref_state   = CIF_Symbol_Reference;
03220          start_sh_idx = bound_semantics(attr_idx,
03221                                         !SCP_IS_INTERFACE(curr_scp_idx));
03222       }
03223 
03224       if (ATD_CLASS(attr_idx) != Constant &&
03225           !ATD_SYMBOLIC_CONSTANT(attr_idx) &&
03226           SCP_ENTRY_IDX(curr_scp_idx) != NULL_IDX) {
03227 
03228          /* Enter the code at each alternate entry.  We do generate tmp = 0   */
03229          /* code, because the bounds can be referenced for whole subscript    */
03230          /* and whole substring references.  These are all bounds tmps for    */
03231          /* arrays (upper or lower) or character length. We do not have to    */
03232          /* worry about OPTIONAL dummy arguments here because it is illegal   */
03233          /* to use an OPTIONAL dummy argument in a bound expression.  Start   */
03234          /* the copy at SH_PREV_IDX(start_sh_idx) and end at curr_stmt_sh_idx.*/
03235 
03236          insert_sh_after_entries(attr_idx, 
03237                                  SH_PREV_IDX(start_sh_idx),
03238                                  curr_stmt_sh_idx,
03239                                  TRUE,
03240                                  TRUE);     /* Advance ATP_FIRST_SH_IDX */
03241       }
03242    }
03243 
03244    TRACE (Func_Exit, "bound_resolution", NULL);
03245 
03246    return;
03247    
03248 }  /* bound_resolution */
03249 
03250 /******************************************************************************\
03251 |*                        *|
03252 |* Description:                     *|
03253 |*  This routine calls expr_semantics for a declaration bound and         *|
03254 |*  handles semantic checking.  If the bounds folds to a constant,        *|
03255 |*  ATD_FLD(tmp) is set to CN_Tbl_Idx and ATD_TMP_IDX(tmp) is set to the  *|
03256 |*  constant table index of the constant.  AT_REFERENCED(tmp) =           *|
03257 |*  Not_Referenced, so the temp does not get used in other phases of      *|
03258 |*  compilation.                          *|
03259 |*  Also, if non-constant a cvrt opr will be added if necessary to set    *|
03260 |*  the type to the correct size/addresss/offset type.                    *|
03261 |*                        *|
03262 |* Input parameters:                    *|
03263 |*  attr_idx      - Index of bound tmp to call expr_semantics for.  *|
03264 |*  insert_in_SH_stream - TRUE if IR should be inserted in IR stream.     *|
03265 |*                        *|
03266 |* Output parameters:                   *|
03267 |*  NONE                      *|
03268 |*                        *|
03269 |* Returns:                     *|
03270 |*  bound_sh_idx      - Index of statement header for bound.            *|
03271 |*                        *|
03272 \******************************************************************************/
03273 int bound_semantics(int   attr_idx,
03274                         boolean   insert_in_SH_stream)
03275 
03276 {
03277    int      bound_sh_idx;
03278    expr_arg_type  expr_desc;
03279    int      list_idx;
03280    fld_type   new_fld;
03281    int      new_ir_idx;
03282    opnd_type    opnd;
03283    int      save_sh_idx;
03284    int      type_idx;
03285 
03286 
03287    TRACE (Func_Entry, "bound_semantics", NULL);
03288 
03289    if (AT_OBJ_CLASS(attr_idx) != Data_Obj ||
03290        ATD_CLASS(attr_idx) != Compiler_Tmp) {
03291       return(NULL_IDX);
03292    }
03293 
03294    expr_mode        = Specification_Expr;
03295    expr_desc.rank     = 0;
03296    ATD_TMP_SEMANTICS_DONE(attr_idx) = TRUE;
03297 
03298    /* Save a copy of the IR.  If this does not fold to a constant, we need    */
03299    /* to keep the IR before it goes through expr_semantics.  This ir is used, */
03300    /* if this bound is part of a description of an interface for a function.  */
03301    /* (Interface block, internal function or module procedure function.)      */
03302 
03303    gen_opnd(&opnd, ATD_TMP_IDX(attr_idx), (fld_type) ATD_FLD(attr_idx),
03304             stmt_start_line, stmt_start_col);
03305    copy_subtree(&opnd, &opnd);
03306    new_ir_idx = OPND_IDX(opnd);
03307    new_fld = OPND_FLD(opnd);
03308 
03309    /* Create a stmt header to link the IR to.  This way if expr_semantics  */
03310    /* generates some statements, they get attached where they need to be.  */
03311 
03312    bound_sh_idx       = ntr_sh_tbl();
03313    SH_IR_IDX(bound_sh_idx)    = ATD_TMP_IDX(attr_idx);
03314    SH_STMT_TYPE(bound_sh_idx)   = Automatic_Base_Size_Stmt;
03315    SH_COMPILER_GEN(bound_sh_idx)  = TRUE;
03316    SH_P2_SKIP_ME(bound_sh_idx)    = TRUE;
03317    SH_GLB_LINE(bound_sh_idx)    = stmt_start_line;
03318    SH_COL_NUM(bound_sh_idx)   = stmt_start_col;
03319    save_sh_idx        = curr_stmt_sh_idx;
03320    curr_stmt_sh_idx     = bound_sh_idx;
03321 
03322 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
03323 
03324    if (ATD_TMP_HAS_CVRT_OPR(attr_idx)) {
03325 
03326       /* Need to do expr_semantics without the cvrt to do error checking */
03327 
03328       COPY_OPND(opnd, IR_OPND_L(IR_IDX_R(ATD_TMP_IDX(attr_idx))));
03329    }
03330    else {
03331       COPY_OPND(opnd, IR_OPND_R(ATD_TMP_IDX(attr_idx)));
03332    }
03333 # else
03334 
03335    COPY_OPND(opnd, IR_OPND_R(ATD_TMP_IDX(attr_idx)));
03336 # endif
03337 
03338    if (!expr_semantics(&opnd, &expr_desc)) {
03339 
03340       /* There were problems with this expression.  Replace it with a   */
03341       /* constant one.  Constant bound processing will free the IR.     */
03342 
03343       OPND_IDX(opnd)    = CN_INTEGER_ONE_IDX;
03344       OPND_FLD(opnd)    = CN_Tbl_Idx;
03345       OPND_LINE_NUM(opnd) = stmt_start_line;
03346       OPND_COL_NUM(opnd)  = stmt_start_col;
03347 
03348       /* This is a newly created list after each call to expr_semantics.*/
03349       /* It contains dargs found in this specification expression.      */
03350 
03351       free_attr_list(SCP_TMP_LIST(curr_scp_idx));
03352       SCP_TMP_LIST(curr_scp_idx) = NULL_IDX;  /* Clear in case of list */
03353    }
03354    else if (expr_desc.rank != 0) {
03355       PRINTMSG(AT_DEF_LINE(attr_idx), 907, Error,
03356               AT_DEF_COLUMN(attr_idx));
03357       AT_DCL_ERR(attr_idx) = TRUE;
03358    }
03359    else if (expr_desc.type != Integer) {
03360 
03361       /* The tmp must be integer.  This must be its first pass thru and no */
03362       /* no previous error messages must have been issued about this tmp.  */
03363 
03364       if (expr_desc.linear_type == Typeless_4 ||
03365           expr_desc.linear_type == Typeless_8) { 
03366          PRINTMSG(AT_DEF_LINE(attr_idx), 221, Ansi, 
03367                   AT_DEF_COLUMN(attr_idx));
03368       }
03369       else if (expr_desc.linear_type == Short_Typeless_Const) {
03370          PRINTMSG(AT_DEF_LINE(attr_idx), 221, Ansi,
03371                   AT_DEF_COLUMN(attr_idx));
03372          OPND_IDX(opnd) = cast_typeless_constant(OPND_IDX(opnd),
03373                                                  INTEGER_DEFAULT_TYPE,
03374              OPND_LINE_NUM(opnd),
03375              OPND_COL_NUM(opnd));
03376          expr_desc.type_idx    = INTEGER_DEFAULT_TYPE;
03377          expr_desc.type        = Integer;
03378          expr_desc.linear_type = INTEGER_DEFAULT_TYPE;
03379 
03380       }
03381       else {
03382 
03383          if (!AT_DCL_ERR(attr_idx)) {
03384 
03385             if (expr_desc.linear_type == Long_Typeless) { 
03386 
03387                /* hollerith too long */
03388 
03389                PRINTMSG(AT_DEF_LINE(attr_idx), 1133, Error, 
03390                         AT_DEF_COLUMN(attr_idx));
03391             }
03392             else {  /* bad type */
03393                PRINTMSG(AT_DEF_LINE(attr_idx), 488, Error,
03394                         AT_DEF_COLUMN(attr_idx),
03395                         get_basic_type_str(expr_desc.type_idx));
03396             }
03397             AT_DCL_ERR(attr_idx) = TRUE;
03398          }
03399 
03400          /* There were problems with this expression.  Replace with a one. */
03401 
03402          OPND_IDX(opnd)   = CN_INTEGER_ONE_IDX;
03403          OPND_FLD(opnd)   = CN_Tbl_Idx;
03404          OPND_LINE_NUM(opnd)  = AT_DEF_LINE(attr_idx);
03405          OPND_COL_NUM(opnd) = AT_DEF_COLUMN(attr_idx);
03406 
03407          /* This is a newly created list after each call to expr_semantics.*/
03408          /* It contains dargs found in this specification expression.      */
03409 
03410          free_attr_list(SCP_TMP_LIST(curr_scp_idx));
03411          SCP_TMP_LIST(curr_scp_idx) = NULL_IDX;  /* Clear in case of list */
03412       }
03413    }
03414    else if (expr_desc.has_symbolic) {
03415 
03416       /* This expression contains a reference to a symbolic constant.     */
03417 
03418       /* Determine if this is a symbolic constant expression or not.      */
03419       /* If this is a symbolic constant expression, ATD_SYMBOLIC_CONSTANT */
03420       /* will be set on the compiler temp.                                */
03421 
03422       ATD_SYMBOLIC_CONSTANT(attr_idx) = expr_is_symbolic_constant(&opnd);
03423    }
03424 
03425 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
03426 
03427    else if (ATD_TMP_HAS_CVRT_OPR(attr_idx)) {
03428       COPY_OPND(IR_OPND_L(IR_IDX_R(ATD_TMP_IDX(attr_idx))), opnd);
03429 
03430       if (OPND_FLD(opnd) == CN_Tbl_Idx) {
03431          COPY_OPND(opnd, IR_OPND_R(ATD_TMP_IDX(attr_idx)));
03432          expr_semantics(&opnd, &expr_desc);
03433       }
03434       else {
03435          COPY_OPND(opnd, IR_OPND_R(ATD_TMP_IDX(attr_idx)));
03436       }
03437    }
03438 # endif
03439 
03440    if (OPND_FLD(opnd) == CN_Tbl_Idx) {
03441 
03442       /* Folded to a constant.   NOTE:  Cannot free IR, because IR can  */
03443       /* be shared and you could free IR that is used in other places.  */
03444 
03445       /* Change the tmp to a constant, so it gets folded whenever it is  */
03446       /* referenced.  AT_DEFINED is left clear.  It is set on declared   */
03447       /* parameters, so that parameter constants can be differentiated   */
03448       /* from compiler tmp constants.  CIF wants all parameters, whether */
03449       /* they are referenced or not, so AT_DEFINED is used to tell the   */
03450       /* difference between them.                                        */
03451 
03452       CLEAR_VARIANT_ATTR_INFO(attr_idx, Data_Obj);
03453 
03454       ATD_CLASS(attr_idx) = Constant;
03455       AT_TYPED(attr_idx)  = TRUE;
03456       ATD_TYPE_IDX(attr_idx)  = CN_TYPE_IDX(OPND_IDX(opnd));
03457       AT_REFERENCED(attr_idx) = Not_Referenced;  /* Temp not used      */
03458       AT_DEFINED(attr_idx)  = FALSE;           /* Temp not defined   */
03459       ATD_CONST_IDX(attr_idx) = OPND_IDX(opnd);
03460       ATD_FLD(attr_idx)   = CN_Tbl_Idx;
03461       curr_stmt_sh_idx    = save_sh_idx;
03462       FREE_SH_NODE(bound_sh_idx);
03463       bound_sh_idx    = NULL_IDX;
03464    }
03465    else if (ATD_SYMBOLIC_CONSTANT(attr_idx)) {
03466 
03467       /* This is a symbolic constant expression.  A temp holds it. */
03468 
03469       curr_stmt_sh_idx    = save_sh_idx;
03470       FREE_SH_NODE(bound_sh_idx);
03471       bound_sh_idx    = NULL_IDX;
03472       ATD_FLD(attr_idx)   = OPND_FLD(opnd);
03473       ATD_TMP_IDX(attr_idx) = OPND_IDX(opnd);
03474    }
03475    else { 
03476 
03477       if (OPND_FLD(opnd) == AT_Tbl_Idx) {
03478 
03479          if (AT_IS_DARG(OPND_IDX(opnd))) {
03480 
03481             /* CIF wants to know if a bound is made up of just one dummy */
03482             /* argument.  NO expression.  AT_CIF_USE_IN_BND is set when  */
03483             /* this is found for a dummy argument.                       */
03484 
03485             AT_CIF_USE_IN_BND(OPND_IDX(opnd)) = TRUE;
03486          }
03487 
03488          /* Let PDGCS know if a temp is set to one var.  Give them       */
03489          /* the link between them.  Use ATD_DEFINING_ATTR_IDX.           */
03490 
03491          ATD_DEFINING_ATTR_IDX(attr_idx)  = OPND_IDX(opnd);
03492       }
03493 
03494       /* Make sure this is set to the correct addressing/offset type. */
03495 
03496       type_idx  = check_type_for_size_address(&opnd);
03497 
03498       COPY_OPND(IR_OPND_R(ATD_TMP_IDX(attr_idx)), opnd);
03499 
03500       /* Reset type if necessary on the Asg_Opr and bound tmp. */
03501 
03502       ATD_TYPE_IDX(attr_idx)      = type_idx;
03503       IR_TYPE_IDX(ATD_TMP_IDX(attr_idx))  = type_idx;
03504 
03505       /* SCP_TMP_LIST contains a list of dummy args referenced in this */
03506       /* expression.  If there are NO alternate entries, SCP_TMP_LIST  */
03507       /* will always be NULL.                                          */
03508 
03509       if (SCP_TMP_LIST(curr_scp_idx) != NULL_IDX) {
03510 
03511          /* Convert the bounds list of dargs that are used in this      */
03512          /* expression, but do not come in at every entry point, into   */
03513          /* a list of entry points where this expression cannot be.     */
03514 
03515          list_idx = SCP_TMP_LIST(curr_scp_idx);
03516 
03517          while (list_idx != NULL_IDX) {
03518             ATD_NO_ENTRY_LIST(attr_idx) = 
03519                 merge_entry_lists(ATD_NO_ENTRY_LIST(attr_idx),
03520                             (AT_OBJ_CLASS(AL_ATTR_IDX(list_idx)) == Data_Obj) ?
03521                                     ATD_NO_ENTRY_LIST(AL_ATTR_IDX(list_idx)) :
03522                                     ATP_NO_ENTRY_LIST(AL_ATTR_IDX(list_idx)));
03523             list_idx = AL_NEXT_IDX(list_idx);
03524          }
03525 
03526          free_attr_list(SCP_TMP_LIST(curr_scp_idx));
03527          SCP_TMP_LIST(curr_scp_idx) = NULL_IDX;
03528       }
03529 
03530       if (!insert_in_SH_stream) {
03531 
03532          /* Statement headers are not wanted.  Leave this as IR.  These tmps  */
03533          /* become place holders.  If this is a parameter bound, this is an   */
03534          /* error situation.  If this is an interface block, all these tmps   */
03535          /* are just place holders.  NOTE:  Cannot free IR, because IR can    */
03536          /* be shared and you could free IR that is used in other places.     */
03537 
03538          AT_REFERENCED(attr_idx)  = Not_Referenced;
03539          AT_DEFINED(attr_idx)   = FALSE;
03540 
03541          while (curr_stmt_sh_idx != NULL_IDX) {
03542             bound_sh_idx  = curr_stmt_sh_idx;
03543             curr_stmt_sh_idx  = SH_PREV_IDX(curr_stmt_sh_idx);
03544             FREE_SH_NODE(bound_sh_idx);
03545          }
03546          bound_sh_idx     = NULL_IDX;
03547          curr_stmt_sh_idx   = save_sh_idx;
03548       }
03549       else {
03550 
03551          /* can't assume that the SH_NEXT_IDX(save_sh_idx) is null */
03552 
03553          if (SH_NEXT_IDX(save_sh_idx) != NULL_IDX) {
03554             while (SH_NEXT_IDX(bound_sh_idx) != NULL_IDX) {
03555                bound_sh_idx = SH_NEXT_IDX(bound_sh_idx);
03556             }
03557             SH_NEXT_IDX(bound_sh_idx)      = SH_NEXT_IDX(save_sh_idx);
03558             if (SH_NEXT_IDX(bound_sh_idx)) {
03559                SH_PREV_IDX(SH_NEXT_IDX(bound_sh_idx)) = bound_sh_idx;
03560             }
03561          }
03562 
03563          while (SH_PREV_IDX(bound_sh_idx) != NULL_IDX) {
03564             bound_sh_idx = SH_PREV_IDX(bound_sh_idx);
03565          }
03566 
03567          SH_PREV_IDX(bound_sh_idx)  = save_sh_idx;
03568          SH_NEXT_IDX(save_sh_idx) = bound_sh_idx;
03569          AT_DEFINED(attr_idx)   = TRUE;
03570          AT_REFERENCED(attr_idx)  = Referenced;
03571       }
03572 
03573       /* Save the unexpanded IR, so it can be expanded later if this  */
03574       /* is part of a function that may be called.                    */
03575 
03576       /* Adjust type if necessary in the save unexpanded IR. */
03577 
03578       OPND_FLD(opnd)      = new_fld;
03579       OPND_IDX(opnd)      = new_ir_idx;
03580       OPND_LINE_NUM(opnd)   = AT_DEF_LINE(attr_idx);
03581       OPND_COL_NUM(opnd)    = AT_DEF_COLUMN(attr_idx);
03582 
03583       type_idx  = check_type_for_size_address(&opnd);
03584 
03585       ATD_FLD(attr_idx)     = OPND_FLD(opnd);
03586       ATD_TMP_IDX(attr_idx)   = OPND_IDX(opnd);
03587    }
03588 
03589    expr_mode = Regular_Expr;
03590 
03591    TRACE (Func_Exit, "bound_semantics", NULL);
03592 
03593    return(bound_sh_idx);
03594 
03595 }  /* bound_semantics */
03596 
03597 /******************************************************************************\
03598 |*                        *|
03599 |* Description:                     *|
03600 |*  This routine resolves the character length to a temp.                 *|
03601 |*      NOTE:  This does not handle component character lengths.  They are    *|
03602 |*      done in parse_cpnt_dcl_stmt.                                          *|
03603 |*                        *|
03604 |* Input parameters:                    *|
03605 |*      attr_idx -> Index to attribute for array.                             *|
03606 |*                        *|
03607 |* Output parameters:                   *|
03608 |*  NONE                      *|
03609 |*                        *|
03610 |* Returns:                     *|
03611 |*  NONE                      *|
03612 |*                        *|
03613 \******************************************************************************/
03614 void  char_len_resolution(int   attr_idx,
03615           boolean must_be_const_array)
03616 
03617 {
03618    int    column;
03619    int    entry_count;
03620    int    ir_idx;
03621    boolean  is_interface;
03622    int    len_entry_count;
03623    int    len_idx;
03624    int    line;
03625    int    list_idx;
03626    int    max_idx;
03627    int    new_len_idx;
03628    opnd_type  opnd;
03629 #ifdef KEY /* Bug 10177 */
03630    int    sh_idx = 0;
03631 #else /* KEY Bug 10177 */
03632    int    sh_idx;
03633 #endif /* KEY Bug 10177 */
03634    int    tmp_attr_idx;
03635    int    t_idx;
03636    int    type_idx;
03637    int    zero_idx;
03638 
03639 
03640    TRACE (Func_Entry, "char_len_resolution", NULL);
03641 
03642    is_interface = SCP_IS_INTERFACE(curr_scp_idx);
03643    type_idx = ATD_TYPE_IDX(attr_idx);
03644 
03645    if (TYP_CHAR_CLASS(type_idx) == Unknown_Char) {
03646 
03647       if (AT_OBJ_CLASS(TYP_IDX(type_idx)) == Data_Obj && 
03648           ATD_CLASS(TYP_IDX(type_idx)) == Constant) {
03649          TYP_IDX(type_idx)    = ATD_CONST_IDX(TYP_IDX(type_idx));
03650          TYP_FLD(type_idx)    = CN_Tbl_Idx;
03651          TYP_CHAR_CLASS(type_idx) = Const_Len_Char;
03652       }
03653       else if (AT_OBJ_CLASS(TYP_IDX(type_idx)) == Data_Obj && 
03654                ATD_SYMBOLIC_CONSTANT(TYP_IDX(type_idx))) {
03655 
03656          PRINTMSG(AT_DEF_LINE(attr_idx), 1211, Error, 
03657                   AT_DEF_COLUMN(attr_idx),
03658                   AT_OBJ_NAME_PTR(attr_idx));
03659          AT_DCL_ERR(attr_idx) = TRUE;
03660          ATD_TYPE_IDX(attr_idx) = CHARACTER_DEFAULT_TYPE;
03661       }
03662       else {
03663          TYP_CHAR_CLASS(type_idx) = Var_Len_Char;
03664          TYP_ORIG_LEN_IDX(type_idx) = TYP_IDX(type_idx);
03665       }
03666    }
03667 
03668    if (TYP_CHAR_CLASS(type_idx) == Var_Len_Char) {
03669 
03670       /* This is called from PARAMETER processing.  This must be a const  */
03671       /* length array.  If it is not, do not process now.  It will happen */
03672       /* at decl_sematics time.  PARAMETER processing will issue error.   */
03673 
03674       if (must_be_const_array) {
03675          goto EXIT;
03676       }
03677 
03678       if (fnd_semantic_err(Obj_Var_Len_Ch,
03679                            AT_DEF_LINE(attr_idx),
03680                            AT_DEF_COLUMN(attr_idx),
03681                            attr_idx,
03682                            TRUE)) {
03683          ATD_TYPE_IDX(attr_idx) = CHARACTER_DEFAULT_TYPE;
03684       }
03685       else if (ATD_CLASS(attr_idx) == Function_Result && 
03686                !ATP_EXPL_ITRFC(ATD_FUNC_IDX(attr_idx))) {
03687          PRINTMSG(AT_DEF_LINE(attr_idx), 916, Error, 
03688                   AT_DEF_COLUMN(attr_idx),
03689                   AT_OBJ_NAME_PTR(ATD_FUNC_IDX(attr_idx)));
03690          AT_DCL_ERR(attr_idx) = TRUE;
03691          ATD_TYPE_IDX(attr_idx) = CHARACTER_DEFAULT_TYPE;
03692       }
03693       else {
03694 
03695          if (!TYP_RESOLVED(type_idx)) {
03696 
03697             /* generate max(0,length) - then switch length to new tmp */
03698 
03699             NTR_IR_TBL(max_idx);
03700             IR_OPR(max_idx)   = Max_Opr;
03701             IR_LINE_NUM(max_idx)  = AT_DEF_LINE(attr_idx);
03702             IR_COL_NUM(max_idx)   = AT_DEF_COLUMN(attr_idx);
03703             IR_LIST_CNT_L(max_idx)  = 2;
03704 
03705             NTR_IR_LIST_TBL(list_idx);
03706             IR_FLD_L(max_idx)   = IL_Tbl_Idx;
03707             IR_IDX_L(max_idx)   = list_idx;
03708 
03709             OPND_FLD(opnd)    = TYP_FLD(type_idx);
03710             OPND_IDX(opnd)    = TYP_IDX(type_idx);
03711             OPND_LINE_NUM(opnd)   = AT_DEF_LINE(attr_idx);
03712             OPND_COL_NUM(opnd)    = AT_DEF_COLUMN(attr_idx);
03713             t_idx     = check_type_for_size_address(&opnd);
03714 
03715             COPY_OPND(IL_OPND(list_idx), opnd);
03716 
03717             IR_TYPE_IDX(max_idx)  = t_idx;
03718 
03719             NTR_IR_LIST_TBL(zero_idx);
03720             IL_NEXT_LIST_IDX(list_idx)  = zero_idx;
03721             IL_PREV_LIST_IDX(zero_idx)  = list_idx;
03722             IL_FLD(zero_idx)        = CN_Tbl_Idx;
03723             IL_IDX(zero_idx)        = CN_INTEGER_ZERO_IDX;
03724             IL_LINE_NUM(zero_idx) = AT_DEF_LINE(attr_idx);
03725             IL_COL_NUM(zero_idx)  = AT_DEF_COLUMN(attr_idx);
03726 
03727             if (!is_interface) {
03728                sh_idx     = ntr_sh_tbl();
03729                SH_STMT_TYPE(sh_idx) = Automatic_Base_Size_Stmt;
03730                SH_P2_SKIP_ME(sh_idx)  = TRUE;
03731                SH_COMPILER_GEN(sh_idx)  = TRUE;
03732                SH_GLB_LINE(sh_idx)  = stmt_start_line;
03733                SH_COL_NUM(sh_idx) = stmt_start_col;
03734             }
03735 
03736             OPND_FLD(opnd)  = IR_Tbl_Idx;
03737             OPND_IDX(opnd)  = max_idx;
03738             OPND_LINE_NUM(opnd) = stmt_start_line;
03739             OPND_COL_NUM(opnd)  = stmt_start_col;
03740             new_len_idx   = ntr_bnds_sh_tmp_list(
03741                                            &opnd,
03742                                            ATD_NO_ENTRY_LIST(TYP_IDX(type_idx)),
03743                                            (is_interface) ? NULL_IDX : sh_idx,
03744                                            TRUE,
03745                                            t_idx);
03746 
03747             TYP_FLD(type_idx) = AT_Tbl_Idx;
03748             TYP_IDX(type_idx) = new_len_idx;
03749 
03750             if (ATD_NO_ENTRY_LIST(new_len_idx) != NULL_IDX) {
03751                entry_count = SCP_ALT_ENTRY_CNT(curr_scp_idx) + 1;
03752 
03753                if (entry_count==AL_ENTRY_COUNT(ATD_NO_ENTRY_LIST(new_len_idx))){
03754 
03755                   /* The length for this character cannot be calculated at    */
03756                   /* any entry point, because dargs used in the expression do */
03757                   /* not enter at all the same points.                        */
03758 
03759                   PRINTMSG(AT_DEF_LINE(attr_idx), 659, Error,
03760                            AT_DEF_COLUMN(attr_idx), 
03761                            AT_OBJ_NAME_PTR(attr_idx));
03762                   AT_DCL_ERR(attr_idx)  = TRUE;
03763                }
03764                else if (ATD_ARRAY_IDX(attr_idx) == NULL_IDX) {
03765                   len_entry_count =
03766                       merge_entry_list_count(ATD_NO_ENTRY_LIST(new_len_idx),
03767                             ((ATD_CLASS(attr_idx) == Function_Result) ?
03768                                  ATP_NO_ENTRY_LIST(ATD_FUNC_IDX(attr_idx)) :
03769                                  ATD_NO_ENTRY_LIST(attr_idx)));
03770    
03771                   if (entry_count == len_entry_count) {
03772                      PRINTMSG(AT_DEF_LINE(attr_idx), 662, Error,
03773                               AT_DEF_COLUMN(attr_idx), 
03774                               AT_OBJ_NAME_PTR(attr_idx));
03775                      AT_DCL_ERR(attr_idx) = TRUE;
03776                   }
03777                   else if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
03778                            ATD_CLASS(attr_idx) == Variable) {
03779                      PRINTMSG(AT_DEF_LINE(attr_idx), 1046, Caution,
03780                               AT_DEF_COLUMN(attr_idx),
03781                               AT_OBJ_NAME_PTR(attr_idx));
03782                   }
03783                }
03784             }
03785          }
03786 
03787          if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
03788 
03789             if (ATD_CLASS(attr_idx) != Function_Result &&
03790                 ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Function &&
03791                 ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Subroutine) {
03792                PRINTMSG(AT_DEF_LINE(attr_idx), 1014, Error,
03793                         AT_DEF_COLUMN(attr_idx), 
03794                         AT_OBJ_NAME_PTR(attr_idx));
03795                AT_DCL_ERR(attr_idx) = TRUE;
03796             }
03797             if (ATD_PE_ARRAY_IDX(attr_idx) != NULL_IDX) {
03798                PRINTMSG(AT_DEF_LINE(attr_idx), 1577, Error,
03799                         AT_DEF_COLUMN(attr_idx),
03800                         AT_OBJ_NAME_PTR(attr_idx));
03801                AT_DCL_ERR(attr_idx) = TRUE;
03802             }
03803             else if (ATD_CLASS(attr_idx) == Variable) {
03804                ATD_AUTOMATIC(attr_idx)  = TRUE;
03805             }
03806          }
03807       }
03808    }
03809    else if (TYP_CHAR_CLASS(type_idx) == Assumed_Size_Char) {
03810 
03811       /* This is called from PARAMETER processing.  This must be a const  */
03812       /* length array.  If it is not, do not process now.  It will happen */
03813       /* at decl_sematics time.  PARAMETER processing will issue error.   */
03814 
03815       if (must_be_const_array) {
03816          goto EXIT;
03817       }
03818 
03819       if (AT_OBJ_CLASS(attr_idx) == Stmt_Func) {
03820          ATD_TYPE_IDX(attr_idx) = CHARACTER_DEFAULT_TYPE;
03821       }
03822       else {
03823 
03824          switch (ATD_CLASS(attr_idx)) {
03825          case Function_Result:
03826 
03827             if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX || ATD_POINTER(attr_idx)) {
03828                PRINTMSG(AT_DEF_LINE(attr_idx), 507, Error,
03829                         AT_DEF_COLUMN(attr_idx),
03830                         AT_OBJ_NAME_PTR(attr_idx));
03831                AT_DCL_ERR(attr_idx)     = TRUE;
03832                AT_DCL_ERR(ATD_FUNC_IDX(attr_idx)) = TRUE;
03833                break;
03834             }
03835 
03836             if (ATD_FUNC_IDX(attr_idx) != SCP_ATTR_IDX(curr_scp_idx) &&
03837                 !ATP_ALT_ENTRY(ATD_FUNC_IDX(attr_idx)) &&
03838                 ATP_PROC(ATD_FUNC_IDX(attr_idx)) != Dummy_Proc) {
03839                PRINTMSG(AT_DEF_LINE(attr_idx), 1107, Error,
03840                         AT_DEF_COLUMN(attr_idx),
03841                         AT_OBJ_NAME_PTR(ATD_FUNC_IDX(attr_idx)));
03842                AT_DCL_ERR(attr_idx)     = TRUE;
03843                AT_DCL_ERR(ATD_FUNC_IDX(attr_idx)) = TRUE;
03844                break;
03845             }
03846 
03847             /* This is an intentional fall through.  All character*(*) */
03848             /* function results will be passed thru the interface as   */
03849             /* dummy arguments.                                        */
03850 
03851          case Dummy_Argument:
03852 
03853             /* Generate tmp = clen(attr).  This must go on the bound list */
03854             /* because this is a dummy argument.                          */
03855 
03856             NTR_IR_TBL(len_idx);
03857             IR_OPR(len_idx)   = Clen_Opr;
03858             IR_TYPE_IDX(len_idx)        = SA_INTEGER_DEFAULT_TYPE;
03859             IR_LINE_NUM(len_idx)  = AT_DEF_LINE(attr_idx);  
03860             IR_COL_NUM(len_idx)   = AT_DEF_COLUMN(attr_idx);  
03861 
03862             if (ATD_CLASS(attr_idx) == Function_Result &&
03863                 ATP_PROC(ATD_FUNC_IDX(attr_idx)) == Dummy_Proc) {
03864                IR_IDX_L(len_idx)  = ATD_FUNC_IDX(attr_idx); 
03865             }
03866             else {
03867                IR_IDX_L(len_idx)  = attr_idx;
03868             }
03869 
03870             IR_FLD_L(len_idx)   = AT_Tbl_Idx;
03871             IR_LINE_NUM_L(len_idx)  = AT_DEF_LINE(attr_idx);  
03872             IR_COL_NUM_L(len_idx) = AT_DEF_COLUMN(attr_idx);  
03873 
03874             OPND_FLD(opnd)    = IR_Tbl_Idx;
03875             OPND_IDX(opnd)    = len_idx;
03876             OPND_LINE_NUM(opnd)   = AT_DEF_LINE(attr_idx);
03877             OPND_COL_NUM(opnd)    = AT_DEF_COLUMN(attr_idx);
03878 
03879             {
03880                expr_arg_type  exp_desc;
03881                fold_clen_opr(&opnd, &exp_desc);
03882             }
03883 
03884             gen_sh(After,
03885                    Automatic_Base_Size_Stmt,
03886                    stmt_start_line,
03887                    stmt_start_col,
03888                    FALSE,
03889                    FALSE,
03890                    TRUE);
03891 
03892             find_opnd_line_and_column(&opnd, &line, &column);
03893             GEN_COMPILER_TMP_ASG(ir_idx,
03894                                  tmp_attr_idx,
03895                                  TRUE,    /* Semantics is done */
03896                                  line,
03897                                  column,
03898                                  SA_INTEGER_DEFAULT_TYPE,
03899                                  Priv);
03900    
03901             COPY_OPND(IR_OPND_R(ir_idx), opnd);      /* IR_OPND_R = opnd */
03902 
03903             SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
03904             SH_IR_IDX(curr_stmt_sh_idx)   = ir_idx;
03905             ATD_TMP_IDX(tmp_attr_idx)   = ir_idx;
03906             ATD_FLD(tmp_attr_idx)   = IR_Tbl_Idx;
03907 
03908             /* Create new entry, because each assumed sized darg has a     */
03909             /* different tmp to go with it.                                */
03910 
03911             type_tbl[TYP_WORK_IDX]  = type_tbl[ATD_TYPE_IDX(attr_idx)];
03912             TYP_FLD(TYP_WORK_IDX) = AT_Tbl_Idx;
03913             TYP_IDX(TYP_WORK_IDX) = tmp_attr_idx;
03914 
03915             ATD_TYPE_IDX(attr_idx)  = ntr_type_tbl();
03916 
03917             /* insert_sh_after_entries will handle this code at alternate  */
03918             /* entry points.  It will also take care of any OPTIONAL stuff */
03919             /* that needs to be generated.                                 */
03920 
03921             insert_sh_after_entries(attr_idx,
03922                                     SH_PREV_IDX(curr_stmt_sh_idx),
03923                                     curr_stmt_sh_idx,
03924                                     FALSE,     /* Don't generate tmp = 0  */
03925                                     TRUE);     /* Advance ATP_FIRST_SH_IDX */
03926             break;
03927 
03928          case CRI__Pointee:
03929            
03930             /* TYP_IDX becomes the attr index of the pointer.  A new entry    */
03931             /* is made, because this entry cannot share with another.         */
03932 
03933             type_tbl[TYP_WORK_IDX]  = type_tbl[ATD_TYPE_IDX(attr_idx)];
03934             TYP_FLD(TYP_WORK_IDX) = AT_Tbl_Idx;
03935             TYP_IDX(TYP_WORK_IDX) = ATD_PTR_IDX(attr_idx);
03936 
03937             ATD_TYPE_IDX(attr_idx)  = ntr_type_tbl();
03938             break;
03939 
03940          case Constant:
03941             break;
03942 
03943          default: /* This must be a darg, constant, or CRI pointee */
03944             PRINTMSG(AT_DEF_LINE(attr_idx), 350, Error,
03945                      AT_DEF_COLUMN(attr_idx),
03946                      AT_OBJ_NAME_PTR(attr_idx));
03947             AT_DCL_ERR(attr_idx) = TRUE;
03948             break;
03949          }  /* End switch */
03950       }
03951    }
03952    else if (TYP_CHAR_CLASS(type_idx) == Const_Len_Char) {
03953 
03954       if (compare_cn_and_value(TYP_IDX(type_idx), 0, Lt_Opr)) {
03955          type_tbl[TYP_WORK_IDX]   = type_tbl[type_idx];
03956          TYP_IDX(TYP_WORK_IDX)    = CN_INTEGER_ZERO_IDX;
03957          ATD_TYPE_IDX(attr_idx)   = ntr_type_tbl();
03958       }
03959       else if (compare_cn_and_value(TYP_IDX(type_idx), 
03960                                     max_character_length, 
03961                                     Gt_Opr) &&
03962                TYP_TYPE(CN_TYPE_IDX(TYP_IDX(type_idx))) == Integer) {
03963 
03964          PRINTMSG(AT_DEF_LINE(attr_idx), 35, Error,
03965                   AT_DEF_COLUMN(attr_idx),
03966                   AT_OBJ_NAME_PTR(attr_idx),
03967                   max_character_length);
03968 
03969          type_tbl[TYP_WORK_IDX] = type_tbl[type_idx];
03970          TYP_IDX(TYP_WORK_IDX)  = C_INT_TO_CN(CN_TYPE_IDX(TYP_IDX(type_idx)),
03971                                               max_character_length);
03972          ATD_TYPE_IDX(attr_idx) = ntr_type_tbl();
03973          AT_DCL_ERR(attr_idx) = TRUE;
03974       }
03975    }
03976 
03977 EXIT:
03978 
03979    TYP_RESOLVED(ATD_TYPE_IDX(attr_idx)) = TRUE;
03980 
03981    TRACE (Func_Exit, "char_len_resolution", NULL);
03982 
03983    return;
03984 
03985 }  /* char_len_resolution */
03986 
03987 /******************************************************************************\
03988 |*                                                                            *|
03989 |* Description:                                                               *|
03990 |*      compares two dummy arguments for type, kind type, and rank.           *|
03991 |*  This is used for verifyng interfaces and for interface resolution.    *|
03992 |*                                                                            *|
03993 |* Input parameters:                                                          *|
03994 |*      idx1, idx2 - the two dummies.                                         *|
03995 |*                                                                            *|
03996 |* Output parameters:                                                         *|
03997 |*      NONE                                                                  *|
03998 |*                                                                            *|
03999 |* Returns:                                                                   *|
04000 |*      TRUE is same in all three categories.                                 *|
04001 |*      FALSE otherwise.                                                      *|
04002 |*                                                                            *|
04003 \******************************************************************************/
04004 boolean  compare_dummy_arguments(int      idx1,
04005          int      idx2)
04006 
04007 {
04008    int    i;
04009    boolean      same    = TRUE;
04010 
04011 
04012    TRACE (Func_Entry, "compare_dummy_arguments", NULL);
04013 
04014    if (AT_OBJ_CLASS(idx1) == AT_OBJ_CLASS(idx2)) {
04015 
04016       if (AT_OBJ_CLASS(idx1) == Pgm_Unit) {
04017 
04018          if (!ATP_EXPL_ITRFC(idx1) || !ATP_EXPL_ITRFC(idx2)) {
04019 
04020             /* We can only disambiguate, if an explicit interface */ 
04021             /* is specified for the dummy procedure.              */
04022 
04023             same = FALSE;
04024          }
04025          else if (ATP_PGM_UNIT(idx1) != ATP_PGM_UNIT(idx2) &&
04026                   ATP_PGM_UNIT(idx1) != Pgm_Unknown &&
04027                   ATP_PGM_UNIT(idx2) != Pgm_Unknown) {
04028             same = FALSE; /* Have func vs Subr */
04029          }
04030          else {
04031 
04032             if (ATP_PGM_UNIT(idx1) == ATP_PGM_UNIT(idx2) &&
04033                 ATP_PGM_UNIT(idx2) == Function) {
04034 
04035                /* Both functions - compare results */
04036 
04037                same = compare_darg_or_rslt_types(ATP_RSLT_IDX(idx1),
04038                                                  ATP_RSLT_IDX(idx2));
04039             }
04040 
04041             if (same) {  /* Compare the dargs */
04042 
04043                if (ATP_NUM_DARGS(idx1) != ATP_NUM_DARGS(idx2)) {
04044                   same = FALSE;
04045                }
04046                else {
04047 
04048                   /* We know the result type is the same, so either both */
04049                   /* have ATP_EXTRA_DARG set or both have it FALSE.      */
04050 
04051                   for (i = (ATP_EXTRA_DARG(idx1) ? 1 : 0);
04052                        i < ATP_NUM_DARGS(idx1); i++) {
04053                      same = compare_dummy_arguments(
04054                                     SN_ATTR_IDX((ATP_FIRST_IDX(idx1)+i)),
04055                                     SN_ATTR_IDX((ATP_FIRST_IDX(idx2)+i)));
04056 
04057                      if (!same) break;
04058                   }
04059                }
04060             }
04061          }
04062       }
04063       else if (AT_OBJ_CLASS(idx1) == Data_Obj) {
04064 
04065          if (ATD_CLASS(idx1) == ATD_CLASS(idx2)) {
04066 
04067             /* If either one is IGNORE_TKR they are the same type and rank. */
04068 
04069             if (ATD_CLASS(idx1) == Dummy_Argument && 
04070                 !ATD_IGNORE_TKR(idx1) && !ATD_IGNORE_TKR(idx2)) {
04071                same = compare_darg_or_rslt_types(idx1, idx2);
04072             }
04073          }
04074          else {
04075             same = FALSE;
04076          }
04077       }
04078    }
04079    else {
04080       same = FALSE;
04081    }
04082 
04083    TRACE (Func_Exit, "compare_dummy_arguments", NULL);
04084 
04085    return(same);
04086 
04087 }  /* compare_dummy_arguments */
04088 
04089 /******************************************************************************\
04090 |*                        *|
04091 |* Description:                     *|
04092 |*  This routine does the semantic error checking between the function    *|
04093 |*  result name and entry names.                                          *|
04094 |*                        *|
04095 |* Input parameters:                    *|
04096 |*  rslt_idx        -> attr idx for the result name.          *|
04097 |*  pgm_rslt_idx    -> Result index for the external program.       *|
04098 |*                        *|
04099 |* Output parameters:                   *|
04100 |*  NONE                      *|
04101 |*                        *|
04102 |* Returns:                     *|
04103 |*  NONE                      *|
04104 |*                        *|
04105 \******************************************************************************/
04106 static void compare_entry_to_func_rslt(int  attr_idx,
04107                int  pgm_rslt_idx)
04108 {
04109    int    column;
04110    int    idx;
04111    int    line;
04112    int    loop;
04113 #ifdef KEY /* Bug 10177 */
04114    boolean  not_a_match = FALSE;
04115 #else /* KEY Bug 10177 */
04116    boolean  not_a_match;
04117 #endif /* KEY Bug 10177 */
04118    int    pgm_type_idx;
04119    int    rslt_idx;
04120    int    rslt_type_idx;
04121 
04122 
04123    TRACE (Func_Entry, "compare_entry_to_func_rslt", NULL);
04124 
04125    line   = AT_DEF_LINE(attr_idx);
04126    column = AT_DEF_COLUMN(attr_idx);
04127    rslt_idx = ATP_RSLT_IDX(attr_idx);
04128    rslt_type_idx= ATD_TYPE_IDX(rslt_idx);
04129    pgm_type_idx = ATD_TYPE_IDX(pgm_rslt_idx);
04130 
04131 
04132    if (ATD_ARRAY_IDX(rslt_idx) != NULL_IDX &&
04133        BD_ARRAY_SIZE(ATD_ARRAY_IDX(rslt_idx)) == Symbolic_Constant_Size) {
04134       PRINTMSG(line, 1230, Error, column, AT_OBJ_NAME_PTR(attr_idx));
04135    }
04136    else if (ATD_ARRAY_IDX(rslt_idx) != ATD_ARRAY_IDX(pgm_rslt_idx) &&
04137        !compare_array_entries(ATD_ARRAY_IDX(rslt_idx),
04138                               ATD_ARRAY_IDX(pgm_rslt_idx))) {
04139       PRINTMSG(line, 673, Error, column, AT_OBJ_NAME_PTR(pgm_rslt_idx),
04140                                          AT_OBJ_NAME_PTR(rslt_idx));
04141    }
04142    else if (ATD_POINTER(pgm_rslt_idx) != ATD_POINTER(rslt_idx)) {
04143          PRINTMSG(line, 674, Error, column, AT_OBJ_NAME_PTR(pgm_rslt_idx),
04144                                            AT_OBJ_NAME_PTR(rslt_idx));
04145    }
04146    else if (TYP_TYPE(ATD_TYPE_IDX(rslt_idx)) !=
04147             TYP_TYPE(ATD_TYPE_IDX(pgm_rslt_idx))) {
04148 
04149       if (TYP_TYPE(rslt_type_idx) > Complex || 
04150           TYP_TYPE(pgm_type_idx) > Complex) {
04151          PRINTMSG(line, 21, Error, column, AT_OBJ_NAME_PTR(pgm_rslt_idx),
04152                                            AT_OBJ_NAME_PTR(rslt_idx));
04153       }
04154 # if defined(_TARGET_OS_MAX)
04155 
04156       else if (cmd_line_flags.integer_32 &&
04157                !cmd_line_flags.s_default32 &&
04158                ((TYP_TYPE(rslt_type_idx) == Integer &&
04159                  TYP_DESC(rslt_type_idx) == Default_Typed) ||
04160                 (TYP_TYPE(pgm_type_idx) == Integer &&
04161                  TYP_DESC(pgm_type_idx) == Default_Typed))) {
04162 
04163          if (TYP_TYPE(rslt_type_idx) == Integer) {
04164             PRINTMSG(line, 1195, Warning, column, 
04165                      AT_OBJ_NAME_PTR(rslt_idx),
04166                      AT_OBJ_NAME_PTR(pgm_rslt_idx));
04167          }
04168          else {
04169             PRINTMSG(line, 1195, Warning, column, 
04170                      AT_OBJ_NAME_PTR(pgm_rslt_idx),
04171                      AT_OBJ_NAME_PTR(rslt_idx));
04172          }
04173       }
04174 # endif
04175       else if (on_off_flags.issue_ansi_messages ||
04176                GET_MESSAGE_TBL(message_warning_tbl, 22) ||
04177                GET_MESSAGE_TBL(message_error_tbl, 22)) {
04178 
04179          /* The standard requires mixed types (COMPLEX, LOGICAL, INTEGER,  */
04180          /* REAL) to all be of default type.  If ANSI checking is on, this */
04181          /* for/switch checks the rslt_idx and then the pgm_rslt_idx to see*/
04182          /* if any are non_default types.  An ANSI msg is issued if found. */
04183            
04184          idx  = rslt_idx;
04185 
04186          for (loop = 1; loop <=2; loop++) {
04187 
04188             switch (TYP_TYPE(ATD_TYPE_IDX(idx))) {
04189             case Logical:
04190                not_a_match = TYP_LINEAR(ATD_TYPE_IDX(idx)) != 
04191                                                           LOGICAL_DEFAULT_TYPE;
04192                break;
04193 
04194             case Complex:
04195                not_a_match = TYP_LINEAR(ATD_TYPE_IDX(idx)) !=
04196                                                           COMPLEX_DEFAULT_TYPE;
04197                break;
04198 
04199             case Integer:
04200                not_a_match = TYP_LINEAR(ATD_TYPE_IDX(idx)) !=
04201                                                           INTEGER_DEFAULT_TYPE;
04202                break;
04203 
04204             case Real:
04205                not_a_match = (TYP_LINEAR(ATD_TYPE_IDX(idx)) !=
04206                                            REAL_DEFAULT_TYPE &&
04207                               TYP_LINEAR(ATD_TYPE_IDX(idx)) !=
04208                                            DOUBLE_DEFAULT_TYPE);
04209                break;
04210             }  /* switch */
04211 
04212             if (not_a_match) {
04213                PRINTMSG(line, 22, Ansi, column, AT_OBJ_NAME_PTR(idx));
04214             }
04215 
04216             idx = pgm_rslt_idx;
04217          }  /* end FOR */
04218       }
04219    }
04220    else if (TYP_LINEAR(rslt_type_idx) == TYP_LINEAR(pgm_type_idx) &&
04221             TYP_IDX(rslt_type_idx) == TYP_IDX(pgm_type_idx)) {
04222 
04223       /* This is the same linear type or the same character length or the */
04224       /* same structure.   Intentionally left blank.                      */
04225    }
04226    else if (TYP_TYPE(rslt_type_idx) == Character) {
04227 
04228       /* Do not issue the error, if they are both variable length, because */
04229       /* this cannot be detected at compile time.                          */
04230 
04231       if (TYP_CHAR_CLASS(rslt_type_idx) == Const_Len_Char &&
04232           TYP_CHAR_CLASS(pgm_type_idx) == Const_Len_Char &&
04233           fold_relationals(TYP_IDX(rslt_type_idx), 
04234                            TYP_IDX(pgm_type_idx), Ne_Opr)) {
04235          PRINTMSG(line, 21, Error, column, AT_OBJ_NAME_PTR(pgm_rslt_idx),
04236                                            AT_OBJ_NAME_PTR(rslt_idx));
04237       }
04238    }
04239    else if (TYP_TYPE(rslt_type_idx) == Structure) {
04240 
04241       /* Both are structures with different structure indexes.   Check if  */
04242       /* the structures are the same.                                      */
04243 
04244       if (!compare_derived_types(rslt_type_idx, pgm_type_idx)) {
04245          PRINTMSG(line, 21, Error, column, AT_OBJ_NAME_PTR(pgm_rslt_idx),
04246                                            AT_OBJ_NAME_PTR(rslt_idx));
04247       }
04248    }
04249    else if (on_off_flags.issue_ansi_messages ||
04250             GET_MESSAGE_TBL(message_warning_tbl, 13) ||
04251             GET_MESSAGE_TBL(message_error_tbl, 13)) {
04252 
04253 
04254       /* Types match, but TYPE_IDX differs.  This means that both cannot   */
04255       /* be default types (unless one is default real and the other is     */
04256       /* default double precision.), so if ANSI checking, issue msg.       */
04257 
04258       if ((TYP_TYPE(rslt_type_idx) == Real) &&
04259           (TYP_LINEAR(rslt_type_idx) == REAL_DEFAULT_TYPE ||
04260            TYP_LINEAR(rslt_type_idx) == DOUBLE_DEFAULT_TYPE) &&
04261           (TYP_LINEAR(pgm_type_idx) == REAL_DEFAULT_TYPE ||
04262            TYP_LINEAR(pgm_type_idx) == DOUBLE_DEFAULT_TYPE)) {
04263          /* This is double precision default and a real default -ok no msg */
04264       }
04265       else {
04266          PRINTMSG(line, 13, Ansi, column, AT_OBJ_NAME_PTR(pgm_rslt_idx),
04267                                           AT_OBJ_NAME_PTR(rslt_idx));
04268       }
04269    }
04270 
04271    TRACE (Func_Exit, "compare_entry_to_func_rslt", NULL);
04272 
04273    return;
04274 
04275 }  /* compare_entry_to_func_rslt */
04276 
04277 /******************************************************************************\
04278 |*                        *|
04279 |* Description:                     *|
04280 |*  This does semantic checking for the declaration statements.           *|
04281 |*                        *|
04282 |* Input parameters:                    *|
04283 |*  NONE                      *|
04284 |*                        *|
04285 |* Output parameters:                   *|
04286 |*  NONE                      *|
04287 |*                        *|
04288 |* Returns:                     *|
04289 |*  NONE                      *|
04290 |*                        *|
04291 \******************************************************************************/
04292 void  decl_semantics(void)
04293 
04294 {
04295    int    al_idx;
04296    int    attr_idx;
04297    int    count;
04298    int    darg_idx;
04299    int    darg_list_idx;
04300    int    eq_idx;
04301    int    entry_attr_idx;
04302    int    entry_idx;
04303    int    entry_list_idx;
04304    int    group;
04305    int    idx;
04306    int    label_sh_idx;
04307    int    line;
04308    int    list_idx;
04309    int    list_idx2;
04310    int    name_idx;
04311    opnd_type  opnd;
04312    int    pgm_attr_idx;
04313    int    prev_idx;
04314    boolean  recursive;
04315    int    rslt_idx;
04316    int    save_curr_stmt_sh_idx;
04317    int          sh_after_entry_idx;
04318 
04319 
04320    TRACE (Func_Entry, "decl_semantics",  NULL);
04321 
04322    pgm_attr_idx = SCP_ATTR_IDX(curr_scp_idx);
04323 
04324    /* Implement the save all commandline option  -ev */
04325 
04326    if (on_off_flags.save_all_vars) {
04327 
04328       if (ATP_RECURSIVE(pgm_attr_idx)) {
04329          PRINTMSG(AT_DEF_LINE(pgm_attr_idx), 1103, Caution,
04330                   AT_DEF_COLUMN(pgm_attr_idx),
04331                   AT_OBJ_NAME_PTR(pgm_attr_idx));
04332       }
04333       else if (SCP_PARENT_IDX(curr_scp_idx) != NULL_IDX) {
04334 
04335             /* Check if the parent is recursive. */
04336 
04337          idx            = SCP_PARENT_IDX(curr_scp_idx);
04338          recursive      = FALSE;
04339 
04340          do {
04341 
04342             if (ATP_RECURSIVE(SCP_ATTR_IDX(idx))) {
04343                recursive = TRUE;
04344                break;
04345             }
04346             idx = SCP_PARENT_IDX(idx);
04347          }
04348          while (idx != NULL_IDX);
04349 
04350          if (!recursive) {
04351             ATP_SAVE_ALL(pgm_attr_idx) = TRUE;
04352          }
04353       }
04354       else {
04355          ATP_SAVE_ALL(pgm_attr_idx) = TRUE;
04356       }
04357    }
04358 
04359    /* Set the default storage for this procedure. */
04360 
04361    if (ATP_PGM_UNIT(pgm_attr_idx) == Module) {
04362        SCP_DEFAULT_STORAGE(curr_scp_idx) = Static;
04363    }
04364    else if (!ATP_SAVE_ALL(pgm_attr_idx) ||
04365              ATP_STACK_DIR(pgm_attr_idx) ||
04366              ATP_RECURSIVE(pgm_attr_idx) ||
04367              (on_off_flags.recursive &&
04368               (ATP_PGM_UNIT(pgm_attr_idx) == Function ||
04369                ATP_PGM_UNIT(pgm_attr_idx) == Subroutine))) {
04370        SCP_DEFAULT_STORAGE(curr_scp_idx) = Stack;
04371    }
04372    else {
04373        SCP_DEFAULT_STORAGE(curr_scp_idx) = Static;
04374    }
04375 
04376    /* Set up global variables needed for decl_semantics and attr_semantics.  */
04377 
04378    allocatable_list_idx   = NULL_IDX;
04379    namelist_list_idx    = NULL_IDX;
04380    number_of_allocatables = 0;
04381    pointee_based_blk    = NULL_IDX;
04382    alt_entry_equiv_blk    = NULL_IDX;
04383    alt_entry_equiv_grp    = NULL_IDX;
04384    reshape_array_list   = NULL_IDX;
04385    init_sh_start_idx    = NULL_IDX;
04386    init_sh_end_idx    = NULL_IDX;
04387 
04388    /* At entry curr_stmt_sh_idx is set to the first stmt of the pgm unit.    */
04389    /* All entry code will insert after curr_stmt_sh_idx.  After the symbol   */
04390    /* table is gone through the rest of the IR must be connected back up to  */
04391    /* curr_stmt_sh_idx.                                                      */
04392 
04393    sh_after_entry_idx     = SH_NEXT_IDX(curr_stmt_sh_idx);
04394    SH_NEXT_IDX(curr_stmt_sh_idx)        = NULL_IDX;
04395    SH_PREV_IDX(sh_after_entry_idx)      = NULL_IDX;
04396 
04397    if (cmd_line_flags.debug_lvl <= Debug_Lvl_1 &&
04398        ATP_PGM_UNIT(pgm_attr_idx) <= Program) {
04399 
04400       /* If -G0 or  -G1 specified and this is not a module or blockdata, */
04401       /* we need to correct the line number for the Ldbg_End_Prologue    */
04402       /* label.  The label needs to point to the first executable        */
04403       /* statement.  Pass up all data and initialization statements.     */
04404       /* These do not count as executable statements for debug.          */
04405 
04406       idx   = SH_NEXT_IDX(sh_after_entry_idx);
04407       label_sh_idx  = sh_after_entry_idx;
04408 
04409       while (SH_STMT_TYPE(idx) == Type_Init_Stmt ||
04410              SH_STMT_TYPE(idx) == Data_Stmt) {
04411             idx = SH_NEXT_IDX(idx);
04412       }
04413 
04414       if (idx != SH_NEXT_IDX(sh_after_entry_idx)) {
04415  
04416          /* Move End_Prologue_Label after initialization statements. */
04417          /* Do not reconnect SH_NEXT_IDX of curr_stmt_sh_idx.  It    */
04418          /* will be connected after decl_semantics.                  */
04419 
04420          sh_after_entry_idx     = SH_NEXT_IDX(label_sh_idx);
04421          SH_PREV_IDX(sh_after_entry_idx)        = NULL_IDX;
04422 
04423          SH_NEXT_IDX(label_sh_idx)    = idx;
04424 
04425          if (SH_PREV_IDX(idx)) {
04426             SH_NEXT_IDX(SH_PREV_IDX(idx))   = label_sh_idx;
04427          }
04428          SH_PREV_IDX(label_sh_idx)    = SH_PREV_IDX(idx);
04429          SH_PREV_IDX(idx)     = label_sh_idx;
04430       }
04431 
04432       line            = SH_GLB_LINE(idx);
04433       SH_GLB_LINE(label_sh_idx)       = line;
04434       IR_LINE_NUM(SH_IR_IDX(label_sh_idx))    = line;
04435       IR_LINE_NUM_L(SH_IR_IDX(label_sh_idx))    = line;
04436       AT_DEF_LINE(IR_IDX_L(SH_IR_IDX(label_sh_idx)))  = line;
04437    }
04438 
04439    if (SCP_ALT_ENTRY_CNT(curr_scp_idx) > 0) {
04440 
04441       if (ATP_PGM_UNIT(pgm_attr_idx) == Function &&
04442           (TYP_TYPE(ATD_TYPE_IDX(ATP_RSLT_IDX(pgm_attr_idx))) == Character ||
04443            ATD_ARRAY_IDX(ATP_RSLT_IDX(pgm_attr_idx)) != NULL_IDX)) {
04444          entry_idx = SCP_ENTRY_IDX(curr_scp_idx);
04445 
04446          /* Add the main entry point to all the alternate entry points, */
04447          /* so that tmps generated for bounds for the main entry point  */
04448          /* will not show up at other entry points.                     */
04449 
04450          while (entry_idx != NULL_IDX) {
04451 
04452             /* Add the main attr to the entry attr list. */
04453    
04454             NTR_ATTR_LIST_TBL(list_idx);
04455             AL_ATTR_IDX(list_idx) = pgm_attr_idx;
04456             entry_attr_idx    = AL_ATTR_IDX(entry_idx);
04457 
04458             if (ATP_NO_ENTRY_LIST(entry_attr_idx) != NULL_IDX) {
04459                AL_NEXT_IDX(list_idx)  = ATP_NO_ENTRY_LIST(entry_attr_idx);
04460                AL_ENTRY_COUNT(list_idx) = 
04461                                        AL_ENTRY_COUNT(AL_NEXT_IDX(list_idx))+ 1;
04462             }
04463             else {
04464                AL_ENTRY_COUNT(list_idx) = 1;
04465             }
04466 
04467             ATP_NO_ENTRY_LIST(entry_attr_idx) = list_idx;
04468 
04469             /* Add the entry attr to the main attr's list */
04470 
04471             NTR_ATTR_LIST_TBL(list_idx);
04472             AL_ATTR_IDX(list_idx)   = entry_attr_idx;
04473    
04474             if (ATP_NO_ENTRY_LIST(pgm_attr_idx) != NULL_IDX) {
04475                AL_NEXT_IDX(list_idx)   = ATP_NO_ENTRY_LIST(pgm_attr_idx);
04476                AL_ENTRY_COUNT(list_idx)  = 
04477                                       AL_ENTRY_COUNT(AL_NEXT_IDX(list_idx)) + 1;
04478             }
04479             else {
04480                AL_ENTRY_COUNT(list_idx)  = 1;
04481             }
04482 
04483             ATP_NO_ENTRY_LIST(pgm_attr_idx) = list_idx;
04484 
04485             entry_list_idx = SCP_ENTRY_IDX(curr_scp_idx);
04486 
04487             while (entry_list_idx != NULL_IDX) {
04488 
04489                if (entry_attr_idx != AL_ATTR_IDX(entry_list_idx)) {
04490                   NTR_ATTR_LIST_TBL(list_idx);
04491                   AL_ATTR_IDX(list_idx) = entry_attr_idx;
04492 
04493                   if (ATP_NO_ENTRY_LIST(AL_ATTR_IDX(entry_list_idx)) != 
04494                                                                      NULL_IDX) {
04495                      AL_NEXT_IDX(list_idx) = 
04496                                  ATP_NO_ENTRY_LIST(AL_ATTR_IDX(entry_list_idx));
04497                      AL_ENTRY_COUNT(list_idx) = 
04498                                  AL_ENTRY_COUNT(AL_NEXT_IDX(list_idx)) + 1;
04499                   }
04500                   else {
04501                      AL_ENTRY_COUNT(list_idx) = 1;
04502                   }
04503                   ATP_NO_ENTRY_LIST(AL_ATTR_IDX(entry_list_idx)) = list_idx;
04504                }
04505                entry_list_idx = AL_NEXT_IDX(entry_list_idx);
04506             }
04507             entry_idx = AL_NEXT_IDX(entry_idx);
04508          }
04509       }
04510 
04511       /* Create a list for each darg, of entry points the darg is NOT at.    */
04512       /* Also, create a list of the SH index for each alternate entry point. */
04513 
04514       /* Process !DIR$ IGNORE TYPE AND KIND directive */
04515 
04516       darg_list_idx = SCP_DARG_LIST(curr_scp_idx);
04517 
04518       while (darg_list_idx != NULL_IDX) {
04519          darg_idx = AL_ATTR_IDX(darg_list_idx);
04520          darg_list_idx  = AL_NEXT_IDX(darg_list_idx);
04521          list_idx = NULL_IDX;
04522 
04523            
04524          if (SCP_IGNORE_TKR(curr_scp_idx) &&
04525              AT_OBJ_CLASS(darg_idx) == Data_Obj) {
04526 
04527             if (!fnd_semantic_err(Obj_Ignore_TKR,
04528                                   AT_DEF_LINE(darg_idx),
04529                                   AT_DEF_COLUMN(darg_idx),
04530                                   darg_idx,
04531                                   TRUE)) {
04532                ATD_IGNORE_TKR(darg_idx) = TRUE;
04533             }
04534          }
04535 
04536          if (!darg_in_entry_list(darg_idx, pgm_attr_idx)) {
04537             NTR_ATTR_LIST_TBL(list_idx);
04538             AL_ATTR_IDX(list_idx) = pgm_attr_idx;
04539             AT_ALT_DARG(darg_idx) = TRUE;
04540             AL_ENTRY_COUNT(list_idx)  = 1;
04541 
04542             if (AT_OBJ_CLASS(darg_idx) == Data_Obj) {
04543                ATD_NO_ENTRY_LIST(darg_idx)  = list_idx;
04544             }
04545             else {
04546                ATP_NO_ENTRY_LIST(darg_idx)  = list_idx;
04547             }
04548          }
04549 
04550          entry_list_idx = SCP_ENTRY_IDX(curr_scp_idx);
04551 
04552          while(entry_list_idx != NULL_IDX) {
04553             entry_attr_idx  = AL_ATTR_IDX(entry_list_idx);
04554             entry_list_idx  = AL_NEXT_IDX(entry_list_idx);
04555 
04556             if (!darg_in_entry_list(darg_idx, entry_attr_idx)) {
04557                prev_idx       = list_idx;
04558                NTR_ATTR_LIST_TBL(list_idx);
04559 
04560                if (prev_idx == NULL_IDX) {
04561                   AL_ENTRY_COUNT(list_idx)  = 1;
04562 
04563                   if (AT_OBJ_CLASS(darg_idx) == Data_Obj) {
04564                      ATD_NO_ENTRY_LIST(darg_idx) = list_idx;
04565                   }
04566                   else {
04567                      ATP_NO_ENTRY_LIST(darg_idx) = list_idx;
04568                   }
04569                }
04570                else {
04571                   AL_NEXT_IDX(prev_idx)      = list_idx;
04572 
04573                   if (AT_OBJ_CLASS(darg_idx) == Data_Obj) {
04574                      AL_ENTRY_COUNT(ATD_NO_ENTRY_LIST(darg_idx))+=1;
04575                   }
04576                   else {
04577                      AL_ENTRY_COUNT(ATP_NO_ENTRY_LIST(darg_idx))+=1;
04578                   }
04579                }
04580                AL_ATTR_IDX(list_idx)    = entry_attr_idx;
04581                AT_ALT_DARG(darg_idx)    = TRUE;
04582             }
04583          }
04584       }
04585    }
04586    else {
04587       darg_list_idx = SCP_DARG_LIST(curr_scp_idx);
04588 
04589       while (darg_list_idx != NULL_IDX) {
04590          darg_idx = AL_ATTR_IDX(darg_list_idx);
04591          darg_list_idx  = AL_NEXT_IDX(darg_list_idx);
04592            
04593          if (SCP_IGNORE_TKR(curr_scp_idx) &&
04594              AT_OBJ_CLASS(darg_idx) == Data_Obj) {
04595 
04596             if (!fnd_semantic_err(Obj_Ignore_TKR,
04597                                   AT_DEF_LINE(darg_idx),
04598                                   AT_DEF_COLUMN(darg_idx),
04599                                   darg_idx,
04600                                   TRUE)) {
04601                ATD_IGNORE_TKR(darg_idx) = TRUE;
04602             }
04603          }
04604       }
04605    }
04606 
04607    if (opt_flags.reshape) {
04608 
04609       /* Set ATD_RESHAPE_ARRAY_OPT for specific attrs */
04610       /* that are specified on the commandline.        */
04611 
04612       reshape_array_semantics();
04613 
04614    }
04615 
04616    /* There may be bounds temps hidden in the implicit table that need to be  */
04617    /* folded.  These come up when something like IMPLICIT CHARACTER*(n) (a-z) */
04618    /* is specified.  This code checks the implicit table for this scope.      */
04619 
04620    for (idx = 0; idx < MAX_IMPL_CHS; idx++) {
04621 
04622       if (IM_SET(curr_scp_idx, idx) && 
04623           TYP_TYPE(IM_TYPE_IDX(curr_scp_idx, idx)) == Character &&
04624           TYP_FLD(IM_TYPE_IDX(curr_scp_idx, idx)) == AT_Tbl_Idx) {
04625          attr_semantics(TYP_IDX(IM_TYPE_IDX(curr_scp_idx, idx)), TRUE);
04626       }
04627    }
04628 
04629    /* Process the program name first, so that any other object that needs */
04630    /* to refer to it or check against it, gets the correct information.   */
04631 
04632    attr_semantics(pgm_attr_idx, FALSE);
04633 
04634    /* There are seperate lists for stride multipliers, extents, array lengths,*/
04635    /* and max(0,char length) tmps.  These can never share with character len, */
04636    /* lower bound and upper bounds tmps, because the stride ect..  tmps all   */
04637    /* reference other tmps in their expressions.  IR is generated and         */
04638    /* attached to curr_stmt_sh_idx for extents, strides, and lengths.  If the */
04639    /* object is an automatic object, the allocate IR will then generate.      */
04640    /* This allocate will always follow its length IR(s) and will be of the    */
04641    /* tmp = form.                                                             */
04642    
04643    for (name_idx = SCP_LN_FW_IDX(curr_scp_idx) + 1; 
04644         name_idx < SCP_LN_LW_IDX(curr_scp_idx); name_idx++) {
04645 
04646       attr_idx = LN_ATTR_IDX(name_idx);
04647       attr_semantics(attr_idx, FALSE);
04648    }
04649 
04650    al_idx = SCP_ATTR_LIST(curr_scp_idx);
04651 
04652    while (al_idx != NULL_IDX) {
04653       attr_idx  = AL_ATTR_IDX(al_idx);
04654       al_idx  = AL_NEXT_IDX(al_idx);
04655 
04656       attr_semantics(attr_idx, FALSE);
04657    }
04658 
04659 # if !defined(_SINGLE_ALLOCS_FOR_AUTOMATIC)
04660 
04661   /* Force saved automatic ir into statements */
04662 
04663    gen_multiple_automatic_allocate(NULL_IDX); 
04664 
04665 # endif
04666 
04667    /* There may be statements before sh_after_entry_idx.       */
04668    /* Find the beginning before hooking up sh_after_entry_idx. */
04669 
04670    while (SH_PREV_IDX(sh_after_entry_idx) != NULL_IDX) {
04671       sh_after_entry_idx = SH_PREV_IDX(sh_after_entry_idx);
04672    }
04673 
04674    /* There may be statements following curr_stmt_sh_idx. */
04675    /* Find the end before hooking up sh_after_entry_idx.  */
04676 
04677    while (SH_NEXT_IDX(curr_stmt_sh_idx) != NULL_IDX) {
04678       curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
04679    }
04680 
04681    if (init_sh_start_idx != NULL_IDX) {
04682 
04683       /* Insert any default initialization Init_Oprs */
04684 
04685       SH_NEXT_IDX(init_sh_end_idx)    = SH_NEXT_IDX(curr_stmt_sh_idx);
04686       SH_NEXT_IDX(curr_stmt_sh_idx)   = init_sh_start_idx;
04687       SH_PREV_IDX(init_sh_start_idx)    = curr_stmt_sh_idx;
04688       SH_PREV_IDX(SH_NEXT_IDX(init_sh_end_idx)) = init_sh_end_idx;
04689       curr_stmt_sh_idx            = init_sh_end_idx;
04690    }
04691 
04692    SH_NEXT_IDX(curr_stmt_sh_idx)   = sh_after_entry_idx;
04693    SH_PREV_IDX(sh_after_entry_idx) = curr_stmt_sh_idx;
04694 
04695    if (ATP_PGM_UNIT(pgm_attr_idx) == Function &&
04696        SCP_ENTRY_IDX(curr_scp_idx) != NULL_IDX &&
04697        TYP_TYPE(ATD_TYPE_IDX(ATP_RSLT_IDX(pgm_attr_idx))) == Character) {
04698 
04699       /* If this is a character function with character alternate entries */
04700       /* equivalence all the character size temps together.               */
04701 
04702       /* BHJ - JBL - You may want to make temps for constant  */
04703       /* size entries as well and equiv them too, but I'm not */
04704       /* going to take the implementation quite that far.     */
04705 
04706       count = 0;
04707       al_idx  = SCP_ENTRY_IDX(curr_scp_idx);  
04708 
04709       while (al_idx != NULL_IDX) {
04710          rslt_idx = ATP_RSLT_IDX(AL_ATTR_IDX(al_idx));
04711 
04712          if (TYP_FLD(ATD_TYPE_IDX(rslt_idx)) == AT_Tbl_Idx) {
04713             NTR_EQ_TBL(eq_idx);
04714             EQ_LINE_NUM(eq_idx)   = AT_DEF_LINE(rslt_idx);
04715             EQ_COLUMN_NUM(eq_idx) = AT_DEF_COLUMN(rslt_idx);
04716             EQ_ATTR_IDX(eq_idx)   = TYP_IDX(ATD_TYPE_IDX(rslt_idx));
04717             ATD_EQUIV(EQ_ATTR_IDX(eq_idx)) = TRUE;
04718             group     = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
04719 
04720             if (count == 0) {
04721                EQ_NEXT_EQUIV_GRP(eq_idx)    = group;
04722                SCP_FIRST_EQUIV_GRP(curr_scp_idx)  = eq_idx;
04723                group          = eq_idx;
04724             }
04725             else {
04726                EQ_NEXT_EQUIV_OBJ(EQ_GRP_END_IDX(group)) = eq_idx;
04727             }
04728             EQ_GRP_END_IDX(group)   = eq_idx;
04729             EQ_GRP_IDX(eq_idx)      = group;
04730             count++;
04731          }
04732          al_idx = AL_NEXT_IDX(al_idx);
04733       }
04734 
04735       if (count > 0 &&
04736           TYP_FLD(ATD_TYPE_IDX(ATP_RSLT_IDX(pgm_attr_idx))) == AT_Tbl_Idx) {
04737          NTR_EQ_TBL(eq_idx);
04738          rslt_idx     = ATP_RSLT_IDX(pgm_attr_idx);
04739          EQ_LINE_NUM(eq_idx)    = AT_DEF_LINE(rslt_idx);
04740          EQ_COLUMN_NUM(eq_idx)    = AT_DEF_COLUMN(rslt_idx);
04741          EQ_ATTR_IDX(eq_idx)    = TYP_IDX(ATD_TYPE_IDX(rslt_idx));
04742          ATD_EQUIV(EQ_ATTR_IDX(eq_idx)) = TRUE;
04743          group        = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
04744          EQ_NEXT_EQUIV_OBJ(EQ_GRP_END_IDX(group)) = eq_idx;
04745          EQ_GRP_END_IDX(group)    = eq_idx;
04746          EQ_GRP_IDX(eq_idx)   = group;
04747       }
04748       else if (count == 1) { /* Only one item on the list - loose it */
04749          SCP_FIRST_EQUIV_GRP(curr_scp_idx) = 
04750                EQ_NEXT_EQUIV_GRP(SCP_FIRST_EQUIV_GRP(curr_scp_idx));
04751      }
04752    }
04753 
04754    if (ATP_ARGCHCK_ENTRY(pgm_attr_idx)) {
04755       insert_argchck_calls(sh_after_entry_idx, pgm_attr_idx);
04756 
04757       if (SCP_ALT_ENTRY_CNT(curr_scp_idx) != 0) {
04758          entry_list_idx = SCP_ENTRY_IDX(curr_scp_idx);
04759 
04760          while (entry_list_idx != NULL_IDX) {
04761             insert_argchck_calls(ATP_ENTRY_LABEL_SH_IDX(AL_ATTR_IDX(
04762                                                         entry_list_idx)),
04763                                  AL_ATTR_IDX(entry_list_idx));
04764             entry_list_idx = AL_NEXT_IDX(entry_list_idx);
04765          }
04766       }
04767    }
04768 
04769    if (SCP_FIRST_EQUIV_GRP(curr_scp_idx) != NULL_IDX &&
04770        num_prog_unit_errors == 0) { 
04771       equivalence_semantics();
04772    }
04773 
04774    /* Put the list of alternate returns on the equiv list, if it exists. */
04775    /* Do now, so it doesn't go throuh equivalence_semantics.             */
04776 
04777    if (alt_entry_equiv_grp != NULL_IDX) {
04778       EQ_NEXT_EQUIV_GRP(alt_entry_equiv_grp)= SCP_FIRST_EQUIV_GRP(curr_scp_idx);
04779       EQ_SEMANTICS_DONE(alt_entry_equiv_grp)= TRUE;
04780       SCP_FIRST_EQUIV_GRP(curr_scp_idx)     = alt_entry_equiv_grp;
04781    }
04782 
04783    if (namelist_list_idx != NULL_IDX) {
04784       namelist_resolution(namelist_list_idx);
04785    }
04786 
04787    if (allocatable_list_idx != NULL_IDX) {
04788       deallocate_local_allocatables();
04789    }
04790 
04791    if (ATP_PGM_UNIT(pgm_attr_idx) == Function ||
04792        ATP_PGM_UNIT(pgm_attr_idx) == Subroutine) {
04793 
04794       if (SCP_COPY_ASSUMED_SHAPE(curr_scp_idx) &&
04795           SCP_COPY_ASSUMED_LIST(curr_scp_idx) != NULL_IDX &&
04796           IL_FLD(SCP_COPY_ASSUMED_LIST(curr_scp_idx)) != NO_Tbl_Idx) {
04797 
04798         /* this is an error situation */
04799         PRINTMSG(IL_LINE_NUM(IL_IDX(SCP_COPY_ASSUMED_LIST(curr_scp_idx))),
04800                  1281, Error, 
04801                  IL_COL_NUM(IL_IDX(SCP_COPY_ASSUMED_LIST(curr_scp_idx))));
04802       }
04803       else if (SCP_COPY_ASSUMED_SHAPE(curr_scp_idx)) {
04804 
04805          idx = SCP_DARG_LIST(curr_scp_idx);
04806 
04807          list_idx = NULL_IDX;
04808          OPND_IDX(opnd) = NULL_IDX;
04809 
04810          while (idx != NULL_IDX) {
04811 
04812             attr_idx = AL_ATTR_IDX(idx);
04813 
04814             if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
04815                 ATD_ARRAY_IDX(attr_idx) != NULL_IDX &&
04816                 BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Assumed_Shape) {
04817 
04818                if (list_idx == NULL_IDX) {
04819                   NTR_IR_LIST_TBL(list_idx);
04820                   OPND_FLD(opnd) = IL_Tbl_Idx;
04821                   OPND_IDX(opnd) = list_idx;
04822                   OPND_LIST_CNT(opnd) = 1;
04823                }
04824                else {
04825                   NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04826                   IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04827                   list_idx = IL_NEXT_LIST_IDX(list_idx);
04828                   OPND_LIST_CNT(opnd) += 1;
04829                }
04830 
04831                IL_FLD(list_idx) = AT_Tbl_Idx;
04832                IL_IDX(list_idx) = attr_idx;
04833                IL_LINE_NUM(list_idx) = 
04834                             IL_LINE_NUM(SCP_COPY_ASSUMED_LIST(curr_scp_idx));
04835                IL_COL_NUM(list_idx) = 
04836                             IL_COL_NUM(SCP_COPY_ASSUMED_LIST(curr_scp_idx));
04837             }
04838 
04839             idx = AL_NEXT_IDX(idx);
04840          }
04841 
04842          if (OPND_IDX(opnd) != NULL_IDX) {
04843             reassign_XT_temps = must_reassign_XT_temp(&opnd);
04844             shared_bd_idx = -1;
04845             list_idx = OPND_IDX(opnd);
04846 
04847             while (list_idx != NULL_IDX) {
04848                curr_stmt_sh_idx = sh_after_entry_idx;
04849                gen_assumed_shape_copy(&IL_OPND(list_idx));
04850                list_idx = IL_NEXT_LIST_IDX(list_idx);
04851             }
04852          }
04853          else {
04854             PRINTMSG(IL_LINE_NUM(SCP_COPY_ASSUMED_LIST(curr_scp_idx)),
04855                      1304, Caution,
04856                      IL_COL_NUM(SCP_COPY_ASSUMED_LIST(curr_scp_idx)));
04857          }
04858       }
04859       else if (SCP_COPY_ASSUMED_LIST(curr_scp_idx) != NULL_IDX) {
04860          list_idx = SCP_COPY_ASSUMED_LIST(curr_scp_idx);
04861 
04862          while (list_idx) {
04863             shared_bd_idx = -1;
04864             COPY_OPND(opnd, IL_OPND(list_idx));
04865             reassign_XT_temps = must_reassign_XT_temp(&opnd);
04866             list_idx2 = OPND_IDX(opnd);
04867 
04868             while (list_idx2) {
04869                if (AT_DCL_ERR(IL_IDX(list_idx2))) {
04870                   /* intentionally blank */
04871                }
04872                else if (AT_OBJ_CLASS(IL_IDX(list_idx2)) != Data_Obj ||
04873                         ATD_ARRAY_IDX(IL_IDX(list_idx2)) == NULL_IDX ||
04874                         BD_ARRAY_CLASS(ATD_ARRAY_IDX(IL_IDX(list_idx2))) != 
04875                                                  Assumed_Shape) {
04876    
04877                   PRINTMSG(IL_LINE_NUM(list_idx2), 1303, Error, 
04878                            IL_COL_NUM(list_idx2));
04879                }
04880                else {
04881                   curr_stmt_sh_idx = sh_after_entry_idx;
04882                   gen_assumed_shape_copy(&IL_OPND(list_idx2));
04883                }
04884 
04885                list_idx2 = IL_NEXT_LIST_IDX(list_idx2);
04886             }
04887 
04888             list_idx = IL_NEXT_LIST_IDX(list_idx);
04889          }
04890       }
04891 
04892       shared_bd_idx = NULL_IDX;
04893    }
04894    else {  /* Module, blockdata or program */
04895 
04896       if (SCP_COPY_ASSUMED_LIST(curr_scp_idx) != NULL_IDX) {
04897          list_idx = SCP_COPY_ASSUMED_LIST(curr_scp_idx);
04898 
04899          while (list_idx) {
04900             COPY_OPND(opnd, IL_OPND(list_idx));
04901             list_idx2 = OPND_IDX(opnd);
04902 
04903             while (list_idx2) {
04904 
04905                if (AT_DCL_ERR(IL_IDX(list_idx2))) {
04906                   /* intentionally blank */
04907                }
04908                else {
04909                   PRINTMSG(IL_LINE_NUM(list_idx2), 1303, Error, 
04910                            IL_COL_NUM(list_idx2));
04911                }
04912                list_idx2 = IL_NEXT_LIST_IDX(list_idx2);
04913             }
04914 
04915             list_idx = IL_NEXT_LIST_IDX(list_idx);
04916          }
04917       }
04918    }
04919 
04920 # ifdef _F_MINUS_MINUS
04921 
04922 # if ! defined(_TARGET_OS_MAX)
04923 
04924    if (cmd_line_flags.co_array_fortran &&
04925        ATP_PGM_UNIT(pgm_attr_idx) == Program) {
04926       /* insert call to start_pes(0) */
04927       save_curr_stmt_sh_idx = curr_stmt_sh_idx;
04928       curr_stmt_sh_idx = SCP_FIRST_SH_IDX(curr_scp_idx);
04929 
04930       OPND_FLD(opnd) = CN_Tbl_Idx;
04931       OPND_IDX(opnd) = CN_INTEGER_ZERO_IDX;
04932       OPND_LINE_NUM(opnd) = AT_DEF_LINE(pgm_attr_idx);
04933       OPND_COL_NUM(opnd) = AT_DEF_COLUMN(pgm_attr_idx);
04934 
04935       gen_internal_call_stmt(START_PES_LIB_ENTRY,
04936                              &opnd,
04937                              After);
04938 
04939       PRINTMSG(AT_DEF_LINE(pgm_attr_idx), 1460, Warning, 
04940                AT_DEF_COLUMN(pgm_attr_idx));
04941       
04942       curr_stmt_sh_idx = save_curr_stmt_sh_idx;
04943    }
04944 # endif
04945 # endif
04946 
04947    if (SCP_DARG_LIST(curr_scp_idx) != NULL_IDX) {
04948       free_attr_list(SCP_DARG_LIST(curr_scp_idx));
04949       SCP_DARG_LIST(curr_scp_idx) = NULL_IDX;
04950    }
04951 
04952    SCP_RESHAPE_ARRAY_LIST(curr_scp_idx) = reshape_array_list;
04953    reshape_array_list     = NULL_IDX;
04954 
04955    TRACE (Func_Exit, "decl_semantics", NULL);
04956 
04957    return;
04958 
04959 }  /* decl_semantics */
04960 
04961 #ifdef KEY /* Bug 6845 */
04962 /* Create symbol for "dealloc" the first time we need it */
04963 static long
04964 lazy_create_dealloc(int line, int col) {
04965    if (glb_tbl_idx[Dealloc_Attr_Idx] == NULL_IDX) {
04966       glb_tbl_idx[Dealloc_Attr_Idx] = create_lib_entry_attr(DEALLOC_LIB_ENTRY,
04967    DEALLOC_NAME_LEN, line, col);
04968    }
04969    return glb_tbl_idx[Dealloc_Attr_Idx];
04970 }
04971 /*
04972  * Generate a statement to deallocate a single simple entity. The code in this
04973  * function is modeled after deallocate_local_allocatables(), with
04974  * _SEPARATE_DEALLOCATES==true and _ALLOCATE_IS_CALL==false. It is generalized
04975  * slightly from the original to allow deallocation of a structure component.
04976  *
04977  * line   source line
04978  * col    source column
04979  * fld    AT_Tbl_Idx or IR_Tbl_Idx
04980  * idx    index of arg or variable to deallocate
04981  * has_pe_ref used only for locals, not dummies
04982  * do_gen_sh  call gen_sh to generate statement to perform dealloc
04983  * optional is optional dummy variable
04984  * return sh_idx for newly generated statement
04985  */
04986 int
04987 help_dealloc(int line, int col, fld_type fld, int idx,
04988    boolean has_pe_ref, boolean do_gen_sh, boolean optional) {
04989 
04990    if (do_gen_sh) {
04991       gen_sh(After, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
04992       SH_P2_SKIP_ME(curr_stmt_sh_idx)   = TRUE;
04993    }
04994 
04995    int list_idx;
04996    NTR_IR_LIST_TBL(list_idx);
04997    IL_FLD(list_idx) = IR_Tbl_Idx;
04998    IL_IDX(list_idx) = gen_ir(fld, idx, Aloc_Opr, CRI_Ptr_8,
04999      line, col, NO_Tbl_Idx, NULL_IDX);
05000 
05001    int asg_idx = SH_IR_IDX(curr_stmt_sh_idx) = gen_ir(IL_Tbl_Idx, list_idx,
05002      Deallocate_Opr, TYPELESS_DEFAULT_TYPE, line, col, NO_Tbl_Idx, NULL_IDX);
05003 
05004    int cn_idx;
05005    IR_FLD_R(asg_idx) = IL_Tbl_Idx;
05006    IR_LIST_CNT_R(asg_idx) = 3;
05007    IR_IDX_R(asg_idx) = gen_il(3, FALSE, line, col, AT_Tbl_Idx,
05008       lazy_create_dealloc(line, col), CN_Tbl_Idx,
05009       gen_alloc_header_const(Integer_8, 1, has_pe_ref, &cn_idx), CN_Tbl_Idx,
05010       CN_INTEGER_ZERO_IDX);
05011 
05012    if (optional) {
05013      curr_stmt_sh_idx = gen_present_ir(idx, curr_stmt_sh_idx,
05014        curr_stmt_sh_idx);
05015    }
05016 
05017    return curr_stmt_sh_idx;
05018 }
05019 /*
05020  * line     source line
05021  * col      source column
05022  * attr_idx   idx for variable or expr of type structure
05023  * attr_fld   which table attr_idx applies to
05024  * cpnt_attr_idx  AT_Tbl_Idx for a component of that structure
05025  * return   IR_Tbl_Idx for Struct_Opr referring to component
05026  */
05027 int
05028 do_make_struct_opr(int line, int col, int attr_idx, fld_type attr_fld,
05029    int cpnt_attr_idx) {
05030    int cpnt_ir_idx;
05031    NTR_IR_TBL(cpnt_ir_idx);
05032    IR_OPR(cpnt_ir_idx) = Struct_Opr;
05033    IR_TYPE_IDX(cpnt_ir_idx) = ATD_TYPE_IDX(cpnt_attr_idx);
05034    IR_LINE_NUM(cpnt_ir_idx) = line;
05035    IR_COL_NUM(cpnt_ir_idx)  = col;
05036    IR_FLD_L(cpnt_ir_idx) = attr_fld;
05037    IR_IDX_L(cpnt_ir_idx) = attr_idx;
05038    IR_FLD_R(cpnt_ir_idx) = AT_Tbl_Idx;
05039    IR_IDX_R(cpnt_ir_idx) = cpnt_attr_idx;
05040    IR_LINE_NUM_L(cpnt_ir_idx) = IR_LINE_NUM_R(cpnt_ir_idx) = line;
05041    IR_COL_NUM_L(cpnt_ir_idx) = IR_COL_NUM_R(cpnt_ir_idx)  = col;
05042    return cpnt_ir_idx;
05043 }
05044 
05045 static void help_dealloc_components(int, int, fld_type, int, boolean,
05046   boolean *);
05047 static void dealloc_allocatables(int, int, int, fld_type, int, boolean, boolean *);
05048 
05049 /*
05050  * Loop through elements of a nonallocatable array whose element type is a
05051  * structure containing allocatable components or subcomponents, and deallocate
05052  * them.
05053  *
05054  * line   Source line
05055  * col    Source column
05056  * fld    AT_Tbl_Idx or IR_Tbl_Idx
05057  * idx    Index for variable or Struct_Opr whose allocatable components
05058  *    we want to deallocate
05059  * has_pe_ref Who knows?
05060  * first  If null, create statement header for each deallocation.
05061  *    Otherwise, caller passes a variable which is used to suppress
05062  *    the first statement header (don't ask--it's historical.)
05063  */
05064 static void
05065 help_dealloc_array_of_struct(int line, int col, fld_type fld, int idx,
05066   boolean has_pe_ref, boolean *first) {
05067   opnd_type opnd;
05068   expr_arg_type exp_desc;
05069   int next_sh_idx = NULL_IDX;
05070   int placeholder_sh_idx = pre_gen_loops(line, col, &next_sh_idx);
05071   OPND_FLD(opnd) = fld;
05072   OPND_IDX(opnd) = idx;
05073   OPND_LINE_NUM(opnd) = line;
05074   OPND_COL_NUM(opnd) = col;
05075   gen_whole_subscript(&opnd, &exp_desc);
05076   gen_loops(&opnd, 0, TRUE);
05077   help_dealloc_components(line, col, OPND_FLD(opnd), OPND_IDX(opnd),
05078     has_pe_ref, first);
05079   post_gen_loops(placeholder_sh_idx, next_sh_idx);
05080 }
05081 /*
05082  * cpnt_attr_idx  AT_Tbl_Idx for a structure component
05083  * return true if the component is a structure containing allocatable
05084  *      components, which therefore requires automatic
05085  *      allocation and deallocation
05086  */
05087 int
05088 allocatable_structure_component(int cpnt_attr_idx) {
05089   if (ATD_POINTER(cpnt_attr_idx)) { /* Bug 14293 */
05090     return 0;
05091   }
05092   int type_idx = ATD_TYPE_IDX(cpnt_attr_idx);
05093   return Structure == TYP_TYPE(type_idx) &&
05094     ATT_ALLOCATABLE_CPNT(TYP_IDX(type_idx));
05095 }
05096 /*
05097  * Recursively deallocate allocatables associated with a variable or component
05098  * whose data type is "structure"
05099  * line   Source line
05100  * col    Source column
05101  * fld    AT_Tbl_Idx or IR_Tbl_Idx
05102  * idx    Index for structure variable or Struct_Opr
05103  *    whose components we need to deallocate
05104  * has_pe_ref Who knows?
05105  * first  If null, create statement header for each deallocation.
05106  *    Otherwise, caller passes a variable which is used to suppress
05107  *    the first statement header (don't ask--it's historical.)
05108  */
05109 static void
05110 help_dealloc_components(int line, int col, fld_type fld, int idx,
05111    boolean has_pe_ref, boolean *first) {
05112    int struct_idx = (fld == IR_Tbl_Idx) ? IR_TYPE_IDX(idx) : ATD_TYPE_IDX(idx);
05113    for (int sn_idx = ATT_FIRST_CPNT_IDX(TYP_IDX(struct_idx));
05114       sn_idx != NULL_IDX;
05115       sn_idx = SN_SIBLING_LINK(sn_idx)) {
05116       int cpnt_attr_idx = SN_ATTR_IDX(sn_idx);
05117       int type_idx = ATD_TYPE_IDX(cpnt_attr_idx);
05118 
05119       if (ATD_ALLOCATABLE(cpnt_attr_idx) ||
05120         allocatable_structure_component(cpnt_attr_idx)) {
05121   dealloc_allocatables(line, col, cpnt_attr_idx, IR_Tbl_Idx,
05122     do_make_struct_opr(line, col, idx, fld, cpnt_attr_idx), has_pe_ref,
05123     first);
05124       }
05125    }
05126 }
05127 /*
05128  * Recursively deallocate allocatables associated with a variable or component
05129  *
05130  * line   source line
05131  * col    source column
05132  * attr_idx AT_Tbl_Idx of variable or structure component 
05133  * fld    AT_Tbl_Idx or IR_Tbl_Idx corresponding to idx
05134  * idx    Index of variable or Struct_Opr expression which refers to
05135  *    the variable or component attr_idx
05136  * has_pe_ref Who knows?
05137  * first  If null, create statement header for each deallocation.
05138  *    Otherwise, caller passes a variable which is used to suppress
05139  *    the first statement header (don't ask--it's historical.)
05140  */
05141 static void
05142 dealloc_allocatables(int line, int col, int attr_idx, fld_type fld, int idx,
05143   boolean has_pe_ref, boolean *first) {
05144   int type_idx = ATD_TYPE_IDX(attr_idx);
05145 
05146   /* Ordinary allocatable array */
05147   if (ATD_ALLOCATABLE(attr_idx)) {
05148     help_dealloc(line, col, fld, idx, has_pe_ref,
05149       first ? (!*first) : TRUE, AT_OPTIONAL(attr_idx));
05150     if (first) {
05151       *first = FALSE;
05152     }
05153   }
05154 
05155   else if (allocatable_structure_component(attr_idx)) {
05156     int line = SH_GLB_LINE(curr_stmt_sh_idx);
05157     int col = SH_COL_NUM(curr_stmt_sh_idx);
05158 
05159     /* Non-allocatable array of structure having allocatable components or
05160      * subcomponents. */
05161     if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
05162       help_dealloc_array_of_struct(line, col, fld, idx, has_pe_ref,
05163         first);
05164     }
05165 
05166     /* Scalar structure having allocatable components or subcomponents:
05167      * recursively deallocate. */
05168     else {
05169       help_dealloc_components(line, col, fld, idx, has_pe_ref, first);
05170     }
05171   }
05172 }
05173 
05174 #endif /* KEY Bug 6845 */
05175 #ifdef KEY /* Bug 9029 */
05176 /*
05177  * Generate a warning message if a variable in a "threadprivate" directive
05178  * violates the rules
05179  * attr_idx AT_Tbl_Idx for the variable
05180  */
05181 static void
05182 threadprivate_check(int attr_idx) {
05183   /*
05184    * A threadprivate individual variable must not be:
05185    *   equivalenced, or
05186    *   in common (an entire common block an be theadprivate)
05187    * but must be:
05188    *   saved, or
05189    *   in a program unit where all vars are saved, or
05190    *   declared in a module
05191    */
05192   if (AT_OBJ_CLASS(attr_idx) != Data_Obj) {
05193      return; /* Just in case */
05194   }
05195   int sb_idx = ATD_STOR_BLK_IDX(attr_idx);
05196   char *msg_str = 0;
05197   if (sb_idx != NULL_IDX && SB_BLK_TYPE(sb_idx) == Threadprivate) {
05198     /* Would disallow common, but at this point we can't tell whether the
05199      * variable is marked "threadprivate" individually (ok) or by virtue of
05200      * its common block being marked "threadprivate" (also ok) or both at
05201      * once (not ok.) */
05202     if (ATD_IN_COMMON(attr_idx)) {
05203       return;
05204     }
05205     if (ATD_EQUIV(attr_idx)) {
05206       msg_str = "EQUIVALENCED";
05207     }
05208     if (msg_str) {
05209       PRINTMSG(AT_DEF_LINE(attr_idx), 1441, Error, AT_DEF_COLUMN(attr_idx),
05210   AT_OBJ_NAME_PTR(attr_idx),
05211   msg_str,
05212   "THREADPRIVATE",
05213   AT_DEF_LINE(attr_idx));
05214     }
05215     
05216     else {
05217       int scp_attr_idx = SCP_ATTR_IDX(curr_scp_idx);
05218       if (!(ATD_SAVED(attr_idx) ||
05219   ATP_SAVE_ALL(scp_attr_idx) ||
05220   (AT_OBJ_CLASS(scp_attr_idx) == Pgm_Unit &&
05221     ATP_PGM_UNIT(scp_attr_idx) == Program) ||
05222   AT_MODULE_OBJECT(attr_idx))) {
05223   PRINTMSG(AT_DEF_LINE(attr_idx), 1687, Warning, AT_DEF_COLUMN(attr_idx),
05224     AT_OBJ_NAME_PTR(attr_idx));
05225       }
05226     }
05227   }
05228 }
05229 #endif /* KEY Bug 9029 */
05230 #ifdef KEY /* Bug 14255 */
05231 /*
05232  * Given an attribute which has been marked as a dummy variable or procedure,
05233  * report an error if it isn't really a dummy argument
05234  *
05235  * attr_idx AT_Tbl_Idx for suspect attribute
05236  */
05237 static void
05238 error_not_darg(int attr_idx) {
05239   char *problem = 0;
05240   int err_number = 352;
05241   if (AT_IS_DARG(attr_idx)) {
05242     return;
05243   }
05244   if (AT_OPTIONAL(attr_idx)) {
05245     problem = "OPTIONAL";
05246   }
05247   else if (ATD_VALUE_ATTR(attr_idx)) {
05248     problem = "VALUE";
05249   }
05250   else if (ATD_INTENT(attr_idx) > Intent_Unseen) {
05251     problem = "INTENT";
05252   }
05253   else if (ATD_IGNORE_TKR(attr_idx)) {
05254     problem = "IGNORE_TKR";
05255     err_number = 1505;
05256   }
05257   AT_DCL_ERR(attr_idx) = TRUE;
05258   PRINTMSG(AT_DEF_LINE(attr_idx), err_number, Error,
05259      AT_DEF_COLUMN(attr_idx),
05260      AT_OBJ_NAME_PTR(attr_idx), problem);
05261 }
05262 #endif /* KEY Bug 14255 */
05263 /******************************************************************************\
05264 |*                        *|
05265 |* Description:                     *|
05266 |*  attr_semantics calls itself recursively to find all attr              *|
05267 |*  dependencies.  Then it does all the semantic checking it can think of.*|
05268 |*                        *|
05269 |* Input parameters:                    *|
05270 |*  NONE                      *|
05271 |*                        *|
05272 |* Output parameters:                   *|
05273 |*  NONE                      *|
05274 |*                        *|
05275 |* Returns:                     *|
05276 |*  NONE                      *|
05277 |*                        *|
05278 \******************************************************************************/
05279 static  void  attr_semantics(int  attr_idx,
05280         boolean bound_attr)
05281 
05282 {
05283    int      al_idx;
05284    int      bd_idx;
05285    int      column;
05286    int      count;
05287    int      curr_fwd_ref_idx;
05288    int      darg_idx;
05289    int      dim;
05290    int      dt_idx;
05291    int      end_entry_sh_idx;
05292    int      entry_sh_idx;
05293    int      eq_idx;
05294    expr_arg_type  expr_desc;
05295    int      first_idx;
05296    int      i;
05297    int      ir_idx;
05298    boolean    is_interface;
05299    int      line;
05300    int      link_idx;
05301    int      name_idx;
05302    int      new_bd_idx;
05303    int      old_fwd_ref_idx;
05304    opnd_type    opnd;
05305    int      pgm_attr_idx;
05306    int      pgm_idx;
05307    int      pointer_idx;
05308    int      proc_idx;
05309    char          *pure_str;
05310 #ifdef KEY /* Bug 10177 */
05311    int      rslt_idx = 0;
05312 #else /* KEY Bug 10177 */
05313    int      rslt_idx;
05314 #endif /* KEY Bug 10177 */
05315    int      scp_idx;
05316    int      sf_attr_idx;
05317    int      sn_attr_idx;
05318    int      sn_idx;
05319    id_str_type    storage_name;
05320    int      tmp_ir_idx;
05321 #ifdef KEY /* Bug 10177 */
05322    int      type_idx = 0;
05323 #else /* KEY Bug 10177 */
05324    int      type_idx;
05325 #endif /* KEY Bug 10177 */
05326    boolean    type_resolved;
05327    size_offset_type     storage_size;
05328 
05329 # if defined(_TARGET_OS_MAX) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
05330    int      tmp_idx;
05331 # endif
05332 
05333 
05334    TRACE (Func_Entry, "attr_semantics", NULL);
05335 
05336    is_interface = SCP_IS_INTERFACE(curr_scp_idx);
05337 
05338    if (AT_SEMANTICS_DONE(attr_idx) || 
05339        AT_DCL_ERR(attr_idx) ||
05340        AT_ATTR_LINK(attr_idx) != NULL_IDX) {
05341       AT_SEMANTICS_DONE(attr_idx) = TRUE;
05342 
05343       if (AT_OBJ_CLASS(attr_idx) != Interface ||
05344           AT_DCL_ERR(attr_idx) ||
05345           AT_ATTR_LINK(attr_idx) == NULL_IDX) {
05346 
05347          if (is_interface) {
05348 
05349             switch(AT_OBJ_CLASS(attr_idx)) {
05350             case Pgm_Unit:
05351                ATP_SCP_IDX(attr_idx)  = SCP_PARENT_IDX(curr_scp_idx);
05352                break;
05353 
05354             case Derived_Type:
05355                ATT_SCP_IDX(attr_idx)  = SCP_PARENT_IDX(curr_scp_idx);
05356                break;
05357             }
05358          }
05359 
05360          return;
05361       }
05362    }
05363 
05364    pgm_attr_idx = SCP_ATTR_IDX(curr_scp_idx);
05365 
05366    /* Mark this flag TRUE, for all objects declared in the module, if */
05367    /* this is a module.  The purpose of this flag is to separate      */
05368    /* objects from any module procedures from the objects in the      */
05369    /* module itself.  The classic case is the same named derived type */
05370    /* declared in the module and the module procedure.  The module    */
05371    /* procedure is of this type.  Because we match on AT_MODULE_IDX   */
05372    /* and AT_USE_ASSOCIATED in resolve_attr during use processing, we */
05373    /* have no way of knowing that these two types are not the same.   */
05374    /* This flag will differentiate between them, because only the     */
05375    /* module procedure name itself will come through this routine     */
05376    /* when pgm_attr_idx is set to the module.  AT_MODULE_IDX and      */
05377    /* AT_USE_ASSOCIATED cannot be used to determine this, because     */
05378    /* they are set for everything coming out of a module at USE time. */
05379 
05380    if (ATP_PGM_UNIT(pgm_attr_idx) == Module && !AT_USE_ASSOCIATED(attr_idx)) {
05381       AT_MODULE_OBJECT(attr_idx) = TRUE;
05382    }
05383 
05384    switch(AT_OBJ_CLASS(attr_idx)) {
05385    case Data_Obj:
05386 
05387       switch (ATD_CLASS(attr_idx)) {
05388       case Atd_Unknown:
05389 
05390          /* All data objs that do not resolve to something else are variables.*/
05391 
05392          ATD_CLASS(attr_idx) = Variable;
05393          break;
05394 
05395       case Function_Result:
05396 
05397          /* These are done when the pgm_unit is processed, */
05398          /* so process the program unit now.               */
05399 
05400          attr_semantics(ATD_FUNC_IDX(attr_idx), FALSE);
05401 
05402          return;
05403 
05404       case Compiler_Tmp:
05405 
05406          if (AT_REFERENCED(attr_idx) == Not_Referenced) {
05407 
05408             /* LRR - You're going to get more than bound attrs here. */
05409 
05410             /* Bound tmp saved just for CIF - These are bound_attrs, but  */
05411             /* only process them if CIF XREFS is on.                      */
05412 
05413             if ((cif_flags & XREF_RECS) != 0) {
05414                bound_attr = TRUE;
05415             }
05416             else {
05417                goto EXIT;
05418             }
05419          }
05420          break;
05421 
05422       case Constant:
05423 
05424          if (ATP_PGM_UNIT(pgm_attr_idx) == Module &&
05425              ATD_FLD(attr_idx) == AT_Tbl_Idx &&
05426              AT_OBJ_CLASS(ATD_CONST_IDX(attr_idx)) == Data_Obj &&
05427              ATD_CLASS(ATD_CONST_IDX(attr_idx)) == Compiler_Tmp &&
05428              ATD_TMP_INIT_NOT_DONE(ATD_CONST_IDX(attr_idx))) {
05429 
05430             /* Do all the init stmts for module parameters */
05431 
05432             insert_init_stmt_for_tmp(ATD_CONST_IDX(attr_idx));
05433          }
05434          break;
05435 
05436       }  /* End switch */
05437 
05438       type_idx = ATD_TYPE_IDX(attr_idx);
05439 
05440       if (TYP_TYPE(type_idx) == Structure) {
05441           
05442          if (AT_ATTR_LINK(TYP_IDX(type_idx)) != NULL_IDX) {
05443 
05444             /* If this derived type is host associated (AT_ATTR_LINK is set)  */
05445             /* change the type table to point to the original type.  It is    */
05446             /* okay to change the type table, because every attr of this type */
05447             /* needs to do this.                                              */
05448 
05449             link_idx = TYP_IDX(type_idx);
05450 
05451             while (AT_ATTR_LINK(link_idx) != NULL_IDX) {
05452                link_idx = AT_ATTR_LINK(link_idx);
05453             }
05454 
05455             TYP_IDX(type_idx) = link_idx;
05456          }
05457 
05458          attr_semantics(TYP_IDX(type_idx), FALSE);
05459       }
05460 
05461       if (ATP_PGM_UNIT(pgm_attr_idx) == Module && 
05462           ATD_CLASS(attr_idx) != Struct_Component) {
05463 
05464          if (TYP_TYPE(type_idx) == Structure &&
05465              !AT_PRIVATE(attr_idx) &&
05466              AT_PRIVATE(TYP_IDX(type_idx)) &&
05467              !AT_USE_ASSOCIATED(TYP_IDX(type_idx))) {  /* Interp 161 */
05468             PRINTMSG(AT_DEF_LINE(attr_idx), 598, Error, 
05469                      AT_DEF_COLUMN(attr_idx),
05470                      AT_OBJ_NAME_PTR(attr_idx),
05471                      AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
05472          }
05473 
05474          if (ATD_CLASS(attr_idx) == CRI__Pointee) {
05475             attr_semantics(ATD_PTR_IDX(attr_idx), FALSE);
05476 
05477             if (AT_PRIVATE(attr_idx) != AT_PRIVATE(ATD_PTR_IDX(attr_idx))) {
05478                PRINTMSG(AT_DEF_LINE(attr_idx), 697, Error, 
05479                         AT_DEF_COLUMN(attr_idx),
05480                         AT_OBJ_NAME_PTR(ATD_PTR_IDX(attr_idx)),
05481                         AT_OBJ_NAME_PTR(attr_idx));
05482             }
05483          }
05484       }
05485 
05486       if (ATP_PURE(pgm_attr_idx) || ATP_ELEMENTAL(pgm_attr_idx)) {
05487 
05488          if (ATD_IN_COMMON(attr_idx) ||
05489              AT_USE_ASSOCIATED(attr_idx) ||
05490              AT_HOST_ASSOCIATED(attr_idx) ||
05491              (ATD_CLASS(attr_idx) == Dummy_Argument &&
05492               (ATP_PGM_UNIT(pgm_attr_idx) == Function ||
05493                 (ATP_PGM_UNIT(pgm_attr_idx) == Subroutine &&
05494                  ATD_INTENT(attr_idx) == Intent_In)))) {
05495 
05496             /* Mark this, so that this object does not get defined. */
05497 
05498             ATD_PURE(attr_idx)  = TRUE;
05499          }
05500 
05501          if (ATD_PE_ARRAY_IDX(attr_idx) != NULL_IDX) {
05502             PRINTMSG(BD_LINE_NUM(ATD_PE_ARRAY_IDX(attr_idx)), 1580, Error, 
05503                      BD_COLUMN_NUM(ATD_PE_ARRAY_IDX(attr_idx)),
05504                      AT_OBJ_NAME_PTR(pgm_attr_idx),
05505                      AT_OBJ_NAME_PTR(attr_idx));
05506          }
05507       } 
05508 
05509       if (AT_USE_ASSOCIATED(attr_idx)) {
05510          goto EXIT;
05511       }
05512 
05513       if (bound_attr && ATD_CLASS(attr_idx) == Compiler_Tmp) {
05514 
05515          if (ATD_FLD(attr_idx) == AT_Tbl_Idx) {
05516             attr_semantics(ATD_TMP_IDX(attr_idx), FALSE);
05517          }
05518          else if (ATD_FLD(attr_idx) == IR_Tbl_Idx) {
05519             ir_idx = ATD_TMP_IDX(attr_idx);
05520 
05521             switch (IR_FLD_R(ir_idx)) {
05522             case AT_Tbl_Idx:
05523                attr_semantics(IR_IDX_R(ir_idx), FALSE);
05524                break;
05525 
05526             case IR_Tbl_Idx:
05527                tmp_ir_resolution(IR_IDX_R(ir_idx));
05528                break;
05529 
05530             case IL_Tbl_Idx:
05531                tmp_il_resolution(IR_IDX_R(ir_idx));
05532                break;
05533             }
05534          }
05535    
05536 #ifdef KEY /* Bug 10675 */
05537    /*
05538     * A fundamental flaw in this front end is that when it generates a
05539     * statement during the semantics phase and inserts it in the series
05540     * of statements generated by the parse phase, there's no way to
05541     * "glue together" the original statement and its progeny so they
05542     * act like a single statement. This is a problem when a compiler
05543     * directive like "omp atomic" refers to "the next statement" (because
05544     * post-semantics-phase it needs to refer to a block of statements.)
05545     * And it's a problem here: if bound_resolution() processes a
05546     * declaration which calls a procedure whose arglist requires the
05547     * allocation of a temporary, then it returns with an "alloc"
05548     * statement prepended to the "call" statement and a "dealloc"
05549     * statement appended. But the "call" statement is still marked as
05550     * the current one. If attr_semantics() now decides to allocate a
05551     * temporary here and deallocate it in the epilog, it will
05552     * append the "alloc" to the current statement. But that will
05553     * actually insert the "alloc" inside the trio of statements which
05554     * represents the call, in front of the "dealloc" belonging to the
05555     * call. Since "alloc" and "dealloc" need to be nested properly
05556     * (they work by moving the stack pointer) this is a tragedy. The
05557     * comprehensive fix would be to invent something in the front end
05558     * IR to represent a "block of statements which act like a single
05559     * one"; the quick fix is to move the current statement pointer past
05560     * the end of that block.
05561     */
05562    int save_next_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
05563          bound_resolution(attr_idx);
05564    for (;
05565      curr_stmt_sh_idx != NULL_IDX &&
05566        SH_NEXT_IDX(curr_stmt_sh_idx) != save_next_stmt_sh_idx &&
05567        SH_P2_SKIP_ME(curr_stmt_sh_idx);
05568        curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx))
05569      ;
05570 #else /* KEY Bug 10675 */
05571          bound_resolution(attr_idx);
05572 #endif /* KEY Bug 10675 */
05573       }
05574 
05575 
05576       if (TYP_TYPE(type_idx) == Character) {
05577 
05578          if (TYP_FLD(type_idx) == AT_Tbl_Idx) {
05579             attr_semantics(TYP_IDX(type_idx), TRUE);
05580          }
05581       }
05582 
05583       bd_idx  = ATD_ARRAY_IDX(attr_idx);
05584 
05585       if (bd_idx != NULL_IDX && BD_ARRAY_CLASS(bd_idx) != Deferred_Shape) {
05586 
05587          for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
05588 
05589             if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
05590                attr_semantics(BD_LB_IDX(bd_idx, dim), TRUE);
05591             }
05592 
05593             if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
05594                attr_semantics(BD_UB_IDX(bd_idx, dim), TRUE);
05595             }
05596          }
05597       }
05598 
05599       bd_idx    = ATD_PE_ARRAY_IDX(attr_idx);
05600 
05601       if (bd_idx != NULL_IDX && BD_ARRAY_CLASS(bd_idx) != Deferred_Shape) {
05602 
05603 # if 0
05604          /* this error is disabled for now. It was a little too strong */
05605          /* Perhaps it must be common or dummy arg.                    */
05606          if (! ATD_IN_COMMON(attr_idx)) {
05607             PRINTMSG(BD_LINE_NUM(bd_idx), 1365, Error,
05608                      BD_COLUMN_NUM(bd_idx),
05609                      AT_OBJ_NAME_PTR(attr_idx));
05610             AT_DCL_ERR(attr_idx) = TRUE;
05611          }
05612 # endif
05613 
05614          for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
05615 
05616             if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
05617                attr_semantics(BD_LB_IDX(bd_idx, dim), TRUE);
05618             }
05619 
05620             if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
05621                attr_semantics(BD_UB_IDX(bd_idx, dim), TRUE);
05622             }
05623          }
05624       }
05625 
05626 
05627       if (!AT_TYPED(attr_idx)) { 
05628 
05629          if (SCP_IMPL_NONE(curr_scp_idx)) {
05630             AT_DCL_ERR(attr_idx) = TRUE;
05631             PRINTMSG(AT_DEF_LINE(attr_idx), 113, Error,
05632                      AT_DEF_COLUMN(attr_idx),
05633                      AT_OBJ_NAME_PTR(attr_idx));
05634          }
05635          else if (!IM_SET(curr_scp_idx, IMPL_IDX(AT_OBJ_NAME(attr_idx)))) {
05636 
05637             if (SCP_PARENT_NONE(curr_scp_idx)) {
05638                AT_DCL_ERR(attr_idx) = TRUE;
05639                PRINTMSG(AT_DEF_LINE(attr_idx), 297, Error,
05640                         AT_DEF_COLUMN(attr_idx),
05641                         AT_OBJ_NAME_PTR(attr_idx));
05642             }
05643             else if (on_off_flags.implicit_none) {
05644                AT_DCL_ERR(attr_idx) = TRUE;
05645                PRINTMSG(AT_DEF_LINE(attr_idx), 1171, Error,
05646                         AT_DEF_COLUMN(attr_idx),
05647                         AT_OBJ_NAME_PTR(attr_idx));
05648             }
05649          }
05650       }
05651 
05652       /* char_len_resolution MUST happen before array_dim_resolution  */
05653       /* because the character length is used to calculate the stride */
05654       /* multiplier stored in the bounds table array entry.           */
05655 
05656       if (TYP_TYPE(type_idx) == Character) { 
05657          char_len_resolution(attr_idx, FALSE);
05658 
05659          /* reset the type_idx in case it changes */
05660 
05661          type_idx = ATD_TYPE_IDX(attr_idx);
05662       }
05663 
05664       if (AT_DCL_ERR(attr_idx)) {
05665          goto EXIT;
05666       }
05667 
05668       if (ATD_ALLOCATABLE(attr_idx)) {
05669          ATD_IM_A_DOPE(attr_idx) = TRUE;
05670 
05671          if (ATD_ARRAY_IDX(attr_idx) == NULL_IDX ||
05672              BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) != Deferred_Shape) {
05673             AT_DCL_ERR(attr_idx) = TRUE;
05674             PRINTMSG(AT_DEF_LINE(attr_idx), 570, Error,
05675                      AT_DEF_COLUMN(attr_idx),
05676                      AT_OBJ_NAME_PTR(attr_idx));
05677          }
05678 
05679 # ifdef _F_MINUS_MINUS
05680          if (ATD_PE_ARRAY_IDX(attr_idx) != NULL_IDX &&
05681              BD_ARRAY_CLASS(ATD_PE_ARRAY_IDX(attr_idx)) != Deferred_Shape) {
05682             AT_DCL_ERR(attr_idx) = TRUE;
05683             PRINTMSG(AT_DEF_LINE(attr_idx), 1552, Error,
05684                      AT_DEF_COLUMN(attr_idx),
05685                      AT_OBJ_NAME_PTR(attr_idx));
05686          }
05687 # endif
05688       }
05689 
05690       if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
05691 
05692          /* If -O fld is set and this is an explicit shape (rank > 1)   */
05693          /* array that has not been specified in a -O fld=array_name    */
05694          /* option, then set ATD_RESHAPE_ARRAY_OPT to TRUE.            */
05695 
05696          if (opt_flags.reshape_all_arrays &&
05697              BD_RANK(ATD_ARRAY_IDX(attr_idx)) > 1 &&
05698              BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Explicit_Shape &&
05699              (ATD_CLASS(attr_idx) != CRI__Pointee &&
05700               ATD_CLASS(attr_idx) != Constant) &&
05701              BD_LB_FLD(ATD_ARRAY_IDX(attr_idx), 
05702                        BD_RANK(ATD_ARRAY_IDX(attr_idx))) == CN_Tbl_Idx &&
05703              compare_cn_and_value(BD_LB_IDX(ATD_ARRAY_IDX(attr_idx), 
05704                                             BD_RANK(ATD_ARRAY_IDX(attr_idx))),
05705                                   1,
05706                                   Eq_Opr) &&
05707              BD_UB_FLD(ATD_ARRAY_IDX(attr_idx), 
05708                        BD_RANK(ATD_ARRAY_IDX(attr_idx))) == CN_Tbl_Idx &&
05709              compare_cn_and_value(BD_UB_IDX(ATD_ARRAY_IDX(attr_idx), 
05710                                             BD_RANK(ATD_ARRAY_IDX(attr_idx))),
05711                                   16,
05712                                   Lt_Opr) &&
05713              !ATD_RESHAPE_ARRAY_OPT(attr_idx)) {
05714 
05715             if (ATD_DATA_INIT(attr_idx)) {
05716                PRINTMSG(AT_DEF_LINE(attr_idx), 1644, Error,
05717                         AT_DEF_COLUMN(attr_idx),
05718                         AT_OBJ_NAME_PTR(attr_idx));
05719             }
05720             ATD_RESHAPE_ARRAY_OPT(attr_idx) = TRUE;
05721             NTR_ATTR_LIST_TBL(al_idx);
05722             AL_ATTR_IDX(al_idx) = attr_idx;
05723             AL_NEXT_IDX(al_idx) = reshape_array_list;
05724             reshape_array_list  = al_idx;
05725          }
05726 
05727          if (ATD_RESHAPE_ARRAY_OPT(attr_idx)) {
05728 
05729             PRINTMSG(AT_DEF_LINE(attr_idx), 1637, Optimization, 0,
05730                      "-O reshape",
05731                      AT_OBJ_NAME_PTR(attr_idx));
05732 
05733             /* create the new bounds entry with the swapped dimensions */
05734 
05735             bd_idx = ATD_ARRAY_IDX(attr_idx);
05736 
05737             new_bd_idx                 = reserve_array_ntry(BD_RANK(bd_idx));
05738             BD_RANK(new_bd_idx)        = BD_RANK(bd_idx);
05739             BD_LINE_NUM(new_bd_idx)    = BD_LINE_NUM(bd_idx);
05740             BD_COLUMN_NUM(new_bd_idx)  = BD_COLUMN_NUM(bd_idx);
05741             BD_ARRAY_CLASS(new_bd_idx) = BD_ARRAY_CLASS(bd_idx);
05742             BD_RESOLVED(new_bd_idx)    = FALSE;
05743 
05744             dim = 1;
05745 
05746             BD_LB_FLD(new_bd_idx,dim) = BD_LB_FLD(bd_idx,BD_RANK(bd_idx));
05747             BD_LB_IDX(new_bd_idx,dim) = BD_LB_IDX(bd_idx,BD_RANK(bd_idx));
05748 
05749             BD_UB_FLD(new_bd_idx,dim) = BD_UB_FLD(bd_idx,BD_RANK(bd_idx));
05750             BD_UB_IDX(new_bd_idx,dim) = BD_UB_IDX(bd_idx,BD_RANK(bd_idx));
05751 
05752             for (i = 1; i < BD_RANK(bd_idx); i++) {
05753                dim++;
05754                BD_LB_FLD(new_bd_idx,dim) = BD_LB_FLD(bd_idx,i);
05755                BD_LB_IDX(new_bd_idx,dim) = BD_LB_IDX(bd_idx,i);
05756 
05757                BD_UB_FLD(new_bd_idx,dim) = BD_UB_FLD(bd_idx,i);
05758                BD_UB_IDX(new_bd_idx,dim) = BD_UB_IDX(bd_idx,i);
05759             }
05760 
05761             new_bd_idx =  ntr_array_in_bd_tbl(new_bd_idx);
05762 
05763             array_dim_resolution(attr_idx, FALSE);
05764             bd_idx = ATD_ARRAY_IDX(attr_idx);
05765 
05766             if (! AT_DCL_ERR(attr_idx) &&
05767                 ! BD_DCL_ERR(bd_idx)) {
05768 
05769                ATD_ARRAY_IDX(attr_idx) = new_bd_idx;
05770                array_dim_resolution(attr_idx, FALSE);
05771                ATD_RESHAPE_ARRAY_IDX(attr_idx) = ATD_ARRAY_IDX(attr_idx);
05772                ATD_ARRAY_IDX(attr_idx) = bd_idx;
05773             }
05774          }
05775          else {
05776             array_dim_resolution(attr_idx, FALSE);
05777          }
05778       }
05779 
05780       if (ATD_PE_ARRAY_IDX(attr_idx) != NULL_IDX) {
05781          pe_array_dim_resolution(attr_idx);
05782       }
05783 
05784       if (ATD_DISTRIBUTION_IDX(attr_idx) != NULL_IDX) {
05785          distribution_resolution(attr_idx);
05786       }
05787 
05788       if (ATD_POINTER(attr_idx) && ATD_CLASS(attr_idx) != Dummy_Argument) {
05789          ATD_IM_A_DOPE(attr_idx)  = TRUE;
05790       }
05791 
05792 # if 0
05793       /* BHJ DOPE VECTOR TARGET */
05794       /* save this in case the interp changes. */
05795 
05796       if (ATD_TARGET(attr_idx) && ATD_CLASS(attr_idx) == Dummy_Argument) {
05797          ATD_IM_A_DOPE(attr_idx)        = TRUE;
05798       }
05799 # endif
05800 
05801       if (ATD_AUTOMATIC(attr_idx)) {
05802 
05803          if (ATD_IM_A_DOPE(attr_idx)) { /* If defrd array, its not auto */
05804             ATD_NO_ENTRY_LIST(attr_idx) = NULL_IDX; /* Only good for autos */
05805             ATD_AUTOMATIC(attr_idx) = FALSE;
05806          }
05807          else if (!is_interface) {
05808 
05809             if (ATP_SYMMETRIC(pgm_attr_idx)) {
05810 
05811                /* Check to see if this can be switched to symmetric. */
05812                /* The only thing AUTOMATIC can be, that SYMMETRIC    */
05813                /* cannot be is TARGET, so check that.                */
05814 
05815                if (ATD_TARGET(attr_idx)) {
05816                   PRINTMSG(AT_DEF_LINE(attr_idx), 1234, Caution,
05817                            AT_DEF_COLUMN(attr_idx),
05818                            AT_OBJ_NAME_PTR(attr_idx),
05819                            "TARGET");
05820                }
05821                else {
05822                   ATD_SYMMETRIC(attr_idx) = TRUE;
05823                }
05824             }
05825 
05826 # if defined(_SINGLE_ALLOCS_FOR_AUTOMATIC)
05827             gen_single_automatic_allocate(attr_idx);
05828 # else
05829 
05830             if (TYP_TYPE(type_idx) == Character ||
05831                 (TYP_TYPE(type_idx) == Structure && 
05832                  ATT_CHAR_SEQ(TYP_IDX(type_idx)))) {
05833                gen_single_automatic_allocate(attr_idx);
05834             }
05835             else {
05836                gen_multiple_automatic_allocate(attr_idx);
05837             }
05838 # endif
05839          }
05840       }
05841 
05842       if (TYP_TYPE(type_idx) == Character &&
05843           ATD_CLASS(attr_idx) != CRI__Pointee &&
05844           TYP_CHAR_CLASS(type_idx) == Assumed_Size_Char &&
05845           TYP_FLD(type_idx) == AT_Tbl_Idx &&
05846           AT_OBJ_CLASS(TYP_IDX(type_idx)) == Data_Obj) {
05847           
05848          tmp_ir_idx = ATD_TMP_IDX(TYP_IDX(type_idx));
05849 
05850          COPY_OPND(opnd, IR_OPND_R(tmp_ir_idx));
05851          fold_clen_opr(&opnd, &expr_desc);
05852          COPY_OPND(IR_OPND_R(tmp_ir_idx), opnd);
05853       }
05854 
05855       if (TYP_TYPE(type_idx) == Structure &&
05856           ATT_DEFAULT_INITIALIZED(TYP_IDX(type_idx))) {
05857 
05858          if (ATD_IN_COMMON(attr_idx)) {
05859             AT_DCL_ERR(attr_idx)        = TRUE;
05860             PRINTMSG(AT_DEF_LINE(attr_idx), 1600, Error,
05861                      AT_DEF_COLUMN(attr_idx),
05862                      AT_OBJ_NAME_PTR(attr_idx),
05863                      AT_OBJ_NAME_PTR(TYP_IDX(ATD_TYPE_IDX(attr_idx))));
05864          }
05865          else if (ATD_CLASS(attr_idx) == CRI__Pointee) {
05866             PRINTMSG(AT_DEF_LINE(attr_idx), 1647, Warning,
05867                      AT_DEF_COLUMN(attr_idx),
05868                      AT_OBJ_NAME_PTR(attr_idx));
05869          }
05870       }
05871 
05872 #ifdef KEY /* Bug 6845 */
05873       /* Dummy intent(out) must be deallocated on entry if it's an allocatable
05874        * array or a struct with allocatable components */
05875       if (Dummy_Argument == ATD_CLASS(attr_idx)) {
05876         if ((!is_interface) && Intent_Out == ATD_INTENT(attr_idx)) {
05877     dealloc_allocatables(SH_GLB_LINE(curr_stmt_sh_idx),
05878       SH_COL_NUM(curr_stmt_sh_idx), attr_idx, AT_Tbl_Idx, attr_idx,
05879       FALSE, 0);
05880         }
05881   /* Fortran 90 required a constraint warning for this */
05882   if (ATD_ALLOCATABLE(attr_idx)) {
05883     PRINTMSG(AT_DEF_LINE(attr_idx), 1679, Ansi, AT_DEF_COLUMN(attr_idx));
05884   }
05885       }
05886 #endif /* KEY Bug 6845 */
05887 
05888 
05889 # if 0
05890             /* BHJ DOPE VECTOR TARGET */
05891             /* save the old version of this condition in case */
05892             /* the target dummy arg interp changes.           */
05893 
05894       if (!is_interface &&
05895           (ATD_IM_A_DOPE(attr_idx) &&
05896            (ATD_CLASS(attr_idx) != Dummy_Argument ||
05897             (ATD_ARRAY_IDX(attr_idx) &&
05898              BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Assumed_Shape) ||
05899             (ATD_TARGET(attr_idx))))                                       ||
05900 
05901           (TYP_TYPE(type_idx) == Structure &&
05902            ATD_CLASS(attr_idx) != Constant &&
05903            (ATD_CLASS(attr_idx) != Dummy_Argument ||
05904               ATD_INTENT(attr_idx) == Intent_Out) &&
05905             ATD_CLASS(attr_idx) != CRI__Pointee &&
05906            ((ATT_POINTER_CPNT(TYP_IDX(type_idx)) ||
05907              ATT_DEFAULT_INITIALIZED(TYP_IDX(type_idx))) &&
05908             !ATD_DATA_INIT(attr_idx))))
05909 # else /* 0 */
05910 #   ifdef KEY /* Bug 431, (1046, 1289, 8717) */
05911      /* It appears that before the code arrived at Pathscale, in the
05912       * process of removing the "ATD_TARGET" test, somebody messed up
05913       * the grouping near the end of this impressive boolean expression,
05914       * causing bug 431. If the variable was declared with an
05915       * initializer (ATD_DATA_INIT) using a structure type which itself
05916       * has a default init (ATT_DEFAULT_INITIALIZED), we don't want to
05917       * call gen_entry_dope_code() to emit the initialization dictated
05918       * by the structure type, because the variable initialization
05919       * (which is emitted elsewhere) overrides it.
05920       *
05921       * At Pathscale, the first (and second and third) attempts to fix
05922       * bug 431 focused on suppressing the resultant WHIRL "store" via
05923       * code in fei_store(), but that caused bug 8717, because in other
05924       * circumstances the "store" is needed. Better not to emit the
05925       * unwanted type-initializer assignment into the IR in the first
05926       * place.
05927       */
05928       if (!is_interface &&
05929 
05930           (ATD_IM_A_DOPE(attr_idx) &&
05931            (ATD_CLASS(attr_idx) != Dummy_Argument ||
05932             (ATD_ARRAY_IDX(attr_idx) &&
05933              BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Assumed_Shape))) ||
05934 
05935            /* Follows is the default init check */
05936 
05937           (TYP_TYPE(type_idx) == Structure &&
05938            ATD_CLASS(attr_idx) != Constant &&
05939            (ATD_CLASS(attr_idx) != Dummy_Argument ||
05940               ATD_INTENT(attr_idx) == Intent_Out) &&
05941             ATD_CLASS(attr_idx) != CRI__Pointee &&
05942            ((ATT_POINTER_CPNT(TYP_IDX(type_idx)) ||
05943 #ifdef KEY /* Bug 6845 */
05944            ATT_ALLOCATABLE_CPNT(TYP_IDX(type_idx)) ||
05945 #endif /* KEY Bug 6845 */
05946              ATT_DEFAULT_INITIALIZED(TYP_IDX(type_idx))) &&
05947             !ATD_DATA_INIT(attr_idx))))
05948 #   else /* KEY Bug 431, (1046, 1289, 8717) */
05949       if (!is_interface &&
05950 
05951           (ATD_IM_A_DOPE(attr_idx) &&
05952            (ATD_CLASS(attr_idx) != Dummy_Argument ||
05953             (ATD_ARRAY_IDX(attr_idx) &&
05954              BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Assumed_Shape))) ||
05955 
05956            /* Follows is the default init check */
05957 
05958           (TYP_TYPE(type_idx) == Structure &&
05959            ATD_CLASS(attr_idx) != Constant &&
05960            (ATD_CLASS(attr_idx) != Dummy_Argument ||
05961               ATD_INTENT(attr_idx) == Intent_Out) &&
05962             ATD_CLASS(attr_idx) != CRI__Pointee &&
05963            (ATT_POINTER_CPNT(TYP_IDX(type_idx)) ||
05964             (ATT_DEFAULT_INITIALIZED(TYP_IDX(type_idx)) &&
05965             !ATD_DATA_INIT(attr_idx)))))
05966 #   endif /* KEY Bug 431, (1046, 1289, 8717) */
05967 # endif /* 0 */
05968       {
05969 
05970          entry_sh_idx   = curr_stmt_sh_idx;
05971          end_entry_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
05972 
05973          if (ATD_IM_A_DOPE(attr_idx)                                   &&
05974              ATD_CLASS(attr_idx)                     == Dummy_Argument &&
05975              ATD_ARRAY_IDX(attr_idx)                                   &&
05976              BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Assumed_Shape) {
05977 
05978             /* Fill in the lower bound of Assumed Shape dummy arg here */
05979             /* TARGET will go here also */
05980 
05981             for (i = 1; i <= BD_RANK(ATD_ARRAY_IDX(attr_idx)); i++) {
05982 
05983                NTR_IR_TBL(ir_idx);
05984                IR_OPR(ir_idx)      = Dv_Set_Low_Bound;
05985                IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
05986                IR_LINE_NUM(ir_idx) = SH_GLB_LINE(curr_stmt_sh_idx);
05987                IR_COL_NUM(ir_idx)  = SH_COL_NUM(curr_stmt_sh_idx);
05988                IR_FLD_L(ir_idx)    = AT_Tbl_Idx;
05989                IR_IDX_L(ir_idx)    = attr_idx;
05990                IR_LINE_NUM_L(ir_idx) = SH_GLB_LINE(curr_stmt_sh_idx);
05991                IR_COL_NUM_L(ir_idx)  = SH_COL_NUM(curr_stmt_sh_idx);
05992 
05993                IR_FLD_R(ir_idx) = BD_LB_FLD(ATD_ARRAY_IDX(attr_idx), i);
05994                IR_IDX_R(ir_idx) = BD_LB_IDX(ATD_ARRAY_IDX(attr_idx), i);
05995                IR_LINE_NUM_R(ir_idx) = SH_GLB_LINE(curr_stmt_sh_idx);
05996                IR_COL_NUM_R(ir_idx)  = SH_COL_NUM(curr_stmt_sh_idx);
05997 
05998                IR_DV_DIM(ir_idx) = i;
05999 
06000                gen_sh(After, Assignment_Stmt, SH_GLB_LINE(curr_stmt_sh_idx), 
06001                       SH_COL_NUM(curr_stmt_sh_idx), FALSE, FALSE, TRUE);
06002 
06003                SH_IR_IDX(curr_stmt_sh_idx)    = ir_idx;
06004                SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
06005             }
06006 
06007 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
06008 # if 0
06009             if (! ATD_COPY_ASSUMED_SHAPE(attr_idx)) {
06010                /* copy the assumed shape dummy arg to a stack dope vector */
06011 
06012                tmp_idx = gen_compiler_tmp(SH_GLB_LINE(curr_stmt_sh_idx), 
06013                                           SH_COL_NUM(curr_stmt_sh_idx), 
06014                                           Shared, TRUE);
06015 
06016                COPY_ATTR_NTRY(tmp_idx, attr_idx);
06017 
06018                ATD_CLASS(tmp_idx) = Compiler_Tmp;
06019                ATD_STOR_BLK_IDX(tmp_idx)  = SCP_SB_STACK_IDX(curr_scp_idx);
06020                AT_SEMANTICS_DONE(tmp_idx) = TRUE;
06021 
06022                NTR_IR_TBL(ir_idx);
06023                IR_OPR(ir_idx) = Dv_Whole_Copy_Opr;
06024                IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
06025                IR_LINE_NUM(ir_idx) = SH_GLB_LINE(curr_stmt_sh_idx);
06026                IR_COL_NUM(ir_idx)  = SH_COL_NUM(curr_stmt_sh_idx);
06027 
06028                IR_FLD_L(ir_idx) = AT_Tbl_Idx;
06029                IR_IDX_L(ir_idx) = tmp_idx;
06030                IR_LINE_NUM_L(ir_idx) = SH_GLB_LINE(curr_stmt_sh_idx);
06031                IR_COL_NUM_L(ir_idx)  = SH_COL_NUM(curr_stmt_sh_idx);
06032 
06033                IR_FLD_R(ir_idx) = AT_Tbl_Idx;
06034                IR_IDX_R(ir_idx) = attr_idx;
06035                IR_LINE_NUM_R(ir_idx) = SH_GLB_LINE(curr_stmt_sh_idx);
06036                IR_COL_NUM_R(ir_idx)  = SH_COL_NUM(curr_stmt_sh_idx);
06037 
06038                gen_sh(After, Assignment_Stmt, SH_GLB_LINE(curr_stmt_sh_idx),
06039                       SH_COL_NUM(curr_stmt_sh_idx), FALSE, FALSE, TRUE);
06040          
06041                SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
06042                SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
06043 
06044                ATD_SF_ARG_IDX(attr_idx) = tmp_idx;
06045             }
06046 # endif /* 0 */
06047 
06048 # endif /* (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN)) */
06049          }
06050          else if (ATP_PGM_UNIT(pgm_attr_idx) != Blockdata &&
06051                   (ATD_CLASS(attr_idx) != Dummy_Argument ||
06052                    (ATD_INTENT(attr_idx) == Intent_Out &&
06053                     ATT_DEFAULT_INITIALIZED(TYP_IDX(type_idx))))) {
06054 
06055             /* Do not generate entry code for block data program units.  */
06056             /* It is meaningless and PVP codegen blows up.               */
06057 
06058             gen_entry_dope_code(attr_idx);
06059          }
06060 
06061          if (end_entry_sh_idx == NULL_IDX) {
06062 
06063             /* find the end of the gen'd stmts */
06064 
06065             end_entry_sh_idx = entry_sh_idx;
06066 
06067             while (SH_NEXT_IDX(end_entry_sh_idx) != NULL_IDX) {
06068                end_entry_sh_idx = SH_NEXT_IDX(end_entry_sh_idx);
06069             }
06070          }
06071          else {
06072             end_entry_sh_idx = SH_PREV_IDX(end_entry_sh_idx);
06073          }
06074 
06075          if (ATD_AUTOMATIC(attr_idx)) {
06076 
06077             /* reset the curr_stmt_sh_idx if automatic, to get order right */
06078 
06079             curr_stmt_sh_idx = entry_sh_idx;
06080          }
06081 
06082          if (
06083 #ifdef KEY /* Bug 6845, 10835 */
06084        /* Allocatable array */
06085        (ATD_ALLOCATABLE(attr_idx) ||
06086          /* Non-pointer structure with allocatable component(s) or
06087     * subcomponent(s) */
06088          (Structure == TYP_TYPE(ATD_TYPE_IDX(attr_idx)) &&
06089      ATT_ALLOCATABLE_CPNT(TYP_IDX(ATD_TYPE_IDX(attr_idx))) &&
06090      !ATD_POINTER(attr_idx))) &&
06091              /* Allocatable dummy must not be deallocated on exit */
06092        ATD_CLASS(attr_idx) != Dummy_Argument &&
06093 #else /* KEY Bug 6845, 10835 */
06094    ATD_ALLOCATABLE(attr_idx)            &&
06095 #endif /* KEY Bug 6845, 10835 */
06096              ATP_PGM_UNIT(pgm_attr_idx) != Module &&
06097              ! ATP_SAVE_ALL(pgm_attr_idx)         &&
06098              ! ATD_DATA_INIT(attr_idx)            &&
06099              ! ATD_SAVED(attr_idx))               {
06100 
06101             NTR_SN_TBL(sn_idx);
06102 
06103             SN_SIBLING_LINK(sn_idx)   = allocatable_list_idx;
06104             allocatable_list_idx      = sn_idx;
06105             SN_ATTR_IDX(sn_idx)       = attr_idx;
06106             number_of_allocatables++;
06107          }
06108 
06109          insert_sh_after_entries(attr_idx, 
06110                                  entry_sh_idx,
06111                                  end_entry_sh_idx,
06112                                  FALSE,   /* Don't generate tmp = 0  */
06113                                  (ATD_AUTOMATIC(attr_idx) ? FALSE : TRUE));
06114 
06115       }
06116 
06117       if (ATD_AUXILIARY(attr_idx)) {
06118 
06119          if (ATP_PGM_UNIT(pgm_attr_idx) == Module && !ATD_IN_COMMON(attr_idx)) {
06120 
06121             /* Cray is not allowing non-COMMON AUXILIARY data in a MODULE blk */
06122 
06123             PRINTMSG(AT_DEF_LINE(attr_idx), 876, Error,
06124                      AT_DEF_COLUMN(attr_idx),
06125                      AT_OBJ_NAME_PTR(attr_idx));
06126             AT_DCL_ERR(attr_idx)  = TRUE;
06127          }
06128          else if (TYP_TYPE(type_idx) == Character) {
06129             PRINTMSG(AT_DEF_LINE(attr_idx), 535, Error,
06130                      AT_DEF_COLUMN(attr_idx),
06131                      AT_OBJ_NAME_PTR(attr_idx));
06132             AT_DCL_ERR(attr_idx)  = TRUE;
06133          }
06134          else if (TYP_TYPE(type_idx) == Structure &&
06135                   (ATT_POINTER_CPNT(TYP_IDX(type_idx)) ||
06136 #ifdef KEY /* Bug 6845 */
06137                   ATT_ALLOCATABLE_CPNT(TYP_IDX(type_idx)) ||
06138 #endif /* KEY Bug 6845 */
06139                    ATT_CHAR_CPNT(TYP_IDX(type_idx))) ) {
06140             PRINTMSG(AT_DEF_LINE(attr_idx), 536, Error,
06141                      AT_DEF_COLUMN(attr_idx),
06142                      AT_OBJ_NAME_PTR(attr_idx),
06143                      AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
06144             AT_DCL_ERR(attr_idx)  = TRUE;
06145          }
06146       }
06147 
06148       if (ATD_PERMUTATION(attr_idx)) {  /* Must be integer array. */
06149 
06150          if (ATD_ARRAY_IDX(attr_idx) == NULL_IDX ||
06151              TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Integer) {
06152             PRINTMSG(AT_DEF_LINE(attr_idx), 1126, Error,
06153                      AT_DEF_COLUMN(attr_idx),
06154                      AT_OBJ_NAME_PTR(attr_idx));
06155             AT_DCL_ERR(attr_idx)  = TRUE;
06156          }
06157       }
06158 
06159       switch (ATD_CLASS(attr_idx)) {
06160       case Variable:
06161 
06162 #ifdef KEY /* Bug 9029 */
06163          threadprivate_check(attr_idx);
06164 #endif /* KEY Bug 9029 */
06165          if (ATD_EQUIV(attr_idx) &&
06166              AL_NEXT_IDX(ATD_EQUIV_LIST(attr_idx)) == NULL_IDX) {
06167 
06168             /* Only one item on list so, clear it for faster equiv processing */
06169 
06170             ATD_EQUIV_LIST(attr_idx) = NULL_IDX;
06171          }
06172 
06173          /* Intentional fall through */
06174 
06175       case Compiler_Tmp:
06176 
06177          if (ATD_IN_COMMON(attr_idx)) {
06178 
06179             if (TYP_TYPE(type_idx) == Structure &&
06180 #ifdef KEY /* Bug 14150 */
06181                 !(ATT_SEQUENCE_SET(TYP_IDX(type_idx)) ||
06182      AT_BIND_ATTR(TYP_IDX(type_idx)))
06183 #else /* KEY Bug 14150 */
06184                 !ATT_SEQUENCE_SET(TYP_IDX(type_idx))
06185 #endif /* KEY Bug 14150 */
06186     ) {
06187                 AT_DCL_ERR(attr_idx) = TRUE;
06188                 PRINTMSG(AT_DEF_LINE(attr_idx), 373, Error,
06189                          AT_DEF_COLUMN(attr_idx),
06190                          AT_OBJ_NAME_PTR(attr_idx),
06191                          AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
06192             }
06193 #ifdef KEY /* Bug 6845 */
06194             if (TYP_TYPE(type_idx) == Structure &&
06195                 ATT_ALLOCATABLE_CPNT(TYP_IDX(type_idx))) {
06196                 AT_DCL_ERR(attr_idx) = TRUE;
06197                 PRINTMSG(AT_DEF_LINE(attr_idx), 691, Error,
06198                          AT_DEF_COLUMN(attr_idx),
06199                          AT_OBJ_NAME_PTR(attr_idx));
06200       }
06201 #endif /* KEY Bug 6845 */
06202 
06203             if (SB_BLK_HAS_NPES(ATD_STOR_BLK_IDX(attr_idx)) &&
06204                 ATD_DATA_INIT(attr_idx)) {
06205                 PRINTMSG(AT_DEF_LINE(attr_idx), 1227, Error, 
06206                          AT_DEF_COLUMN(attr_idx),
06207                          AT_OBJ_NAME_PTR(attr_idx),
06208                          SB_BLANK_COMMON(ATD_STOR_BLK_IDX(attr_idx)) ?
06209                          "" : SB_NAME_PTR(ATD_STOR_BLK_IDX(attr_idx)));
06210                 AT_DCL_ERR(attr_idx) = TRUE;
06211             }
06212          }
06213          else {
06214 
06215             if (ATD_SYMMETRIC(attr_idx)) {
06216 
06217                if (AT_HOST_ASSOCIATED(attr_idx)) {
06218                   PRINTMSG(AT_DEF_LINE(attr_idx), 1235, Error,
06219                            AT_DEF_COLUMN(attr_idx),
06220                            AT_OBJ_NAME_PTR(attr_idx));
06221 
06222                   ATD_SYMMETRIC(attr_idx)   = FALSE;
06223                }
06224             }
06225             else if (ATP_SYMMETRIC(pgm_attr_idx)) {
06226 
06227                /* Check to see if this item should be switched to symmetric */
06228 
06229                if (fnd_semantic_err(Obj_Symmetric,
06230                                     AT_DEF_LINE(attr_idx),
06231                                     AT_DEF_COLUMN(attr_idx),
06232                                     attr_idx,
06233                                     FALSE)) {
06234 
06235                    /* Blank until caution messages can be issued. */
06236 
06237                   if (AT_HOST_ASSOCIATED(attr_idx)) {
06238                      PRINTMSG(AT_DEF_LINE(attr_idx), 1236, Caution,
06239                               AT_DEF_COLUMN(attr_idx),
06240                               AT_OBJ_NAME_PTR(attr_idx));
06241                   }
06242                   else {
06243 
06244                      if (ATD_TARGET(attr_idx)) {
06245                         PRINTMSG(AT_DEF_LINE(attr_idx), 1234, Caution,
06246                                  AT_DEF_COLUMN(attr_idx),
06247                                  AT_OBJ_NAME_PTR(attr_idx),
06248                                  "TARGET");
06249                      }
06250                      else if (ATD_DATA_INIT(attr_idx)) {
06251                         PRINTMSG(AT_DEF_LINE(attr_idx), 1234, Caution,
06252                                  AT_DEF_COLUMN(attr_idx),
06253                                  AT_OBJ_NAME_PTR(attr_idx),
06254                                  "DATA initialized");
06255                      }
06256                      else if (ATD_SAVED(attr_idx)) {
06257                         PRINTMSG(AT_DEF_LINE(attr_idx), 1234, Caution,
06258                                  AT_DEF_COLUMN(attr_idx),
06259                                  AT_OBJ_NAME_PTR(attr_idx),
06260                                  "SAVE");
06261                      }
06262                      else if (ATD_POINTER(attr_idx)) {
06263                         PRINTMSG(AT_DEF_LINE(attr_idx), 1234, Caution,
06264                                  AT_DEF_COLUMN(attr_idx),
06265                                  AT_OBJ_NAME_PTR(attr_idx),
06266                                  "POINTER");
06267                      }
06268                      else if (ATD_EQUIV(attr_idx)) {
06269                         PRINTMSG(AT_DEF_LINE(attr_idx), 1234, Caution,
06270                                  AT_DEF_COLUMN(attr_idx),
06271                                  AT_OBJ_NAME_PTR(attr_idx),
06272                                  "EQUIVALENCE");
06273                      }
06274                      else if (ATD_ALLOCATABLE(attr_idx)) {
06275                         PRINTMSG(AT_DEF_LINE(attr_idx), 1234, Caution,
06276                                  AT_DEF_COLUMN(attr_idx),
06277                                  AT_OBJ_NAME_PTR(attr_idx),
06278                                  "ALLOCATABLE");
06279                      }
06280                      else if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX &&
06281                               BD_ARRAY_CLASS(attr_idx) == Deferred_Shape) {
06282                         PRINTMSG(AT_DEF_LINE(attr_idx), 1234, Caution,
06283                                  AT_DEF_COLUMN(attr_idx),
06284                                  AT_OBJ_NAME_PTR(attr_idx),
06285                                  "deferred-shape DIMENSION");
06286                      }
06287                   }
06288                }
06289                else {
06290                   ATD_SYMMETRIC(attr_idx) = TRUE;
06291                }
06292             }
06293 
06294             if (ATD_STOR_BLK_IDX(attr_idx) == NULL_IDX) {
06295                assign_storage_blk(attr_idx);
06296             }
06297          }
06298 
06299          break;
06300 
06301       case Dummy_Argument:
06302          ATD_STOR_BLK_IDX(attr_idx) = SCP_SB_DARG_IDX(curr_scp_idx);
06303 
06304          if (ATD_AUXILIARY(attr_idx)) {
06305             SB_AUXILIARY(ATD_STOR_BLK_IDX(attr_idx)) = TRUE;
06306          }
06307 
06308          if (!AT_IS_DARG(attr_idx)) {
06309 #ifdef KEY /* Bug 14255 */
06310            error_not_darg(attr_idx);
06311 #endif /* KEY Bug 14255 */
06312          }
06313          else if (TYP_TYPE(type_idx) == Structure &&
06314                   ATT_DEFAULT_INITIALIZED(TYP_IDX(type_idx)) &&
06315                   ATD_INTENT(attr_idx) == Intent_Out &&
06316                   ATD_ARRAY_IDX(attr_idx) != NULL_IDX &&
06317                   BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Assumed_Size) {
06318             AT_DCL_ERR(attr_idx) = TRUE;
06319             PRINTMSG(AT_DEF_LINE(attr_idx), 1590, Error,
06320                      AT_DEF_COLUMN(attr_idx),
06321                      AT_OBJ_NAME_PTR(attr_idx),
06322                      AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
06323          }
06324 #ifdef KEY /* Bug 14150 */
06325          else if (ATD_VALUE_ATTR(attr_idx) &&
06326      !length_type_param_is_one(attr_idx)) {
06327            PRINTMSG(AT_DEF_LINE(attr_idx), 1695, Error, 
06328        AT_DEF_COLUMN(attr_idx), AT_OBJ_NAME_PTR(attr_idx));
06329    }
06330          break;
06331 #endif /* KEY Bug 14150 */
06332 
06333          break;
06334 
06335       case CRI__Pointee:
06336 
06337          if (pointee_based_blk == NULL_IDX) {
06338 
06339             /* Create a based entry for PDGCS to use for cri_pointees */
06340 
06341             CREATE_ID(storage_name, sb_name[Pointee_Blk], sb_len[Pointee_Blk]);
06342             pointee_based_blk = ntr_stor_blk_tbl(storage_name.string,
06343                                                  sb_len[Pointee_Blk],
06344                                                  AT_DEF_LINE(attr_idx),
06345                                                  AT_DEF_COLUMN(attr_idx),
06346                                                  Based);
06347          }
06348 
06349          ATD_STOR_BLK_IDX(attr_idx) = pointee_based_blk;
06350          pointer_idx      = ATD_PTR_IDX(attr_idx);
06351 
06352          if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
06353 
06354             if (ATD_PTR_TYPE_SET(pointer_idx)) {  /* Pointer locked in */
06355 
06356                if (TYP_LINEAR(ATD_TYPE_IDX(pointer_idx)) != CRI_Ch_Ptr_8) {
06357 
06358                   /* Error - Mixing char and non-char pointers */
06359 
06360                   AT_DCL_ERR(attr_idx)    = TRUE;
06361                   AT_DCL_ERR(pointer_idx) = TRUE;
06362                   PRINTMSG(AT_DEF_LINE(attr_idx), 1428, Error,
06363                            AT_DEF_COLUMN(attr_idx),
06364                            AT_OBJ_NAME_PTR(pointer_idx),
06365                            AT_OBJ_NAME_PTR(attr_idx));
06366                }
06367             }
06368             else {
06369                ATD_PTR_TYPE_SET(pointer_idx)  = TRUE;
06370                ATD_TYPE_IDX(pointer_idx)  = CRI_Ch_Ptr_8;
06371             }
06372             break;
06373          }
06374          else if (ATD_PTR_TYPE_SET(pointer_idx)) {  /* Pointer locked in */
06375 
06376             if (TYP_LINEAR(ATD_TYPE_IDX(pointer_idx)) == CRI_Ch_Ptr_8) {
06377 
06378                /* Error - Mixing char and non-char pointers */
06379 
06380                AT_DCL_ERR(attr_idx) = TRUE;
06381                AT_DCL_ERR(pointer_idx)  = TRUE;
06382                PRINTMSG(AT_DEF_LINE(attr_idx), 1427, Error,
06383                         AT_DEF_COLUMN(attr_idx),
06384                         AT_OBJ_NAME_PTR(pointer_idx),
06385                         AT_OBJ_NAME_PTR(attr_idx));
06386             }
06387          }
06388          
06389 
06390 # if defined(_TARGET_OS_MAX)
06391 
06392          if (PACK_HALF_WORD_TEST_CONDITION(ATD_TYPE_IDX(attr_idx))) {
06393 
06394             if (ATD_PTR_TYPE_SET(pointer_idx)) {
06395 
06396                if (TYP_PTR_INCREMENT(ATD_TYPE_IDX(pointer_idx)) != 32) {
06397                   PRINTMSG(AT_DEF_LINE(pointer_idx), 1092, Error,
06398                            AT_DEF_COLUMN(pointer_idx),
06399                            AT_OBJ_NAME_PTR(pointer_idx));
06400                }
06401             }
06402             else {
06403                CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
06404                TYP_TYPE(TYP_WORK_IDX)   = CRI_Ptr;
06405                TYP_LINEAR(TYP_WORK_IDX)   = CRI_Ptr_8;
06406                TYP_PTR_INCREMENT(TYP_WORK_IDX)  = 32;
06407                ATD_TYPE_IDX(pointer_idx)  = ntr_type_tbl();
06408             }
06409          }
06410          else if (ATD_PTR_TYPE_SET(pointer_idx)) {
06411 
06412             if (TYP_PTR_INCREMENT(ATD_TYPE_IDX(pointer_idx)) != 64) {
06413                PRINTMSG(AT_DEF_LINE(pointer_idx), 1092, Error,
06414                         AT_DEF_COLUMN(pointer_idx),
06415                         AT_OBJ_NAME_PTR(pointer_idx));
06416             }
06417          }  /* Else type uses default pointer type */
06418 
06419 # elif defined(_TARGET_OS_UNICOS)
06420 
06421          /* Issue caution if we are mixing potential 32 bit types with      */
06422          /* 64 bit types.  This works on the PVP okay, but is not portable. */
06423 
06424          if (TARGET_MAX_HALF_WORD_STORAGE_TYPE(ATD_TYPE_IDX(attr_idx))) {
06425 
06426             if (ATD_PTR_TYPE_SET(pointer_idx)) {
06427 
06428                if (!ATD_PTR_HALF_WORD(pointer_idx)) {
06429                   PRINTMSG(AT_DEF_LINE(pointer_idx), 1102, Caution,
06430                            AT_DEF_COLUMN(pointer_idx),
06431                            AT_OBJ_NAME_PTR(pointer_idx));
06432                }
06433             }
06434             else {
06435                ATD_PTR_HALF_WORD(pointer_idx) = TRUE;
06436             }
06437          }
06438          else if (ATD_PTR_TYPE_SET(pointer_idx)) {
06439 
06440             if (ATD_PTR_HALF_WORD(pointer_idx)) {
06441                PRINTMSG(AT_DEF_LINE(pointer_idx), 1102, Caution,
06442                         AT_DEF_COLUMN(pointer_idx),
06443                         AT_OBJ_NAME_PTR(pointer_idx));
06444             }
06445          }
06446 
06447 # elif defined(_TARGET_OS_SOLARIS) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
06448 
06449 #ifdef KEY /* Bug 7299 */
06450    /* We want to use default pointer type for Cray pointers */
06451 #else /* KEY Bug 7299 */
06452          if (TARGET_32BIT_DOUBLE_WORD_STORAGE_TYPE(ATD_TYPE_IDX(attr_idx))) {
06453 
06454             if (ATD_PTR_TYPE_SET(pointer_idx)) {
06455 
06456                if (TYP_PTR_INCREMENT(ATD_TYPE_IDX(pointer_idx)) != 64) {
06457                   PRINTMSG(AT_DEF_LINE(pointer_idx), 1092, Error,
06458                            AT_DEF_COLUMN(pointer_idx),
06459                            AT_OBJ_NAME_PTR(pointer_idx));
06460                }
06461             }
06462             else {
06463                CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
06464                TYP_TYPE(TYP_WORK_IDX)   = CRI_Ptr;
06465                TYP_LINEAR(TYP_WORK_IDX)   = CRI_Ptr_8;
06466                TYP_PTR_INCREMENT(TYP_WORK_IDX)  = 64;
06467                ATD_TYPE_IDX(pointer_idx)  = ntr_type_tbl();
06468             }
06469          }
06470          else if (ATD_PTR_TYPE_SET(pointer_idx)) {
06471 
06472             if (TYP_PTR_INCREMENT(ATD_TYPE_IDX(pointer_idx)) != 32) {
06473                PRINTMSG(AT_DEF_LINE(pointer_idx), 1092, Error,
06474                         AT_DEF_COLUMN(pointer_idx),
06475                         AT_OBJ_NAME_PTR(pointer_idx));
06476             }
06477          }  /* Else type uses default pointer type */
06478 #endif /* KEY Bug 7299 */
06479 
06480 # endif
06481          ATD_PTR_TYPE_SET(pointer_idx) = TRUE;
06482          break;
06483 
06484       }  /* End switch */
06485 
06486       if (ATP_PURE(pgm_attr_idx) || ATP_ELEMENTAL(pgm_attr_idx)) {
06487          pure_str = ATP_PURE(pgm_attr_idx) ? "PURE" : "ELEMENTAL";
06488 
06489          if (ATD_SAVED(attr_idx)) {
06490             PRINTMSG(AT_DEF_LINE(attr_idx), 1264, Error,
06491                      AT_DEF_COLUMN(attr_idx),
06492                      AT_OBJ_NAME_PTR(attr_idx),
06493                      pure_str,
06494                      AT_OBJ_NAME_PTR(pgm_attr_idx),
06495                      "SAVE");
06496          }
06497 
06498          if (ATD_DATA_INIT(attr_idx)) {
06499             PRINTMSG(AT_DEF_LINE(attr_idx), 1264, Error,
06500                      AT_DEF_COLUMN(attr_idx),
06501                      AT_OBJ_NAME_PTR(attr_idx),
06502                      pure_str,
06503                      AT_OBJ_NAME_PTR(pgm_attr_idx),
06504                      "DATA initialized");
06505          }
06506 
06507          if (ATD_CLASS(attr_idx) == Dummy_Argument) {
06508 
06509             if (!ATD_POINTER(attr_idx) && ATD_INTENT(attr_idx) != Intent_In) {
06510 
06511                if (ATP_PGM_UNIT(pgm_attr_idx) == Function) {
06512                   PRINTMSG(AT_DEF_LINE(attr_idx), 1265, Error,
06513                            AT_DEF_COLUMN(attr_idx),
06514                            AT_OBJ_NAME_PTR(attr_idx),
06515                            pure_str,
06516                            AT_OBJ_NAME_PTR(pgm_attr_idx));
06517                }
06518                else if (ATP_PGM_UNIT(pgm_attr_idx) == Subroutine &&
06519                   ATD_INTENT(attr_idx) == Intent_Unseen) {
06520                   PRINTMSG(AT_DEF_LINE(attr_idx), 1266, Error,
06521                            AT_DEF_COLUMN(attr_idx),
06522                            AT_OBJ_NAME_PTR(attr_idx),
06523                            pure_str,
06524                            AT_OBJ_NAME_PTR(pgm_attr_idx));
06525                }
06526             }
06527 
06528             if (ATP_ELEMENTAL(pgm_attr_idx) && 
06529                 (ATD_POINTER(attr_idx) || ATD_ARRAY_IDX(attr_idx) != NULL_IDX)){
06530                PRINTMSG(AT_DEF_LINE(attr_idx), 1267, Error,
06531                         AT_DEF_COLUMN(attr_idx),
06532                         AT_OBJ_NAME_PTR(attr_idx),
06533                         AT_OBJ_NAME_PTR(pgm_attr_idx));
06534             }
06535          }
06536       }
06537 
06538       if (ATP_PGM_UNIT(pgm_attr_idx) == Module &&
06539           TYP_TYPE(type_idx) == Structure &&
06540           ATT_DEFAULT_INITIALIZED(TYP_IDX(type_idx)) &&
06541           !ATD_IN_COMMON(attr_idx) &&
06542           (ATD_CLASS(attr_idx) == Atd_Unknown ||
06543            ATD_CLASS(attr_idx) == Variable) &&
06544           !ATD_POINTER(attr_idx) &&
06545           !ATD_ALLOCATABLE(attr_idx) &&
06546 #ifdef KEY /* Bug 7967 */
06547     /* "save<newline>" doesn't mark each individual variable in scope */
06548           !(ATD_SAVED(attr_idx) || ATP_SAVE_ALL(pgm_attr_idx))
06549 #else /* KEY Bug 7967 */
06550           !ATD_SAVED(attr_idx)
06551 #endif /* KEY Bug 7967 */
06552     ) {
06553          PRINTMSG(AT_DEF_LINE(attr_idx), 1641, Ansi,
06554                   AT_DEF_COLUMN(attr_idx),
06555                   AT_OBJ_NAME_PTR(attr_idx),
06556                   AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
06557       }
06558       break;
06559 
06560 
06561    case Pgm_Unit: 
06562 
06563       /* Set in case we have an overloaded intrinsic that references the */
06564       /* standard intrinsic.                                             */
06565 
06566       AT_SEMANTICS_DONE(attr_idx) = TRUE;
06567 
06568       if (ATP_PROC(attr_idx) == Intern_Proc || 
06569           ATP_PROC(attr_idx) == Module_Proc) {
06570 
06571          if (ATP_SCP_IDX(attr_idx) != curr_scp_idx) {
06572 
06573             /* This is an internal or module procedure that is in its   */
06574             /* parent's scope.  Process this when its own scope is done.*/
06575 
06576             AT_SEMANTICS_DONE(attr_idx) = FALSE;
06577             return;
06578          }
06579 
06580          /* If this pgm unit is pure and elemental, the parent        */
06581          /* procedures can be anything and do not need to be checked. */
06582 
06583          if (ATP_PROC(attr_idx) == Intern_Proc &&
06584              (!ATP_PURE(attr_idx) || !ATP_ELEMENTAL(attr_idx))) {
06585              scp_idx = SCP_PARENT_IDX(curr_scp_idx);
06586 
06587             while (scp_idx != NULL_IDX) {
06588 
06589                /* Parent is pure, so child must be too.  This only goes back */
06590 
06591                if (ATP_PURE(SCP_ATTR_IDX(scp_idx)) && 
06592                    !ATP_PURE(attr_idx) && !ATP_ELEMENTAL(attr_idx)) {
06593                   PRINTMSG(AT_DEF_LINE(attr_idx), 1272, Error,
06594                            AT_DEF_COLUMN(attr_idx),
06595                            AT_OBJ_NAME_PTR(attr_idx),
06596                            ATP_PURE(SCP_ATTR_IDX(scp_idx))?"pure":"elemental",
06597                            AT_OBJ_NAME_PTR(SCP_ATTR_IDX(scp_idx)),
06598                            ATP_PURE(SCP_ATTR_IDX(scp_idx))?"PURE":"ELEMENTAL");
06599                }
06600 
06601                if (ATP_ELEMENTAL(SCP_ATTR_IDX(scp_idx)) && 
06602                    !ATP_ELEMENTAL(attr_idx)) {
06603                   PRINTMSG(AT_DEF_LINE(attr_idx), 1272, Error,
06604                            AT_DEF_COLUMN(attr_idx),
06605                            AT_OBJ_NAME_PTR(attr_idx),
06606                            "elemental",
06607                            AT_OBJ_NAME_PTR(SCP_ATTR_IDX(scp_idx)),
06608                            "ELEMENTAL");
06609                }
06610                scp_idx  = SCP_PARENT_IDX(scp_idx);
06611             }
06612          }
06613       }
06614 
06615       if (ATP_PGM_UNIT(attr_idx) == Function) {
06616          rslt_idx = ATP_RSLT_IDX(attr_idx);
06617          type_idx = ATD_TYPE_IDX(rslt_idx);
06618 
06619          if (TYP_TYPE(type_idx) == Structure) {
06620 
06621 #ifdef KEY /* Bug 11741 */
06622       /* Someday it would be well to rewrite the processing of:
06623        *
06624        *  type(t) function f()
06625        *
06626        * so that we treat it as:
06627        *
06628        *  function() result(f)
06629        *    <import, implicit, and other specifications>
06630        *    type(t) :: f
06631        *
06632        * which would eliminate a bunch of special cases caused by the
06633        * attempt to process "type(t)" before we have seen the decls
06634        * within the function. At this spot, we face the special case that
06635        * occurs because the function type appeared prior to a no-list
06636        * "import" statement which would have accessed the host.
06637        */
06638       int type_attr = TYP_IDX(type_idx);
06639       if ((!AT_DEFINED(type_attr)) && ATP_IN_INTERFACE_BLK(attr_idx) &&
06640         SCP_IMPORT(curr_scp_idx)) {
06641         /* *#$*! srch_sym_tbl() requires padded name */
06642         token_type t = initial_token;
06643         char *name = AT_OBJ_NAME_PTR(type_attr);
06644         int name_len = strlen(name);
06645         memcpy(TOKEN_STR(t), name, name_len);
06646         import_from_host(TOKEN_STR(t), name_len, 0, type_attr);
06647       }
06648 #endif /* KEY Bug 11741 */
06649 
06650             if (AT_ATTR_LINK(TYP_IDX(type_idx)) != NULL_IDX) {
06651 
06652                /* If this derived type is host associated (AT_ATTR_LINK is   */
06653                /* set) change the type table to point to the original type.  */
06654                /* It is okay to change the type table, because every attr of */
06655                /* this type needs to do this.                                */
06656 
06657                link_idx = TYP_IDX(type_idx);
06658 
06659                while (AT_ATTR_LINK(link_idx) != NULL_IDX) {
06660                   link_idx = AT_ATTR_LINK(link_idx);
06661                }
06662 
06663                TYP_IDX(type_idx) = link_idx;
06664             }
06665             attr_semantics(TYP_IDX(type_idx), FALSE);
06666          }
06667 
06668          bd_idx = ATD_ARRAY_IDX(rslt_idx);
06669 
06670          if (TYP_TYPE(type_idx) == Character) {
06671 
06672             if (TYP_FLD(type_idx) == AT_Tbl_Idx) {
06673                attr_semantics(TYP_IDX(type_idx), TRUE);
06674             }
06675 
06676             if (TYP_CHAR_CLASS(type_idx) == Assumed_Size_Char) {
06677 
06678                if (ATP_ELEMENTAL(attr_idx)) {
06679                   PRINTMSG(AT_DEF_LINE(rslt_idx), 1564, Error,
06680                            AT_DEF_COLUMN(rslt_idx),
06681                            AT_OBJ_NAME_PTR(rslt_idx), "ELEMENTAL");
06682                }
06683                else if (ATP_PURE(attr_idx)) { 
06684                   PRINTMSG(AT_DEF_LINE(rslt_idx), 1564, Error,
06685                            AT_DEF_COLUMN(rslt_idx),
06686                            AT_OBJ_NAME_PTR(rslt_idx), "PURE");
06687                }
06688             }
06689          }
06690 
06691          if (bd_idx != NULL_IDX && BD_ARRAY_CLASS(bd_idx) != Deferred_Shape) {
06692 
06693             for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
06694 
06695                if (BD_LB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
06696                   attr_semantics(BD_LB_IDX(bd_idx, dim), TRUE);
06697                }
06698 
06699                if (BD_UB_FLD(bd_idx, dim) == AT_Tbl_Idx) {
06700                   attr_semantics(BD_UB_IDX(bd_idx, dim), TRUE);
06701                }
06702             }
06703          }
06704 #ifdef KEY /* Bug 4865 */
06705    /* Setting AT_SEMANTICS_DONE on the result variable here bypasses the
06706           * code inside a later call to function attr_semantics(rslt_idx)
06707     * which would perform default initialization if the result variable
06708     * is a derived type that needs it.
06709     * Since we don't know why the original author wanted to bypass most
06710     * of the execution of that function, it seems safer to force the
06711     * initialization here than to remove the bypassing. */
06712    
06713    if (TYP_TYPE(type_idx) == Structure &&
06714       ATT_DEFAULT_INITIALIZED(TYP_IDX(type_idx))) {
06715 #ifdef KEY /* Bug 7856 */ 
06716       /* Here's something else from attr_semantics() that we're missing.
06717        * And there's a lot more...some day consider removing all the
06718        * code inside "if (ATP_PGM_UNIT(attr_idx) == Function)" and just
06719        * calling attr_semantics(rslt_idx), and seeing what if any reason
06720        * there is to replicate an increasing fraction of attr_semantics()
06721        * here instead of just calling the function outright. */
06722       if (bd_idx != NULL_IDX) {
06723         array_dim_resolution(rslt_idx, FALSE);
06724       }
06725 #endif /* KEY Bug 7856 */ 
06726             gen_entry_dope_code(rslt_idx);
06727    }
06728 #endif /* KEY Bug 4865 */
06729          AT_SEMANTICS_DONE(rslt_idx) = TRUE;
06730       }
06731 
06732 # if defined(_TARGET_OS_SOLARIS) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
06733 
06734       /* These return charcter results on the SPARC but not Cray. */
06735 
06736       if (ATP_PROC(attr_idx) != Intrin_Proc ||
06737           AT_OBJ_NAME(attr_idx) != '_' ||
06738           (!(strcmp(AT_OBJ_NAME_PTR(attr_idx), "_DATE") == 0)) &&
06739 # ifdef KEY
06740           (!(strcmp(AT_OBJ_NAME_PTR(attr_idx), "_FDATE") == 0)) &&
06741 # endif
06742           (!(strcmp(AT_OBJ_NAME_PTR(attr_idx), "_JDATE") == 0)) &&
06743           (!(strcmp(AT_OBJ_NAME_PTR(attr_idx), "_CLOCK") == 0))) {
06744 # endif
06745 
06746          if (AT_USE_ASSOCIATED(attr_idx) || AT_IS_INTRIN(attr_idx)) {
06747             goto EXIT;
06748          }
06749 
06750 # if defined(_TARGET_OS_SOLARIS) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
06751       }
06752       else {
06753          CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
06754          TYP_TYPE(TYP_WORK_IDX)   = Character;
06755          TYP_LINEAR(TYP_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
06756          TYP_CHAR_CLASS(TYP_WORK_IDX) = Const_Len_Char;
06757          TYP_FLD(TYP_WORK_IDX)    = CN_Tbl_Idx;
06758          TYP_IDX(TYP_WORK_IDX)    = C_INT_TO_CN(SA_INTEGER_DEFAULT_TYPE,
06759                                                       8);
06760          ATD_TYPE_IDX(rslt_idx)   = ntr_type_tbl();
06761       }
06762 # endif
06763 
06764       if (ATP_PGM_UNIT(attr_idx) == Function) {
06765 
06766          if (!AT_TYPED(rslt_idx) && ATP_PROC(attr_idx) != Intrin_Proc) {
06767 
06768             if (SCP_IMPL_NONE(curr_scp_idx)) {
06769                AT_DCL_ERR(rslt_idx) = TRUE;
06770                PRINTMSG(AT_DEF_LINE(rslt_idx), 232, Error, 
06771                         AT_DEF_COLUMN(rslt_idx),
06772                         AT_OBJ_NAME_PTR(rslt_idx));
06773             }
06774             else if (!IM_SET(curr_scp_idx, IMPL_IDX(AT_OBJ_NAME(rslt_idx)))) {
06775 
06776                if (SCP_PARENT_NONE(curr_scp_idx)) {
06777