This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] timevar TLC
On Tue, Aug 14, 2012 at 10:46 PM, Lawrence Crowl <crowl@googlers.com> wrote:
> You can check the error statically. Something like
>
> % cat limitstring.c
> #define LIMIT 32
>
> struct def {
> int x;
> char name[LIMIT+1];
> };
>
> struct def var[] = {
> { 3, "hello" },
> { 4, "name is much too too long for a reasonable name" },
> };
>
> % gcc -c limitstring.c -Werror
> cc1: warnings being treated as errors
> limitstring.c:10: error: initializer-string for array of chars is too long
> limitstring.c:10: error: (near initialization for 'timevars[1].name')
>
> But of course the variable definition would look more like
>
> #define DEFTIMEVAR(identifier__, name__) \
> { ...., name__, ... },
> struct def var[] = {
> #include "timevar.def"
> };
That looks much better than my hack! I'll see if I can find some time
to implement this idea.
In the mean time I've committed my patch without the timevar.c bits.
Ciao!
Steven