Patchwork misc gengtype micro-patch (use macro for predefined typedef)

login
register
mail settings
Submitter Basile Starynkevitch
Date Nov. 5, 2010, 8:16 p.m.
Message ID <20101105211620.d36ff536.basile@starynkevitch.net>
Download mbox | patch
Permalink /patch/70290/
State New
Headers show

Comments

Basile Starynkevitch - Nov. 5, 2010, 8:16 p.m.
The following patch is a cleaner macro to
force the pos to the actual position. (I actually created 
the mistake by indenting the file too GNU-sely).


       for (i = 0; i < num_gt_files; i++)
 	{
################ gcc/ChangeLog entry
2010-11-05  Basile Starynkevitch  <basile@starynkevitch.net>
	* gengtype (main): Get here's position using POS_HERE macro for 
          do*typedef calls.
############## 

Ok for trunk?

PS. Since I am changing web provider next week, I might have transitory
email problems. If an email bounce to basile@starynkevitch.net please
resend it to both basile.starynkevitch@gmail.com &
basile.starynkevitch@cea.fr (but don't use these emails when
basile@starynkevitch.net works)
Basile Starynkevitch - Nov. 5, 2010, 8:17 p.m.
On Fri, 5 Nov 2010 21:16:20 +0100
Basile Starynkevitch <basile@starynkevitch.net> wrote:
> +#define POS_HERE(Call) do { pos.file = this_file; pos.line = __LINE__;
> \

Something get wrong with my emailer. Please consider the backslash to be on the same line as the #define
Richard Guenther - Nov. 6, 2010, 2:35 p.m.
On Fri, Nov 5, 2010 at 9:16 PM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> The following patch is a cleaner macro to
> force the pos to the actual position. (I actually created
> the mistake by indenting the file too GNU-sely).
>
>
> Index: gcc/gengtype.c
> ===================================================================
> --- gcc/gengtype.c      (revision 166376)
> +++ gcc/gengtype.c      (working copy)
> @@ -4531,28 +4536,21 @@ main (int argc, char **argv)
>       /* These types are set up with #define or else outside of where
>          we can see them.  We should initialize them before calling
>          read_input_list.  */
> -      pos.file = this_file;
> -      pos.line = __LINE__ + 1;
> -      do_scalar_typedef ("CUMULATIVE_ARGS", &pos);
> -      pos.line++;
> -      do_scalar_typedef ("REAL_VALUE_TYPE", &pos);
> -      pos.line++;
> -      do_scalar_typedef ("FIXED_VALUE_TYPE", &pos);
> -      pos.line++;
> -      do_scalar_typedef ("double_int", &pos);
> -      pos.line++;
> -      do_scalar_typedef ("uint64_t", &pos);
> -      pos.line++;
> -      do_scalar_typedef ("uint8", &pos);
> -      pos.line++;
> -      do_scalar_typedef ("jword", &pos);
> -      pos.line++;
> -      do_scalar_typedef ("JCF_u2", &pos);
> -      pos.line++;
> -      do_scalar_typedef ("void", &pos);
> -      pos.line++;
> -      do_typedef ("PTR", create_pointer (resolve_typedef ("void",
> &pos)),
> -                 &pos);
> +#define POS_HERE(Call) do { pos.file = this_file; pos.line = __LINE__;
> \
> +       Call;} while(0)
> +      POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos));
> +      POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos));
> +      POS_HERE (do_scalar_typedef ("FIXED_VALUE_TYPE", &pos));
> +      POS_HERE (do_scalar_typedef ("double_int", &pos));
> +      POS_HERE (do_scalar_typedef ("uint64_t", &pos));
> +      POS_HERE (do_scalar_typedef ("uint8", &pos));
> +      POS_HERE (do_scalar_typedef ("jword", &pos));
> +      POS_HERE (do_scalar_typedef ("JCF_u2", &pos));
> +      POS_HERE (do_scalar_typedef ("void", &pos));
> +      POS_HERE (do_typedef ("PTR",
> +                           create_pointer (resolve_typedef ("void", &pos)),
> +                           &pos));

This doesn't look like a 1:1 transformation - who increments pos.line?

> +#undef POS_HERE
>       read_input_list (inputlist);
>       for (i = 0; i < num_gt_files; i++)
>        {
> ################ gcc/ChangeLog entry
> 2010-11-05  Basile Starynkevitch  <basile@starynkevitch.net>
>        * gengtype (main): Get here's position using POS_HERE macro for
>          do*typedef calls.
> ##############
>
> Ok for trunk?
>
> PS. Since I am changing web provider next week, I might have transitory
> email problems. If an email bounce to basile@starynkevitch.net please
> resend it to both basile.starynkevitch@gmail.com &
> basile.starynkevitch@cea.fr (but don't use these emails when
> basile@starynkevitch.net works)
> --
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mine, sont seulement les miennes} ***
>
Basile Starynkevitch - Nov. 6, 2010, 2:59 p.m.
On Sat, 6 Nov 2010 15:35:17 +0100
Richard Guenther <richard.guenther@gmail.com> wrote:

>> +#define POS_HERE(Call) do { pos.file = this_file; pos.line = __LINE__; \
>> +       Call;} while(0)
>> +      POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos));
>> +      POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos));

> This doesn't look like a 1:1 transformation - who increments pos.line?

pos.line is not supposed to be incremented, but to give the accurate
line number.

It was incremented in 4.5 to avoid using __LINE__ repeatedly. (that was
a poor way of doing it, IMHO)

Then, I indented gengtype and the line increment got on seperate line,
which sucks.

Cheers
Laurynas Biveinis - Nov. 8, 2010, 2:21 a.m.
2010/11/5 Basile Starynkevitch <basile@starynkevitch.net>:
> 2010-11-05  Basile Starynkevitch  <basile@starynkevitch.net>
>        * gengtype (main): Get here's position using POS_HERE macro for
>          do*typedef calls.

Richard -

This patch is a 1:1 transformation from a pre-indent-run gengtype.
Also, it is not terribly critical to get the line numbers right here.

Basile -

This patch is OK, unless Richard objects. Thanks,
Basile Starynkevitch - Nov. 8, 2010, 6:09 a.m.
On Mon, 8 Nov 2010 04:21:11 +0200
Laurynas Biveinis <laurynas.biveinis@gmail.com> wrote:

> 2010/11/5 Basile Starynkevitch <basile@starynkevitch.net>:
> > 2010-11-05  Basile Starynkevitch  <basile@starynkevitch.net>
> >        * gengtype (main): Get here's position using POS_HERE macro for
> >          do*typedef calls.
> This patch is OK, unless Richard objects. Thanks,

Committed revision 166428.

PS: Laurynas, if mails to me bounce, please use
basile@ours.starynkevitch.net or basile.starynkevitch@gmail.com or
basile.starynkevitch@cea.fr
Laurynas Biveinis - Nov. 8, 2010, 6:17 a.m.
2010/11/8 Basile Starynkevitch <basile@starynkevitch.net>:
>> This patch is OK, unless Richard objects. Thanks,
>
> Committed revision 166428.

You didn't wait to see if Richard objects. Now let's hope he doesn't :)

Patch

Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c	(revision 166376)
+++ gcc/gengtype.c	(working copy)
@@ -4531,28 +4536,21 @@  main (int argc, char **argv)
       /* These types are set up with #define or else outside of where
          we can see them.  We should initialize them before calling
          read_input_list.  */
-      pos.file = this_file;
-      pos.line = __LINE__ + 1;
-      do_scalar_typedef ("CUMULATIVE_ARGS", &pos);
-      pos.line++;
-      do_scalar_typedef ("REAL_VALUE_TYPE", &pos);
-      pos.line++;
-      do_scalar_typedef ("FIXED_VALUE_TYPE", &pos);
-      pos.line++;
-      do_scalar_typedef ("double_int", &pos);
-      pos.line++;
-      do_scalar_typedef ("uint64_t", &pos);
-      pos.line++;
-      do_scalar_typedef ("uint8", &pos);
-      pos.line++;
-      do_scalar_typedef ("jword", &pos);
-      pos.line++;
-      do_scalar_typedef ("JCF_u2", &pos);
-      pos.line++;
-      do_scalar_typedef ("void", &pos);
-      pos.line++;
-      do_typedef ("PTR", create_pointer (resolve_typedef ("void",
&pos)),
-		  &pos);
+#define POS_HERE(Call) do { pos.file = this_file; pos.line = __LINE__;
\
+	Call;} while(0)
+      POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos));
+      POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos));
+      POS_HERE (do_scalar_typedef ("FIXED_VALUE_TYPE", &pos));
+      POS_HERE (do_scalar_typedef ("double_int", &pos));
+      POS_HERE (do_scalar_typedef ("uint64_t", &pos));
+      POS_HERE (do_scalar_typedef ("uint8", &pos));
+      POS_HERE (do_scalar_typedef ("jword", &pos));
+      POS_HERE (do_scalar_typedef ("JCF_u2", &pos));
+      POS_HERE (do_scalar_typedef ("void", &pos));
+      POS_HERE (do_typedef ("PTR", 
+			    create_pointer (resolve_typedef ("void", &pos)),
+			    &pos));
+#undef POS_HERE
       read_input_list (inputlist);