From c8460010fab905e8441a1d15f859da8ffb6fceda Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Sat, 14 Sep 2002 23:19:48 +0000 Subject: [PATCH] re PR c++/7768 (__PRETTY_FUNCTION__ for template destructor is wrong) cp: PR c++/7768 * pt.c (build_template_decl): Copy DECL_DESTRUCTOR_P. testsuite: * g++.dg/template/pretty1.C: New test From-SVN: r57152 --- gcc/cp/ChangeLog | 5 +++ gcc/cp/pt.c | 1 + gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/g++.dg/template/pretty1.C | 43 +++++++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/pretty1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bbdbef09585..b8051cc8eda 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2002-09-14 Nathan Sidwell + + PR c++/7768 + * pt.c (build_template_decl): Copy DECL_DESTRUCTOR_P. + 2002-09-14 Kazu Hirata * error.c: Fix comment formatting. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e05174fb005..12c420a18f5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2110,6 +2110,7 @@ build_template_decl (decl, parms) DECL_VIRTUAL_CONTEXT (tmpl) = DECL_VIRTUAL_CONTEXT (decl); DECL_STATIC_FUNCTION_P (tmpl) = DECL_STATIC_FUNCTION_P (decl); DECL_CONSTRUCTOR_P (tmpl) = DECL_CONSTRUCTOR_P (decl); + DECL_DESTRUCTOR_P (tmpl) = DECL_DESTRUCTOR_P (decl); DECL_NONCONVERTING_P (tmpl) = DECL_NONCONVERTING_P (decl); DECL_ASSIGNMENT_OPERATOR_P (tmpl) = DECL_ASSIGNMENT_OPERATOR_P (decl); if (DECL_OVERLOADED_OPERATOR_P (decl)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 97a432575b2..6bab83d970d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-09-15 Nathan Sidwell + + * g++.dg/template/pretty1.C: New test. + 2002-09-14 Alan Modra * gcc.c-torture/execute/struct-cpy-1.c: New test. diff --git a/gcc/testsuite/g++.dg/template/pretty1.C b/gcc/testsuite/g++.dg/template/pretty1.C new file mode 100644 index 00000000000..99cbcd64a55 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pretty1.C @@ -0,0 +1,43 @@ +// { dg-do run } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 14 Sep 2002 + +// PR 7768 template dtor pretty function wrong + +#include + +static size_t current = 0; +static bool error = false; + +static char const *names[] = +{ + "X::X() [with T = void]", + "X::~X() [with T = void]", + 0 +}; + +void Verify (char const *ptr) +{ + error = strcmp (ptr, names[current++]); +} + +template +struct X +{ + X() { Verify (__PRETTY_FUNCTION__); } + ~X() { Verify (__PRETTY_FUNCTION__); } +}; + +int main() +{ + { + X x; + + if (error) + return current; + } + if (error) + return current; + return 0; +} -- 2.30.2