aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--preprocess.c3
-rw-r--r--tests/083.sh11
2 files changed, 14 insertions, 0 deletions
diff --git a/preprocess.c b/preprocess.c
index 066a77f..5b7c180 100644
--- a/preprocess.c
+++ b/preprocess.c
@@ -945,6 +945,9 @@ void process_pp_directives(Preprocessor* pp) {
} else if ((next_tok = process_define_directive(pp, tok)) != NULL) {
tok = next_tok;
continue;
+ } else {
+ fatal_error("%s:%d: unknown preprocessor directive (%s)", tok->loc.filename, tok->loc.line,
+ token_stringify(tok + 1));
}
} else if (skip_pp_tokens(pp)) {
make_token_whitespace(tok);
diff --git a/tests/083.sh b/tests/083.sh
new file mode 100644
index 0000000..8047f1f
--- /dev/null
+++ b/tests/083.sh
@@ -0,0 +1,11 @@
+set -e
+
+cat <<'EOF' > expected
+main.c:1: unknown preprocessor directive (foo (<identifier>))
+EOF
+
+bash ../../test_compile_error.sh <<'EOF'
+#foo
+
+int main() {}
+EOF