public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mmitchel at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/12581] [3.4 Regression] gcc rejects typeof use for the return type
Date: Wed, 12 Nov 2003 16:14:00 -0000	[thread overview]
Message-ID: <20031112161441.27951.qmail@sources.redhat.com> (raw)
In-Reply-To: <20031011162654.12581.pinskia@gcc.gnu.org>


------- Additional Comments From mmitchel at gcc dot gnu dot org  2003-11-12 16:14 -------
There are two pieces of code in this PR; comment #1 and comment #2.

(1) In comment #2, GCC does not accept the code, either.  That's because:

  typedef int (F)();
  F() x;

is not syntactically valid either.

(3) In the example in comment #1, the problem is more complex.  The "typeof"
keyword, like the "sizeof" keyword, can be used in two alternative productions:

sizeof type-id
sizeof unary-expression

In comment #1, it is the second production which is used.  Note that this second
production is *not* "sizeof (unary-expression)"; the unary-expression is not
parenthesized.  

One alternative for a unary-expression is a postfix-expression.  

A postfix-expression can have the form "x (...)".  

That is the syntactic form of the line in comment #1: (Just...) (....).  The
parser becomes unhappy when it sees "bar::*" because "*" is not a valid identifier.

(This case is analogous to "sizeof f ()" which is valid C/C++.)

To try to recover from the case where the arguments to the function call are not
valid would require a considerable amount of code and a slower parser.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12581


  parent reply	other threads:[~2003-11-12 16:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-11 16:26 [Bug c++/12581] New: [3.4 Regression ] " pinskia at gcc dot gnu dot org
2003-10-13  3:27 ` [Bug c++/12581] " pinskia at gcc dot gnu dot org
2003-10-16 16:14 ` ehrhardt at mathematik dot uni-ulm dot de
2003-10-22  1:25 ` [Bug c++/12581] [3.4 Regression] " bangerth at dealii dot org
2003-10-22  1:27 ` bangerth at dealii dot org
2003-11-12  3:14 ` mmitchel at gcc dot gnu dot org
2003-11-12  3:16 ` mmitchel at gcc dot gnu dot org
2003-11-12 12:35 ` gabor dot greif at lucent dot com
2003-11-12 12:43 ` gdr at integrable-solutions dot net
2003-11-12 14:03 ` gabor dot greif at lucent dot com
2003-11-12 14:29 ` gdr at integrable-solutions dot net
2003-11-12 16:14 ` mmitchel at gcc dot gnu dot org [this message]
2003-11-13  8:23 ` gabor dot greif at lucent dot com

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031112161441.27951.qmail@sources.redhat.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).