Bug 22138 - Better error message for rejecting local template declaration.
Summary: Better error message for rejecting local template declaration.
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P2 enhancement
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2005-06-21 16:59 UTC by Mattias Karlsson
Modified: 2010-07-05 09:42 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-30 07:10:06


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mattias Karlsson 2005-06-21 16:59:27 UTC
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"
Comment 1 Andrew Pinski 2005-06-21 17:04:16 UTC
Confirmed, 3.3 and before gave a worse error message (at least to me):
t.cc:3: parse error before `template'
Comment 2 Shujing Zhao 2010-07-05 05:36:23 UTC
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

Comment 3 Shujing Zhao 2010-07-05 06:13:37 UTC
Fixed for trunk.