00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 static char USMID[] = "\n@(#)5.0_pl/sources/p_dcl_pu.c 5.5 09/01/99 09:11:00\n";
00046
00047 # include "defines.h"
00048
00049 # include "host.m"
00050 # include "host.h"
00051 # include "target.m"
00052 # include "target.h"
00053
00054 # include "globals.m"
00055 # include "tokens.m"
00056 # include "sytb.m"
00057 # include "p_globals.m"
00058 # include "debug.m"
00059
00060 # include "globals.h"
00061 # include "tokens.h"
00062 # include "sytb.h"
00063 # include "p_globals.h"
00064 # ifdef KEY
00065 # include "i_cvrt.h"
00066 # endif
00067
00068
00069
00070
00071
00072
00073 static void gen_end_prologue_debug_label (int);
00074 static void parse_dummy_args (int);
00075 static void parse_prefix_spec (void);
00076 static void set_function_rslt (int, boolean);
00077 static void start_new_scp (void);
00078 static int start_new_subpgm (pgm_unit_type, boolean, boolean);
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 void parse_block_stmt (void)
00098 {
00099 int defer_msg = 0;
00100 static char num_unnamed = 'A';
00101 boolean parse_error;
00102 boolean unnamed_blk = FALSE;
00103
00104
00105 TRACE (Func_Entry, "parse_block_stmt", NULL);
00106
00107 if (matched_specific_token(Tok_Kwd_Data, Tok_Class_Keyword)) {
00108 parse_error = FALSE;
00109
00110 if (LA_CH_VALUE == EOS) {
00111 unnamed_blk = TRUE;
00112 TOKEN_STR(token)[0] = 'B';
00113 TOKEN_STR(token)[1] = 'L';
00114 TOKEN_STR(token)[2] = 'K';
00115 # if defined(_NO_AT_SIGN_IN_NAMES)
00116 TOKEN_STR(token)[3] = '.';
00117 # else
00118 TOKEN_STR(token)[3] = '@';
00119 # endif
00120 TOKEN_STR(token)[4] = 'D';
00121 TOKEN_STR(token)[5] = 'A';
00122 TOKEN_STR(token)[6] = 'T';
00123 TOKEN_STR(token)[7] = num_unnamed;
00124 TOKEN_LEN(token) = 8;
00125 TOKEN_VALUE(token) = Tok_Id;
00126 TOKEN_LINE(token) = stmt_start_line;
00127 TOKEN_COLUMN(token) = stmt_start_col;
00128
00129 if (num_unnamed > 'Z') {
00130
00131
00132
00133
00134 TOKEN_STR(token)[7] = 'a';
00135 }
00136 }
00137 else if (!MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
00138 parse_err_flush(Find_EOS, "block-data-name");
00139 parse_error = TRUE;
00140 token = main_token;
00141 TOKEN_LINE(token) = stmt_start_line;
00142 TOKEN_COLUMN(token) = stmt_start_col;
00143 }
00144 }
00145 else {
00146 parse_err_flush(Find_EOS, "DATA");
00147 parse_error = TRUE;
00148 token = main_token;
00149 TOKEN_LINE(token) = stmt_start_line;
00150 TOKEN_COLUMN(token) = stmt_start_col;
00151 }
00152
00153 start_new_prog_unit(Blockdata,
00154 Blockdata_Blk,
00155 FALSE,
00156 parse_error,
00157 &defer_msg);
00158 CURR_BLK_NO_EXEC = TRUE;
00159
00160 if (unnamed_blk) {
00161 CURR_BLK_NAME = NULL_IDX;
00162
00163 if (num_unnamed > 'Z') {
00164 PRINTMSG(stmt_start_line, 29, Error, stmt_start_col);
00165 }
00166 else if (num_unnamed > 'A') {
00167 PRINTMSG(stmt_start_line, 30, Ansi, stmt_start_col);
00168 }
00169 num_unnamed++;
00170 }
00171
00172 if (LA_CH_VALUE != EOS) {
00173 parse_err_flush(Find_EOS, EOS_STR);
00174 }
00175
00176 NEXT_LA_CH;
00177
00178 TRACE (Func_Exit, "parse_block_stmt", NULL);
00179
00180 return;
00181
00182 }
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200 void parse_entry_stmt (void)
00201
00202 {
00203 int attr_idx = NULL_IDX;
00204 boolean blk_err = FALSE;
00205 int branch_around_lbl_idx;
00206 int host_attr_idx;
00207 int host_name_idx;
00208 int ir_idx;
00209 boolean issue_msg;
00210 int length;
00211 int list_idx;
00212 int name_idx;
00213 pgm_unit_type pgm_unit;
00214 atp_proc_type proc_type;
00215 int save_scp_idx;
00216 obj_type sem_type;
00217
00218
00219 TRACE (Func_Entry, "parse_entry_stmt", NULL);
00220
00221 if (STMT_CANT_BE_IN_BLK(Entry_Stmt, CURR_BLK) && iss_blk_stk_err()) {
00222
00223
00224
00225 blk_err = TRUE;
00226
00227 }
00228 else if (curr_stmt_category < Implicit_None_Stmt_Cat) {
00229
00230
00231
00232
00233 curr_stmt_category = Implicit_None_Stmt_Cat;
00234 }
00235
00236 if (MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
00237 attr_idx = srch_sym_tbl(TOKEN_STR(token),
00238 TOKEN_LEN(token),
00239 &name_idx);
00240
00241 pgm_unit = (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Function) ?
00242 Function : Subroutine;
00243
00244 proc_type = (atp_proc_type) ATP_PROC(SCP_ATTR_IDX(curr_scp_idx));
00245
00246
00247
00248 if (ATP_PROC(SCP_ATTR_IDX(curr_scp_idx)) == Module_Proc) {
00249 host_attr_idx = srch_host_sym_tbl(TOKEN_STR(token),
00250 TOKEN_LEN(token),
00251 &host_name_idx,
00252 FALSE);
00253
00254 if (host_attr_idx == NULL_IDX) {
00255
00256 if (attr_idx == NULL_IDX) {
00257 save_scp_idx = curr_scp_idx;
00258 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
00259 host_attr_idx = ntr_sym_tbl(&token, host_name_idx);
00260 curr_scp_idx = save_scp_idx;
00261 attr_idx = srch_sym_tbl(TOKEN_STR(token),
00262 TOKEN_LEN(token),
00263 &name_idx);
00264
00265
00266
00267 attr_idx = ntr_host_in_sym_tbl(&token,
00268 name_idx,
00269 host_attr_idx,
00270 host_name_idx,
00271 FALSE);
00272
00273 LN_DEF_LOC(name_idx) = TRUE;
00274 LN_DEF_LOC(host_name_idx) = TRUE;
00275 AT_OBJ_CLASS(attr_idx) = Pgm_Unit;
00276 ATP_PGM_UNIT(attr_idx) = pgm_unit;
00277 ATP_PROC(attr_idx) = proc_type;
00278 }
00279 else {
00280
00281 sem_type = (pgm_unit == Function) ? Obj_Entry_Func :
00282 Obj_Entry_Subr;
00283
00284 if (fnd_semantic_err(sem_type,
00285 TOKEN_LINE(token),
00286 TOKEN_COLUMN(token),
00287 attr_idx,
00288 TRUE)) {
00289 CREATE_ERR_ATTR(attr_idx,
00290 TOKEN_LINE(token),
00291 TOKEN_COLUMN(token),
00292 Pgm_Unit);
00293
00294 ATP_PGM_UNIT(attr_idx) = pgm_unit;
00295 ATP_PROC(attr_idx) = proc_type;
00296 }
00297 else {
00298 LN_DEF_LOC(name_idx) = TRUE;
00299 }
00300
00301 save_scp_idx = curr_scp_idx;
00302 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
00303 host_attr_idx = ntr_sym_tbl(&token,
00304 host_name_idx);
00305 curr_scp_idx = save_scp_idx;
00306 attr_tbl_idx--;
00307 attr_aux_tbl_idx--;
00308 LN_ATTR_IDX(host_name_idx) = attr_idx;
00309 LN_NAME_IDX(host_name_idx) = AT_NAME_IDX(attr_idx);
00310 LN_DEF_LOC(host_name_idx) = TRUE;
00311
00312 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
00313 chg_data_obj_to_pgm_unit(attr_idx,
00314 pgm_unit,
00315 proc_type);
00316 }
00317 else if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit) {
00318 ATP_PGM_UNIT(attr_idx) = pgm_unit;
00319 ATP_PROC(attr_idx) = proc_type;
00320 }
00321 }
00322 }
00323 else {
00324 issue_msg = TRUE;
00325
00326 if (attr_idx != NULL_IDX) {
00327 sem_type = (pgm_unit == Function) ? Obj_Entry_Func :
00328 Obj_Entry_Subr;
00329
00330 if (fnd_semantic_err(sem_type,
00331 TOKEN_LINE(token),
00332 TOKEN_COLUMN(token),
00333 attr_idx,
00334 TRUE)) {
00335
00336 CREATE_ERR_ATTR(attr_idx,
00337 TOKEN_LINE(token),
00338 TOKEN_COLUMN(token),
00339 Pgm_Unit);
00340
00341 ATP_PGM_UNIT(attr_idx) = pgm_unit;
00342 ATP_PROC(attr_idx) = proc_type;
00343 issue_msg = FALSE;
00344 }
00345 else {
00346 LN_DEF_LOC(name_idx) = TRUE;
00347 }
00348 }
00349
00350 sem_type = (pgm_unit == Function) ? Obj_Module_Func :
00351 Obj_Module_Subr;
00352
00353 if (AT_OBJ_CLASS(host_attr_idx) == Interface &&
00354 ATI_PROC_IDX(host_attr_idx) != NULL_IDX) {
00355 host_attr_idx = ATI_PROC_IDX(host_attr_idx);
00356 }
00357
00358 if (fnd_semantic_err(sem_type,
00359 TOKEN_LINE(token),
00360 TOKEN_COLUMN(token),
00361 host_attr_idx,
00362 issue_msg)) {
00363 CREATE_ERR_ATTR(host_attr_idx,
00364 TOKEN_LINE(token),
00365 TOKEN_COLUMN(token),
00366 Pgm_Unit);
00367 ATP_PGM_UNIT(host_attr_idx) = pgm_unit;
00368 ATP_PROC(host_attr_idx) = proc_type;
00369
00370 }
00371 else if (AT_OBJ_CLASS(host_attr_idx) == Data_Obj) {
00372 chg_data_obj_to_pgm_unit(host_attr_idx,
00373 pgm_unit,
00374 proc_type);
00375 }
00376 else if (ATP_PROC(host_attr_idx) == Module_Proc &&
00377 ATP_EXPL_ITRFC(host_attr_idx)) {
00378
00379
00380
00381 PRINTMSG(TOKEN_LINE(token), 1529, Error,
00382 TOKEN_COLUMN(token),
00383 AT_OBJ_NAME_PTR(host_attr_idx));
00384 }
00385 else {
00386 ATP_PGM_UNIT(host_attr_idx) = pgm_unit;
00387 ATP_PROC(host_attr_idx) = proc_type;
00388 }
00389
00390 if (attr_idx == NULL_IDX) {
00391 attr_idx = ntr_host_in_sym_tbl(&token,
00392 name_idx,
00393 host_attr_idx,
00394 host_name_idx,
00395 FALSE);
00396 LN_DEF_LOC(name_idx) = TRUE;
00397 }
00398 else {
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410 if (issue_msg && pgm_unit == Function) {
00411 ATP_RSLT_IDX(host_attr_idx) = attr_idx;
00412 ATD_CLASS(attr_idx) = Function_Result;
00413 ATD_FUNC_IDX(attr_idx) = host_attr_idx;
00414 }
00415 }
00416 LN_ATTR_IDX(name_idx) = host_attr_idx;
00417 LN_NAME_IDX(name_idx) = AT_NAME_IDX(host_attr_idx);
00418 LN_DEF_LOC(host_name_idx) = TRUE;
00419 attr_idx = host_attr_idx;
00420 }
00421
00422 ATP_EXT_NAME_IDX(attr_idx) = make_in_parent_string(
00423 AT_NAME_IDX(attr_idx),
00424 AT_NAME_LEN(attr_idx),
00425 SCP_PARENT_IDX(curr_scp_idx),
00426 &length);
00427 ATP_EXT_NAME_LEN(attr_idx) = length;
00428 }
00429 else if (attr_idx == NULL_IDX) {
00430 attr_idx = ntr_sym_tbl(&token, name_idx);
00431 LN_DEF_LOC(name_idx) = TRUE;
00432 AT_OBJ_CLASS(attr_idx) = Pgm_Unit;
00433 ATP_PGM_UNIT(attr_idx) = pgm_unit;
00434 ATP_PROC(attr_idx) = ATP_PROC(SCP_ATTR_IDX(curr_scp_idx));
00435 MAKE_EXTERNAL_NAME(attr_idx,
00436 AT_NAME_IDX(attr_idx),
00437 AT_NAME_LEN(attr_idx));
00438 }
00439 else {
00440 sem_type = (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Function) ?
00441 Obj_Entry_Func : Obj_Entry_Subr;
00442
00443 if (fnd_semantic_err(sem_type,
00444 TOKEN_LINE(token),
00445 TOKEN_COLUMN(token),
00446 attr_idx,
00447 TRUE)) {
00448 CREATE_ERR_ATTR(attr_idx,
00449 TOKEN_LINE(token),
00450 TOKEN_COLUMN(token),
00451 Pgm_Unit);
00452
00453 ATP_PGM_UNIT(attr_idx) = pgm_unit;
00454 ATP_PROC(attr_idx) = ATP_PROC(SCP_ATTR_IDX(curr_scp_idx));
00455 MAKE_EXTERNAL_NAME(attr_idx,
00456 AT_NAME_IDX(attr_idx),
00457 AT_NAME_LEN(attr_idx));
00458 }
00459 else {
00460 LN_DEF_LOC(name_idx)= TRUE;
00461
00462 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
00463 chg_data_obj_to_pgm_unit(attr_idx,
00464 pgm_unit,
00465 (atp_proc_type)
00466 ATP_PROC(SCP_ATTR_IDX(curr_scp_idx)));
00467 }
00468 else if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit) {
00469 ATP_PGM_UNIT(attr_idx) = pgm_unit;
00470 ATP_PROC(attr_idx) = proc_type;
00471 }
00472 }
00473 }
00474
00475 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
00476 ATP_ALT_ENTRY(attr_idx) = TRUE;
00477 ATP_RECURSIVE(attr_idx) = ATP_RECURSIVE(SCP_ATTR_IDX(curr_scp_idx));
00478 ATP_ELEMENTAL(attr_idx) = ATP_ELEMENTAL(SCP_ATTR_IDX(curr_scp_idx));
00479 ATP_PURE(attr_idx) = ATP_PURE(SCP_ATTR_IDX(curr_scp_idx));
00480 ATP_SCP_ALIVE(attr_idx) = TRUE;
00481 ATP_EXPL_ITRFC(attr_idx) = TRUE;
00482 ATP_MAY_INLINE(attr_idx) = ATP_MAY_INLINE(SCP_ATTR_IDX(curr_scp_idx));
00483
00484 if ((cif_flags & XREF_RECS) != 0) {
00485 cif_usage_rec(attr_idx,
00486 AT_Tbl_Idx,
00487 TOKEN_LINE(token),
00488 TOKEN_COLUMN(token),
00489 CIF_Symbol_Declaration);
00490 }
00491
00492 NTR_ATTR_LIST_TBL(list_idx);
00493 AL_ATTR_IDX(list_idx) = attr_idx;
00494 AL_NEXT_IDX(list_idx) = SCP_ENTRY_IDX(curr_scp_idx);
00495 SCP_ENTRY_IDX(curr_scp_idx) = list_idx;
00496
00497 if (SCP_ALT_ENTRY_CNT(curr_scp_idx) >= MAX_ALTERNATE_ENTRIES) {
00498 PRINTMSG(TOKEN_LINE(token), 1115, Limit,
00499 TOKEN_COLUMN(token),
00500 MAX_ALTERNATE_ENTRIES);
00501 }
00502
00503 SCP_ALT_ENTRY_CNT(curr_scp_idx) = SCP_ALT_ENTRY_CNT(curr_scp_idx) + 1;
00504 AT_DCL_ERR(attr_idx) |= blk_err;
00505
00506 if (LA_CH_VALUE != EOS && LA_CH_VALUE != LPAREN) {
00507 parse_err_flush(Find_Lparen, "( or " EOS_STR );
00508 }
00509
00510 if (CURR_BLK != Interface_Body_Blk &&
00511 (cmd_line_flags.runtime_argument ||
00512 cmd_line_flags.runtime_arg_entry)) {
00513
00514 ATP_ARGCHCK_ENTRY(attr_idx) = TRUE;
00515 }
00516
00517 if (LA_CH_VALUE == LPAREN) {
00518 parse_dummy_args(attr_idx);
00519 }
00520
00521 if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Function) {
00522 set_function_rslt(attr_idx, FALSE);
00523
00524 if (LA_CH_VALUE != EOS) {
00525 parse_err_flush(Find_EOS, EOS_STR);
00526 }
00527 }
00528 else if (LA_CH_VALUE != EOS) {
00529
00530 if (matched_specific_token (Tok_Kwd_Result, Tok_Class_Keyword)){
00531
00532
00533
00534 PRINTMSG(TOKEN_LINE(token), 122, Error, TOKEN_COLUMN(token));
00535 parse_err_flush(Find_EOS, NULL);
00536 }
00537 else {
00538 parse_err_flush(Find_EOS, EOS_STR);
00539 }
00540 }
00541
00542 branch_around_lbl_idx = gen_internal_lbl(TOKEN_LINE(token));
00543
00544 NTR_IR_TBL(ir_idx);
00545 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
00546 SH_COMPILER_GEN(curr_stmt_sh_idx) = TRUE;
00547 SH_STMT_TYPE(curr_stmt_sh_idx) = Goto_Stmt;
00548 IR_OPR(ir_idx) = Br_Uncond_Opr;
00549 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
00550 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token);
00551 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token);
00552 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
00553 IR_IDX_R(ir_idx) = branch_around_lbl_idx;
00554 IR_COL_NUM_R(ir_idx) = TOKEN_COLUMN(token);
00555 IR_LINE_NUM_R(ir_idx) = TOKEN_LINE(token);
00556
00557 gen_sh(After, stmt_type, TOKEN_LINE(token), TOKEN_COLUMN(token),
00558 FALSE, FALSE, FALSE);
00559
00560 NTR_IR_TBL(ir_idx);
00561 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
00562 IR_OPR(ir_idx) = Entry_Opr;
00563 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
00564 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token);
00565 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token);
00566 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
00567 IR_IDX_L(ir_idx) = attr_idx;
00568 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(token);
00569 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(token);
00570
00571 if (attr_idx != NULL_IDX) {
00572 ATP_FIRST_SH_IDX(attr_idx) = curr_stmt_sh_idx;
00573 }
00574
00575 gen_sh(After, Continue_Stmt, TOKEN_LINE(token), TOKEN_COLUMN(token),
00576 FALSE, TRUE, TRUE);
00577
00578 NTR_IR_TBL(ir_idx);
00579 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
00580 IR_OPR(ir_idx) = Label_Opr;
00581 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
00582 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token);
00583 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token);
00584 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
00585 IR_IDX_L(ir_idx) = branch_around_lbl_idx;
00586 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(token);
00587 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(token);
00588
00589 if (attr_idx != NULL_IDX) {
00590 ATP_ENTRY_LABEL_SH_IDX(attr_idx) = curr_stmt_sh_idx;
00591 }
00592
00593 if (cmd_line_flags.debug_lvl <= Debug_Lvl_1) {
00594 gen_end_prologue_debug_label(attr_idx);
00595 }
00596 }
00597 else {
00598 parse_err_flush(Find_EOS, "entry-name");
00599 }
00600
00601 NEXT_LA_CH;
00602
00603 TRACE (Func_Exit, "parse_entry_stmt", NULL);
00604
00605 return;
00606
00607 }
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628 void parse_function_stmt (void)
00629
00630 {
00631 int attr_idx;
00632 int defer_msg;
00633 boolean err_fnd = FALSE;
00634 token_type save_token;
00635
00636
00637 TRACE (Func_Entry, "parse_function_stmt", NULL);
00638
00639 if (curr_stmt_category > Sub_Func_Stmt_Cat) {
00640 err_fnd = TRUE;
00641 iss_blk_stk_err();
00642 }
00643
00644 if (!MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
00645 parse_err_flush(Find_Lparen, "function-name");
00646 token = main_token;
00647 TOKEN_LINE(token) = stmt_start_line;
00648 TOKEN_COLUMN(token) = stmt_start_col;
00649 err_fnd = TRUE;
00650 }
00651 else if (LA_CH_VALUE != LPAREN) {
00652 save_token = token;
00653 parse_err_flush(Find_Lparen, "(");
00654 err_fnd = TRUE;
00655 token = save_token;
00656 }
00657
00658 if (curr_stmt_category == Init_Stmt_Cat) {
00659 defer_msg = 0;
00660 attr_idx = start_new_prog_unit(Function,
00661 Function_Blk,
00662 FALSE,
00663 err_fnd,
00664 &defer_msg);
00665 ATP_PROC(attr_idx) = Extern_Proc;
00666 }
00667 else {
00668
00669
00670
00671
00672
00673
00674 start_new_scp();
00675 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
00676 attr_idx = start_new_subpgm(Function, err_fnd, TRUE);
00677 }
00678
00679
00680
00681 SCP_IN_ERR(curr_scp_idx) = SCP_IN_ERR(curr_scp_idx) ||
00682 AT_DCL_ERR(attr_idx);
00683
00684 if (CURR_BLK != Interface_Body_Blk &&
00685 (cmd_line_flags.runtime_argument ||
00686 cmd_line_flags.runtime_arg_entry)) {
00687
00688 ATP_ARGCHCK_ENTRY(attr_idx) = TRUE;
00689 }
00690
00691 if (LA_CH_VALUE == LPAREN) {
00692 parse_dummy_args(attr_idx);
00693 }
00694
00695 set_function_rslt(attr_idx, FALSE);
00696
00697 if (LA_CH_VALUE != EOS) {
00698 parse_err_flush(Find_EOS, EOS_STR);
00699 }
00700
00701 NEXT_LA_CH;
00702
00703 TRACE (Func_Exit, "parse_function_stmt", NULL);
00704
00705 return;
00706
00707 }
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725 void parse_module_stmt (void)
00726
00727 {
00728 int attr_idx;
00729 int defer_msg;
00730 boolean found_comma;
00731 int host_name_idx;
00732 int interface_idx = NULL_IDX;
00733
00734 # if defined(_SPLIT_STATIC_STORAGE_M)
00735 id_str_type name;
00736 int new_idx;
00737 # endif
00738
00739 int name_idx;
00740 int new_attr_idx;
00741 boolean parse_error;
00742 int sn_idx;
00743 int stmt_number;
00744 int tmp_attr_idx;
00745
00746
00747 TRACE (Func_Entry, "parse_module_stmt", NULL);
00748
00749 stmt_number = statement_number;
00750
00751 if (curr_stmt_category != Init_Stmt_Cat &&
00752 matched_specific_token (Tok_Kwd_Procedure, Tok_Class_Keyword)) {
00753
00754
00755
00756
00757 stmt_type = Module_Proc_Stmt;
00758 SH_STMT_TYPE(curr_stmt_sh_idx) = Module_Proc_Stmt;
00759
00760 if (CURR_BLK == Interface_Blk) {
00761
00762 if (CURR_BLK_NAME == NULL_IDX) {
00763 PRINTMSG(stmt_start_line, 4, Error, stmt_start_col);
00764 }
00765 else {
00766 curr_stmt_category = Sub_Func_Stmt_Cat;
00767
00768 if (cif_flags & MISC_RECS) {
00769 cif_stmt_type_rec(TRUE, CIF_Module_Procedure_Stmt, stmt_number);
00770 }
00771 }
00772
00773 interface_idx = CURR_BLK_NAME;
00774 }
00775 else if (!iss_blk_stk_err()) {
00776 curr_stmt_category = Sub_Func_Stmt_Cat;
00777 }
00778
00779 do {
00780 if (MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
00781
00782
00783
00784
00785 attr_idx = srch_sym_tbl(TOKEN_STR(token), TOKEN_LEN(token),
00786 &name_idx);
00787
00788 if (attr_idx == NULL_IDX) {
00789 attr_idx = srch_host_sym_tbl(TOKEN_STR(token),
00790 TOKEN_LEN(token),
00791 &host_name_idx,
00792 FALSE);
00793
00794 if (attr_idx == NULL_IDX) {
00795 attr_idx = ntr_sym_tbl(&token, name_idx);
00796 LN_DEF_LOC(name_idx) = TRUE;
00797 AT_OBJ_CLASS(attr_idx) = Pgm_Unit;
00798 ATP_PROC(attr_idx) = Module_Proc;
00799 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
00800 MAKE_EXTERNAL_NAME(attr_idx,
00801 AT_NAME_IDX(attr_idx),
00802 AT_NAME_LEN(attr_idx));
00803 }
00804 else {
00805
00806 if (AT_OBJ_CLASS(attr_idx) == Interface &&
00807 ATI_PROC_IDX(attr_idx) != NULL_IDX) {
00808 attr_idx = ATI_PROC_IDX(attr_idx);
00809 }
00810
00811 if (AT_NOT_VISIBLE(attr_idx)) {
00812 PRINTMSG(TOKEN_LINE(token), 486, Error,
00813 TOKEN_COLUMN(token),
00814 AT_OBJ_NAME_PTR(attr_idx),
00815 AT_OBJ_NAME_PTR(AT_MODULE_IDX((attr_idx))));
00816 CREATE_ERR_ATTR(attr_idx,
00817 TOKEN_LINE(token),
00818 TOKEN_COLUMN(token),
00819 Pgm_Unit);
00820 ATP_PROC(attr_idx) = Module_Proc;
00821 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
00822 MAKE_EXTERNAL_NAME(attr_idx,
00823 AT_NAME_IDX(attr_idx),
00824 AT_NAME_LEN(attr_idx));
00825 }
00826 else if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
00827 ATP_PROC(attr_idx) == Module_Proc) {
00828
00829
00830
00831 attr_idx = ntr_host_in_sym_tbl(&token,
00832 name_idx,
00833 attr_idx,
00834 host_name_idx,
00835 FALSE);
00836 LN_DEF_LOC(name_idx) = TRUE;
00837 }
00838 else if (AT_OBJ_CLASS(attr_idx) == Interface) {
00839 NTR_ATTR_TBL(tmp_attr_idx);
00840 COPY_COMMON_ATTR_INFO(attr_idx, tmp_attr_idx, Pgm_Unit);
00841 ATI_PROC_IDX(attr_idx) = tmp_attr_idx;
00842 attr_idx = tmp_attr_idx;
00843 AT_USE_ASSOCIATED(attr_idx)= FALSE;
00844 AT_IS_INTRIN(attr_idx) = FALSE;
00845 AT_ELEMENTAL_INTRIN(attr_idx) = FALSE;
00846 MAKE_EXTERNAL_NAME(attr_idx,
00847 AT_NAME_IDX(attr_idx),
00848 AT_NAME_LEN(attr_idx));
00849 ATP_PROC(attr_idx) = Module_Proc;
00850 AT_DEF_LINE(attr_idx) = TOKEN_LINE(token);
00851 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(token);
00852 }
00853 else if (fnd_semantic_err(Obj_Module_Proc,
00854 TOKEN_LINE(token),
00855 TOKEN_COLUMN(token),
00856 attr_idx,
00857 FALSE)) {
00858
00859
00860
00861
00862 PRINTMSG(TOKEN_LINE(token), 707, Error,
00863 TOKEN_COLUMN(token),
00864 AT_OBJ_NAME_PTR(attr_idx));
00865
00866 CREATE_ERR_ATTR(attr_idx,
00867 TOKEN_LINE(token),
00868 TOKEN_COLUMN(token),
00869 Pgm_Unit);
00870
00871 ATP_PROC(attr_idx) = Module_Proc;
00872 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
00873 MAKE_EXTERNAL_NAME(attr_idx,
00874 AT_NAME_IDX(attr_idx),
00875 AT_NAME_LEN(attr_idx));
00876 }
00877 else {
00878
00879
00880 attr_idx = ntr_host_in_sym_tbl(&token, name_idx,
00881 attr_idx, host_name_idx,
00882 FALSE);
00883
00884 if (AT_OBJ_CLASS(attr_idx) != Pgm_Unit) {
00885 CLEAR_VARIANT_ATTR_INFO(attr_idx, Pgm_Unit);
00886 MAKE_EXTERNAL_NAME(attr_idx,
00887 AT_NAME_IDX(attr_idx),
00888 AT_NAME_LEN(attr_idx));
00889 }
00890
00891 ATP_PROC(attr_idx) = Module_Proc;
00892 LN_DEF_LOC(name_idx) = TRUE;
00893 }
00894 }
00895 }
00896 else {
00897
00898 if (AT_OBJ_CLASS(attr_idx) == Interface &&
00899 ATI_PROC_IDX(attr_idx) == NULL_IDX ||
00900 AT_IS_INTRIN(attr_idx)) {
00901
00902
00903
00904
00905
00906
00907
00908
00909 NTR_ATTR_TBL(tmp_attr_idx);
00910 #ifdef KEY
00911
00912
00913 AT_IS_INTRIN(attr_idx) = FALSE;
00914 AT_ELEMENTAL_INTRIN(attr_idx) = FALSE;
00915 COPY_COMMON_ATTR_INFO(attr_idx, tmp_attr_idx, Pgm_Unit);
00916 #else
00917 COPY_COMMON_ATTR_INFO(attr_idx, tmp_attr_idx, Pgm_Unit);
00918 AT_IS_INTRIN(attr_idx) = FALSE;
00919 AT_ELEMENTAL_INTRIN(attr_idx) = FALSE;
00920 #endif
00921 ATI_PROC_IDX(attr_idx) = tmp_attr_idx;
00922 attr_idx = tmp_attr_idx;
00923 AT_USE_ASSOCIATED(attr_idx) = FALSE;
00924 MAKE_EXTERNAL_NAME(attr_idx,
00925 AT_NAME_IDX(attr_idx),
00926 AT_NAME_LEN(attr_idx));
00927 ATP_PROC(attr_idx) = Module_Proc;
00928 AT_DEF_LINE(attr_idx) = TOKEN_LINE(token);
00929 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(token);
00930 }
00931 else {
00932
00933 if (AT_OBJ_CLASS(attr_idx) == Interface) {
00934 attr_idx = ATI_PROC_IDX(attr_idx);
00935 }
00936
00937 if (AT_NOT_VISIBLE(attr_idx) ||
00938 AT_OBJ_CLASS(attr_idx) != Pgm_Unit ||
00939 ATP_PROC(attr_idx) != Module_Proc) {
00940
00941 if (fnd_semantic_err(Obj_Module_Proc,
00942 TOKEN_LINE(token),
00943 TOKEN_COLUMN(token),
00944 attr_idx,
00945 TRUE)) {
00946 CREATE_ERR_ATTR(attr_idx,
00947 TOKEN_LINE(token),
00948 TOKEN_COLUMN(token),
00949 Pgm_Unit);
00950 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
00951 }
00952 else if (AT_OBJ_CLASS(attr_idx) != Pgm_Unit) {
00953 CLEAR_VARIANT_ATTR_INFO(attr_idx, Pgm_Unit);
00954 }
00955
00956 MAKE_EXTERNAL_NAME(attr_idx,
00957 AT_NAME_IDX(attr_idx),
00958 AT_NAME_LEN(attr_idx));
00959 }
00960
00961 ATP_PROC(attr_idx) = Module_Proc;
00962 }
00963 }
00964
00965 if (ATP_SCP_ALIVE(attr_idx) && !ATP_RECURSIVE(attr_idx) &&
00966 !on_off_flags.recursive) {
00967 PRINTMSG(TOKEN_LINE(token), 708, Warning,
00968 TOKEN_COLUMN(token),
00969 AT_OBJ_NAME_PTR(attr_idx));
00970 }
00971
00972 # if 0
00973 if ((cif_flags & XREF_RECS) != 0) {
00974 cif_usage_rec(attr_idx,
00975 AT_Tbl_Idx,
00976 TOKEN_LINE(token),
00977 TOKEN_COLUMN(token),
00978 CIF_Symbol_Declaration);
00979 }
00980 # endif
00981
00982
00983
00984
00985 if (interface_idx != NULL_IDX) {
00986
00987
00988
00989 sn_idx = ATI_FIRST_SPECIFIC_IDX(interface_idx);
00990 new_attr_idx = srch_linked_sn(TOKEN_STR(token),
00991 TOKEN_LEN(token),
00992 &sn_idx);
00993
00994 if (new_attr_idx == NULL_IDX) {
00995 NTR_INTERFACE_IN_SN_TBL(sn_idx,
00996 attr_idx,
00997 interface_idx,
00998 TOKEN_LINE(token),
00999 TOKEN_COLUMN(token));
01000
01001 if (ATI_INTERFACE_CLASS(interface_idx) ==
01002 Generic_Unknown_Interface &&
01003 ATP_PGM_UNIT(attr_idx) != Pgm_Unknown) {
01004
01005 ATI_INTERFACE_CLASS(interface_idx) =
01006 (ATP_PGM_UNIT(attr_idx) == Function) ?
01007 Generic_Function_Interface:
01008 Generic_Subroutine_Interface;
01009 }
01010 }
01011 else if (ATP_SCP_IDX(attr_idx) == curr_scp_idx) {
01012
01013 if (AT_USE_ASSOCIATED(new_attr_idx) &&
01014 AT_PRIVATE(new_attr_idx)) {
01015
01016
01017
01018
01019
01020 }
01021 else if (AT_IS_INTRIN(new_attr_idx)) {
01022
01023
01024 }
01025 else if (!AT_DCL_ERR(attr_idx)) {
01026 PRINTMSG(TOKEN_LINE(token), 671, Error,
01027 TOKEN_COLUMN(token),
01028 AT_OBJ_NAME_PTR(attr_idx),
01029 AT_OBJ_NAME_PTR(interface_idx));
01030 AT_DCL_ERR(attr_idx) = TRUE;
01031
01032
01033 }
01034
01035
01036 NTR_INTERFACE_IN_SN_TBL(sn_idx,
01037 attr_idx,
01038 interface_idx,
01039 TOKEN_LINE(token),
01040 TOKEN_COLUMN(token));
01041 }
01042 else {
01043 NTR_INTERFACE_IN_SN_TBL(sn_idx,
01044 attr_idx,
01045 interface_idx,
01046 TOKEN_LINE(token),
01047 TOKEN_COLUMN(token));
01048 }
01049 }
01050
01051 if (LA_CH_VALUE != COMMA && LA_CH_VALUE != EOS) {
01052 parse_err_flush(Find_Comma, ", or " EOS_STR);
01053 }
01054 }
01055 else {
01056 parse_err_flush(Find_Comma, "procedure-name");
01057 }
01058
01059 found_comma = (LA_CH_VALUE == COMMA);
01060 NEXT_LA_CH;
01061 }
01062 while (found_comma);
01063 }
01064 else {
01065
01066 if (!MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
01067 parse_err_flush(Find_EOS, "module-name");
01068 token = main_token;
01069 TOKEN_LINE(token) = stmt_start_line;
01070 TOKEN_COLUMN(token) = stmt_start_col;
01071 parse_error = TRUE;
01072 }
01073 else {
01074 parse_error = FALSE;
01075 }
01076
01077 if (cif_flags & MISC_RECS) {
01078 cif_stmt_type_rec(TRUE, CIF_Module_Stmt, stmt_number);
01079 }
01080
01081 SB_MODULE(SCP_SB_STATIC_IDX(curr_scp_idx)) = TRUE;
01082 SB_BLK_TYPE(SCP_SB_STATIC_IDX(curr_scp_idx)) = Static;
01083 SB_RUNTIME_INIT(SCP_SB_STATIC_IDX(curr_scp_idx)) = FALSE;
01084
01085 # if defined(_SPLIT_STATIC_STORAGE_M)
01086
01087
01088
01089
01090 CREATE_ID(name, sb_name[Data_Init_Blk], sb_len[Data_Init_Blk]);
01091 new_idx = ntr_stor_blk_tbl(name.string,
01092 sb_len[Data_Init_Blk],
01093 stmt_start_line,
01094 stmt_start_col,
01095 Static);
01096 SCP_SB_STATIC_INIT_IDX(curr_scp_idx) = new_idx;
01097 SB_PAD_BLK(new_idx) = cmd_line_flags.pad;
01098 SB_MODULE(new_idx) = TRUE;
01099
01100 if (cmd_line_flags.pad_amount != 0) {
01101 SB_PAD_AMOUNT(new_idx) = cmd_line_flags.pad_amount;
01102 SB_PAD_AMOUNT_SET(new_idx) = TRUE;
01103 }
01104
01105 # elif defined(_SPLIT_STATIC_STORAGE_2)
01106
01107
01108
01109 SB_MODULE(SCP_SB_STATIC_INIT_IDX(curr_scp_idx)) = TRUE;
01110
01111 # elif defined(_SPLIT_STATIC_STORAGE_3)
01112
01113
01114
01115
01116
01117
01118
01119 SCP_SB_STATIC_INIT_IDX(curr_scp_idx) = SCP_SB_STATIC_IDX(curr_scp_idx);
01120 SCP_SB_STATIC_UNINIT_IDX(curr_scp_idx) = SCP_SB_STATIC_IDX(curr_scp_idx);
01121 # else
01122
01123
01124
01125
01126
01127
01128
01129 SCP_SB_STATIC_INIT_IDX(curr_scp_idx) = SCP_SB_STATIC_IDX(curr_scp_idx);
01130 # endif
01131
01132 defer_msg = 0;
01133 attr_idx = start_new_prog_unit(Module,
01134 Module_Blk,
01135 FALSE,
01136 parse_error,
01137 &defer_msg);
01138
01139 name_idx = check_global_pgm_unit(attr_idx);
01140 ATP_MODULE_STR_IDX(attr_idx) = GN_NAME_IDX(name_idx);
01141
01142 CURR_BLK_NO_EXEC = TRUE;
01143
01144 # if defined(_MODULE_TO_DOT_o)
01145
01146 if (!cmd_line_flags.binary_output) {
01147 PRINTMSG(TOKEN_LINE(token), 301, Warning, TOKEN_COLUMN(token),
01148 AT_OBJ_NAME_PTR(attr_idx));
01149 }
01150 # endif
01151
01152 if (LA_CH_VALUE != EOS) {
01153 parse_err_flush(Find_EOS, EOS_STR);
01154 }
01155
01156 NEXT_LA_CH;
01157 }
01158
01159 TRACE (Func_Exit, "parse_module_stmt", NULL);
01160
01161 return;
01162
01163 }
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181 void parse_program_stmt (void)
01182
01183 {
01184 int defer_msg = 0;
01185 boolean err_fnd;
01186
01187
01188 TRACE (Func_Entry, "parse_program_stmt", NULL);
01189
01190 if (!MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
01191 parse_err_flush(Find_EOS, "program-name");
01192 token = main_token;
01193 TOKEN_LINE(token) = stmt_start_line;
01194 TOKEN_COLUMN(token) = stmt_start_col;
01195 err_fnd = TRUE;
01196 }
01197 else {
01198 err_fnd = FALSE;
01199 }
01200
01201 start_new_prog_unit(Program,
01202 Program_Blk,
01203 FALSE,
01204 err_fnd,
01205 &defer_msg);
01206
01207 if (LA_CH_VALUE == LPAREN) {
01208
01209 if (MATCHED_TOKEN_CLASS(Tok_Class_Program_Str)) {
01210
01211
01212
01213
01214
01215 PRINTMSG(TOKEN_LINE(token), 31, Ansi, TOKEN_COLUMN(token));
01216 }
01217 else {
01218 parse_err_flush(Find_EOS, NULL);
01219 }
01220 }
01221
01222 if (LA_CH_VALUE != EOS) {
01223 parse_err_flush(Find_EOS, EOS_STR);
01224 }
01225
01226 NEXT_LA_CH;
01227
01228 TRACE (Func_Exit, "parse_program_stmt", NULL);
01229
01230 return;
01231
01232 }
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250 void parse_elemental_stmt (void)
01251 {
01252 TRACE (Func_Entry, "parse_elemental_stmt", NULL);
01253
01254 CLEAR_ATTR_NTRY(AT_WORK_IDX);
01255 AT_OBJ_CLASS(AT_WORK_IDX) = Pgm_Unit;
01256 ATP_ELEMENTAL(AT_WORK_IDX) = TRUE;
01257 parse_prefix_spec();
01258
01259 TRACE (Func_Exit, "parse_elemental_stmt", NULL);
01260
01261 return;
01262
01263 }
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281 void parse_pure_stmt (void)
01282
01283 {
01284 TRACE (Func_Entry, "parse_pure_stmt", NULL);
01285
01286 CLEAR_ATTR_NTRY(AT_WORK_IDX);
01287 AT_OBJ_CLASS(AT_WORK_IDX) = Pgm_Unit;
01288 ATP_PURE(AT_WORK_IDX) = TRUE;
01289 parse_prefix_spec();
01290
01291 TRACE (Func_Exit, "parse_pure_stmt", NULL);
01292
01293 return;
01294
01295 }
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313 void parse_recursive_stmt (void)
01314 {
01315 TRACE (Func_Entry, "parse_recursive_stmt", NULL);
01316
01317 CLEAR_ATTR_NTRY(AT_WORK_IDX);
01318 AT_OBJ_CLASS(AT_WORK_IDX) = Pgm_Unit;
01319 ATP_RECURSIVE(AT_WORK_IDX) = TRUE;
01320 parse_prefix_spec();
01321
01322 TRACE (Func_Exit, "parse_recursive_stmt", NULL);
01323
01324 return;
01325
01326 }
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344 static void parse_prefix_spec (void)
01345
01346 {
01347 int attr_idx;
01348 blk_cntxt_type blk_type;
01349 int defer_msg;
01350 boolean elemental_set;
01351 boolean matched;
01352 pgm_unit_type pgm_type;
01353 boolean pure_set;
01354 boolean recursive_set;
01355
01356
01357 TRACE (Func_Entry, "parse_prefix_spec", NULL);
01358
01359 while (matched = MATCHED_TOKEN_CLASS(Tok_Class_Keyword)) {
01360
01361 switch (TOKEN_VALUE(token)) {
01362 case Tok_Kwd_Recursive:
01363
01364 if (ATP_ELEMENTAL(AT_WORK_IDX)) {
01365
01366
01367
01368 PRINTMSG(TOKEN_LINE(token), 1261, Error, TOKEN_COLUMN(token));
01369 AT_DCL_ERR(AT_WORK_IDX) = TRUE;
01370 }
01371 else if (ATP_RECURSIVE(AT_WORK_IDX)) {
01372 PRINTMSG(TOKEN_LINE(token), 1260, Error, TOKEN_COLUMN(token),
01373 "RECURSIVE");
01374 AT_DCL_ERR(AT_WORK_IDX) = TRUE;
01375 }
01376 else {
01377 ATP_RECURSIVE(AT_WORK_IDX) = TRUE;
01378 }
01379 continue;
01380
01381 case Tok_Kwd_Elemental:
01382
01383 if (ATP_RECURSIVE(AT_WORK_IDX)) {
01384
01385
01386
01387 PRINTMSG(TOKEN_LINE(token), 1261, Error, TOKEN_COLUMN(token));
01388 AT_DCL_ERR(AT_WORK_IDX) = TRUE;
01389 }
01390 else if (ATP_ELEMENTAL(AT_WORK_IDX)) {
01391 PRINTMSG(TOKEN_LINE(token), 1260, Error, TOKEN_COLUMN(token),
01392 "ELEMENTAL");
01393 AT_DCL_ERR(AT_WORK_IDX) = TRUE;
01394 }
01395 else {
01396 ATP_ELEMENTAL(AT_WORK_IDX) = TRUE;
01397 }
01398 continue;
01399
01400 case Tok_Kwd_Pure:
01401
01402 if (ATP_PURE(AT_WORK_IDX)) {
01403 PRINTMSG(TOKEN_LINE(token), 1260, Error, TOKEN_COLUMN(token),
01404 "PURE");
01405 AT_DCL_ERR(AT_WORK_IDX) = TRUE;
01406 }
01407 ATP_PURE(AT_WORK_IDX) = TRUE;
01408 continue;
01409
01410 case Tok_Kwd_Logical:
01411 case Tok_Kwd_Integer:
01412 case Tok_Kwd_Double:
01413 case Tok_Kwd_Real:
01414 case Tok_Kwd_Complex:
01415 case Tok_Kwd_Character:
01416 case Tok_Kwd_Type:
01417 parse_typed_function_stmt();
01418 goto EXIT;
01419
01420 default:
01421 break;
01422 }
01423 break;
01424 }
01425
01426 recursive_set = ATP_RECURSIVE(AT_WORK_IDX);
01427 elemental_set = ATP_ELEMENTAL(AT_WORK_IDX);
01428 pure_set = ATP_PURE(AT_WORK_IDX);
01429
01430 if (TOKEN_VALUE(token) == Tok_Kwd_Subroutine) {
01431 stmt_type = Subroutine_Stmt;
01432 SH_STMT_TYPE(curr_stmt_sh_idx) = Subroutine_Stmt;
01433 parse_subroutine_stmt();
01434 ATP_RECURSIVE(SCP_ATTR_IDX(curr_scp_idx)) = recursive_set;
01435 ATP_ELEMENTAL(SCP_ATTR_IDX(curr_scp_idx)) = elemental_set;
01436 ATP_PURE(SCP_ATTR_IDX(curr_scp_idx)) = pure_set;
01437 }
01438 else if (TOKEN_VALUE(token) == Tok_Kwd_Function) {
01439 stmt_type = Function_Stmt;
01440 SH_STMT_TYPE(curr_stmt_sh_idx) = Function_Stmt;
01441 parse_function_stmt();
01442 ATP_RECURSIVE(SCP_ATTR_IDX(curr_scp_idx)) = recursive_set;
01443 ATP_ELEMENTAL(SCP_ATTR_IDX(curr_scp_idx)) = elemental_set;
01444 ATP_PURE(SCP_ATTR_IDX(curr_scp_idx)) = pure_set;
01445 }
01446 else if (curr_stmt_category > Sub_Func_Stmt_Cat) {
01447 iss_blk_stk_err();
01448 parse_err_flush(Find_EOS, NULL);
01449 NEXT_LA_CH;
01450 }
01451 else {
01452
01453
01454
01455
01456 if (matched) {
01457 reset_lex(TOKEN_BUF_IDX(token), TOKEN_STMT_NUM(token));
01458 }
01459
01460 parse_err_flush(Find_Lparen, "FUNCTION, SUBROUTINE, INTEGER, "
01461 "LOGICAL, DOUBLE PRECISION, REAL, COMPLEX, CHARACTER or TYPE");
01462
01463 token = main_token;
01464 TOKEN_LINE(token) = stmt_start_line;
01465 TOKEN_COLUMN(token) = stmt_start_col;
01466 pgm_type = Subroutine;
01467 blk_type = Subroutine_Blk;
01468
01469 if (curr_stmt_category == Init_Stmt_Cat) {
01470 defer_msg = 0;
01471 attr_idx = start_new_prog_unit(pgm_type,
01472 blk_type,
01473 FALSE,
01474 TRUE,
01475 &defer_msg);
01476 ATP_PROC(attr_idx) = Extern_Proc;
01477 }
01478 else {
01479
01480
01481
01482 start_new_scp();
01483 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
01484 attr_idx = start_new_subpgm(pgm_type, TRUE, FALSE);
01485 }
01486
01487 CURR_BLK_ERR = TRUE;
01488 SCP_IN_ERR(curr_scp_idx) = TRUE;
01489 ATP_RECURSIVE(attr_idx) = recursive_set;
01490 ATP_ELEMENTAL(attr_idx) = elemental_set;
01491 ATP_PURE(attr_idx) = pure_set;
01492
01493 if (CURR_BLK != Interface_Body_Blk &&
01494 (cmd_line_flags.runtime_argument ||
01495 cmd_line_flags.runtime_arg_entry)) {
01496
01497 ATP_ARGCHCK_ENTRY(attr_idx) = TRUE;
01498 }
01499
01500 if (LA_CH_VALUE == LPAREN) {
01501 parse_dummy_args(attr_idx);
01502 }
01503
01504 if (LA_CH_VALUE == 'R') {
01505
01506
01507
01508
01509 ATP_PGM_UNIT(attr_idx) = Function;
01510
01511 if (CURR_BLK == Subroutine_Blk) {
01512 CURR_BLK = Function_Blk;
01513 }
01514 set_function_rslt(attr_idx, FALSE);
01515 }
01516
01517 if (LA_CH_VALUE != EOS) {
01518 parse_err_flush(Find_EOS, EOS_STR);
01519 }
01520
01521 NEXT_LA_CH;
01522 }
01523
01524 EXIT:
01525
01526 TRACE (Func_Exit, "parse_prefix_spec", NULL);
01527
01528 return;
01529
01530 }
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550 void parse_subroutine_stmt (void)
01551
01552 {
01553 int attr_idx;
01554 int defer_msg;
01555 boolean err_fnd = FALSE;
01556
01557
01558 TRACE (Func_Entry, "parse_subroutine_stmt", NULL);
01559
01560 if (curr_stmt_category > Sub_Func_Stmt_Cat) {
01561 iss_blk_stk_err();
01562 err_fnd = TRUE;
01563 }
01564
01565 if (!MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
01566 parse_err_flush(Find_Lparen, "subroutine-name");
01567 token = main_token;
01568 TOKEN_LINE(token) = stmt_start_line;
01569 TOKEN_COLUMN(token) = stmt_start_col;
01570 err_fnd = TRUE;
01571 }
01572
01573 if (curr_stmt_category == Init_Stmt_Cat) {
01574 defer_msg = 0;
01575 attr_idx = start_new_prog_unit(Subroutine,
01576 Subroutine_Blk,
01577 FALSE,
01578 err_fnd,
01579 &defer_msg);
01580 ATP_PROC(attr_idx) = Extern_Proc;
01581 }
01582 else {
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592 start_new_scp();
01593 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
01594 attr_idx = start_new_subpgm(Subroutine, err_fnd, TRUE);
01595 }
01596
01597 SCP_IN_ERR(curr_scp_idx) = AT_DCL_ERR(attr_idx);
01598
01599 if (CURR_BLK != Interface_Body_Blk &&
01600 (cmd_line_flags.runtime_argument ||
01601 cmd_line_flags.runtime_arg_entry)) {
01602
01603 ATP_ARGCHCK_ENTRY(attr_idx) = TRUE;
01604 }
01605
01606 if (LA_CH_VALUE == LPAREN) {
01607 parse_dummy_args(attr_idx);
01608 }
01609
01610 #ifdef KEY
01611 if (matched_specific_token(Tok_Kwd_Bind, Tok_Class_Keyword)) {
01612 if (AT_IS_DARG(attr_idx)) {
01613 parse_language_binding_spec(0);
01614 AT_BIND_ATTR(attr_idx) = TRUE;
01615 }
01616 else {
01617 parse_language_binding_spec(&new_binding_label);
01618 set_binding_label(AT_Tbl_Idx, attr_idx, &new_binding_label);
01619 }
01620 }
01621 else
01622 #endif
01623 if (LA_CH_VALUE != EOS) {
01624 parse_err_flush(Find_EOS, EOS_STR);
01625 }
01626
01627 NEXT_LA_CH;
01628
01629 TRACE (Func_Exit, "parse_subroutine_stmt", NULL);
01630
01631 return;
01632
01633 }
01634 #ifdef KEY
01635
01636
01637
01638
01639
01640
01641 static int
01642 help_set_function_rslt(int attr_idx, int *out_result_idx) {
01643 token_type save_token;
01644 int rslt_idx;
01645 int name_idx;
01646 int err_found = FALSE;
01647
01648 if (LA_CH_VALUE != LPAREN) {
01649 parse_err_flush(Find_EOS, "(");
01650 err_found = TRUE;
01651 }
01652 else {
01653 NEXT_LA_CH;
01654
01655 if (!MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
01656 parse_err_flush(Find_EOS, "result-name");
01657 err_found = TRUE;
01658 }
01659 else {
01660
01661 if (LA_CH_VALUE == RPAREN) {
01662 NEXT_LA_CH;
01663 }
01664 else {
01665 save_token = token;
01666 parse_err_flush(Find_EOS, ")");
01667 err_found = TRUE;
01668 token = save_token;
01669 }
01670
01671 rslt_idx = srch_sym_tbl(TOKEN_STR(token), TOKEN_LEN(token),
01672 &name_idx);
01673
01674 if (rslt_idx == NULL_IDX) {
01675 rslt_idx = ntr_sym_tbl(&token, name_idx);
01676 LN_DEF_LOC(name_idx) = TRUE;
01677 AT_OBJ_CLASS(rslt_idx) = Data_Obj;
01678 }
01679 else if (!ATP_ALT_ENTRY(attr_idx)) {
01680
01681
01682
01683 PRINTMSG(TOKEN_LINE(token), 1471, Error, TOKEN_COLUMN(token),
01684 AT_OBJ_NAME_PTR(rslt_idx));
01685 CREATE_ERR_ATTR(rslt_idx,
01686 TOKEN_LINE(token),
01687 TOKEN_COLUMN(token),
01688 Data_Obj);
01689 }
01690 else if (fnd_semantic_err(Obj_Ntry_Func_Result,
01691 TOKEN_LINE(token),
01692 TOKEN_COLUMN(token),
01693 rslt_idx,
01694 TRUE)) {
01695 CREATE_ERR_ATTR(rslt_idx,
01696 TOKEN_LINE(token),
01697 TOKEN_COLUMN(token),
01698 Data_Obj);
01699 }
01700 else if (AT_REFERENCED(rslt_idx) == Char_Rslt_Bound_Ref) {
01701 AT_ATTR_LINK(rslt_idx) = NULL_IDX;
01702 LN_DEF_LOC(name_idx) = TRUE;
01703 }
01704
01705 if ((cif_flags & XREF_RECS) != 0) {
01706 cif_usage_rec(rslt_idx,
01707 AT_Tbl_Idx,
01708 TOKEN_LINE(token),
01709 TOKEN_COLUMN(token),
01710 CIF_Symbol_Declaration);
01711 }
01712
01713 ATD_CLASS(rslt_idx) = Function_Result;
01714 ATP_RSLT_NAME(attr_idx) = TRUE;
01715 }
01716 }
01717 *out_result_idx = rslt_idx;
01718 return err_found;
01719 }
01720 #endif
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738 static void set_function_rslt(int attr_idx,
01739 boolean type_err)
01740
01741 {
01742 boolean err_found = FALSE;
01743 int func_rslt_idx;
01744 int rslt_idx = NULL_IDX;
01745
01746
01747 TRACE (Func_Entry, "set_function_rslt", NULL);
01748
01749 #ifdef KEY
01750 int bind_ok = 1;
01751 int result_ok = 1;
01752 while (LA_CH_VALUE != EOS) {
01753 if (bind_ok && matched_specific_token(Tok_Kwd_Bind, Tok_Class_Keyword)) {
01754 bind_ok = 0;
01755 int line, column;
01756 if (AT_IS_DARG(attr_idx)) {
01757 parse_language_binding_spec(0);
01758 AT_BIND_ATTR(attr_idx) = TRUE;
01759 }
01760 else {
01761 parse_language_binding_spec(&new_binding_label);
01762 set_binding_label(AT_Tbl_Idx, attr_idx, &new_binding_label);
01763 }
01764 }
01765 else if (result_ok && matched_specific_token(Tok_Kwd_Result,
01766 Tok_Class_Keyword)) {
01767 result_ok = 0;
01768 err_found = help_set_function_rslt(attr_idx, &rslt_idx);
01769 } else {
01770 parse_err_flush(Find_EOS, "BIND, RESULT or " EOS_STR);
01771 err_found = TRUE;
01772 break;
01773 }
01774 }
01775 #endif
01776
01777 func_rslt_idx = ATP_RSLT_IDX(attr_idx);
01778
01779 if (rslt_idx == NULL_IDX) {
01780
01781 if (func_rslt_idx == NULL_IDX) {
01782 NTR_ATTR_TBL(rslt_idx);
01783 COPY_COMMON_ATTR_INFO(attr_idx, rslt_idx, Data_Obj);
01784 ATD_CLASS(rslt_idx) = Function_Result;
01785 }
01786 else {
01787 rslt_idx = func_rslt_idx;
01788 }
01789 }
01790 else if (func_rslt_idx != NULL_IDX) {
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801 if (ATD_ARRAY_IDX(func_rslt_idx) != NULL_IDX) {
01802 err_found = TRUE;
01803 PRINTMSG(TOKEN_LINE(token), 27, Error, TOKEN_COLUMN(token),
01804 AT_OBJ_NAME_PTR(attr_idx), AT_OBJ_NAME_PTR(rslt_idx));
01805
01806 if (ATD_ARRAY_IDX(rslt_idx) == NULL_IDX) {
01807 ATD_ARRAY_IDX(rslt_idx) = ATD_ARRAY_IDX(func_rslt_idx);
01808 }
01809 }
01810
01811 if (ATD_POINTER(func_rslt_idx)) {
01812 err_found = TRUE;
01813 PRINTMSG(TOKEN_LINE(token), 36, Error, TOKEN_COLUMN(token),
01814 AT_OBJ_NAME_PTR(attr_idx), AT_OBJ_NAME_PTR(rslt_idx));
01815
01816 if (!ATD_POINTER(rslt_idx)) {
01817 ATD_POINTER(rslt_idx) = TRUE;
01818 ATD_IM_A_DOPE(rslt_idx) = TRUE;
01819 }
01820 }
01821
01822 if (ATD_TARGET(func_rslt_idx)) {
01823 err_found = TRUE;
01824 PRINTMSG(TOKEN_LINE(token), 132, Error, TOKEN_COLUMN(token),
01825 AT_OBJ_NAME_PTR(attr_idx), AT_OBJ_NAME_PTR(rslt_idx));
01826
01827 if (!ATD_TARGET(rslt_idx)) {
01828 ATD_TARGET(rslt_idx) = TRUE;
01829 }
01830 }
01831
01832 if (AT_TYPED(func_rslt_idx)) {
01833 err_found = TRUE;
01834 PRINTMSG(TOKEN_LINE(token), 185, Error, TOKEN_COLUMN(token),
01835 AT_OBJ_NAME_PTR(attr_idx), AT_OBJ_NAME_PTR(rslt_idx));
01836
01837 if (!AT_TYPED(rslt_idx)) {
01838 ATD_TYPE_IDX(rslt_idx) = ATD_TYPE_IDX(func_rslt_idx);
01839 AT_TYPED(rslt_idx) = AT_TYPED(func_rslt_idx);
01840 }
01841 }
01842 AT_ACCESS_SET(rslt_idx) = AT_ACCESS_SET(func_rslt_idx);
01843 AT_PRIVATE(rslt_idx) = AT_PRIVATE(func_rslt_idx);
01844
01845
01846
01847
01848 CLEAR_ATTR_NTRY(func_rslt_idx);
01849 AT_DCL_ERR(func_rslt_idx) = TRUE;
01850 }
01851
01852 if (!AT_TYPED(rslt_idx) || type_err) {
01853
01854 if (!AT_DCL_ERR(rslt_idx)) {
01855 SET_IMPL_TYPE(rslt_idx);
01856 }
01857 else if (ATD_TYPE_IDX(rslt_idx) == NULL_IDX) {
01858 ATD_TYPE_IDX(rslt_idx) = TYPELESS_DEFAULT_TYPE;
01859 }
01860 }
01861
01862 ATP_RSLT_IDX(attr_idx) = rslt_idx;
01863 ATD_FUNC_IDX(rslt_idx) = attr_idx;
01864 AT_DCL_ERR(rslt_idx) = err_found || AT_DCL_ERR(rslt_idx);
01865 AT_DCL_ERR(attr_idx) = AT_DCL_ERR(attr_idx) || AT_DCL_ERR(rslt_idx);
01866
01867 TRACE (Func_Exit, "set_function_rslt", NULL);
01868
01869 return;
01870
01871 }
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888 static void parse_dummy_args(int pgm_attr_idx)
01889 {
01890 int attr_idx;
01891 boolean found_end = FALSE;
01892 int list_idx;
01893 int name_idx;
01894 int sn_idx;
01895 int sn_attr_idx;
01896
01897
01898 TRACE (Func_Entry, "parse_dummy_args", NULL);
01899
01900 # ifdef _DEBUG
01901 if (LA_CH_VALUE != LPAREN) {
01902 PRINTMSG(TOKEN_LINE(token), 295, Internal, TOKEN_COLUMN(token),
01903 "parse_dummy_args", "LPAREN");
01904 }
01905 # endif
01906
01907 NEXT_LA_CH;
01908
01909 if (LA_CH_VALUE == RPAREN) {
01910 NEXT_LA_CH;
01911 return;
01912 }
01913
01914
01915
01916
01917
01918 NTR_SN_TBL(sn_attr_idx);
01919
01920 do {
01921 if (MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
01922 attr_idx = srch_sym_tbl(TOKEN_STR(token), TOKEN_LEN(token), &name_idx);
01923
01924 if (attr_idx == NULL_IDX) {
01925 attr_idx = ntr_sym_tbl(&token, name_idx);
01926 LN_DEF_LOC(name_idx) = TRUE;
01927 AT_OBJ_CLASS(attr_idx) = Data_Obj;
01928 ATD_CLASS(attr_idx) = Dummy_Argument;
01929 SET_IMPL_TYPE(attr_idx);
01930 AT_IS_DARG(attr_idx) = TRUE;
01931 AT_DCL_ERR(attr_idx) = AT_DCL_ERR(pgm_attr_idx);
01932
01933
01934
01935 NTR_ATTR_LIST_TBL(list_idx);
01936 AL_NEXT_IDX(list_idx) = SCP_DARG_LIST(curr_scp_idx);
01937 AL_ATTR_IDX(list_idx) = attr_idx;
01938 SCP_DARG_LIST(curr_scp_idx) = list_idx;
01939 }
01940 else if (!fnd_semantic_err(Obj_Dummy_Arg,
01941 TOKEN_LINE(token),
01942 TOKEN_COLUMN(token),
01943 attr_idx,
01944 TRUE)) {
01945
01946 AT_DCL_ERR(attr_idx) = AT_DCL_ERR(pgm_attr_idx);
01947
01948 if (AT_REFERENCED(attr_idx) == Char_Rslt_Bound_Ref) {
01949 AT_ATTR_LINK(attr_idx) = NULL_IDX;
01950 LN_DEF_LOC(name_idx) = TRUE;
01951 CLEAR_VARIANT_ATTR_INFO(attr_idx, Data_Obj);
01952 ATD_CLASS(attr_idx) = Dummy_Argument;
01953 SET_IMPL_TYPE(attr_idx);
01954 }
01955 else if ((AT_REFERENCED(attr_idx) == Referenced ||
01956 AT_DEFINED(attr_idx)) && !AT_IS_DARG(attr_idx)) {
01957
01958
01959
01960
01961
01962 PRINTMSG(TOKEN_LINE(token), 529, Error, TOKEN_COLUMN(token),
01963 AT_OBJ_NAME_PTR(attr_idx));
01964 }
01965
01966 if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit) {
01967
01968 if (ATP_PROC(attr_idx) != Dummy_Proc) {
01969 ATP_PROC(attr_idx) = Dummy_Proc;
01970 }
01971 }
01972 else if (ATD_CLASS(attr_idx) != Dummy_Argument) {
01973 ATD_CLASS(attr_idx) = Dummy_Argument;
01974 }
01975
01976
01977
01978 if (!AT_IS_DARG(attr_idx)) {
01979 NTR_ATTR_LIST_TBL(list_idx);
01980 AL_NEXT_IDX(list_idx) = SCP_DARG_LIST(curr_scp_idx);
01981 AL_ATTR_IDX(list_idx) = attr_idx;
01982 SCP_DARG_LIST(curr_scp_idx) = list_idx;
01983 }
01984 AT_IS_DARG(attr_idx) = TRUE;
01985 }
01986
01987 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
01988 ATD_SEEN_OUTSIDE_IMP_DO(attr_idx) = TRUE;
01989 }
01990
01991
01992 if ((cif_flags & XREF_RECS) != 0) {
01993 cif_usage_rec(attr_idx,
01994 AT_Tbl_Idx,
01995 TOKEN_LINE(token),
01996 TOKEN_COLUMN(token),
01997 CIF_Symbol_Is_Dummy_Arg);
01998 }
01999
02000
02001
02002 sn_attr_idx = srch_kwd_name(TOKEN_STR(token), TOKEN_LEN(token),
02003 pgm_attr_idx, &sn_idx);
02004
02005 if (sn_attr_idx != NULL_IDX) {
02006 PRINTMSG(TOKEN_LINE(token), 10, Error, TOKEN_COLUMN(token),
02007 TOKEN_STR(token));
02008 }
02009 else {
02010 NTR_SN_TBL(sn_idx);
02011 SN_ATTR_IDX(sn_idx) = attr_idx;
02012 SN_NAME_LEN(sn_idx) = AT_NAME_LEN(attr_idx);
02013 SN_NAME_IDX(sn_idx) = AT_NAME_IDX(attr_idx);
02014 SN_LINE_NUM(sn_idx) = TOKEN_LINE(token);
02015 SN_COLUMN_NUM(sn_idx) = TOKEN_COLUMN(token);
02016
02017 if (ATP_FIRST_IDX(pgm_attr_idx) == NULL_IDX) {
02018 ATP_FIRST_IDX(pgm_attr_idx) = sn_idx;
02019 }
02020 ATP_NUM_DARGS(pgm_attr_idx) += 1;
02021 }
02022 }
02023 else if (LA_CH_VALUE == STAR &&
02024 ATP_PGM_UNIT(pgm_attr_idx) == Subroutine) {
02025
02026
02027
02028
02029 attr_idx = gen_compiler_tmp(LA_CH_LINE, LA_CH_COLUMN, Shared, TRUE);
02030
02031 NEXT_LA_CH;
02032
02033
02034 AT_REFERENCED(attr_idx) = Referenced;
02035 AT_DEFINED(attr_idx) = TRUE;
02036 AT_SEMANTICS_DONE(attr_idx) = TRUE;
02037 ATD_TYPE_IDX(attr_idx) = INTEGER_DEFAULT_TYPE;
02038 ATD_STOR_BLK_IDX(attr_idx) = SCP_SB_DARG_IDX(curr_scp_idx);
02039 ATD_CLASS(attr_idx) = Dummy_Argument;
02040 AT_IS_DARG(attr_idx) = TRUE;
02041 ATP_HAS_ALT_RETURN(pgm_attr_idx) = TRUE;
02042 ATP_HAS_ALT_RETURN(SCP_ATTR_IDX(curr_scp_idx)) = TRUE;
02043
02044 NTR_SN_TBL(sn_attr_idx);
02045 SN_ATTR_IDX(sn_attr_idx) = attr_idx;
02046 SN_NAME_IDX(sn_attr_idx) = AT_NAME_IDX(attr_idx);
02047 SN_LINE_NUM(sn_attr_idx) = LA_CH_LINE;
02048 SN_COLUMN_NUM(sn_attr_idx) = LA_CH_COLUMN;
02049
02050 if (ATP_FIRST_IDX(pgm_attr_idx) == NULL_IDX) {
02051 ATP_FIRST_IDX(pgm_attr_idx) = sn_attr_idx;
02052 }
02053 ATP_NUM_DARGS(pgm_attr_idx) +=1;
02054 }
02055 else {
02056 parse_err_flush(Find_Comma_Rparen, "dummy-arg-name");
02057 found_end = (LA_CH_VALUE == EOS);
02058 }
02059
02060 if (LA_CH_VALUE != RPAREN && LA_CH_VALUE != COMMA && !found_end) {
02061 parse_err_flush(Find_Comma_Rparen, ", or )");
02062 }
02063
02064 if (LA_CH_VALUE == COMMA) {
02065 NEXT_LA_CH;
02066 }
02067 else {
02068 found_end = TRUE;
02069 }
02070 }
02071 while (!found_end);
02072
02073
02074
02075
02076
02077 if (ATP_NUM_DARGS(pgm_attr_idx) > max_call_list_size) {
02078 max_call_list_size = (long) ATP_NUM_DARGS(pgm_attr_idx);
02079 }
02080
02081 if (LA_CH_VALUE == RPAREN) {
02082 NEXT_LA_CH;
02083 }
02084
02085 TRACE (Func_Exit, "parse_dummy_args", NULL);
02086
02087 return;
02088
02089 }
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113 static int start_new_subpgm(pgm_unit_type pgm_type,
02114 boolean has_error,
02115 boolean save_idxs)
02116
02117 {
02118 int attr_idx;
02119 int host_name_idx;
02120 int interface_idx = NULL_IDX;
02121 int ir_idx;
02122 int length;
02123 int loc_name_idx;
02124 int name_idx;
02125 atp_proc_type proc_type;
02126 int sb_idx;
02127 int sn_idx;
02128 int tmp_attr_idx;
02129 obj_type type_of_obj;
02130
02131
02132 TRACE (Func_Entry, "start_new_subpgm", NULL);
02133
02134 if (CURR_BLK == Interface_Blk) {
02135 interface_idx = CURR_BLK_NAME;
02136
02137 if (interface_idx) {
02138
02139 if (ATI_INTERFACE_CLASS(interface_idx) == Generic_Unknown_Interface) {
02140 ATI_INTERFACE_CLASS(interface_idx) = (pgm_type == Function) ?
02141 Generic_Function_Interface :
02142 Generic_Subroutine_Interface;
02143 }
02144 }
02145 else {
02146 interface_idx = BLK_UNNAMED_INTERFACE(blk_stk_idx);
02147 }
02148
02149 ATI_HAS_NON_MOD_PROC(interface_idx) = TRUE;
02150
02151
02152
02153
02154 if (save_idxs && BLK_AT_IDX(blk_stk_idx) == NULL_IDX) {
02155 BLK_AT_IDX(blk_stk_idx) = attr_tbl_idx;
02156 BLK_BD_IDX(blk_stk_idx) = bounds_tbl_idx;
02157 BLK_CN_IDX(blk_stk_idx) = const_tbl_idx;
02158 BLK_CP_IDX(blk_stk_idx) = const_pool_idx;
02159 BLK_NP_IDX(blk_stk_idx) = name_pool_idx;
02160 BLK_SB_IDX(blk_stk_idx) = stor_blk_tbl_idx;
02161 BLK_SN_IDX(blk_stk_idx) = sec_name_tbl_idx;
02162 BLK_TYP_IDX(blk_stk_idx) = type_tbl_idx;
02163 }
02164
02165 PUSH_BLK_STK(Interface_Body_Blk);
02166 CURR_BLK_NO_EXEC = TRUE;
02167 proc_type = Extern_Proc;
02168 type_of_obj = (pgm_type == Function) ? Obj_Interface_Func :
02169 Obj_Interface_Subr;
02170 }
02171 else if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module) {
02172
02173
02174
02175
02176 PUSH_BLK_STK(Module_Proc_Blk);
02177 type_of_obj = (pgm_type == Function) ? Obj_Module_Func :
02178 Obj_Module_Subr;
02179 proc_type = Module_Proc;
02180 }
02181 else {
02182 PUSH_BLK_STK(Internal_Blk);
02183 proc_type = Intern_Proc;
02184 type_of_obj = (pgm_type == Function) ? Obj_Intern_Func :
02185 Obj_Intern_Subr;
02186 }
02187
02188
02189
02190 attr_idx = srch_sym_tbl(TOKEN_STR(token), TOKEN_LEN(token), &name_idx);
02191
02192 if (CURR_BLK == Interface_Body_Blk) {
02193
02194
02195
02196
02197
02198
02199
02200
02201 if (SCP_LEVEL(curr_scp_idx) == 1 &&
02202 (attr_idx == NULL_IDX || AT_OBJ_CLASS(attr_idx) == Interface)) {
02203
02204 attr_idx = srch_host_sym_tbl(TOKEN_STR(token),
02205 TOKEN_LEN(token),
02206 &host_name_idx,
02207 TRUE);
02208
02209 if (attr_idx != NULL_IDX &&
02210 !SH_ERR_FLG(curr_stmt_sh_idx) &&
02211 (SCP_ATTR_IDX(SCP_PARENT_IDX(curr_scp_idx)) == attr_idx ||
02212 AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
02213 ATP_ALT_ENTRY(attr_idx)) ) {
02214
02215
02216
02217
02218
02219 curr_scp_idx = SCP_LAST_CHILD_IDX(curr_scp_idx);
02220 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02221 PRINTMSG(TOKEN_LINE(token), 44, Error, TOKEN_COLUMN(token),
02222 AT_OBJ_NAME_PTR(attr_idx));
02223 AT_DCL_ERR(attr_idx) = TRUE;
02224 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
02225 }
02226 attr_idx = NULL_IDX;
02227 }
02228 }
02229
02230 if (attr_idx == NULL_IDX) {
02231 attr_idx = ntr_sym_tbl(&token, name_idx);
02232 AT_OBJ_CLASS(attr_idx) = Pgm_Unit;
02233 LN_DEF_LOC(name_idx) = TRUE;
02234 ATP_PROC(attr_idx) = proc_type;
02235 ATP_PGM_UNIT(attr_idx) = pgm_type;
02236 }
02237 else if (AT_NOT_VISIBLE(attr_idx)) {
02238 curr_scp_idx = SCP_LAST_CHILD_IDX(curr_scp_idx);
02239 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02240
02241 PRINTMSG(TOKEN_LINE(token), 486, Error,
02242 TOKEN_COLUMN(token),
02243 AT_OBJ_NAME_PTR(attr_idx),
02244 AT_OBJ_NAME_PTR(AT_MODULE_IDX((attr_idx))));
02245
02246 CREATE_ERR_ATTR(attr_idx,
02247 TOKEN_LINE(token),
02248 TOKEN_COLUMN(token),
02249 Pgm_Unit);
02250
02251 ATP_PROC(attr_idx) = proc_type;
02252 ATP_PGM_UNIT(attr_idx) = pgm_type;
02253 AT_TYPED(attr_idx) = FALSE;
02254 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
02255 }
02256 else if (CURR_BLK == Interface_Body_Blk && interface_idx == attr_idx) {
02257
02258
02259
02260 NTR_ATTR_TBL(tmp_attr_idx);
02261 COPY_COMMON_ATTR_INFO(attr_idx, tmp_attr_idx, Pgm_Unit);
02262 ATI_PROC_IDX(attr_idx) = tmp_attr_idx;
02263 attr_idx = tmp_attr_idx;
02264 ATP_PROC(attr_idx) = proc_type;
02265 ATP_PGM_UNIT(attr_idx) = pgm_type;
02266 AT_DEF_LINE(attr_idx) = TOKEN_LINE(token);
02267 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(token);
02268 AT_IS_INTRIN(attr_idx) = FALSE;
02269 AT_ELEMENTAL_INTRIN(attr_idx) = FALSE;
02270 }
02271 else if (CURR_BLK == Interface_Body_Blk &&
02272 SCP_ATTR_IDX(curr_scp_idx) == attr_idx) {
02273
02274
02275
02276
02277 NTR_ATTR_TBL(tmp_attr_idx);
02278 COPY_COMMON_ATTR_INFO(attr_idx, tmp_attr_idx, Pgm_Unit);
02279 ATP_DUPLICATE_INTERFACE_IDX(attr_idx) = tmp_attr_idx;
02280 attr_idx = tmp_attr_idx;
02281 ATP_PROC(attr_idx) = proc_type;
02282 ATP_PGM_UNIT(attr_idx) = pgm_type;
02283 AT_DEF_LINE(attr_idx) = TOKEN_LINE(token);
02284 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(token);
02285 AT_IS_INTRIN(attr_idx) = FALSE;
02286 AT_ELEMENTAL_INTRIN(attr_idx) = FALSE;
02287 }
02288 else {
02289
02290 if (AT_OBJ_CLASS(attr_idx) == Interface &&
02291 ATI_PROC_IDX(attr_idx) != NULL_IDX) {
02292 attr_idx = ATI_PROC_IDX(attr_idx);
02293 }
02294
02295 if (proc_type == Intern_Proc &&
02296 AT_ATTR_LINK(attr_idx) != NULL_IDX &&
02297 AT_LOCKED_IN(attr_idx)) {
02298
02299 do {
02300 tmp_attr_idx = AT_ATTR_LINK(attr_idx);
02301 }
02302 while (AT_ATTR_LINK(tmp_attr_idx) != NULL_IDX);
02303
02304 if (AT_OBJ_CLASS(tmp_attr_idx) == Data_Obj &&
02305 ATD_CLASS(tmp_attr_idx) == Constant) {
02306
02307
02308
02309
02310 curr_scp_idx = SCP_LAST_CHILD_IDX(curr_scp_idx);
02311 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02312
02313 PRINTMSG(TOKEN_LINE(token), 919, Error,
02314 TOKEN_COLUMN(token),
02315 AT_OBJ_NAME_PTR(attr_idx),
02316 (pgm_type == Function) ? "FUNCTION" : "SUBROUTINE");
02317 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
02318 }
02319 }
02320
02321 if (SH_ERR_FLG(curr_stmt_sh_idx) ||
02322 attr_idx == glb_tbl_idx[Main_Attr_Idx] ||
02323 AT_DCL_ERR(attr_idx) ||
02324 fnd_semantic_err(type_of_obj,
02325 TOKEN_LINE(token),
02326 TOKEN_COLUMN(token),
02327 attr_idx,
02328 TRUE)) {
02329
02330
02331
02332
02333
02334
02335 CREATE_ERR_ATTR(attr_idx,
02336 TOKEN_LINE(token),
02337 TOKEN_COLUMN(token),
02338 Pgm_Unit);
02339 AT_TYPED(attr_idx) = FALSE;
02340 ATP_PROC(attr_idx) = proc_type;
02341 ATP_PGM_UNIT(attr_idx) = pgm_type;
02342 }
02343 else if (CURR_BLK != Interface_Body_Blk &&
02344 proc_type == Module_Proc &&
02345 (AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
02346 ATP_PROC(attr_idx) == Module_Proc &&
02347 ATP_EXPL_ITRFC(attr_idx))) {
02348
02349
02350
02351 curr_scp_idx = SCP_LAST_CHILD_IDX(curr_scp_idx);
02352 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02353
02354 PRINTMSG(TOKEN_LINE(token), 1529, Error,
02355 TOKEN_COLUMN(token),
02356 AT_OBJ_NAME_PTR(attr_idx));
02357 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
02358 }
02359 else if (AT_OBJ_CLASS(attr_idx) == Interface) {
02360
02361 if (AT_IS_INTRIN(attr_idx) && !LN_DEF_LOC(name_idx)) {
02362
02363
02364
02365
02366 CLEAR_VARIANT_ATTR_INFO(attr_idx, Pgm_Unit);
02367 AT_ATTR_LINK(attr_idx) = NULL_IDX;
02368 AT_IS_INTRIN(attr_idx) = FALSE;
02369 AT_ELEMENTAL_INTRIN(attr_idx)= FALSE;
02370 ATP_PROC(attr_idx) = proc_type;
02371 ATP_PGM_UNIT(attr_idx) = pgm_type;
02372 AT_USE_ASSOCIATED(attr_idx) = FALSE;
02373 AT_DEF_LINE(attr_idx) = TOKEN_LINE(token);
02374 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(token);
02375 LN_DEF_LOC(name_idx) = TRUE;
02376 }
02377 else {
02378 NTR_ATTR_TBL(tmp_attr_idx);
02379 COPY_COMMON_ATTR_INFO(attr_idx, tmp_attr_idx, Pgm_Unit);
02380 ATI_PROC_IDX(attr_idx) = tmp_attr_idx;
02381 attr_idx = tmp_attr_idx;
02382 AT_USE_ASSOCIATED(attr_idx) = FALSE;
02383 MAKE_EXTERNAL_NAME(attr_idx,
02384 AT_NAME_IDX(attr_idx),
02385 AT_NAME_LEN(attr_idx));
02386 ATP_PROC(attr_idx) = proc_type;
02387 ATP_PGM_UNIT(attr_idx) = pgm_type;
02388 AT_DEF_LINE(attr_idx) = TOKEN_LINE(token);
02389 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(token);
02390 AT_IS_INTRIN(attr_idx) = FALSE;
02391 AT_ELEMENTAL_INTRIN(attr_idx) = FALSE;
02392 }
02393 }
02394 else {
02395
02396
02397
02398
02399
02400
02401 AT_ATTR_LINK(attr_idx) = NULL_IDX;
02402 LN_DEF_LOC(name_idx) = TRUE;
02403
02404 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
02405 chg_data_obj_to_pgm_unit(attr_idx, pgm_type, proc_type);
02406 }
02407 else {
02408 ATP_PROC(attr_idx) = proc_type;
02409 ATP_PGM_UNIT(attr_idx) = pgm_type;
02410
02411 if (pgm_type == Function && ATP_RSLT_IDX(attr_idx) != NULL_IDX) {
02412 AT_ATTR_LINK(ATP_RSLT_IDX(attr_idx)) = NULL_IDX;
02413 }
02414 }
02415 AT_DEF_LINE(attr_idx) = TOKEN_LINE(token);
02416 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(token);
02417 }
02418
02419 }
02420
02421
02422
02423
02424
02425
02426 curr_scp_idx = SCP_LAST_CHILD_IDX(curr_scp_idx);
02427 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02428 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
02429 AT_DCL_ERR(attr_idx) = AT_DCL_ERR(attr_idx) || has_error;
02430
02431
02432
02433 tmp_attr_idx = srch_sym_tbl(TOKEN_STR(token),
02434 TOKEN_LEN(token),
02435 &loc_name_idx);
02436
02437
02438
02439
02440
02441
02442 ATP_PARENT_IDX(attr_idx) = SCP_ATTR_IDX(SCP_PARENT_IDX(curr_scp_idx));
02443
02444 if (tmp_attr_idx != NULL_IDX) {
02445 fnd_semantic_err(type_of_obj,
02446 TOKEN_LINE(token),
02447 TOKEN_COLUMN(token),
02448 tmp_attr_idx,
02449 TRUE);
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462 LN_ATTR_IDX(loc_name_idx) = attr_idx;
02463 LN_NAME_IDX(loc_name_idx) = AT_NAME_IDX(attr_idx);
02464 }
02465 else {
02466
02467
02468
02469
02470 attr_idx = ntr_host_in_sym_tbl(&token, loc_name_idx, attr_idx, name_idx,
02471 FALSE);
02472 }
02473
02474 LN_DEF_LOC(loc_name_idx) = TRUE;
02475 curr_stmt_category = Dir_Integer_Stmt_Cat;
02476 CURR_BLK_NAME = attr_idx;
02477 ATP_EXPL_ITRFC(attr_idx) = TRUE;
02478
02479 if ((cif_flags & XREF_RECS) != 0) {
02480 cif_usage_rec(attr_idx,
02481 AT_Tbl_Idx,
02482 TOKEN_LINE(token),
02483 TOKEN_COLUMN(token),
02484 CIF_Symbol_Declaration);
02485 }
02486
02487
02488
02489
02490 CURR_BLK_FIRST_SH_IDX =
02491 (SH_STMT_TYPE(SCP_FIRST_SH_IDX(curr_scp_idx)) != Label_Def) ?
02492 SCP_FIRST_SH_IDX(curr_scp_idx) :
02493 IR_IDX_L(SH_IR_IDX(SCP_FIRST_SH_IDX(curr_scp_idx)));
02494
02495 NTR_IR_TBL(ir_idx);
02496 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
02497 IR_OPR(ir_idx) = Entry_Opr;
02498 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
02499 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token);
02500 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token);
02501 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
02502 IR_IDX_L(ir_idx) = attr_idx;
02503 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(token);
02504 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(token);
02505
02506 ATP_SCP_ALIVE(attr_idx) = TRUE;
02507
02508 if (CURR_BLK == Interface_Body_Blk) {
02509 MAKE_EXTERNAL_NAME(attr_idx,
02510 AT_NAME_IDX(attr_idx),
02511 AT_NAME_LEN(attr_idx));
02512 ATP_IN_INTERFACE_BLK(attr_idx) = TRUE;
02513 ATP_IN_UNNAMED_INTERFACE(attr_idx)= ATI_UNNAMED_INTERFACE(interface_idx);
02514
02515 if (interface_idx != NULL_IDX) {
02516 sn_idx = ATI_FIRST_SPECIFIC_IDX(interface_idx);
02517 tmp_attr_idx = srch_linked_sn(TOKEN_STR(token),
02518 TOKEN_LEN(token),
02519 &sn_idx);
02520
02521 if (tmp_attr_idx == NULL_IDX) {
02522
02523
02524 }
02525 else if (AT_IS_INTRIN(tmp_attr_idx)) {
02526
02527
02528 }
02529 else if (ATP_SCP_IDX(attr_idx) == curr_scp_idx &&
02530 !AT_USE_ASSOCIATED(attr_idx) &&
02531 !ATI_UNNAMED_INTERFACE(interface_idx)) {
02532
02533 if (!AT_DCL_ERR(attr_idx)) {
02534 PRINTMSG(TOKEN_LINE(token), 671, Error,
02535 TOKEN_COLUMN(token),
02536 AT_OBJ_NAME_PTR(attr_idx),
02537 AT_OBJ_NAME_PTR(interface_idx));
02538 AT_DCL_ERR(attr_idx) = TRUE;
02539 }
02540
02541
02542
02543 }
02544 else {
02545
02546
02547 }
02548
02549 #ifdef KEY
02550
02551
02552
02553
02554
02555
02556
02557
02558 if (AT_IS_INTRIN(interface_idx)) {
02559 boolean adding_subroutine = (Subroutine == ATP_PGM_UNIT(attr_idx));
02560 if (adding_subroutine != (Generic_Subroutine_Interface ==
02561 ATI_INTERFACE_CLASS(interface_idx))) {
02562 AT_IS_INTRIN(interface_idx) = FALSE;
02563 ATI_FIRST_SPECIFIC_IDX(interface_idx) = NULL_IDX;
02564 ATI_NUM_SPECIFICS(interface_idx) = 0;
02565 ATI_INTERFACE_CLASS(interface_idx) = adding_subroutine ?
02566 Generic_Subroutine_Interface :
02567 Generic_Function_Interface;
02568 }
02569 }
02570 #endif
02571
02572 NTR_INTERFACE_IN_SN_TBL(sn_idx,
02573 attr_idx,
02574 interface_idx,
02575 TOKEN_LINE(token),
02576 TOKEN_COLUMN(token));
02577 }
02578
02579
02580
02581
02582 sb_idx = SCP_SB_STATIC_IDX(curr_scp_idx);
02583 SB_HOSTED_STATIC(sb_idx) = TRUE;
02584 SB_BLK_TYPE(sb_idx) = Static;
02585 SB_RUNTIME_INIT(sb_idx) = FALSE;
02586
02587 SCP_SB_HOSTED_STATIC_IDX(curr_scp_idx) = sb_idx;
02588
02589
02590
02591 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
02592 SB_NAME_LEN(sb_idx),
02593 curr_scp_idx,
02594 &length);
02595 SB_NAME_LEN(sb_idx) = length;
02596
02597 if (sb_idx != SCP_SB_STATIC_INIT_IDX(curr_scp_idx)) {
02598 sb_idx = SCP_SB_STATIC_INIT_IDX(curr_scp_idx);
02599 SB_HOSTED_STATIC(sb_idx) = TRUE;
02600 SB_BLK_TYPE(sb_idx) = Static_Named;
02601 SB_RUNTIME_INIT(sb_idx) = FALSE;
02602 SCP_SB_HOSTED_DATA_IDX(curr_scp_idx) = sb_idx;
02603
02604 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
02605 SB_NAME_LEN(sb_idx),
02606 curr_scp_idx,
02607 &length);
02608 SB_NAME_LEN(sb_idx) = length;
02609 }
02610
02611 if (sb_idx != SCP_SB_STATIC_UNINIT_IDX(curr_scp_idx)) {
02612 sb_idx = SCP_SB_STATIC_UNINIT_IDX(curr_scp_idx);
02613 SB_HOSTED_STATIC(sb_idx) = TRUE;
02614 SB_BLK_TYPE(sb_idx) = Static_Named;
02615 SB_RUNTIME_INIT(sb_idx) = FALSE;
02616 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
02617 SB_NAME_LEN(sb_idx),
02618 curr_scp_idx,
02619 &length);
02620 SB_NAME_LEN(sb_idx) = length;
02621 }
02622 }
02623 else {
02624 ATP_EXT_NAME_IDX(attr_idx) = make_in_parent_string(AT_NAME_IDX(attr_idx),
02625 AT_NAME_LEN(attr_idx),
02626 SCP_PARENT_IDX(curr_scp_idx),
02627 &length);
02628 ATP_EXT_NAME_LEN(attr_idx) = length;
02629
02630 if (cmd_line_flags.debug_lvl <= Debug_Lvl_1) {
02631 gen_end_prologue_debug_label(attr_idx);
02632 }
02633
02634
02635
02636 sb_idx = SCP_SB_STATIC_IDX(curr_scp_idx);
02637 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
02638 SB_NAME_LEN(sb_idx),
02639 curr_scp_idx,
02640 &length);
02641 SB_NAME_LEN(sb_idx) = length;
02642
02643 if (sb_idx != SCP_SB_STATIC_INIT_IDX(curr_scp_idx)) {
02644 sb_idx = SCP_SB_STATIC_INIT_IDX(curr_scp_idx);
02645 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
02646 SB_NAME_LEN(sb_idx),
02647 curr_scp_idx,
02648 &length);
02649 SB_NAME_LEN(sb_idx) = length;
02650 }
02651
02652 if (sb_idx != SCP_SB_STATIC_UNINIT_IDX(curr_scp_idx)) {
02653 sb_idx = SCP_SB_STATIC_UNINIT_IDX(curr_scp_idx);
02654 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
02655 SB_NAME_LEN(sb_idx),
02656 curr_scp_idx,
02657 &length);
02658 SB_NAME_LEN(sb_idx) = length;
02659 }
02660
02661 ATP_MAY_INLINE(attr_idx) =
02662 ATP_MAY_INLINE(SCP_ATTR_IDX(SCP_PARENT_IDX(curr_scp_idx)));
02663 }
02664
02665
02666
02667
02668 if (cif_flags & BASIC_RECS) {
02669 cif_begin_scope_rec();
02670 }
02671
02672 if (CURR_BLK == Interface_Body_Blk) {
02673
02674
02675 cdir_switches.implicit_use_idx = cmd_line_flags.implicit_use_idx;
02676 }
02677
02678 implicit_use_semantics();
02679
02680 TRACE (Func_Exit, "start_new_subpgm", NULL);
02681
02682 return(attr_idx);
02683
02684 }
02685
02686
02687
02688
02689
02690
02691
02692
02693
02694
02695
02696
02697
02698
02699
02700
02701 static void gen_end_prologue_debug_label(int attr_idx)
02702
02703 {
02704 int ir_idx;
02705 int lbl_attr_idx;
02706
02707
02708 TRACE (Func_Entry, "gen_end_prologue_debug_label", NULL);
02709
02710
02711
02712
02713 NTR_ATTR_TBL(lbl_attr_idx);
02714 COPY_COMMON_ATTR_INFO(attr_idx, lbl_attr_idx, Label);
02715 AT_DEFINED(lbl_attr_idx) = TRUE;
02716 ATL_CLASS(lbl_attr_idx) = Lbl_Debug;
02717 ATL_DEBUG_CLASS(lbl_attr_idx) = Ldbg_End_Prologue;
02718
02719 if (ATP_EXT_NAME_IDX(attr_idx) != NULL_IDX) {
02720 AT_NAME_LEN(lbl_attr_idx) = ATP_EXT_NAME_LEN(attr_idx);
02721 AT_NAME_IDX(lbl_attr_idx) = ATP_EXT_NAME_IDX(attr_idx);
02722 }
02723
02724 ADD_ATTR_TO_LOCAL_LIST(lbl_attr_idx);
02725
02726 gen_sh(After,
02727 Continue_Stmt,
02728 SH_GLB_LINE(curr_stmt_sh_idx),
02729 SH_COL_NUM(curr_stmt_sh_idx),
02730 FALSE,
02731 TRUE,
02732 TRUE);
02733
02734 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
02735
02736 NTR_IR_TBL(ir_idx);
02737 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
02738 IR_OPR(ir_idx) = Label_Opr;
02739 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
02740 IR_LINE_NUM(ir_idx) = SH_GLB_LINE(curr_stmt_sh_idx);
02741 IR_COL_NUM(ir_idx) = SH_COL_NUM(curr_stmt_sh_idx);
02742 IR_LINE_NUM_L(ir_idx) = SH_GLB_LINE(curr_stmt_sh_idx);
02743 IR_COL_NUM_L(ir_idx) = SH_COL_NUM(curr_stmt_sh_idx);
02744 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
02745 IR_IDX_L(ir_idx) = lbl_attr_idx;
02746 ATL_DEF_STMT_IDX(lbl_attr_idx) = curr_stmt_sh_idx;
02747
02748 TRACE (Func_Exit, "gen_end_prologue_debug_label", NULL);
02749
02750 return;
02751
02752 }
02753
02754
02755
02756
02757
02758
02759
02760
02761
02762
02763
02764
02765
02766
02767
02768
02769
02770
02771
02772
02773
02774
02775
02776 #ifdef KEY
02777 int start_new_prog_unit_by_token(pgm_unit_type, blk_cntxt_type, boolean,
02778 boolean, int *, token_type *);
02779 #endif
02780
02781 int start_new_prog_unit(pgm_unit_type pgm_type,
02782 blk_cntxt_type blk_type,
02783 boolean no_name_entry,
02784 boolean parse_error,
02785 int *defer_msg)
02786 #ifdef KEY
02787 {
02788 return start_new_prog_unit_by_token(pgm_type, blk_type, no_name_entry,
02789 parse_error, defer_msg, &token);
02790 }
02791
02792
02793
02794 int start_new_prog_unit_by_token(pgm_unit_type pgm_type,
02795 blk_cntxt_type blk_type, boolean no_name_entry, boolean parse_error,
02796 int *defer_msg, token_type *token)
02797 #endif
02798 {
02799 int attr_idx;
02800 static int num_main_program = 0;
02801 static int num_no_name_entry = 0;
02802 boolean has_task_dirs = FALSE;
02803 int ir_idx;
02804 int length;
02805 int message;
02806 int name_idx;
02807 int save_sh_idx;
02808 int sb_idx;
02809
02810
02811 TRACE (Func_Entry, "start_new_prog_unit", NULL);
02812
02813 if (!no_name_entry) {
02814
02815 if (curr_stmt_category != Init_Stmt_Cat) {
02816 iss_blk_stk_err();
02817 SCP_IN_ERR(curr_scp_idx) = TRUE;
02818
02819
02820
02821 }
02822
02823 curr_stmt_category = Dir_Integer_Stmt_Cat;
02824 }
02825
02826 #ifdef KEY
02827 attr_idx = srch_sym_tbl(TOKEN_STR(*token), TOKEN_LEN(*token), &name_idx);
02828 #else
02829 attr_idx = srch_sym_tbl(TOKEN_STR(token), TOKEN_LEN(token), &name_idx);
02830 #endif
02831
02832 if (attr_idx == NULL_IDX) {
02833 #ifdef KEY
02834 attr_idx = ntr_sym_tbl(token, name_idx);
02835 #else
02836 attr_idx = ntr_sym_tbl(&token, name_idx);
02837 #endif
02838 AT_DCL_ERR(attr_idx) = parse_error;
02839 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02840 message = 0;
02841
02842 if (no_name_entry) {
02843
02844
02845
02846
02847
02848
02849
02850 has_task_dirs = ATP_HAS_TASK_DIRS(glb_tbl_idx[Main_Attr_Idx]);
02851 attr_idx = glb_tbl_idx[Main_Attr_Idx];
02852 #ifdef KEY
02853 AT_DEF_LINE(attr_idx) = TOKEN_LINE(*token);
02854 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(*token);
02855 AT_NAME_LEN(attr_idx) = TOKEN_LEN(*token);
02856 #else
02857 AT_DEF_LINE(attr_idx) = TOKEN_LINE(token);
02858 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(token);
02859 AT_NAME_LEN(attr_idx) = TOKEN_LEN(token);
02860 #endif
02861 AT_NAME_IDX(attr_idx) = LN_NAME_IDX(name_idx);
02862 AT_DEFINED(attr_idx) = TRUE;
02863 LN_ATTR_IDX(name_idx) = attr_idx;
02864 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02865 attr_tbl_idx--;
02866 attr_aux_tbl_idx--;
02867
02868 if (++num_no_name_entry == 2) {
02869 message = 1003;
02870 }
02871 else if (++num_main_program == 2) {
02872 message = 1009;
02873 }
02874 }
02875 else if (pgm_type == Program && ++num_main_program == 2) {
02876 message = 1009;
02877 }
02878
02879 if (message != 0 && !parse_error) {
02880
02881 if (*defer_msg > 0) {
02882 *defer_msg = message;
02883 }
02884 else if (!parse_error) {
02885
02886 #ifdef KEY
02887 PRINTMSG(TOKEN_LINE(*token), message,
02888 # if defined(_ERROR_DUPLICATE_GLOBALS)
02889 Error,
02890 # else
02891 Warning,
02892 # endif
02893 TOKEN_COLUMN(*token));
02894 #else
02895 PRINTMSG(TOKEN_LINE(token), message,
02896 # if defined(_ERROR_DUPLICATE_GLOBALS)
02897 Error,
02898 # else
02899 Warning,
02900 # endif
02901 TOKEN_COLUMN(token));
02902 #endif
02903 }
02904 }
02905 }
02906 else if (pgm_type == Function) {
02907 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02908
02909
02910
02911 #ifdef KEY
02912 PRINTMSG(TOKEN_LINE(*token), 666, Error, TOKEN_COLUMN(*token),
02913 AT_OBJ_NAME_PTR(attr_idx));
02914 CREATE_ERR_ATTR(attr_idx, TOKEN_LINE(*token),
02915 TOKEN_COLUMN(*token), Pgm_Unit);
02916 #else
02917 PRINTMSG(TOKEN_LINE(token), 666, Error, TOKEN_COLUMN(token),
02918 AT_OBJ_NAME_PTR(attr_idx));
02919 CREATE_ERR_ATTR(attr_idx, TOKEN_LINE(token),
02920 TOKEN_COLUMN(token), Pgm_Unit);
02921 #endif
02922 SCP_IN_ERR(curr_scp_idx) = TRUE;
02923 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02924 }
02925 else {
02926 SCP_ATTR_IDX(curr_scp_idx) = attr_idx;
02927
02928 if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
02929 ATD_CLASS(attr_idx) == Variable &&
02930 ATD_SYMBOLIC_CONSTANT(attr_idx)) {
02931 }
02932 else {
02933 #ifdef KEY
02934 PRINTMSG(TOKEN_LINE(*token), 180, Internal, TOKEN_COLUMN(*token),
02935 TOKEN_STR(*token), "attr_tbl");
02936 #else
02937 PRINTMSG(TOKEN_LINE(token), 180, Internal, TOKEN_COLUMN(token),
02938 TOKEN_STR(token), "attr_tbl");
02939 #endif
02940 }
02941 }
02942
02943 LN_DEF_LOC(name_idx) = TRUE;
02944 AT_OBJ_CLASS(attr_idx) = Pgm_Unit;
02945 ATP_PGM_UNIT(attr_idx) = pgm_type;
02946 ATP_HAS_TASK_DIRS(attr_idx) = has_task_dirs;
02947
02948 #ifdef KEY
02949
02950
02951 if (on_off_flags.intrinsic_module_gen &&
02952 Pgm_Unit == AT_OBJ_CLASS(attr_idx) && Module == ATP_PGM_UNIT(attr_idx)) {
02953 AT_IS_INTRIN(attr_idx) = TRUE;
02954 }
02955 #endif
02956
02957 MAKE_EXTERNAL_NAME(attr_idx, AT_NAME_IDX(attr_idx), AT_NAME_LEN(attr_idx));
02958
02959 ATP_SCP_ALIVE(attr_idx) = TRUE;
02960 ATP_EXPL_ITRFC(attr_idx) = TRUE;
02961 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
02962
02963 if (cif_flags && pgm_type == Program) {
02964 AT_CIF_SYMBOL_ID(attr_idx) = 2;
02965 }
02966
02967 ATP_MAY_INLINE(attr_idx) = opt_flags.modinline ||
02968 (pgm_type != Module && dump_flags.preinline);
02969 if (pgm_type <= Program) {
02970 NTR_IR_TBL(ir_idx);
02971 IR_OPR(ir_idx) = Entry_Opr;
02972 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
02973 #ifdef KEY
02974 IR_LINE_NUM(ir_idx) = TOKEN_LINE(*token);
02975 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(*token);
02976 #else
02977 IR_LINE_NUM(ir_idx) = TOKEN_LINE(token);
02978 IR_COL_NUM(ir_idx) = TOKEN_COLUMN(token);
02979 #endif
02980 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
02981 IR_IDX_L(ir_idx) = attr_idx;
02982 #ifdef KEY
02983 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(*token);
02984 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(*token);
02985 #else
02986 IR_COL_NUM_L(ir_idx) = TOKEN_COLUMN(token);
02987 IR_LINE_NUM_L(ir_idx) = TOKEN_LINE(token);
02988 #endif
02989
02990 if (no_name_entry ) {
02991
02992
02993
02994
02995
02996
02997
02998
02999
03000 save_sh_idx = curr_stmt_sh_idx;
03001 curr_stmt_sh_idx = SCP_FIRST_SH_IDX(curr_scp_idx);
03002
03003 gen_sh(Before,
03004 Program_Stmt,
03005 stmt_start_line,
03006 stmt_start_col,
03007 FALSE,
03008 FALSE,
03009 TRUE);
03010
03011 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
03012 curr_stmt_sh_idx = SCP_FIRST_SH_IDX(curr_scp_idx);
03013
03014 if (cmd_line_flags.debug_lvl <= Debug_Lvl_1) {
03015 gen_end_prologue_debug_label(attr_idx);
03016 }
03017
03018 curr_stmt_sh_idx = save_sh_idx;
03019 }
03020 else {
03021 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
03022
03023 if (cmd_line_flags.debug_lvl <= Debug_Lvl_1) {
03024 gen_end_prologue_debug_label(attr_idx);
03025 }
03026 }
03027 }
03028
03029
03030
03031 sb_idx = SCP_SB_STATIC_IDX(curr_scp_idx);
03032 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
03033 SB_NAME_LEN(sb_idx),
03034 curr_scp_idx,
03035 &length);
03036 SB_NAME_LEN(sb_idx) = length;
03037
03038 if (sb_idx != SCP_SB_STATIC_INIT_IDX(curr_scp_idx)) {
03039 sb_idx = SCP_SB_STATIC_INIT_IDX(curr_scp_idx);
03040 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
03041 SB_NAME_LEN(sb_idx),
03042 curr_scp_idx,
03043 &length);
03044 SB_NAME_LEN(sb_idx) = length;
03045 }
03046
03047 if (sb_idx != SCP_SB_STATIC_UNINIT_IDX(curr_scp_idx)) {
03048 sb_idx = SCP_SB_STATIC_UNINIT_IDX(curr_scp_idx);
03049 SB_NAME_IDX(sb_idx) = make_in_parent_string(SB_NAME_IDX(sb_idx),
03050 SB_NAME_LEN(sb_idx),
03051 curr_scp_idx,
03052 &length);
03053 SB_NAME_LEN(sb_idx) = length;
03054 }
03055
03056 CURR_BLK = blk_type;
03057 CURR_BLK_NAME = attr_idx;
03058 CURR_BLK_DEF_LINE = stmt_start_line;
03059 CURR_BLK_DEF_COLUMN = stmt_start_col;
03060
03061 if (cif_flags & XREF_RECS) {
03062 cif_usage_rec(attr_idx,
03063 AT_Tbl_Idx,
03064 #ifdef KEY
03065 TOKEN_LINE(*token),
03066 TOKEN_COLUMN(*token),
03067 #else
03068 TOKEN_LINE(token),
03069 TOKEN_COLUMN(token),
03070 #endif
03071 CIF_Symbol_Declaration);
03072 }
03073
03074 if (!no_name_entry) {
03075
03076
03077
03078
03079 implicit_use_semantics();
03080 }
03081
03082 TRACE (Func_Exit, "start_new_prog_unit", NULL);
03083
03084 return(attr_idx);
03085
03086 }
03087
03088
03089
03090
03091
03092
03093
03094
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110
03111
03112
03113
03114
03115
03116 void parse_typed_function_stmt()
03117
03118 {
03119 boolean assumed_size_ch = FALSE;
03120 int attr_idx;
03121 int defer_msg;
03122 boolean elemental_set;
03123 boolean err_fnd = FALSE;
03124 char err_str[45];
03125 int idx;
03126 int local_scp_idx = curr_scp_idx;
03127 boolean matched;
03128 int interface_idx;
03129 boolean pure_set;
03130 boolean recursive_set;
03131 int rslt_idx;
03132 int stmt_number;
03133 boolean type_err;
03134 #ifdef KEY
03135 token_type saved_id;
03136 boolean use_saved_id = FALSE;
03137 #endif
03138
03139 TRACE (Func_Entry, "parse_typed_function_stmt", NULL);
03140
03141 stmt_type = Function_Stmt;
03142 SH_STMT_TYPE(curr_stmt_sh_idx) = Function_Stmt;
03143 stmt_number = statement_number;
03144
03145 if (curr_stmt_category == Sub_Func_Stmt_Cat) {
03146
03147
03148
03149
03150
03151 if (CURR_BLK == Interface_Blk) {
03152 interface_idx = CURR_BLK_NAME;
03153
03154 if (interface_idx == NULL_IDX) {
03155 interface_idx = BLK_UNNAMED_INTERFACE(blk_stk_idx);
03156 }
03157
03158 ATI_HAS_NON_MOD_PROC(interface_idx) = TRUE;
03159
03160
03161
03162
03163 if (BLK_AT_IDX(blk_stk_idx) == NULL_IDX) {
03164 BLK_AT_IDX(blk_stk_idx) = attr_tbl_idx;
03165 BLK_BD_IDX(blk_stk_idx) = bounds_tbl_idx;
03166 BLK_CN_IDX(blk_stk_idx) = const_tbl_idx;
03167 BLK_CP_IDX(blk_stk_idx) = const_pool_idx;
03168 BLK_NP_IDX(blk_stk_idx) = name_pool_idx;
03169 BLK_SB_IDX(blk_stk_idx) = stor_blk_tbl_idx;
03170 BLK_SN_IDX(blk_stk_idx) = sec_name_tbl_idx;
03171 BLK_TYP_IDX(blk_stk_idx) = type_tbl_idx;
03172 }
03173 }
03174
03175
03176
03177
03178
03179 start_new_scp();
03180 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
03181 }
03182
03183 if (AT_OBJ_CLASS(AT_WORK_IDX) == Pgm_Unit) {
03184
03185
03186
03187
03188
03189 err_fnd = AT_DCL_ERR(AT_WORK_IDX);
03190 recursive_set = ATP_RECURSIVE(AT_WORK_IDX);
03191 elemental_set = ATP_ELEMENTAL(AT_WORK_IDX);
03192 pure_set = ATP_PURE(AT_WORK_IDX);
03193 }
03194 else {
03195 recursive_set = FALSE;
03196 elemental_set = FALSE;
03197 pure_set = FALSE;
03198 }
03199
03200 if (AT_TYPED(AT_WORK_IDX)) {
03201 type_err = AT_DCL_ERR(AT_WORK_IDX);
03202 }
03203 else {
03204
03205
03206
03207
03208
03209
03210 if (curr_stmt_category == Sub_Func_Stmt_Cat) {
03211
03212
03213
03214
03215
03216
03217
03218 curr_scp_idx =SCP_LAST_CHILD_IDX(curr_scp_idx);
03219 SCP_ATTR_IDX(curr_scp_idx) =SCP_ATTR_IDX(SCP_PARENT_IDX(curr_scp_idx));
03220 }
03221
03222 type_err = !parse_type_spec(TRUE);
03223 err_fnd = type_err;
03224
03225 if (curr_stmt_category == Sub_Func_Stmt_Cat) {
03226
03227
03228
03229 local_scp_idx = curr_scp_idx;
03230 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
03231 }
03232 }
03233
03234 while (matched = MATCHED_TOKEN_CLASS(Tok_Class_Keyword)) {
03235
03236 switch (TOKEN_VALUE(token)) {
03237 case Tok_Kwd_Recursive:
03238
03239 if (elemental_set) {
03240
03241
03242
03243 PRINTMSG(TOKEN_LINE(token), 1261, Error, TOKEN_COLUMN(token));
03244 err_fnd = TRUE;
03245 }
03246 else if (recursive_set) {
03247 PRINTMSG(TOKEN_LINE(token), 1260, Error, TOKEN_COLUMN(token),
03248 "RECURSIVE");
03249 err_fnd = TRUE;
03250 }
03251 else {
03252 recursive_set = TRUE;
03253 }
03254 continue;
03255
03256 case Tok_Kwd_Elemental:
03257
03258 if (recursive_set) {
03259
03260
03261
03262 PRINTMSG(TOKEN_LINE(token), 1261, Error, TOKEN_COLUMN(token));
03263 err_fnd = TRUE;
03264 }
03265 else if (elemental_set) {
03266 PRINTMSG(TOKEN_LINE(token), 1260, Error, TOKEN_COLUMN(token),
03267 "ELEMENTAL");
03268 err_fnd = TRUE;
03269 }
03270 else {
03271 elemental_set = TRUE;
03272 }
03273 continue;
03274
03275 case Tok_Kwd_Pure:
03276
03277 if (pure_set) {
03278 PRINTMSG(TOKEN_LINE(token), 1260, Error, TOKEN_COLUMN(token),
03279 "PURE");
03280 err_fnd = TRUE;
03281 }
03282 pure_set = TRUE;
03283 continue;
03284
03285 case Tok_Kwd_Function:
03286
03287 if (!MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
03288 parse_err_flush(Find_Lparen, "function-name");
03289 token = main_token;
03290 TOKEN_LINE(token) = stmt_start_line;
03291 TOKEN_COLUMN(token) = stmt_start_col;
03292 err_fnd = TRUE;
03293 }
03294 #ifdef KEY
03295
03296
03297 else if (STAR == LA_CH_VALUE) {
03298 saved_id = token;
03299 use_saved_id = TRUE;
03300 int type_idx = ATD_TYPE_IDX(AT_WORK_IDX);
03301 if (Character != TYP_TYPE(type_idx) &&
03302 !on_off_flags.issue_ansi_messages) {
03303 NEXT_LA_CH;
03304 ATD_TYPE_IDX(AT_WORK_IDX) = parse_non_char_kind_selector(FALSE);
03305 }
03306 else {
03307 parse_length_selector(AT_WORK_IDX, FALSE, TRUE);
03308 TYP_DESC(TYP_WORK_IDX) = TYP_DESC(type_idx);
03309 TYP_DCL_VALUE(TYP_WORK_IDX) = TYP_DCL_VALUE(type_idx);
03310 ATD_TYPE_IDX(AT_WORK_IDX) = ntr_type_tbl();
03311 }
03312 }
03313 #endif
03314 break;
03315
03316 default:
03317 matched = FALSE;
03318 reset_lex(TOKEN_BUF_IDX(token), TOKEN_STMT_NUM(token));
03319 break;
03320 }
03321 break;
03322 }
03323
03324 if (!matched) {
03325 err_str[0] = '\0';
03326
03327 if (!recursive_set) {
03328 strcat(err_str, "[RECURSIVE] ");
03329 }
03330 if (!elemental_set) {
03331 strcat(err_str, "[ELEMENTAL] ");
03332 }
03333 if (!pure_set) {
03334 strcat(err_str, "[PURE] ");
03335 }
03336
03337 strcat(err_str, "FUNCTION");
03338
03339 parse_err_flush(Find_EOS, err_str);
03340 token = main_token;
03341 TOKEN_LINE(token) = stmt_start_line;
03342 TOKEN_COLUMN(token) = stmt_start_col;
03343 err_fnd = TRUE;
03344 }
03345
03346 if (TYP_TYPE(ATD_TYPE_IDX(AT_WORK_IDX)) == Character) {
03347
03348 if (TYP_CHAR_CLASS(ATD_TYPE_IDX(AT_WORK_IDX)) == Assumed_Size_Char) {
03349 assumed_size_ch = TRUE;
03350 }
03351 else if (TYP_CHAR_CLASS(ATD_TYPE_IDX(AT_WORK_IDX)) == Var_Len_Char ||
03352 TYP_CHAR_CLASS(ATD_TYPE_IDX(AT_WORK_IDX)) == Unknown_Char) {
03353
03354
03355
03356
03357 for (idx = SCP_LN_FW_IDX(local_scp_idx);
03358 idx < SCP_LN_LW_IDX(local_scp_idx); idx++) {
03359 AT_REFERENCED(LN_ATTR_IDX(idx)) = Char_Rslt_Bound_Ref;
03360 }
03361 }
03362 }
03363
03364 if (curr_stmt_category != Sub_Func_Stmt_Cat) {
03365 defer_msg = 0;
03366 #ifdef KEY
03367 attr_idx= start_new_prog_unit_by_token(Function, Function_Blk, FALSE,
03368 err_fnd, &defer_msg, (use_saved_id ? (&saved_id) : (&token)));
03369 #else
03370 attr_idx = start_new_prog_unit(Function,
03371 Function_Blk,
03372 FALSE,
03373 err_fnd,
03374 &defer_msg);
03375 #endif
03376 ATP_PROC(attr_idx) = Extern_Proc;
03377 }
03378 else {
03379 attr_idx = start_new_subpgm(Function, err_fnd, FALSE);
03380 }
03381
03382 if (assumed_size_ch) {
03383 PRINTMSG(AT_DEF_LINE(attr_idx), 1565,
03384 #ifdef KEY
03385 Ansi,
03386 #else
03387 Comment,
03388 #endif
03389 AT_DEF_COLUMN(attr_idx));
03390
03391 if (ATP_PROC(attr_idx) == Intern_Proc ||
03392 ATP_PROC(attr_idx) == Module_Proc) {
03393
03394
03395
03396
03397 PRINTMSG(AT_DEF_LINE(attr_idx), 367, Error,
03398 AT_DEF_COLUMN(attr_idx),
03399 AT_OBJ_NAME_PTR(attr_idx));
03400 AT_DCL_ERR(attr_idx) = TRUE;
03401 ATD_TYPE_IDX(AT_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
03402 }
03403 else if (CURR_BLK == Interface_Body_Blk) {
03404
03405
03406
03407
03408 PRINTMSG(AT_DEF_LINE(attr_idx), 1566, Warning,
03409 AT_DEF_COLUMN(attr_idx),
03410 AT_OBJ_NAME_PTR(attr_idx));
03411 }
03412 else if (recursive_set) {
03413
03414 PRINTMSG(AT_DEF_LINE(attr_idx), 506, Error,
03415 AT_DEF_COLUMN(attr_idx),
03416 AT_OBJ_NAME_PTR(attr_idx));
03417 AT_DCL_ERR(attr_idx) = TRUE;
03418 ATD_TYPE_IDX(AT_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
03419 }
03420 }
03421
03422 if ((cif_flags & MISC_RECS) && ! err_fnd) {
03423 cif_stmt_type_rec(TRUE, CIF_Function_Stmt, stmt_number);
03424 }
03425
03426 SCP_IN_ERR(curr_scp_idx) = AT_DCL_ERR(attr_idx);
03427 SCP_IN_ERR(SCP_PARENT_IDX(curr_scp_idx)) = AT_DCL_ERR(attr_idx);
03428 CURR_BLK_ERR = AT_DCL_ERR(attr_idx);
03429 ATP_RECURSIVE(attr_idx) = recursive_set;
03430 ATP_ELEMENTAL(attr_idx) = elemental_set;
03431 ATP_PURE(attr_idx) = pure_set;
03432
03433 if (CURR_BLK != Interface_Body_Blk &&
03434 (cmd_line_flags.runtime_argument ||
03435 cmd_line_flags.runtime_arg_entry)) {
03436
03437 ATP_ARGCHCK_ENTRY(attr_idx) = TRUE;
03438 }
03439
03440
03441
03442 if (LA_CH_VALUE == LPAREN || (!err_fnd &&
03443 parse_err_flush(Find_Lparen, "(") )) {
03444 parse_dummy_args(attr_idx);
03445 }
03446
03447 set_function_rslt(attr_idx, type_err);
03448
03449 rslt_idx = ATP_RSLT_IDX(attr_idx);
03450 AT_TYPED(rslt_idx) = TRUE;
03451 ATD_TYPE_IDX(rslt_idx) = ATD_TYPE_IDX(AT_WORK_IDX);
03452
03453 #ifdef KEY
03454
03455 if (AT_OBJ_CLASS(rslt_idx) == Data_Obj && !AT_IS_INTRIN(rslt_idx) &&
03456 TYP_LINEAR(ATD_TYPE_IDX(rslt_idx)) == Real_4 &&
03457 Check_FF2C_Script(AT_OBJ_NAME_PTR(rslt_idx), 0) )
03458 {
03459 ATD_TYPE_IDX(rslt_idx) = Real_8;
03460 }
03461 #endif
03462 if (LA_CH_VALUE != EOS) {
03463 parse_err_flush(Find_EOS, EOS_STR);
03464 }
03465
03466 NEXT_LA_CH;
03467
03468 TRACE (Func_Exit, "parse_typed_function_stmt", NULL);
03469
03470 return;
03471
03472 }
03473
03474
03475
03476
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490
03491
03492
03493
03494
03495
03496
03497
03498
03499 static void start_new_scp(void)
03500
03501 {
03502 int first_sh_idx;
03503 int idx;
03504 int name_idx;
03505 int npes_attr;
03506 token_type npes_token;
03507 int parent_idx;
03508 int parent_name_idx;
03509 int save_scp;
03510
03511
03512 TRACE (Func_Entry, "start_new_scp", NULL);
03513
03514 parent_idx = curr_scp_idx;
03515 NTR_SCP_TBL(curr_scp_idx);
03516
03517
03518
03519 if (SCP_FIRST_CHILD_IDX(parent_idx) == NULL_IDX) {
03520 SCP_FIRST_CHILD_IDX(parent_idx) = curr_scp_idx;
03521 }
03522 else {
03523 SCP_SIBLING_IDX(SCP_LAST_CHILD_IDX(parent_idx)) = curr_scp_idx;
03524 }
03525
03526 SCP_LAST_CHILD_IDX(parent_idx) = curr_scp_idx;
03527 SCP_NUM_CHILDREN(parent_idx) = SCP_NUM_CHILDREN(parent_idx) + 1;
03528 SCP_PARENT_IDX(curr_scp_idx) = parent_idx;
03529 SCP_LEVEL(curr_scp_idx) = SCP_LEVEL(parent_idx) + 1;
03530 SCP_IMPL_NONE(curr_scp_idx) = FALSE;
03531
03532
03533
03534
03535
03536
03537 first_sh_idx = SH_LABELED(curr_stmt_sh_idx) ? SH_PREV_IDX(curr_stmt_sh_idx) :
03538 curr_stmt_sh_idx;
03539
03540 SCP_FIRST_SH_IDX(curr_scp_idx) = first_sh_idx;
03541
03542
03543
03544
03545 SCP_LAST_SH_IDX(parent_idx) = SH_PREV_IDX(first_sh_idx);
03546 SH_PREV_IDX(first_sh_idx) = NULL_IDX;
03547 SH_NEXT_IDX(SH_PREV_IDX(first_sh_idx)) = NULL_IDX;
03548
03549
03550
03551 init_name_and_stor_tbls(curr_scp_idx, TRUE);
03552
03553 if (CURR_BLK == Interface_Blk) {
03554 SCP_PARENT_NONE(curr_scp_idx) = FALSE;
03555 SCP_IS_INTERFACE(curr_scp_idx) = TRUE;
03556
03557
03558
03559 for (idx = 0; idx < MAX_IMPL_CHS; idx++) {
03560 IM_TYPE_IDX(curr_scp_idx, idx) = REAL_DEFAULT_TYPE;
03561 IM_SET(curr_scp_idx, idx) = FALSE;
03562 }
03563
03564 for (idx = IMPL_IDX('I'); idx <= IMPL_IDX('N'); idx++) {
03565 IM_TYPE_IDX(curr_scp_idx, idx) = INTEGER_DEFAULT_TYPE;
03566 }
03567
03568
03569
03570
03571
03572
03573
03574
03575 SCP_SB_STACK_IDX(curr_scp_idx) = SCP_SB_STACK_IDX(parent_idx);
03576
03577 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
03578
03579
03580
03581 SB_SCP_IDX(SCP_SB_DARG_IDX(curr_scp_idx)) =
03582 SB_SCP_IDX(SCP_SB_DARG_IDX(parent_idx));
03583 # endif
03584
03585 }
03586 else {
03587 SCP_PARENT_NONE(curr_scp_idx) = SCP_IMPL_NONE(parent_idx) ||
03588 SCP_PARENT_NONE(parent_idx);
03589
03590 for (idx = 0; idx < MAX_IMPL_CHS; idx++) {
03591
03592 IM_TYPE_IDX(curr_scp_idx, idx) = IM_TYPE_IDX(parent_idx, idx);
03593 }
03594 }
03595
03596
03597
03598 CREATE_ID(TOKEN_ID(npes_token), "N$PES", 5);
03599
03600 TOKEN_COLUMN(npes_token) = 1;
03601 TOKEN_LEN(npes_token) = 5;
03602 TOKEN_LINE(npes_token) = stmt_start_line;
03603 npes_attr = srch_sym_tbl(TOKEN_STR(npes_token),
03604 TOKEN_LEN(npes_token),
03605 &name_idx);
03606 npes_attr = ntr_sym_tbl(&npes_token,name_idx);
03607 LN_DEF_LOC(name_idx) = TRUE;
03608 save_scp = curr_scp_idx;
03609 curr_scp_idx = parent_idx;
03610 npes_attr = srch_sym_tbl(TOKEN_STR(npes_token),
03611 TOKEN_LEN(npes_token),
03612 &parent_name_idx);
03613
03614
03615
03616 LN_ATTR_IDX(name_idx) = npes_attr;
03617 LN_NAME_IDX(name_idx) = AT_NAME_IDX(npes_attr);
03618 curr_scp_idx = save_scp;
03619
03620 TRACE (Func_Exit, "start_new_scp", NULL);
03621
03622 return;
03623
03624 }