aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorXi Wang <xi.wang@gmail.com>2012-06-03 16:01:46 -0400
committerChristopher Li <sparse@chrisli.org>2012-06-04 16:06:33 -0700
commit64a6b4c61faa23c40a402656d044141a669965a3 (patch)
tree21cadcc042e6cd19388fb547cfc65acb91ff5c3d /validation
parent4c982e9d3c6827afb529c7c7ce7fbe987eac24c6 (diff)
downloadsparse-dev-64a6b4c61faa23c40a402656d044141a669965a3.tar.gz
check missing or duplicate goto labels
This patch sets ->stmt of a SYM_LABEL to the corresponding label statement. If ->stmt was already set, it is a duplicate label. On the other hand, if ->stmt of a goto label is not set during evaluation, the label was never declared. Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation')
-rw-r--r--validation/goto-label.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/validation/goto-label.c b/validation/goto-label.c
new file mode 100644
index 00000000..1196fdef
--- /dev/null
+++ b/validation/goto-label.c
@@ -0,0 +1,29 @@
+void foo(void)
+{
+ goto a;
+a:
+a:
+ return;
+}
+
+void g(void)
+{
+ goto a;
+a:
+ return;
+}
+
+void bar(void)
+{
+ goto neverland;
+}
+
+/*
+ * check-name: goto labels
+ *
+ * check-error-start
+goto-label.c:5:1: error: label 'a' redefined
+goto-label.c:18:9: error: label 'neverland' was not declared
+ * check-error-end
+ */
+