Bug 23211 - using dec in nested class doesn't import name
Summary: using dec in nested class doesn't import name
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 4.7.0
Assignee: fabien
URL:
Keywords: diagnostic
Depends on: 14258
Blocks:
  Show dependency treegraph
 
Reported: 2005-08-03 00:22 UTC by Ivan Godard
Modified: 2012-01-03 09:57 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.4
Known to fail: 3.4.5, 4.0.2, 4.1.0
Last reconfirmed: 2006-07-05 09:32:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Godard 2005-08-03 00:22:40 UTC
template<typename T>
struct  foo {
    typedef int itype;
    typedef int jtype;
    struct bar {
        typedef typename foo::itype itype;
        using foo::jtype;
        itype i;
        jtype j;
        };
    };

gets you:
~/ootbc/members/src$ g++ foo.cc
foo.cc:9: error: `jtype' does not name a type

Adding "typename" here and there changes the error you get but doesn't compile.
The above code compiles OK on Comeau.
Comment 1 Andrew Pinski 2005-08-03 00:34:49 UTC
I think this is a dup of bug 14258.  GCC still implements the old using rules.
Comment 2 Wolfgang Bangerth 2005-09-14 15:28:34 UTC
Confirmed. This is a regression against 3.3 which compiled the code 
just fine. 
 
W. 
Comment 3 Andrew Pinski 2005-09-14 15:34:58 UTC
As I said, I think this is a dup of bug 14258, we never really got using correct.
Comment 4 Wolfgang Bangerth 2005-09-14 18:07:09 UTC
I'm not sure it is a duplicate, since the error messages are very 
different. But be that as it may, this is a regression and should 
be fixed. If it is, someone may want to take a look at that other 
PR as well. 
 
W. 
Comment 5 Andrew Pinski 2005-10-13 20:11:47 UTC
: Search converges between 2003-07-29-trunk (#308) and 2003-07-30-trunk (#309).
Comment 6 Mark Mitchell 2005-10-31 04:39:20 UTC
Leavinga s P2.  We should at least look at this, and understand what's wrong.
Comment 7 Mark Mitchell 2006-02-24 00:26:03 UTC
This issue will not be resolved in GCC 4.1.0; retargeted at GCC 4.1.1.
Comment 8 Mark Mitchell 2006-05-25 02:33:07 UTC
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.
Comment 9 Andrew Pinski 2006-08-16 06:43:51 UTC
Janis,
  Could you do a regression hunt on this bug?
Comment 10 Janis Johnson 2006-08-18 21:30:43 UTC
A regression hunt on powerpc-linux using the submitter's testcase identified the following patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=69921

    r69921 | nathan | 2003-07-29 11:16:50 +0000 (Tue, 29 Jul 2003)
Comment 11 Jason Merrill 2006-08-22 19:17:16 UTC
The using-declaration is invalid because foo is not a base of bar.  icc also rejects the testcase if you try to instantiate bar.
Comment 12 Ivan Godard 2006-08-22 20:28:07 UTC
If the "using" is invalid then there should be a diagnostic on line 7 that says so. 
Comment 13 Andrew Pinski 2006-08-22 20:30:57 UTC
So this is just a diagnostic issue and not a regression.
Comment 14 Ivan Godard 2006-08-22 20:38:04 UTC
Not, it's an error: invalid text is accepted without diagnostic (if the identifier introduced with the "using" is not itself used, then the using statement is invalid but gets no diagnostic).
Comment 15 fabien 2011-12-28 19:53:19 UTC
Author: fabien
Date: Wed Dec 28 19:53:14 2011
New Revision: 182711

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182711
Log:
gcc/testsuite/ChangeLog

2011-12-28  Fabien Chene  <fabien@gcc.gnu.org>

	PR c++/23211
	* g++.dg/template/using18.C: New.
	* g++.dg/template/using19.C: New.
	* g++.dg/template/nested3.C: Remove dg-message at instantiation.
	* g++.dg/template/crash13.C: Likewise.

gcc/cp/ChangeLog

2011-12-28  Fabien Chene  <fabien@gcc.gnu.org>

	PR c++/23211
	* name-lookup.c (do_class_using_decl): Use dependent_scope_p
	instead of dependent_type_p, to check that a non-dependent
	nested-name-specifier of a class-scope using declaration refers to
	a base, even if the current scope is dependent.
	* parser.c (cp_parser_using_declaration): Set
	USING_DECL_TYPENAME_P to 1 if the DECL is not null. Re-indent a
	'else' close to the prior modification.


Added:
    trunk/gcc/testsuite/g++.dg/template/using18.C
    trunk/gcc/testsuite/g++.dg/template/using19.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/crash13.C
    trunk/gcc/testsuite/g++.dg/template/nested3.C
Comment 16 fabien 2011-12-28 20:04:25 UTC
Fixed.