Patchwork [C++,/,RFC] PR 46206

login
register
mail settings
Submitter Paolo Carlini
Date Aug. 7, 2013, 8:41 a.m.
Message ID <52020821.7050105@oracle.com>
Download mbox | patch
Permalink /patch/265410/
State New
Headers show

Comments

Paolo Carlini - Aug. 7, 2013, 8:41 a.m.
Hi,

On 08/07/2013 01:08 AM, Jason Merrill wrote:
> On 08/06/2013 06:14 PM, Paolo Carlini wrote:
>> Ah I see, thanks. We reject this before and after the patch. Shall I add
>> this variant to the new testcase?
> Sure.
Thanks. Thus after a further round of testing I'm going to apply the below.

Thanks,
Paolo.

////////////////////////
/cp
2013-08-07  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/46206
	* name-lookup.c (lookup_name_real_1): Handle iter->type before
	iter->value.

/testsuite
2013-08-07  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/46206
	* g++.dg/lookup/typedef2.C: New.

Patch

Index: cp/name-lookup.c
===================================================================
--- cp/name-lookup.c	(revision 201524)
+++ cp/name-lookup.c	(working copy)
@@ -4740,11 +4740,11 @@  lookup_name_real_1 (tree name, int prefer_type, in
 	  continue;
 
 	/* If this is the kind of thing we're looking for, we're done.  */
-	if (qualify_lookup (iter->value, flags))
+	if ((flags & LOOKUP_PREFER_TYPES)
+	    && qualify_lookup (iter->type, flags))
+	  binding = iter->type;
+	else if (qualify_lookup (iter->value, flags))
 	  binding = iter->value;
-	else if ((flags & LOOKUP_PREFER_TYPES)
-		 && qualify_lookup (iter->type, flags))
-	  binding = iter->type;
 	else
 	  binding = NULL_TREE;
 
Index: testsuite/g++.dg/lookup/typedef2.C
===================================================================
--- testsuite/g++.dg/lookup/typedef2.C	(revision 0)
+++ testsuite/g++.dg/lookup/typedef2.C	(working copy)
@@ -0,0 +1,30 @@ 
+// PR c++/46206
+
+class Foo1
+{
+  int u, v, w, x;
+  typedef struct Bar { } Bar;
+  virtual void foo(void) {
+    struct Bar bar;
+  }
+};
+
+class Foo2
+{
+  int u, v, w;
+  typedef struct Bar { } Bar;
+  Bar bar;
+  virtual void foo(void) {
+    struct Bar bar;
+  }
+};
+
+class Foo3
+{
+  int u, v, w;
+  typedef struct Bar { } Bar;
+  int Bar;   // { dg-error "conflicts" }
+  virtual void foo(void) {
+    struct Bar bar;
+  }
+};