public inbox for [email protected]
help / color / mirror / Atom feedFrom: Ashutosh Sharma <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: ecpg: issue related to preprocessor directives
Date: Mon, 3 Aug 2020 16:00:06 +0530
Message-ID: <CAE9k0Pm1nzxJsmHM77ZmyCG==89mKyYqofz93WkqBm7LgtiiGA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAE9k0P=dQk9X0cU2tN49S7a9tv733-e1pVdpB1P-pWJ5PdTktg@mail.gmail.com>
<[email protected]>
On Sat, Aug 1, 2020 at 5:36 AM Tom Lane <[email protected]> wrote:
>
> Ashutosh Sharma <[email protected]> writes:
> > When the following ecpg program having preprocessor directives is compiled,
> > the output produced is not correct.
> > ...
> > As seen from above output, both exec sql ifdef and exec sql else block got
> > compiled which is wrong. If the above output is further compiled using gcc
> > compiler, the compilation would fail.
>
> Looking at pgc.l, it seems that 'elif' is treated as though it were
> 'endif' followed by 'ifdef', which of course completely loses the
> expected property that a previous successful branch would keep the
> elif branch from being expanded.
Yeah, that's right. The point is, while processing the elif branch, we
remove an entry for the previous branch (ifdef, ifndef) from the stack
and push a new entry for the current elif branch. So, if the elif
branch is evaluated to false, the else branch gets automatically
evaluated to true. And as a result of that both ifdef and else branch
gets evaluated to true thereby compiling both (ifdef/ifndef, else)
blocks.
--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com
view thread (7+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected]
Subject: Re: ecpg: issue related to preprocessor directives
In-Reply-To: <CAE9k0Pm1nzxJsmHM77ZmyCG==89mKyYqofz93WkqBm7LgtiiGA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox