Bug 15096 - [3.3/3.4/4.0 Regression] parse error with templates and pointer to const member
Summary: [3.3/3.4/4.0 Regression] parse error with templates and pointer to const member
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P2 normal
Target Milestone: 3.4.1
Assignee: Mark Mitchell
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2004-04-23 10:54 UTC by Wolfgang Roehrl
Modified: 2004-10-30 21:11 UTC (History)
2 users (show)

See Also:
Host: i386-pc-mingw32
Target: powerpc-wrs-vxworks
Build: sparc-sun-solaris2.5.1
Known to work: 2.95.3
Known to fail: 3.2.3 3.3.3 3.4.0 4.0.0
Last reconfirmed: 2004-04-23 13:15:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Roehrl 2004-04-23 10:54:37 UTC
We use the compiler to generate code for a PowerPc processor. 
Used invokation line for the C++ compiler:

ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig -mmultiple
      -mno-string -mstrict-align -O3 -fno-exceptions -fno-rtti
      -I<different include paths>
      -D<differen #define's>
      Z.CPP -oZ.O



// example program 1

template <typename T_>
class C1
{
public:
    C1 ();
    ~C1 ();
    const int C1<T_>::* getPtr () const;

private:
    int x;
    T_ y;
};


template <typename T_>
const int C1<T_>::* C1<T_>::getPtr () const
{ return &C1<T_>::x; }                      // <-- line 17


The compiler gives the following error message:
 
z.CPP:17: error: too few template parameter lists in declaration of `const int 
   C1<T_>::* C1<T_>::getPtr() const'


We get no error message if a typedef is introduced:

// example program 2

template <typename T_>
class C1
{
    typedef const int C1<T_>::* T_C1_INT_PTR;

public:
    C1 ();
    ~C1 ();
    T_C1_INT_PTR getPtr () const;

private:
    int x;
    T_ y;
};


template <typename T_>
typename C1<T_>::T_C1_INT_PTR C1<T_>::getPtr () const
{ return &C1<T_>::x; }
Comment 1 Giovanni Bajo 2004-04-23 13:11:09 UTC
Confirmed, but can anybody test it with 2.95?
Comment 2 Andrew Pinski 2004-04-23 13:15:39 UTC
It worked with 2.95.3
Comment 3 Giovanni Bajo 2004-06-06 03:39:25 UTC
Retargeting to 3.4.1, being a regression on that release branch.
Comment 4 Mark Mitchell 2004-06-12 21:32:16 UTC
Working on a fix.
Comment 5 CVS Commits 2004-06-14 15:52:59 UTC
Subject: Bug 15096

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-06-14 15:52:50

Modified files:
	gcc/cp         : decl.c name-lookup.c ChangeLog 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: friend30.C ptrmem10.C 

Log message:
	PR c++/15096
	* decl.c (grokdeclarator): Ignore pointer-to-members when
	computing template depth.
	
	PR c++/14930
	* name-lookup.c (pushtag): Do not try to put class declarations in
	explicit specialization scopes.
	
	PR c++/15096
	* g++.dg/template/ptrmem10.C: New test.
	
	PR c++/14930
	* g++.dg/template/friend30.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.20&r2=1.1174.2.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.34.2.15&r2=1.34.2.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.122&r2=1.3892.2.123
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.206&r2=1.3389.2.207
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/friend30.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem10.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 6 CVS Commits 2004-06-14 15:58:58 UTC
Subject: Bug 15096

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-06-14 15:58:54

Modified files:
	gcc/cp         : decl.c name-lookup.c ChangeLog 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: friend30.C ptrmem10.C 

Log message:
	PR c++/15096
	* decl.c (grokdeclarator): Ignore pointer-to-members when
	computing template depth.
	
	PR c++/14930
	* name-lookup.c (pushtag): Do not try to put class declarations in
	explicit specialization scopes.
	
	PR c++/15096
	* g++.dg/template/ptrmem10.C: New test.
	
	PR c++/14930
	* g++.dg/template/friend30.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1214&r2=1.1215
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.58&r2=1.59
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4094&r2=1.4095
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3854&r2=1.3855
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/friend30.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/ptrmem10.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 7 Mark Mitchell 2004-06-14 17:15:13 UTC
Fixed in GCC 3.4.1.