From 9aaceb4b3e161bc4ce5d2265bf6d3a95d1e62d66 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Mon, 10 Dec 2001 22:49:13 +0000 Subject: [PATCH] re PR c++/72 (aggressive type analysis in template-class's template-member-function) cp: PR g++/72 * decl.c (add_binding): Don't reject duplicate typedefs involving template parameters. testsuite: * g++.dg/template/typedef1.C: New test. From-SVN: r47854 --- gcc/cp/ChangeLog | 8 +++++++- gcc/cp/decl.c | 8 ++++++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/template/typedef1.C | 21 +++++++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/typedef1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a8c08a215f7..880ef3fd021 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,8 +1,14 @@ +2001-12-10 Nathan Sidwell + + PR g++/72 + * decl.c (add_binding): Don't reject duplicate typedefs involving + template parameters. + 2001-12-10 Neil Booth * parse.y, semantics.c: Similarly. -2001-12-04 Nathan Sidwell +2001-12-09 Nathan Sidwell PR g++/87 * cp-tree.h (DECL_COPY_CONSTRUCTOR_P): Use copy_fn_p. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 26d3a2499ed..8bf940e4ffd 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -981,8 +981,12 @@ add_binding (id, decl) else if (TREE_CODE (BINDING_VALUE (binding)) == TYPE_DECL && TREE_CODE (decl) == TYPE_DECL && DECL_NAME (decl) == DECL_NAME (BINDING_VALUE (binding)) - && same_type_p (TREE_TYPE (decl), - TREE_TYPE (BINDING_VALUE (binding)))) + && (same_type_p (TREE_TYPE (decl), + TREE_TYPE (BINDING_VALUE (binding))) + /* If either type involves template parameters, we must + wait until instantiation. */ + || uses_template_parms (TREE_TYPE (decl)) + || uses_template_parms (TREE_TYPE (BINDING_VALUE (binding))))) /* We have two typedef-names, both naming the same type to have the same name. This is OK because of: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9c774301cb9..a7766e95387 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-12-10 Nathan Sidwell + + * g++.dg/template/typedef1.C: New test. + 2001-12-09 Nathan Sidwell * g++.dg/other/copy1.C: New test. diff --git a/gcc/testsuite/g++.dg/template/typedef1.C b/gcc/testsuite/g++.dg/template/typedef1.C new file mode 100644 index 00000000000..03257571d1d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/typedef1.C @@ -0,0 +1,21 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 9 Dec 2001 + +// PR 72 + +template struct A +{ + typedef T type; +}; + +template struct B +{ + typedef int xxx; + typedef T xxx; + typedef typename A::type xxx; + typedef A::type xxx; +}; + +B good; -- 2.30.2