[cfe-dev] Sema && redefinitions

Anton Korobeynikov asl at math.spbu.ru
Thu Dec 4 16:56:39 PST 2008


Hello, Everyone

We faced with the following problem trying to add sema checks for
dllimport / dllexport attributes.

Consider the following situation:

void __attribute__((dllimport)) foo();

void foo() {
}

In this situation we need to ignore dllimport attribute everywhere and
issue warning. The problem is that at the point, when we just saw the
body of foo() w/o dllimport attribute - all attributes were already
merged in and thus we cannot distinguish declaration and redefintion.

Another approach is the store first decl somewhere and process in the
late end of sema. But then we faced with one problem... How one can
obtain definition of 'foo' given a first declaration? It seems, that
getPreviousDeclaration() works only backward, is there way to obtain the
definition?

All other possible solutions look really hacky and lead to significant
overhead (e.g. checks on each definition, etc).

Or... maybe there is some other clever way to do semanatic checks in
such situations we're not aware of?

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.




More information about the cfe-dev mailing list