Bug 37140 - type inherited from base class not recognized
Summary: type inherited from base class not recognized
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: fabien
URL:
Keywords:
: 58047 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-16 16:39 UTC by João Eiras
Modified: 2014-02-26 21:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-08-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description João Eiras 2008-08-16 16:39:46 UTC
The following code sample does not compile, and it should.
I get the error:
  error: 'o_t' is not a class or namespace

G++ version: g++ (GCC) 4.4.0 20080729 (experimental)

template<class X> class O{
public:
	typedef X type_t;
};

template<class X> class A{
public:
	typedef O<X> o_t;
};

template<class X> class B: A<X>{
public:
	using typename A<X>::o_t;
	B(){typename o_t::type_t x;}
};

int main(int argc, char *argv[]){
	B<int> b;
	return 1;
}
Comment 1 João Eiras 2008-08-16 16:42:17 UTC
Sorry, full error is

gpp_bug_2.cpp: In constructor `B<X>::B()':
gpp_bug_2.cpp:15: error: `o_t' is not a class or namesp
gpp_bug_2.cpp:15: error: `type_t' does not name a type
Comment 2 David Fang 2008-09-27 22:09:39 UTC
With the test case, I get the same diagnostic with g++-4.3.2.
I'm not sure if the in-class using directive is supposed to work as you expected, but what I usually write is (using your example):

template<class X> class B: A<X>{
public:
        typedef typename A<X>::o_t   o_t;
        B(){typename o_t::type_t x;}
};

... which compiles for me.  
Comment 3 Jonathan Wakely 2009-12-11 00:50:22 UTC
is this bug 14258 ?
Comment 4 Paolo Carlini 2013-05-20 17:33:56 UTC
PR14258 is fixed and this is still rejected. Maybe Fabien wants to have a look?!?
Comment 5 fabien 2013-05-22 20:17:44 UTC
(In reply to Paolo Carlini from comment #4)
> PR14258 is fixed and this is still rejected. Maybe Fabien wants to have a
> look?!?

Sure, I'll have a look. Thank you Paolo!
Comment 6 Paolo Carlini 2013-05-23 23:02:02 UTC
Thanks a lot!
Comment 7 Paolo Carlini 2013-08-01 10:49:47 UTC
Any news on this?
Comment 8 fabien 2013-08-02 08:10:53 UTC
(In reply to Paolo Carlini from comment #7)
> Any news on this?

Sorry Paolo, no news. I will look into it after I resurrect some "stage one 1 material" patches on using decls (comming after c++/54537). I think this one can be tackled in stage 3.
Comment 9 Paolo Carlini 2014-01-22 15:29:19 UTC
Fabien, any news on this - now that we are in Stage 3?
Comment 10 fabien 2014-01-27 12:53:57 UTC
(In reply to Paolo Carlini from comment #9)
> Fabien, any news on this - now that we are in Stage 3?

I have successfuly tested a patch, but wait a moment, I need to refine it a bit.
Comment 11 fabien 2014-02-02 19:58:38 UTC
Author: fabien
Date: Sun Feb  2 19:58:06 2014
New Revision: 207407

URL: http://gcc.gnu.org/viewcvs?rev=207407&root=gcc&view=rev
Log:
2014-02-02  Fabien Chene  <fabien@gcc.gnu.org>
        PR c++/37140
        * parser.c (cp_parser_nonclass_name): Call strip_using_decl and
	move the code handling dependent USING_DECLs...
        * name-lookup.c (strip_using_decl): ...Here.

2014-02-02  Fabien Chene  <fabien@gcc.gnu.org>

        PR c++/37140
        * g++.dg/template/using27.C: New.
	* g++.dg/template/using28.C: New.
	* g++.dg/template/using29.C: New.

Modified:
    trunk/gcc/cp/name-lookup.c
Comment 12 fabien 2014-02-02 20:03:09 UTC
Author: fabien
Date: Sun Feb  2 20:02:37 2014
New Revision: 207408

URL: http://gcc.gnu.org/viewcvs?rev=207408&root=gcc&view=rev
Log:
2014-02-02  Fabien Chene  <fabien@gcc.gnu.org>
        PR c++/37140
        * parser.c (cp_parser_nonclass_name): Call strip_using_decl and
	move the code handling dependent USING_DECLs...
        * name-lookup.c (strip_using_decl): ...Here.

2014-02-02  Fabien Chene  <fabien@gcc.gnu.org>

        PR c++/37140
        * g++.dg/template/using27.C: New.
	* g++.dg/template/using28.C: New.
	* g++.dg/template/using29.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/template/using27.C
    trunk/gcc/testsuite/g++.dg/template/using28.C
    trunk/gcc/testsuite/g++.dg/template/using29.C
Modified:
    trunk/gcc/cp/parser.c
Comment 13 fabien 2014-02-02 20:06:42 UTC
Fixed in 4.9. I will backport it to 4.8 and 4.7 if everething goes well.
Comment 14 fabien 2014-02-02 20:08:13 UTC
*** Bug 58047 has been marked as a duplicate of this bug. ***
Comment 15 fabien 2014-02-24 20:28:06 UTC
Author: fabien
Date: Mon Feb 24 20:27:34 2014
New Revision: 208093

URL: http://gcc.gnu.org/viewcvs?rev=208093&root=gcc&view=rev
Log:
2014-02-24  Fabien Chene  <fabien@gcc.gnu.org>
        PR c++/37140
        * parser.c (cp_parser_nonclass_name): Call strip_using_decl and
    move the code handling dependent USING_DECLs...
        * name-lookup.c (strip_using_decl): ...Here.

2014-02-24  Fabien Chene  <fabien@gcc.gnu.org>

        PR c++/37140
        * g++.dg/template/using27.C: New.
        * g++.dg/template/using28.C: New.
        * g++.dg/template/using29.C: New.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/template/using27.C
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/template/using28.C
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/template/using29.C
Modified:
    branches/gcc-4_8-branch/gcc/cp/ChangeLog
    branches/gcc-4_8-branch/gcc/cp/name-lookup.c
    branches/gcc-4_8-branch/gcc/cp/parser.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Comment 16 fabien 2014-02-26 21:16:48 UTC
Author: fabien
Date: Wed Feb 26 21:16:15 2014
New Revision: 208182

URL: http://gcc.gnu.org/viewcvs?rev=208182&root=gcc&view=rev
Log:
2014-02-26  Fabien Chene  <fabien@gcc.gnu.org>
        PR c++/37140
        * parser.c (cp_parser_nonclass_name): Call strip_using_decl and
    move the code handling dependent USING_DECLs...
        * name-lookup.c (strip_using_decl): ...Here.

2014-02-26  Fabien Chene  <fabien@gcc.gnu.org>

        PR c++/37140
        * g++.dg/template/using27.C: New.
        * g++.dg/template/using28.C: New.
        * g++.dg/template/using29.C: New.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/template/using27.C
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/template/using28.C
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/template/using29.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/name-lookup.c
    branches/gcc-4_7-branch/gcc/cp/parser.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog