diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-04-13 14:39:52 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-04-13 14:39:52 +0200 |
commit | c51a0382202e992c1d0c4fa87fad7eb625a73a2a (patch) | |
tree | 50e0ec858cac6d559e11a1e62c72a8e8b56c2c95 | |
parent | 0f5a39dcea89c66236c04815b77b107763873431 (diff) | |
parent | a606990219d5a278cd3cda97d1e95b9728069098 (diff) | |
download | sparse-c51a0382202e992c1d0c4fa87fad7eb625a73a2a.tar.gz |
Merge branch 'fix-atomic-type'
* fix type compatibility of _Atomic types
-rw-r--r-- | symbol.h | 6 | ||||
-rw-r--r-- | validation/c11-atomic.c | 58 | ||||
-rw-r--r-- | validation/typeof-mods.c | 2 |
3 files changed, 41 insertions, 25 deletions
@@ -253,10 +253,10 @@ struct symbol { #define MOD_SIGNEDNESS (MOD_SIGNED | MOD_UNSIGNED | MOD_EXPLICITLY_SIGNED) #define MOD_SPECIFIER MOD_SIGNEDNESS #define MOD_IGNORE (MOD_STORAGE | MOD_ACCESS | MOD_USERTYPE | MOD_EXPLICITLY_SIGNED | MOD_EXT_VISIBLE) -#define MOD_QUALIFIER (MOD_CONST | MOD_VOLATILE | MOD_RESTRICT | MOD_ATOMIC) -#define MOD_PTRINHERIT (MOD_QUALIFIER | MOD_NODEREF | MOD_NORETURN | MOD_NOCAST) +#define MOD_QUALIFIER (MOD_CONST | MOD_VOLATILE | MOD_RESTRICT) +#define MOD_PTRINHERIT (MOD_QUALIFIER | MOD_ATOMIC | MOD_NODEREF | MOD_NORETURN | MOD_NOCAST) /* modifiers preserved by typeof() operator */ -#define MOD_TYPEOF (MOD_QUALIFIER | MOD_NOCAST | MOD_SPECIFIER) +#define MOD_TYPEOF (MOD_QUALIFIER | MOD_ATOMIC | MOD_NOCAST | MOD_SPECIFIER) /* modifiers for function attributes */ #define MOD_FUN_ATTR (MOD_PURE|MOD_NORETURN) /* like cvr-qualifiers but 'reversed' (OK: source <= target) */ diff --git a/validation/c11-atomic.c b/validation/c11-atomic.c index 17720861..85461f64 100644 --- a/validation/c11-atomic.c +++ b/validation/c11-atomic.c @@ -6,7 +6,7 @@ void f03(int _Atomic *dst); int _Atomic qo; int uo; -void f00(int dst) { } /* check-should-pass */ +void f00(int dst) { } /* check-should-fail */ void f01(typeof(&qo) dst) { } /* check-should-pass */ void f02(int *dst) { } /* check-should-fail */ void f03(typeof(&uo) dst) { } /* check-should-fail */ @@ -21,12 +21,12 @@ void ref(void) { const int qo; int uo; - extern const int *pqo; - extern int *puo; + const int *pqo; + int *puo; pqo = &qo; /* check-should-pass */ pqo = &uo; /* check-should-pass */ - pqo = puo; + pqo = puo; /* check-should-pass */ puo = &uo; /* check-should-pass */ @@ -36,12 +36,12 @@ void ref(void) void bar(void) { - extern int _Atomic *pqo; - extern int *puo; + int _Atomic *pqo; + int *puo; pqo = &qo; /* check-should-pass */ - pqo = &uo; /* check-should-pass */ - pqo = puo; + pqo = &uo; /* check-should-fail */ + pqo = puo; /* check-should-fail */ puo = &uo; /* check-should-pass */ @@ -51,12 +51,12 @@ void bar(void) void baz(void) { - extern typeof(&qo) pqo; - extern typeof(&uo) puo; + typeof(&qo) pqo; + typeof(&uo) puo; pqo = &qo; /* check-should-pass */ - pqo = &uo; /* check-should-pass */ - pqo = puo; + pqo = &uo; /* check-should-fail*/ + pqo = puo; /* check-should-fail */ puo = &uo; /* check-should-pass */ @@ -69,6 +69,10 @@ void baz(void) * check-command: sparse -Wno-decl $file * * check-error-start +c11-atomic.c:9:6: error: symbol 'f00' redeclared with different type (incompatible argument 1 (different modifiers)): +c11-atomic.c:9:6: void extern [addressable] [toplevel] f00( ... ) +c11-atomic.c:1:6: note: previously declared as: +c11-atomic.c:1:6: void extern [addressable] [toplevel] f00( ... ) c11-atomic.c:11:6: error: symbol 'f02' redeclared with different type (incompatible argument 1 (different modifiers)): c11-atomic.c:11:6: void extern [addressable] [toplevel] f02( ... ) c11-atomic.c:3:6: note: previously declared as: @@ -78,22 +82,34 @@ c11-atomic.c:12:6: void extern [addressable] [toplevel] f03( ... ) c11-atomic.c:4:6: note: previously declared as: c11-atomic.c:4:6: void extern [addressable] [toplevel] f03( ... ) c11-atomic.c:33:13: warning: incorrect type in assignment (different modifiers) -c11-atomic.c:33:13: expected int *extern [assigned] puo +c11-atomic.c:33:13: expected int *[assigned] puo c11-atomic.c:33:13: got int const * c11-atomic.c:34:13: warning: incorrect type in assignment (different modifiers) -c11-atomic.c:34:13: expected int *extern [assigned] puo -c11-atomic.c:34:13: got int const *extern [assigned] pqo +c11-atomic.c:34:13: expected int *[assigned] puo +c11-atomic.c:34:13: got int const *[assigned] pqo +c11-atomic.c:43:13: warning: incorrect type in assignment (different modifiers) +c11-atomic.c:43:13: expected int [atomic] *[assigned] pqo +c11-atomic.c:43:13: got int * +c11-atomic.c:44:13: warning: incorrect type in assignment (different modifiers) +c11-atomic.c:44:13: expected int [atomic] *[assigned] pqo +c11-atomic.c:44:13: got int *puo c11-atomic.c:48:13: warning: incorrect type in assignment (different modifiers) -c11-atomic.c:48:13: expected int *extern [assigned] puo +c11-atomic.c:48:13: expected int *[assigned] puo c11-atomic.c:48:13: got int [atomic] * c11-atomic.c:49:13: warning: incorrect type in assignment (different modifiers) -c11-atomic.c:49:13: expected int *extern [assigned] puo -c11-atomic.c:49:13: got int [atomic] *extern [assigned] pqo +c11-atomic.c:49:13: expected int *[assigned] puo +c11-atomic.c:49:13: got int [atomic] *[assigned] pqo +c11-atomic.c:58:13: warning: incorrect type in assignment (different modifiers) +c11-atomic.c:58:13: expected int [atomic] *[assigned] pqo +c11-atomic.c:58:13: got int * +c11-atomic.c:59:13: warning: incorrect type in assignment (different modifiers) +c11-atomic.c:59:13: expected int [atomic] *[assigned] pqo +c11-atomic.c:59:13: got int *puo c11-atomic.c:63:13: warning: incorrect type in assignment (different modifiers) -c11-atomic.c:63:13: expected int *extern [assigned] puo +c11-atomic.c:63:13: expected int *[assigned] puo c11-atomic.c:63:13: got int [atomic] * c11-atomic.c:64:13: warning: incorrect type in assignment (different modifiers) -c11-atomic.c:64:13: expected int *extern [assigned] puo -c11-atomic.c:64:13: got int [atomic] *extern [assigned] pqo +c11-atomic.c:64:13: expected int *[assigned] puo +c11-atomic.c:64:13: got int [atomic] *[assigned] pqo * check-error-end */ diff --git a/validation/typeof-mods.c b/validation/typeof-mods.c index aa880f37..117269c0 100644 --- a/validation/typeof-mods.c +++ b/validation/typeof-mods.c @@ -102,7 +102,7 @@ static void test_static(void) static void test_tls(void) { - __thread int obj, *ptr; + static __thread int obj, *ptr; typeof(obj) var = obj; typeof(ptr) ptr2 = ptr; typeof(*ptr) var2 = obj; |