From 93efbc0929b38b3f66213e1b2d92fc1f8365c6ed Mon Sep 17 00:00:00 2001 From: bkoz Date: Fri, 27 Feb 2004 03:21:16 +0000 Subject: [PATCH] 2004-02-26 Ian Lance Taylor * testsuite/demangle/abi_examples/01.cc: Expect error -2. * testsuite/demangle/abi_examples/02.cc: Likewise. * testsuite/demangle/regression/cw-11.cc: Likewise. * testsuite/demangle/regression/cw-16.cc: Change two expected results to match libiberty demangler output. 2004-02-26 Benjamin Kosnik PR libstdc++/10246 * libsupc++/Makefile.am: Use libiberty demangler. (c_sources): Add cp-demangle.c. * libsupc++/Makefile.in: Regenerate. * src/Makefile.am (sources): Remove demangle.cc. * src/Makefile.in: Regenerate. * include/Makefile.am (bits_headers): Move demangle.h. (ext_headers): ...here. * include/Makefile.in: Regenerate. * include/bits/demangle.h: Move... * include/ext/demangle.h: ...here. * src/demangle.cc: Remove. 2004-02-26 Benjamin Kosnik * include/bits/demangle.h: Add type template parameter to all templates with just an Allocator template parameter. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@78553 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 28 +++ libstdc++-v3/include/Makefile.am | 2 +- libstdc++-v3/include/Makefile.in | 4 +- libstdc++-v3/include/{bits => ext}/demangle.h | 168 +++++++++--------- libstdc++-v3/libsupc++/Makefile.am | 32 +++- libstdc++-v3/libsupc++/Makefile.in | 59 ++++++- libstdc++-v3/src/Makefile.am | 1 - libstdc++-v3/src/Makefile.in | 11 +- libstdc++-v3/src/demangle.cc | 195 --------------------- libstdc++-v3/testsuite/demangle/abi_examples/01.cc | 2 +- libstdc++-v3/testsuite/demangle/abi_examples/02.cc | 2 +- .../testsuite/demangle/regression/cw-11.cc | 3 +- .../testsuite/demangle/regression/cw-16.cc | 4 +- 13 files changed, 206 insertions(+), 305 deletions(-) rename libstdc++-v3/include/{bits => ext}/demangle.h (94%) delete mode 100644 libstdc++-v3/src/demangle.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 39782cd3d79..00f73289110 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,31 @@ +2004-02-26 Ian Lance Taylor + + * testsuite/demangle/abi_examples/01.cc: Expect error -2. + * testsuite/demangle/abi_examples/02.cc: Likewise. + * testsuite/demangle/regression/cw-11.cc: Likewise. + * testsuite/demangle/regression/cw-16.cc: Change two expected + results to match libiberty demangler output. + +2004-02-26 Benjamin Kosnik + + PR libstdc++/10246 + * libsupc++/Makefile.am: Use libiberty demangler. + (c_sources): Add cp-demangle.c. + * libsupc++/Makefile.in: Regenerate. + * src/Makefile.am (sources): Remove demangle.cc. + * src/Makefile.in: Regenerate. + * include/Makefile.am (bits_headers): Move demangle.h. + (ext_headers): ...here. + * include/Makefile.in: Regenerate. + * include/bits/demangle.h: Move... + * include/ext/demangle.h: ...here. + * src/demangle.cc: Remove. + +2004-02-26 Benjamin Kosnik + + * include/bits/demangle.h: Add type template parameter to all + templates with just an Allocator template parameter. + 2004-02-25 Benjamin Kosnik * include/bits/atomicity.h: New, forward declarations for __atomic_add diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index b6b05ff30d8..63867322f6a 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -103,7 +103,6 @@ bits_headers = \ ${bits_srcdir}/concept_check.h \ ${bits_srcdir}/concurrence.h \ ${bits_srcdir}/cpp_type_traits.h \ - ${bits_srcdir}/demangle.h \ ${bits_srcdir}/deque.tcc \ ${bits_srcdir}/fstream.tcc \ ${bits_srcdir}/functexcept.h \ @@ -204,6 +203,7 @@ ext_builddir = ./ext ext_headers = \ ${ext_srcdir}/algorithm \ ${ext_srcdir}/debug_allocator.h \ + ${ext_srcdir}/demangle.h \ ${ext_srcdir}/enc_filebuf.h \ ${ext_srcdir}/stdio_filebuf.h \ ${ext_srcdir}/stdio_sync_filebuf.h \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index e0fa5c06c7b..d79cded347f 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -299,7 +299,6 @@ bits_headers = \ ${bits_srcdir}/concept_check.h \ ${bits_srcdir}/concurrence.h \ ${bits_srcdir}/cpp_type_traits.h \ - ${bits_srcdir}/demangle.h \ ${bits_srcdir}/deque.tcc \ ${bits_srcdir}/fstream.tcc \ ${bits_srcdir}/functexcept.h \ @@ -402,6 +401,7 @@ ext_builddir = ./ext ext_headers = \ ${ext_srcdir}/algorithm \ ${ext_srcdir}/debug_allocator.h \ + ${ext_srcdir}/demangle.h \ ${ext_srcdir}/enc_filebuf.h \ ${ext_srcdir}/stdio_filebuf.h \ ${ext_srcdir}/stdio_sync_filebuf.h \ @@ -526,9 +526,9 @@ debug_headers = \ # For --enable-cheaders=c_std @GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc @GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra = -@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra = @GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers} +@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra = host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR) host_builddir = ./${host_alias}/bits diff --git a/libstdc++-v3/include/bits/demangle.h b/libstdc++-v3/include/ext/demangle.h similarity index 94% rename from libstdc++-v3/include/bits/demangle.h rename to libstdc++-v3/include/ext/demangle.h index 68cdabea6bd..5de4f04a224 100644 --- a/libstdc++-v3/include/bits/demangle.h +++ b/libstdc++-v3/include/ext/demangle.h @@ -1,6 +1,6 @@ // C++ IA64 / g++ v3 demangler -*- C++ -*- -// Copyright (C) 2003 Free Software Foundation, Inc. +// Copyright (C) 2003, 2004 Free Software Foundation, Inc. // Written by Carlo Wood // // This file is part of the GNU ISO C++ Library. This library is free @@ -37,6 +37,7 @@ #include #include +#include #ifndef _GLIBCXX_DEMANGLER_DEBUG #define _GLIBCXX_DEMANGLER_CWDEBUG 0 @@ -58,7 +59,6 @@ namespace __gnu_cxx { namespace demangler { - enum substitution_nt { type, @@ -101,16 +101,16 @@ namespace __gnu_cxx pointer_to_member = 'M' }; - template + template > class qualifier; - template + template > class qualifier_list; - template + template > class session; - template + template class qualifier { typedef typename Allocator::template rebind::other @@ -205,7 +205,7 @@ namespace __gnu_cxx #endif }; - template + template class qualifier_list { typedef typename Allocator::template rebind::other @@ -215,18 +215,18 @@ namespace __gnu_cxx private: mutable bool M_printing_suppressed; - typedef qualifier qual; + typedef qualifier qual; typedef typename Allocator::template rebind::other qual_Allocator; typedef std::vector qual_vector; qual_vector M_qualifier_starts; - session& M_demangler; + session& M_demangler; void decode_KVrA(string_type& prefix, string_type& postfix, int cvq, typename qual_vector:: const_reverse_iterator const& iter_array) const; public: - qualifier_list(session& demangler_obj) + qualifier_list(session& demangler_obj) : M_printing_suppressed(false), M_demangler(demangler_obj) { } @@ -235,7 +235,7 @@ namespace __gnu_cxx int start_pos, int inside_substitution) { M_qualifier_starts. - push_back(qualifier(start_pos, + push_back(qualifier(start_pos, simple_qualifier, inside_substitution)); } void @@ -244,7 +244,7 @@ namespace __gnu_cxx int count, int inside_substitution) { M_qualifier_starts. - push_back(qualifier(start_pos, + push_back(qualifier(start_pos, cv_qualifier, &M_demangler.M_str[start_pos], count, inside_substitution)); } @@ -254,7 +254,7 @@ namespace __gnu_cxx string_type optional_type, int inside_substitution) { M_qualifier_starts. - push_back(qualifier(start_pos, + push_back(qualifier(start_pos, param_qualifier, optional_type, inside_substitution)); } void @@ -347,10 +347,11 @@ namespace __gnu_cxx { return false; } }; - template + template class session { - friend class qualifier_list; + public: + friend class qualifier_list; typedef typename Allocator::template rebind::other char_Allocator; typedef std::basic_string, char_Allocator> @@ -406,7 +407,7 @@ namespace __gnu_cxx bool decode_type(string_type& output, - qualifier_list* qualifiers = NULL) + qualifier_list* qualifiers = NULL) { string_type postfix; bool res = decode_type_with_postfix(output, postfix, qualifiers); @@ -449,7 +450,7 @@ namespace __gnu_cxx int number_of_prefixes); bool decode_type_with_postfix(string_type& prefix, - string_type& postfix, qualifier_list* qualifiers = NULL); + string_type& postfix, qualifier_list* qualifiers = NULL); bool decode_bare_function_type(string_type& output); bool decode_builtin_type(string_type& output); bool decode_call_offset(string_type& output); @@ -465,10 +466,10 @@ namespace __gnu_cxx bool decode_operator_name(string_type& output); bool decode_source_name(string_type& output); bool decode_substitution(string_type& output, - qualifier_list* qualifiers = NULL); + qualifier_list* qualifiers = NULL); bool decode_template_args(string_type& output); bool decode_template_param(string_type& output, - qualifier_list* qualifiers = NULL); + qualifier_list* qualifiers = NULL); bool decode_unqualified_name(string_type& output); bool decode_unscoped_name(string_type& output); bool decode_non_negative_decimal_integer(string_type& output); @@ -476,12 +477,12 @@ namespace __gnu_cxx bool decode_real(string_type& output, size_t size_of_real); }; - template + template #if !_GLIBCXX_DEMANGLER_CWDEBUG inline #endif void - session::add_substitution(int start_pos, + session::add_substitution(int start_pos, substitution_nt sub_type, int number_of_prefixes = 0) { @@ -572,9 +573,9 @@ namespace __gnu_cxx // ::= 1|2|3|4|5|6|7|8|9 [+] // ::= 0|1|2|3|4|5|6|7|8|9 // - template + template bool - session:: + session:: decode_non_negative_decimal_integer(string_type& output) { char c = current(); @@ -598,9 +599,9 @@ namespace __gnu_cxx // ::= [n] // - template + template bool - session::decode_number(string_type& output) + session::decode_number(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_number"); if (current() != 'n') @@ -668,9 +669,9 @@ namespace __gnu_cxx }; // - template + template bool - session::decode_builtin_type(string_type& output) + session::decode_builtin_type(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_builtin_type"); char const* bt; @@ -683,9 +684,9 @@ namespace __gnu_cxx // ::= // - template + template bool - session::decode_class_enum_type(string_type& output) + session::decode_class_enum_type(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_class_enum_type"); string_type nested_name_qualifiers; @@ -711,10 +712,10 @@ namespace __gnu_cxx // 0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z // [] # Base 36 number // - template + template bool - session::decode_substitution(string_type& output, - qualifier_list* qualifiers) + session::decode_substitution(string_type& output, + qualifier_list* qualifiers) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_substitution"); unsigned int value = 0; @@ -885,10 +886,10 @@ namespace __gnu_cxx // ::= T_ # first template parameter // ::= T _ // - template + template bool - session::decode_template_param(string_type& output, - qualifier_list* qualifiers) + session::decode_template_param(string_type& output, + qualifier_list* qualifiers) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_template_parameter"); if (current() != 'T') @@ -928,9 +929,9 @@ namespace __gnu_cxx _GLIBCXX_DEMANGLER_RETURN; } - template + template bool - session::decode_real(string_type& output, size_t size_of_real) + session::decode_real(string_type& output, size_t size_of_real) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_real"); @@ -988,9 +989,9 @@ namespace __gnu_cxx _GLIBCXX_DEMANGLER_RETURN; } - template + template bool - session::decode_literal(string_type& output) + session::decode_literal(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_literal"); eat_current(); // Eat the 'L'. @@ -1222,9 +1223,9 @@ namespace __gnu_cxx { "ix", "operator[]", unary } }; - template + template bool - session::decode_operator_name(string_type& output) + session::decode_operator_name(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_operator_name"); @@ -1292,9 +1293,9 @@ namespace __gnu_cxx // ::= L E # floating literal // ::= L E # external name // - template + template bool - session::decode_expression(string_type& output) + session::decode_expression(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_expression"); if (current() == 'T') @@ -1479,9 +1480,9 @@ namespace __gnu_cxx // ::= L E # floating literal // ::= L E # external name // ::= X E # expression - template + template bool - session::decode_template_args(string_type& output) + session::decode_template_args(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_template_args"); if (eat_current() != 'I') @@ -1542,9 +1543,9 @@ namespace __gnu_cxx // our slightly different from the one in // the C++-ABI description. // - template + template bool - session::decode_bare_function_type(string_type& output) + session::decode_bare_function_type(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_bare_function_type"); if (M_saw_destructor) @@ -1702,9 +1703,9 @@ namespace __gnu_cxx // number of A's in the series. // In the function below, iter_array points to the first (right most) // A in the series, if any. - template + template void - qualifier_list::decode_KVrA( + qualifier_list::decode_KVrA( string_type& prefix, string_type& postfix, int cvq, typename qual_vector::const_reverse_iterator const& iter_array) const { @@ -1750,9 +1751,9 @@ namespace __gnu_cxx _GLIBCXX_DEMANGLER_RETURN3; } - template + template void - qualifier_list::decode_qualifiers( + qualifier_list::decode_qualifiers( string_type& prefix, string_type& postfix, bool member_function_pointer_qualifiers = false) const @@ -1842,11 +1843,11 @@ namespace __gnu_cxx } // - template + template bool - session::decode_type_with_postfix( + session::decode_type_with_postfix( string_type& prefix, string_type& postfix, - qualifier_list* qualifiers) + qualifier_list* qualifiers) { _GLIBCXX_DEMANGLER_DOUT_ENTERING2("decode_type"); ++M_inside_type; @@ -1953,7 +1954,7 @@ namespace __gnu_cxx ++count; c = next(); } - qualifier_list class_type_qualifiers(*this); + qualifier_list class_type_qualifiers(*this); if (count) class_type_qualifiers. add_qualifier_start(cv_qualifier, Q2_start_pos, @@ -2209,9 +2210,9 @@ namespace __gnu_cxx // ::= // ::= // - template + template bool - session::decode_nested_name(string_type& output, + session::decode_nested_name(string_type& output, string_type& qualifiers) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_nested_name"); @@ -2295,9 +2296,9 @@ namespace __gnu_cxx // := Z E s [] // := _ // - template + template bool - session::decode_local_name(string_type& output) + session::decode_local_name(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_local_name"); if (current() != 'Z' || M_pos >= M_maxpos) @@ -2327,9 +2328,9 @@ namespace __gnu_cxx // ::= // - template + template bool - session::decode_source_name(string_type& output) + session::decode_source_name(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_source_name"); int length = current() - '0'; @@ -2359,9 +2360,9 @@ namespace __gnu_cxx // ::= # Starts with 'C' or 'D'. // ::= # Starts with a digit. // - template + template bool - session::decode_unqualified_name(string_type& output) + session::decode_unqualified_name(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_unqualified_name"); if (M_inside_template_args) @@ -2434,9 +2435,9 @@ namespace __gnu_cxx // # Starts not with an 'S' // St # ::std:: // - template + template bool - session::decode_unscoped_name(string_type& output) + session::decode_unscoped_name(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_unscoped_name"); if (current() == 'S') @@ -2460,9 +2461,9 @@ namespace __gnu_cxx // // ::= // ::= - template + template bool - session::decode_name(string_type& output, + session::decode_name(string_type& output, string_type& nested_name_qualifiers) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_name"); @@ -2502,9 +2503,9 @@ namespace __gnu_cxx // // ::= _ // virtual base override, with vcall offset - template + template bool - session::decode_call_offset(string_type& + session::decode_call_offset(string_type& #if _GLIBCXX_DEMANGLER_CWDEBUG output #endif @@ -2557,9 +2558,9 @@ namespace __gnu_cxx // second call-offset is result // adjustment // - template + template bool - session::decode_special_name(string_type& output) + session::decode_special_name(string_type& output) { _GLIBCXX_DEMANGLER_DOUT_ENTERING("decode_special_name"); if (current() == 'G') @@ -2642,9 +2643,9 @@ namespace __gnu_cxx // character. // # Idem. // # Starts with 'T' or 'G'. - template + template int - session::decode_encoding(string_type& output, + session::decode_encoding(string_type& output, char const* in, int len, implementation_details const& id) { #if _GLIBCXX_DEMANGLER_CWDEBUG @@ -2656,7 +2657,7 @@ namespace __gnu_cxx #endif if (len <= 0) return INT_MIN; - session demangler_session(in, len, id); + session demangler_session(in, len, id); string_type nested_name_qualifiers; int saved_pos; demangler_session.store(saved_pos); @@ -2696,7 +2697,7 @@ namespace __gnu_cxx } // namespace demangler // Public interface - template + template struct demangle { typedef typename Allocator::template rebind::other char_Allocator; @@ -2712,15 +2713,15 @@ namespace __gnu_cxx // // Demangle `input' which should be a mangled function name as for // instance returned by nm(1). - template - typename demangle::string_type - demangle::symbol(char const* input, + template + typename demangle::string_type + demangle::symbol(char const* input, demangler::implementation_details const& id) { // ::= _Z // ::= _GLOBAL_ __ // can be I or D (GNU extension) - typedef demangler::session demangler_type; + typedef demangler::session demangler_type; string_type result; bool failure = (input[0] != '_'); @@ -2763,9 +2764,9 @@ namespace __gnu_cxx // demangle::type() // Demangle `input' which must be a zero terminated mangled type // name as for instance returned by std::type_info::name(). - template - typename demangle::string_type - demangle::type(char const* input, + template + typename demangle::string_type + demangle::type(char const* input, demangler::implementation_details const& id) { std::basic_string, Allocator> result; @@ -2773,7 +2774,7 @@ namespace __gnu_cxx result = "(null)"; else { - demangler::session demangler_session(input, INT_MAX, id); + demangler::session demangler_session(input, INT_MAX, id); if (!demangler_session.decode_type(result) || demangler_session.remaining_input_characters()) { @@ -2783,7 +2784,6 @@ namespace __gnu_cxx } return result; } - } // namespace __gnu_cxx #endif // __DEMANGLE_H diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am index 50727402c13..5550686728a 100644 --- a/libstdc++-v3/libsupc++/Makefile.am +++ b/libstdc++-v3/libsupc++/Makefile.am @@ -1,6 +1,6 @@ ## Makefile for the GNU C++ Support library. ## -## Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +## Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. ## ## Process this file with automake to produce Makefile.in. ## @@ -34,6 +34,9 @@ noinst_LTLIBRARIES = libsupc++convenience.la headers = \ exception new typeinfo cxxabi.h exception_defines.h +c_sources = \ + cp-demangle.c + sources = \ del_op.cc \ del_opnt.cc \ @@ -62,8 +65,8 @@ sources = \ vec.cc \ vterminate.cc -libsupc___la_SOURCES = $(sources) -libsupc__convenience_la_SOURCES = $(sources) +libsupc___la_SOURCES = $(sources) $(c_sources) +libsupc__convenience_la_SOURCES = $(sources) $(c_sources) glibcxxinstalldir = $(gxx_include_dir) glibcxxinstall_HEADERS = $(headers) @@ -83,6 +86,29 @@ AM_CXXFLAGS = \ AM_MAKEFLAGS = \ "gxx_include_dir=$(gxx_include_dir)" + +# Use special rules for pulling things out of libiberty. These +# objects should be compiled with the "C" compiler, not the C++ +# compiler, and also should not use the C++ includes. +C_INCLUDES = -I.. -I$(toplevel_srcdir)/libiberty -I$(toplevel_srcdir)/include +C_COMPILE = \ + $(CC) $(DEFS) $(C_INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) + +# LTCOMPILE is copied from LTCXXCOMPILE below. +LTCOMPILE = $(LIBTOOL) --tag CC --tag disable-shared --mode=compile $(CC) \ + $(DEFS) $(C_INCLUDES) $(LIBSUPCXX_PICFLAGS) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) + +cp-demangle.c: + rm -f $@ + $(LN_S) $(toplevel_srcdir)/libiberty/cp-demangle.c $@ +cp-demangle.lo: cp-demangle.c + $(LTCOMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< +cp-demangle.o: cp-demangle.c + $(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< + + # libstdc++ libtool notes # 1) Need to explicitly set LTCXXCOMPILE so that AM_CXXFLAGS is diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in index f2ef55ee83b..9945e8295ca 100644 --- a/libstdc++-v3/libsupc++/Makefile.in +++ b/libstdc++-v3/libsupc++/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.7.9 from Makefile.am. +# Makefile.in generated by automake 1.7.8 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 @@ -42,7 +42,8 @@ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AS = @AS@ -ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@ +ATOMICITY_SRCDIR = @ATOMICITY_SRCDIR@ +ATOMIC_WORD_SRCDIR = @ATOMIC_WORD_SRCDIR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ @@ -227,6 +228,10 @@ headers = \ exception new typeinfo cxxabi.h exception_defines.h +c_sources = \ + cp-demangle.c + + sources = \ del_op.cc \ del_opnt.cc \ @@ -256,8 +261,8 @@ sources = \ vterminate.cc -libsupc___la_SOURCES = $(sources) -libsupc__convenience_la_SOURCES = $(sources) +libsupc___la_SOURCES = $(sources) $(c_sources) +libsupc__convenience_la_SOURCES = $(sources) $(c_sources) glibcxxinstalldir = $(gxx_include_dir) glibcxxinstall_HEADERS = $(headers) @@ -279,6 +284,21 @@ AM_MAKEFLAGS = \ "gxx_include_dir=$(gxx_include_dir)" +# Use special rules for pulling things out of libiberty. These +# objects should be compiled with the "C" compiler, not the C++ +# compiler, and also should not use the C++ includes. +C_INCLUDES = -I.. -I$(toplevel_srcdir)/libiberty -I$(toplevel_srcdir)/include +C_COMPILE = \ + $(CC) $(DEFS) $(C_INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) + + +# LTCOMPILE is copied from LTCXXCOMPILE below. +LTCOMPILE = $(LIBTOOL) --tag CC --tag disable-shared --mode=compile $(CC) \ + $(DEFS) $(C_INCLUDES) $(LIBSUPCXX_PICFLAGS) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) + + # libstdc++ libtool notes # 1) Need to explicitly set LTCXXCOMPILE so that AM_CXXFLAGS is @@ -329,16 +349,22 @@ am__objects_1 = del_op.lo del_opnt.lo del_opv.lo del_opvnt.lo \ eh_terminate.lo eh_throw.lo eh_type.lo eh_unex_handler.lo \ guard.lo new_handler.lo new_op.lo new_opnt.lo new_opv.lo \ new_opvnt.lo pure.lo tinfo.lo tinfo2.lo vec.lo vterminate.lo -am_libsupc___la_OBJECTS = $(am__objects_1) +am__objects_2 = cp-demangle.lo +am_libsupc___la_OBJECTS = $(am__objects_1) $(am__objects_2) libsupc___la_OBJECTS = $(am_libsupc___la_OBJECTS) libsupc__convenience_la_LDFLAGS = libsupc__convenience_la_LIBADD = -am_libsupc__convenience_la_OBJECTS = $(am__objects_1) +am_libsupc__convenience_la_OBJECTS = $(am__objects_1) $(am__objects_2) libsupc__convenience_la_OBJECTS = $(am_libsupc__convenience_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) @@ -353,7 +379,7 @@ SOURCES = $(libsupc___la_SOURCES) $(libsupc__convenience_la_SOURCES) all: all-am .SUFFIXES: -.SUFFIXES: .cc .lo .o .obj +.SUFFIXES: .c .cc .lo .o .obj $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/fragment.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --foreign libsupc++/Makefile @@ -407,6 +433,15 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +.c.o: + $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< + +.c.obj: + $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` + +.c.lo: + $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< + .cc.o: $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< @@ -530,7 +565,7 @@ install-am: all-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: @@ -606,6 +641,14 @@ uninstall-am: uninstall-glibcxxinstallHEADERS uninstall-info-am \ uninstall-info-am uninstall-toolexeclibLTLIBRARIES +cp-demangle.c: + rm -f $@ + $(LN_S) $(toplevel_srcdir)/libiberty/cp-demangle.c $@ +cp-demangle.lo: cp-demangle.c + $(LTCOMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< +cp-demangle.o: cp-demangle.c + $(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< + # We have to have rules modified from the default to counteract SUN make # prepending each of $(glibcxxinstall_HEADERS) with VPATH below. install-glibcxxinstallHEADERS: $(glibcxxinstall_HEADERS) diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index 7b7f97767be..d70d1af3ad1 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/src/Makefile.am @@ -101,7 +101,6 @@ sources = \ complex_io.cc \ ctype.cc \ debug.cc \ - demangle.cc \ functexcept.cc \ globals_locale.cc \ globals_io.cc \ diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in index 24e7796175e..99a6eb64124 100644 --- a/libstdc++-v3/src/Makefile.in +++ b/libstdc++-v3/src/Makefile.in @@ -220,12 +220,12 @@ AM_CPPFLAGS = $(GLIBCXX_INCLUDES) # Cross compiler support. toolexeclib_LTLIBRARIES = libstdc++.la +@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_arg = # Symbol versioning for shared libraries. @GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_arg = -Wl,--version-script=libstdc++-symbol.ver -@GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_arg = -@GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_dep = libstdc++-symbol.ver @GLIBCXX_BUILD_VERSIONED_SHLIB_FALSE@version_dep = +@GLIBCXX_BUILD_VERSIONED_SHLIB_TRUE@version_dep = libstdc++-symbol.ver # Source files linked in via configuration/make substitution for a # particular host. @@ -256,7 +256,6 @@ sources = \ complex_io.cc \ ctype.cc \ debug.cc \ - demangle.cc \ functexcept.cc \ globals_locale.cc \ globals_io.cc \ @@ -366,9 +365,9 @@ am__objects_1 = atomicity.lo codecvt_members.lo collate_members.lo \ numeric_members.lo time_members.lo am__objects_2 = basic_file.lo c++locale.lo am__objects_3 = allocator.lo codecvt.lo complex_io.lo ctype.lo debug.lo \ - demangle.lo functexcept.lo globals_locale.lo globals_io.lo \ - ios.lo ios_failure.lo ios_init.lo ios_locale.lo limits.lo \ - list.lo locale.lo locale_init.lo locale_facets.lo localename.lo \ + functexcept.lo globals_locale.lo globals_io.lo ios.lo \ + ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo \ + locale.lo locale_init.lo locale_facets.lo localename.lo \ stdexcept.lo strstream.lo tree.lo allocator-inst.lo \ concept-inst.lo fstream-inst.lo ext-inst.lo io-inst.lo \ istream-inst.lo locale-inst.lo locale-misc-inst.lo misc-inst.lo \ diff --git a/libstdc++-v3/src/demangle.cc b/libstdc++-v3/src/demangle.cc deleted file mode 100644 index 779076d3554..00000000000 --- a/libstdc++-v3/src/demangle.cc +++ /dev/null @@ -1,195 +0,0 @@ -// C++ IA64 / g++ v3 demangler -*- C++ -*- - -// Copyright (C) 2003, 2004 Free Software Foundation, Inc. -// Written by Carlo Wood -// -// This file is part of the GNU ISO C++ Library. This library is free -// software; you can redistribute it and/or modify it under the -// terms of the GNU General Public License as published by the -// Free Software Foundation; either version 2, or (at your option) -// any later version. - -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING. If not, write to the Free -// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, -// USA. - -// As a special exception, you may use this file as part of a free software -// library without restriction. Specifically, if other files instantiate -// templates or use macros or inline functions from this file, or you compile -// this file and link it with other files to produce an executable, this -// file does not by itself cause the resulting executable to be covered by -// the GNU General Public License. This exception does not however -// invalidate any other reasons why the executable file might be covered by -// the GNU General Public License. - -#include -#include - -// __cxa_demangle -// -// Demangle a C++ symbol or type name. -// -// `mangled-name' is a pointer to a null-terminated array of characters. -// It may be either an external name, i.e. with a "_Z" prefix, or an -// internal NTBS mangling, e.g. of a type for type_info. -// -// `buf' may be null. If it is non-null, then n must also be non-null, -// and buf is a pointer to an array, of at least *n characters, that -// was allocated using malloc. -// -// `status' points to an int that is used as an error indicator. It is -// permitted to be null, in which case the user just doesn't get any -// detailed error information. -// -// Returns: a pointer to a null-terminated array of characters, the -// demangled name. Or NULL in case of failure. -// -// If there is an error in demangling, the return value is a null pointer. -// The user can examine *status to find out what kind of error occurred. -// Meaning of error indications: -// -// * 0: success -// * -1: memory allocation failure -// * -2: invalid mangled name -// * -3: invalid arguments (e.g. buf nonnull and n null) -// - -namespace __cxxabiv1 -{ - namespace - { - char* const error = 0; - - enum status_codes - { - success = 0, - memory_allocation_failure = -1, - invalid_mangled_name = -2, - invalid_argument = -3 - }; - - inline char* - failure(status_codes error_code, int* status) - { - if (status) - *status = error_code; - return error; - } - - char* - finish(char const* demangled_name, size_t demangled_name_size, - char* buf, size_t* n, int* status) - { - if (!buf || *n < demangled_name_size + 1) - { - if (n) - *n = demangled_name_size + 1; - buf = (char*)realloc(buf, demangled_name_size + 1); - if (!buf) - return failure(memory_allocation_failure, status); - } - if (status) - *status = success; - std::strncpy(buf, demangled_name, demangled_name_size); - buf[demangled_name_size] = 0; - return buf; - } - } // namespace - - char* - __cxa_demangle(char const* mangled_name, char* buf, std::size_t* n, - int* status) - { - try { - using namespace __gnu_cxx; - typedef demangler::session > session_type; - - if (!mangled_name || (buf && !n)) - return failure(invalid_argument, status); - - std::string result; - if (mangled_name[0] == '_') - { - // External name? - if (mangled_name[1] == 'Z') - { - // C++ name? - int cnt = session_type:: - decode_encoding(result, mangled_name + 2, INT_MAX); - if (cnt < 0 || mangled_name[cnt + 2] != 0) - return failure(invalid_mangled_name, status); - return finish(result.data(), result.size(), buf, n, status); - } - else if (mangled_name[1] == 'G') - { - // Possible _GLOBAL__ extension? - if (!std::strncmp(mangled_name, "_GLOBAL__", 9) - && (mangled_name[9] == 'D' || mangled_name[9] == 'I') - && mangled_name[10] == '_') - { - if (mangled_name[9] == 'D') - result.assign("global destructors keyed to ", 28); - else - result.assign("global constructors keyed to ", 29); - // Output the disambiguation part as-is. - result += mangled_name + 11; - return finish(result.data(), result.size(), buf, n, status); - } - } - } - - // Ambiguities are possible between extern "C" object names and - // internal built-in type names, e.g. "i" may be either an object - // named "i" or the built-in "int" type. Such ambiguities should - // be resolved to user names over built-in names. Builtin types - // are any single lower case character. Any other single - // character is not a mangled type so we can treat those the same - // here. - if (mangled_name[1] == 0) - return finish(mangled_name, 1, buf, n, status); - - // Not a built-in type or external name, try to demangle input as - // NTBS mangled type name. - session_type demangler_session(mangled_name, INT_MAX); - if (!demangler_session.decode_type(result) - || demangler_session.remaining_input_characters()) - { - // Failure to demangle, assume extern "C" name. - result = mangled_name; - } - return finish(result.data(), result.size(), buf, n, status); - } catch (std::bad_alloc&) { - return failure(memory_allocation_failure, status); - } - } -} // namespace __cxxabiv1 - -// Explicit instantiations. -namespace __gnu_cxx -{ - template class demangler::qualifier_list >; - template class demangler::session >; -} // namespace __gnu_cxx - -namespace std -{ - template - void vector::_M_insert_aux(vector::iterator, const int&); - - typedef __gnu_cxx::demangler::substitution_st value_type1; - template - void vector::_M_insert_aux(vector::iterator, - const value_type1&); - - typedef __gnu_cxx::demangler::qualifier > value_type2; - template - void vector::_M_insert_aux(vector::iterator, - const value_type2&); -} - diff --git a/libstdc++-v3/testsuite/demangle/abi_examples/01.cc b/libstdc++-v3/testsuite/demangle/abi_examples/01.cc index 585cfe0435c..e7c41e7b966 100644 --- a/libstdc++-v3/testsuite/demangle/abi_examples/01.cc +++ b/libstdc++-v3/testsuite/demangle/abi_examples/01.cc @@ -31,7 +31,7 @@ int main() // extern "C" function // extern "C" float f(void) { }; // T f - verify_demangle("f", "f"); + verify_demangle("f", "error code = -2: invalid mangled name"); return 0; } diff --git a/libstdc++-v3/testsuite/demangle/abi_examples/02.cc b/libstdc++-v3/testsuite/demangle/abi_examples/02.cc index ce33e53894a..bbae9381e7d 100644 --- a/libstdc++-v3/testsuite/demangle/abi_examples/02.cc +++ b/libstdc++-v3/testsuite/demangle/abi_examples/02.cc @@ -31,7 +31,7 @@ int main() // or variable "f" // int f; // B f - verify_demangle("f", "f"); + verify_demangle("f", "error code = -2: invalid mangled name"); return 0; } diff --git a/libstdc++-v3/testsuite/demangle/regression/cw-11.cc b/libstdc++-v3/testsuite/demangle/regression/cw-11.cc index e5405b2f6e9..6fef1314d99 100644 --- a/libstdc++-v3/testsuite/demangle/regression/cw-11.cc +++ b/libstdc++-v3/testsuite/demangle/regression/cw-11.cc @@ -28,7 +28,8 @@ int main() using namespace __gnu_test; // cplus-dem CORE - verify_demangle("_X11TransParseAddress", "_X11TransParseAddress"); + verify_demangle("_X11TransParseAddress", + "error code = -2: invalid mangled name"); return 0; } diff --git a/libstdc++-v3/testsuite/demangle/regression/cw-16.cc b/libstdc++-v3/testsuite/demangle/regression/cw-16.cc index 8dbfcb1f56e..78ae363a62b 100644 --- a/libstdc++-v3/testsuite/demangle/regression/cw-16.cc +++ b/libstdc++-v3/testsuite/demangle/regression/cw-16.cc @@ -29,14 +29,14 @@ int main() // 2003/11/07, libstdc++/12736 verify_demangle("_Z3fooIA6_KiEvA9_KT_rVPrS4_", - "void foo(int const [9][6], int const restrict (* volatile restrict) [9][6])"); + "void foo(int const [9][6], int restrict const (* volatile restrict) [9][6])"); // 2003/11/12, libstdc++/12947 verify_demangle("_Z1fILi5E1AEvN1CIXqugtT_Li0ELi1ELi2EEE1qE", "void f<5, A>(C<(((5) > (0))) ? (1) : (2)>::q)"); verify_demangle("_Z1fILi5EEvN1AIXcvimlT_Li22EEE1qE", "void f<5>(A<(int)((5) * (22))>::q)"); verify_demangle("_Z1fPFYPFiiEiE", - "f(int (*(*) [extern \"C\"] (int))(int))"); + "f(int (*(*)(int))(int))"); verify_demangle("_Z1fI1XENT_1tES2_", "X::t f(X::t)"); verify_demangle("_Z1fILi5E1AEvN1CIXstN1T1tEEXszsrS2_1tEE1qE", -- 2.11.0