This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: compile server design document


On Thu, 27 Feb 2003, Per Bothner wrote:

> > Note that any place where an identifier is lexed as not 
> > currently declared as a typedef, this must be treated as having a negative 
> > dependency,
> 
> I think this is only an issue when an identifier is being declared,
> since when the identifier is *used*, a positive dependency is noted.
> I also think this could only be an issue for non-local declarations,
> since otherwise the duplicate definition will be caught.

In C90 you have implicit function declarations, so given a declaration of 
x in an outer scope,

  foo(x);

redeclares x if foo is a typedef, but implicitly declares and calls a
function foo if foo isn't declared.  (No doubt header files should not
contain that sort of thing in inline functions, but I think compile-time
performance optimisations ought to start from the basis of always being
correct, even in corner cases, and then optimise particular cases where a
dependency isn't needed when it can be shown this is correct in that
particular case.)

> > This is an area where seeing the testsuite for the dependency handling
> > would be more useful at this point than the source code for an
> > implementation of it.
> 
> Hm.  I guess I need to learn how to write such tests in an
> other-than-ad-hoc manner.

Go through the standards sentence-by-sentence to find all ways in which
the interpretation or validity of code can depend on previous code in the
same translation unit.  For C this should mostly be covered (apart from
the preprocessor cases) by every reference to an identifier having
dependencies on any relevant declaration in scope, or on the absence of
such - but the declared type of an identifier could be a composite type
arising from several source code declarations, and for GCC warnings there
may be other cases, e.g. checking based on extern declarations that have
gone out of scope, but warnings for which may still be useful.  And
explicit declarations may modify built-in function declarations (which you
wanted to initialise only once), e.g. adding attributes to them.

The tests would probably be of the form: run one compilation that uses a
header that uses or declares an identifier in a particular way (a test for
every standard case of how it might be used or declared).  Then run
another compilation in which the context for that identifier's use or
declaration is different (in every way in the standard in which it might
be different leading to different warnings or code generation) and check
that the diagnostics and code are identical to those without the server.

-- 
Joseph S. Myers
jsm28 at cam dot ac dot uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]