diff options
-rw-r--r-- | Documentation/TODO.md | 12 | ||||
-rw-r--r-- | Documentation/nocast-vs-bitwise.md | 34 | ||||
-rwxr-xr-x | Documentation/sphinx/cdoc.py | 10 | ||||
-rw-r--r-- | machine.h | 2 | ||||
-rw-r--r-- | parse.c | 26 | ||||
-rw-r--r-- | symbol.h | 5 | ||||
-rw-r--r-- | validation/attr-visible.c | 1 | ||||
-rw-r--r-- | validation/attr-visible2.c | 1 |
8 files changed, 38 insertions, 53 deletions
diff --git a/Documentation/TODO.md b/Documentation/TODO.md index cbda1c39..4344a1dc 100644 --- a/Documentation/TODO.md +++ b/Documentation/TODO.md @@ -24,15 +24,9 @@ Core - add the sym into a list and - recalculate the addressability before memops's SSA conversion * bool_ctype should be split into internal 1-bit / external 8-bit -* Previous declarations and the definition need to be merged. For example, - in the code here below, the function definition is **not** static: - ``` - static void foo(void); - void foo(void) { ... } - ``` Testsuite --------- +--------- * there are more than 50 failing tests. They should be fixed (but most are non-trivial to fix). @@ -84,9 +78,13 @@ Longer term/to investigate * should support "-Werror=..." ? * All warning messages should include the option how to disable it. For example: + "warning: Variable length array is used." + should be something like: + "warning: Variable length array is used. (-Wno-vla)" + * ptrlists must have elements be removed while being iterated but this is hard to insure it is not done. * having 'struct symbol' used to represent symbols *and* types is diff --git a/Documentation/nocast-vs-bitwise.md b/Documentation/nocast-vs-bitwise.md index b649abcd..9ba5a789 100644 --- a/Documentation/nocast-vs-bitwise.md +++ b/Documentation/nocast-vs-bitwise.md @@ -1,4 +1,5 @@ -# __nocast vs __bitwise +__nocast vs __bitwise +===================== `__nocast` warns about explicit or implicit casting to different types. HOWEVER, it doesn't consider two 32-bit integers to be different @@ -16,25 +17,26 @@ harder to lose the type by mistake. So the basic rule is: - - `__nocast` on its own tends to be more useful for *big* integers -that still need to act like integers, but you want to make it much -less likely that they get truncated by mistake. So a 64-bit integer -that you don't want to mistakenly/silently be returned as `int`, for -example. But they mix well with random integer types, so you can add -to them etc without using anything special. However, that mixing also -means that the `__nocast` really gets lost fairly easily. - - - `__bitwise` is for *unique types* that cannot be mixed with other -types, and that you'd never want to just use as a random integer (the -integer `0` is special, though, and gets silently accepted - it's -kind of like `NULL` for pointers). So `gfp_t` or the `safe endianness` -types would be `__bitwise`: you can only operate on them by doing -specific operations that know about *that* particular type. +- `__nocast` on its own tends to be more useful for *big* integers + that still need to act like integers, but you want to make it much + less likely that they get truncated by mistake. So a 64-bit integer + that you don't want to mistakenly/silently be returned as `int`, for + example. But they mix well with random integer types, so you can add + to them etc without using anything special. However, that mixing also + means that the `__nocast` really gets lost fairly easily. + +- `__bitwise` is for *unique types* that cannot be mixed with other + types, and that you'd never want to just use as a random integer (the + integer `0` is special, though, and gets silently accepted - it's + kind of like `NULL` for pointers). So `gfp_t` or the `safe endianness` + types would be `__bitwise`: you can only operate on them by doing + specific operations that know about *that* particular type. Generally, you want `__bitwise` if you are looking for type safety. `__nocast` really is pretty weak. -## Reference: +Reference: +---------- * Linus' e-mail about `__nocast` vs `__bitwise`: diff --git a/Documentation/sphinx/cdoc.py b/Documentation/sphinx/cdoc.py index 318e9b23..73c128cb 100755 --- a/Documentation/sphinx/cdoc.py +++ b/Documentation/sphinx/cdoc.py @@ -269,7 +269,7 @@ if __name__ == '__main__': dump_doc(extract(sys.stdin, '<stdin>')) -from sphinx.ext.autodoc import AutodocReporter +from sphinx.util.docutils import switch_source_input import docutils import os class CDocDirective(docutils.parsers.rst.Directive): @@ -294,13 +294,13 @@ class CDocDirective(docutils.parsers.rst.Directive): ## let parse this new reST content memo = self.state.memo - save = memo.reporter, memo.title_styles, memo.section_level - memo.reporter = AutodocReporter(lst, memo.reporter) + save = memo.title_styles, memo.section_level node = docutils.nodes.section() try: - self.state.nested_parse(lst, 0, node, match_titles=1) + with switch_source_input(self.state, lst): + self.state.nested_parse(lst, 0, node, match_titles=1) finally: - memo.reporter, memo.title_styles, memo.section_level = save + memo.title_styles, memo.section_level = save return node.children def setup(app): @@ -113,7 +113,7 @@ enum { #elif defined(__sun__) || defined(__sun) #define OS_NATIVE OS_SUNOS #elif defined(__unix__) || defined(__unix) -#define OS_UNIX OS_UNIX +#define OS_NATIVE OS_UNIX #else #define OS_NATIVE OS_UNKNOWN #endif @@ -84,7 +84,6 @@ typedef struct token *attr_t(struct token *, struct symbol *, static attr_t attribute_packed, attribute_aligned, attribute_modifier, attribute_function, - attribute_ext_visible, attribute_bitwise, attribute_address_space, attribute_context, attribute_designated_init, @@ -389,10 +388,6 @@ static struct symbol_op attr_fun_op = { .attribute = attribute_function, }; -static struct symbol_op ext_visible_op = { - .attribute = attribute_ext_visible, -}; - static struct symbol_op attr_bitwise_op = { .attribute = attribute_bitwise, }; @@ -573,6 +568,8 @@ static struct init_keyword { { "__safe__", NS_KEYWORD, MOD_SAFE, .op = &attr_mod_op }, { "unused", NS_KEYWORD, MOD_UNUSED, .op = &attr_mod_op }, { "__unused__", NS_KEYWORD, MOD_UNUSED, .op = &attr_mod_op }, + { "externally_visible", NS_KEYWORD, MOD_EXT_VISIBLE,.op = &attr_mod_op }, + { "__externally_visible__", NS_KEYWORD,MOD_EXT_VISIBLE,.op = &attr_mod_op }, { "force", NS_KEYWORD, .op = &attr_force_op }, { "__force__", NS_KEYWORD, .op = &attr_force_op }, { "bitwise", NS_KEYWORD, MOD_BITWISE, .op = &attr_bitwise_op }, @@ -592,8 +589,6 @@ static struct init_keyword { {"__const__", NS_KEYWORD, MOD_PURE, .op = &attr_fun_op }, {"gnu_inline", NS_KEYWORD, MOD_GNU_INLINE, .op = &attr_fun_op }, {"__gnu_inline__",NS_KEYWORD, MOD_GNU_INLINE, .op = &attr_fun_op }, - {"externally_visible", NS_KEYWORD, .op = &ext_visible_op }, - {"__externally_visible__", NS_KEYWORD, .op = &ext_visible_op }, { "mode", NS_KEYWORD, .op = &mode_op }, { "__mode__", NS_KEYWORD, .op = &mode_op }, @@ -1157,12 +1152,6 @@ static struct token *attribute_function(struct token *token, struct symbol *attr return token; } -static struct token *attribute_ext_visible(struct token *token, struct symbol *attr, struct decl_state *ctx) -{ - ctx->is_ext_visible = 1; - return token; -} - static struct token *attribute_bitwise(struct token *token, struct symbol *attr, struct decl_state *ctx) { if (Wbitwise) @@ -1401,15 +1390,14 @@ static unsigned long decl_modifiers(struct decl_state *ctx) }; unsigned long mods = ctx->ctype.modifiers & MOD_DECLARE; ctx->ctype.modifiers &= ~MOD_DECLARE; - return mod[ctx->storage_class] | (ctx->is_inline ? MOD_INLINE : 0) - | (ctx->is_tls ? MOD_TLS : 0) - | (ctx->is_ext_visible ? MOD_EXT_VISIBLE : 0) | mods; + return mod[ctx->storage_class] | mods; } static void set_storage_class(struct position *pos, struct decl_state *ctx, int class) { + int is_tls = ctx->ctype.modifiers & MOD_TLS; /* __thread can be used alone, or with extern or static */ - if (ctx->is_tls && (class != SStatic && class != SExtern)) { + if (is_tls && (class != SStatic && class != SExtern)) { sparse_error(*pos, "__thread can only be used alone, or with " "extern or static"); return; @@ -1460,7 +1448,7 @@ static struct token *thread_specifier(struct token *next, struct decl_state *ctx /* This GCC extension can be used alone, or with extern or static */ if (!ctx->storage_class || ctx->storage_class == SStatic || ctx->storage_class == SExtern) { - ctx->is_tls = 1; + apply_qualifier(&next->pos, &ctx->ctype, MOD_TLS); } else { sparse_error(next->pos, "__thread can only be used alone, or " "with extern or static"); @@ -1477,7 +1465,7 @@ static struct token *attribute_force(struct token *token, struct symbol *attr, s static struct token *inline_specifier(struct token *next, struct decl_state *ctx) { - ctx->is_inline = 1; + apply_qualifier(&next->pos, &ctx->ctype, MOD_INLINE); return next; } @@ -108,8 +108,7 @@ struct decl_state { struct ident **ident; struct symbol_op *mode; unsigned long f_modifiers; // function attributes - unsigned char prefer_abstract, is_inline, storage_class, is_tls; - unsigned char is_ext_visible; + unsigned char prefer_abstract, storage_class; unsigned char autotype; }; @@ -270,7 +269,7 @@ struct symbol { /* do not warn when these are duplicated */ #define MOD_DUP_OK (MOD_UNUSED|MOD_GNU_INLINE) /* must be part of the declared symbol, not its type */ -#define MOD_DECLARE (MOD_STORAGE|MOD_GNU_INLINE|MOD_UNUSED|MOD_PURE|MOD_NORETURN|MOD_EXT_VISIBLE) +#define MOD_DECLARE (MOD_STORAGE|MOD_INLINE|MOD_TLS|MOD_GNU_INLINE|MOD_UNUSED|MOD_PURE|MOD_NORETURN|MOD_EXT_VISIBLE) diff --git a/validation/attr-visible.c b/validation/attr-visible.c index 38ee8575..ce35e4e5 100644 --- a/validation/attr-visible.c +++ b/validation/attr-visible.c @@ -9,5 +9,4 @@ int flag __visible; /* * check-name: attr-visible * check-command: sparse -Wdecl $file - * check-known-to-fail */ diff --git a/validation/attr-visible2.c b/validation/attr-visible2.c index 62949b47..98918169 100644 --- a/validation/attr-visible2.c +++ b/validation/attr-visible2.c @@ -6,5 +6,4 @@ int arr[2] __visible; /* * check-name: attr-visible-after * check-command: sparse -Wdecl $file - * check-known-to-fail */ |