aboutsummaryrefslogtreecommitdiffstatshomepage
AgeCommit message (Collapse)AuthorFilesLines
2005-04-07Handle predefines for integer types, floating point types,welinder@troll.com2-7/+146
and system in cgcc.
2005-04-07Merge http://sparse-mw.bkbits.net:8080/janitorialLinus Torvalds1-1/+1
into ppc970.osdl.org:/home/torvalds/BK/sparse
2005-04-07[PATCH] graceful handling of old-style array initializersAlexander Viro1-31/+45
The current gcc initializer code is too permissive, AFAICS - [0][0] 1 will be rejected by gcc too, so we shouldn't consider it "broken gcc syntax". There was another bug in there - *ep = NULL; token = initializer(ep, token); if (!expr) break; add_expression(list, expr); would not catch the case when we have e.g. .foo = <bad expression> and we end up with list polluted by EXPR_IDENTIFIER with NULL ->ident_expression. Should be if (!*ep) instead. This also cleans it up by splitting the list handling case up from the loop, and making the single initializer parsing a function of its own.
2005-04-07Rename -Wundefined-preprocessor-symbol to -Wundef to matchwelinder@troll.com1-1/+1
gcc.
2005-04-07[PATCH] trivial sparse patch - ignore model attributeDavid Mosberger2-1/+4
Teach sparse to ignore the "model" (aka "__model__") attribute used by ia64 linux. Signed-off-by: davidm@hpl.hp.com Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07Merge bk://sparse-mw@sparse-mw.bkbits.net/solariswelinder@troll.com6-49/+89
into troll.com:/scratch/welinder/solaris
2005-04-07Warn about old-style gcc named initializers, suggesting C99 usage.Linus Torvalds1-4/+12
Most of the kernel ones have long since been converted. This might help convert the last few hold-outs.
2005-04-07Add compatibility file for solaris.welinder@troll.com6-49/+89
2005-04-07We actually _can_ have multiple initializers at offset zero.Linus Torvalds1-2/+6
It's not an error, it just is pretty rare. It happens when there are bitfields that are all at byte offset zero, and we need to allocate a new EXPR_POS when we offset these bitfields due to them being inside a nested initializer.
2005-04-07Be more lenient in placement of 'asm("reg")' variable hard-registerLinus Torvalds1-13/+17
specifiers. They now parse the same way as __attribute__ node-specifiers. This simplifies the code, and makes sparse not care about random gcc rules for exactly where one or the other can be placed.
2005-04-07[PATCH] testcase for two-argument ?:Alexander Viro1-0/+11
2005-04-07[PATCH] two-arguments ?:Alexander Viro1-23/+59
Instead of trying to handle two- and three-argument ?: in the same code, have evaluate_expression() turn the expression 'v1 ? : v2' into its equivalent of '(temp_var = v1, temp_var ? temp_var : v2)' and use the normal logics to deal with the results.
2005-04-07[PATCH] #if expression handling cleanupsAlexander Viro5-37/+27
- handling of "unexpanded identifiers should be replaced with 0" is moved to pre-process.c and done on token replacement level - warning about such replacement made conditional - expand() and expand_one_symbol() return int now - it's "is the first token completely expanded now" (simplifies the life in #if handling, etc.) - crud removed from evaluate.c and expand.c
2005-04-07[PATCH] enum handlingAlexander Viro4-20/+154
a) we allow enum have an equivalent type other than int (it is kept in ->ctype.base_type for SYM_ENUM types). Code adjusted. b) enum declaration parsing tries to determine the equivalent type; if such type does not exist we set it to &bad_enum_ctype and examine_symbol_type() generates a warning when it meets such beast. The rules for equivalent type follow: 1) if all members have the same bitwise type, it is the equivalent type of enum. 2) if all members have integer types and there is a single integer type capable of representing all their values, we pick the first such type (in the same ordering that is used for e.g. integer constants). 3) anything else => bad_enum_ctype. c) enum is compatible with its equivalent type. d) it is an error to have implied initializer for a member following that of bitwise type. There are still issues with float in enums, but since gcc would choke on those unconditionally, we can be sure that there's no instances in any code we could deal with (unless we start playing with Plan 9 codebase, and that would require more work in other places - float enum is not the only C extension in there). Separate patch...
2005-04-07AutomergeLinus Torvalds3-8/+21
2005-04-07Ignore test-sort binary.welinder@anemone.rentec.com0-0/+0
2005-04-07Add new "compat.h" header file to lib dependencies list.Linus Torvalds1-1/+1
Noted by Chris Wedgwood.
2005-04-07Fix structure size calculation for structures with unsized arrays.Linus Torvalds2-7/+20
Such a structure does not have its size padded up by the alignment, since arrays of such structures are meaningless anyway.
2005-04-07New BitKeeper file ``test-sort.c''welinder@anemone.rentec.com2-0/+48
2005-04-07Make sure sort does not degenerate.welinder@anemone.rentec.com2-76/+264
2005-04-07This file uses NULL, so include stdlib.hwelinder@anemone.rentec.com1-0/+3
2005-04-07[PATCH] fix compat-cygwin.cmshah@teja.com1-1/+2
mingw works fine, but cygwin needs <sys/stat.h> for stat structure definition.
2005-04-07[PATCH] WinGW/CygWin compatibility supportmshah@teja.com2-0/+103
First cut at CygWin/MinGW compat support. Currently, for mingw, I am using windows API to identify the files uniquely, which is somewhat heavy because I have to open both the files simultaneously to compare the indices, will replace it to a lighter version later if I find out how to do that.
2005-04-07Add system-specific compatibility functions to makeLinus Torvalds7-24/+92
up for various system deficiencies. This makes sparse easier to port to silly things like MinGW or Solaris. In particular: - strtold() is a C99 thing, not everybody has it - MinGW has problems with mmap(MAP_ANONYMOUS) and doesn't zero it. - st_ino/st_dev is POSIX identity testing, not supported by MinGW
2005-04-07[PATCH] Use $(CC) everywhere in Makefile.pj@ludd.ltu.se1-6/+6
This changes the sparse Makefile to use $(CC) (which is already defined at the top) instead of using gcc directly. That makes it possible to use "make CC=/long/path/bin/gcc".
2005-04-07Don't SIGSEGV on bad cast expressions.Linus Torvalds1-0/+3
2005-04-07Make enumerated constants have the type of the constantLinus Torvalds2-3/+6
they got initialized with. This is not how standard C works. 'enum's are normally just integers. Tough.
2005-04-07Use the list sorter to sort the EXPR_INITIALIZER lists.Linus Torvalds1-0/+32
This should mean that the initializers are nicely sorted in ascending order, which makes it possible to check for duplicates and just in general is a good idea. We also need the sorted order to emit the dang things, after all.
2005-04-07Add sort_list() function that kind of works like qsort, butLinus Torvalds3-1/+105
is just different enough to be confusing. Thank you, thank you, I'll be here all week. Please remember to tip your waitresses.
2005-04-07Do the EXPR_POS simplification breadth first, not depth first. Linus Torvalds1-4/+4
Otherwise the inner levels get the wrong offsets, because they haven't added up the depth of the outer ones yet.
2005-04-07Simplify EXPR_INITIALIZER that is nested inside a simple EXPR_POS.Linus Torvalds1-6/+32
We move the offset from EXPR_POS into each of the EXPR_INITIALIZER entries - they should all have an EXPR_POS themselves, except for one potential zero-offset one (which we turn into an EXPR_POS by re-using the now unused nested EXPR_INITIALIZER).
2005-04-07Fix index expression conversion to EXPR_POS.Linus Torvalds1-1/+1
The EXPR_INDEX "to" thing is the last entry, while EXPR_POS wants the number of entries (to+1 - from). Off-by-one error resulted.
2005-04-07Simplify nested EXPR_POS expressions.Linus Torvalds1-1/+25
They happen with the new struct xxx x = { .a.b[10].c = val; } syntax.
2005-04-07Make sure EXPR_POS expressions have the right type.Linus Torvalds1-0/+2
2005-04-07Allow 'show_position_expr()' to survive lack of type information.Linus Torvalds1-1/+4
Again, this allows us to continue past errors.
2005-04-07For functions that lack a type, print out error rather than SIGSEGV.Linus Torvalds1-0/+4
Obviously we should have just exited earlier, but this allows us to survive past errors.
2005-04-07Allow EXPR_POS subexpressions in initializer evaluation.Linus Torvalds1-0/+7
That just happens when an initializer has already been evaluated once before, and the other positional expressions have been convered to EXPR_POS. Nothing more to do.
2005-04-07Totally re-do how we build up the initializer tree: make theLinus Torvalds6-97/+195
positional markers be hierarchical rather than a flat list. This makes the data structure a bit more complex, but it simplifies some of the code, and makes it possible to evaluate complex initializers without going insane. In particular, we how support struct xxxx var = { .a.b[10] = 1; }; which we couldn't handle at all before (it had to be written as struct xxxx var = { .a = { .b = { [10] = 1; } } } or similar. The new code changes all array indexes and structure members to EXPR_POS expressions offset from the "outer" scope (either start of the symbol, or an outer EXPR_POS).
2005-04-07Print out the proper filename on open failure.Linus Torvalds3-3/+3
Pointed out by Mitesh shah <mshah@teja.com>
2005-04-07Fix handling if "-I" switch.Linus Torvalds1-7/+23
The "char **next" argument is confusing. It is in fact the pointer to the _current_ argument.
2005-04-07Parse "nested" named or index initializers.Linus Torvalds1-3/+11
This just parses them, we don't actually handle them correctly afterwards. One step at a time.
2005-04-07Make blob_alloc and blob_free functions in order to hide caddr_twelinder@troll.com1-2/+16
issues and to get error checks.
2005-04-07Teach cgcc about -Wbitwise and -Wtypesign.welinder@troll.com1-1/+1
2005-04-07Add "-Wtypesign" command line option.Linus Torvalds3-8/+22
This enables the type sign warnings. They don't seem to be all that valid most of the time, so an explicit warning knob seems to be called for.
2005-04-07Improve sign warnings a bit.Linus Torvalds1-12/+15
We always warn about clashing _explicit_ signs. We don't warn about non-explicitly signed "char". The non-explicitly signed other types are still under consideration, but for now we warn about them with a different warning message.
2005-04-07Fix replace_by_integer.welinder@troll.com1-2/+2
2005-04-07Complain about type differences in signedness.Linus Torvalds1-3/+6
We've got a fair number of these in the kernel, because gcc historically hasn't checked it right, so lots of small problems have crept in. But gcc-4 will check, and we really should clean it up. Make the warning string a bit more readable for the sign-only difference case. NOTE! We're very anal about these things because we check for _explicit_ signedness differences too. That might be overkill, of course.
2005-04-07Add "__builtin_warning()" builtin.Linus Torvalds1-1/+57
Print out a user-supplied sparse warning, possibly conditional. Ie: __builtin_warning("This should warn"); __builtin_warning([typeof(x)] == [int], "'x' is an integer"); Any C expression can be used for a conditional (or set of conditionals, they all have to be true for the warning to trigger), but something is considered "true" only for a non-zero compile-time integer constant.
2005-04-07Getting the type of a symbol (and checking behind SYM_NODE) isLinus Torvalds1-8/+4
so common that we might as well make it a proper operation.
2005-04-07[PATCH] recovery from typeof on expression with bad typeAlexander Viro1-2/+2
A typeof on expression with bad type will result in segfault in examine_symbol_type() when we get to SYM_TYPEOF case in switch. void a(void) { typeof(*1) a; a ? 1 : 0; }
2005-04-07Fix conditional expression evaluation bugletsLinus Torvalds1-7/+8
- make sure we convert the true expression in the tree, not just in our local copy - fix restricted binop checks (too much cut-and-paste)
2005-04-07Fix shift size check and make warning more readable.Linus Torvalds1-9/+13
We used to trigger the size check only when shifting constant values by a constant value. Which is obviously bogus - we should check the shift amount even for a non-const left side. Noticed by Eric Sesterhenn
2005-04-07[PATCH] trivial ansi-c declearChristopher Li1-1/+1
Caught by checking sparse with itself.
2005-04-07Morten made us almost -Wwrite-strings clean. Go the extra mile.Linus Torvalds3-6/+8
The only remaining place was the magic constant "0" "1" number token generated by "defined(xxx)". And since we never actually modify number tokens (which would have broken that code anyway), let's just make that const'ness explicit.
2005-04-07Janitorial trivialities.welinder@darter.rentec.com6-10/+10
2005-04-07Fix up format string buglet found by the compiler.Linus Torvalds1-1/+1
2005-04-07Many files:welinder@darter.rentec.com14-200/+226
warn->warning error->error_die new error lib.h: warn->warning error->error_die new error Add gcc format checking to warning/error/...
2005-04-07symbol.h, symbol.c:welinder@troll.com4-45/+67
Add s(char|short|int|long|longlong)_ctype. show-parse.c: Print "signed" as part of the type names when needed. parse.c: Add separate ctypes for signed char, short, int, long, and long long. Make ctype_integer pick the explicitly signed type as needed.
2005-04-07Reinstate non-ANSI warning for "int foo () { }".welinder@troll.com1-2/+12
Warn for "int foo (...);".
2005-04-07More "union" trouble: don't look at ctype for non-NS_SYMBOL.Linus Torvalds1-1/+1
NS_PREPROCESSOR doesn't have any sym->ctype at all.
2005-04-07Move symbol "used" flag out from SYM_NODE union.Linus Torvalds1-1/+1
It's also used by SYM_MACRO preprocessor symbols (the regular "lookup_symbol()" sets it), and thus it has to be shared, not in a private part of a union.
2005-04-07Sanitize base type declarations some more.Linus Torvalds3-43/+45
Make "label_type" be a real ctype, rather than an uninitialized mess.
2005-04-07We need to initialize the type of the fundamental base types.Linus Torvalds1-0/+1
It _used_ to be initialized to zero (SYM_BASETYPE) automatically, but Chris added SYM_PREPROCESSOR at the beginning, without realizing that there was a magic reason for SYM_BASETYPE being zero. Rather than just re-instate the magic, let's just do the sane thing instead and initialize the base types properly.
2005-04-07Remove "match_string_ident" now that nothing uses it.Linus Torvalds2-11/+0
It may well come back as a debugging and prototyping thing, but I'd rather remove it and have to re-introduce it, than have people use that stupid interface just "because it's there". Sparse is very good at hashing identifiers and making them all unique. So you really should never need to match by string, you can just compare "struct ident" pointers directly. Thanks to Chris for getting rid of the users.
2005-04-07[PATCH] make preprocesser command a symbolChristopher Li4-39/+54
This all started with I want to remove match_string_ident in preprocessor. I decide that I don't want to search a pointer in the list. There is faster way which is register a symbol with a new name space which contain the handler. This changes: 1) changed name of NS_PRECESSOR to NS_MACRO and give it a new meaning for preprocessor command. Now NS_MACRO means a macro name, and the new NS_PREPROCESSOR means a preprocessor command. 2) The ctype and preprocessor can put into one union. They are on different name space so they _should_ never collapse. I did that and made struct symbol 8 bytes smaller. Nothing blew up for me so it must be correct ;) And a question: 3) When to initialize the preprocessor command symbol. Should we make it part of the init_symbol or let the caller(check.c) initialize it? Do we want to remove the preprocessor command afterwords?
2005-04-07Poison deleted ptr-list entries.Linus Torvalds1-0/+1
Our current PREPARE_PTR_LIST/RESET_PTR_LIST implementation has a bug: if we ever hit a block of pointers where every single pointer has been deleted, it doesn't understand to skip over it, and instead uses the first (deleted) entry. This at least causes a nice SIGSEGV rather than random behaviour. I'll have to think about how to do the PTR list traversal fix nicely.
2005-04-07[PATCH] Use more simple/fast iteratorsChristopher Li3-26/+17
Here is the second step to get ride of the old list iterator using the new infrastructure.
2005-04-07Add DELETE_CURRENT_PTR and REPLACE_CURRENT_PTR.Linus Torvalds1-0/+16
2005-04-07Make END_FOR_EACH_PTR[_REVERSE] take the ptr name as an argument.Linus Torvalds11-69/+69
..and switch us entirely over to the new naming scheme. All the nasty work of going through the users thanks to Chris Li.
2005-04-07Re-organize list access macros for easier expansion.Linus Torvalds1-40/+62
This prepares for the next stage, which is to make sure that we can name nested FOR_EACH_PTR() levels.
2005-04-07Fix "compile-i386.c" incestuous list internal knowledge.Linus Torvalds1-1/+1
Use the existing access macro instead.
2005-04-07Use the fast/simple list iterators in cases where we don'tLinus Torvalds1-7/+5
modify the list. Pointed out by Chris Li.
2005-04-07Mark the "entry" point in a function, and update it whenLinus Torvalds2-7/+20
packing blocks. The entrypoint doesn't necessarily end up being the first basic block in the list of blocks after we have packed them.
2005-04-07Fix silly "first_basic_block()" typoLinus Torvalds1-1/+1
Noticed by Chris Li.
2005-04-07[PATCH] __attribute__((bitwise))Alexander Viro7-25/+187
Handling of __attribute__((bitwise)) in a way that should be easy to extend afterwards. Example of use: typedef __u32 __attribute__((bitwise)) __le32; That will create a new 32bit type that will be assignment-incompatible with anything else. The set of allowed operations is restricted to bitwise ones, the only allowed constant is 0 right now. Forced casts are allowed, so is cast from type to itself and cast to void. Any other cast will give a warning. Checks are triggered by -Wbitwise in command line; if it's not there, attribute will be silently ignored.
2005-04-07[PATCH] parser.c cleanupAlexander Viro1-57/+64
* handling of bitfields taken to a helper function. * reading and handling list of attributes taken to a helper function. * caller became readable...
2005-04-07[PATCH] evaluate_sign() typoAlexander Viro1-1/+1
The unary operation allowed for integers but not for floats is ~, not % ;-)
2005-04-07[PATCH] uninlining inline functionsAlexander Viro5-13/+46
When we take the address of an inline function or otherwise refusing to inline it, we need to output the now non-inline function properly. What we do is a) keeping body and symbol list of inlined function in new fields b) when expanding inlined call use these fields c) when evaluating the function itself (which happens if sparse decides that it can't be [always] inlined) uninline the sucker. I.e. create ->stmt and ->symbol_list by copying the ->inline_stmt and ->inline_symbol_list same as we would do while expanding a call. That guarantees that we won't run into trouble with inlined calls coming afterwards - evaluation doesn't mangle ->inline_stmt anymore.
2005-04-07[PATCH] more on fixing dependencyChristopher Li1-0/+3
I hit some SEGV turn out to dependency related.
2005-04-07Add dependancy information for the new ident-list.hLinus Torvalds1-1/+2
2005-04-07[PATCH] avoid matching idents with string comparesChristopher Li4-123/+87
Identifiers are unique objects, so we can just compare the pointers directly, if we just set up the identifiers first. Identifier setup simplified as suggested by Linus.
2005-04-07Merge troll.com:/scratch/welinder/linus-sparsewelinder@troll.com2-4/+3
into troll.com:/scratch/welinder/sparse-for-linus
2005-04-07Fix up silly typo that caused __builtin_constant_p not to work on FP constants.Linus Torvalds1-1/+1
It's kind of redundant to check for integer constants twice. "Just to make sure" doesn't cut it ;) Noted by Morten Welinder <terra@gnome.org>
2005-04-07symbol.c:welinder@troll.com2-4/+3
Make eval_init_table static. pre-process.c: Fix match_string_ident.
2005-04-07Make sure to handle TOKEN_STREAMEND even inside a false conditional.welinder@troll.com1-11/+15
2005-04-07Make elif_ignore also keep track of whether we have seen #else.welinder@troll.com1-30/+42
Check for unterminated #if on a per-stream basis. Check for #else after #else or #elif. Check for unmatched #else/#elif/#endif on a per-stream basis.
2005-04-07Encountering #warning or #error at the wrong spot means that the filewelinder@troll.com1-0/+4
is not constant. Not that it really matters, but still...
2005-04-07Fix #warning for lines that end up with precisely 1024 characters.welinder@troll.com1-1/+1
2005-04-07Merge troll.com:/scratch/welinder/linus-sparsewelinder@troll.com11-50/+111
into troll.com:/scratch/welinder/sparse-for-linus
2005-04-07Make "-nostdinc" command line flag actually work.Linus Torvalds1-4/+28
Also add some infrastructure to make it easier to add new random command line options.
2005-04-07Make "next_path" be per-stream for better "include_next".Linus Torvalds10-30/+29
Maybe this makes us gcc-compatible. Maybe it doesn't.
2005-04-07Implement "include_next"Linus Torvalds1-7/+19
It's trivial now with the re-organized include path handling.
2005-04-07Re-organize search path handling.Linus Torvalds1-23/+49
This is a cunning plan to make "include_next" work. This is just the infrastructure. Actual include_next handling in the next patch.
2005-04-07__const in addition to const and __const__. Sigh.welinder@troll.com1-0/+1
From Dave Jones <davej@redhat.com>.
2005-04-07Merge http://sparse-mw.bkbits.net:8080/for-linusLinus Torvalds1-2/+9
into ppc970.osdl.org:/home/torvalds/BK/sparse
2005-04-07pre-process.c:welinder@troll.com3-36/+75
Fix file-is-const for #define, #undef, C-code inside the #ifndef. Make it easy to debug file-is-const. tokenize.c: Fix check for identical-file. token.h: Introduce symbolic names for the stream->constant states and comment those states.
2005-04-07Improve error reporting for bad K&R function parameterLinus Torvalds1-2/+9
declarations. Complain about extraneous bogus declarations, and make a better warning for missing ones.
2005-04-07Merge troll.com:/scratch/welinder/linus-sparsewelinder@troll.com1-17/+30
into troll.com:/scratch/welinder/sparse-for-linus
2005-04-07Oops - when parsing a K&R function, we started at the wrong point.Linus Torvalds1-1/+1
My silly test file was a bit _too_ simple, and missed the fact that the parser would have missed the first token in the function body ;)
2005-04-07Since we allow K&R declarations, allow empty ones too.Linus Torvalds1-0/+3
We used to require the "void" thing, but if we parse K&R we can no longer do that. So just silently allow an empty parameter type list.
2005-04-07Merge troll.com:/scratch/welinder/linus-sparsewelinder@troll.com1-5/+44
into troll.com:/scratch/welinder/sparse-for-linus
2005-04-07Improve K&R name matching.Linus Torvalds1-13/+11
I didn't even realize that K&R allowed the declaration of the types to be in a different order than the arguments themselves. Anyway, that's easy to handle, although we should probably also check that we don't declare some name that doesn't exist.
2005-04-07Final part of K&R functions - integer promotionsLinus Torvalds1-4/+16
char/short types promote to "int" in K&R function declarations.
2005-04-07Merge troll.com:/scratch/welinder/linus-sparsewelinder@troll.com1-15/+16
into troll.com:/scratch/welinder/sparse-for-linus
2005-04-07Apply the K&R parse ctypes to the argument list.Linus Torvalds1-4/+22
Hey, this is still wrong. A "char" should be promoted to "int" etc, and we don't do that. So it's kind of half-K&R, half-ANSI.
2005-04-07Parse K&R function declarations.Linus Torvalds1-5/+26
HOWEVER! We don't actually go and apply the types to the arguments yet, so this is purely a "parse only" fix. To actually make K&R functions work, we'd need to match up the re-declared arguments against the argument list. All the information is there now, though. Somebody more interestedin K&R could fix it up.
2005-04-07Unnamed bitfields should not affect structure and union alignment.welinder@troll.com1-5/+14
2005-04-07Split "side effects" from "might take an exception" costs.Linus Torvalds1-15/+16
A "might take an exception" expression may not be re-ordered very much wrt other expressions, but it _can_ be dropped entirely if it is part of an expression that has no other effect. In contrast, a real side effect obviously can't be dropped.
2005-04-07Tests for structure namespace issues.welinder@troll.com2-0/+31
2005-04-07First cut at getting local structure ns handling right.welinder@troll.com1-2/+16
2005-04-07Merge troll.com:/scratch/welinder/linus-sparsewelinder@troll.com3-3/+3
into troll.com:/scratch/welinder/sparse-for-linus
2005-04-07Allow "extern" void declarations.Linus Torvalds1-1/+1
They are used by the Linux kernel for referring to assembler symbols without a type (you can obviously only take the address of such a symbol, not use it for anything else).
2005-04-07Check the right type in "alignof" evaluation.Linus Torvalds1-1/+1
2005-04-07Put enums in the same namespace as unions and structs.welinder@troll.com2-9/+10
Check tags when naming tagged types. This catches things like... enum Foo { FOO }; struct Foo x;
2005-04-07Don't strip the binary when installing.Linus Torvalds1-1/+1
When we don't have bugs all the time, we can strip it again, but for now it just makes debugging harder.
2005-04-07fix layout of zero-width bitfields.welinder@troll.com1-6/+9
2005-04-07Disallow sizeof/alignof/typeof on bitfields.welinder@troll.com3-3/+14
2005-04-07Make array dereference build the right evaluation tree.Linus Torvalds1-0/+8
When dereferencing an array, it degenerates into a pointer to the first entry of the array. We did all that correctly from a type standpoint, but we didn't actually do the "addressof" operation on the tree itself. This fixes up the tree properly. Problem noticed by Chris Li.
2005-04-07Add proper dependencies on compile.hLinus Torvalds1-2/+2
Chris Wedgwood pointed these out.
2005-04-07Check for illegal modifier combinations only after weLinus Torvalds1-1/+1
have accepted them in the first place.
2005-04-07Fix assignment to bitfields. (From Christopher Li.)welinder@troll.com1-2/+3
2005-04-07Teach cgcc about flags that are for sparse only.welinder@troll.com1-10/+31
2005-04-07Handle __func__ correctly as a variable and not a #define.welinder@troll.com4-2/+31
With help from Christopher Li <sparse@chrisli.org>.
2005-04-07Mondane cleanups at the level of typos.welinder@troll.com3-8/+8
2005-04-07Introduce -Wdefault-bitfield-sign and only warn when asked for.welinder@troll.com3-1/+38
2005-04-07parse.c:welinder@troll.com1-3/+4
Get the right signedness (which broke when the code moved here).
2005-04-07Merge troll.com:/scratch/welinder/linus-sparsewelinder@troll.com2-41/+132
into troll.com:/scratch/welinder/sparse-for-linus
2005-04-07[PATCH] better recovery from type errors in EXPR_COMMAAlexander Viro1-2/+1
Don't bail out if left argument of , has type error - we can continue just fine at that point. Reduces cascades of bogus warnings and allows to catch real ones in the right argument. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07[PATCH] cast constraint checksAlexander Viro1-7/+30
Unless the cast is to void, both argument and result should be scalars. Checks added. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07[PATCH] <op>= handlingAlexander Viro1-16/+69
<op>= handling. Basically, we rewrite *p += v into (temp = p, *temp = *temp + v) and similar for bitfield lvalues. evaluate_assignment() adjusted accordingly. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07[PATCH] evaluate_statement() fixesAlexander Viro1-10/+20
1) Eliminate double evaluate_conditional() on loop condition - we get the same reference both in ->iterator_post_condition and ->iterator_pre_condition and evaluate_statement() didn't take that into account. 2) In handling of if() do not bail if evaluate_conditional() had failed - that way we'll catch what there is to catch in ->if_true and ->if_false (their evaluation doesn't depend on type errors in condition) _and_ won't get noise from linearizer confused by unevaluated statements. 3) In <expr>; do not try to degenerate the expression if evaluate_expression() had failed - again, less noise that way. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07evaluate.c:welinder@troll.com1-1/+3
Ignore MOD_EXPLICITLY_SIGNED for type comparisons.
2005-04-07[PATCH] casts are not lvaluesAlexander Viro1-2/+0
Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07Don't complain over sign problems with unnamed bitfields.welinder@troll.com2-14/+17
2005-04-07[PATCH] inline declaration getting clobbered by expansionAlexander Viro1-4/+12
When we copy the body of inlined function, we leave more nodes shared than we should - they might be mangled by evaluation of copy. Fixed. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07Fix nonterminated ident matching.Linus Torvalds1-2/+2
Found by Dave Jones and 'valgrind'.
2005-04-07Fix merge issue with Al's stuff.welinder@troll.com1-5/+5
2005-04-07Cset exclude: welinder@troll.com|ChangeSet|20040812190944|57264welinder@troll.com3-74/+7
Cset exclude: welinder@troll.com|ChangeSet|20040812190029|57250 Cset exclude: welinder@troll.com|ChangeSet|20040812184608|57271 Cset exclude: welinder@troll.com|ChangeSet|20040812175907|57697 Cset exclude: welinder@troll.com|ChangeSet|20040812160921|53242
2005-04-07Mergewelinder@troll.com10-14/+139
2005-04-07[PATCH] teach show_special() to handle tokens introduced by ↵Alexander Viro2-3/+4
evaluate_comparison() Fix handling of replaced comparisons in expression. We are handling unsigned comparisons by replacing the expr->op with new special values (SPECIAL_UNSIGNED_{LT,GT,LTE,GTE}) which works fine, but confuses the hell out of show_special(). As the result, test-linearize simply segfaults on any code that contains unsigned comparison. This patch fixes that by teaching show_special() to handle these guys and making sure that tokenizer doesn't get confused (it uses the same set of strings to recognize punctuators). Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07[PATCH] handling of non-lvalue compound objectsAlexander Viro7-10/+129
Handling of non-lvalue compound objects: We introduce a new primitive - EXPR_SLICE. Meaning is "that many bits from that offset in that non-lvalue struct or union". It is used when we try to get a member out of a non-lvalue struct or union (subsequent .<field> just narrow the slice). And as far as scalar, struct and union fields count, that's it. The only subtle point is handling of array fields. And there I'm doing what C99 requires - they *do* decay to real, honest pointers, causing a copy of object to memory if needed. We get an anonymous object that lives until the next sequence point; optimizer is certainly free to get rid of it completely if it can make do with the value we'd copied there. Note that you _are_ allowed to say foo().a[1] = 0; It doesn't make sense, since the value you've assigned will be immediately lost (and any optimizer will turn that into f()), but it is legitimate and it avoids a *lot* of PITA in describing semantics. It covers only array decay - any other member of non-lvalue struct or union is *not* an lvalue and in struct foo {int x; int y[2];}; struct foo a(void); ... a().x = 0; /* not allowed, non-lvalue */ a().y[0] = 1; /* allowed, but pointless */ you will get an error from the first assignment, but not from the second one. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07lib.c:welinder@troll.com1-1/+9
Muck with solaris predefines to suit solaris libc.
2005-04-07[PATCH] fix double warnings in inline callsAlexander Viro1-1/+1
Fix double warnings on type mismatch in inline arguments; once we'd got a warning, cast the damn thing and be done with that. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07[PATCH] attributes on bitfieldsAlexander Viro1-0/+5
Bitfields in structure declarations can have attributes; teach parser to handle them. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-07lib.c:welinder@troll.com1-5/+26
Linux/Solaris split. Keep it minimal for now.
2005-04-07expand.c:welinder@troll.com1-1/+3
Don't complain over undefined preprocessor symbols that start with an underscore. This helps quiet a gazillion errors with _cplusplus and others used by solaris' system headers. This change may or may not be approapriate on a glibc system.
2005-04-07check.c:welinder@troll.com2-2/+8
Use __SIZE_TYPE__ Define __builtin_alloca. lib.c: Pre-define __SIZE_TYPE__
2005-04-07lib.c:welinder@troll.com1-1/+4
Add __unix__ and variants to create_builtin_stream.
2005-04-07lib.c, lib.h:welinder@troll.com2-0/+36
Under __sun__, implement a strtold.
2005-04-07parse.c:welinder@troll.com4-5/+12
Don't clear MOD_EXPLICITLY_SIGNED in indirect.\ symbol.c: Add modifier MOD_EXPLICITLY_SIGNED to all versions of "signed". check for integer bitfields that are just "int foo : 42". symbol.h: Define MOD_EXPLICITLY_SIGNED. This will be used to distinguish "int" and "signed int". show-parse.c: Show MOD_EXPLICITLY_SIGNED as "[explicitly-signed]".
2005-04-07parse.c:welinder@troll.com1-11/+27
Move bitfield parsing into struct/union parsing where it belongs. Sanity check bitfield widths.
2005-04-07symbol.c:welinder@troll.com1-1/+10
Check for signed one-bit bitfields.
2005-04-07parse.c:welinder@troll.com1-1/+2
Handle __noreturn__ as noreturn (==ignore).
2005-04-07parse.c:welinder@troll.com1-3/+8
Disallow "void" parameters and "void" variables.
2005-04-07parse.c:welinder@troll.com1-0/+30
Check that "signed", "unsigned", "long", ... only occur where they may. Notably not as "signed double" or "long struct { ... }".
2005-04-07pre-process.c, lib.c:welinder@troll.com2-2/+2
Never call isdigit/isspace on type char, use unsigned char only.
2005-04-07parse.c:welinder@troll.com1-1/+7
Check for multiple storage classes such as "static extern".
2005-04-07lib.c:welinder@troll.com1-0/+11
Handle -MF foo, -MQ foo, and -MT foo.
2005-04-07expand.c:welinder@troll.com1-2/+11
Handle integer overflow in unary minus.
2005-04-07pre-process.c:welinder@troll.com1-1/+1
Gnome needs lots of -Ipath -- just up the limit a whole lot.
2005-04-07Add "__word__" mode attribute and fix __QI__.Linus Torvalds1-1/+7
Lack of __word__ noted by Dave Jones.
2005-04-07Wrapper to run check and gcc in series.welinder@troll.com1-0/+22
2005-04-07[PATCH] sparse --- Makefile dependancy fix for check.oChris Wedgwood1-0/+1
check.o doesn't have LIB_H dep, trival fix below. with this you can: make clean bk -r clean make -j install and it works as expected
2005-04-07config:welinder@troll.com0-0/+0
MW prefs.
2005-04-07[PATCH] Silently ignore __attribute__((visibility("hidden")))terra@gnome.org1-0/+2
This would be handy. ("visibility" is a linkage directive.)
2005-04-07[PATCH] "signed unsigned", "short long", "double x : 4", "int y : 1 : 2"terra@gnome.org3-16/+27
Don't allow nonsensical type descriptions like signed unsigned x; short long x; double x : 4; int y : 1 : 2;
2005-04-07[PATCH] simplify_float_binopterra@gnome.org1-3/+5
Another case of prematurely loading floating point values.
2005-04-07[PATCH] Avoid recursive inline function expansionChristopher Li2-1/+7
Ideally we should probably allocate an error code for recursive expand, so the caller can know that the inline did not expand at all. But the evaluate_symbol_call don't care about that so I just make it reutrn 0.
2005-04-07Fix up the worst regcache thinko's.Linus Torvalds1-28/+31
In particular: - we should only test (and not mark busy) the things a register aliases when we allocate it. This bug kept us from using %edx, because when we used %eax, we bogusly marked the 64-bit combination %eax:%edx as being busy, and refused to use %edx later. - "get_reg_value()" should take a regclass, so that we can allocate a new reg from a valid class.
2005-04-07Add the proper accessor functions to turn a 32-bit regLinus Torvalds1-0/+2
into a 16-bit one, and into the "high byte" version.
2005-04-07Make "emit_conditional_test()" use register caches.Linus Torvalds1-2/+5
2005-04-07Improve "emit_move()" handling.Linus Torvalds1-6/+34
If we are loading something into a register, and another register has that value already cached, used the cached register value.
2005-04-07Mark an inline symbol accessed when taking its address.Linus Torvalds1-1/+2
(And ignore the ACCESSED bit when comparing types)
2005-04-07Make binops use the new register tracking in compile-i386.cLinus Torvalds1-33/+13
2005-04-07Do some rudimentary register content tracking.Linus Torvalds1-34/+116
This still does just mainly EXPR_SELECT, since that is what I'm familiar with. It's also extremely lazy about invalidating register content info, since any code that hasn't been moved to the new format won't do things properly. Very much a work-in-progress, designed to eventually allow us to generate some kind of half-readable code from the SSA form.
2005-04-07Start infrastructure for more dynamic register allocation.Linus Torvalds1-14/+112
Instead of using fixed register names, we keep track of busy registers, and allocate them as needed. Also changed EXPR_SELECT to actually use this.
2005-04-07Add "bitmap.h" for some simple bitmap opsLinus Torvalds2-1/+52
2005-04-07Let compile-i386 know about more registers.Linus Torvalds1-56/+54
We don't actually _use_ any of them yet, but this lists them, and adds the information about which register conflicts with which register (eg %al conflicts with %eax, but not with %ah)
2005-04-07Simplify the interface between compile.c and the actualLinus Torvalds3-16/+16
code emitter. Don't make the code emission have to know about symbol lists etc. Thus the code emitter can do whatever it wants to do to the symbols as they are encountered, as part of the main loop rather than as a separate phase afterwards. Straightforward.
2005-04-07Create a valid linearization of EXPR_SELECT.Linus Torvalds2-1/+20
Since the "struct instruction" format doesn't allow for all the data a select needs, we create two pseudo-instructions instead, and generate a select as a combination of the two: OP_SETCC + OP_SEL. We should possibly do the same thing for conditional branches.
2005-04-07Make compile-i386.c create pseudo-code for the logical binops.Linus Torvalds1-0/+8
It gets them wrong right now: we can't just use "and" and "or", we need to convert to canonical logical form (0/1) too. But it's documentation.
2005-04-07Teach compile-i386.c to emit select instructions.Linus Torvalds1-1/+31
They are valid now that we have a EXPR_SELECT type for safe conditionals.
2005-04-07Oops. Must expand conditional expression before checking it for constantness.Linus Torvalds1-2/+3
"constantness" is probably not a word.
2005-04-07EXPR_SAFELOGICAL is unnecessary. It ends up being the same as EXPR_BINOP.Linus Torvalds7-13/+10
Make linearize.h show the right ops for the logical (as opposed to binary) and/or EXPR_BINOP.
2005-04-07Make expression expansion calculate the "cost" of theLinus Torvalds9-127/+204
expression. This is just a very high-level cost, mainly distinguishing between "safe" and "unsafe" operations, so that we can determine if we can turn a C conditional into a select statement, or a logical op into one without short-ciruiting.
2005-04-07Add "select" expression.Linus Torvalds7-0/+8
It's the same as a regular C conditional, except you could evaluate both sides first. Right now we treat it exactly the same as an EXPR_CONDITIONAL.
2005-04-07[be] fix amazingly stupid conditional expression handlingJeff Garzik1-61/+69
By virtue of attempting to be too smart, the conditional expression handling ("x ? foo : bar") would evaluate both 'foo' and 'bar', and then use the cmov instruction to determine the result, avoiding a branch in the process. Unfortunately this only makes sense for simple things (EXPR_VALUE, EXPR_SYMBOL) and is quite wrong for everything else. Changed so that 'if' statements and conditional expressions use largely the same code.
2005-04-07[be] minor fixesJeff Garzik1-1/+13
* Mostly revert function call stack frame construction ("correctly generate push* instruction") * Add comment regarding ABI-dictated function call argument size * Clamp function call arg size to 32-bit minimum. This will copy the correct value to the stack at the correct alignment, but (SECURITY/FIXME) will also copy extra bits (24 bits for an 8-bit value, 16 bits for a 16-bit value). * Add EXPR_FVALUE to the 'unhandled' portion of the master emit-expression 'switch' statement.
2005-04-07Merge bk://kernel.bkbits.net/jgarzik/sparse.beLinus Torvalds2-7/+11
into ppc970.osdl.org:/home/torvalds/BK/sparse
2005-04-07[be] fix some of the brokenness related to non-32-bit variablesJeff Garzik1-23/+37
Assumptions that values are 32-bit still remain in places, but some simple test cases involving 8-bit and 16-bit variables seem much more sane now.
2005-04-07Simplify the trivial direct "indirect" goto.Linus Torvalds1-1/+9
Goto's of the form "goto *&&label" might actually end up happening as part of constant folding. And even if they don't, this is the RightThing(tm) to do.
2005-04-07Copy the whole symbol when creating a copy for inlining.Linus Torvalds1-6/+2
I really don't know why we didn't do this before. Not copying all fields is a bug, but maybe there was a reason that isn't immediately obvious. If so, maybe we'd comment on it next time.
2005-04-07Fix symbol copy on inlining.Linus Torvalds1-0/+2
Stupid stupid bugs. This makes inlining work a lot better.
2005-04-07Teach linearizer about computed goto's.Linus Torvalds3-2/+48
We need to emit an OP_COMPUTEDGOTO instruction with a full list of potential targets.
2005-04-07Keep track of computed target label lists per-function.Linus Torvalds4-1/+29
Associate them with each computed goto, and copy them properly when inlining.
2005-04-07Handle preprocessor "# <nr> <file>" the same as #line <nr> <file>".Linus Torvalds1-2/+9
This is the format gcc will output the line information in, for example. We still don't actually _use_ the information, and perhaps never will, but at least we'll silently ignore it rather than complain.
2005-04-07[PATCH] #lineterra@gnome.org1-0/+9
Stuff from bison contains #line directives. This makes sparse ignore such lines. This helps but doesn't exactly make sparse happy over such .c files. (Ignoring isn't quite right because, arguably, later error messages should refer to the file from which the c code was generated, not from the c code itself.)
2005-04-07[PATCH] Generate correct push* instruction.Alexey Dobriyan1-2/+1
Pay attention to size of function arguments when pushing them to stack. Generate "pushb" for char, "pushw" for short, ... [ Linus' note: this is likely "wrong". In a real x86 compiler, we'd expand the width of the argument to 32 bits regardless, but from a demonstration standpoint this is better ]
2005-04-07[PATCH] Simplify mnemonic generation for mov* instructions.Alexey Dobriyan1-23/+7
We already have a function that adds correct {b,w,l,q} suffix.
2005-04-07[PATCH] Print instruction's suffix in a human-readable form.Alexey Dobriyan1-1/+1
{'b', 'w', 'l', 'q'} instead of {ascii 8, ascii 16, ' ', '@'}