aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
Diffstat (limited to 'validation')
-rw-r--r--validation/bitfields.c18
-rw-r--r--validation/struct-as.c16
2 files changed, 34 insertions, 0 deletions
diff --git a/validation/bitfields.c b/validation/bitfields.c
new file mode 100644
index 00000000..292a110b
--- /dev/null
+++ b/validation/bitfields.c
@@ -0,0 +1,18 @@
+/*
+ * Al Viro points out that we don't
+ * do bitfield -> integer promotions
+ * for array dereferences
+ *
+ * "warning: a.c:16:10: incompatible types for operation"
+ */
+struct {
+ int x:4;
+} y;
+
+extern int a[];
+
+int b(void)
+{
+ return a[y.x];
+}
+
diff --git a/validation/struct-as.c b/validation/struct-as.c
new file mode 100644
index 00000000..f5752f0c
--- /dev/null
+++ b/validation/struct-as.c
@@ -0,0 +1,16 @@
+/*
+ * Structure members should get the address
+ * space of their pointer.
+ */
+#define __user __attribute__((address_space(1)))
+
+struct hello {
+ int a;
+};
+
+extern int test(int __user *ip);
+
+int broken(struct hello __user *sp)
+{
+ test(&sp->a);
+}