Compiling the invalid code snippet -------------------------------------------- inline template <int> void foo () {} -------------------------------------------- with mainline, I get the following error message: bug.cc:1: error: expected unqualified-id bug.cc:1: error: ISO C++ forbids declaration of `type name' with no type bug.cc:1: error: abstract declarator `int' used as declaration bug.cc:1: error: explicit instantiation of non-template `int ._0' bug.cc:1: error: expected `;' which is bogus. The worst part is "int ._0" which is nowhere to be seen in the code. The rest isn't very helpful either. Previous versions of gcc just gave a simple bug.cc:1: error: parse error before `<' token which isn't very elaborate, but not as confusing as mainline's message. Btw, 3.3 branch issues an ICE when compiling the following code (one can use any name of a builtin instead of abort): -------------------------------------------- inline template <int> void foo () {} void abort (); -------------------------------------------- The error message then is: bug.cc:1: error: parse error before `<' token bug.cc:3: internal compiler error: in lookup_template_function, at cp/pt.c: 4002 Please submit a full bug report, [etc.] But since this is an error-recovery problem which is fixed on mainline, there's nothing more to do about the ICE.
*** Bug 12135 has been marked as a duplicate of this bug. ***
Correct.
Related to bug 6259 and bug 9050.
On the mainline (20030907) on PPC Darwin, gcc gives a silightly different error message: pr12132.cc:2: error: expected unqualified-id pr12132.cc:2: error: ISO C++ forbids declaration of `type name' with no type pr12132.cc:2: error: abstract declarator `int' used as declaration pr12132.cc:2: error: explicit instantiation of non-template `int $_0' pr12132.cc:2: error: expected `;'
Subject: Bug 12132 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-01-05 21:07:22 Modified files: gcc/cp : ChangeLog parser.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: error11.C Log message: PR c++/12132 * parser.c (cp_parser_explicit_instantiation): Improve error recovery. (cp_parser_require): Improve indication of the error location. PR c++/12132 * g++.dg/template/error11.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3855&r2=1.3856 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.146&r2=1.147 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3337&r2=1.3338 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error11.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed in GCC 3.4.