From cf36410e30b3c18be6c556158b2d0d0938f5b77d Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Tue, 13 Apr 2010 21:08:37 +0200 Subject: [PATCH] Complain for static fct declared w/o file scope Error out on static function without file scope and give an explaination to the user This is a rewrite of e9406c09a3212ab3f120412a6bbdacb0cdd25deb but considering problems raised about static local function pointers in 632ee5a54076d417971ae7fa8a0c154441a71499. --- tccgen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tccgen.c b/tccgen.c index 7144ccdd..8464e649 100644 --- a/tccgen.c +++ b/tccgen.c @@ -5423,6 +5423,10 @@ ST_FUNC void decl(int l) while (1) { /* iterate thru each declaration */ type = btype; type_decl(&type, &ad, &v, TYPE_DIRECT); + if (((type.t & (VT_STATIC|VT_FUNC)) == (VT_STATIC|VT_FUNC)) + && (l == VT_LOCAL)) { + error("Function without file scope cannot be static"); + } #if 0 { char buf[500];