* RE: possible parser bug?
@ 1998-11-06 11:00 Wegher, Jeff
1998-11-06 23:39 ` Alexandre Oliva
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Wegher, Jeff @ 1998-11-06 11:00 UTC (permalink / raw)
To: 'Michael Iber', egcs
Your line:
B(GetA()->f());
looks like a function declaration rather than a constructor, and it's
invalid syntax for a function declaration.
Try B aB(GetA()->f());
Works fine.
Jeff
> -----Original Message-----
> From: Michael Iber [SMTP:michael.iber@siemens.at]
> Sent: Friday, November 06, 1998 5:25 AM
> To: egcs@cygnus.com
> Subject: possible parser bug?
>
> I have a problem with the egcs parser.
> It raises an error message on code that seems syntactically correct to me.
> It seems the egcs parser knows, it is inside a constructor parameter list.
>
> In a function call parameter list there is no parse error.
>
> the code:
>
> class A
> {
> public:
> A() {};
> int f() { return 1; };
> };
>
> class B
> {
> public:
> B(int) {};
> };
>
> A* GetA() { return new A(); };
>
> int main()
> {
> B(GetA()->f());
> }
>
> the error message:
>
> test1.cxx: In function `int main()':
> test1.cxx:18: parse error before `->'
>
> egcs-1.0.3, egcs-1.1 and egcs-ss981101 show the same behaviour.
>
> mike
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: possible parser bug?
1998-11-06 11:00 possible parser bug? Wegher, Jeff
@ 1998-11-06 23:39 ` Alexandre Oliva
1998-11-07 2:46 ` Martin von Loewis
1998-11-09 4:40 ` Michael Iber
2 siblings, 0 replies; 5+ messages in thread
From: Alexandre Oliva @ 1998-11-06 23:39 UTC (permalink / raw)
To: Wegher, Jeff; +Cc: 'Michael Iber', egcs
On Nov 6, 1998, "Wegher, Jeff" <JWegher@neonsoft.com> wrote:
> Your line:
> B(GetA()->f());
> looks like a function declaration rather than a constructor, and it's
> invalid syntax for a function declaration.
I don't think this is one of the cases of ambiguity. This can't
possibly be a declaration, so it must be interpreted as an
expression-statement.
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva aoliva@{acm.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.anu.edu.au}
Universidade Estadual de Campinas, SP, Brasil
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: possible parser bug?
1998-11-06 11:00 possible parser bug? Wegher, Jeff
1998-11-06 23:39 ` Alexandre Oliva
@ 1998-11-07 2:46 ` Martin von Loewis
1998-11-09 4:40 ` Michael Iber
2 siblings, 0 replies; 5+ messages in thread
From: Martin von Loewis @ 1998-11-07 2:46 UTC (permalink / raw)
To: JWegher; +Cc: michael.iber, egcs
> Your line:
>
> B(GetA()->f());
>
> looks like a function declaration rather than a constructor, and it's
> invalid syntax for a function declaration.
Although this explanation is correct with regard to the
implementation, it is not with regard to the standard.
There is no way this could be a function declaration: The return type
is missing, so this is clearly a function-style. Of course, g++
assumes "int" here, which is an error.
In addition, this has a class member access in it, so it can be
clearly disambiguated as an expression, according to
[stmt.ambig]. It's just that g++ does not get it right.
Regards,
Martin
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: possible parser bug?
1998-11-06 11:00 possible parser bug? Wegher, Jeff
1998-11-06 23:39 ` Alexandre Oliva
1998-11-07 2:46 ` Martin von Loewis
@ 1998-11-09 4:40 ` Michael Iber
2 siblings, 0 replies; 5+ messages in thread
From: Michael Iber @ 1998-11-09 4:40 UTC (permalink / raw)
To: JWegher, egcs
>Your line:
>
> B(GetA()->f());
>
>looks like a function declaration rather than a constructor, and it's
>invalid syntax for a function declaration.
>
>Try B aB(GetA()->f());
>
>Works fine.
It should be a constructor, but I think the example was too short.
I use code like this
if (flag)
B(GetA()->f()).Execute();
e.g to display a modal window on screen, depending on some condition.
An instance of B is created only to call Execute() and destroyed
automatically after the call.
There the parse error occurs. It works fine for function calls.
mike
^ permalink raw reply [flat|nested] 5+ messages in thread
* possible parser bug?
@ 1998-11-06 4:27 Michael Iber
0 siblings, 0 replies; 5+ messages in thread
From: Michael Iber @ 1998-11-06 4:27 UTC (permalink / raw)
To: egcs
I have a problem with the egcs parser.
It raises an error message on code that seems syntactically correct to me.
It seems the egcs parser knows, it is inside a constructor parameter list.
In a function call parameter list there is no parse error.
the code:
class A
{
public:
A() {};
int f() { return 1; };
};
class B
{
public:
B(int) {};
};
A* GetA() { return new A(); };
int main()
{
B(GetA()->f());
}
the error message:
test1.cxx: In function `int main()':
test1.cxx:18: parse error before `->'
egcs-1.0.3, egcs-1.1 and egcs-ss981101 show the same behaviour.
mike
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1998-11-09 4:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-06 11:00 possible parser bug? Wegher, Jeff
1998-11-06 23:39 ` Alexandre Oliva
1998-11-07 2:46 ` Martin von Loewis
1998-11-09 4:40 ` Michael Iber
-- strict thread matches above, loose matches on Subject: below --
1998-11-06 4:27 Michael Iber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).