[cfe-dev] Unneeded declarations invalidation

Eli Friedman eli.friedman at gmail.com
Thu Jul 2 02:12:01 PDT 2009

On Thu, Jul 2, 2009 at 1:30 AM, Abramo Bagnara<abramobagnara at tin.it> wrote:
> The following typescript show what happens when trying to compile a
> simple C source not legal for C99 standard, but accepted and compiled by
> gcc.
> The C source is a simplified version of a problem seen in linux-2.6.

If I'm reading the testcase, correctly,
http://llvm.org/bugs/show_bug.cgi?id=4065 .  We tentatively decided
that since the construct is rare, it wasn't worth messing with clang
to handle this funny edge case; I wouldn't mind a clean patch to
degrade it to a warning, though.

> I'm not sure that in this case an error is better than a proper warning,
> but that apart I believe that the choice to invalidate the decl and then
> inhibits the generation of code dependending on it is not a good idea
> when that is not strictly needed.

A real error (marked Error in the diagnostic lists) can't be
downgraded because we can't guarantee working output.  With a clean
fix with a warning, I don't see any point to defaulting this to error

> Resuming, if codegen is not concerned by this construct (not legal for
> C99 but legal for gcc) I'd like to turn it in a proper warning
> (otherwise obviously we should leave it a fatal error).

IRGen wouldn't mind if we handled it the same way as tentative
declarations for variables with external linkage.

> OTOH in both cases, I'd like to avoid to invalidate the declaration and
> thus to inhibit ast generation if this is not strictly needed.

Mmm... yeah, even if we don't fix this, we probably don't need to mark
the declaration invalid; it's well-formed in any case.


More information about the cfe-dev mailing list