Given: void f(void) { template<typename T> class A { }; } g++ 4.0/3.4 gives: bug.cpp:4: error: expected primary-expression before 'template' A better error message would be something like "Local template declarations is not allowed" or something similar, instead of what is now basicly a "Syntax error"
Confirmed, 3.3 and before gave a worse error message (at least to me): t.cc:3: parse error before `template'
Subject: Bug 22138 Author: pzhao Date: Mon Jul 5 05:36:02 2010 New Revision: 161818 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161818 Log: gcc/cp/ 2010-07-05 Shujing Zhao <pearly.zhao@oracle.com> PR c++/22138 * parser.c (cp_parser_primary_expression): Error if local template is declared. gcc/testsuite/ 2010-07-05 Shujing Zhao <pearly.zhao@oracle.com> PR c++/22138 * g++.dg/parse/template25.C: New. Added: trunk/gcc/testsuite/g++.dg/parse/template25.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/parser.c trunk/gcc/testsuite/ChangeLog
Fixed for trunk.