1987-03-10 17:51:10 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1986-03-10 13:07:55 +00:00
|
|
|
/* $Header$ */
|
|
|
|
/* D E C L A R A T I O N S P E C I F I E R C H E C K I N G */
|
|
|
|
|
1986-09-24 13:53:16 +00:00
|
|
|
#include "nofloat.h"
|
1986-03-10 13:07:55 +00:00
|
|
|
#include "Lpars.h"
|
|
|
|
#include "decspecs.h"
|
|
|
|
#include "arith.h"
|
|
|
|
#include "type.h"
|
|
|
|
#include "level.h"
|
|
|
|
#include "def.h"
|
1987-03-25 23:14:43 +00:00
|
|
|
#include "noRoption.h"
|
1986-03-10 13:07:55 +00:00
|
|
|
|
|
|
|
extern char options[];
|
|
|
|
extern int level;
|
|
|
|
extern char *symbol2str();
|
|
|
|
|
|
|
|
struct decspecs null_decspecs;
|
|
|
|
|
|
|
|
do_decspecs(ds)
|
1986-09-24 13:53:16 +00:00
|
|
|
register struct decspecs *ds;
|
1986-03-10 13:07:55 +00:00
|
|
|
{
|
|
|
|
/* The provisional decspecs ds as obtained from the program
|
|
|
|
is turned into a legal consistent decspecs.
|
|
|
|
*/
|
1986-09-24 13:53:16 +00:00
|
|
|
register struct type *tp = ds->ds_type;
|
1986-03-10 13:07:55 +00:00
|
|
|
|
|
|
|
if (level == L_FORMAL1)
|
|
|
|
crash("do_decspecs");
|
|
|
|
|
|
|
|
if ( level == L_GLOBAL &&
|
|
|
|
(ds->ds_sc == AUTO || ds->ds_sc == REGISTER)
|
|
|
|
) {
|
|
|
|
warning("no global %s variable allowed",
|
|
|
|
symbol2str(ds->ds_sc));
|
|
|
|
ds->ds_sc = GLOBAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (level == L_FORMAL2) {
|
1987-10-05 10:17:44 +00:00
|
|
|
if (ds->ds_sc_given &&
|
1986-03-10 13:07:55 +00:00
|
|
|
ds->ds_sc != REGISTER){
|
|
|
|
error("%s formal illegal", symbol2str(ds->ds_sc));
|
1986-12-01 10:00:23 +00:00
|
|
|
ds->ds_sc = FORMAL;
|
1986-03-10 13:07:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* The tests concerning types require a full knowledge of the
|
|
|
|
type and will have to be postponed to declare_idf.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* some adjustments as described in RM 8.2 */
|
|
|
|
if (tp == 0)
|
|
|
|
tp = int_type;
|
|
|
|
switch (ds->ds_size) {
|
|
|
|
case SHORT:
|
|
|
|
if (tp == int_type)
|
|
|
|
tp = short_type;
|
1986-09-12 09:16:07 +00:00
|
|
|
else
|
|
|
|
error("short with illegal type");
|
1986-03-10 13:07:55 +00:00
|
|
|
break;
|
|
|
|
case LONG:
|
|
|
|
if (tp == int_type)
|
|
|
|
tp = long_type;
|
|
|
|
else
|
1986-09-12 09:16:07 +00:00
|
|
|
#ifndef NOFLOAT
|
1986-03-10 13:07:55 +00:00
|
|
|
if (tp == float_type)
|
|
|
|
tp = double_type;
|
1986-09-12 09:16:07 +00:00
|
|
|
else
|
|
|
|
#endif NOFLOAT
|
|
|
|
error("long with illegal type");
|
1986-03-10 13:07:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ds->ds_unsigned) {
|
|
|
|
switch (tp->tp_fund) {
|
|
|
|
case CHAR:
|
1987-03-25 23:14:43 +00:00
|
|
|
#ifndef NOROPTION
|
1986-03-10 13:07:55 +00:00
|
|
|
if (options['R'])
|
|
|
|
warning("unsigned char not allowed");
|
1987-03-25 23:14:43 +00:00
|
|
|
#endif
|
1986-03-10 13:07:55 +00:00
|
|
|
tp = uchar_type;
|
|
|
|
break;
|
|
|
|
case SHORT:
|
1987-03-25 23:14:43 +00:00
|
|
|
#ifndef NOROPTION
|
1986-03-10 13:07:55 +00:00
|
|
|
if (options['R'])
|
|
|
|
warning("unsigned short not allowed");
|
1987-03-25 23:14:43 +00:00
|
|
|
#endif
|
1986-03-10 13:07:55 +00:00
|
|
|
tp = ushort_type;
|
|
|
|
break;
|
|
|
|
case INT:
|
|
|
|
tp = uint_type;
|
|
|
|
break;
|
|
|
|
case LONG:
|
1987-03-25 23:14:43 +00:00
|
|
|
#ifndef NOROPTION
|
1986-03-10 13:07:55 +00:00
|
|
|
if (options['R'])
|
|
|
|
warning("unsigned long not allowed");
|
1987-03-25 23:14:43 +00:00
|
|
|
#endif
|
1986-03-10 13:07:55 +00:00
|
|
|
tp = ulong_type;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error("unsigned with illegal type");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ds->ds_type = tp;
|
|
|
|
}
|