xref: /openbsd-src/gnu/usr.bin/binutils/gdb/testsuite/gdb.base/lineinc.c (revision 11efff7f3ac2b3cfeff0c0cddc14294d9b3aca4f)
1*11efff7fSkettenis /* The following is written to tickle a specific bug in the macro
2*11efff7fSkettenis    table code (now hopefully fixed), which doesn't insert new included
3*11efff7fSkettenis    files in the #including file's list in the proper place.  They
4*11efff7fSkettenis    should be sorted by the number of the line which #included them, in
5*11efff7fSkettenis    increasing order, but the sense of the comparison was reversed, so
6*11efff7fSkettenis    the list ends up being built backwards.  This isn't a problem by
7*11efff7fSkettenis    itself, but the code to pick new, non-conflicting line numbers for
8*11efff7fSkettenis    headers alleged to be #included at the same line as some other
9*11efff7fSkettenis    header assumes that the list's line numbers are in ascending order.
10*11efff7fSkettenis 
11*11efff7fSkettenis    So, given the following input, lineinc1.h gets added to lineinc.c's
12*11efff7fSkettenis    #inclusion list first, at line 10.  When the debug info reader
13*11efff7fSkettenis    tries to add lineinc2.h at line 10 as well, the code will notice the
14*11efff7fSkettenis    duplication --- since there's only one extant element in the list,
15*11efff7fSkettenis    it'll find it --- and insert it after lineinc1.h, with line 11.
16*11efff7fSkettenis    Since the code is putting the list in order of descending
17*11efff7fSkettenis    #inclusion line number, the list is now out of order.  When we try
18*11efff7fSkettenis    to #include lineinc3.h at line 11, we won't notice the duplication.  */
19*11efff7fSkettenis 
20*11efff7fSkettenis #line 10
21*11efff7fSkettenis #include "lineinc1.h"
22*11efff7fSkettenis #line 10
23*11efff7fSkettenis #include "lineinc2.h"
24*11efff7fSkettenis #line 11
25*11efff7fSkettenis #include "lineinc3.h"
26*11efff7fSkettenis 
27*11efff7fSkettenis int
main(int argc,char ** argv)28*11efff7fSkettenis main (int argc, char **argv)
29*11efff7fSkettenis {
30*11efff7fSkettenis }
31