aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-11-17 02:23:58 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-11-20 21:36:50 +0100
commit9305d48da0890d578254bd0e671e55a30b77ced0 (patch)
tree1bcc974cd75b96ba6d489e3f6b59742011f1ab69 /validation
parent009181de300b2f0e6f9e64d4694e07aa12808c57 (diff)
downloadsparse-dev-9305d48da0890d578254bd0e671e55a30b77ced0.tar.gz
propagate function modifiers only to functions
Function attributes need to be parsed differently than the usual specifiers: For example, in code like: #define __noreturn __attribute__((noreturn)) __noreturn void foo(int a); the __noreturn attribute should apply to the function type while a specifier like 'const' would apply to its return type. The situation is quite similar to how storage specifiers must not be handled by alloc_indirect_symbol(). However, the solution used for storage specifiers (apply the modifier bits only after the declarator is reached: cfr.commit 233d4e17c ("function attributes apply to the function declaration")) can't be used here (because the storage modifiers can be applied to the outermost declarator and function attributes may be applied more deeply if function pointers are present). Fix this by: 1) reverting the previous storage-specifier-like solution 2) collect function specifiers MODs in a new separate field in the declaration context (f_modifiers) 3) apply these modifiers when the declarator for the function type is reached (note: it must not be applied to the SYM_FN itself since this correspond to the function's return type; it must be applied to the parent node which can be a SYM_NODE or a SYM_PTR). 4) also apply these modifiers to the declared symbol, if this symbol is a function declaration, to take into account attributes which are placed at the end of the declaration and not in front. Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Fixes: 233d4e17c544e1de252aed8f409630599104dbc7 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/function-attribute-inner.c1
-rw-r--r--validation/function-attribute-pointer.c1
2 files changed, 0 insertions, 2 deletions
diff --git a/validation/function-attribute-inner.c b/validation/function-attribute-inner.c
index 178c7c01..3a8a8407 100644
--- a/validation/function-attribute-inner.c
+++ b/validation/function-attribute-inner.c
@@ -6,5 +6,4 @@ _Static_assert([void (__noreturn *)(void)] == [typeof(&fun)], "");
/*
* check-name: function-attribute-inner
- * check-known-to-fail
*/
diff --git a/validation/function-attribute-pointer.c b/validation/function-attribute-pointer.c
index 27f43bfb..fd08ac71 100644
--- a/validation/function-attribute-pointer.c
+++ b/validation/function-attribute-pointer.c
@@ -21,7 +21,6 @@ static void foo(void)
/*
* check-name: function-attribute-pointer
- * check-known-to-fail
*
* check-error-start
function-attribute-pointer.c:14:20: warning: incorrect type in argument 1 (different modifiers)