From dd81965b766c8465c2eec3ae4563f0076a899f8d Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 7 Aug 2013 10:10:27 +0000 Subject: [PATCH] re PR c++/46206 (using typedef-name error with typedef name hiding struct name) /cp 2013-08-07 Paolo Carlini PR c++/46206 * name-lookup.c (lookup_name_real_1): Handle iter->type before iter->value. /testsuite 2013-08-07 Paolo Carlini PR c++/46206 * g++.dg/lookup/typedef2.C: New. From-SVN: r201558 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/name-lookup.c | 8 ++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/lookup/typedef2.C | 30 ++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/lookup/typedef2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 624af2b..d3709fa 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-08-07 Paolo Carlini + + PR c++/46206 + * name-lookup.c (lookup_name_real_1): Handle iter->type before + iter->value. + 2013-08-06 Caroline Tice * Make-lang.in (*CXX_AND_OBJCXX_OBJS): Add vtable-class-hierarchy.o to diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 0fe0246..05f0480 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4740,11 +4740,11 @@ lookup_name_real_1 (tree name, int prefer_type, int nonclass, bool block_p, continue; /* If this is the kind of thing we're looking for, we're done. */ - if (qualify_lookup (iter->value, flags)) - binding = iter->value; - else if ((flags & LOOKUP_PREFER_TYPES) - && qualify_lookup (iter->type, 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 binding = NULL_TREE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2f8197f..ef030b0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-08-07 Paolo Carlini + + PR c++/46206 + * g++.dg/lookup/typedef2.C: New. + 2013-08-07 David Malcolm * lib/plugin-support.exp (plugin-test-execute): Add -fno-rtti diff --git a/gcc/testsuite/g++.dg/lookup/typedef2.C b/gcc/testsuite/g++.dg/lookup/typedef2.C new file mode 100644 index 0000000..fdadeec --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/typedef2.C @@ -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; + } +}; -- 2.7.4