This is the mail archive of the gcc-patches@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: [patch] Stop gengtype from emitting empty loops


On Tue, Jul 24, 2012 at 12:11 PM, Laurynas Biveinis
<laurynas.biveinis@gmail.com> wrote:
>> I think it merely points to a bogus GTY annotation, not sure if we want to
>> gobble this kind of gengtype hacks which only benefit -O0 ...
>>
>> The annotation is libcpp/include/line-map.h
>>
>>      In the example above x1 (for token "+") is going to be the same
>>      as y1.  x0 is the spelling location for the argument token "1",
>>      and x2 is the spelling location for the argument token "2".  */
>>   source_location * GTY((length ("2 * %h.n_tokens"))) macro_locations;
>
> This one indeed looks redundant, are there others?

Yes:
../../trunk/gcc/../libcpp/include/line-map.h:168: option `length' may
not be applied to arrays of scalar types
../../trunk/gcc/emit-rtl.c:5913: option `length' may not be applied to
arrays of scalar types
../../trunk/gcc/java/jcf.h:85: option `length' may not be applied to
arrays of scalar types
../../trunk/gcc/java/jcf.h:94: option `length' may not be applied to
arrays of scalar types

The emit-rtl.c one is for DEF_VEC_O(location_t);


Index: gengtype.c
===================================================================
--- gengtype.c  (revision 189778)
+++ gengtype.c  (working copy)
@@ -1256,7 +1256,17 @@ adjust_field_type (type_p t, options_p opt)

   for (; opt; opt = opt->next)
     if (strcmp (opt->name, "length") == 0)
-      length_p = 1;
+      {
+       if (length_p)
+         error_at_line (&lexer_line, "duplicate `%s' option", opt->name);
+       if (t->u.p->kind == TYPE_SCALAR && ! t->u.p->u.scalar_is_char)
+         {
+           error_at_line (&lexer_line,
+                          "option `%s' may not be applied to arrays
of scalar types",
+                          opt->name);
+         }
+       length_p = 1;
+      }
     else if ((strcmp (opt->name, "param_is") == 0
              || (strncmp (opt->name, "param", 5) == 0
                  && ISDIGIT (opt->name[5])


> I am wondering if
> there is something that would produce an empty loop for GC but not for
> PCH or the other way around.

You're the one who's supposed to understand all of this best ;-)

Ciao!
Steven


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