aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorNicolai Stange <nicstange@gmail.com>2016-02-01 03:42:10 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-31 02:27:12 +0200
commit722199c0867a391df6ba78b4ca57ee93f71b6e42 (patch)
tree15db3642e9a1c8c9af0ec1d6583c3e75cceb1331 /validation
parenta39fedb0d7bf128bbef74c9a618f4ee6fe875a92 (diff)
downloadsparse-dev-722199c0867a391df6ba78b4ca57ee93f71b6e42.tar.gz
constexpr: recognize references to labels as address constants
As an extension, GCC allows labels to be referenced a la label1: ... void *ptr = &&label1; Tag these label references as being address constants allowing them to be used as initializers for objects of static storage duration. Signed-off-by: Nicolai Stange <nicstange@gmail.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/constexpr-labelref.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/validation/constexpr-labelref.c b/validation/constexpr-labelref.c
new file mode 100644
index 00000000..15b5293a
--- /dev/null
+++ b/validation/constexpr-labelref.c
@@ -0,0 +1,14 @@
+static void a(void)
+{
+label1:
+ ;
+ static void *b = &&label1;
+}
+
+/*
+ * check-name: label reference constness verification.
+ * check-command: sparse -Wconstexpr-not-const $file
+ *
+ * check-error-start
+ * check-error-end
+ */