[cfe-dev] Weird behavior while parsing nested (and non) pragmas
Simone Pellegrini
spellegrini at dps.uibk.ac.at
Wed Aug 25 08:47:37 PDT 2010
Hi there,
I have a question about a weird behavior I am observing when parsing C
programs which contains nested pragmas.
The bottom line is that I need to extend some of the functions in Sema
in order to associate the pragmas to the correct statement. Let's
consider now the following code:
1 int main() {
2 #pragma omp parallel
3 {
4 #pragma omp barrier
5 #pragma omp master
6 ;
7 }
8 }
my overloaded version of ActOnCompoundStmt(SourceLocation lbrac,
SourceLocation rbrac, ...) is called every time a block is consumed,
when I try to print the location of the left bracket and the right
bracket I obtain something weird:
1) ActOnCompoundStmt() -> left bracket 5:4, right bracket 7:2 (line:column)
2) ActOnCompoundStmt() -> left bracket 2:22, right bracket 8:1
Naturally 1 is referred to the inner compound stmt while 2 to the main
body. As you see, the location of the left bracket is not correct, is
this an intended behavior or I am doing something wrong. I have to say,
to be complete, that in order to parse the pragmas I manually call the
ConsumeToken() of the Parser class, could be this the problem?
cheers, Simone
More information about the cfe-dev
mailing list