From 5427d758ddd8257a5f24408e036e062c51607972 Mon Sep 17 00:00:00 2001 From: Michael Tiemann Date: Wed, 4 Mar 1998 12:13:02 +0000 Subject: [PATCH] rtti.c (get_tinfo_fn_dynamic): If this function is called an FLAG_RTTI is unset... * rtti.c (get_tinfo_fn_dynamic): If this function is called an FLAG_RTTI is unset, initialize type info machinery and continue with FLAG_RTTI enabled. (get_typeid): Ditto. From-SVN: r18401 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/gxxint.texi | 28 ++++++++++++++++++++++++++++ gcc/cp/lex.c | 1 + gcc/cp/rtti.c | 17 ++++++++++++++++- 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 582567a4e7e..c088b9b48b0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +Wed Mar 4 12:11:53 1998 Michael Tiemann + + * rtti.c (get_tinfo_fn_dynamic): If this function is called an + FLAG_RTTI is unset, initialize type info machinery and continue + with FLAG_RTTI enabled. + (get_typeid): Ditto. + Wed Mar 4 11:47:55 1998 Jason Merrill * typeck.c (unary_complex_lvalue): &D::i has type B::* if i comes diff --git a/gcc/cp/gxxint.texi b/gcc/cp/gxxint.texi index cf9aaa9a12d..84f0395832b 100644 --- a/gcc/cp/gxxint.texi +++ b/gcc/cp/gxxint.texi @@ -1578,6 +1578,11 @@ we are concerned here about a lower-level interface primarily intended for methods written in Java, but that can also be used for C++ (and less easily C). +Note that on systems that follow BSD tradition, a C identifier @code{var} +would get "mangled" into the assembler name @samp{_var}. On such +systems, all other mangled names are also prefixed by a @samp{_} +which is not shown in the following examples. + @subsection Method name mangling C++ mangles a method by emitting the function name, followed by @code{__}, @@ -1646,6 +1651,7 @@ entire mangled method name is followed by a @samp{U}. For example, the method @code{X\u0319::M\u002B(int)} is encoded as @samp{M_002b__U6X_0319iU}. + @subsection Pointer and reference types A C++ pointer type is mangled as @samp{P} followed by the @@ -1706,6 +1712,28 @@ as if it were the C++ type @code{JArray}. For example @code{java.lang.String[]} is encoded as @samp{Pt6JArray1ZPQ34java4lang6String}. +@subsection Static fields + +Both C++ and Java classes can have static fields. +These are allocated statically, and are shared among all instances. + +The mangling starts with a prefix (@samp{_} in most systems), which is +followed by the mangling +of the class name, followed by the "joiner" and finally the field name. +The joiner (see @code{JOINER} in @code{cp-tree.h}) is a special +separator character. For historical reasons (and idiosyncracies +of assembler syntax) it can @samp{$} or @samp{.} (or even +@samp{_} on a few systems). If the joiner is @samp{_} then the prefix +is @samp{__static_} instead of just @samp{_}. + +For example @code{Foo::Bar::var} (or @code{Foo.Bar.var} in Java syntax) +would be encoded as @samp{_Q23Foo3Bar$var} or @samp{_Q23Foo3Bar.var} +(or rarely @samp{__static_Q23Foo3Bar_var}). + +If the name of a static variable needs Unicode escapes, +the Unicode indicator @samp{U} comes before the "joiner". +This @code{\u1234Foo::var\u3445} becomes @code{_U8_1234FooU.var_3445}. + @subsection Table of demangling code characters The following special characters are used in mangling: diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index 7dfcc1f4c21..90d42802237 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -846,6 +846,7 @@ init_lex () UNSET_RESERVED_WORD ("classof"); UNSET_RESERVED_WORD ("headof"); } + if (! flag_handle_signatures || flag_no_gnu_keywords) { /* Easiest way to not recognize signature diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index d01077c8c96..e866e3c023a 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -205,7 +205,13 @@ get_tinfo_fn_dynamic (exp) tree t; if (! flag_rtti) - warning ("taking dynamic typeid of object without -frtti"); + { + warning ("taking dynamic typeid of object without -frtti"); + push_obstacks (&permanent_obstack, &permanent_obstack); + init_rtti_processing (); + pop_obstacks (); + flag_rtti = 1; + } /* If we don't have rtti stuff, get to a sub-object that does. */ if (! CLASSTYPE_VFIELDS (type)) @@ -387,6 +393,15 @@ get_typeid (type) if (type == error_mark_node) return error_mark_node; + if (! flag_rtti) + { + warning ("requesting typeid of object without -frtti"); + push_obstacks (&permanent_obstack, &permanent_obstack); + init_rtti_processing (); + pop_obstacks (); + flag_rtti = 1; + } + if (processing_template_decl) return build_min_nt (TYPEID_EXPR, type); -- 2.30.2