[C++] Error for missing endif
A fix for https://github.com/google/kati/issues/55
diff --git a/parser.cc b/parser.cc
index 4b4012e..96b8ba3 100644
--- a/parser.cc
+++ b/parser.cc
@@ -87,6 +87,9 @@
l_ = e + 1;
}
+
+ if (!if_stack_.empty())
+ ERROR("%s:%d: *** missing `endif'.", loc_.filename, loc_.lineno + 1);
}
static void Init() {
diff --git a/testcase/err_missing_endif.mk b/testcase/err_missing_endif.mk
new file mode 100644
index 0000000..14cbf7c
--- /dev/null
+++ b/testcase/err_missing_endif.mk
@@ -0,0 +1,3 @@
+all:
+ echo FAIL
+ifdef foo