Bug 46890 - [4.6 Regression] Failed to compile scummvm's player_v4a.cpp
Summary: [4.6 Regression] Failed to compile scummvm's player_v4a.cpp
Status: VERIFIED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P1 normal
Target Milestone: 4.6.0
Assignee: Nathan Froyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-10 23:45 UTC by Matt Hargett
Modified: 2011-04-12 18:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-12-16 14:49:03


Attachments
pre-processed source of the file that triggers the compilation regression (42.04 KB, application/x-bzip)
2010-12-17 00:38 UTC, Matt Hargett
Details
original source file (2.38 KB, text/x-c++src)
2010-12-17 00:39 UTC, Matt Hargett
Details
gcc46-pr46890.patch (874 bytes, patch)
2011-01-19 12:24 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Hargett 2010-12-10 23:45:46 UTC
using 4.6.0 20101206 (experimental) [trunk revision 167481]:

building the open source project, scummvm (http://scummvm.org) trunk revision :
54858
matt@matt-desktop:~/src/scummvm$ CXX=/usr/lib/gcc-snapshot/bin/g++ ./configure --enable-all-engines
[...]
matt@matt-desktop:~/src/scummvm$ make
[...]
In file included from ./engines/scumm/player_v4a.h:32:0,
                 from engines/scumm/player_v4a.cpp:27:
./sound/mods/tfmx.h:115:2: error: expected ';' after struct definition
./sound/mods/tfmx.h:115:11: error: ISO C++ forbids declaration of '_resource' with no type [-fpermissive]

[ ... and then several more compile errors that snowball from the first one ... ]

The code in question looks like this:


        struct MdatResource {
                const byte *mdatAlloc;  ///< allocated Block of Memory
                const byte *mdatData;   ///< Start of mdat-File, might point before mdatAlloc to correct Offset
                uint32 mdatLen;

                uint16 headerFlags;
//              uint32 headerUnknown;
//              char textField[6 * 40];

                struct Subsong {
                        uint16 songstart;       ///< Index in Trackstep-Table
                        uint16 songend;         ///< Last index in Trackstep-Table
                        uint16 tempo;
                } subsong[kNumSubsongs];

                uint32 trackstepOffset; ///< Offset in mdat
                uint32 sfxTableOffset;

                uint32 patternOffset[kMaxPatternOffsets];       ///< Offset in mdat
                uint32 macroOffset[kMaxMacroOffsets];   ///< Offset in mdat

                void boundaryCheck(const void *address, size_t accessLen = 1) const {
                        assert(mdatAlloc <= address && (const byte *)address + accessLen <= (const byte *)mdatData + mdatLen);
                }
        } const *_resource;


Configuring with g++-4.5 (4.5.1-7ubuntu2) or g++-4.4 (Ubuntu/Linaro 4.4.4-14ubuntu5) fixes the compilation.
Comment 1 Richard Biener 2010-12-16 14:49:03 UTC
Please provide preprocessed source.
Comment 2 Matt Hargett 2010-12-17 00:38:14 UTC
Created attachment 22789 [details]
pre-processed source of the file that triggers the compilation regression

generated with this commandline using scummvm trunk sources:
/usr/lib/gcc-snapshot/bin/g++ -MMD -MF "engines/scumm/.deps/player_v4a.d" -MQ "engines/scumm/player_v4a.o" -MP -Wall -O3 -flto  -g  -ansi -W -Wno-unused-parameter -Wno-empty-body -pedantic -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder -Wpointer-arith -Wcast-qual -Wshadow -Wimplicit -Wnon-virtual-dtor -Wwrite-strings -fno-rtti -fno-exceptions -fcheck-new -DSCUMMVM_SVN_REVISION=\"54939\" -DHAVE_CONFIG_H -DUNIX -DDATA_PATH=\"/usr/local/share/scummvm\" -DPLUGIN_DIRECTORY=\"/usr/local/lib/scummvm\" -DSDL_BACKEND -DENABLE_SCUMM=STATIC_PLUGIN -DENABLE_SCUMM_7_8 -DENABLE_HE -DENABLE_AGI=STATIC_PLUGIN -DENABLE_AGOS=STATIC_PLUGIN -DENABLE_AGOS2 -DENABLE_CINE=STATIC_PLUGIN -DENABLE_CRUISE=STATIC_PLUGIN -DENABLE_DRACI=STATIC_PLUGIN -DENABLE_DRASCULA=STATIC_PLUGIN -DENABLE_GOB=STATIC_PLUGIN -DENABLE_GROOVIE=STATIC_PLUGIN -DENABLE_GROOVIE2 -DENABLE_HUGO=STATIC_PLUGIN -DENABLE_KYRA=STATIC_PLUGIN -DENABLE_LOL -DENABLE_LASTEXPRESS=STATIC_PLUGIN -DENABLE_LURE=STATIC_PLUGIN -DENABLE_M4=STATIC_PLUGIN -DENABLE_MADE=STATIC_PLUGIN -DENABLE_MOHAWK=STATIC_PLUGIN -DENABLE_PARALLACTION=STATIC_PLUGIN -DENABLE_QUEEN=STATIC_PLUGIN -DENABLE_SAGA=STATIC_PLUGIN -DENABLE_IHNM -DENABLE_SAGA2 -DENABLE_SCI=STATIC_PLUGIN -DENABLE_SCI32 -DENABLE_SKY=STATIC_PLUGIN -DENABLE_SWORD1=STATIC_PLUGIN -DENABLE_SWORD2=STATIC_PLUGIN -DENABLE_SWORD25=STATIC_PLUGIN -DENABLE_TESTBED=STATIC_PLUGIN -DENABLE_TEENAGENT=STATIC_PLUGIN -DENABLE_TINSEL=STATIC_PLUGIN -DENABLE_TOON=STATIC_PLUGIN -DENABLE_TOUCHE=STATIC_PLUGIN -DENABLE_TUCKER=STATIC_PLUGIN -I. -I. -I./engines -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -c engines/scumm/player_v4a.cpp -E > player_v4a.i
Comment 3 Matt Hargett 2010-12-17 00:39:27 UTC
Created attachment 22790 [details]
original source file
Comment 4 Matt Hargett 2010-12-17 00:40:55 UTC
Attached original and pre-processed sources. Re-tested with 4.6.0 20101215, problem is still happening.
Comment 5 H.J. Lu 2010-12-17 05:55:32 UTC
A simple testcase:

[hjl@gnu-35 rrs]$ cat pr46890.cc 
struct MdatResource {
const char *mdatAlloc;
} const *_resource;
[hjl@gnu-35 rrs]$ ./166977/usr/bin/gcc -S pr46890.cc
pr46890.cc:3:1: error: expected \u2018;\u2019 after struct definition
pr46890.cc:3:10: error: ISO C++ forbids declaration of \u2018_resource\u2019 with no type [-fpermissive]
[hjl@gnu-35 rrs]$ 

It is caused by revision 166977:

http://gcc.gnu.org/ml/gcc-cvs/2010-11/msg00866.html
Comment 6 Jakub Jelinek 2011-01-19 12:24:31 UTC
Created attachment 23028 [details]
gcc46-pr46890.patch

Untested fix.
Comment 7 Jakub Jelinek 2011-01-19 20:40:31 UTC
Reassigning back to Nathan, he apparently posted a patch at:
http://gcc.gnu.org/ml/gcc-patches/2010-12/msg01398.html
with feedback at:
http://gcc.gnu.org/ml/gcc-patches/2011-01/msg00252.html
Comment 8 froydnj@codesourcery.com 2011-01-26 15:06:09 UTC
Waiting on Jason to approve feedback-modified patch:

http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01667.html
Comment 9 Matt Hargett 2011-01-27 20:11:26 UTC
Still reproducible with this version:
g++ (Ubuntu/Linaro 20110126-0ubuntu1) 4.6.0 20110126 (experimental) [trunk revision 169283]
Comment 10 Nathan Froyd 2011-02-03 17:16:21 UTC
Author: froydnj
Date: Thu Feb  3 17:16:17 2011
New Revision: 169797

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169797
Log:
gcc/c-family/
	PR c++/46890
	* c-common.h (keyword_is_decl_specifier): Declare.
	* c-common.c (keyword_is_decl_specifier): Define.
	(keyword_is_function_specifier): New function.

gcc/cp/
	PR c++/46890
	* parser.c (cp_parser_class_specifier): Fix setting of
	want_semicolon.

gcc/testsuite/
	PR c++/46890
	* g++.dg/parser/semicolon3.C: Adjust.
	* g++.dg/parser/semicolon4.C: New testcase.
	* g++.dg/pr46890.C: New testcase.


Added:
    trunk/gcc/testsuite/g++.dg/parse/semicolon4.C
    trunk/gcc/testsuite/g++.dg/pr46890.C
Modified:
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-common.c
    trunk/gcc/c-family/c-common.h
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/parse/semicolon3.C
Comment 11 Jakub Jelinek 2011-02-03 17:23:12 UTC
Fixed.
Comment 12 Matt Hargett 2011-04-12 18:15:56 UTC
Verified fixed in 4.6.0.