aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-10 01:32:55 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-19 18:07:33 +0200
commit50917d27ebf9c7b476914d2b269d0cb7ac3b19ac (patch)
tree1b5d34af0cad2f1487f3c2976470dd1ad1bfbb0d
parent08f2b69e8c90efdd6bcb72cd126010ad87489985 (diff)
downloadsparse-50917d27ebf9c7b476914d2b269d0cb7ac3b19ac.tar.gz
builtin: add support for __atomic_clear()
The first argument is supposed to be a pointer to a bool, but of course, a volatile qualified pointer should be accepted too. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--builtin.c1
-rw-r--r--validation/builtin-atomic-clear.c15
2 files changed, 16 insertions, 0 deletions
diff --git a/builtin.c b/builtin.c
index 1a95018c..b481a810 100644
--- a/builtin.c
+++ b/builtin.c
@@ -483,6 +483,7 @@ static const struct builtin_fn builtins_common[] = {
#define vol_ptr &volatile_ptr_ctype
{ "__atomic_add_fetch", NULL, 0, { vol_ptr, &dyntype, &int_ctype }, .op = &atomic_op },
{ "__atomic_and_fetch", NULL, 0, { vol_ptr, &dyntype, &int_ctype }, .op = &atomic_op },
+ { "__atomic_clear", &void_ctype, 0, { &volatile_bool_ptr_ctype, &int_ctype }},
{ "__atomic_compare_exchange", &bool_ctype, 0, { vol_ptr, &ptr_ctype, &ptr_ctype, &bool_ctype, &int_ctype, &int_ctype }, .op = &atomic_op },
{ "__atomic_compare_exchange_n", &bool_ctype, 0, { vol_ptr, &ptr_ctype, &dyntype, &bool_ctype, &int_ctype, &int_ctype }, .op = &atomic_op },
{ "__atomic_exchange", &void_ctype, 0, { vol_ptr, &ptr_ctype, &ptr_ctype, &int_ctype }, .op = &atomic_op },
diff --git a/validation/builtin-atomic-clear.c b/validation/builtin-atomic-clear.c
new file mode 100644
index 00000000..ef430c64
--- /dev/null
+++ b/validation/builtin-atomic-clear.c
@@ -0,0 +1,15 @@
+void foo(void *ptr, _Bool *bptr, volatile void *vptr, volatile _Bool *vbptr, int mo)
+{
+ __atomic_clear(ptr, mo);
+ __atomic_clear(bptr, mo);
+ __atomic_clear(vptr, mo);
+ __atomic_clear(vbptr, mo);
+}
+
+/*
+ * check-name: builtin-atomic-clear
+ *
+ * check-error-start
+builtin-atomic-clear.c:1:6: warning: symbol 'foo' was not declared. Should it be static?
+ * check-error-end
+ */