Bug 40738 - missing typename error improvement
Summary: missing typename error improvement
Status: RESOLVED DUPLICATE of bug 15946
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2009-07-13 23:39 UTC by Benjamin Kosnik
Modified: 2010-10-16 23:01 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Kosnik 2009-07-13 23:39:48 UTC
This code, compiled with trunk:

  template<typename _Tp, typename _Alloc>
    class list
    {
      struct iterator;
      
      struct const_iterator;
    };


  template<typename _Tp, typename _Alloc>
    struct list<_Tp, _Alloc>::iterator 
     { };
 
#if 0
  template<typename _Tp, typename _Alloc>
    inline bool
    operator!=(const typename list<_Tp, _Alloc>::iterator& __x,
	       const typename list<_Tp, _Alloc>::const_iterator& __y)
    { return __x._M_node != __y._M_node; }
#else
  template<typename _Tp, typename _Alloc>
    inline bool
    operator!=(const list<_Tp, _Alloc>::iterator& __x,
	       const list<_Tp, _Alloc>::const_iterator& __y)
    { return __x._M_node != __y._M_node; }
#endif

gives:

%g++ -c test.cc
test.cc:24: error: expected unqualified-id before ‘&’ token
test.cc:24: error: expected ‘)’ before ‘&’ token
test.cc:24: error: expected initializer before ‘&’ token

Hmmm. Yeah.

Here's something more useful:

%g++ -c test.cc
test.cc:24: error: expected typename before qualified-id
Comment 1 Benjamin Kosnik 2009-07-13 23:40:46 UTC
eek that should be expected 'typename' before...
Comment 2 Andrew Pinski 2009-10-14 04:08:26 UTC

*** This bug has been marked as a duplicate of 15946 ***
Comment 3 Jason Merrill 2009-11-08 03:47:51 UTC
Subject: Bug 40738

Author: jason
Date: Sun Nov  8 03:47:36 2009
New Revision: 154006

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154006
Log:
	PR c++/18451
	PR c++/40738
	* cp-tree.h (cp_decl_specifier_seq): Add any_type_specifiers_p.
	* parser.c (cp_parser_single_declaration): Call
	cp_parser_parse_and_diagnose_invalid_type_name here, too.
	(cp_parser_parameter_declaration): And here.
	(cp_parser_parse_and_diagnose_invalid_type_name): Be
	less picky about declarator form.  Don't skip to
	the end of the block if	we're in a declarator.
	(cp_parser_decl_specifier_seq): Set any_type_specifiers_p.
	(cp_parser_simple_declaration): Check it.
	(cp_parser_member_declaration): Likewise.
	(cp_parser_diagnose_invalid_type_name): Tweak error message.
	(cp_parser_expression_statement): Likewise.
	* decl2.c (grokfield): Mention decltype instead of typeof.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl2.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic-ex1.C
    trunk/gcc/testsuite/g++.dg/ext/typedef-init.C
    trunk/gcc/testsuite/g++.dg/lookup/hidden-class1.C
    trunk/gcc/testsuite/g++.dg/lookup/hidden-class10.C
    trunk/gcc/testsuite/g++.dg/lookup/hidden-class5.C
    trunk/gcc/testsuite/g++.dg/lookup/hidden-class7.C
    trunk/gcc/testsuite/g++.dg/lookup/hidden-temp-class1.C
    trunk/gcc/testsuite/g++.dg/lookup/hidden-temp-class4.C
    trunk/gcc/testsuite/g++.dg/lookup/hidden-temp-class7.C
    trunk/gcc/testsuite/g++.dg/lookup/strong-using-2.C
    trunk/gcc/testsuite/g++.dg/other/typedef1.C
    trunk/gcc/testsuite/g++.dg/parse/access10.C
    trunk/gcc/testsuite/g++.dg/parse/constructor1.C
    trunk/gcc/testsuite/g++.dg/parse/crash38.C
    trunk/gcc/testsuite/g++.dg/parse/error3.C
    trunk/gcc/testsuite/g++.dg/parse/error36.C
    trunk/gcc/testsuite/g++.dg/parse/typespec1.C
    trunk/gcc/testsuite/g++.dg/template/typedef5.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/typename3.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/typename4.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/typename6.C
    trunk/gcc/testsuite/g++.old-deja/g++.robertl/eb94.C

Comment 4 John David Anglin 2010-10-16 23:01:02 UTC
Author: danglin
Date: Sat Oct 16 23:00:55 2010
New Revision: 165568

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165568
Log:
	Backport from mainline
	2010-09-06  Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/45543
	* g++.dg/debug/dwarf2/typedef1.C: Expect just one
	DW_TAG_enumeration_type DIE.

	2010-09-04  Andreas Schwab  <schwab@linux-m68k.org>
	* g++.dg/debug/dwarf2/typedef1.C: Replace ".*" by "\[^\n\]*".

	2009-11-07  Jason Merrill  <jason@redhat.com>

	PR c++/18451
	PR c++/40738
	* g++.dg/other/typedef1.C: Update expected errors.

	2009-08-03  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR testsuite/40858
	* g++.dg/debug/dwarf2/typedef1.C: Also match assembler string used with
	.ascii.


Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/debug/dwarf2/typedef1.C