1*47951Sbostic /*-
2*47951Sbostic * Copyright (c) 1980 The Regents of the University of California.
3*47951Sbostic * All rights reserved.
4*47951Sbostic *
5*47951Sbostic * %sccs.include.proprietary.c%
643219Sbostic */
743219Sbostic
843219Sbostic #ifndef lint
9*47951Sbostic static char sccsid[] = "@(#)paramset.c 5.3 (Berkeley) 04/12/91";
10*47951Sbostic #endif /* not lint */
1143219Sbostic
1243219Sbostic /*
1343219Sbostic * paramset.c
1443219Sbostic *
1543219Sbostic * Routines for handling PARAMETER statements, f77 compiler, 4.2 BSD.
1643219Sbostic *
1743219Sbostic * $Log: paramset.c,v $
1843219Sbostic * Revision 3.2 84/10/13 03:52:03 donn
1943219Sbostic * Setting a parameter variable to a nonconstant expression is an error;
2043219Sbostic * previously a mere warning was emitted. Also added a comment header.
2143219Sbostic *
2243219Sbostic */
2343219Sbostic
2443219Sbostic #include "defs.h"
2543219Sbostic #include "data.h"
2643219Sbostic
2743219Sbostic /* process the items in a PARAMETER statement */
paramset(param_item_nm,param_item_vl)2843219Sbostic paramset( param_item_nm, param_item_vl )
2943219Sbostic Namep param_item_nm;
3043219Sbostic expptr param_item_vl;
3143219Sbostic {
3243219Sbostic if (param_item_nm->vstg != STGUNKNOWN && param_item_nm->vstg != STGCONST )
3343219Sbostic dclerr("conflicting declarations", param_item_nm);
3443219Sbostic else if (param_item_nm->vclass == CLUNKNOWN)
3543219Sbostic param_item_nm->vclass = CLPARAM;
3643219Sbostic else if ( param_item_nm->vclass == CLPARAM )
3743219Sbostic dclerr("redefining PARAMETER value", param_item_nm );
3843219Sbostic else
3943219Sbostic dclerr("conflicting declarations", param_item_nm);
4043219Sbostic
4143219Sbostic if (param_item_nm->vclass == CLPARAM)
4243219Sbostic {
4343219Sbostic if (!ISCONST(param_item_vl))
4443219Sbostic param_item_vl = fixtype(param_item_vl);
4543219Sbostic
4643219Sbostic if (param_item_nm->vtype == TYUNKNOWN)
4743219Sbostic {
4843219Sbostic char c;
4943219Sbostic
5043219Sbostic c = param_item_nm->varname[0];
5143219Sbostic if (c >= 'A' && c <= 'Z')
5243219Sbostic c = c - 'A';
5343219Sbostic else
5443219Sbostic c = c - 'a';
5543219Sbostic param_item_nm->vtype = impltype[c];
5643219Sbostic param_item_nm->vleng = ICON(implleng[c]);
5743219Sbostic }
5843219Sbostic if (param_item_nm->vtype == TYUNKNOWN)
5943219Sbostic {
6043219Sbostic warn1("type undefined for %s",
6143219Sbostic varstr(VL, param_item_nm->varname));
6243219Sbostic ((struct Paramblock *) (param_item_nm))->paramval = param_item_vl;
6343219Sbostic }
6443219Sbostic else
6543219Sbostic {
6643219Sbostic extern int badvalue;
6743219Sbostic extern expptr constconv();
6843219Sbostic int type;
6943219Sbostic ftnint len;
7043219Sbostic
7143219Sbostic type = param_item_nm->vtype;
7243219Sbostic if (type == TYCHAR)
7343219Sbostic {
7443219Sbostic if (param_item_nm->vleng != NULL)
7546305Sbostic len = param_item_nm->vleng->constblock.constant.ci;
7643219Sbostic else if (ISCONST(param_item_vl) &&
7743219Sbostic param_item_vl->constblock.vtype == TYCHAR)
7843219Sbostic len = param_item_vl->constblock.vleng->
7946305Sbostic constblock.constant.ci;
8043219Sbostic else
8143219Sbostic len = 1;
8243219Sbostic }
8343219Sbostic badvalue = 0;
8443219Sbostic if (ISCONST(param_item_vl))
8543219Sbostic {
8643219Sbostic ((struct Paramblock *) (param_item_nm))->paramval =
8743219Sbostic convconst(param_item_nm->vtype, len, param_item_vl);
8843219Sbostic if (type == TYLOGICAL)
8943219Sbostic ((struct Paramblock *) (param_item_nm))->paramval->
9043219Sbostic headblock.vtype = TYLOGICAL;
9143219Sbostic frexpr((tagptr) param_item_vl);
9243219Sbostic }
9343219Sbostic else
9443219Sbostic {
9543219Sbostic erri("%s set to a nonconstant",
9643219Sbostic varstr(VL, param_item_nm->varname));
9743219Sbostic ((struct Paramblock *) (param_item_nm))->paramval = param_item_vl;
9843219Sbostic }
9943219Sbostic }
10043219Sbostic }
10143219Sbostic }
102