[hackers] [scc] [cc1] Avoid wrong message in invalid storage class || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 28 Jan 2016 08:49:39 +0100 (CET)

commit 5ab49e1bb06b5266b817527557114bada4bfa432
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jan 28 08:40:18 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Jan 28 08:47:30 2016 +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.

diff --git a/cc1/decl.c b/cc1/decl.c
index 992c77f..1a22c44 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -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 *
_AT_@ -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
index ce7298b..818d83c 100644
--- a/cc1/tests/test014.c
+++ b/cc1/tests/test014.c
_AT_@ -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
Received on Thu Jan 28 2016 - 08:49:39 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 28 2016 - 09:00:24 CET