diff mbox

C++ Patch for c++/60894

Message ID 54DE48D6.5030803@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Feb. 13, 2015, 6:56 p.m. UTC
Hi,

On 02/13/2015 04:03 PM, Jason Merrill wrote:
> On 02/11/2015 02:10 PM, Paolo Carlini wrote:
>> Today I was having a look to this pending issue and went astray due to
>> the broken thread: I wondered if, basing on Fabien' first try and the
>> comments accompanying tag_scope, it would make sense to use
>> strip_using_decl only when the scope is ts_global (or maybe !=
>> ts_current)?!?
>
> Good thought, that makes sense and is a lot simpler.  But I think 
> since we have a ts_global block earlier in the function, let's do the 
> stripping there, right after the call to lookup_name_prefer_type.  OK 
> with that change.
Thanks. Thus I'm going to resolve the issue at least in mainline and 
4_9-branch with the below.

While working on this issue I noticed that we have another regression, 
which appeared in 4_7, having to do with using declarations but not 
involving redeclarations or redundant 'struct' in parameters:

struct B
{
   template<typename T>
   struct S {};
};

struct D : B
{
   using B::S;

   template<typename T>
   void doIt(/*struct*/ S<T>&);
};

Anything you would recommend besides filing a new Bug Report (or marking 
an existing one as regression)?!?

Thanks,
Paolo.

//////////////////////////
/cp
2015-02-13  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60894
	* decl.c (lookup_and_check_tag): Use strip_using_decl.

/testsuite
2015-02-13  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60894
	* g++.dg/lookup/using54.C: New.

Comments

Jason Merrill Feb. 13, 2015, 10:09 p.m. UTC | #1
On 02/13/2015 01:56 PM, Paolo Carlini wrote:
> Anything you would recommend besides filing a new Bug Report (or marking
> an existing one as regression)?!?

Definitely do that.  I guess it has to do with not recognizing a 
USING_DECL as a template...

Jason
diff mbox

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 220688)
+++ cp/decl.c	(working copy)
@@ -12205,6 +12205,7 @@  lookup_and_check_tag (enum tag_types tag_code, tre
       /* First try ordinary name lookup, ignoring hidden class name
 	 injected via friend declaration.  */
       decl = lookup_name_prefer_type (name, 2);
+      decl = strip_using_decl (decl);
       /* If that fails, the name will be placed in the smallest
 	 non-class, non-function-prototype scope according to 3.3.1/5.
 	 We may already have a hidden name declared as friend in this
Index: testsuite/g++.dg/lookup/using54.C
===================================================================
--- testsuite/g++.dg/lookup/using54.C	(revision 0)
+++ testsuite/g++.dg/lookup/using54.C	(working copy)
@@ -0,0 +1,16 @@ 
+// PR c++/60894
+
+struct B
+{
+  struct S {};
+};
+
+struct D : B
+{
+  using B::S;
+  void doIt(struct S&);
+};
+
+void D::doIt(struct S&)
+{
+}