scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 5ab49e1bb06b5266b817527557114bada4bfa432
parent 298b9d10ce37f28fa4e09a13df94835de354d696
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 28 Jan 2016 08:40:18 +0100

[cc1] Avoid wrong message in invalid storage class

The code was wrintten in a way that external declarations with incorrect
storage class were always printing 'invalid storage class for function'
independently of the real error. This patch removes this problem and
also deal wrong storage class an empty.

Diffstat:
cc1/decl.c | 10+++++-----
cc1/tests/test014.c | 1-
2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/cc1/decl.c b/cc1/decl.c @@ -654,7 +654,8 @@ bad_storage(Type *tp, char *name) { if (tp->op != FTN) errorp("incorrect storage class for file-scope declaration"); - errorp("invalid storage class for function '%s'", name); + else + errorp("invalid storage class for function '%s'", name); } static Symbol * @@ -764,12 +765,11 @@ identifier(struct decl *dcl) switch (sclass) { case REGISTER: case AUTO: - if (curctx == GLOBALCTX || tp->op == FTN) { - bad_storage(tp, name); + if (curctx != GLOBALCTX && tp->op != FTN) { + flags |= (sclass == REGISTER) ? ISREGISTER : ISAUTO; break; } - flags |= (sclass == REGISTER) ? ISREGISTER : ISAUTO; - break; + bad_storage(tp, name); case NOSCLASS: if (tp->op == FTN) flags |= ISEXTERN; diff --git a/cc1/tests/test014.c b/cc1/tests/test014.c @@ -11,7 +11,6 @@ test014.c:21: warning: 'par' defined but not used test014.c:21: warning: 'par' defined but not used test014.c:26: warning: 'par' defined but not used test014.c:28: error: incorrect storage class for file-scope declaration -test014.c:28: error: invalid storage class for function 'd' test014.c:31: error: bad storage class in function parameter test014.c:32: error: invalid storage class for function 'func4' test014.c:33: error: invalid type specification