From: Fabien Chêne Date: Tue, 31 May 2011 19:02:19 +0000 (+0200) Subject: re PR c++/48010 (typedef redefinitions are allowed if the redefined type is a nested... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ff7714547ff7aaaac44011e2184fc876945ad0a5;p=gcc.git re PR c++/48010 (typedef redefinitions are allowed if the redefined type is a nested class type) gcc/cp/ChangeLog 2010-05-31 Fabien Chene PR c++/48010 * name-lookup.c (supplement_binding_1): If the old binding was a type name, also check that the DECL actually refers to the same type or is not a type. gcc/testsuite/ChangeLog 2010-05-31 Fabien Chene PR c++/48010 * g++.dg/lookup/name-clash9.C: New. From-SVN: r174506 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 10a1d776df9..7a8042b6194 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2010-05-31 Fabien Chêne + + PR c++/48010 + * name-lookup.c (supplement_binding_1): If the old binding was a + type name, also check that the DECL actually refers to the same + type or is not a type. + 2011-05-31 Jason Merrill PR c++/44870 diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 0e762fd6aca..7f0f6153998 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1,5 +1,5 @@ /* Definitions for C++ name lookup routines. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis @@ -436,7 +436,9 @@ supplement_binding_1 (cxx_binding *binding, tree decl) && DECL_ANTICIPATED (bval) && !DECL_HIDDEN_FRIEND_P (bval))) binding->value = decl; - else if (TREE_CODE (bval) == TYPE_DECL && DECL_ARTIFICIAL (bval)) + else if (TREE_CODE (bval) == TYPE_DECL && DECL_ARTIFICIAL (bval) + && (TREE_CODE (decl) != TYPE_DECL + || same_type_p (TREE_TYPE (decl), TREE_TYPE (bval)))) { /* The old binding was a type name. It was placed in VALUE field because it was thought, at the point it was diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f9fae6282e4..10a41bd30d9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-11-15 Fabien Chêne + + PR c++/48010 + * g++.dg/lookup/name-clash9.C: New. + 2011-05-31 Tobias Burnus PR fortran/18918 diff --git a/gcc/testsuite/g++.dg/lookup/name-clash9.C b/gcc/testsuite/g++.dg/lookup/name-clash9.C new file mode 100644 index 00000000000..4167f47b4a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/name-clash9.C @@ -0,0 +1,8 @@ +// { dg-do compile } +// PR c++/48010 + +struct A +{ + struct type {}; // { dg-error "conflicts with previous" } + typedef int type; // { dg-error "declaration" } +};