pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Zdenek Kotala <Zdenek.Kotala@Sun.COM>
To: Michael Meskes <meskes@postgresql.org>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Compiler warning cleanup - unitilized const variables, pointer type mismatch
Date: Thu, 28 May 2009 16:34:38 +0200
Message-ID: <1243521278.22457.13.camel@localhost> (raw)
In-Reply-To: <20090528124723.GA23989@feivel.credativ.lan>
References: <1243501880.1372.23.camel@localhost>
	<20090528113347.GB9247@feivel.credativ.lan>
	<1243511467.1372.43.camel@localhost>
	<20090528124723.GA23989@feivel.credativ.lan>


Michael Meskes píše v čt 28. 05. 2009 v 14:47 +0200:
> On Thu, May 28, 2009 at 01:51:07PM +0200, Zdenek Kotala wrote:
> > Problem is with YYLLOC_DEFAULT. When I look on macro definition 
> > 
> > #define YYLLOC_DEFAULT(Current, Rhs, N)          \
> >   Current.first_line   = Rhs[1].first_line;      \
> >   Current.first_column = Rhs[1].first_column;    \
> >   Current.last_line    = Rhs[N].last_line;       \
> >   Current.last_column  = Rhs[N].last_column;
> > 
> > It seems to me that it is OK, because 1 is used as a index which finally
> > point on yyerror_range[0]. 
> 
> Wait, this is the bison definition. Well to be more precise the bison
> definition in your bison version. Mine is different:

I took it from documentation. I have same as you in generated code.

> # define YYLLOC_DEFAULT(Current, Rhs, N)                                \
>     do                                                                  \
>       if (YYID (N))                                                    \
>         {                                                               \
>           (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
>           (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
>           (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
>           (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
>         }                                                               \
>       else                                                              \
>         {                                                               \
>           (Current).first_line   = (Current).last_line   =              \
>             YYRHSLOC (Rhs, 0).last_line;                                \
>           (Current).first_column = (Current).last_column =              \
>             YYRHSLOC (Rhs, 0).last_column;                              \
>        }                                                               \
>     while (YYID (0))
> 
> Having said that, it doesn't really matter as we redefine the macro:
> 
> #define YYLLOC_DEFAULT(Current, Rhs, N) \
>         do { \
>                 if (N) \
>                         (Current) = (Rhs)[1]; \
>                 else \
>                         (Current) = (Rhs)[0]; \
>         } while (0)
> 
> I have to admit that those version look strikingly unsimilar to me. There is no
> reference to Rhs[N] in our macro at all. But then I have no idea whether this
> is needed.

Current is only int. See gramparse.h. I think we could rewrite it this
way:

#define YYLLOC_DEFAULT(Current, Rhs, N) \
	do { \
		if (N) \
			(Current) = (Rhs)[1]; \
		else \
			(Current) = (Rhs)[N]; \
	} while (0)

It is same result and compiler is quite.

		Zdenek








view thread (10+ messages)  latest in thread

Message-ID: <1243521278.22457.13.camel@localhost>
Permalink:  ../1243521278.22457.13.camel@localhost/
Also on:    postgresql.org/message-id/1243521278.22457.13.camel@localhost

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: Zdenek.Kotala@Sun.COM, meskes@postgresql.org
  Subject: Re: Compiler warning cleanup - unitilized const variables, pointer type mismatch
  In-Reply-To: <1243521278.22457.13.camel@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox