diff --git a/src/snc/analysis.c b/src/snc/analysis.c index 6222049835c655dfb6b7aa0bc136b14b006216ff..8451795a7b3b682a958ff606ddd4b7ebd7e7e2fc 100644 --- a/src/snc/analysis.c +++ b/src/snc/analysis.c @@ -283,6 +283,7 @@ static void analyse_declaration(SymTable st, Expr *scope, Expr *defn) { Var *vp; VarList *var_list; + static uint seen_foreign = FALSE; assert(scope); /* precondition */ assert(defn); /* precondition */ @@ -294,7 +295,12 @@ static void analyse_declaration(SymTable st, Expr *scope, Expr *defn) #ifdef DEBUG report("declaration: %s\n", vp->name); #endif - + if (vp->type->tag == T_NONE && !seen_foreign) + { + warning_at_expr(defn, + "foreign declarations are deprecated\n"); + seen_foreign = TRUE; + } if (scope->type != D_PROG && (vp->type->tag == T_NONE || vp->type->tag == T_EVFLAG)) { @@ -1119,7 +1125,7 @@ static int connect_variable(Expr *ep, Expr *scope, void *parg) return FALSE; } - extra_warning_at_expr(ep, "variable '%s' used but not declared\n", + extra_warning_at_expr(ep, "treating undeclared object '%s' as foreign\n", ep->value); /* create a pseudo declaration so we can finish the analysis phase */ vp = new(Var); diff --git a/src/snc/snl.lem b/src/snc/snl.lem index 89b93887432614a0b80de02c02d2caeb20f124c6..c9101ad4242e98327e92a3c6b885aff670091ead 100644 --- a/src/snc/snl.lem +++ b/src/snc/snl.lem @@ -197,6 +197,7 @@ direct_declarator(p) ::= LPAREN declarator(x) RPAREN. direct_declarator(p) ::= direct_declarator(x) subscript(s). { p = decl_postfix_array(x, s.str); } +// deprecated declaration(p) ::= FOREIGN declarators(ds) SEMICOLON. { p = decl_add_base_type(ds, mk_no_type()); }