shithub: scc

Download patch

ref: 5ab49e1bb06b5266b817527557114bada4bfa432
parent: 298b9d10ce37f28fa4e09a13df94835de354d696
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jan 28 03:40:18 EST 2016

[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.

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -654,7 +654,8 @@
 {
 	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 @@
 		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;
--- 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: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