Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 00037 static char USMID[] = "\n@(#)5.0_pl/sources/p_driver.c 5.13 10/20/99 16:13:01\n"; 00038 00039 # include "defines.h" /* Machine dependent ifdefs */ 00040 00041 # include "host.m" /* Host machine dependent macros.*/ 00042 # include "host.h" /* Host machine dependent header.*/ 00043 # include "target.m" /* Target machine dependent macros.*/ 00044 # include "target.h" /* Target machine dependent header.*/ 00045 00046 # include "globals.m" 00047 # include "tokens.m" 00048 # include "sytb.m" 00049 # include "p_globals.m" 00050 # include "debug.m" 00051 00052 # include "globals.h" 00053 # include "tokens.h" 00054 # include "sytb.h" 00055 # include "p_globals.h" 00056 # include "p_driver.h" 00057 # include "fmath.h" 00058 00059 00060 /*****************************************************************\ 00061 |* Function prototypes of static functions declared in this file *| 00062 \*****************************************************************/ 00063 00064 void init_parse_prog_unit(void); 00065 static void check_for_dup_derived_type_lbl(void); 00066 static void ck_lbl_construct_name(void); 00067 static void enter_intrinsic_info (void); 00068 static void init_const_tbl(void); 00069 static void set_integer_default_type(void); 00070 static void stmt_level_semantics(void); 00071 00072 # if defined(_EXPRESSION_EVAL) 00073 static void parse_expr_for_evaluator(void); 00074 # endif 00075 00076 00077 /******************************************************************************\ 00078 |* *| 00079 |* Description: *| 00080 |* Copy the information from the static intrinsic table into the *| 00081 |* dictionary. *| 00082 |* *| 00083 |* Input parameters: *| 00084 |* NONE *| 00085 |* *| 00086 |* Output parameters: *| 00087 |* NONE *| 00088 |* *| 00089 |* Returns: *| 00090 |* NOTHING *| 00091 |* *| 00092 \******************************************************************************/ 00093 void complete_intrinsic_definition(int generic_attr) 00094 00095 { 00096 int al_idx; 00097 int arg_attr_idx; 00098 int arg_idx; 00099 int attr_idx; 00100 int intrin_tbl_idx; 00101 int j; 00102 id_str_type name; 00103 int np_idx; 00104 int result_attr; 00105 int sn_idx; 00106 int tmp_len; 00107 id_str_type tmp_nam; 00108 int dp_specific_args; 00109 int dp_specific_rslt; 00110 00111 00112 TRACE (Func_Entry, "complete_intrinsic_definition", NULL); 00113 00114 # if defined(_DEBUG) 00115 00116 if ((ATI_FIRST_SPECIFIC_IDX(generic_attr) == NULL_IDX && 00117 ATI_NUM_SPECIFICS(generic_attr) > 0)|| 00118 (ATI_FIRST_SPECIFIC_IDX(generic_attr) != NULL_IDX && 00119 ATI_NUM_SPECIFICS(generic_attr) == 0)) { 00120 PRINTMSG(stmt_start_line, 626, Internal, 0, 00121 "correct intrinsic", "complete_intrinsic_definition"); 00122 } 00123 # endif 00124 00125 intrin_tbl_idx = ATI_INTRIN_TBL_IDX(generic_attr); 00126 j = intrin_tbl_idx + 1; 00127 00128 while ((! intrin_tbl[j].generic) && 00129 (intrin_tbl[j].name_len > 0)) { /* just so don't run off end */ 00130 00131 if (cmd_line_flags.s_pointer8) { 00132 if ((strcmp("_MALLOC_I4_I4", (char *)&intrin_tbl[j].id_str) == 0) || 00133 (strcmp("_MALLOC_I4_I8", (char *)&intrin_tbl[j].id_str) == 0)) { 00134 j = j + 1; /* skip over the first specific entry */ 00135 00136 while (intrin_tbl[j].intrin_enum == 0 && 00137 intrin_tbl[j].external == 0) { 00138 j = j + 1; /* skip over the dummy arguments */ 00139 } 00140 } 00141 } 00142 00143 if (INTEGER_DEFAULT_TYPE == Integer_8 || 00144 LOGICAL_DEFAULT_TYPE == Logical_8) { 00145 if ((strcmp("_SIZE_4", (char *)&intrin_tbl[j].id_str) == 0) || 00146 (strcmp("_SCAN_4", (char *)&intrin_tbl[j].id_str) == 0) || 00147 (strcmp("_SIZEOF_4", (char *)&intrin_tbl[j].id_str) == 0) || 00148 (strcmp("_LBOUND0_4", (char *)&intrin_tbl[j].id_str) == 0) || 00149 (strcmp("_SYSTEM_CLOCK_4", (char *)&intrin_tbl[j].id_str) == 0) || 00150 (strcmp("_ASSOCIATED_4", (char *)&intrin_tbl[j].id_str) == 0) || 00151 (strcmp("_SELECTED_REAL_KIND_4", 00152 (char *)&intrin_tbl[j].id_str) == 0) || 00153 (strcmp("_FP_CLASS_I4_H", 00154 (char *)&intrin_tbl[j].id_str) == 0) || 00155 (strcmp("_FP_CLASS_I4_R", 00156 (char *)&intrin_tbl[j].id_str) == 0) || 00157 (strcmp("_FP_CLASS_I4_D", 00158 (char *)&intrin_tbl[j].id_str) == 0) || 00159 (strcmp("_UBOUND0_4", (char *)&intrin_tbl[j].id_str) == 0)) { 00160 j = j + 1; /* skip over the first specific entry */ 00161 00162 while (intrin_tbl[j].intrin_enum == 0 && 00163 intrin_tbl[j].external == 0) { 00164 j = j + 1; /* skip over the dummy arguments */ 00165 } 00166 } 00167 } 00168 00169 dp_specific_args = 0; 00170 dp_specific_rslt = 0; 00171 /* If double precision enabled, alter the */ 00172 /* result type of the intrinsic in the */ 00173 /* static intrinsic table now to reflect the */ 00174 /* correct result type of this intrinsic. */ 00175 00176 /* we don't care about this in source-level translation---fzhao 00177 # if defined(_TARGET_OS_LINUX) 00178 if (intrin_tbl[intrin_tbl_idx].n_specifics == 1) { 00179 if (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'Q' || 00180 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'C' && 00181 intrin_tbl[intrin_tbl_idx].id_str.string[1] == 'Q')) { 00182 PRINTMSG (stmt_start_line, 541, Error, 1); 00183 } 00184 } 00185 # endif 00186 */ 00187 if (intrin_tbl[intrin_tbl_idx].n_specifics == 1 && 00188 # if defined(_QUAD_PRECISION) 00189 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'D' || 00190 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'I' && 00191 intrin_tbl[intrin_tbl_idx].id_str.string[1] == 'D') || 00192 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'C' && 00193 intrin_tbl[intrin_tbl_idx].id_str.string[1] == 'D'))) { 00194 # else 00195 /* 00196 Treat QUAD precision intrinsics as if they were double precision 00197 on platforms that do not actually support quad precision arithmetic. 00198 ie. PVP, T3E 00199 */ 00200 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'D' || 00201 intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'Q' || 00202 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'I' && 00203 intrin_tbl[intrin_tbl_idx].id_str.string[1] == 'D') || 00204 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'I' && 00205 intrin_tbl[intrin_tbl_idx].id_str.string[1] == 'Q') || 00206 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'C' && 00207 intrin_tbl[intrin_tbl_idx].id_str.string[1] == 'D') || 00208 (intrin_tbl[intrin_tbl_idx].id_str.string[0] == 'C' && 00209 intrin_tbl[intrin_tbl_idx].id_str.string[1] == 'Q'))) { 00210 # endif 00211 00212 if ((intrin_tbl[j].data_type == Real_8 || 00213 intrin_tbl[j].data_type == Real_16) && 00214 (1<<intrin_tbl[j].data_type) == intrin_tbl[j+1].data_type) { 00215 dp_specific_args = (1<<DOUBLE_DEFAULT_TYPE); 00216 dp_specific_rslt = DOUBLE_DEFAULT_TYPE; 00217 } 00218 else if (intrin_tbl[j].data_type == Integer_4) { 00219 dp_specific_args = (1<<DOUBLE_DEFAULT_TYPE); 00220 dp_specific_rslt = INTEGER_DEFAULT_TYPE; 00221 } 00222 else if ((intrin_tbl[j].data_type == Complex_8 || 00223 intrin_tbl[j].data_type == Complex_16) && 00224 (1<<intrin_tbl[j].data_type) == intrin_tbl[j+1].data_type) { 00225 dp_specific_args = (1<<DOUBLE_COMPLEX_DEFAULT_TYPE); 00226 dp_specific_rslt = DOUBLE_COMPLEX_DEFAULT_TYPE; 00227 } 00228 00229 if (strcmp("CDABS", (char *)&intrin_tbl[intrin_tbl_idx].id_str) == 0) { 00230 dp_specific_args = (1<<DOUBLE_COMPLEX_DEFAULT_TYPE); 00231 dp_specific_rslt = DOUBLE_DEFAULT_TYPE; 00232 } 00233 00234 if (strcmp("DIMAG", (char *)&intrin_tbl[intrin_tbl_idx].id_str) == 0) { 00235 dp_specific_args = (1<<DOUBLE_COMPLEX_DEFAULT_TYPE); 00236 dp_specific_rslt = DOUBLE_DEFAULT_TYPE; 00237 } 00238 00239 if (strcmp("DREAL", (char *)&intrin_tbl[intrin_tbl_idx].id_str) == 0) { 00240 dp_specific_args = intrin_tbl[j+1].data_type; 00241 dp_specific_rslt = DOUBLE_DEFAULT_TYPE; 00242 } 00243 00244 # ifndef _QUAD_PRECISION 00245 if (strcmp("CQABS", (char *)&intrin_tbl[intrin_tbl_idx].id_str) == 0) { 00246 dp_specific_args = (1<<DOUBLE_COMPLEX_DEFAULT_TYPE); 00247 dp_specific_rslt = DOUBLE_DEFAULT_TYPE; 00248 } 00249 00250 if (strcmp("QIMAG", (char *)&intrin_tbl[intrin_tbl_idx].id_str) == 0) { 00251 dp_specific_args = (1<<DOUBLE_COMPLEX_DEFAULT_TYPE); 00252 dp_specific_rslt = DOUBLE_DEFAULT_TYPE; 00253 } 00254 00255 if (strcmp("QREAL", (char *)&intrin_tbl[intrin_tbl_idx].id_str) == 0) { 00256 dp_specific_args = intrin_tbl[j+1].data_type; 00257 dp_specific_rslt = DOUBLE_DEFAULT_TYPE; 00258 } 00259 # endif 00260 00261 } 00262 00263 tmp_len = intrin_tbl[j].name_len; 00264 strcpy(&tmp_nam.string[0], &intrin_tbl[j].id_str.string[0]); 00265 00266 CREATE_ID(name, 00267 tmp_nam.string, 00268 tmp_len); 00269 00270 NTR_NAME_POOL(&(name.words[0]), intrin_tbl[j].name_len, np_idx); 00271 00272 NTR_ATTR_TBL(attr_idx); 00273 COPY_COMMON_ATTR_INFO(generic_attr, attr_idx, Pgm_Unit); 00274 AT_NAME_LEN(attr_idx) = intrin_tbl[j].name_len; 00275 AT_NAME_IDX(attr_idx) = np_idx; 00276 00277 NTR_INTERFACE_IN_SN_TBL(sn_idx, 00278 attr_idx, 00279 generic_attr, 00280 stmt_start_line, 00281 stmt_start_col); 00282 00283 AT_OBJ_CLASS(attr_idx) = Pgm_Unit; 00284 AT_ELEMENTAL_INTRIN(attr_idx) = intrin_tbl[j].elemental; 00285 ATP_ELEMENTAL(attr_idx) = intrin_tbl[j].elemental && 00286 !(intrin_tbl[j].non_ansi); 00287 ATP_PURE(attr_idx) = ATP_ELEMENTAL(attr_idx); 00288 ATP_PROC(attr_idx) = Intrin_Proc; 00289 AT_IS_INTRIN(attr_idx) = TRUE; 00290 ATP_EXPL_ITRFC(attr_idx) = TRUE; 00291 MAKE_EXTERNAL_NAME(attr_idx, 00292 AT_NAME_IDX(attr_idx), 00293 AT_NAME_LEN(attr_idx)); 00294 ATP_IN_INTERFACE_BLK(attr_idx) = TRUE; 00295 ATP_EXTERNAL_INTRIN(attr_idx) = intrin_tbl[j].external; 00296 ATP_NON_ANSI_INTRIN(attr_idx) = intrin_tbl[j].non_ansi; 00297 ATP_INTRIN_ENUM(attr_idx) = intrin_tbl[j].intrin_enum; 00298 00299 if (intrin_tbl[j].function) { 00300 NTR_ATTR_TBL(result_attr); 00301 COPY_COMMON_ATTR_INFO(attr_idx, result_attr, Data_Obj); 00302 ATD_CLASS(result_attr) = Function_Result; 00303 ATP_RSLT_IDX(attr_idx) = result_attr; 00304 ATD_FUNC_IDX(result_attr) = attr_idx; 00305 ATD_TYPE_IDX(result_attr) = intrin_tbl[j].data_type; 00306 00307 if (dp_specific_rslt != 0) 00308 ATD_TYPE_IDX(result_attr) = dp_specific_rslt; 00309 00310 if ((strcmp("KIND", (char *)&intrin_tbl[j].id_str) == 0) || 00311 (strcmp("_LBOUND", (char *)&intrin_tbl[j].id_str) == 0) || 00312 (strcmp("_UBOUND", (char *)&intrin_tbl[j].id_str) == 0)) { 00313 ATD_TYPE_IDX(result_attr) = INTEGER_DEFAULT_TYPE; 00314 } 00315 00316 ATD_ARRAY_IDX(result_attr) = intrin_tbl[j].n_specifics; 00317 ATD_IM_A_DOPE(result_attr) = intrin_tbl[j].dope; 00318 ATP_PGM_UNIT(attr_idx) = Function; 00319 ATP_NOSIDE_EFFECTS(attr_idx) = TRUE; 00320 ATP_PURE(attr_idx) = TRUE; 00321 } 00322 else { 00323 ATP_PGM_UNIT(attr_idx) = Subroutine; 00324 } 00325 00326 ATP_SCP_IDX(attr_idx) = curr_scp_idx; 00327 00328 j = j + 1; 00329 00330 while ((intrin_tbl[j].intrin_enum == 0) && 00331 (intrin_tbl[j].name_len > 0) && /* just so don't run off end */ 00332 (!intrin_tbl[j].external) && 00333 (!intrin_tbl[j].generic)) { 00334 CREATE_ID(name, 00335 intrin_tbl[j].id_str.string, 00336 intrin_tbl[j].name_len); 00337 00338 NTR_NAME_POOL(&(name.words[0]), 00339 intrin_tbl[j].name_len, 00340 np_idx); 00341 00342 NTR_ATTR_TBL(arg_attr_idx); 00343 AT_DEF_LINE(arg_attr_idx) = stmt_start_line; 00344 AT_DEF_COLUMN(arg_attr_idx) = stmt_start_col; 00345 AT_NAME_LEN(arg_attr_idx) = intrin_tbl[j].name_len; 00346 AT_NAME_IDX(arg_attr_idx) = np_idx; 00347 00348 NTR_SN_TBL(arg_idx); 00349 SN_ATTR_IDX(arg_idx) = arg_attr_idx; 00350 SN_NAME_LEN(arg_idx) = intrin_tbl[j].name_len; 00351 SN_NAME_IDX(arg_idx) = np_idx; 00352 00353 if (ATP_FIRST_IDX(attr_idx) == NULL_IDX) { 00354 ATP_FIRST_IDX(attr_idx) = arg_idx; 00355 } 00356 00357 ATP_NUM_DARGS(attr_idx) += 1; 00358 00359 if (intrin_tbl[j].function) { 00360 AT_OBJ_CLASS(arg_attr_idx) = Pgm_Unit; 00361 AT_NAME_LEN(arg_attr_idx) = intrin_tbl[j].name_len; 00362 AT_NAME_IDX(arg_attr_idx) = np_idx; 00363 ATP_PROC(arg_attr_idx) = Dummy_Proc; 00364 ATP_EXT_NAME_LEN(arg_attr_idx) = intrin_tbl[j].name_len; 00365 ATP_EXT_NAME_IDX(arg_attr_idx) = np_idx; 00366 } 00367 else { 00368 AT_OBJ_CLASS(arg_attr_idx) = Data_Obj; 00369 ATD_CLASS(arg_attr_idx) = Dummy_Argument; 00370 ATD_INTRIN_DARG(arg_attr_idx) = TRUE; 00371 ATD_INTRIN_DARG_TYPE(arg_attr_idx) = intrin_tbl[j].data_type; 00372 if (dp_specific_args != 0) 00373 ATD_INTRIN_DARG_TYPE(arg_attr_idx) = dp_specific_args; 00374 ATD_IM_A_DOPE(arg_attr_idx) = intrin_tbl[j].dope; 00375 ATD_ARRAY_IDX(arg_attr_idx) = intrin_tbl[j].n_specifics; 00376 } 00377 00378 AT_IS_DARG(arg_attr_idx) = TRUE; 00379 AT_OPTIONAL(arg_attr_idx) = intrin_tbl[j].optional; 00380 j = j + 1; 00381 } 00382 00383 if (!cmd_line_flags.s_pointer8) { 00384 if ((strcmp("_MALLOC_I8_I4", (char *)&intrin_tbl[j].id_str) == 0) || 00385 (strcmp("_MALLOC_I8_I8", (char *)&intrin_tbl[j].id_str) == 0)) { 00386 j = j + 1; /* skip over the first specific entry */ 00387 00388 while ((intrin_tbl[j].intrin_enum == 0) && 00389 (! intrin_tbl[j].generic)) { 00390 j = j + 1; /* skip over the dummy arguments */ 00391 } 00392 } 00393 } 00394 00395 if (INTEGER_DEFAULT_TYPE == Integer_4 || 00396 LOGICAL_DEFAULT_TYPE == Logical_4) { 00397 if ((strcmp("_SIZE_8", (char *)&intrin_tbl[j].id_str) == 0) || 00398 (strcmp("_SCAN_8", (char *)&intrin_tbl[j].id_str) == 0) || 00399 (strcmp("_SIZEOF_8", (char *)&intrin_tbl[j].id_str) == 0) || 00400 (strcmp("_LBOUND0_8", (char *)&intrin_tbl[j].id_str) == 0) || 00401 (strcmp("_SYSTEM_CLOCK_8", (char *)&intrin_tbl[j].id_str) == 0) || 00402 (strcmp("_ASSOCIATED_8", (char *)&intrin_tbl[j].id_str) == 0) || 00403 (strcmp("_SELECTED_REAL_KIND_8", 00404 (char *)&intrin_tbl[j].id_str) == 0) || 00405 (strcmp("_FP_CLASS_I8_H", 00406 (char *)&intrin_tbl[j].id_str) == 0) || 00407 (strcmp("_FP_CLASS_I8_R", 00408 (char *)&intrin_tbl[j].id_str) == 0) || 00409 (strcmp("_FP_CLASS_I8_D", 00410 (char *)&intrin_tbl[j].id_str) == 0) || 00411 (strcmp("_UBOUND0_8", (char *)&intrin_tbl[j].id_str) == 0)) { 00412 j = j + 1; /* skip over the first specific entry */ 00413 00414 while ((intrin_tbl[j].intrin_enum == 0) && 00415 (! intrin_tbl[j].generic)) { 00416 j = j + 1; /* skip over the dummy arguments */ 00417 } 00418 } 00419 } 00420 } 00421 00422 /* Do not allow duplicate attrs on the list. It causes havoc in modules. */ 00423 /* And modules is why we keep this list in the first place. */ 00424 00425 al_idx = expanded_intrinsic_list; 00426 00427 while (al_idx != NULL_IDX) { 00428 00429 if (generic_attr == AL_ATTR_IDX(al_idx)) { 00430 break; 00431 } 00432 al_idx = AL_NEXT_IDX(al_idx); 00433 } 00434 00435 if (al_idx == NULL_IDX) { /* Not found - add to list */ 00436 NTR_ATTR_LIST_TBL(al_idx); 00437 AL_ATTR_IDX(al_idx) = generic_attr; 00438 AL_NEXT_IDX(al_idx) = expanded_intrinsic_list; 00439 expanded_intrinsic_list = al_idx; 00440 } 00441 00442 TRACE (Func_Exit, "complete_intrinsic_definition", NULL); 00443 00444 return; 00445 00446 } /* complete_intrinsic_definition */ 00447 00448 /******************************************************************************\ 00449 |* *| 00450 |* Description: *| 00451 |* Copy the information from the static intrinsic table into the *| 00452 |* dictionary. *| 00453 |* *| 00454 |* Input parameters: *| 00455 |* NONE *| 00456 |* *| 00457 |* Output parameters: *| 00458 |* NONE *| 00459 |* *| 00460 |* Returns: *| 00461 |* NOTHING *| 00462 |* *| 00463 \******************************************************************************/ 00464 static void enter_intrinsic_info (void) 00465 00466 { 00467 int attr_idx; 00468 int name_idx = 2; 00469 token_type tmp_token; 00470 int i; 00471 00472 TRACE (Func_Entry, "enter_intrinsic_info", NULL); 00473 00474 i = 1; 00475 tmp_token = initial_token; 00476 TOKEN_COLUMN(tmp_token) = 1; 00477 TOKEN_LINE(tmp_token) = 1; 00478 TOKEN_VALUE(tmp_token) = Tok_Id; 00479 00480 while (i < MAX_INTRIN_TBL_SIZE) { 00481 if (intrin_tbl[i].generic) { 00482 00483 CREATE_ID(TOKEN_ID(tmp_token), 00484 intrin_tbl[i].id_str.string, 00485 intrin_tbl[i].name_len); 00486 00487 TOKEN_LEN(tmp_token) = intrin_tbl[i].name_len; 00488 00489 attr_idx = ntr_sym_tbl(&tmp_token, name_idx); 00490 00491 AT_OBJ_CLASS(attr_idx) = Interface; 00492 AT_IS_INTRIN(attr_idx) = TRUE; 00493 ATI_INTRIN_PASSABLE(attr_idx) = intrin_tbl[i].passable; 00494 ATI_GENERIC_INTRINSIC(attr_idx) = intrin_tbl[i].dope; 00495 AT_ELEMENTAL_INTRIN(attr_idx) = intrin_tbl[i].elemental; 00496 00497 if (intrin_tbl[i].function) { 00498 ATI_INTERFACE_CLASS(attr_idx) = Generic_Function_Interface; 00499 } 00500 else { 00501 ATI_INTERFACE_CLASS(attr_idx) = Generic_Subroutine_Interface; 00502 } 00503 00504 ATI_INTRIN_TBL_IDX(attr_idx) = i; 00505 name_idx = name_idx + 1; 00506 } 00507 00508 i = i + 1; 00509 } 00510 00511 expanded_intrinsic_list = NULL_IDX; 00512 00513 TRACE (Func_Exit, "enter_intrinsic_info", NULL); 00514 00515 return; 00516 00517 } /* enter_intrinsic_info */ 00518 00519 00520 /******************************************************************************\ 00521 |* *| 00522 |* Description: *| 00523 |* To drive the parsing of each statement of a program unit by deter- *| 00524 |* mining the statement's type (based on the statement's first non- *| 00525 |* label, non-construct name token), calling out the approprate state- *| 00526 |* ment parser, and determining if the valid statement is ordered *| 00527 |* properly and allowed in the current program unit context. *| 00528 |* *| 00529 |* Input parameters: *| 00530 |* NONE *| 00531 |* *| 00532 |* Output parameters: *| 00533 |* NONE *| 00534 |* *| 00535 |* Returns: *| 00536 |* NOTHING *| 00537 |* *| 00538 \******************************************************************************/ 00539 00540 void parse_prog_unit (void) 00541 00542 { 00543 int defer_msg = 0; 00544 int name_idx; 00545 int need_ez_debug_label = FALSE; 00546 int prev_stmt_start_line; 00547 int save_blk_stk_idx; 00548 int sh_idx; 00549 00550 # if defined(GENERATE_WHIRL) 00551 int ir_idx; 00552 # endif 00553 00554 00555 TRACE (PU_Start, NULL, NULL); 00556 00557 TRACE (Func_Entry, "parse_prog_unit", NULL); 00558 00559 if (first_time_tbl_alloc) { 00560 first_time_tbl_alloc = FALSE; 00561 /* init_parse_prog_unit already called */ 00562 } 00563 else { 00564 init_parse_prog_unit(); 00565 } 00566 00567 prev_stmt_start_line = stmt_start_line; 00568 pgm_unit_start_line = stmt_start_line; 00569 00570 # if defined(_EXPRESSION_EVAL) 00571 00572 if (cmd_line_flags.expression_eval_expr) { /* Parsing just an expression */ 00573 parse_expr_for_evaluator(); /* Should point to EOPU */ 00574 } 00575 00576 # endif 00577 00578 while (!EOPU_encountered) { 00579 00580 TRACE_NEW_STMT(NULL); 00581 00582 stmt_type = Null_Stmt; 00583 00584 if (need_new_sh) { 00585 sh_idx = curr_stmt_sh_idx; 00586 curr_stmt_sh_idx = ntr_sh_tbl(); 00587 SH_NEXT_IDX(sh_idx) = curr_stmt_sh_idx; 00588 SH_PREV_IDX(curr_stmt_sh_idx) = sh_idx; 00589 } 00590 else { 00591 /* clear out the old one. */ 00592 /* except for prev idx */ 00593 sh_idx = SH_PREV_IDX(curr_stmt_sh_idx); 00594 CLEAR_TBL_NTRY(sh_tbl, curr_stmt_sh_idx); 00595 SH_PREV_IDX(curr_stmt_sh_idx) = sh_idx; 00596 } 00597 00598 ck_lbl_construct_name(); 00599 00600 if (MATCHED_TOKEN_CLASS(Tok_Class_Keyword)) { 00601 determine_stmt_type(); 00602 00603 if (curr_stmt_category == Init_Stmt_Cat && 00604 cdir_switches.implicit_use_idx != NULL_IDX) { 00605 00606 /* We have an implicit use. Is this an unnamed program unit? */ 00607 00608 switch (stmt_type) { 00609 case Blockdata_Stmt: 00610 case Elemental_Stmt: 00611 case Function_Stmt: 00612 case Module_Stmt: 00613 case Program_Stmt: 00614 case Pure_Stmt: 00615 case Recursive_Stmt: 00616 case Subroutine_Stmt: 00617 00618 /* We know for sure that this is a program type statement. */ 00619 /* implicit_use_semantics will be called in p_dcl_pu */ 00620 00621 case Directive_Stmt: 00622 00623 /* Status is unknown - Use the next statement to determine. */ 00624 00625 /* Intentionally blank */ 00626 00627 break; 00628 00629 case Type_Decl_Stmt: 00630 00631 if ((TOKEN_VALUE(token) == Tok_Kwd_Type && 00632 LA_CH_VALUE != LPAREN) || 00633 stmt_has_double_colon()) { 00634 00635 /* This is a type statement or derived type statement, */ 00636 /* so this is an unnamed program unit. */ 00637 00638 implicit_use_semantics(); 00639 } 00640 00641 /* else treat as a typed function statement. */ 00642 00643 break; 00644 00645 default: 00646 implicit_use_semantics(); /* Program is $MAIN. */ 00647 break; 00648 } 00649 } 00650 00651 if (stmt_type != Use_Stmt && 00652 SCP_USED_MODULE_LIST(curr_scp_idx) != NULL_IDX) { 00653 use_stmt_semantics(); 00654 } 00655 00656 if (need_ez_debug_label) { 00657 gen_debug_lbl_stmt(curr_stmt_sh_idx, Ldbg_Stmt_Lbl, NULL_IDX); 00658 need_ez_debug_label = FALSE; 00659 } 00660 00661 if (cmd_line_flags.debug_lvl == Debug_Lvl_0) { /* -ed -G0 */ 00662 00663 /* Generate debug labels for all statements. */ 00664 00665 if (prev_stmt_start_line != stmt_start_line) { 00666 00667 /* End statements have their own code in parse_end_stmt */ 00668 00669 switch (stmt_type) { 00670 case Allocate_Stmt: 00671 case Arith_If_Stmt: 00672 case Assign_Stmt: 00673 case Assignment_Stmt: 00674 case Backspace_Stmt: 00675 case Buffer_Stmt: 00676 case Call_Stmt: 00677 case Case_Stmt: 00678 case Close_Stmt: 00679 case Continue_Stmt: 00680 case Cycle_Stmt: 00681 case Deallocate_Stmt: 00682 case Decode_Stmt: 00683 case Do_Iterative_Stmt: 00684 case Do_While_Stmt: 00685 case Do_Infinite_Stmt: 00686 case Else_Where_Stmt: 00687 case Encode_Stmt: 00688 case Endfile_Stmt: 00689 case Entry_Stmt: 00690 case Exit_Stmt: 00691 case Goto_Stmt: 00692 case If_Cstrct_Stmt: 00693 case If_Stmt: 00694 case Inquire_Stmt: 00695 case Nullify_Stmt: 00696 case Open_Stmt: 00697 case Outmoded_If_Stmt: 00698 case Pause_Stmt: 00699 case Print_Stmt: 00700 case Read_Stmt: 00701 case Return_Stmt: 00702 case Rewind_Stmt: 00703 case Select_Stmt: 00704 case Stop_Stmt: 00705 case Then_Stmt: 00706 case Where_Cstrct_Stmt: 00707 case Where_Stmt: 00708 case Write_Stmt: 00709 gen_debug_lbl_stmt(curr_stmt_sh_idx, 00710 Ldbg_Stmt_Lbl, 00711 NULL_IDX); 00712 break; 00713 00714 } 00715 } 00716 prev_stmt_start_line = stmt_start_line; 00717 } 00718 00719 if (stmt_label_idx != NULL_IDX) { 00720 gen_attr_and_IR_for_lbl(TRUE); 00721 } 00722 00723 (*stmt_parsers[stmt_type])(); 00724 00725 stmt_level_semantics(); 00726 00727 if (cdir_switches.implicit_use_idx != NULL_IDX) { 00728 00729 /* This is an unnamed program unit, whose first */ 00730 /* statement is a type declaration statement. */ 00731 00732 implicit_use_semantics(); 00733 } 00734 00735 if (cmd_line_flags.debug_lvl == Debug_Lvl_1) { /* -ez -G1 */ 00736 00737 /* For optimized debugging - these statements need */ 00738 /* labels at the start of the statement following them. */ 00739 00740 switch (stmt_type) { 00741 case If_Cstrct_Stmt: 00742 case Else_Stmt: 00743 case Else_If_Stmt: 00744 case Else_Where_Stmt: 00745 case Case_Stmt: 00746 case Where_Cstrct_Stmt: 00747 need_ez_debug_label = TRUE; 00748 break; 00749 } 00750 } 00751 } 00752 else { /* MATCHED_TOKEN_CLASS(Tok_Class_Keyword) failed. */ 00753 00754 /* This is a label or construct with nothing on it. This is an */ 00755 /* error situation. Because we are in error recovery, we do a */ 00756 /* little extra work to get more meaningful messages for the user. */ 00757 00758 /* Pathological case: 1. First stmt in prog unit is in error. */ 00759 /* 2. Second stmt in prog unit is END. */ 00760 /* If the Unit record has not been output yet, we need to do it now */ 00761 /* because the next stmt to be parsed is the END stmt, which cause */ 00762 /* all the END stmt records to precede the head-of-prog-unit records.*/ 00763 00764 /* We also need to do a little setup for $MAIN and statement numbers */ 00765 00766 stmt_start_line = LA_CH_LINE; 00767 stmt_start_col = LA_CH_COLUMN; 00768 SH_GLB_LINE(curr_stmt_sh_idx) = stmt_start_line; 00769 SH_COL_NUM(curr_stmt_sh_idx) = stmt_start_col; 00770 SH_STMT_TYPE(curr_stmt_sh_idx) = stmt_type; 00771 00772 if (SCP_ATTR_IDX(curr_scp_idx) == glb_tbl_idx[Main_Attr_Idx] && 00773 !AT_DEFINED(glb_tbl_idx[Main_Attr_Idx]) && 00774 !AT_DCL_ERR(glb_tbl_idx[Main_Attr_Idx])) { 00775 00776 if (curr_stmt_category == Init_Stmt_Cat) { 00777 curr_stmt_category = Use_Stmt_Cat; 00778 } 00779 00780 token = main_token; 00781 TOKEN_LINE(token) = stmt_start_line; 00782 TOKEN_COLUMN(token) = stmt_start_col; 00783 save_blk_stk_idx = blk_stk_idx; 00784 blk_stk_idx = BLK_HEAD_IDX; 00785 defer_msg = 1; 00786 00787 start_new_prog_unit(Program, Program_Blk, TRUE, FALSE, &defer_msg); 00788 00789 CURR_BLK_NAME = NULL_IDX; 00790 blk_stk_idx = save_blk_stk_idx; 00791 } 00792 00793 if (cif_need_unit_rec && 00794 stmt_type != Directive_Stmt && 00795 stmt_type != End_Parallel_Stmt && 00796 stmt_type != End_Do_Parallel_Stmt && 00797 stmt_type != End_Parallel_Case_Stmt && 00798 stmt_type != Parallel_Case_Stmt && 00799 stmt_type != End_Guard_Stmt && 00800 stmt_type != Open_MP_Section_Stmt && 00801 stmt_type != Open_MP_End_Parallel_Stmt && 00802 stmt_type != Open_MP_End_Do_Stmt && 00803 stmt_type != Open_MP_End_Parallel_Sections_Stmt && 00804 stmt_type != Open_MP_End_Sections_Stmt && 00805 stmt_type != Open_MP_End_Section_Stmt && 00806 stmt_type != Open_MP_End_Single_Stmt && 00807 stmt_type != Open_MP_End_Parallel_Do_Stmt && 00808 stmt_type != Open_MP_End_Master_Stmt && 00809 stmt_type != Open_MP_End_Critical_Stmt && 00810 stmt_type != Open_MP_End_Ordered_Stmt && 00811 stmt_type != Open_MP_End_Parallel_Workshare_Stmt && 00812 stmt_type != Open_MP_End_Workshare_Stmt && 00813 stmt_type != SGI_Section_Stmt && 00814 stmt_type != SGI_End_Psection_Stmt && 00815 stmt_type != SGI_End_Pdo_Stmt && 00816 stmt_type != SGI_End_Parallel_Stmt && 00817 stmt_type != SGI_End_Critical_Section_Stmt && 00818 stmt_type != SGI_End_Single_Process_Stmt && 00819 stmt_type != SGI_Region_End_Stmt) { 00820 00821 cif_unit_rec(); 00822 00823 if (cif_flags) { 00824 cif_begin_scope_rec(); 00825 00826 if (cif_flags & XREF_RECS) { 00827 cif_usage_rec(glb_tbl_idx[Main_Attr_Idx], 00828 AT_Tbl_Idx, 00829 stmt_start_line, 00830 stmt_start_col, 00831 CIF_Symbol_Declaration); 00832 } 00833 } 00834 } 00835 00836 if ((stmt_label_idx | stmt_construct_idx) == NULL_IDX) { 00837 00838 if (LA_CH_CLASS == Ch_Class_Digit && ! label_ok) { 00839 PRINTMSG (LA_CH_LINE, 407, Error, LA_CH_COLUMN); 00840 } 00841 else { 00842 00843 /* A statement must begin with a label, construct name, */ 00844 /* keyword or identifier. */ 00845 00846 PRINTMSG (LA_CH_LINE, 100, Error, LA_CH_COLUMN); 00847 } 00848 } 00849 else { 00850 00851 /* If a stmt label exists, issue an error because a keyword or */ 00852 /* identifier must follow it. */ 00853 00854 if (stmt_label_idx != NULL_IDX) { 00855 PRINTMSG (LA_CH_LINE, 6, Error, LA_CH_COLUMN); 00856 00857 /* If the label has any forward references, they must be */ 00858 /* abandoned. They can't be processed because the statement */ 00859 /* type of the current statement is unknown. */ 00860 00861 if (CURR_BLK != Derived_Type_Blk) { 00862 stmt_label_idx = srch_sym_tbl(TOKEN_STR(label_token), 00863 TOKEN_LEN(label_token), 00864 &name_idx); 00865 00866 if (stmt_label_idx != NULL_IDX && 00867 ! AT_DEFINED(stmt_label_idx) && 00868 ATL_FWD_REF_IDX(stmt_label_idx) != NULL_IDX) { 00869 AT_DCL_ERR(stmt_label_idx) = TRUE; 00870 resolve_fwd_lbl_refs(); 00871 } 00872 } 00873 } 00874 00875 /* If a construct name exists, issue an error because a keyword */ 00876 /* or identifier must follow it. */ 00877 00878 if (stmt_construct_idx != NULL_IDX) { 00879 PRINTMSG (LA_CH_LINE, 6, Error, LA_CH_COLUMN); 00880 AT_DCL_ERR(stmt_construct_idx) = TRUE; 00881 } 00882 } 00883 parse_err_flush(Find_EOS, NULL); 00884 NEXT_LA_CH; 00885 00886 if (defer_msg > 1 && LA_CH_CLASS != Ch_Class_EOF) { 00887 PRINTMSG (AT_DEF_LINE(SCP_ATTR_IDX(curr_scp_idx)), defer_msg, 00888 00889 # if defined(_ERROR_DUPLICATE_GLOBALS) 00890 Error, 00891 # else 00892 Warning, 00893 # endif 00894 AT_DEF_COLUMN(SCP_ATTR_IDX(curr_scp_idx))); 00895 } 00896 00897 } 00898 00899 # if defined(GENERATE_WHIRL) 00900 if (stmt_type != Directive_Stmt) { 00901 directives_are_global = FALSE; 00902 } 00903 00904 if (stmt_type != Directive_Stmt && 00905 stmt_type != End_Parallel_Stmt && 00906 stmt_type != End_Do_Parallel_Stmt && 00907 stmt_type != End_Parallel_Case_Stmt && 00908 stmt_type != Parallel_Case_Stmt && 00909 stmt_type != End_Guard_Stmt && 00910 stmt_type != Open_MP_Section_Stmt && 00911 stmt_type != Open_MP_End_Parallel_Stmt && 00912 stmt_type != Open_MP_End_Do_Stmt && 00913 stmt_type != Open_MP_End_Parallel_Sections_Stmt && 00914 stmt_type != Open_MP_End_Sections_Stmt && 00915 stmt_type != Open_MP_End_Section_Stmt && 00916 stmt_type != Open_MP_End_Single_Stmt && 00917 stmt_type != Open_MP_End_Parallel_Do_Stmt && 00918 stmt_type != Open_MP_End_Master_Stmt && 00919 stmt_type != Open_MP_End_Critical_Stmt && 00920 stmt_type != Open_MP_End_Ordered_Stmt && 00921 stmt_type != Open_MP_End_Parallel_Workshare_Stmt && 00922 stmt_type != Open_MP_End_Workshare_Stmt && 00923 stmt_type != SGI_Section_Stmt && 00924 stmt_type != SGI_End_Psection_Stmt && 00925 stmt_type != SGI_End_Pdo_Stmt && 00926 stmt_type != SGI_End_Parallel_Stmt && 00927 stmt_type != SGI_End_Critical_Section_Stmt && 00928 stmt_type != SGI_End_Single_Process_Stmt && 00929 stmt_type != SGI_Region_End_Stmt && 00930 cdir_switches.inline_here_sgi) { 00931 00932 /* generate an End_Inline_Here_Star_Opr stmt next */ 00933 00934 need_new_sh = TRUE; 00935 00936 if (SH_IR_IDX(curr_stmt_sh_idx)) { 00937 /* maybe this should be gen_sh instead */ 00938 00939 SH_NEXT_IDX(curr_stmt_sh_idx) = ntr_sh_tbl(); 00940 SH_PREV_IDX(SH_NEXT_IDX(curr_stmt_sh_idx)) = curr_stmt_sh_idx; 00941 curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx); 00942 SH_STMT_TYPE(curr_stmt_sh_idx) = Directive_Stmt; 00943 } 00944 00945 SH_GLB_LINE(curr_stmt_sh_idx)= stmt_start_line; 00946 SH_COL_NUM(curr_stmt_sh_idx) = stmt_start_col; 00947 00948 NTR_IR_TBL(ir_idx); 00949 IR_OPR(ir_idx) = End_Inline_Here_Star_Opr; 00950 00951 /* must have a type idx */ 00952 00953 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE; 00954 IR_LINE_NUM(ir_idx) = stmt_start_line; 00955 IR_COL_NUM(ir_idx) = stmt_start_col; 00956 00957 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx; 00958 cdir_switches.inline_here_sgi = FALSE; 00959 } 00960 # endif 00961 00962 if (LA_CH_CLASS == Ch_Class_EOF) { /* EOF following EOS */ 00963 EOPU_encountered = TRUE; 00964 } 00965 } /* while */ 00966 00967 # if defined(_EXPRESSION_EVAL) 00968 00969 /* Force an END statement. This is */ 00970 /* for the expression evaluator only. */ 00971 00972 if (cmd_line_flags.expression_eval_stmt || 00973 cmd_line_flags.expression_eval_expr) { 00974 00975 stmt_type = End_Stmt; 00976 00977 if (need_new_sh) { 00978 sh_idx = curr_stmt_sh_idx; 00979 curr_stmt_sh_idx = ntr_sh_tbl(); 00980 SH_NEXT_IDX(sh_idx) = curr_stmt_sh_idx; 00981 SH_PREV_IDX(curr_stmt_sh_idx) = sh_idx; 00982 } 00983 else { 00984 /* clear out the old one. */ 00985 /* except for prev idx */ 00986 sh_idx = SH_PREV_IDX(curr_stmt_sh_idx); 00987 CLEAR_TBL_NTRY(sh_tbl, curr_stmt_sh_idx); 00988 SH_PREV_IDX(curr_stmt_sh_idx) = sh_idx; 00989 } 00990 00991 expression_eval_end(); 00992 } 00993 00994 # endif 00995 00996 if (blk_stk_idx != NULL_IDX) { 00997 00998 if (SCP_ATTR_IDX(curr_scp_idx) == glb_tbl_idx[Main_Attr_Idx] && 00999 stmt_start_line == AT_DEF_LINE(glb_tbl_idx[Main_Attr_Idx]) && 01000 !SCP_IN_ERR(curr_scp_idx) && 01001 LA_CH_CLASS == Ch_Class_EOF) { 01002 01003 /* This is just a trailing statement. */ 01004 01005 SCP_IN_ERR(curr_scp_idx) = TRUE; 01006 AT_DCL_ERR(SCP_ATTR_IDX(curr_scp_idx)) = TRUE; 01007 PRINTMSG (stmt_start_line, 1581, Error, stmt_start_col); 01008 } 01009 01010 /* Clear blk stack and issue missing end msgs for stack. Also takes */ 01011 /* care of appropriate end of program unit processing. */ 01012 01013 clearing_blk_stk = TRUE; 01014 01015 if (need_new_sh) { 01016 sh_idx = curr_stmt_sh_idx; 01017 curr_stmt_sh_idx = ntr_sh_tbl(); 01018 SH_NEXT_IDX(sh_idx) = curr_stmt_sh_idx; 01019 SH_PREV_IDX(curr_stmt_sh_idx) = sh_idx; 01020 } 01021 else { /* clear out the old one - except for prev idx */ 01022 sh_idx = SH_PREV_IDX(curr_stmt_sh_idx); 01023 CLEAR_TBL_NTRY(sh_tbl, curr_stmt_sh_idx); 01024 SH_PREV_IDX(curr_stmt_sh_idx) = sh_idx; 01025 need_new_sh = TRUE; 01026 } 01027 01028 SH_ERR_FLG(curr_stmt_sh_idx) = TRUE; 01029 01030 pop_and_err_blk_stk(NULL_IDX, TRUE); 01031 01032 clearing_blk_stk = FALSE; 01033 } 01034 01035 /* The block stack table is not needed for the rest of compilation. */ 01036 01037 TBL_FREE(blk_stk); 01038 01039 TRACE (Func_Exit, "parse_prog_unit", NULL); 01040 01041 return; 01042 01043 } /* parse_prog_unit */ 01044 01045 01046 /******************************************************************************\ 01047 |* *| 01048 |* Description: *| 01049 |* Initialize for parsing of a program unit. *| 01050 |* *| 01051 |* Input parameters: *| 01052 |* NONE *| 01053 |* *| 01054 |* Output parameters: *| 01055 |* NONE *| 01056 |* *| 01057 |* Returns: *| 01058 |* NOTHING *| 01059 |* *| 01060 \******************************************************************************/ 01061 01062 void init_parse_prog_unit() 01063 01064 { 01065 int i; 01066 int idx; 01067 id_str_type name; 01068 int name_idx; 01069 token_type npes_token; 01070 int npes_attr; 01071 int save_stmt_start_line; 01072 long *type_tbl_base; 01073 long *static_type_tbl_base; 01074 01075 01076 TRACE (Func_Entry, "init_parse_prog_unit", NULL); 01077 01078 save_stmt_start_line = stmt_start_line; 01079 stmt_start_line = 1; 01080 01081 01082 /* This sets/resets the integer sizes back to the sizes specified on the */ 01083 /* commandline in case a CDIR INTEGER changed them. */ 01084 01085 set_integer_default_type(); 01086 01087 01088 if (on_off_flags.recognize_minus_zero) { 01089 for (i = 0; i < MAX_INTRIN_MAP_SIZE; i++) { 01090 if ((strcmp("SIGN", (char *)&intrin_map[i].id_str) == 0) || 01091 (strcmp("DSIGN", (char *)&intrin_map[i].id_str) == 0)) { 01092 intrin_map[i].mapped_4.string[8] = '_'; 01093 intrin_map[i].mapped_8.string[8] = '_'; 01094 } 01095 } 01096 } 01097 01098 01099 /* ALLOCATE memory for tables that exist for the complete compilation. */ 01100 /* The third argument is what the tables index gets set to. If the */ 01101 /* index is not set to NULL, either these entries in the table are */ 01102 /* filled in here, or it is used as a work area. */ 01103 /* BOUNDS_LAST_USED_IDX -> The bounds table has the 0-7 entries reserved */ 01104 /* as a work area for adding new entries. */ 01105 /* NAME_POOL_LAST_IDX -> The name pool has entries 0-2 reserved. Entry */ 01106 /* 0 is not used. 1 and 2 are set to smallest and largest strings. */ 01107 01108 CHECK_INITIAL_ALLOC (blk_stk, NULL_IDX); 01109 01110 CHECK_INITIAL_ALLOC (attr_list_tbl, NULL_IDX); 01111 CHECK_INITIAL_ALLOC (attr_tbl, NULL_IDX); 01112 CHECK_INITIAL_ALLOC (attr_aux_tbl, NULL_IDX); 01113 CHECK_INITIAL_ALLOC (bounds_tbl, BD_LAST_USED_IDX); 01114 CHECK_INITIAL_ALLOC (const_tbl, NULL_IDX); 01115 CHECK_INITIAL_ALLOC (const_pool, NULL_IDX); 01116 CHECK_INITIAL_ALLOC (sec_name_tbl, NULL_IDX); 01117 CHECK_INITIAL_ALLOC (stor_blk_tbl, NULL_IDX); 01118 CHECK_INITIAL_ALLOC (loc_name_tbl, NULL_IDX); 01119 CHECK_INITIAL_ALLOC (hidden_name_tbl,NULL_IDX); 01120 CHECK_INITIAL_ALLOC (name_pool, NP_LAST_USED_IDX); 01121 CHECK_INITIAL_ALLOC (scp_tbl, NULL_IDX); 01122 CHECK_INITIAL_ALLOC (type_tbl, TYP_LAST_USED_IDX); 01123 CHECK_INITIAL_ALLOC (equiv_tbl, NULL_IDX); 01124 01125 CHECK_INITIAL_ALLOC (ir_tbl, NULL_IDX); 01126 CHECK_INITIAL_ALLOC (sh_tbl, NULL_IDX); 01127 CHECK_INITIAL_ALLOC (ir_list_tbl, NULL_IDX); 01128 01129 01130 /* Clear the zero entry of the list tables, because this entry is */ 01131 /* used to keep the free list for the table. */ 01132 01133 CLEAR_TBL_NTRY(attr_list_tbl, NULL_IDX); 01134 CLEAR_TBL_NTRY(ir_tbl, NULL_IDX); 01135 CLEAR_TBL_NTRY(ir_list_tbl, NULL_IDX); 01136 CLEAR_TBL_NTRY(sh_tbl, NULL_IDX); 01137 CLEAR_TBL_NTRY(bounds_tbl, NULL_IDX); 01138 01139 01140 /* Clear globals attribute indexes */ 01141 01142 for (idx = 0; idx < Num_Glb_Tbl_Idxs; idx++) { 01143 glb_tbl_idx[idx] = 0; 01144 } 01145 01146 init_target_opnd = null_opnd; 01147 01148 type_tbl_base = (long *) type_tbl; 01149 static_type_tbl_base = (long *) type_init_tbl; 01150 01151 for (idx = 0; idx < ((Num_Linear_Types+2) * NUM_TYP_WDS); idx++) { 01152 type_tbl_base[idx] = static_type_tbl_base[idx]; 01153 } 01154 01155 01156 /* Initialize the zeroth entry for all those oprs that do not type things.*/ 01157 01158 type_tbl[NULL_IDX] = type_tbl[INTEGER_DEFAULT_TYPE]; 01159 01160 01161 /* Initialize the search limits of the local name table. */ 01162 /* This consists of setting the initial entry, fw, to reference */ 01163 /* the first entry in the name pool and the second entry, lw, to */ 01164 /* reference the second entry in the name pool. The first entry in */ 01165 /* the name is a word of zeros, the second entry is a word of ones. */ 01166 /* pool is a word of zeros. These limits are needed in order to */ 01167 /* search and enter names into the local name table. */ 01168 01169 name_pool[0].name_long = 0; 01170 name_pool[1].name_long = 0; 01171 name_pool[2].name_long = LARGE_WORD_FOR_TBL_SRCH; 01172 01173 curr_scp_idx = INTRINSIC_SCP_IDX; 01174 01175 CLEAR_TBL_NTRY(scp_tbl, INTRINSIC_SCP_IDX); 01176 01177 init_name_and_stor_tbls(INTRINSIC_SCP_IDX, FALSE); 01178 01179 enter_intrinsic_info(); 01180 01181 SCP_FIRST_CHILD_IDX(INTRINSIC_SCP_IDX) = 1; 01182 SCP_NUM_CHILDREN(INTRINSIC_SCP_IDX) = 1; 01183 01184 NTR_SCP_TBL(curr_scp_idx); 01185 01186 SCP_PARENT_IDX(curr_scp_idx) = 0; 01187 01188 01189 /* Init first 2 enteries in loc_name_table and stor_blk_tbl. */ 01190 01191 init_name_and_stor_tbls(curr_scp_idx, TRUE); 01192 01193 01194 /* Put $MAIN into the string pool and the attr table, but do not put it */ 01195 /* into the local name table, unless it is necessary. If $MAIN is */ 01196 /* needed because of a missing PROGRAM statement, it is entered into the */ 01197 /* local name table by p_driver. */ 01198 01199 NTR_ATTR_TBL(glb_tbl_idx[Main_Attr_Idx]); 01200 AT_NAME_LEN(glb_tbl_idx[Main_Attr_Idx]) = 5; 01201 AT_NAME_IDX(glb_tbl_idx[Main_Attr_Idx]) = name_pool_idx + 1; 01202 AT_DEF_LINE(glb_tbl_idx[Main_Attr_Idx]) = curr_glb_line; 01203 AT_DEF_COLUMN(glb_tbl_idx[Main_Attr_Idx]) = 1; 01204 AT_OBJ_CLASS(glb_tbl_idx[Main_Attr_Idx]) = Pgm_Unit; 01205 ATP_EXT_NAME_LEN(glb_tbl_idx[Main_Attr_Idx]) = 5; 01206 ATP_EXT_NAME_IDX(glb_tbl_idx[Main_Attr_Idx]) = name_pool_idx + 1; 01207 ATP_PGM_UNIT(glb_tbl_idx[Main_Attr_Idx]) = Program; 01208 ATP_SCP_IDX(glb_tbl_idx[Main_Attr_Idx]) = curr_scp_idx; 01209 ATP_EXPL_ITRFC(glb_tbl_idx[Main_Attr_Idx]) = TRUE; 01210 01211 CREATE_ID(name, UNNAMED_PROGRAM_NAME, UNNAMED_PROGRAM_NAME_LEN); 01212 NTR_NAME_POOL(&(name.words[0]), UNNAMED_PROGRAM_NAME_LEN, idx); 01213 01214 SCP_ATTR_IDX(curr_scp_idx) = glb_tbl_idx[Main_Attr_Idx]; 01215 01216 PUSH_BLK_STK(Program_Blk); 01217 SCP_IMPL_NONE(curr_scp_idx) = FALSE; 01218 SCP_PARENT_NONE(curr_scp_idx) = FALSE; 01219 01220 for (idx = 0; idx < MAX_IMPL_CHS; idx++) { 01221 IM_TYPE_IDX(curr_scp_idx, idx) = REAL_DEFAULT_TYPE; 01222 IM_SET(curr_scp_idx, idx) = FALSE; 01223 } 01224 01225 for (idx = IMPL_IDX('I'); idx <= IMPL_IDX('N'); idx++) { 01226 IM_TYPE_IDX(curr_scp_idx, idx) = INTEGER_DEFAULT_TYPE; 01227 } 01228 01229 init_const_tbl(); 01230 01231 /* Enter N$PES into symbol table */ 01232 01233 CREATE_ID(TOKEN_ID(npes_token), "N$PES", 5); 01234 01235 TOKEN_COLUMN(npes_token) = 1; 01236 TOKEN_LEN(npes_token) = 5; 01237 TOKEN_LINE(npes_token) = curr_glb_line; 01238 npes_attr = srch_sym_tbl(TOKEN_STR(npes_token), 01239 TOKEN_LEN(npes_token), 01240 &name_idx); 01241 npes_attr = ntr_sym_tbl(&npes_token,name_idx); 01242 LN_DEF_LOC(name_idx) = TRUE; 01243 AT_OBJ_CLASS(npes_attr) = Data_Obj; 01244 AT_COMPILER_GEND(npes_attr) = TRUE; 01245 AT_SEMANTICS_DONE(npes_attr) = TRUE; 01246 ATD_SYMBOLIC_CONSTANT(npes_attr) = TRUE; 01247 ATD_TYPE_IDX(npes_attr) = CG_INTEGER_DEFAULT_TYPE; 01248 01249 /* Enter value for N$PES into the constant table and attr entry. The */ 01250 /* value will be 0 if not entered on the command line; this will mean */ 01251 /* that the value for N$PES will be supplied at link time or run time. */ 01252 /* On non MPP platforms, num_pes will default to 1 if not specified. */ 01253 01254 if (cmd_line_flags.MPP_num_pes == 0) { 01255 ATD_CLASS(npes_attr) = Variable; 01256 } 01257 else { 01258 ATD_CLASS(npes_attr) = Constant; 01259 AT_DEFINED(npes_attr) = TRUE; 01260 ATD_FLD(npes_attr) = CN_Tbl_Idx; 01261 ATD_CONST_IDX(npes_attr) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 01262 cmd_line_flags.MPP_num_pes); 01263 } 01264 01265 const_safevl_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 01266 target_safevl); 01267 01268 /* Initialize the Type table for CHARACTER*(1) for all possible defaults. */ 01269 01270 TYP_IDX(Character_1) = CN_INTEGER_ONE_IDX; 01271 TYP_FLD(Character_1) = CN_Tbl_Idx; 01272 TYP_IDX(Character_2) = CN_INTEGER_ONE_IDX; 01273 TYP_FLD(Character_1) = CN_Tbl_Idx; 01274 TYP_IDX(Character_4) = CN_INTEGER_ONE_IDX; 01275 TYP_FLD(Character_4) = CN_Tbl_Idx; 01276 01277 01278 /* Now that the TYP table has been set up, TYP_LINEAR and */ 01279 /* INTEGER_DEFAULT_TYPE can be referenced. */ 01280 01281 # ifdef _TARGET_OS_SOLARIS 01282 01283 if (TYP_LINEAR(INTEGER_DEFAULT_TYPE) == Integer_8) { 01284 storage_bit_size_tbl[CRI_Ptr_8] = 64; 01285 } 01286 01287 # endif 01288 01289 01290 /* Initialize the bounds table for deferred shape arrays */ 01291 01292 for (idx = BD_DEFERRED_1_IDX; idx <= BD_DEFERRED_7_IDX; idx++) { 01293 CLEAR_TBL_NTRY(bounds_tbl, idx); 01294 BD_ARRAY_CLASS(idx) = Deferred_Shape; 01295 BD_RANK(idx) = idx; 01296 BD_USED_NTRY(idx) = TRUE; 01297 BD_NTRY_SIZE(idx) = 1; 01298 BD_GLOBAL_IDX(idx) = idx; 01299 } 01300 01301 PRINT_INTRIN; /* If -u intrin and DEBUG compiler, print intrin tbl */ 01302 01303 EOPU_encountered = FALSE; 01304 curr_stmt_category = Init_Stmt_Cat; 01305 curr_internal_lbl = 0; 01306 curr_debug_lbl = 0; 01307 if_stmt_lbl_idx = NULL_IDX; 01308 01309 cif_prog_unit_init(); /* Also needed for buffered message file. */ 01310 01311 curr_stmt_sh_idx = ntr_sh_tbl(); 01312 SH_STMT_TYPE(curr_stmt_sh_idx) = Null_Stmt; 01313 SCP_FIRST_SH_IDX(curr_scp_idx) = curr_stmt_sh_idx; 01314 CURR_BLK_FIRST_SH_IDX = curr_stmt_sh_idx; 01315 need_new_sh = FALSE; 01316 01317 /* initialize the cdir stuff */ 01318 01319 init_directive (1); 01320 stmt_start_line = save_stmt_start_line; 01321 01322 TRACE (Func_Exit, "init_parse_prog_unit", NULL); 01323 01324 return; 01325 01326 } /* init_parse_prog_unit */ 01327 01328 01329 /******************************************************************************\ 01330 |* *| 01331 |* Description: *| 01332 |* If the current statement is prefixed by a statement label and/or a *| 01333 |* construct name, this routine captures the statement label token and/or*| 01334 |* processes the construct name. This routine exits without fetching *| 01335 |* the first token of the statement. *| 01336 |* *| 01337 |* Input parameters: *| 01338 |* NONE *| 01339 |* *| 01340 |* Output parameters: *| 01341 |* NONE *| 01342 |* *| 01343 |* Returns: *| 01344 |* NOTHING *| 01345 |* *| 01346 \******************************************************************************/ 01347 01348 static void ck_lbl_construct_name(void) 01349 01350 { 01351 int ir_idx; 01352 int name_idx; 01353 int sh_idx; 01354 01355 01356 TRACE (Func_Entry, "ck_lbl_construct_name", NULL); 01357 01358 stmt_label_idx = NULL_IDX; 01359 stmt_construct_idx = NULL_IDX; 01360 01361 /* An invalid label (e.g. 000) is caught by the scanner which emits a */ 01362 /* message and leaves the input stream so that the next call to get_token */ 01363 /* produces the token following the invalid label. */ 01364 01365 if (label_ok && 01366 MATCHED_TOKEN_CLASS(Tok_Class_Label) && 01367 ! TOKEN_ERR(token)) { 01368 01369 /* Because a label in a derived type definition (including the TYPE and */ 01370 /* END TYPE statements) belongs to the derived type scope (but we don't */ 01371 /* build a SCP entry to represent a derived type definition scoping */ 01372 /* unit), we can't decide what to do with a label until after the */ 01373 /* statement is parsed (so we know what kind of a statement we have) so */ 01374 /* just hold on to the token for now (and set stmt_label_idx to a */ 01375 /* nonzero value so it looks like a label exists). More label */ 01376 /* processing is done by gen_attr_and_IR_for_lbl after the statement */ 01377 /* type has been determined and some final label processing is */ 01378 /* completed after the statement has been parsed (see the code */ 01379 /* following the call to stmt_parsers). */ 01380 01381 label_token = token; 01382 stmt_label_idx = -911; 01383 } 01384 01385 if (MATCHED_TOKEN_CLASS(Tok_Class_Construct_Def)) { 01386 01387 /* If match - token = construct name - the : following is consumed */ 01388 01389 stmt_construct_idx = srch_sym_tbl(TOKEN_STR(token), 01390 TOKEN_LEN(token), 01391 &name_idx); 01392 01393 if (stmt_construct_idx == NULL_IDX || 01394 AT_OBJ_CLASS(stmt_construct_idx) != Label) { 01395 01396 if (stmt_construct_idx == NULL_IDX) { 01397 stmt_construct_idx = ntr_sym_tbl(&token, name_idx); 01398 } 01399 else { 01400 fnd_semantic_err(Obj_Construct, 01401 TOKEN_LINE(token), 01402 TOKEN_COLUMN(token), 01403 stmt_construct_idx, 01404 TRUE); 01405 CREATE_ERR_ATTR(stmt_construct_idx, TOKEN_LINE(token), 01406 TOKEN_COLUMN(token), Label); 01407 } 01408 01409 LN_DEF_LOC(name_idx) = TRUE; 01410 AT_OBJ_CLASS(stmt_construct_idx) = Label; 01411 AT_DEFINED(stmt_construct_idx) = TRUE; 01412 AT_DEF_LINE(stmt_construct_idx) = TOKEN_LINE(token); 01413 ATL_DEBUG_CLASS(stmt_construct_idx) = Ldbg_Construct_Name; 01414 01415 gen_sh(Before, Construct_Def, TOKEN_LINE(token), TOKEN_COLUMN(token), 01416 FALSE, FALSE, FALSE); 01417 01418 sh_idx = SH_PREV_IDX(curr_stmt_sh_idx); 01419 01420 if (SCP_FIRST_SH_IDX(curr_scp_idx) == curr_stmt_sh_idx) { 01421 SCP_FIRST_SH_IDX(curr_scp_idx) = sh_idx; 01422 } 01423 01424 NTR_IR_TBL(ir_idx); 01425 SH_IR_IDX(sh_idx) = ir_idx; 01426 IR_OPR(ir_idx) = Label_Opr; 01427 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE; 01428 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token); 01429 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token); 01430 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(token); 01431 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(token); 01432 IR_FLD_L(ir_idx) = AT_Tbl_Idx; 01433 IR_IDX_L(ir_idx) = stmt_construct_idx; 01434 IR_FLD_R(ir_idx) = SH_Tbl_Idx; 01435 IR_IDX_R(ir_idx) = curr_stmt_sh_idx; 01436 01437 if (cif_flags & XREF_RECS) { 01438 cif_usage_rec(stmt_construct_idx, AT_Tbl_Idx, 01439 TOKEN_LINE(token), TOKEN_COLUMN(token), 01440 CIF_Symbol_Declaration); 01441 } 01442 01443 } 01444 else { 01445 AT_DCL_ERR(stmt_construct_idx) = TRUE; 01446 PRINTMSG(TOKEN_LINE(token), 171, Error, TOKEN_COLUMN(token), 01447 AT_OBJ_NAME_PTR(stmt_construct_idx), 01448 AT_DEF_LINE(stmt_construct_idx)); 01449 } 01450 } 01451 01452 TRACE (Func_Exit, "ck_lbl_construct_name", NULL); 01453 01454 return; 01455 01456 } /* ck_lbl_construct_name */ 01457 01458 /******************************************************************************\ 01459 |* *| 01460 |* Description: *| 01461 |* check_stmt_type is *| 01462 |* TRUE : If the stmt is a type declaration or type definition stmt, *| 01463 |* or END (TYPE) stmt, it's context is ambiguous, so wait *| 01464 |* until a later call to process the label. Otherwise, search *| 01465 |* for the Attr, do conflict checking, etc. now. *| 01466 |* FALSE: A stmt type that was previously ambiguous is now known to *| 01467 |* something outside of a derived type definition so we can at *| 01468 |* last check it for conflicts, generate its Attr entry, and *| 01469 |* the Label_Def IR. *| 01470 |* *| 01471 |* Input parameters: *| 01472 |* check_stmt_type : see above explanation *| 01473 |* *| 01474 |* Output parameters: *| 01475 |* NONE *| 01476 |* *| 01477 |* Returns: *| 01478 |* NOTHING *| 01479 |* *| 01480 \******************************************************************************/ 01481 void gen_attr_and_IR_for_lbl(boolean check_stmt_type) 01482 01483 { 01484 int ir_idx; 01485 int name_idx; 01486 int sh_idx; 01487 01488 01489 TRACE (Func_Entry, "gen_attr_and_IR_for_lbl", NULL); 01490 01491 if (check_stmt_type && 01492 (stmt_type == Type_Decl_Stmt || 01493 stmt_type == Function_Stmt || 01494 stmt_type == Recursive_Stmt || 01495 stmt_type == Subroutine_Stmt || 01496 stmt_type == Pure_Stmt || 01497 stmt_type == Elemental_Stmt || 01498 stmt_type == End_Stmt)) { 01499 goto EXIT; 01500 } 01501 01502 stmt_label_idx = srch_sym_tbl(TOKEN_STR(label_token), 01503 TOKEN_LEN(label_token), 01504 &name_idx); 01505 01506 if (stmt_label_idx == NULL_IDX) { 01507 stmt_label_idx = ntr_sym_tbl(&label_token, name_idx); 01508 AT_OBJ_CLASS(stmt_label_idx) = Label; 01509 ATL_DEBUG_CLASS(stmt_label_idx) = Ldbg_User_Lbl; 01510 01511 if (! check_stmt_type) { 01512 ATL_CLASS(stmt_label_idx) = Lbl_User; 01513 } 01514 01515 LN_DEF_LOC(name_idx) = TRUE; 01516 } 01517 01518 if (AT_DEFINED(stmt_label_idx)) { 01519 PRINTMSG(TOKEN_LINE(label_token), 146, Error, 01520 TOKEN_COLUMN(label_token), 01521 AT_OBJ_NAME_PTR(stmt_label_idx), 01522 AT_DEF_LINE(stmt_label_idx)); 01523 } 01524 else { 01525 01526 /* If there are forward references to the label, AT_DEFINED and */ 01527 /* ATL_DEF_STMT_IDX will be set after the forward refs are processed. */ 01528 01529 if (ATL_FWD_REF_IDX(stmt_label_idx) == NULL_IDX) { 01530 AT_DEFINED(stmt_label_idx) = TRUE; 01531 ATL_DEF_STMT_IDX(stmt_label_idx) = curr_stmt_sh_idx; 01532 } 01533 01534 if (! cdir_switches.vector) { 01535 ATL_NOVECTOR(stmt_label_idx) = TRUE; 01536 } 01537 01538 AT_DEF_LINE(stmt_label_idx) = TOKEN_LINE(label_token); 01539 SH_LABELED(curr_stmt_sh_idx) = TRUE; 01540 01541 gen_sh(Before, Label_Def, 01542 TOKEN_LINE(label_token), TOKEN_COLUMN(label_token), 01543 FALSE, FALSE, FALSE); 01544 01545 sh_idx = SH_PREV_IDX(curr_stmt_sh_idx); 01546 01547 if (SCP_FIRST_SH_IDX(curr_scp_idx) == curr_stmt_sh_idx) { 01548 SCP_FIRST_SH_IDX(curr_scp_idx) = sh_idx; 01549 } 01550 01551 NTR_IR_TBL(ir_idx); 01552 SH_IR_IDX(sh_idx) = ir_idx; 01553 IR_OPR(ir_idx) = Label_Opr; 01554 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE; 01555 IR_LINE_NUM(ir_idx) = TOKEN_LINE(label_token); 01556 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(label_token); 01557 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(label_token); 01558 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(label_token); 01559 IR_FLD_L(ir_idx) = AT_Tbl_Idx; 01560 IR_IDX_L(ir_idx) = stmt_label_idx; 01561 IR_FLD_R(ir_idx) = SH_Tbl_Idx; 01562 IR_IDX_R(ir_idx) = curr_stmt_sh_idx; 01563 01564 if (cif_flags & XREF_RECS) { 01565 cif_usage_rec(stmt_label_idx, AT_Tbl_Idx, 01566 TOKEN_LINE(label_token), TOKEN_COLUMN(label_token), 01567 CIF_Symbol_Declaration); 01568 } 01569 01570 } 01571 01572 EXIT: 01573 01574 TRACE (Func_Exit, "gen_attr_and_IR_for_lbl", NULL); 01575 01576 return; 01577 01578 } /* gen_attr_and_IR_for_lbl */ 01579 01580 01581 /******************************************************************************\ 01582 |* *| 01583 |* Description: *| 01584 |* Based on the keyword-form token just obtained, determine the stmt *| 01585 |* type. This code exists as a separate procedure because it's also *| 01586 |* needed by logical IF stmt processing to determine the stmt type of *| 01587 |* stmt following the IF condition. *| 01588 |* *| 01589 |* Input parameters: *| 01590 |* NONE *| 01591 |* *| 01592 |* Output parameters: *| 01593 |* NONE *| 01594 |* *| 01595 |* Returns: *| 01596 |* NOTHING *| 01597 |* *| 01598 \******************************************************************************/ 01599 01600 void determine_stmt_type(void) 01601 01602 { 01603 int buf_idx; 01604 int stmt_num; 01605 01606 TRACE (Func_Entry, "determine_stmt_type", NULL); 01607 stmt_start_line = TOKEN_LINE(token); 01608 stmt_start_col = TOKEN_COLUMN(token); 01609 buf_idx = TOKEN_BUF_IDX(token); 01610 stmt_num = TOKEN_STMT_NUM(token); 01611 stmt_type = token_to_stmt_type [TOKEN_VALUE(token)]; 01612 01613 SH_GLB_LINE(curr_stmt_sh_idx) = stmt_start_line; 01614 SH_COL_NUM(curr_stmt_sh_idx) = stmt_start_col; 01615 01616 if (stmt_type == Format_Stmt && 01617 stmt_label_idx && 01618 LA_CH_VALUE == LPAREN) { 01619 01620 /* if it is label "format" "(" then it is a format stmt. */ 01621 /* whether you like it or not. */ 01622 /* intentionally blank. */ 01623 } 01624 else if (stmt_type != Assignment_Stmt && 01625 stmt_type != Directive_Stmt && 01626 stmt_type != End_Parallel_Stmt && 01627 stmt_type != End_Do_Parallel_Stmt && 01628 stmt_type != End_Parallel_Case_Stmt && 01629 stmt_type != Parallel_Case_Stmt && 01630 stmt_type != End_Guard_Stmt && 01631 stmt_type != Open_MP_Section_Stmt && 01632 stmt_type != Open_MP_End_Parallel_Stmt && 01633 stmt_type != Open_MP_End_Do_Stmt && 01634 stmt_type != Open_MP_End_Parallel_Sections_Stmt && 01635 stmt_type != Open_MP_End_Sections_Stmt && 01636 stmt_type != Open_MP_End_Section_Stmt && 01637 stmt_type != Open_MP_End_Single_Stmt && 01638 stmt_type != Open_MP_End_Parallel_Do_Stmt && 01639 stmt_type != Open_MP_End_Master_Stmt && 01640 stmt_type != Open_MP_End_Critical_Stmt && 01641 stmt_type != Open_MP_End_Ordered_Stmt && 01642 stmt_type != Open_MP_End_Parallel_Workshare_Stmt && 01643 stmt_type != Open_MP_End_Workshare_Stmt && 01644 stmt_type != SGI_Section_Stmt && 01645 stmt_type != SGI_End_Psection_Stmt && 01646 stmt_type != SGI_End_Pdo_Stmt && 01647 stmt_type != SGI_End_Parallel_Stmt && 01648 stmt_type != SGI_End_Critical_Section_Stmt && 01649 stmt_type != SGI_End_Single_Process_Stmt && 01650 stmt_type != SGI_Region_End_Stmt) { 01651 01652 if (TOKEN_VALUE(token) == Tok_Kwd_Double && ! set_stmt_type_known()) { 01653 01654 /* Kludge to handle the fixed form case of DOUBLE */ 01655 /* possibly being a DO stmt (e.g. DO uble = ...) */ 01656 01657 reset_lex (buf_idx, stmt_num); 01658 MATCHED_TOKEN_CLASS (Tok_Class_DO); 01659 stmt_type = Do_Iterative_Stmt; 01660 } 01661 01662 if (stmt_type == Do_Iterative_Stmt) { 01663 01664 if (! set_stmt_type_known() ) { 01665 01666 if (! stmt_is_DO_stmt () ) { 01667 stmt_type = Assignment_Stmt; 01668 } 01669 } 01670 } 01671 else if (stmt_type == Data_Stmt) { 01672 01673 if ( ! stmt_is_DATA_stmt () ) { 01674 stmt_type = Assignment_Stmt; 01675 } 01676 } 01677 else if (! set_stmt_type_known() ) { 01678 stmt_type = Assignment_Stmt; 01679 } 01680 } 01681 01682 if (stmt_type == Assignment_Stmt) { 01683 01684 if (TOKEN_VALUE(token) != Tok_Id) { 01685 01686 /* The token is a keyword but is NOT a beginning of stmt keyword */ 01687 /* and therefore the first token must be reinterpreted as an id so */ 01688 /* that fixed form stmts get parsed right (e.g. for "INDEX = 0" we */ 01689 /* have keyword IN at this point and it needs to be id INDEX). */ 01690 /* NOTE: the backup col and line don't have to be reset. */ 01691 01692 reset_lex (buf_idx, stmt_num); 01693 MATCHED_TOKEN_CLASS(Tok_Class_Id); 01694 } 01695 } 01696 01697 /* Fill in rest of stmt header. */ 01698 01699 SH_STMT_TYPE(curr_stmt_sh_idx) = stmt_type; 01700 01701 /* need_new_sh = TRUE will cause a new SH to be generated for the next */ 01702 /* statement. If this statement is a declarative statement and doesn't */ 01703 /* have a label, the new SH can be reused for the next statement, so */ 01704 /* need_new_sh is set to FALSE. */ 01705 01706 need_new_sh = TRUE; 01707 01708 01709 /* If "other" CIF records were requested, call cif_stmt_type_rec to */ 01710 /* perhaps output a Statement Type record (it will only be output if the */ 01711 /* statement can be exactly determined by this procedure; otherwise, the */ 01712 /* specific parsing code will call cif_stmt_type_rec again with the exact */ 01713 /* statement type. */ 01714 01715 if (cif_flags & MISC_RECS) { 01716 cif_stmt_type_rec(FALSE, CIF_Not_Exact, statement_number); 01717 } 01718 01719 TRACE (Func_Exit, "determine_stmt_type", NULL); 01720 01721 return; 01722 01723 } /* determine_stmt_type */ 01724 01725 /******************************************************************************\ 01726 |* *| 01727 |* Description: *| 01728 |* This routine checks thru the block stack to see if there really is *| 01729 |* a block or context error. NOTE: The CYCLE, END, and EXIT stmts *| 01730 |* handle there own stuff. *| 01731 |* *| 01732 |* Input parameters: *| 01733 |* NONE *| 01734 |* *| 01735 |* Output parameters: *| 01736 |* NONE *| 01737 |* *| 01738 |* Returns: *| 01739 |* TRUE if there really is a block or context error. FALSE if we are in *| 01740 |* an error recovery situation and the error shouldn't be issued. *| 01741 |* *| 01742 \******************************************************************************/ 01743 boolean iss_blk_stk_err(void) 01744 01745 { 01746 int blk_idx; 01747 int err_msg; 01748 boolean iss_msg; 01749 01750 01751 TRACE (Func_Entry, "iss_blk_stk_err", NULL); 01752 01753 /* If the action-stmt of a logical IF is being parsed, don't issue a block */ 01754 /* stack error for the action-stmt (it's already been issued for the IF */ 01755 /* statement). */ 01756 01757 if (if_stmt_lbl_idx != NULL_IDX) { 01758 iss_msg = FALSE; 01759 goto EXIT; 01760 } 01761 01762 err_msg = 5; /* Default to stmt out of order msg */ 01763 iss_msg = TRUE; /* Assume msg will be issued */ 01764 01765 if (STMT_CANT_BE_IN_BLK(stmt_type, CURR_BLK)) { 01766 01767 for (blk_idx = blk_stk_idx; 01768 01769 /* Keep going while blocks still left on stack, they are in */ 01770 /* error, and the stmt doesn't fit into the block. */ 01771 01772 blk_idx > NULL_IDX && 01773 BLK_ERR(blk_idx) == TRUE && 01774 STMT_CANT_BE_IN_BLK(stmt_type, BLK_TYPE(blk_idx)); 01775 01776 blk_idx--); 01777 01778 if (blk_idx > NULL_IDX) { 01779 err_msg = (STMT_CANT_BE_IN_BLK(stmt_type, BLK_TYPE(blk_idx))) ? 01780 blk_err_msgs[BLK_TYPE(blk_idx)] : FALSE; 01781 } 01782 } 01783 01784 switch (stmt_type) { 01785 01786 case Blockdata_Stmt: 01787 case Module_Stmt: 01788 case Program_Stmt: 01789 /* Pop all blocks on stack and issue errors for all unclosed blocks. */ 01790 pop_and_err_blk_stk(NULL_IDX, TRUE); 01791 init_parse_prog_unit(); 01792 err_msg = 0; 01793 iss_msg = FALSE; 01794 break; 01795 01796 case Function_Stmt: 01797 case Subroutine_Stmt: 01798 for (blk_idx = blk_stk_idx; 01799 (blk_idx > NULL_IDX && 01800 BLK_TYPE(blk_idx) != Interface_Blk && 01801 BLK_TYPE(blk_idx) != Contains_Blk); 01802 blk_idx--); 01803 01804 /* Pop back to the first Interface_Blk or Contains_Blk found. If */ 01805 /* neither is on the stack, pop the complete stack. Issue errors */ 01806 01807 pop_and_err_blk_stk(blk_idx, TRUE); 01808 01809 if (blk_idx == NULL_IDX) { 01810 /* Need to generate some cif records */ 01811 01812 if (cif_flags & BASIC_RECS) { 01813 cif_send_sytb(); 01814 } 01815 init_parse_prog_unit(); 01816 } 01817 01818 err_msg = 0; 01819 iss_msg = FALSE; 01820 break; 01821 01822 case Return_Stmt: 01823 if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Function && 01824 ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Subroutine) { 01825 01826 switch (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx))) { 01827 case Module: 01828 err_msg = 19; 01829 break; 01830 01831 case Blockdata: 01832 err_msg = 15; 01833 break; 01834 01835 case Program: 01836 err_msg = 16; 01837 break; 01838 # ifdef _DEBUG 01839 default: 01840 PRINTMSG(stmt_start_line, 179, Internal, 01841 stmt_start_col, "iss_blk_stk_err"); 01842 break; 01843 # endif 01844 } /* End switch */ 01845 } 01846 break; 01847 01848 case Private_Stmt: 01849 case Public_Stmt: 01850 01851 if (STMT_LEGAL_IN_BLK(stmt_type, CURR_BLK)) { 01852 01853 if (STMT_CANT_BE_IN_BLK(stmt_type, BLK_TYPE(BLK_HEAD_IDX))) { 01854 err_msg = blk_err_msgs[BLK_TYPE(BLK_HEAD_IDX)]; 01855 iss_msg = TRUE; 01856 } 01857 } 01858 break; 01859 01860 default: 01861 break; 01862 01863 } /* End switch */ 01864 01865 if (iss_msg && err_msg != 0) { 01866 PRINTMSG(stmt_start_line, err_msg, Error, stmt_start_col, 01867 stmt_type_str[stmt_type]); 01868 01869 if (err_msg != 5) { /* Block error */ 01870 SCP_IN_ERR(curr_scp_idx) = TRUE; 01871 } 01872 } 01873 01874 EXIT: 01875 01876 TRACE (Func_Exit, "iss_blk_stk_err", NULL); 01877 01878 return(iss_msg); 01879 01880 } /* iss_blk_stk_err */ 01881 01882 /******************************************************************************\ 01883 |* *| 01884 |* Description: *| 01885 |* This is a Debug routine that issues an internal error if the parse *| 01886 |* driver ends up calling this. *| 01887 |* *| 01888 |* Input parameters: *| 01889 |* NONE *| 01890 |* *| 01891 |* Output parameters: *| 01892 |* NONE *| 01893 |* *| 01894 |* Returns: *| 01895 |* NONE *| 01896 |* *| 01897 \******************************************************************************/ 01898 01899 void parse_bad_stmt(void) 01900 01901 { 01902 TRACE (Func_Entry, "parse_bad_stmt", NULL); 01903 01904 PRINTMSG(TOKEN_LINE(token), 141, Internal, TOKEN_COLUMN(token)); 01905 01906 TRACE (Func_Exit, "parse_bad_stmt", NULL); 01907 01908 return; 01909 01910 } /* parse_bad_stmt */ 01911 01912 /******************************************************************************\ 01913 |* *| 01914 |* Description: *| 01915 |* Check to see if a label has been duplicated within a derived type *| 01916 |* definition. *| 01917 |* *| 01918 |* Input parameters: *| 01919 |* NONE *| 01920 |* *| 01921 |* Output parameters: *| 01922 |* NONE *| 01923 |* *| 01924 |* Returns: *| 01925 |* NONE *| 01926 |* *| 01927 \******************************************************************************/ 01928 01929 static void check_for_dup_derived_type_lbl(void) 01930 { 01931 int al_idx; 01932 int lbl_list_idx; 01933 int np_idx; 01934 01935 01936 TRACE (Func_Entry, "check_for_dup_derived_type_lbl", NULL); 01937 01938 if (CURR_BLK_NAME == NULL_IDX || AT_DCL_ERR(CURR_BLK_NAME) || CURR_BLK_ERR) { 01939 01940 /* In error situation - clear label and return */ 01941 01942 stmt_label_idx = NULL_IDX; 01943 return; 01944 } 01945 01946 lbl_list_idx = (stmt_type == End_Type_Stmt) ? 01947 ATT_LABEL_LIST_IDX(BLK_NAME(blk_stk_idx + 1)) : 01948 ATT_LABEL_LIST_IDX(CURR_BLK_NAME); 01949 01950 while (lbl_list_idx != NULL_IDX && 01951 ! EQUAL_STRS(TOKEN_STR(label_token), 01952 AT_OBJ_NAME_PTR(AL_ATTR_IDX(lbl_list_idx)))) { 01953 lbl_list_idx = AL_NEXT_IDX(lbl_list_idx); 01954 } 01955 01956 if (lbl_list_idx == NULL_IDX) { 01957 NTR_ATTR_TBL(stmt_label_idx); 01958 AT_DEF_COLUMN(stmt_label_idx) = TOKEN_COLUMN(label_token); 01959 AT_DEF_LINE(stmt_label_idx) = TOKEN_LINE(label_token); 01960 01961 NTR_NAME_POOL(TOKEN_ID(label_token).words, 01962 TOKEN_LEN(label_token), 01963 np_idx); 01964 01965 AT_NAME_IDX(stmt_label_idx) = np_idx; 01966 AT_NAME_LEN(stmt_label_idx) = TOKEN_LEN(label_token); 01967 AT_OBJ_CLASS(stmt_label_idx) = Label; 01968 AT_DEFINED(stmt_label_idx) = TRUE; 01969 ATL_CLASS(stmt_label_idx) = Lbl_User; 01970 ATL_DEF_STMT_IDX(stmt_label_idx) = curr_stmt_sh_idx; 01971 ATL_DEBUG_CLASS(stmt_label_idx) = Ldbg_User_Lbl; 01972 01973 NTR_ATTR_LIST_TBL(al_idx); 01974 AL_ATTR_IDX(al_idx) = stmt_label_idx; 01975 AL_NEXT_IDX(al_idx) = ATT_LABEL_LIST_IDX(CURR_BLK_NAME); 01976 ATT_LABEL_LIST_IDX(CURR_BLK_NAME) = al_idx; 01977 01978 if (cif_flags & INFO_RECS) { 01979 cif_label_rec(stmt_label_idx); 01980 } 01981 01982 if (cif_flags & XREF_RECS) { 01983 cif_usage_rec(stmt_label_idx, 01984 AT_Tbl_Idx, 01985 AT_DEF_LINE(stmt_label_idx), 01986 AT_DEF_COLUMN(stmt_label_idx), 01987 CIF_Symbol_Declaration); 01988 } 01989 } 01990 else { 01991 PRINTMSG(TOKEN_LINE(label_token), 146, Error, 01992 TOKEN_COLUMN(label_token), 01993 TOKEN_STR(label_token), 01994 AT_DEF_LINE(AL_ATTR_IDX(lbl_list_idx))); 01995 stmt_label_idx = AL_ATTR_IDX(lbl_list_idx); 01996 } 01997 01998 TRACE (Func_Exit, "check_for_dup_derived_type_lbl", NULL); 01999 02000 return; 02001 02002 } /* check_for_dup_derived_type_lbl */ 02003 02004 02005 /******************************************************************************\ 02006 |* *| 02007 |* Description: *| 02008 |* This sets the initial default type values based on commandline *| 02009 |* options. This is called once per compilation. *| 02010 |* *| 02011 |* Input parameters: *| 02012 |* NONE *| 02013 |* *| 02014 |* Output parameters: *| 02015 |* NONE *| 02016 |* *| 02017 |* Returns: *| 02018 |* NONE *| 02019 |* *| 02020 \******************************************************************************/ 02021 02022 extern void init_type(void) 02023 02024 { 02025 linear_type_type dp_linear_type; 02026 02027 TRACE (Func_Entry, "init_type", NULL); 02028 02029 set_integer_default_type(); 02030 02031 /* Set the correct linear type for the -dp type table entry. */ 02032 02033 dp_linear_type = half_linear_type[Fortran_Double]; 02034 02035 type_init_tbl[DOUBLE_PRECISION_TYPE_IDX].fld.linear_type = 02036 (cmd_line_flags.s_doubleprecision16) ? Real_16 : 02037 init_default_linear_type[Fortran_Double]; 02038 02039 type_init_tbl[DOUBLE_COMPLEX_TYPE_IDX].fld.linear_type = 02040 (cmd_line_flags.s_doublecomplex16) ? Complex_16: 02041 init_default_linear_type[Fortran_Double_Complex]; 02042 02043 LOGICAL_DEFAULT_TYPE = (cmd_line_flags.s_logical8) ? Logical_8 : 02044 init_default_linear_type[Fortran_Logical]; 02045 REAL_DEFAULT_TYPE = (cmd_line_flags.s_real8) ? Real_8 : 02046 init_default_linear_type[Fortran_Real]; 02047 COMPLEX_DEFAULT_TYPE = (cmd_line_flags.s_complex8) ? Complex_8 : 02048 init_default_linear_type[Fortran_Complex]; 02049 02050 CHARACTER_DEFAULT_TYPE = init_default_linear_type[Fortran_Character]; 02051 02052 # if defined(_ACCEPT_CMD_s_32) 02053 02054 if (cmd_line_flags.s_default32) { 02055 CHARACTER_DEFAULT_TYPE = half_linear_type[Fortran_Character]; 02056 COMPLEX_DEFAULT_TYPE = half_linear_type[Fortran_Complex]; 02057 LOGICAL_DEFAULT_TYPE = half_linear_type[Fortran_Logical]; 02058 REAL_DEFAULT_TYPE = half_linear_type[Fortran_Real]; 02059 02060 type_init_tbl[DOUBLE_PRECISION_TYPE_IDX].fld.linear_type = 02061 half_linear_type[Fortran_Double]; 02062 02063 type_init_tbl[DOUBLE_COMPLEX_TYPE_IDX].fld.linear_type = 02064 half_linear_type[Fortran_Double_Complex]; 02065 02066 02067 # ifdef _TARGET_OS_MAX 02068 dp_linear_type = half_linear_type[Fortran_Real]; 02069 # endif 02070 02071 } 02072 02073 # endif 02074 02075 02076 # if defined(_TARGET32) || defined(_WHIRL_HOST64_TARGET64) || (defined(_HOST32) && defined(_TARGET64)) 02077 02078 if (cmd_line_flags.s_default64) { 02079 CHARACTER_DEFAULT_TYPE = double_linear_type[Fortran_Character]; 02080 COMPLEX_DEFAULT_TYPE = double_linear_type[Fortran_Complex]; 02081 LOGICAL_DEFAULT_TYPE = double_linear_type[Fortran_Logical]; 02082 REAL_DEFAULT_TYPE = double_linear_type[Fortran_Real]; 02083 02084 type_init_tbl[DOUBLE_PRECISION_TYPE_IDX].fld.linear_type = 02085 double_linear_type[Fortran_Double]; 02086 02087 type_init_tbl[DOUBLE_COMPLEX_TYPE_IDX].fld.linear_type = 02088 double_linear_type[Fortran_Double_Complex]; 02089 } 02090 else if (cmd_line_flags.s_float64) { 02091 CHARACTER_DEFAULT_TYPE = init_default_linear_type[Fortran_Character]; 02092 LOGICAL_DEFAULT_TYPE = init_default_linear_type[Fortran_Logical]; 02093 REAL_DEFAULT_TYPE = double_linear_type[Fortran_Real]; 02094 COMPLEX_DEFAULT_TYPE = double_linear_type[Fortran_Complex]; 02095 02096 type_init_tbl[DOUBLE_PRECISION_TYPE_IDX].fld.linear_type = 02097 double_linear_type[Fortran_Double]; 02098 02099 type_init_tbl[DOUBLE_COMPLEX_TYPE_IDX].fld.linear_type = 02100 double_linear_type[Fortran_Double_Complex]; 02101 } 02102 02103 # endif 02104 02105 if (!on_off_flags.enable_double_precision) { 02106 type_init_tbl[DOUBLE_PRECISION_TYPE_IDX].fld.linear_type = dp_linear_type; 02107 02108 type_init_tbl[DOUBLE_COMPLEX_TYPE_IDX].fld.linear_type = 02109 COMPLEX_DEFAULT_TYPE; 02110 02111 type_init_tbl[DOUBLE_PRECISION_TYPE_IDX].fld.dp_hit_me = TRUE; 02112 type_init_tbl[DOUBLE_COMPLEX_TYPE_IDX].fld.dp_hit_me = TRUE; 02113 } 02114 02115 02116 # if defined(GENERATE_WHIRL) 02117 02118 if (cmd_line_flags.s_pointer8) { 02119 storage_bit_size_tbl[CRI_Ptr_8] = 64; 02120 storage_bit_size_tbl[CRI_Ch_Ptr_8] = 128; 02121 storage_bit_size_tbl[CRI_Parcel_Ptr_8] = 64; 02122 } 02123 02124 # endif 02125 02126 02127 TRACE (Func_Exit, "init_type", NULL); 02128 02129 return; 02130 02131 } /* init_type */ 02132 02133 02134 /******************************************************************************\ 02135 |* *| 02136 |* Description: *| 02137 |* This sets the initial default type values based on commandline *| 02138 |* options. This is called once per compilation. *| 02139 |* *| 02140 |* Input parameters: *| 02141 |* NONE *| 02142 |* *| 02143 |* Output parameters: *| 02144 |* NONE *| 02145 |* *| 02146 |* Returns: *| 02147 |* NONE *| 02148 |* *| 02149 \******************************************************************************/ 02150 02151 static void set_integer_default_type(void) 02152 02153 { 02154 TRACE (Func_Entry, "set_integer_default_type", NULL); 02155 02156 02157 /* Set the correct linear type for integer from commandline. */ 02158 02159 if (cmd_line_flags.integer_32) { 02160 INTEGER_DEFAULT_TYPE = Integer_4; 02161 } 02162 else { 02163 # if defined(_TARGET32) || defined(_WHIRL_HOST64_TARGET64) || (defined(_HOST32) && defined(_TARGET64)) 02164 INTEGER_DEFAULT_TYPE = Integer_4; 02165 # else 02166 INTEGER_DEFAULT_TYPE = Integer_8; 02167 # endif 02168 } 02169 02170 if (cmd_line_flags.s_integer8) { 02171 INTEGER_DEFAULT_TYPE = Integer_8; 02172 } 02173 02174 02175 # if defined(_ACCEPT_CMD_s_32) 02176 if (cmd_line_flags.s_default32) { 02177 INTEGER_DEFAULT_TYPE = half_linear_type[Fortran_Integer]; 02178 } 02179 # endif 02180 02181 # if defined(_TARGET32) 02182 if (cmd_line_flags.s_default64) { 02183 INTEGER_DEFAULT_TYPE = double_linear_type[Fortran_Integer]; 02184 } 02185 # endif 02186 02187 TRACE (Func_Exit, "set_integer_default_type", NULL); 02188 02189 return; 02190 02191 } /* set_integer_default_type */ 02192 02193 02194 /******************************************************************************\ 02195 |* *| 02196 |* Description: *| 02197 |* Set up the Constant table, the Constant Search table, and the *| 02198 |* Constant Search Index table. *| 02199 |* *| 02200 |* Input parameters: *| 02201 |* NONE *| 02202 |* *| 02203 |* Output parameters: *| 02204 |* NONE *| 02205 |* *| 02206 |* Returns: *| 02207 |* NONE *| 02208 |* *| 02209 \******************************************************************************/ 02210 02211 static void init_const_tbl(void) 02212 { 02213 int idx; 02214 02215 02216 TRACE (Func_Entry, "init_const_tbl", NULL); 02217 02218 /* IF YOU WANT TO PREDEFINE A NEW CONSTANT YOU MUST ADD IT TO BOTH OF */ 02219 /* THE FOLLOWING IFDEF SECTIONS IN THE APPROPRIATE WAY. */ 02220 02221 02222 for (idx = 0; idx < Num_Linear_Types; idx++) { 02223 cn_root_idx[idx] = 0; 02224 } 02225 02226 /* Initialize first 6 entries of constant table. These are used as */ 02227 /* follows: */ 02228 /* */ 02229 /* CN_INTEGER_ZERO_IDX entry 1 */ 02230 /* CN_INTEGER_ONE_IDX entry 2 */ 02231 /* CN_INTEGER_TWO_IDX entry 3 */ 02232 /* CN_INTEGER_THREE_IDX entry 4 */ 02233 /* CN_INTEGER_NEG_ONE_IDX entry 5 */ 02234 /* CN_INTEGER_BITS_PER_WORD_IDX entry 6 */ 02235 /* CN_INTEGER_CHAR_BIT_IDX entry 7 */ 02236 /* CN_INTEGER_MIN_IDX entry 8 */ 02237 02238 idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 0); 02239 02240 # ifdef _DEBUG 02241 if (idx != CN_INTEGER_ZERO_IDX) { 02242 PRINTMSG(1, 626, Internal, 0, 02243 "CN_INTEGER_ZERO_IDX = 1", "init_const_tbl"); 02244 } 02245 # endif 02246 02247 idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 1); 02248 02249 # ifdef _DEBUG 02250 if (idx != CN_INTEGER_ONE_IDX) { 02251 PRINTMSG(1, 626, Internal, 0, 02252 "CN_INTEGER_ONE_IDX = 2", "init_const_tbl"); 02253 } 02254 # endif 02255 02256 idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 2); 02257 02258 # ifdef _DEBUG 02259 if (idx != CN_INTEGER_TWO_IDX) { 02260 PRINTMSG(1, 626, Internal, 0, 02261 "CN_INTEGER_TWO_IDX = 3", "init_const_tbl"); 02262 } 02263 # endif 02264 02265 idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 3); 02266 02267 # ifdef _DEBUG 02268 if (idx != CN_INTEGER_THREE_IDX) { 02269 PRINTMSG(1, 626, Internal, 0, 02270 "CN_INTEGER_THREE_IDX = 4", "init_const_tbl"); 02271 } 02272 # endif 02273 02274 idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, -1); 02275 02276 # ifdef _DEBUG 02277 if (idx != CN_INTEGER_NEG_ONE_IDX) { 02278 PRINTMSG(1, 626, Internal, 0, 02279 "CN_INTEGER_NEG_ONE_IDX = 5", "init_const_tbl"); 02280 } 02281 # endif 02282 02283 idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, TARGET_BITS_PER_WORD); 02284 02285 # ifdef _DEBUG 02286 if (idx != CN_INTEGER_BITS_PER_WORD_IDX) { 02287 PRINTMSG(1, 626, Internal, 0, 02288 "CN_INTEGER_BITS_PER_WORD_IDX = 6", "init_const_tbl"); 02289 } 02290 # endif 02291 02292 idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, CHAR_BIT); 02293 02294 # ifdef _DEBUG 02295 if (idx != CN_INTEGER_CHAR_BIT_IDX) { 02296 PRINTMSG(1, 626, Internal, 0, 02297 "CN_INTEGER_CHAR_BIT_IDX = 7", "init_const_tbl"); 02298 } 02299 # endif 02300 idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, INT_MIN); 02301 02302 # ifdef _DEBUG 02303 if (idx != CN_INTEGER_MIN_IDX) { 02304 PRINTMSG(1, 626, Internal, 0, 02305 "CN_INTEGER_MIN_IDX = 8", "init_const_tbl"); 02306 } 02307 # endif 02308 02309 02310 /* This is only used by ntr_abnormal_ieee_const but it needs to be */ 02311 /* initialized for each program unit. */ 02312 02313 for (idx = 0; idx < 18; ++idx) { 02314 ieee_const_tbl_idx[idx] = NULL_IDX; 02315 } 02316 02317 TRACE (Func_Exit, "init_const_tbl", NULL); 02318 02319 return; 02320 02321 } /* init_const_tbl */ 02322 02323 /******************************************************************************\ 02324 |* *| 02325 |* Description: *| 02326 |* This procedure is called to add modules specified on the -A *| 02327 |* commandline option to the SCP_USED_MODULE_LIST for this scope. *| 02328 |* *| 02329 |* Input parameters: *| 02330 |* NONE *| 02331 |* *| 02332 |* Output parameters: *| 02333 |* NONE *| 02334 |* *| 02335 |* Returns: *| 02336 |* NONE *| 02337 |* *| 02338 \******************************************************************************/ 02339 02340 void implicit_use_semantics(void) 02341 { 02342 int attr_idx; 02343 int fp_idx; 02344 int list_idx; 02345 int name_idx; 02346 token_type name_token; 02347 02348 02349 TRACE (Func_Entry, "implicit_use_semantics", NULL); 02350 02351 fp_idx = cdir_switches.implicit_use_idx; 02352 cdir_switches.implicit_use_idx = NULL_IDX; 02353 02354 while (fp_idx != NULL_IDX) { 02355 CREATE_ID(TOKEN_ID(name_token),(FP_NAME_PTR(fp_idx)),FP_NAME_LEN(fp_idx)); 02356 02357 TOKEN_COLUMN(name_token) = 1; 02358 TOKEN_LEN(name_token) = FP_NAME_LEN(fp_idx); 02359 TOKEN_LINE(name_token) = stmt_start_line; 02360 02361 attr_idx = srch_sym_tbl(TOKEN_STR(name_token), 02362 TOKEN_LEN(name_token), 02363 &name_idx); 02364 02365 if (attr_idx != NULL_IDX) { /* Name exists in symbol table already */ 02366 02367 if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit && 02368 ATP_PGM_UNIT(attr_idx) == Module) { 02369 02370 /* The only way this could be here, is if it is */ 02371 /* specified multiple times on the -A commandline option. */ 02372 02373 list_idx = SCP_USED_MODULE_LIST(curr_scp_idx); 02374 02375 while (list_idx != NULL_IDX) { 02376 02377 if (AL_ATTR_IDX(list_idx) == attr_idx) { 02378 break; 02379 } 02380 list_idx = AL_NEXT_IDX(list_idx); 02381 } 02382 02383 if (list_idx == NULL_IDX) { 02384 02385 /* Found end of module list. The attr is not */ 02386 /* in the list. Add the attr to the list. */ 02387 02388 /* This should be an error - as in it is the */ 02389 /* same name as the module we are in. An */ 02390 /* error will be issued during use semantics. */ 02391 02392 NTR_ATTR_LIST_TBL(list_idx); 02393 AL_ATTR_IDX(list_idx) = attr_idx; 02394 AL_PREV_MODULE_IDX(SCP_USED_MODULE_LIST(curr_scp_idx))= list_idx; 02395 AL_NEXT_IDX(list_idx) = SCP_USED_MODULE_LIST(curr_scp_idx); 02396 SCP_USED_MODULE_LIST(curr_scp_idx) = list_idx; 02397 AT_USE_ASSOCIATED(attr_idx) = TRUE; 02398 AT_MODULE_IDX(attr_idx) = attr_idx; 02399 } 02400 } 02401 else { /* This is already something else in this scope. */ 02402 PRINTMSG(TOKEN_LINE(name_token), 1496, Error, 02403 TOKEN_COLUMN(name_token), 02404 AT_OBJ_NAME_PTR(attr_idx)); 02405 } 02406 } 02407 else { 02408 attr_idx = ntr_sym_tbl(&name_token, name_idx); 02409 AT_OBJ_CLASS(attr_idx) = Pgm_Unit; 02410 ATP_PGM_UNIT(attr_idx) = Module; 02411 ATP_SCP_IDX(attr_idx) = curr_scp_idx; 02412 ATP_IMPLICIT_USE_MODULE(attr_idx) = TRUE; 02413 MAKE_EXTERNAL_NAME(attr_idx, 02414 AT_NAME_IDX(attr_idx), 02415 AT_NAME_LEN(attr_idx)); 02416 NTR_ATTR_LIST_TBL(list_idx); 02417 AL_ATTR_IDX(list_idx) = attr_idx; 02418 AL_PREV_MODULE_IDX(SCP_USED_MODULE_LIST(curr_scp_idx)) = list_idx; 02419 AL_NEXT_IDX(list_idx) = SCP_USED_MODULE_LIST(curr_scp_idx); 02420 SCP_USED_MODULE_LIST(curr_scp_idx)= list_idx; 02421 AT_USE_ASSOCIATED(attr_idx) = TRUE; 02422 AT_MODULE_IDX(attr_idx) = attr_idx; 02423 LN_DEF_LOC(name_idx) = TRUE; 02424 } 02425 02426 if (AT_ORIG_NAME_IDX(attr_idx) == NULL_IDX) { 02427 AT_ORIG_NAME_IDX(attr_idx) = AT_NAME_IDX(attr_idx); 02428 AT_ORIG_NAME_LEN(attr_idx) = AT_NAME_LEN(attr_idx); 02429 } 02430 02431 fp_idx = FP_NEXT_FILE_IDX(fp_idx); 02432 } 02433 02434 TRACE (Func_Exit, "implicit_use_semantics", NULL); 02435 02436 return; 02437 02438 } /* implicit_use_semantics */ 02439 02440 /******************************************************************************\ 02441 |* *| 02442 |* Description: *| 02443 |* Perform statement level semantics necessary after processing a *| 02444 |* statement but before going to the next. *| 02445 |* *| 02446 |* Input parameters: *| 02447 |* NONE *| 02448 |* *| 02449 |* Output parameters: *| 02450 |* NONE *| 02451 |* *| 02452 |* Returns: *| 02453 |* NOTHING *| 02454 |* *| 02455 \******************************************************************************/ 02456 02457 static void stmt_level_semantics(void) 02458 { 02459 int blk_idx; 02460 int defer_msg; 02461 int save_blk_stk_idx; 02462 boolean stmt_is_directive; 02463 02464 02465 TRACE (Func_Entry, "stmt_level_semantics", NULL); 02466 02467 switch (stmt_type) { 02468 case Directive_Stmt: 02469 case End_Parallel_Stmt: 02470 case End_Do_Parallel_Stmt: 02471 case End_Parallel_Case_Stmt: 02472 case Parallel_Case_Stmt: 02473 case End_Guard_Stmt: 02474 case Open_MP_Section_Stmt: 02475 case Open_MP_End_Parallel_Stmt: 02476 case Open_MP_End_Do_Stmt: 02477 case Open_MP_End_Parallel_Sections_Stmt: 02478 case Open_MP_End_Sections_Stmt: 02479 case Open_MP_End_Section_Stmt: 02480 case Open_MP_End_Single_Stmt: 02481 case Open_MP_End_Parallel_Do_Stmt: 02482 case Open_MP_End_Master_Stmt: 02483 case Open_MP_End_Critical_Stmt: 02484 case Open_MP_End_Ordered_Stmt: 02485 case Open_MP_End_Parallel_Workshare_Stmt: 02486 case Open_MP_End_Workshare_Stmt: 02487 case SGI_Section_Stmt: 02488 case SGI_End_Psection_Stmt: 02489 case SGI_End_Pdo_Stmt: 02490 case SGI_End_Parallel_Stmt: 02491 case SGI_End_Critical_Section_Stmt: 02492 case SGI_End_Single_Process_Stmt: 02493 case SGI_Region_End_Stmt: 02494 02495 /* Special case if a directive is the very last statement */ 02496 /* in compilation. Need to force a program unit for this */ 02497 /* directive so compilation can finish up neatly. */ 02498 02499 if (LA_CH_CLASS == Ch_Class_EOF) { 02500 stmt_is_directive = FALSE; 02501 defer_msg = 1; 02502 } 02503 else { 02504 stmt_is_directive = TRUE; 02505 defer_msg = 0; 02506 } 02507 02508 break; 02509 02510 default: 02511 stmt_is_directive = FALSE; 02512 defer_msg = 0; 02513 break; 02514 } 02515 02516 /* Do stuff for program unit with no PROGRAM statement. */ 02517 /* SCP_ATTR_IDX may be set to $MAIN, if the first statement was an */ 02518 /* entry style statement, but had an error in the name (i.e., a */ 02519 /* PROGRAM statement with a missing name is entered as $MAIN). */ 02520 /* There is no beginning statement that can cause a new scope to */ 02521 /* be entered. Neither the CONTAINS or the INTERFACE statements */ 02522 /* cause new scopes. It is the FUNCTION/SUBROUTINE following the */ 02523 /* CONTAINS or INTERFACE that causes the new scope. If this first */ 02524 /* statement is a FUNCTION or a SUBROUTINE, then we'll fail the if */ 02525 /* test, because this program unit has an entry name. */ 02526 02527 if (SCP_ATTR_IDX(curr_scp_idx) == glb_tbl_idx[Main_Attr_Idx] && 02528 !AT_DEFINED(glb_tbl_idx[Main_Attr_Idx]) && 02529 !AT_DCL_ERR(glb_tbl_idx[Main_Attr_Idx]) && 02530 (!stmt_is_directive || LA_CH_CLASS == Ch_Class_EOF)) { 02531 02532 if (curr_stmt_category == Init_Stmt_Cat && !stmt_is_directive) { 02533 curr_stmt_category = Use_Stmt_Cat; 02534 } 02535 02536 token = main_token; 02537 TOKEN_LINE(token) = stmt_start_line; 02538 TOKEN_COLUMN(token) = stmt_start_col; 02539 save_blk_stk_idx = blk_stk_idx; 02540 blk_stk_idx = BLK_HEAD_IDX; 02541 02542 start_new_prog_unit(Program, Program_Blk, TRUE, FALSE, &defer_msg); 02543 02544 CURR_BLK_NAME = NULL_IDX; 02545 blk_stk_idx = save_blk_stk_idx; 02546 } 02547 02548 /* If basic CIF records were requested, output the Unit record for */ 02549 /* this external program unit (main program, external subprogram */ 02550 /* (procedure or block data subprogram), or module). */ 02551 /* If the first statement of a main program is INTERFACE, the */ 02552 /* Begin Scope record has already been output. */ 02553 02554 if (cif_need_unit_rec && !stmt_is_directive) { 02555 02556 /* If we have the pathological case where the program unit */ 02557 /* consists of nothing but an END statement, the action is the */ 02558 /* the same as if we're in error recovery mode. */ 02559 02560 if (blk_stk_idx == 0) { 02561 cif_pgm_unit_error_recovery = TRUE; 02562 } 02563 02564 if (cif_pgm_unit_error_recovery) { 02565 02566 /* See explanation of cif_pgm_unit_error_recovery in */ 02567 /* blk_match_err in p_end.c. */ 02568 02569 if (cif_flags == 0) { 02570 cif_pgm_unit_error_recovery = FALSE; 02571 } 02572 02573 blk_stk_idx = 1; 02574 cif_unit_rec(); 02575 blk_stk_idx = 0; 02576 } 02577 else { 02578 cif_unit_rec(); 02579 } 02580 02581 if (cif_flags != 0) { 02582 02583 if (cif_pgm_unit_error_recovery) { 02584 02585 /* See explanation of cif_pgm_unit_error_recovery */ 02586 /* in blk_match_err in p_end.c. */ 02587 02588 blk_stk_idx = 1; 02589 cif_begin_scope_rec(); 02590 blk_stk_idx = 0; 02591 cif_copy_temp_to_actual_CIF(); 02592 cif_pgm_unit_error_recovery = FALSE; 02593 } 02594 else if (BLK_CIF_SCOPE_ID(blk_stk_idx) == 0) { 02595 cif_begin_scope_rec(); 02596 } 02597 else if (CURR_BLK == Do_Blk) { 02598 02599 /* BLK_TC_TEMP_IDX and BLK_CIF_SCOPE_ID are overlayed. */ 02600 02601 save_blk_stk_idx = blk_stk_idx; 02602 --blk_stk_idx; 02603 cif_begin_scope_rec(); 02604 blk_stk_idx = save_blk_stk_idx; 02605 } 02606 } 02607 } 02608 02609 /* An END statement that ends a scoping unit has its label, if any, */ 02610 /* processed before coming back here. As part of that processing, */ 02611 /* stmt_label_idx is set to NULL_IDX so the following code will not */ 02612 /* be executed. */ 02613 02614 if (stmt_label_idx != NULL_IDX) { 02615 02616 switch(stmt_type) { 02617 case Allocate_Stmt: 02618 case Arith_If_Stmt: 02619 case Assign_Stmt: 02620 case Assignment_Stmt: 02621 case Backspace_Stmt: 02622 case Buffer_Stmt: 02623 case Call_Stmt: 02624 case Case_Stmt: 02625 case Close_Stmt: 02626 case Continue_Stmt: 02627 case Cycle_Stmt: 02628 case Deallocate_Stmt: 02629 case Decode_Stmt: 02630 case Do_Iterative_Stmt: 02631 case Do_While_Stmt: 02632 case Do_Infinite_Stmt: 02633 case Else_Stmt: 02634 case Else_If_Stmt: 02635 case Else_Where_Stmt: 02636 case Encode_Stmt: 02637 case Endfile_Stmt: 02638 case Entry_Stmt: 02639 case Exit_Stmt: 02640 case Forall_Cstrct_Stmt: 02641 case Forall_Stmt: 02642 case Goto_Stmt: 02643 case If_Cstrct_Stmt: 02644 case If_Stmt: 02645 case Inquire_Stmt: 02646 case Nullify_Stmt: 02647 case Open_Stmt: 02648 case Outmoded_If_Stmt: 02649 case Pause_Stmt: 02650 case Print_Stmt: 02651 case Read_Stmt: 02652 case Return_Stmt: 02653 case Rewind_Stmt: 02654 case Select_Stmt: 02655 case Stop_Stmt: 02656 case Then_Stmt: 02657 case Where_Cstrct_Stmt: 02658 case Where_Stmt: 02659 case Write_Stmt: 02660 02661 ATL_EXECUTABLE(stmt_label_idx) = TRUE; 02662 ATL_CLASS(stmt_label_idx) = Lbl_User; 02663 ATL_DEBUG_CLASS(stmt_label_idx) = Ldbg_User_Lbl; 02664 02665 /* Check to see if this label is within a parallel region and */ 02666 /* save the statement header that begins the region if it is. */ 02667 02668 blk_idx = blk_stk_idx; 02669 02670 while (blk_idx > 0) { 02671 02672 if (BLK_IS_PARALLEL_REGION(blk_idx)) { 02673 ATL_CMIC_BLK_STMT_IDX(stmt_label_idx) = 02674 BLK_FIRST_SH_IDX(blk_idx); 02675 break; 02676 } 02677 blk_idx--; 02678 } 02679 02680 /* Connect the label to its containing blocking statement. */ 02681 /* (If the label is defined at the procedure level, the label */ 02682 /* is already at the outermost level so just leave */ 02683 /* ATL_BLK_STMT_IDX as NULL_IDX. */ 02684 /* - The label is defined on an IF construct statement: */ 02685 /* The label really belongs to the scope containing the */ 02686 /* IF stmt. Skip over the If_Then_Blk and If_Blk frames. */ 02687 /* (If the label is marked in error, it means we don't */ 02688 /* know what kind of IF we really have so don't do */ 02689 /* anything.) */ 02690 /* - The label is defined on a DO, SELECT, or WHERE construct: */ 02691 /* The label really belongs to the scope containing the */ 02692 /* construct so go back one block stack frame. */ 02693 /* - Otherwise, just use the top frame. */ 02694 02695 switch (stmt_type) { 02696 case If_Cstrct_Stmt: 02697 02698 if (!AT_DCL_ERR(stmt_label_idx) ) { 02699 blk_idx = blk_stk_idx - 2; 02700 02701 while (BLK_IS_PARALLEL_REGION(blk_idx) || 02702 BLK_TYPE(blk_idx) == Do_Parallel_Blk || 02703 BLK_TYPE(blk_idx) == Wait_Blk || 02704 BLK_TYPE(blk_idx) == SGI_Region_Blk) { 02705 blk_idx--; 02706 } 02707 02708 if (BLK_TYPE(blk_idx) > Interface_Body_Blk) { 02709 ATL_BLK_STMT_IDX(stmt_label_idx) = 02710 BLK_FIRST_SH_IDX(blk_idx); 02711 } 02712 } 02713 break; 02714 02715 case Do_Iterative_Stmt: 02716 case Do_While_Stmt: 02717 case Do_Infinite_Stmt: 02718 case Select_Stmt: 02719 case Where_Cstrct_Stmt: 02720 case Forall_Cstrct_Stmt: 02721 blk_idx = blk_stk_idx - 1; 02722 02723 while (BLK_IS_PARALLEL_REGION(blk_idx) || 02724 BLK_TYPE(blk_idx) == Do_Parallel_Blk || 02725 BLK_TYPE(blk_idx) == Wait_Blk || 02726 BLK_TYPE(blk_idx) == SGI_Region_Blk) { 02727 blk_idx--; 02728 } 02729 02730 if (BLK_TYPE(blk_idx) > Interface_Body_Blk) { 02731 ATL_BLK_STMT_IDX(stmt_label_idx)=BLK_FIRST_SH_IDX(blk_idx); 02732 } 02733 break; 02734 02735 default: 02736 blk_idx = blk_stk_idx; 02737 02738 while (BLK_IS_PARALLEL_REGION(blk_idx) || 02739 BLK_TYPE(blk_idx) == Do_Parallel_Blk || 02740 BLK_TYPE(blk_idx) == Wait_Blk || 02741 BLK_TYPE(blk_idx) == SGI_Region_Blk) { 02742 blk_idx--; 02743 } 02744 02745 if (BLK_TYPE(blk_idx) > Interface_Body_Blk) { 02746 ATL_BLK_STMT_IDX(stmt_label_idx)=BLK_FIRST_SH_IDX(blk_idx); 02747 } 02748 break; 02749 02750 } /* End switch */ 02751 02752 end_labeled_do(); 02753 break; 02754 02755 case Elemental_Stmt: 02756 case Function_Stmt: 02757 case Pure_Stmt: 02758 case Recursive_Stmt: 02759 case Subroutine_Stmt: 02760 gen_attr_and_IR_for_lbl(FALSE); 02761 break; 02762 02763 case Null_Stmt: 02764 case Allocatable_Stmt: 02765 case Automatic_Stmt: 02766 case Common_Stmt: 02767 case Contains_Stmt: 02768 case Cpnt_Decl_Stmt: 02769 case Data_Stmt: 02770 case Derived_Type_Stmt: 02771 case Dimension_Stmt: 02772 case Directive_Stmt: 02773 case Equivalence_Stmt: 02774 case External_Stmt: 02775 case Format_Stmt: 02776 case Implicit_Stmt: 02777 case Implicit_None_Stmt: 02778 case Intent_Stmt: 02779 case Interface_Stmt: 02780 case Intrinsic_Stmt: 02781 case Module_Proc_Stmt: 02782 case Namelist_Stmt: 02783 case Optional_Stmt: 02784 case Parameter_Stmt: 02785 case Pointer_Stmt: 02786 case Private_Stmt: 02787 case Public_Stmt: 02788 case Save_Stmt: 02789 case Sequence_Stmt: 02790 case Stmt_Func_Stmt: 02791 case Target_Stmt: 02792 case Task_Common_Stmt: 02793 case Type_Decl_Stmt: 02794 case Use_Stmt: 02795 case Volatile_Stmt: 02796 02797 /* The label is defined on a spec stmt. Normally, the stmt */ 02798 /* doesn't need to be processed by the Semantics Pass (DATA */ 02799 /* is an exception). */ 02800 02801 if (stmt_type != Data_Stmt) { 02802 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE; 02803 } 02804 02805 /* If the label was defined on a type declaration stmt outside */ 02806 /* of a derived type definition, it's Attr can be created now. */ 02807 /* If it was defined within a type declaration, check to see */ 02808 /* if this is a duplicate definition by checking the label */ 02809 /* list attached to the derived type Attr. If it's not a */ 02810 /* duplicate, create an Attr for it by hand (so it doesn't go */ 02811 /* in the Local Name table). */ 02812 02813 if (CURR_BLK == Derived_Type_Blk) { 02814 check_for_dup_derived_type_lbl(); 02815 } 02816 else if (stmt_type == Type_Decl_Stmt) { 02817 gen_attr_and_IR_for_lbl(FALSE); 02818 } 02819 02820 /* See if the user tried to end a loop with a spec stmt like a */ 02821 /* FORMAT or DATA stmt. */ 02822 02823 end_labeled_do(); 02824 break; 02825 02826 case Blockdata_Stmt: 02827 case Module_Stmt: 02828 case Program_Stmt: 02829 case End_Blockdata_Stmt: 02830 case End_Do_Stmt: 02831 case End_Function_Stmt: 02832 case End_If_Stmt: 02833 case End_Interface_Stmt: 02834 case End_Module_Stmt: 02835 case End_Program_Stmt: 02836 case End_Select_Stmt: 02837 case End_Stmt: 02838 case End_Subroutine_Stmt: 02839 case End_Type_Stmt: 02840 case End_Where_Stmt: 02841 case End_Forall_Stmt: 02842 case Type_Init_Stmt: 02843 case Label_Def: 02844 case Construct_Def: 02845 case Automatic_Base_Calc_Stmt: 02846 case Automatic_Base_Size_Stmt: 02847 case End_Parallel_Stmt: 02848 case End_Do_Parallel_Stmt: 02849 case End_Parallel_Case_Stmt: 02850 case Parallel_Case_Stmt: 02851 case End_Guard_Stmt: 02852 case Statement_Num_Stmt: 02853 case SGI_Section_Stmt: 02854 case SGI_End_Psection_Stmt: 02855 case SGI_End_Pdo_Stmt: 02856 case SGI_End_Parallel_Stmt: 02857 case SGI_End_Critical_Section_Stmt: 02858 case SGI_End_Single_Process_Stmt: 02859 case SGI_Region_End_Stmt: 02860 case Open_MP_Section_Stmt: 02861 case Open_MP_End_Parallel_Stmt: 02862 case Open_MP_End_Do_Stmt: 02863 case Open_MP_End_Parallel_Sections_Stmt: 02864 case Open_MP_End_Sections_Stmt: 02865 case Open_MP_End_Section_Stmt: 02866 case Open_MP_End_Single_Stmt: 02867 case Open_MP_End_Parallel_Do_Stmt: 02868 case Open_MP_End_Master_Stmt: 02869 case Open_MP_End_Critical_Stmt: 02870 case Open_MP_End_Ordered_Stmt: 02871 case Open_MP_End_Parallel_Workshare_Stmt: 02872 case Open_MP_End_Workshare_Stmt: 02873 02874 /* Check to see if this label is within a parallel region and */ 02875 /* save the statement header that begins the region if it is. */ 02876 02877 blk_idx = blk_stk_idx + 1; 02878 02879 while (blk_idx > 0) { 02880 02881 if (BLK_IS_PARALLEL_REGION(blk_idx)) { 02882 ATL_CMIC_BLK_STMT_IDX(stmt_label_idx) = 02883 BLK_FIRST_SH_IDX(blk_idx); 02884 break; 02885 } 02886 blk_idx--; 02887 } 02888 02889 /* The label is defined on an END statement. */ 02890 /* The block stack has already been popped so we need to cheat */ 02891 /* a little by using the index to the just-popped frame (we're */ 02892 /* assuming it hasn't been destroyed between the pop and */ 02893 /* arriving here). */ 02894 /* Don't call end_labeled_do here. It's called by the END */ 02895 /* routines themselves (too late by the time we get back here). */ 02896 02897 switch (stmt_type) { 02898 case End_Do_Stmt: 02899 ATL_EXECUTABLE(stmt_label_idx) = TRUE; 02900 ATL_CLASS(stmt_label_idx) = Lbl_User; 02901 ATL_DEBUG_CLASS(stmt_label_idx) = Ldbg_User_Lbl; 02902 02903 blk_idx = blk_stk_idx + 1; 02904 02905 while (BLK_IS_PARALLEL_REGION(blk_idx) || 02906 BLK_TYPE(blk_idx) == Do_Parallel_Blk || 02907 BLK_TYPE(blk_idx) == Wait_Blk || 02908 BLK_TYPE(blk_idx) == SGI_Region_Blk) { 02909 02910 blk_idx++; 02911 } 02912 02913 ATL_BLK_STMT_IDX(stmt_label_idx) = BLK_FIRST_SH_IDX(blk_idx); 02914 break; 02915 02916 case End_If_Stmt: 02917 case End_Select_Stmt: 02918 case End_Where_Stmt: 02919 ATL_EXECUTABLE(stmt_label_idx) = TRUE; 02920 ATL_CLASS(stmt_label_idx) = Lbl_User; 02921 ATL_DEBUG_CLASS(stmt_label_idx) = Ldbg_User_Lbl; 02922 02923 blk_idx = blk_stk_idx + 1; 02924 02925 while (BLK_IS_PARALLEL_REGION(blk_idx) || 02926 BLK_TYPE(blk_idx) == Do_Parallel_Blk || 02927 BLK_TYPE(blk_idx) == Wait_Blk || 02928 BLK_TYPE(blk_idx) == SGI_Region_Blk) { 02929 02930 blk_idx++; 02931 } 02932 02933 ATL_BLK_STMT_IDX(stmt_label_idx) = BLK_FIRST_SH_IDX(blk_idx); 02934 02935 end_labeled_do(); 02936 break; 02937 02938 case End_Type_Stmt: 02939 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE; 02940 check_for_dup_derived_type_lbl(); 02941 break; 02942 02943 case End_Interface_Stmt: /* Labeled declaration statements */ 02944 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE; 02945 break; 02946 02947 default: 02948 break; 02949 } 02950 break; 02951 } 02952 02953 /* If the label has forward references to it, verify that they */ 02954 /* are correct. */ 02955 02956 if (stmt_label_idx != NULL_IDX && 02957 !AT_DEFINED(stmt_label_idx) && 02958 ATL_FWD_REF_IDX(stmt_label_idx) != NULL_IDX ) { 02959 resolve_fwd_lbl_refs(); 02960 } 02961 } 02962 else { 02963 02964 /* If this is a specification statement, the statement header may */ 02965 /* be reused, so set need_new_sh = FALSE. NOTE that DATA stmt */ 02966 /* and USE stmt are NOT included here because they generate IR. */ 02967 02968 switch (stmt_type) { 02969 case Allocatable_Stmt: 02970 case Automatic_Stmt: 02971 case Common_Stmt: 02972 case Contains_Stmt: 02973 case Cpnt_Decl_Stmt: 02974 case Derived_Type_Stmt: 02975 case Dimension_Stmt: 02976 case Equivalence_Stmt: 02977 case External_Stmt: 02978 case Format_Stmt: 02979 case Implicit_Stmt: 02980 case Implicit_None_Stmt: 02981 case Intent_Stmt: 02982 case Interface_Stmt: 02983 case Intrinsic_Stmt: 02984 case Module_Proc_Stmt: 02985 case Namelist_Stmt: 02986 case Optional_Stmt: 02987 case Parameter_Stmt: 02988 case Pointer_Stmt: 02989 case Private_Stmt: 02990 case Public_Stmt: 02991 case Save_Stmt: 02992 case Sequence_Stmt: 02993 case Stmt_Func_Stmt: 02994 case Target_Stmt: 02995 case Task_Common_Stmt: 02996 case Type_Decl_Stmt: 02997 case End_Interface_Stmt: 02998 case End_Type_Stmt: 02999 case Volatile_Stmt: 03000 need_new_sh = FALSE; 03001 break; 03002 03003 default: 03004 break; 03005 } /* End switch */ 03006 } 03007 03008 if (stmt_construct_idx != NULL_IDX) { 03009 03010 /* Construct name not allowed on this type of statement. IF, DO, */ 03011 /* and SELECT statements use stmt_construct_idx and then clear it */ 03012 /* so that this check does not have to check statement type. */ 03013 03014 PRINTMSG(stmt_start_line, 7, Error, stmt_start_col, 03015 stmt_type_str[stmt_type]); 03016 } 03017 03018 TRACE (Func_Exit, "stmt_level_semantics", NULL); 03019 03020 return; 03021 03022 } /* stmt_level_semantics */ 03023 03024 # if defined(_EXPRESSION_EVAL) 03025 /******************************************************************************\ 03026 |* *| 03027 |* Description: *| 03028 |* When the FE is used as an expression evaluator, we can be sent *| 03029 |* expressions rather than whole statement. This routine parses *| 03030 |* that expression and turns it into a whole statement. *| 03031 |* *| 03032 |* Input parameters: *| 03033 |* NONE *| 03034 |* *| 03035 |* Output parameters: *| 03036 |* NONE *| 03037 |* *| 03038 |* Returns: *| 03039 |* NOTHING *| 03040 |* *| 03041 \******************************************************************************/ 03042 03043 static void parse_expr_for_evaluator(void) 03044 { 03045 int attr_idx; 03046 int ir_idx; 03047 opnd_type opnd; 03048 int sh_idx; 03049 03050 03051 TRACE (Func_Entry, "parse_expr_for_evaluator", NULL); 03052 03053 stmt_type = Assignment_Stmt; 03054 sh_idx = curr_stmt_sh_idx; 03055 curr_stmt_sh_idx = ntr_sh_tbl(); 03056 SH_NEXT_IDX(sh_idx) = curr_stmt_sh_idx; 03057 SH_PREV_IDX(curr_stmt_sh_idx)= sh_idx; 03058 03059 if (parse_expr(&opnd)) { 03060 03061 # if 0 /* Do not want to generate a compiler temp here. Need to insert */ 03062 /* a new statement type and operator. Use it. */ 03063 03064 GEN_COMPILER_TMP_ASG(ir_idx, 03065 attr_idx, 03066 TRUE, /* Semantics done */ 03067 OPND_LINE_NUM(opnd), 03068 OPND_COL_NUM(opnd), 03069 INTEGER_DEFAULT_TYPE, 03070 Priv); 03071 03072 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx; 03073 COPY_OPND(IR_OPND_R(ir_idx),opnd); 03074 # endif 03075 stmt_level_semantics(); 03076 } 03077 else { /* Problems with expression - exit */ 03078 } 03079 03080 NEXT_LA_CH; /* Should be End */ 03081 03082 TRACE (Func_Exit, "parse_expr_for_evaluator", NULL); 03083 03084 return; 03085 03086 } /* parse_expr_for_evaluator */ 03087 # endif