Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
p_dcl_attr.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 
00037 static char USMID[] = "\n@(#)5.0_pl/sources/p_dcl_attr.c        5.2     06/17/99 09:28:10\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 
00057 
00058 /*****************************************************************\
00059 |* function prototypes of static functions declared in this file *|
00060 \*****************************************************************/
00061 static void parse_attrs(boolean (*func) (boolean, int, int, int));
00062 
00063 
00064 /******************************************************************************\
00065 |*                                                                            *|
00066 |* Description:                                                               *|
00067 |*      This is a generic parser, used by all the attribute statements,       *|
00068 |*      except for PUBLIC and PRIVATE.  It parses the statements, and         *|
00069 |*      calls the appropriate merge routine to update the symbol table.       *|
00070 |*                                                                            *|
00071 |* Input parameters:                                                          *|
00072 |*      merge_function - pointer to the merge function to call                *|
00073 |*                                                                            *|
00074 |* Output parameters:                                                         *|
00075 |*      NONE                                                                  *|
00076 |*                                                                            *|
00077 |* Returns:                                                                   *|
00078 |*      NONE                                                                  *|
00079 |*                                                                            *|
00080 \******************************************************************************/
00081 
00082 static void parse_attrs(boolean (*merge_function) ())
00083 
00084 {
00085    int          array_idx;
00086    int          attr_idx;
00087    boolean      blk_err         = FALSE;
00088    int          column;
00089    boolean      found_attr;
00090    boolean      found_end       = FALSE;
00091    int          line;
00092    int          name_idx;
00093    int          new_sb_idx;
00094    int          sb_idx;
00095 
00096 
00097    TRACE (Func_Entry, "parse_attrs", NULL);
00098 
00099    if (LA_CH_VALUE == COLON &&
00100        matched_specific_token(Tok_Punct_Colon_Colon, Tok_Class_Punct)) {
00101 
00102       /* Intentionally blank */
00103    }
00104 
00105    if ((STMT_OUT_OF_ORDER(curr_stmt_category, stmt_type) ||
00106         STMT_CANT_BE_IN_BLK(stmt_type, CURR_BLK)) && iss_blk_stk_err()) {
00107 
00108       /* block error issued by check. */
00109 
00110       blk_err = TRUE;
00111    }
00112    else {
00113       curr_stmt_category = Declaration_Stmt_Cat;
00114    }
00115 
00116    do {
00117       if (MATCHED_TOKEN_CLASS(Tok_Class_Id)) {  /* TOKEN is the id */
00118          line           = TOKEN_LINE(token);
00119          column         = TOKEN_COLUMN(token);
00120          attr_idx       = srch_sym_tbl(TOKEN_STR(token), TOKEN_LEN(token),
00121                                        &name_idx);
00122          found_attr     = TRUE;
00123 
00124          if (attr_idx == NULL_IDX) {
00125             found_attr                  = FALSE;
00126             attr_idx                    = ntr_sym_tbl(&token, name_idx);
00127             LN_DEF_LOC(name_idx)        = TRUE;      /* Can't be host assoc */
00128 
00129             /* The merge functions set the implicit type - if needed */
00130          }
00131          else if (AT_REFERENCED(attr_idx) == Char_Rslt_Bound_Ref) {
00132             AT_ATTR_LINK(attr_idx)      = NULL_IDX;
00133             LN_DEF_LOC(name_idx)        = TRUE;
00134          }
00135 
00136          if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
00137             ATD_SEEN_OUTSIDE_IMP_DO(attr_idx) = TRUE;
00138          }
00139 
00140          if (LA_CH_VALUE == LPAREN) {
00141 
00142             switch (stmt_type) {
00143       
00144                case Allocatable_Stmt:
00145                case Automatic_Stmt:
00146                case Dimension_Stmt:
00147                case Pointer_Stmt:
00148                case Target_Stmt:
00149                   array_idx = parse_array_spec(attr_idx);
00150 
00151                   merge_dimension(attr_idx, line, column, array_idx);
00152 
00153                   if (!found_attr) {
00154                      SET_IMPL_TYPE(attr_idx);
00155                   }
00156                   found_attr = TRUE;  /* Have to merge with dimension */
00157                   break;
00158 
00159                default:
00160                   if (parse_err_flush(Find_Rparen, ", or " EOS_STR)) {
00161                      NEXT_LA_CH;        /* Get Rparen */
00162                   }
00163                   break;
00164 
00165             }  /* End switch */
00166          }
00167          else if (stmt_type == Dimension_Stmt) {
00168 
00169            /* DIMENSION needs dim spec */
00170 
00171 # ifdef COARRAY_FORTRAN
00172 
00173             if ((!cmd_line_flags.co_array_fortran) || LA_CH_VALUE != LBRKT) {
00174                parse_err_flush(Find_Comma, "(");
00175                AT_DCL_ERR(attr_idx) = TRUE;
00176             }
00177 # else
00178             parse_err_flush(Find_Comma, "(");
00179             AT_DCL_ERR(attr_idx) = TRUE;
00180 # endif
00181          }
00182 
00183 # ifdef COARRAY_FORTRAN
00184 
00185          if (LA_CH_VALUE == LBRKT && cmd_line_flags.co_array_fortran &&
00186              (stmt_type == Allocatable_Stmt ||
00187               stmt_type == Automatic_Stmt ||
00188               stmt_type == Dimension_Stmt ||
00189               stmt_type == Pointer_Stmt ||
00190               stmt_type == Target_Stmt)) {
00191             array_idx   = parse_pe_array_spec(attr_idx);
00192             merge_co_array(found_attr, line, column, attr_idx, array_idx);
00193          }
00194 # endif
00195 
00196          if (stmt_type != Dimension_Stmt) {
00197             (*merge_function) (found_attr, line, column, attr_idx);
00198          }
00199 
00200          AT_DCL_ERR(attr_idx) = AT_DCL_ERR(attr_idx) | blk_err;
00201 
00202          if ((cif_flags & XREF_RECS) != 0) {
00203             cif_usage_rec(attr_idx,
00204                           AT_Tbl_Idx,
00205                           line,
00206                           column,
00207                           CIF_Symbol_Declaration);
00208          }
00209       }
00210       else if (LA_CH_VALUE == SLASH &&
00211                (stmt_type == Save_Stmt ||
00212                 stmt_type == Volatile_Stmt)) {
00213 
00214          NEXT_LA_CH;            /* Pick up slash */
00215 
00216          if (MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
00217             sb_idx   = srch_stor_blk_tbl(TOKEN_STR(token),
00218                                          TOKEN_LEN(token),
00219                                          curr_scp_idx);
00220 
00221             if (sb_idx == NULL_IDX) {
00222                sb_idx   = ntr_stor_blk_tbl(TOKEN_STR(token),
00223                                            TOKEN_LEN(token),
00224                                            TOKEN_LINE(token),
00225                                            TOKEN_COLUMN(token),
00226                                            Common);
00227                SB_COMMON_NEEDS_OFFSET(sb_idx)   = TRUE;
00228             }
00229             else if (SB_USE_ASSOCIATED(sb_idx) || SB_HOST_ASSOCIATED(sb_idx)) {
00230 
00231                /* Common block has been use or host associated into this scp. */
00232                /* Make an entry for this block and hide the associated block  */
00233                /* behind it.  storage_blk_resolution will resolve the blocks. */
00234 
00235                new_sb_idx = ntr_stor_blk_tbl(TOKEN_STR(token),
00236                                              TOKEN_LEN(token),
00237                                              TOKEN_LINE(token),
00238                                              TOKEN_COLUMN(token),
00239                                              Common);
00240                SB_MERGED_BLK_IDX(sb_idx)                = new_sb_idx;
00241                SB_COMMON_NEEDS_OFFSET(new_sb_idx)       = TRUE;
00242                SB_HIDDEN(sb_idx)                        = TRUE;
00243                SB_DEF_MULT_SCPS(sb_idx)                 = TRUE;
00244                sb_idx                                   = new_sb_idx;
00245             }
00246 
00247             SB_DCL_ERR(sb_idx)  = SB_DCL_ERR(sb_idx) | blk_err;
00248 
00249             if (stmt_type == Save_Stmt) {
00250 
00251                if (SB_SAVED(sb_idx)) {
00252 
00253                    /* Cannot set SAVE twice for same common block name */
00254 
00255                   PRINTMSG(TOKEN_LINE(token), 110, Error, TOKEN_COLUMN(token),
00256                            SB_NAME_PTR(sb_idx));
00257                }
00258 
00259                SB_SAVED(sb_idx)         = TRUE;
00260             }
00261             else {  /* Volatile_Stmt */
00262                SB_VOLATILE(sb_idx)      = TRUE;
00263             }
00264 
00265             if ((cif_flags & XREF_RECS) != 0) {
00266                cif_sb_usage_rec(sb_idx,
00267                                 TOKEN_LINE(token),
00268                                 TOKEN_COLUMN(token),
00269                                 CIF_Symbol_Declaration);
00270             }
00271 
00272             if (LA_CH_VALUE == SLASH) {
00273                NEXT_LA_CH;              /* Pick up slash */
00274             }
00275             else {
00276                parse_err_flush(Find_Comma, "/");
00277             }
00278          }
00279          else {
00280             parse_err_flush(Find_Comma, "common-block-name");
00281          }
00282       }
00283       else {    /* Looking for id or common block name */
00284          parse_err_flush(Find_Comma, ((stmt_type == Save_Stmt ||
00285                                        stmt_type == Volatile_Stmt) ?
00286                                       "object-name or /" : "object-name"));
00287       }
00288 
00289       if (LA_CH_VALUE != COMMA && LA_CH_VALUE != EOS) {
00290          parse_err_flush(Find_Comma, ", or " EOS_STR);
00291       }
00292 
00293       if (LA_CH_VALUE == COMMA) {
00294          NEXT_LA_CH;                            /* Pick up comma */
00295       }
00296       else if (LA_CH_VALUE == EOS) {
00297          found_end = TRUE;
00298          NEXT_LA_CH;                            /* Pick up EOS */
00299       }
00300    }  /* End while */
00301    while (!found_end);
00302 
00303    TRACE (Func_Exit, "parse_attrs", NULL);
00304 
00305    return;
00306 
00307 
00308 }  /* parse_attrs */
00309 
00310 
00311 /******************************************************************************\
00312 |*                                                                            *|
00313 |* Description:                                                               *|
00314 |*       Parse the PUBLIC and PRIVATE statements.                             *|
00315 |*       BNF  - PUBLIC  [[::] access-id-list]                                 *|
00316 |*              PRIVATE [[::] access-id-list]                                 *|
00317 |*              access-id IS use-name OR generic-spec                         *|
00318 |*                                                                            *|
00319 |* Input parameters:                                                          *|
00320 |*      NONE                                                                  *|
00321 |*                                                                            *|
00322 |* Output parameters:                                                         *|
00323 |*      NONE                                                                  *|
00324 |*                                                                            *|
00325 |* Returns:                                                                   *|
00326 |*      NONE                                                                  *|
00327 |*                                                                            *|
00328 \******************************************************************************/
00329 
00330 void parse_access_stmt()
00331 
00332 {
00333    access_type          access;
00334    int                  attr_idx;
00335    boolean              found_end;
00336 
00337 
00338    TRACE (Func_Entry, "parse_access_stmt", NULL);
00339 
00340    access = (TOKEN_VALUE(token) == Tok_Kwd_Private) ? Private : Public;
00341 
00342    if (CURR_BLK == Derived_Type_Blk && access == Private) {
00343 
00344       if (LA_CH_VALUE == EOS) {
00345 
00346          if (ATT_PRIVATE_CPNT(CURR_BLK_NAME)) {
00347 
00348             /* The PRIVATE statement may only be specified once in a dt def */
00349 
00350             PRINTMSG(TOKEN_LINE(token), 41, Error, TOKEN_COLUMN(token),
00351                      "PRIVATE", AT_OBJ_NAME_PTR(CURR_BLK_NAME));
00352          }
00353          else if (ATT_FIRST_CPNT_IDX(CURR_BLK_NAME) != NULL_IDX) {
00354 
00355             /* PRIVATE must be specified before any components are */
00356 
00357             PRINTMSG(TOKEN_LINE(token), 8, Error, TOKEN_COLUMN(token),
00358                      "PRIVATE", AT_OBJ_NAME_PTR(CURR_BLK_NAME));
00359          }
00360 
00361          if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module) {
00362             ATT_PRIVATE_CPNT(CURR_BLK_NAME) = TRUE;
00363          } 
00364          else {
00365             iss_blk_stk_err();
00366          }
00367       }
00368       else {
00369          parse_err_flush(Find_EOS, EOS_STR);
00370       }
00371       curr_stmt_category = Declaration_Stmt_Cat;
00372    }
00373    else {
00374 
00375       if (LA_CH_VALUE == EOS) {
00376 
00377          if (CURR_BLK == Module_Blk) {
00378 
00379             if (AT_ACCESS_SET(SCP_ATTR_IDX(curr_scp_idx))) {
00380 
00381                /* Issue error.  Don't allow access to change. */
00382 
00383                PRINTMSG(TOKEN_LINE(token), 656, Error, TOKEN_COLUMN(token),
00384                         AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)));
00385                access = (access_type) AT_PRIVATE(SCP_ATTR_IDX(curr_scp_idx));
00386             }
00387 
00388             AT_ACCESS_SET(SCP_ATTR_IDX(curr_scp_idx))   = TRUE;
00389             AT_PRIVATE(SCP_ATTR_IDX(curr_scp_idx))      = access;
00390          }
00391          else {
00392             /* Intentionally blank.  If this is not a MODULE, it will be  */
00393             /* caught at the end of the routine in block checking.        */
00394          }
00395       }
00396       else {
00397          found_end      = FALSE;
00398 
00399          if (LA_CH_VALUE == COLON) {                   /* Pick up optional :: */
00400             matched_specific_token(Tok_Punct_Colon_Colon, Tok_Class_Punct);
00401          }
00402 
00403          do {   /* parse_generic_spec issues CIF records */
00404             if (parse_generic_spec()) {
00405                attr_idx = generic_spec_semantics();
00406 
00407                if (CURR_BLK == Module_Blk) {
00408                   merge_access(attr_idx, TOKEN_LINE(token),
00409                                          TOKEN_COLUMN(token), access);
00410                }
00411             }
00412 
00413             if (LA_CH_VALUE != COMMA && LA_CH_VALUE != EOS) {
00414                parse_err_flush(Find_Comma, ", or " EOS_STR);
00415             }
00416 
00417             if (LA_CH_VALUE == COMMA) {
00418                NEXT_LA_CH;                      /* Skip Comma */
00419             }
00420             else if (LA_CH_VALUE == EOS) {
00421                found_end = TRUE;
00422             }
00423          }  
00424          while (!found_end);
00425       }
00426 
00427       if ((CURR_BLK != Module_Blk ||
00428            STMT_OUT_OF_ORDER(curr_stmt_category, stmt_type)) &&
00429          iss_blk_stk_err()) {
00430          /* Block error - intentionally left blank */
00431       }
00432       else {
00433          curr_stmt_category = Declaration_Stmt_Cat;
00434       }
00435    }
00436    NEXT_LA_CH;                                  /* Always will be EOS */
00437 
00438    TRACE (Func_Exit, "parse_access_stmt", NULL);
00439    return;
00440 
00441 }  /* parse_access_stmt */
00442 
00443 
00444 /******************************************************************************\
00445 |*                                                                            *|
00446 |* Description:                                                               *|
00447 |*      BNF       - ALLOCATABLE [::] array-name [(deferred-shape-spec-list)]  *|
00448 |*                               [,array-name [(deferred-shape-spec-list)]..  *|
00449 |*                                                                            *|
00450 |* Input parameters:                                                          *|
00451 |*      NONE                                                                  *|
00452 |*                                                                            *|
00453 |* Output parameters:                                                         *|
00454 |*      NONE                                                                  *|
00455 |*                                                                            *|
00456 |* Returns:                                                                   *|
00457 |*      NONE                                                                  *|
00458 |*                                                                            *|
00459 \******************************************************************************/
00460 
00461 void parse_allocatable_stmt (void)
00462 
00463 {
00464    TRACE (Func_Entry, "parse_allocatable_stmt", NULL);
00465 
00466    parse_attrs(merge_allocatable);
00467 
00468    TRACE (Func_Exit, "parse_allocatable_stmt", NULL);
00469 
00470    return;
00471 
00472 }  /* parse_allocatable_stmt */
00473 
00474 /******************************************************************************\
00475 |*                                                                            *|
00476 |* Description:                                                               *|
00477 |*      BNF       - AUTOMATIC [::] object-name                                *|
00478 |*                                                                            *|
00479 |* Input parameters:                                                          *|
00480 |*      NONE                                                                  *|
00481 |*                                                                            *|
00482 |* Output parameters:                                                         *|
00483 |*      NONE                                                                  *|
00484 |*                                                                            *|
00485 |* Returns:                                                                   *|
00486 |*      NONE                                                                  *|
00487 |*                                                                            *|
00488 \******************************************************************************/
00489 
00490 void parse_automatic_stmt (void)
00491 
00492 {
00493    TRACE (Func_Entry, "parse_automatic_stmt", NULL);
00494 
00495    PRINTMSG(stmt_start_line, 1253, Ansi, stmt_start_col, "AUTOMATIC");
00496    
00497    parse_attrs(merge_automatic);
00498 
00499    TRACE (Func_Exit, "parse_automatic_stmt", NULL);
00500 
00501    return;
00502 
00503 }  /* parse_automatic_stmt */
00504 
00505 
00506 /******************************************************************************\
00507 |*                                                                            *|
00508 |* Description:                                                               *|
00509 |*      BNF       - DIMENSION [::] array-name (array-spec)                    *|
00510 |*                                 [,array-name (array_spec)]...              *|
00511 |*                                                                            *|
00512 |* Input parameters:                                                          *|
00513 |*      NONE                                                                  *|
00514 |*                                                                            *|
00515 |* Output parameters:                                                         *|
00516 |*      NONE                                                                  *|
00517 |*                                                                            *|
00518 |* Returns:                                                                   *|
00519 |*      NONE                                                                  *|
00520 |*                                                                            *|
00521 \******************************************************************************/
00522 
00523 void parse_dimension_stmt (void)
00524 
00525 {
00526    TRACE (Func_Entry, "parse_dimension_stmt", NULL);
00527 
00528    parse_attrs(NULL);
00529 
00530    TRACE (Func_Exit, "parse_dimension_stmt", NULL);
00531 
00532    return;
00533 
00534 }  /* parse_dimension_stmt */
00535 
00536 /******************************************************************************\
00537 |*                                                                            *|
00538 |* Description:                                                               *|
00539 |*      Parse the external statement                                          *|
00540 |*      BNF       - EXTERNAL external-name-list                               *|
00541 |*                                                                            *|
00542 |* Input parameters:                                                          *|
00543 |*      NONE                                                                  *|
00544 |*                                                                            *|
00545 |* Output parameters:                                                         *|
00546 |*      NONE                                                                  *|
00547 |*                                                                            *|
00548 |* Returns:                                                                   *|
00549 |*      NONE                                                                  *|
00550 |*                                                                            *|
00551 \******************************************************************************/
00552 
00553 void parse_external_stmt (void)
00554 
00555 {
00556    TRACE (Func_Entry, "parse_external_stmt", NULL);
00557 
00558    parse_attrs(merge_external);
00559 
00560    TRACE (Func_Exit, "parse_external_stmt", NULL);
00561 
00562    return;
00563 
00564 }  /* parse_external_stmt */
00565 
00566 /******************************************************************************\
00567 |*                                                                            *|
00568 |* Description:                                                               *|
00569 |*      BNF    - INTENT(intent_spec) [::] dummy-arg-name-list                 *|
00570 |*                                                                            *|
00571 |* Input parameters:                                                          *|
00572 |*      NONE                                                                  *|
00573 |*                                                                            *|
00574 |* Output parameters:                                                         *|
00575 |*      NONE                                                                  *|
00576 |*                                                                            *|
00577 |* Returns:                                                                   *|
00578 |*      NONE                                                                  *|
00579 |*                                                                            *|
00580 \******************************************************************************/
00581 
00582 void parse_intent_stmt (void)
00583 
00584 {
00585    int          stmt_number;
00586 
00587    TRACE (Func_Entry, "parse_intent_stmt", NULL);
00588 
00589    stmt_number = statement_number;
00590 
00591    if (LA_CH_VALUE != LPAREN) {
00592       parse_err_flush(Find_EOS, "(");
00593       NEXT_LA_CH;                               /* Pick up EOS */
00594    }
00595    else {
00596       colon_recovery    = TRUE;                 /* Can recover at :: */
00597       new_intent        = parse_intent_spec();
00598       colon_recovery    = FALSE;
00599 
00600       if (new_intent != Intent_Unseen) {
00601          parse_attrs(merge_intent);
00602 
00603          if (cif_flags & MISC_RECS) {
00604 
00605             if (new_intent == Intent_In) {
00606                cif_stmt_type_rec(TRUE, CIF_Intent_In_Stmt, stmt_number);
00607             }
00608             else if (new_intent == Intent_Out) {
00609                cif_stmt_type_rec(TRUE, CIF_Intent_Out_Stmt, stmt_number);
00610             }
00611             else {
00612                cif_stmt_type_rec(TRUE, CIF_Intent_Inout_Stmt, stmt_number);
00613             }
00614          }
00615       }
00616       else {
00617          parse_err_flush(Find_EOS, NULL);
00618          NEXT_LA_CH;                            /* Pick up EOS */
00619       }
00620    }
00621 
00622    TRACE (Func_Exit, "parse_intent_stmt", NULL);
00623 
00624    return;
00625 
00626 }  /* parse_intent_stmt */
00627 
00628 
00629 /******************************************************************************\
00630 |*                                                                            *|
00631 |* Description:                                                               *|
00632 |*      Parse the intrinsic statement                                         *|
00633 |*      BNF       - INTRINSIC intrinsic-name-list                             *|
00634 |*                                                                            *|
00635 |* Input parameters:                                                          *|
00636 |*      NONE                                                                  *|
00637 |*                                                                            *|
00638 |* Output parameters:                                                         *|
00639 |*      NONE                                                                  *|
00640 |*                                                                            *|
00641 |* Returns:                                                                   *|
00642 |*      NONE                                                                  *|
00643 |*                                                                            *|
00644 \******************************************************************************/
00645 
00646 void parse_intrinsic_stmt (void)
00647 
00648 {
00649    TRACE (Func_Entry, "parse_intrinsic_stmt", NULL);
00650    parse_attrs(merge_intrinsic);
00651    TRACE (Func_Exit, "parse_intrinsic_stmt", NULL);
00652 
00653    return;
00654 
00655 }  /* parse_intrinsic_stmt */
00656 
00657 /******************************************************************************\
00658 |*                                                                            *|
00659 |* Description:                                                               *|
00660 |*      Parse the optional statement                                          *|
00661 |*      BNF       - OPTIONAL [::] dummy-arg-name-list                         *|
00662 |*                                                                            *|
00663 |* Input parameters:                                                          *|
00664 |*      NONE                                                                  *|
00665 |*                                                                            *|
00666 |* Output parameters:                                                         *|
00667 |*      NONE                                                                  *|
00668 |*                                                                            *|
00669 |* Returns:                                                                   *|
00670 |*      NONE                                                                  *|
00671 |*                                                                            *|
00672 \******************************************************************************/
00673 
00674 void parse_optional_stmt(void)
00675 
00676 {
00677    TRACE (Func_Entry, "parse_optional_stmt", NULL);
00678 
00679    parse_attrs(merge_optional);
00680 
00681    TRACE (Func_Exit, "parse_optional_stmt", NULL);
00682 
00683    return;
00684 
00685 }  /* parse_optional_stmt */
00686 
00687 
00688 /******************************************************************************\
00689 |*                                                                            *|
00690 |* Description:                                                               *|
00691 |*      BNF       - POINTER   or  POINTER(CRI-pointer-name, CRI-pointee-name) *|
00692 |*                                                                            *|
00693 |* Input parameters:                                                          *|
00694 |*      NONE                                                                  *|
00695 |*                                                                            *|
00696 |* Output parameters:                                                         *|
00697 |*      NONE                                                                  *|
00698 |*                                                                            *|
00699 |* Returns:                                                                   *|
00700 |*      NONE                                                                  *|
00701 |*                                                                            *|
00702 \******************************************************************************/
00703 
00704 void parse_pointer_stmt (void)
00705 
00706 {
00707    int          array_idx;
00708    int          attr_idx;
00709    int          name_idx;
00710    boolean      parse_err;
00711    int          pointer_idx;
00712    token_type   pointee_name;
00713    token_type   pointer_name;
00714    boolean      semantic_err;
00715 
00716 # if defined(_NO_CRAY_CHARACTER_PTR)
00717    int          lparen_col;
00718    int          lparen_line;
00719 # endif
00720 
00721 
00722 
00723    TRACE (Func_Entry, "parse_pointer_stmt", NULL);
00724 
00725    if (LA_CH_VALUE != LPAREN) {         /* Fortran 90 POINTER */
00726       parse_attrs(merge_pointer);
00727       goto EXIT;
00728    }
00729 
00730    /*  CRI pointer statement */
00731 
00732    if ((STMT_OUT_OF_ORDER(curr_stmt_category, Pointer_Stmt) ||
00733         STMT_CANT_BE_IN_BLK(Pointer_Stmt, CURR_BLK)) && iss_blk_stk_err()) {
00734       /* Intentionally blank */
00735    }
00736    else {
00737       curr_stmt_category = Declaration_Stmt_Cat;
00738       PRINTMSG(stmt_start_line, 134, Ansi, stmt_start_col);
00739    }
00740 
00741    do {
00742       parse_err         = FALSE;
00743       semantic_err      = FALSE;
00744 
00745       if (LA_CH_VALUE == LPAREN) {
00746 
00747 # if defined(_NO_CRAY_CHARACTER_PTR)
00748          lparen_line = LA_CH_LINE;
00749          lparen_col  = LA_CH_COLUMN; 
00750 # endif
00751 
00752          NEXT_LA_CH;                            /* Skip LPAREN */
00753 
00754          if (MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
00755             pointer_name = token;
00756    
00757             if (LA_CH_VALUE == COMMA) {
00758                NEXT_LA_CH;                      /* Skip COMMA */
00759 
00760                if (MATCHED_TOKEN_CLASS(Tok_Class_Id)) {
00761                   pointee_name  = token;
00762                   array_idx     = (LA_CH_VALUE == LPAREN) ? 
00763                                   parse_array_spec(AT_WORK_IDX) : NULL_IDX;
00764 
00765                   if (LA_CH_VALUE != RPAREN) {
00766                      parse_err_flush(Find_Rparen, ")");
00767                      parse_err = TRUE;
00768                   }
00769                }
00770                else {
00771                   parse_err_flush(Find_Rparen, "pointee name");
00772                   parse_err = TRUE;
00773                }
00774             }
00775             else {
00776                parse_err_flush(Find_Rparen, ",");
00777                parse_err = TRUE;
00778             }
00779          }
00780          else {
00781             parse_err_flush(Find_Rparen, "Cray pointer name");
00782             parse_err = TRUE;
00783          }
00784 
00785          if (LA_CH_VALUE == RPAREN) {
00786             NEXT_LA_CH;                 /* Skip RPAREN */
00787          }
00788 
00789          if (LA_CH_VALUE != COMMA && LA_CH_VALUE != EOS) {
00790             parse_err_flush(Find_Comma, ", or " EOS_STR);
00791             parse_err = TRUE;
00792          }
00793 
00794          if (LA_CH_VALUE == COMMA) {
00795             NEXT_LA_CH;
00796          }
00797       }
00798       else {
00799          parse_err_flush(Find_Lparen, "(");
00800          parse_err = TRUE;
00801       }
00802  
00803       if (parse_err) {
00804          continue;
00805       }
00806 
00807       attr_idx = srch_sym_tbl(TOKEN_STR(pointee_name), 
00808                               TOKEN_LEN(pointee_name), &name_idx);
00809 
00810       if (attr_idx == NULL_IDX) {
00811          attr_idx                       = ntr_sym_tbl(&pointee_name, name_idx);
00812          LN_DEF_LOC(name_idx)           = TRUE;      /* Can't be host assoc */
00813          SET_IMPL_TYPE(attr_idx);
00814          ATD_CLASS(attr_idx)            = CRI__Pointee;
00815       }
00816       else if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
00817                TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
00818 
00819          if (fnd_semantic_err(Obj_Cri_Ch_Pointee,
00820                               TOKEN_LINE(pointee_name),
00821                               TOKEN_COLUMN(pointee_name),
00822                               attr_idx,
00823                               TRUE)) {
00824 
00825             semantic_err        = TRUE;
00826 
00827             CREATE_ERR_ATTR(attr_idx,
00828                             TOKEN_LINE(pointee_name),
00829                             TOKEN_COLUMN(pointee_name),
00830                             Data_Obj);
00831             SET_IMPL_TYPE(attr_idx);
00832          }
00833          else {
00834 # ifndef _EXTENDED_CRI_CHAR_POINTER
00835             if (TYP_CHAR_CLASS(ATD_TYPE_IDX(attr_idx)) != Assumed_Size_Char) {
00836                PRINTMSG(TOKEN_LINE(pointee_name), 1390, Warning,
00837                         TOKEN_COLUMN(pointee_name),
00838                         AT_OBJ_NAME_PTR(attr_idx));
00839 
00840                /* change to Assumed_Size_Char */
00841 
00842                CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
00843                TYP_TYPE(TYP_WORK_IDX)        = Character;
00844                TYP_LINEAR(TYP_WORK_IDX)      = Character_1;
00845                TYP_DESC(TYP_WORK_IDX)        = Default_Typed;
00846                TYP_DCL_VALUE(TYP_WORK_IDX)   = 0;
00847                TYP_CHAR_CLASS(TYP_WORK_IDX)  = Assumed_Size_Char;
00848                ATD_TYPE_IDX(attr_idx)        = ntr_type_tbl();
00849             }
00850 # endif
00851 
00852             if (AT_REFERENCED(attr_idx) == Char_Rslt_Bound_Ref) {
00853                AT_ATTR_LINK(attr_idx)   = NULL_IDX;
00854                LN_DEF_LOC(name_idx)     = TRUE;
00855             }
00856          }
00857 
00858 # if defined(_NO_CRAY_CHARACTER_PTR)
00859          PRINTMSG(lparen_line, 541, Error, lparen_col);
00860 # endif
00861 
00862       }
00863       else if (fnd_semantic_err(Obj_Cri_Pointee,
00864                                 TOKEN_LINE(pointee_name),
00865                                 TOKEN_COLUMN(pointee_name),
00866                                 attr_idx,
00867                                 TRUE)) {
00868          CREATE_ERR_ATTR(attr_idx,
00869                          TOKEN_LINE(pointee_name),
00870                          TOKEN_COLUMN(pointee_name),
00871                          Data_Obj);
00872          SET_IMPL_TYPE(attr_idx);
00873          semantic_err   = TRUE;
00874       }
00875 
00876 # if !defined(_POINTEES_CAN_BE_STRUCT)
00877       else if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure) {
00878          PRINTMSG (TOKEN_LINE(pointee_name), 651, Error,
00879                    TOKEN_COLUMN(pointee_name), 
00880                    AT_OBJ_NAME_PTR(attr_idx));
00881          CREATE_ERR_ATTR(attr_idx,
00882                          TOKEN_LINE(pointee_name),
00883                          TOKEN_COLUMN(pointee_name),
00884                          Data_Obj);
00885          SET_IMPL_TYPE(attr_idx);
00886          semantic_err   = TRUE;
00887       }
00888 # endif
00889       else if (AT_REFERENCED(attr_idx) == Char_Rslt_Bound_Ref) {
00890          AT_ATTR_LINK(attr_idx) = NULL_IDX;
00891          LN_DEF_LOC(name_idx)   = TRUE;
00892       }
00893 
00894       if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
00895          ATD_SEEN_OUTSIDE_IMP_DO(attr_idx) = TRUE;
00896       }
00897 
00898 
00899       ATD_CLASS(attr_idx)   = CRI__Pointee;
00900 
00901       if ((cif_flags & XREF_RECS) != 0) {
00902          cif_usage_rec(attr_idx,
00903                        AT_Tbl_Idx,
00904                        TOKEN_LINE(pointee_name),
00905                        TOKEN_COLUMN(pointee_name),
00906                        CIF_Symbol_Declaration);
00907       }
00908 
00909       if (array_idx != NULL_IDX) {
00910          merge_dimension(attr_idx,
00911                          TOKEN_LINE(pointee_name),
00912                          TOKEN_COLUMN(pointee_name),
00913                          array_idx);
00914       }
00915 
00916       pointer_idx = srch_sym_tbl(TOKEN_STR(pointer_name), 
00917                                  TOKEN_LEN(pointer_name), &name_idx);
00918 
00919       if (pointer_idx == NULL_IDX) {
00920          pointer_idx                    = ntr_sym_tbl(&pointer_name, name_idx);
00921          LN_DEF_LOC(name_idx)           = TRUE;      /* Can't be host assoc */
00922       }
00923       else if (fnd_semantic_err(Obj_Cri_Ptr, 
00924                                 TOKEN_LINE(pointer_name),
00925                                 TOKEN_COLUMN(pointer_name),
00926                                 pointer_idx,
00927                                 TRUE)) {
00928          semantic_err = TRUE;
00929          CREATE_ERR_ATTR(pointer_idx,
00930                          TOKEN_LINE(pointer_name),
00931                          TOKEN_COLUMN(pointer_name),
00932                          Data_Obj);
00933       }
00934       else if (AT_REFERENCED(pointer_idx) == Char_Rslt_Bound_Ref) {
00935          AT_ATTR_LINK(pointer_idx)      = NULL_IDX;
00936          LN_DEF_LOC(name_idx)           = TRUE;
00937       }
00938 
00939       if (AT_OBJ_CLASS(pointer_idx) == Data_Obj) {
00940          ATD_SEEN_OUTSIDE_IMP_DO(pointer_idx) = TRUE;
00941       }
00942 
00943       if ((cif_flags & XREF_RECS) != 0) {
00944          cif_usage_rec(pointer_idx,
00945                        AT_Tbl_Idx,
00946                        TOKEN_LINE(pointer_name),
00947                        TOKEN_COLUMN(pointer_name),
00948                        CIF_Symbol_Declaration);
00949       }
00950 
00951       if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Character) {
00952          ATD_TYPE_IDX(pointer_idx)      = CRI_Ptr_8;
00953       }
00954       else {
00955          ATD_TYPE_IDX(pointer_idx)      = CRI_Ch_Ptr_8;
00956       }
00957 
00958       AT_TYPED(pointer_idx)     = TRUE;
00959       ATD_PTR_IDX(attr_idx)     = pointer_idx;
00960 
00961       if (semantic_err) {
00962          AT_DCL_ERR(pointer_idx)= TRUE;
00963          AT_DCL_ERR(attr_idx)   = TRUE;
00964       }
00965    }  /* End while */
00966    while (LA_CH_VALUE != EOS); 
00967 
00968    NEXT_LA_CH;                          /* Skip EOS */
00969 
00970 EXIT:
00971 
00972    TRACE (Func_Exit, "parse_pointer_stmt", NULL);
00973 
00974    return;
00975 
00976 }  /* parse_pointer_stmt */
00977 
00978 
00979 /******************************************************************************\
00980 |*                                                                            *|
00981 |* Description:                                                               *|
00982 |*      BNF       - SAVE [::] object-name OR /common-block-name/              *|
00983 |*                                                                            *|
00984 |* Input parameters:                                                          *|
00985 |*      NONE                                                                  *|
00986 |*                                                                            *|
00987 |* Output parameters:                                                         *|
00988 |*      NONE                                                                  *|
00989 |*                                                                            *|
00990 |* Returns:                                                                   *|
00991 |*      NONE                                                                  *|
00992 |*                                                                            *|
00993 \******************************************************************************/
00994 
00995 void parse_save_stmt (void)
00996 
00997 {
00998    TRACE (Func_Entry, "parse_save_stmt", NULL);
00999 
01000    if (LA_CH_VALUE == EOS) {
01001 
01002       if ((STMT_CANT_BE_IN_BLK(Save_Stmt, CURR_BLK) ||
01003            STMT_OUT_OF_ORDER(curr_stmt_category, Save_Stmt)) && 
01004           iss_blk_stk_err()) {
01005          /* Block stack error - intentionally blank */
01006       }
01007       else {
01008          if (ATP_SAVE_ALL(SCP_ATTR_IDX(curr_scp_idx))) {
01009             PRINTMSG(TOKEN_LINE(token), 133, Ansi, TOKEN_COLUMN(token));
01010          }
01011          ATP_SAVE_ALL(SCP_ATTR_IDX(curr_scp_idx))       = TRUE;
01012          curr_stmt_category                             = Declaration_Stmt_Cat;
01013 
01014          if (ATP_STACK_DIR(SCP_ATTR_IDX(curr_scp_idx))) {
01015 
01016             /* A SAVE with no save entity list has been specified in this */
01017             /* program unit.  SAVE overrides STACK.  Issue warning.       */
01018 
01019             PRINTMSG(TOKEN_LINE(token), 1144, Warning,
01020                      TOKEN_COLUMN(token),
01021                      "STACK");
01022             ATP_STACK_DIR(SCP_ATTR_IDX(curr_scp_idx))   = FALSE;
01023          }
01024       }
01025       NEXT_LA_CH;                       /* Pick up EOS */
01026    }
01027    else {
01028 
01029       if (ATP_SAVE_ALL(SCP_ATTR_IDX(curr_scp_idx))) {
01030          PRINTMSG (stmt_start_line, 133, Ansi, stmt_start_col);
01031       }
01032 
01033       parse_attrs(merge_save);
01034    }
01035 
01036    TRACE (Func_Exit, "parse_save_stmt", NULL);
01037 
01038    return;
01039 
01040 }  /* parse_save_stmt */
01041 
01042 
01043 /******************************************************************************\
01044 |*                                                                            *|
01045 |* Description:                                                               *|
01046 |*      BNF       - TARGET [::] object-name [(array-spec)]                    *|
01047 |*                                 [,object-name [(array_spec)]..             *|
01048 |*                                                                            *|
01049 |* Input parameters:                                                          *|
01050 |*      NONE                                                                  *|
01051 |*                                                                            *|
01052 |* Output parameters:                                                         *|
01053 |*      NONE                                                                  *|
01054 |*                                                                            *|
01055 |* Returns:                                                                   *|
01056 |*      NONE                                                                  *|
01057 |*                                                                            *|
01058 \******************************************************************************/
01059 
01060 void parse_target_stmt (void)
01061 
01062 {
01063    TRACE (Func_Entry, "parse_target_stmt", NULL);
01064 
01065    parse_attrs(merge_target);
01066 
01067    TRACE (Func_Exit, "parse_target_stmt", NULL);
01068 
01069    return;
01070 
01071 }  /* parse_target_stmt */
01072 
01073 /******************************************************************************\
01074 |*                                                                            *|
01075 |* Description:                                                               *|
01076 |*      BNF       - VOLATILE [::] object-name OR /common-block-name/          *|
01077 |*                                                                            *|
01078 |* Input parameters:                                                          *|
01079 |*      NONE                                                                  *|
01080 |*                                                                            *|
01081 |* Output parameters:                                                         *|
01082 |*      NONE                                                                  *|
01083 |*                                                                            *|
01084 |* Returns:                                                                   *|
01085 |*      NONE                                                                  *|
01086 |*                                                                            *|
01087 \******************************************************************************/
01088 
01089 void parse_volatile_stmt (void)
01090 
01091 {
01092    TRACE (Func_Entry, "parse_volatile_stmt", NULL);
01093 
01094    PRINTMSG(stmt_start_line, 1253, Ansi, stmt_start_col, "VOLATILE");
01095    
01096    parse_attrs(merge_volatile);
01097 
01098    TRACE (Func_Exit, "parse_volatile_stmt", NULL);
01099 
01100    return;
01101 
01102 }  /* parse_volatile_stmt */
01103 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines