aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-11-09 14:52:16 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2019-11-10 21:55:51 +0100
commit781bc5d9369bd0dd5740a92fd1d62f08396b54a4 (patch)
tree227872b6dabadac2e204c24466bbf25bf7575a43
parentdd95ee8cbfeb1fd8e078397eda81a6686c31f472 (diff)
parentefe42efcc1c774af69b15ac26f8c9144fbc00f08 (diff)
downloadsparse-781bc5d9369bd0dd5740a92fd1d62f08396b54a4.tar.gz
Merge branch 'eval-typeof' into next
* clarify lazy evaluation & conversion of SYM_TYPEOF
-rw-r--r--.gitignore1
-rw-r--r--Makefile1
-rw-r--r--show-parse.c1
-rw-r--r--symbol.c9
-rw-r--r--test-show-type.c28
-rw-r--r--validation/eval/typeof0.c10
6 files changed, 46 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index fea16237..91305a6a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ test-inspect
test-lexing
test-linearize
test-parsing
+test-show-type
test-unssa
# tags
diff --git a/Makefile b/Makefile
index a87d0643..deab4897 100644
--- a/Makefile
+++ b/Makefile
@@ -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:
diff --git a/symbol.c b/symbol.c
index 116b1040..90149e5a 100644
--- a/symbol.c
+++ b/symbol.c
@@ -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
+ */