]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Diagnostic tests for expected semicolon situations.
authorDale Weiler <killfieldengine@gmail.com>
Fri, 31 May 2013 05:54:16 +0000 (05:54 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 31 May 2013 05:54:16 +0000 (05:54 +0000)
parser.c
tests/diag/semicolon.qc [new file with mode: 0644]
tests/diag/semicolon.tmpl [new file with mode: 0644]
tests/diag/semienum.qc [new file with mode: 0644]
tests/diag/semienum.tmpl [new file with mode: 0644]

index 063c6d2e7a9d09a47e6ccd04c56336f7bfdc9ca5..d0aaf4a440e58ce0ad9a5bf2490bad614999d5cd 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3946,6 +3946,7 @@ static bool parse_enum(parser_t *parser)
     }
 
     if (!parser_next(parser) || parser->tok != ';') {
+        parser->diagnostic = DIAGNOSTIC_SEMICOLON;
         parseerror(parser, "expected semicolon after enumeration");
         goto onerror;
     }
@@ -6165,10 +6166,10 @@ static bool parser_compile(parser_t *parser)
         while (parser->tok != TOKEN_EOF && parser->tok < TOKEN_ERROR)
         {
             if (!parser_global_statement(parser)) {
-                if (parser->tok == TOKEN_EOF)
+                parser->diagnostic = DIAGNOSTIC_NULL;
+                if (parser->tok == TOKEN_EOF) {
                     parseerror(parser, "unexpected eof");
-                else if (compile_errors) {
-                    parser->diagnostic = DIAGNOSTIC_NULL;
+                } else if (compile_errors) {
                     parseerror(parser, "there have been errors, bailing out");
                 }
                 lex_close(parser->lex);
diff --git a/tests/diag/semicolon.qc b/tests/diag/semicolon.qc
new file mode 100644 (file)
index 0000000..3f0b591
--- /dev/null
@@ -0,0 +1,3 @@
+void foo() {
+       float a
+}
diff --git a/tests/diag/semicolon.tmpl b/tests/diag/semicolon.tmpl
new file mode 100644 (file)
index 0000000..16c0b3b
--- /dev/null
@@ -0,0 +1,7 @@
+I: semicolon.qc
+D: test diagnostics: expected semicolon
+T: -diagnostic
+C: -std=gmqcc
+M: expected semicolon
+M:     3:  float a
+M:               ~^
diff --git a/tests/diag/semienum.qc b/tests/diag/semienum.qc
new file mode 100644 (file)
index 0000000..143de80
--- /dev/null
@@ -0,0 +1,3 @@
+enum {
+       A, B
+}
diff --git a/tests/diag/semienum.tmpl b/tests/diag/semienum.tmpl
new file mode 100644 (file)
index 0000000..954e257
--- /dev/null
@@ -0,0 +1,8 @@
+I: semienum.qc
+D: test diagnostics: expected semicolon (enum)
+T: -diagnostic
+C: -std=gmqcc
+M: expected semicolon after enumeration
+M:     4: }
+M:        ~^
+M: unexpected eof