aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* parser: add Blackfin gcc infoMike Frysinger2010-10-081-0/+6
| | | | | | | | | The Blackfin port uses some custom attributes to control memory placement, and it has some custom builtins. So add the ones that the kernel actually utilizes to avoid massive build errors with sparse. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
* skip may_alias and declare builtin_fabsMorten Welinder2010-07-191-0/+2
| | | | | Signed-off-by: Morten Welinder <terra@gnome.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
* parser: fix and simplify support of asm gotoJiri Slaby2010-07-131-1/+2
| | | | | | | | | | 1) We now handle only "asm (volatile|goto)?", whereas "asm volatile? goto?" is correct. 2) We need to match only goto_ident, so do it explicitly against token->ident without match_idents. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Christopher <sparse@chrisli.org>
* parser: add support for asm gotoJiri Slaby2010-06-171-0/+23
| | | | | | | | | As of gcc 4.5, asm goto("jmp %l[label]" : OUT : IN : CLOB : LABELS) is supported. Add this support to the parser so that it won't choke on the newest Linux kernel when compiling with gcc 4.5. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Ignore the may_alias GCC attributeDamien Lespiau2010-06-171-0/+2
| | | | | | | | may_alias is used in the wild (glib) and makes sparse spew a lot of unhelpful warning messages. Ignore it (for now?). Signed-off-by: Damien Lespiau <damien.lespiau@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Pointer don't inherent the alignment from base typeChristopher Li2010-03-281-0/+1
| | | | Signed-off-by: Christopher Li <sparse@chrisli.org>
* Ignore "naked" attributeMichael Buesch2010-03-281-0/+2
| | | | | | | | | | The GCC "naked" attribute is used on certain architectures to generate functions without a prologue/epilogue. Ignore it in sparse. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: Christopher Li <sparse@chrisli.org>
* ignore attributes "externally_visible" and "signal"Michael Buesch2010-03-281-0/+4
| | | | | | | | | | | | This adds more ignored gcc-style attributes. externally_visible is a standard gcc attribute. signal is an AVR8 attribute used to define interrupt service routines. Ignore these attributes, as they are currently not useful for sparse checking. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: Christopher Li <sparse@chrisli.org>
* New attribute designated_init: mark a struct as requiring designated initJosh Triplett2010-03-281-0/+15
| | | | | | | | | | | | | | | | | | | | | | | Some structure types provide a set of fields of which most users will only initialize the subset they care about. Users of these types should always use designated initializers, to avoid relying on the specific structure layout. Examples of this type of structure include the many *_operations structures in Linux, which contain a set of function pointers; these structures occasionally gain a new field, lose an obsolete field, or change the function signature for a field. Add a new attribute designated_init; when used on a struct, it tells Sparse to warn on any positional initialization of a field in that struct. The new flag -Wdesignated-init controls these warnings. Since these warnings only fire for structures explicitly tagged with the attribute, enable the warning by default. Includes documentation and test case. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Handle __builtin_ms_va_list.Michael Stefaniuc2010-03-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | For Win64 compiles Wine does #ifndef __ms_va_list # if defined(__x86_64__) && defined (__GNUC__) # define __ms_va_list __builtin_ms_va_list # define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg) # define __ms_va_end(list) __builtin_ms_va_end(list) # else Wouldn't be as bad if sparse cannot handle those but it trips over WINBASEAPI DWORD WINAPI FormatMessageA(DWORD,LPCVOID,DWORD,DWORD,LPSTR,DWORD,__ms_va_list*); WINBASEAPI DWORD WINAPI FormatMessageW(DWORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,__ms_va_list*); producing this errors for basically every file: wine/include/winbase.h:1546:96: error: Expected ) in function declarator wine/include/winbase.h:1546:96: error: got * wine/include/winbase.h:1547:97: error: Expected ) in function declarator wine/include/winbase.h:1547:97: error: got * Signed-off-by: Michael Stefaniuc <mstefaniuc@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Ignore the alloc_size attribute.Michael Stefaniuc2010-03-281-0/+2
| | | | | | | | | Wine has annotated the Win32 alloc functions with the alloc_size attribute. This cuts down the noise a lot when running sparse on the Wine source code. Signed-off-by: Michael Stefaniuc <mstefaniuc@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Ignore the ms_abi/sysv_abi attributes.Michael Stefaniuc2010-03-281-0/+4
| | | | | | | | | | | | | This is needed for getting a meaningful sparse run on a Wine 64-bit compile. Else the basic Win32 headers will produce tons of error: attribute 'ms_abi': unknown attribute which end in error: too many errors. The sysv_abi attribute was just added for symmetry. Signed-off-by: Michael Stefaniuc <mstefaniuc@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Declare ignored attributres into a list of string.Christopher Li2010-03-281-71/+82
| | | | | | Adding ignored attributes is much easier now. Signed-off-by: Christopher Li <sparse@chrisli.org>
* Move noreturn attribute out of ignore attr areaChristopher Li2010-03-281-2/+2
| | | | Signed-off-by: Christopher Li <sparse@chrisli.org>
* do not ignore attribute 'noreturn'...Kamil Dudka2009-10-161-2/+2
| | | | | | | | | | | | | | | | | | | | | Hello, enclosed is a simple patch adding support for attribute 'noreturn' to the parser. The enhancement makes it possible to optimize walk through CFG and thus help us to fight with the state explosion. The benefit is demonstrated on a simple real-world example. Generated CFG before patch: http://dudka.cz/devel/html/slsparse-before/slplug.c-handle_stmt_assign.svg Generated CFG after patch: http://dudka.cz/devel/html/slsparse-after/slplug.c-handle_stmt_assign.svg It's one of the key features I am currently missing in SPARSE in contrast to gcc used as parser. Thanks in advance for considering it! Signed-off-by: Kamil Dudka <kdudka@redhat.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Add support for TImode type (__int128_t)Blue Swirl2009-08-011-3/+22
| | | | | | | | | | GCC provides a 128 bit type called internally as TImode (__int128_t)on 64 bit platforms (at least x86_64 and Sparc64). These types are used by OpenBIOS. Add support for types "long long long", __mode__(TI) and __(u)int128_t. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Ignore attribute __bounded__, used by OpenBSD headers.Blue Swirl2009-08-031-0/+2
| | | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Avoid "attribute 'warning': unknown attribute" warningLinus Torvalds2009-07-181-0/+2
| | | | | | | | | | | | | This avoids getting annoying warnings from <curl/typecheck-gcc.h> and from <bits/string3.h>, which use the "__attribute__((__warning__ (msg)))" gcc attribute. [ The attribute causes gcc to print out the supplied warning message if the function is used. We should some day support it, but this patch just makes us ignore it. ] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Allow array declarators to have 'restrict' in themLinus Torvalds2009-07-181-0/+2
| | | | | | | | | | | | Otherwise sparse is very unhappy about the current glibc header files (aio.h, netdb.h. regex.h and spawn.h at a minimum). It's a hack, and not a proper parsing with saving the information. It just ignores any "restrict" keyword at the start of an abstract array declaration, but it's better than what we have now. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Support the __thread storage classAlberto Bertogli2009-07-181-3/+31
| | | | | | | | | | GCC supports a __thread storage class, used to indicate thread-local storage. It may be used alone, or with extern or static. This patch makes sparse aware of it, and check those restrictions. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Print an error if typeof() lacks an argumentMartin Nagy2009-07-181-1/+5
| | | | | | | | We weren't checking if the initializer isn't NULL, which caused sparse to segfault later on when performing lazy evaluation in classify_type(). Signed-off-by: Martin Nagy <nagy.martin@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Add missing checks for Waddress-spaceMartin Nagy2009-07-181-1/+1
| | | | | | | | | | Remove all previous checks for Waddress_space and add one centralized to the address_space attribute handler. If user passes the -Wno-address-space option, we behave as if every pointer had no address space. Signed-off-by: Martin Nagy <nagy.martin@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Segfault at evaluate.c:341Al Viro2009-07-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | On Thu, Mar 19, 2009 at 09:52:50PM +0000, Al Viro wrote: Yeah... It's an old b0rken handling of calls for K&R + changes that exposed that even worse. Status quo is restored by the patch below, but it's a stopgap - e.g. void f(); void g(void) { f(0, 0); } will warn about extra arguments as if we had void f(void); as sparse had been doing all along. B0rken. Testcase for the segfault is void f(x, y); void g(void) { f(0, 0); } Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Sanitize pointer()Al Viro2009-07-181-15/+5
| | | | | | | | | There's no need to concat the context list into (empty) one of new node, only to free the original one. Moving the pointer to list instead works fine... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <chrisl@hera.kernel.org>
* Don't mix storage class bits with ctype->modifiers while parsing typeAl Viro2009-07-181-29/+78
| | | | | | | | | | | | | Keep storage class (and "is it inline") explicitly in decl_state; translate to modifiers only when we are done with parsing. That avoids the need to separate MOD_STORAGE bits while constructing the type (e.g. in alloc_indirect_symbol(), etc.). It also allows to get rid of MOD_FORCE for good - instead of passing it to typename() we pass an int * and let typename() tell whether we'd got a force-cast. Indication of force-cast never makes it into the modifier bits at all. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <chrisl@hera.kernel.org>
* Simplify get_number_value() and ctype_integer()Al Viro2009-07-181-11/+2
| | | | | | | | | | | There's no point whatsoever in constructing modifiers for chosen type when decoding integer constant only to have them picked apart by ctype_integer(). Seeing that the former is the only caller of the latter these days, we can bloody well just pass the rank and signedness explicitly and save a lot of efforts. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <chrisl@hera.kernel.org>
* Fix __label__ handlingAl Viro2009-07-181-28/+27
| | | | | | | | | | | | a) __label__ in gcc is not a type, it's a statement. Accepted in the beginning of compound-statement, has form __label__ ident-list; b) instead of crapping into NS_SYMBOL namespace (and consequent shadowing issues), reassign the namespace to NS_LABEL after we'd bound it. We'll get block scope and label namespace, i.e. what we get in gcc. c) MOD_LABEL can be dropped now. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Fix declaration_specifiers() handling of typedef name shadowed by NS_SYMBOLAl Viro2009-07-181-2/+3
| | | | | | | | | | | | | | | | | | | | | Doing lookup_symbol() with NS_TYPEDEF will happily skip the redeclarations of the same identifier with NS_SYMBOL. We need to check that we are not dealing with something like typedef int T; void f(int T) { static T a; /* not a valid declaration - T is not a typedef name */ or similar (e.g. enum member shadowing a typedef, etc.). While we are at it, microoptimize similar code in lookup_type() - instead of sym->namespace == NS_TYPEDEF we can do sym->namespace & NS_TYPEDEF; the former will turn into "fetch 32bit value, mask all but 9 bits, compare with NS_TYPEDEF", the latter - "check that one bit in 32bit value is set". We never mix NS_TYPEDEF with anything in whatever->namespace, so the tests are equivalent. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Fix enumeration constants' scope beginningAl Viro2009-07-181-4/+3
| | | | | | | | | | | | | | It starts after the end of enumerator; i.e. if we have enum { ... Foo = expression, ... }; the scope of Foo starts only after the end of expression. Rationale: 6.2.1p7. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Restore __attribute__((mode)) handlingAl Viro2009-07-181-21/+97
| | | | | | | | | | | ... at least to the extent we used to do it. It still does _not_ cover the perversions gcc can do with that, but at least it deals with regressions. Full solution will have to wait for full-blown imitation of what gcc people call __attribute__ semantics, the bastards... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Pass decl_state down to ->attribute()Al Viro2009-07-181-18/+19
| | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Pass decl_state down to ->declarator() and handle_attributes()Al Viro2009-07-171-48/+48
| | | | | | | | | | | Other than for attributes of labels (completely ignored, and we can simply use skip_attributes() there), all callers of handle_attributes actually get ctype == &ctx->ctype for some ctx. Ditto for ->declarator(). Switch both to passing ctx instead (has to be done at the same time, since we have handle_attributes() called from ->declarator() for struct). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Clean up and split declaration_specifiers()Al Viro2009-07-171-30/+29
| | | | | | | | | At this point there's not much in common between qualifiers-only and full cases; easier to split the sucker in two and lose the qual argument. Clean it up, while we are at it... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Have ->declarator() act directly on ctype being affectedAl Viro2009-07-171-73/+161
| | | | | | | ... and don't do full-blown apply_ctype() every damn time. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Rewrite and fix specifiers handlingAl Viro2009-07-171-160/+207
| | | | | | | | | | | | | | | | | | | | Make sure that we accept the right set; kill ad-hackery around checks for banned combinations. Instead of that we keep a bitmap describing what we'd already seen (with several extra bits for 'long long' and for keeping track of can't-combine-with-anything stuff), check and update it using the values in ..._op and keep track of size modifiers more or less explicitly. Testcases added. A _lot_ of that used to be done wrong. Note that __attribute__((mode(...))) got more broken by this one; the next several changesets will take care of that. One more thing: we are -><- close to getting rid of MOD_SPECIFIER bits for good. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Saner type for __builtin_va_listAl Viro2009-07-171-1/+1
| | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Take the rest of specifiers to parse.cAl Viro2009-07-171-2/+26
| | | | | | | ... and yes, right now it's ucking fugly. Will get sanitized shortly. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* preparations to ->declarator() cleanup - separate typedef handlingAl Viro2009-07-171-9/+11
| | | | | | | | | | Take typedef handling in declaration_specifiers() into separate branch; kill useless check for qual in case the type we've got has non-NULL base_type (we'd have already buggered off in that situation before we get to the check in question). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Fix handling of typedefs with several declaratorsAl Viro2009-07-171-0/+3
| | | | | | | | | | We set MOD_USERTYPE only on the first one, so declaration_specifiers didn't recognize something like unsigned P; where P had been such a typedef as redefinition (see the testcase). Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Take the rest of storage class keywords to parse.cAl Viro2009-07-171-0/+6
| | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Fix regression created by commit af30c6df74f01db10fa78ac0cbdb5c3c40b5c73fAl Viro2009-07-171-0/+2
| | | | | | | const and friends are reserved words, TYVM... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Propagate decl_state to declaration_specifiers()Al Viro2009-07-171-37/+37
| | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Separating ctype and parser state, part 1Al Viro2009-07-171-44/+54
| | | | | | | | | | | Introduce struct decl_state that will hold the declaration parser state. Pass it to declarator() and direct_declarator(). Note that at this stage we are putting more stuff on stack *and* get extra copying; that's temporary and we'll deal with that in subsequent patches. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Sanitize direct_declarator logicsAl Viro2009-07-171-75/+65
| | | | | | | | a) handling of nested declarator does not belong in the loop, for fsck sake b) functions and arrays don't mix (and functions don't mix with functions) Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Fix braino in which_kind()Al Viro2009-07-171-1/+1
| | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Don't mess with passing symbol to declarator/direct_declaratorAl Viro2009-07-171-16/+14
| | | | | | | | There's no reason to pass symbol to declarator/direct_declarator; we only use &sym->ctype, so passing ctype * is fine. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Leave applying attributes until we know whether it's a nested declaratorAl Viro2009-07-171-23/+63
| | | | | | | | | | Don't mess with applying attributes in which_kind(); leave that until we know whether that's function declarator or a nested one. We'll need that to deal with scopes properly. Clean parameter_type_list() and parameter_declaration(), get rid of a leak. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Apply attributes after ( to the right placeAl Viro2009-07-171-8/+15
| | | | | | | In int f(__user int *p) __user applies to p, not to f... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* Warn about non-empty identifier list outside of definitionAl Viro2009-07-171-2/+10
| | | | | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
* more direct_declarator() sanitizingAl Viro2009-07-171-51/+87
| | | | | | | | | | | | | | | * new helper function - which_kind(). Finds how to parse what follows ( in declarator. * parameter-type-list and identifier-list handling separated and cleaned up. * saner recovery from errors * int f(__attribute__((....)) x) is prohibited by gcc syntax; attributes are not allowed in K&R identifier list, obviously, and gcc refused to treat that as "int is implicit if missing" kind of case. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>