]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Added diagnostic for case expressions
authorDale Weiler <killfieldengine@gmail.com>
Fri, 31 May 2013 03:56:12 +0000 (03:56 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 31 May 2013 03:56:12 +0000 (03:56 +0000)
diag.c
gmqcc.h
parser.c

diff --git a/diag.c b/diag.c
index 13d276fdeb72d1bc89af12e4e7739c7df9c4dc71..009df345b31093ec9f9f263794028a65a83899d5 100644 (file)
--- a/diag.c
+++ b/diag.c
@@ -156,6 +156,7 @@ static void diagnostic_feed(const char *file, size_t line, size_t beg, size_t en
     }
     
     switch (diagnostic) {
+        case DIAGNOSTIC_EXPRESSION_CASE:
         case DIAGNOSTIC_SEMICOLON:
             for (; len < vec_size(vec_last(read)->values); len++)
                 space += strlen(vec_last(read)->values[len]);
@@ -223,6 +224,11 @@ void diagnostic_calculate(const char *file, size_t line, size_t diagnostic) {
             linebeg++;
             marker = true;
             break;
+            
+        case DIAGNOSTIC_EXPRESSION_CASE:
+            linebeg++;
+            marker = true;
+            break;
 
         /* Catches the DIAGNOSTIC_NULL and out of range case */
         default:
diff --git a/gmqcc.h b/gmqcc.h
index 1beaf4d2c56ea2f6b7756662994f7f048f4dd5fe..9a41ae5b5aa81481c93e98e5412e4660eecfe0d5 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -1029,7 +1029,8 @@ void            ftepp_add_macro        (struct ftepp_s *ftepp, const char *name,
 /*===================================================================*/
 enum {
     DIAGNOSTIC_NULL,
-    DIAGNOSTIC_SEMICOLON
+    DIAGNOSTIC_SEMICOLON,
+    DIAGNOSTIC_EXPRESSION_CASE
 };
 
 void diagnostic_destroy();
index 907f6a658e9987883ea9f734c8bf286fa3c6d6c6..33978562d2d004177460c8b66a9b0acbb368dee1 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3371,12 +3371,14 @@ static bool parse_switch_go(parser_t *parser, ast_block *block, ast_expression *
         if (!strcmp(parser_tokval(parser), "case")) {
             if (!parser_next(parser)) {
                 ast_delete(switchnode);
+                parser->diagnostic = DIAGNOSTIC_EXPRESSION_CASE;
                 parseerror(parser, "expected expression for case");
                 return false;
             }
             swcase.value = parse_expression_leave(parser, false, false, false);
             if (!swcase.value) {
                 ast_delete(switchnode);
+                parser->diagnostic = DIAGNOSTIC_EXPRESSION_CASE;
                 parseerror(parser, "expected expression for case");
                 return false;
             }