Bug 15946 - Unhelpful error message when "typename" is omitted
Summary: Unhelpful error message when "typename" is omitted
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 enhancement
Target Milestone: 4.5.0
Assignee: Jason Merrill
URL:
Keywords: diagnostic
: 15179 18451 35228 36353 40738 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-06-11 17:17 UTC by Paul Koning
Modified: 2009-11-08 04:03 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-11-08 04:03:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Koning 2004-06-11 17:17:28 UTC
Consider this test case:

template <class T> class Foo
{
public:
    typedef T bar;
    int x;
    T z;
};
template <class T> class Test: public Foo<T>
{
public:
    typedef T * t2;
    typedef Foo<T> F;
    
    t2 t;
    F f;
    typename F::bar b;
    typename Foo<T>::bar b2;
    F::bar b3;
    Foo<T>::bar b4;
};

Test<int> T2;

GCC 3.3.3 complains about the declarations of b3 and b4, saying that it's an
implicit typename and that's deprecated.

GCC 3.4.0 rejects the code outright.  Given that it's the next version, and it
was deprecated, that's ok.  What's not ok is the error message:

foo.cc:18: error: expected `;' before "b3"
foo.cc:19: error: expected `;' before "b4"

This gives no clue at all about what the problem is or how to correct it.
Comment 1 Andrew Pinski 2004-06-11 17:26:40 UTC
Confirmed.
Comment 2 Andrew Pinski 2004-11-12 14:11:54 UTC
*** Bug 18451 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Pinski 2008-05-28 08:00:21 UTC
*** Bug 36353 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Pinski 2009-10-14 04:08:26 UTC
*** Bug 40738 has been marked as a duplicate of this bug. ***
Comment 5 Jason Merrill 2009-11-06 21:18:54 UTC
Subject: Bug 15946

Author: jason
Date: Fri Nov  6 21:18:42 2009
New Revision: 153978

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153978
Log:
	PR c++/15946
	* parser.c (cp_parser_check_template_parameters): Don't talk about
	specialization at function scope.
	(cp_parser_diagnose_invalid_type_name): Handle dependent scope.
	(cp_parser_parse_and_diagnose_invalid_type_name): Likewise.
	(cp_parser_expression_statement): Suggest typename.
	* error.c (dump_decl) [SCOPE_REF]: Print the type here.
	(dump_expr) [SCOPE_REF]: Call it.
	(dump_type) [UNBOUND_CLASS_TEMPLATE]: Check TFF_UNQUALIFIED_NAME.
	* cxx-pretty-print.c (pp_cxx_unqualified_id): Print class template
	args.

Added:
    trunk/gcc/testsuite/g++.dg/parse/error36.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cxx-pretty-print.c
    trunk/gcc/cp/error.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/error26.C
    trunk/gcc/testsuite/g++.old-deja/g++.other/typename1.C

Comment 6 Jason Merrill 2009-11-08 03:10:22 UTC
*** Bug 35228 has been marked as a duplicate of this bug. ***
Comment 7 Jason Merrill 2009-11-08 04:02:34 UTC
*** Bug 15179 has been marked as a duplicate of this bug. ***
Comment 8 Jason Merrill 2009-11-08 04:03:41 UTC
Fixed for 4.5.