if (oldtp->tp_fund == POINTER && is_integral_type(tp)) {
/* from pointer to integral */
if (oper != CAST)
- expr_warning(exp,
+ expr_strict(exp,
"illegal conversion of pointer to %s",
symbol2str(tp->tp_fund));
if (oldtp->tp_size > tp->tp_size)
if (is_cp_cst(exp) && exp->VL_VALUE == (arith)0)
break;
default:
- expr_warning(exp,
+ expr_strict(exp,
"illegal conversion of %s to pointer",
symbol2str(oldtp->tp_fund));
break;
}
else
if (oldtp->tp_size == tp->tp_size && oper == CAST) {
- expr_warning(exp, "dubious conversion based on equal size");
+ expr_strict(exp, "dubious conversion based on equal size");
exp->ex_type = tp; /* brute force */
}
else {
switch (def->df_sc) {
case EXTERN:
case GLOBAL:
- case IMPLICIT:
if (fund == FUNCTION)
C_exp(text);
else
)
def->df_alloc = ALLOC_SEEN;
if (expr && def_sc == STATIC && sc == EXTERN) {
- warning("%s redeclared extern", idf->id_text);
- def->df_sc = EXTERN;
+ warning("%s has internal linkage", idf->id_text);
}
if (expr) { /* code only if initialized */
#ifndef PREPEND_SCOPES
}
else
if (lvl >= L_LOCAL) { /* local variable */
- /* STATIC, EXTERN, GLOBAL, IMPLICIT, AUTO or REGISTER */
+ /* STATIC, EXTERN, GLOBAL, AUTO or REGISTER */
switch (def_sc) {
case STATIC:
if (fund == FUNCTION) {
error("cannot initialize extern in block"
, idf->id_text);
case GLOBAL:
- case IMPLICIT:
/* we are sure there is no expression */
break;
case AUTO:
idf->id_def->df_type->tp_fund = ERRONEOUS;
}
if (level == L_FORMAL2)
- warning("illegal initialization of formal parameter (ignored)");
+ error("illegal initialization of formal parameter");
}
'='
{
error("non_empty formal parameter pack");
free_formals(dc->dc_formal);
dc->dc_formal = 0;
+ } else {
+ if (du && du->du_fund == FUNCTION
+ && !du->du_proto && !options['o']) {
+ warning("old-fashioned function declaration");
+ }
}
while (du) {
if (du->du_fund == FUNCTION)
if ( level == L_GLOBAL &&
(ds->ds_sc == AUTO || ds->ds_sc == REGISTER)
) {
- warning("no global %s variable allowed",
+ error("no global %s variable allowed",
symbol2str(ds->ds_sc));
ds->ds_sc = GLOBAL;
}
int df_level;
struct type *df_type;
int df_sc; /* may be:
- GLOBAL, STATIC, EXTERN, IMPLICIT,
+ GLOBAL, STATIC, EXTERN
TYPEDEF,
FORMAL, AUTO,
ENUM, LABEL
*/
for (pbuf2 = pbuf - 1; pbuf2 >= &buf[0]; pbuf2--) {
if (!strcmp(*pbuf2, *pbuf)) {
- warning("formal parameter \"%s\" already used",
+ error("formal parameter \"%s\" already used",
*pbuf);
}
}
/* if (df->df_level == L_GLOBAL) { /* } ??? re-examine */
if (df->df_sc == GLOBAL
|| df->df_sc == EXTERN
- || df->df_sc == STATIC
- || df->df_sc == IMPLICIT) {
+ || df->df_sc == STATIC) {
if (inword)
C_ste_dnam(id->id_text, val);
else
/* if (df->df_level == L_GLOBAL) { /* } ??? re-examine */
if ( df->df_sc == GLOBAL
|| df->df_sc == STATIC
- || df->df_sc == EXTERN
- || df->df_sc == IMPLICIT) {
+ || df->df_sc == EXTERN) {
if (rvalue) {
if (inword)
C_loe_dnam(id->id_text, val);
if (def == 0) {
if (AHEAD == '(') {
- /* function call, declare name IMPLICITly (3.3.2.2) */
+ /* function call, declare name implicitly (3.3.2.2) */
if (!options['o'])
warning("implicit declaration of function %s"
, idf->id_text);
- add_def(idf, IMPLICIT, funint_type, level);
+ add_def(idf, EXTERN, funint_type, level);
} else {
if (!is_anon_idf(idf))
error("%s undefined", idf->id_text);
int idfsize = IDFSIZE;
extern char options[];
extern arith NewLocal();
+extern char *symbol2str();
char sp_occurred[SP_TOTAL+1]; /* indicate occurrence of special id */
/* the type is not yet known,
but it has to be:
*/
- extern char *symbol2str();
if (type->tp_fund != VOID) {
if (level != L_GLOBAL)
error("unknown %s-type",
if (lvl != L_GLOBAL) { /* 3.5.1 */
if (sc == 0)
sc = GLOBAL;
- else if (sc != EXTERN && sc != IMPLICIT) {
+ else if (sc != EXTERN) {
error("illegal storage class %s for function with block-scope"
, symbol2str(sc));
- ds->ds_sc = sc = GLOBAL;
+ ds->ds_sc = sc = EXTERN;
}
}
else if (sc == 0)
: lvl == L_FORMAL1 || lvl == L_FORMAL2 ? FORMAL
: AUTO;
- /* is it a universal typedef? */
- if (def && def->df_level == L_UNIVERSAL)
- warning("redeclaring reserved word %s", idf->id_text);
-
#ifdef LINT
if ( def && def->df_level < lvl
&& !( lvl == L_FORMAL2
def->df_file = idf->id_file;
def->df_line = idf->id_line;
}
-#if 0 /* be more strict in scope (at least for now) */
- else
- if ( lvl >= L_LOCAL &&
- (type->tp_fund == FUNCTION || sc == EXTERN)
- ) {
- /* extern declaration inside function is treated the
- same way as global extern declaration
- */
- if (sc == STATIC && type->tp_fund == FUNCTION)
- if (!is_anon_idf(idf))
- warning("non-global static function %s",
- idf->id_text);
- declare_idf(ds, dc, L_GLOBAL);
- }
-#endif
else { /* fill in the def block */
register struct def *newdef = new_def();
if (def->df_type->tp_size < 0) { /* old decl has [] */
def->df_type = tp;
}
+ } if (tp->tp_fund == FUNCTION && new_sc == GLOBAL) {
+ /* see 3.1.2.2 */
+ new_sc = EXTERN;
}
/* Now we may be able to update the storage class.
level, without either "extern" or
"static".
STATIC: we have seen the word "static"
- IMPLICIT: function declaration inferred from
- call
*/
- if (new_sc == IMPLICIT)
- return; /* no new information */
switch (def->df_sc) { /* the old storage class */
case EXTERN:
switch (new_sc) { /* the new storage class */
- case EXTERN:
- case GLOBAL:
- break;
case STATIC:
- warning("redeclaration of %s to static ignored"
- , idf->id_text);
+ warning("%s redeclared static", idf->id_text);
+ /* fallthrough */
+ case GLOBAL:
+ def->df_sc = new_sc;
+ /* fallthrough */
+ case EXTERN:
break;
default:
crash("bad storage class");
break;
case GLOBAL:
switch (new_sc) { /* the new storage class */
- case EXTERN:
- def->df_sc = EXTERN;
- break;
+ case STATIC: /* linkage disagreement */
+ warning("%s redeclared static", idf->id_text);
+ def->df_sc = new_sc;
+ /* fallthrough */
case GLOBAL:
- break;
- case STATIC:
- warning("redeclaration of %s to static ignored"
- , idf->id_text);
+ case EXTERN:
break;
default:
crash("bad storage class");
break;
case STATIC:
switch (new_sc) { /* the new storage class */
- case GLOBAL:
- warning("%s redeclared extern", idf->id_text);
- def->df_sc = new_sc;
- break;
- case EXTERN: /* complain at definition */
- break;
- case STATIC:
- break;
- default:
- crash("bad storage class");
- /*NOTREACHED*/
- }
- break;
- case IMPLICIT:
- switch (new_sc) { /* the new storage class */
+ case GLOBAL: /* linkage disagreement */
case EXTERN:
- case GLOBAL:
- def->df_sc = new_sc;
- break;
+ warning("%s is already declared static", idf->id_text);
+ /* fallthrough */
case STATIC:
- def->df_sc = new_sc;
break;
default:
crash("bad storage class");
if (def->df_initialized)
error("multiple initialization of %s", idf->id_text);
if (def->df_sc == TYPEDEF) {
- warning("typedef cannot be initialized");
- def->df_sc = EXTERN; /* ??? *//* What else ? */
+ error("typedef cannot be initialized");
+ return;
}
def->df_initialized = 1;
}
def->df_used ? "used" : "not used");
}
#endif DEBUG
- /*
- /_* find final storage class *_/
- if (def->df_sc == GLOBAL || def->df_sc == IMPLICIT)
- /_* even now we still don't know *_/
- def->df_sc = EXTERN;
- */
-
if (def->df_sc == STATIC
&& def->df_type->tp_fund == FUNCTION
&& !def->df_initialized) {
{FIELD, "field"},
{GLOBAL, "global"},
- {IMPLICIT, "implicit"},
{FORMAL, "formal"},
{LABEL, "label"},
{ERRONEOUS, "erroneous"},