diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-09 14:52:16 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-10 21:55:51 +0100 |
commit | 781bc5d9369bd0dd5740a92fd1d62f08396b54a4 (patch) | |
tree | 227872b6dabadac2e204c24466bbf25bf7575a43 | |
parent | dd95ee8cbfeb1fd8e078397eda81a6686c31f472 (diff) | |
parent | efe42efcc1c774af69b15ac26f8c9144fbc00f08 (diff) | |
download | sparse-781bc5d9369bd0dd5740a92fd1d62f08396b54a4.tar.gz |
Merge branch 'eval-typeof' into next
* clarify lazy evaluation & conversion of SYM_TYPEOF
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | show-parse.c | 1 | ||||
-rw-r--r-- | symbol.c | 9 | ||||
-rw-r--r-- | test-show-type.c | 28 | ||||
-rw-r--r-- | validation/eval/typeof0.c | 10 |
6 files changed, 46 insertions, 4 deletions
@@ -24,6 +24,7 @@ test-inspect test-lexing test-linearize test-parsing +test-show-type test-unssa # tags @@ -80,6 +80,7 @@ PROGRAMS += test-dissect PROGRAMS += test-lexing PROGRAMS += test-linearize PROGRAMS += test-parsing +PROGRAMS += test-show-type PROGRAMS += test-unssa INST_PROGRAMS=sparse cgcc diff --git a/show-parse.c b/show-parse.c index 68b3e718..1c0ecf7e 100644 --- a/show-parse.c +++ b/show-parse.c @@ -334,6 +334,7 @@ deeper: mod = sym->ctype.modifiers; as = sym->ctype.as; was_ptr = 1; + examine_pointer_target(sym); break; case SYM_FN: @@ -436,10 +436,11 @@ static struct symbol *examine_enum_type(struct symbol *sym) static struct symbol *examine_pointer_type(struct symbol *sym) { /* - * We need to set the pointer size first, and - * examine the thing we point to only afterwards. - * That's because this pointer type may end up - * being needed for the base type size evaluation. + * Since pointers to incomplete types can be used, + * for example in a struct-declaration-list, + * the base type must *not* be examined here. + * It thus means that it needs to be done later, + * when the base type of the pointer is looked at. */ if (!sym->bit_size) sym->bit_size = bits_in_pointer; diff --git a/test-show-type.c b/test-show-type.c new file mode 100644 index 00000000..8396fdcf --- /dev/null +++ b/test-show-type.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT + +#include <stdio.h> +#include "lib.h" +#include "symbol.h" + +static void show_symbols(struct symbol_list *list) +{ + struct symbol *sym; + + FOR_EACH_PTR(list, sym) { + printf("%s;\n", show_typename(sym)); + } END_FOR_EACH_PTR(sym); +} + +int main(int argc, char **argv) +{ + struct string_list *filelist = NULL; + char *file; + + sparse_initialize(argc, argv, &filelist); + Wdecl = 0; + FOR_EACH_PTR(filelist, file) { + show_symbols(sparse(file)); + } END_FOR_EACH_PTR(file); + + return has_error; +} diff --git a/validation/eval/typeof0.c b/validation/eval/typeof0.c new file mode 100644 index 00000000..12b08660 --- /dev/null +++ b/validation/eval/typeof0.c @@ -0,0 +1,10 @@ +static int i; +static typeof(i) *ptr; + +/* + * check-name: eval-typeof0 + * check-command: test-show-type $file + * + * check-output-ignore + * check-output-excludes: unknown type + */ |