This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/39028] New: C++ front-end rejects "__label__" at the beginning of a block after "for" and "while"
- From: "springl-gcc at bfw-online dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jan 2009 20:08:08 -0000
- Subject: [Bug c++/39028] New: C++ front-end rejects "__label__" at the beginning of a block after "for" and "while"
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Trying to compile the c++ program label.C
void c ()
{ for (;;) {__label__ l; goto l; l:;}
while (1) {__label__ l; goto l; l:;}
if (1) {__label__ l; goto l; l:;}
do {__label__ l; goto l; l:;} while (1);
{__label__ l; goto l; l:;}
}
using
g++ -Wall -Wextra -c label.C
with g++ versions 4.4.0 20090129 (experimental) and 4.3.3 gives:
label.C: In function 'void c()':
label.C:2: error: '__label__' not at the beginning of a block
label.C:3: error: '__label__' not at the beginning of a block
label.C:3: error: duplicate label 'l'
The fix for bug 32121 "C++ front-end accepts invalid __label__
declarations" (svn revision 129253) moved handling __label__ declarations
to function cp_parser_compound_statement in gcc/cp/parser.c and omitted
it in function cp_parser_already_scoped_statement. The newly introduced
tests cases only check the error case for while and for statements,
unfortunately.
Without any deeper understanding of gcc internals, I suggest two
possible fixes:
- copy the two lines handling __label__ declarations
from function cp_parser_compound_statement to function
cp_parser_already_scoped_statement, which might be the smallest change or
- merge part of cp_parser_already_scoped_statement's functionality to
cp_parser_compound_statement avoiding code duplication.
--
Summary: C++ front-end rejects "__label__" at the beginning of a
block after "for" and "while"
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: springl-gcc at bfw-online dot de
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39028