public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/67784] New: Incorrect parsing when using declarations in for loops and typedefs
@ 2015-09-30 14:14 jacques-henri.jourdan at inria dot Fr
  2015-09-30 15:18 ` [Bug c/67784] " jacques-henri.jourdan at inria dot Fr
  0 siblings, 1 reply; 2+ messages in thread
From: jacques-henri.jourdan at inria dot Fr @ 2015-09-30 14:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67784

            Bug ID: 67784
           Summary: Incorrect parsing when using declarations in for loops
                    and typedefs
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jacques-henri.jourdan at inria dot Fr
  Target Milestone: ---

The following code snippet does not parse correctly:

typedef int T;

void h() {
  for(int T; ;)
    if(1)
      ;
  T *x;
  x = 0;
}

However, this one does:

typedef int T;

void h() {
  for(int T; ;)
    if(1)
      ;
  ;
  T *x;
  x = 0;
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/67784] Incorrect parsing when using declarations in for loops and typedefs
  2015-09-30 14:14 [Bug c/67784] New: Incorrect parsing when using declarations in for loops and typedefs jacques-henri.jourdan at inria dot Fr
@ 2015-09-30 15:18 ` jacques-henri.jourdan at inria dot Fr
  0 siblings, 0 replies; 2+ messages in thread
From: jacques-henri.jourdan at inria dot Fr @ 2015-09-30 15:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67784

--- Comment #1 from Jacques-Henri Jourdan <jacques-henri.jourdan at inria dot Fr> ---
My explanation of the problem is that the parser has to do a lookahead to make
sure that there is no "else" associated to the selection statement. However,
this lookahead is done in the wrong context, which make T look like a variable
(while it is actually a type name).


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-30 15:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30 14:14 [Bug c/67784] New: Incorrect parsing when using declarations in for loops and typedefs jacques-henri.jourdan at inria dot Fr
2015-09-30 15:18 ` [Bug c/67784] " jacques-henri.jourdan at inria dot Fr

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).