[cfe-dev] Should we build semantically invalid nodes?

Doug Gregor doug.gregor at gmail.com
Thu Oct 23 11:15:12 PDT 2008


On Thu, Oct 23, 2008 at 10:47 AM, Argiris Kirtzidis <akyrtzi at gmail.com> wrote:
> Sebastian Redl wrote:
>>
>> From a purely practical standpoint, and possibly a minor issue,
>> disallowing the construction of AST elements for invalid code means that for
>> EXTENSION-diagnostics I also have to check for -pedantic-errors myself and
>> prevent AST construction in this case.
>>
>> I don't know how widespread use of those is. There's one in
>> CheckReinterpretCast.
>
> This is an excellent example for that the syntax tree and the semantic
> checks are somewhat orthogonal. The fact that a syntactic construct is
> semantically valid or invalid based on a compiler flag, does not affect the
> ability of Sema to handle it later on.

If it's an extension, then naturally all of the other syntactic and
semantic routines in the compiler have to deal with this kind of tree.
More importantly, if it's an extension that we support then the
resulting AST node is, by definition, semantically correct. We might
complain about the use of the extension, but it's not something that's
outside what Clang can handle.

  - Doug



More information about the cfe-dev mailing list