1include MutRecHeader2;
2
3/* MutRecHeader1 (H1) includes MutRecHeader2 (H2), and uses a struct from H2.
4   H2 includes MutRecHeader3 (H3).
5   H3 includes H1.
6
7When type checking H1, GatherDecls::visitInclude will recursively
8cause us to first check H2, which in turn will cause us to first check
9H3.
10
11H3 only includes H1, so when we check it, we do not have any
12declarations from H2 in the context. There used to be code in
13GatherDecls::visitTranslationUnit that would, as part of the "second
14pass", check the validity of all included structures. This would check
15Struct1, and fail, because Struct2 is not declared.
16
17Fundamentally, it doesn't make sense to check anything declared in an
18included file in the context of the file that included it.
19
20Note that this error did not show up when either H2 or H3 was
21checked. This is because in those cases we are not in the middle of
22checking H1 when we check H3, so we end up fully checking H1 before we
23get to the end of checking H3. This means the "visited" tag gets put
24on Struct1 before we get to the end of that troublesome block of code
25in visitTranslationUnit, and visitStructDecl doesn't do anything if
26that tag is set, so we don't end up actually checking H1 in the
27context of H3.
28
29*/
30
31struct Struct1
32{
33  Struct2 b;
34};
35