* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)const.c 5.1 (Berkeley) %G%";
* Const enters the definitions
* of the constant declaration
* part into the namelist.
static bool const_order
= FALSE
;
static bool const_seen
= FALSE
;
* this allows for multiple declaration
* parts, unless the "standard" option
* If a routine segment is being compiled,
* do level one processing.
if (parts
[ cbn
] & (TPRT
|VPRT
|RPRT
)) {
error("Constant declarations should precede type, var and routine declarations");
error("Constant declarations should precede type, var and routine declarations");
if (parts
[ cbn
] & CPRT
) {
error("All constants should be declared in one const part");
error("All constants should be declared in one const part");
register struct tnode
*cdecl;
send(REVCNST
, cline
, cid
, cdecl);
np
= enter(defnl(cid
, CONST
, con
.ctype
, con
.cival
));
stabgconst( cid
, line
);
pPointer Const
= ConstDecl( cid
, cdecl );
pSeize( PorFHeader
[ nesting
] );
Consts
= &( pDEF( PorFHeader
[ nesting
] ).PorFConsts
);
*Consts
= ListAppend( *Consts
, Const
);
pRelease( PorFHeader
[ nesting
] );
if ( con
.ctype
== nl
+ TSTR
)
np
->ptr
[0] = (struct nl
*) con
.cpval
;
np
->range
[0] = con
.crval
;
else if (isa(con
.ctype
, "d"))
if (cbn
== 1 && con
.ctype
!= NIL
) {
* only types of constants
* are integer, reals, strings
* and scalars, the first two
register struct tnode
*cn
;
if (cn
== TR_NIL
|| cn
->sign_const
.number
== TR_NIL
)
cn
= cn
->sign_const
.number
;
np
= lookup(cn
->char_const
.cptr
);
if (np
->class != CONST
) {
derror("%s is a %s, not a constant as required", cn
->char_const
.cptr
, classes
[np
->class]);
switch (classify(np
->type
)) {
con
.crval
= np
->range
[0];
con
.cival
= np
->value
[0];
con
.cpval
= (char *) np
->ptr
[0];
con
.crval
= a8tol(cn
->char_const
.cptr
);
con
.crval
= atof(cn
->char_const
.cptr
);
if (con
.crval
> MAXINT
|| con
.crval
< MININT
) {
derror("Constant too large for this implementation");
con
.crval
= atof(cn
->char_const
.cptr
);
cp
= cn
->char_const
.cptr
;
if (isnta((struct nl
*) con
.ctype
, "id"))
derror("%s constants cannot be signed",
nameof((struct nl
*) con
.ctype
));
register struct tnode
*cn
;
return (isconst(cn
->sign_const
.number
));
return (isconst(cn
->sign_const
.number
));
if (cn
->var_node
.qual
!= TR_NIL
)