[cfe-dev] Unneeded declarations invalidation
Enea Zaffanella
zaffanella at cs.unipr.it
Tue Jul 7 00:48:06 PDT 2009
Eli Friedman wrote:
> 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.
[...SNIP...]
>> 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.
>
> -Eli
Hello.
Please find attached a small patch that fixes what is, to my
understanding, another occurrence of an unneeded declaration
invalidation (triggered by non-standard use of VM types).
The testcase is the following:
====================
void p(int a) {
struct {
char x[(int)(char*)2 - 4000];
char y[a];
} f;
}
====================
which currently clang treats as follows:
====================
# Debug/bin/clang-cc -ast-print bug.c
bug.c:4:10: error: array size is negative
char x[(int)(char*)2 - 4000];
^
bug.c:5:10: error: fields must have a constant
size: 'variable length array in structure' extension will never be
supported
char y[a];
^
[...SNIP...]
void p(int a) {
struct {
int x;
int y;
} f;
}
2 diagnostics generated.
====================
After the patch, it will become:
====================
# Debug/bin/clang-cc -ast-print bug.c
bug.c:4:10: error: array size is negative
char x[(int)(char*)2 - 4000];
^
bug.c:5:10: error: fields must have a constant
size: 'variable length array in structure' extension will never be
supported
char y[a];
^
[...SNIP...]
void p(int a) {
struct {
char x[(int)(char *)2 - 4000];
char y[a];
} f;
}
2 diagnostics generated.
====================
Hence, the error is still reported as it was,
but the AST generation is more faithful to the original.
The latter property is important for clients such as ours.
Cheers,
Enea Zaffanella.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: VM_types_in_records.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090707/b0e6dce3/attachment.ksh>
More information about the cfe-dev
mailing list