[cfe-dev] Problem in SLocEntry creation

Abramo Bagnara abramo.bagnara at bugseng.com
Wed Dec 19 14:00:35 PST 2012


$ cat file.c
#define WINDOW win
#include "file.h"
$ cat file.h
#define P_(args)	args
extern void f P_((WINDOW win));
$ clang -c file.c
error: unknown type name 'win'
./file.h:1:18: note: expanded from macro 'P_'
#define P_(args)        args
                        ^
1 error generated.

It seems that when the spelling location for 'win' is computed we end up
into an expansion SLocEntry despite we start from a file SLocEntry.

This is the dump of relevant SLocEntry:

4: file 12275-12329 name:./file.h iloc:30
5: macro 2147495978-2147495982 exp:12311-12326 sloc:12292 text:args
6: macro 2147495983-2147495986 exp:12315-12315 sloc:17 text:win
7: arg 2147495987-2147496011 exp:2147495978-2147495978 sloc:12314
text:(WINDOW win));

The location for 'win' is 2147496008, i.e. fid 7 and offset 21, if we
sum that offset to base spelling loc 12314 + 21 = 12335, but this offset
belong to fid 6 that is not a file SLocEntry.

So we get as spelling loc a file loc that is erroneously inside an
expansion SLocEntry, this produces the effect to obtain an invalid loc
that confuse diagnostics, so that, as you can see above, no
file:line:column is shown before "error:".

Do you know what might be the reason for that and/or what is the correct
remediation?

-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com



More information about the cfe-dev mailing list