mycoboco / beluga

a standard C compiler (with an integrated preprocessor)
http://code.woong.org/beluga
Other
65 stars 8 forks source link

incorrect recognization of system headers #90

Closed mycoboco closed 7 years ago

mycoboco commented 7 years ago

Assuming that <bar.h> is a system header and macro-guarded, the following code does not let diagnostics correctly point into the macro definition that triggers them because foo.h is incorrectly recognized as a system header.

// foo.h
typedef struct { int x; } ux_t;
#define SYM(p) (~(~(ux_t)0 << (p)))

// foo.c
#include <bar.h>
#include <bar.h>
#include "foo.h"

void f(void)
{
    SYM(f);
}

Works fine when <bar.h> is treated as a normal one.

mycoboco commented 7 years ago

When a macro-guard detected, #include will not be performed, in which case setting syslev should be also avoided. Moving the code to change syslev below the check for macro-guards solves the problem.

mycoboco commented 7 years ago

112265506a0bf0d0b49825e4979b14549ab28a8a