rtti.c (get_tinfo_fn_dynamic): If this function is called an FLAG_RTTI is unset...
authorMichael Tiemann <tiemann@axon.cygnus.com>
Wed, 4 Mar 1998 12:13:02 +0000 (12:13 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 4 Mar 1998 12:13:02 +0000 (07:13 -0500)
* 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
gcc/cp/gxxint.texi
gcc/cp/lex.c
gcc/cp/rtti.c

index 582567a4e7e124729482884a278450b8e0ad5746..c088b9b48b093d64bdf8ee4fe567a835e482a518 100644 (file)
@@ -1,3 +1,10 @@
+Wed Mar  4 12:11:53 1998  Michael Tiemann  <tiemann@axon.cygnus.com>
+
+       * 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  <jason@yorick.cygnus.com>
 
        * typeck.c (unary_complex_lvalue): &D::i has type B::* if i comes
index cf9aaa9a12d9a961caeaf584a6dd88e27dedb68f..84f0395832b2db4f35782511fa992b9659aee22b 100644 (file)
@@ -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<T>}.
 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:
index 7dfcc1f4c21c62c638be1dd64f5e19864ae97c40..90d42802237705ad210ecb151a818234511f20c9 100644 (file)
@@ -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
index d01077c8c967cde0dc06c7334233e201d8bea27d..e866e3c023a441cef5cb4ab8cf524445bf083c18 100644 (file)
@@ -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);