Commit c028c472 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[kernel] fix ast-diff on code with forward-decl of struct

In presence of the following pattern of code:

```c
struct S;
enum { t = 1 };
struct S { char[t]; };
```

-ast-diff will attempt to compare the use of `t` in the field declaration
before having visited the `enum` definition. Thus, we can't rely on an enumitem
being present in the correspondance table when looking for a correspondance.
parent 0ca4524a
......@@ -1357,7 +1357,16 @@ and enuminfo_correspondance ?loc ei env =
in
Enuminfo.memo add ei
and enumitem_correspondance ?loc:_loc ei _env = Enumitem.find ei
(* For now, all enumitems are treated with their parent enuminfo: if
we don't find one, we let enuminfo_correspondance do the job. *)
and enumitem_correspondance ?loc ei env =
let add ei =
match enuminfo_correspondance ?loc ei.eihost env with
| `Not_present -> `Not_present
| `Same _ -> Enumitem.find ei
in
try Enumitem.find ei with
| Not_found -> add ei
and gvar_correspondance ?loc vi env =
let add vi =
......
......@@ -19,9 +19,11 @@
[AST diff test] Variable x: => x
[AST diff test] Variable c: => c
[AST diff test] Variable g: => g
[AST diff test] Variable se: => se
[AST diff test] Variable S: => S
[AST diff test] Variable has_static_local_x: => has_static_local_y
[AST diff test] Variable __retres: => __retres
[AST diff test] Variable h: => h
[AST diff test] Variable __retres: => __retres
[AST diff test] Variable use_logic_builtin: => use_logic_builtin
[AST diff test] Variable x: => x
[AST diff test] Variable y: => y
......@@ -36,6 +38,7 @@
[AST diff test] Function f: => f
[AST diff test] Function with_goto_unchanged: => with_goto_unchanged
[AST diff test] Function g: N/A
[AST diff test] Function se: => se
[AST diff test] Function h: -> h (body changed)
[AST diff test] Function use_logic_builtin: => use_logic_builtin
[AST diff test] Function has_static_local: => has_static_local
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment