* method.c (emit_thunk): Don't crash when -fsyntax-only.
authorMark Mitchell <mark@codesourcery.com>
Fri, 1 Oct 1999 04:34:24 +0000 (04:34 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 1 Oct 1999 04:34:24 +0000 (04:34 +0000)
From-SVN: r29748

gcc/cp/ChangeLog
gcc/cp/method.c
gcc/testsuite/g++.old-deja/g++.other/syntax2.C [new file with mode: 0644]

index 85a03fea03e391af0df00bebc1d6f1124d720d0d..4b40f8427bd899b4c9dcb9a906365981b117b2de 100644 (file)
@@ -1,5 +1,7 @@
 1999-09-30  Mark Mitchell  <mark@codesourcery.com>
 
+       * method.c (emit_thunk): Don't crash when -fsyntax-only.
+
        * cp-tree.h (lang_decl_flags): Add global_ctor_p and
        global_dtor_p.  Add init_priority.
        (DECL_ACCESS): Adjust accordingly.
index f4eb396b94a3ef25113038608e3cd7b938acb96b..b2daeb2f4f62cfcac575f7449c38be0c237ec0d1 100644 (file)
@@ -2086,26 +2086,29 @@ emit_thunk (thunk_fndecl)
 
   TREE_SET_CODE (thunk_fndecl, FUNCTION_DECL);
 
-  {
 #ifdef ASM_OUTPUT_MI_THUNK
-    char *fnname;
-    current_function_decl = thunk_fndecl;
-    /* Make sure we build up its RTL before we go onto the
-       temporary obstack.  */
-    make_function_rtl (thunk_fndecl);
-    temporary_allocation ();
-    DECL_RESULT (thunk_fndecl)
-      = build_decl (RESULT_DECL, 0, integer_type_node);
-    fnname = XSTR (XEXP (DECL_RTL (thunk_fndecl), 0), 0);
-    init_function_start (thunk_fndecl, input_filename, lineno);
-    current_function_is_thunk = 1;
-    assemble_start_function (thunk_fndecl, fnname);
-    ASM_OUTPUT_MI_THUNK (asm_out_file, thunk_fndecl, delta, function);
-    assemble_end_function (thunk_fndecl, fnname);
-    permanent_allocation (1);
-    current_function_decl = 0;
-    current_function = 0;
+  if (!flag_syntax_only)
+    {
+      char *fnname;
+      current_function_decl = thunk_fndecl;
+      /* Make sure we build up its RTL before we go onto the
+        temporary obstack.  */
+      make_function_rtl (thunk_fndecl);
+      temporary_allocation ();
+      DECL_RESULT (thunk_fndecl)
+       = build_decl (RESULT_DECL, 0, integer_type_node);
+      fnname = XSTR (XEXP (DECL_RTL (thunk_fndecl), 0), 0);
+      init_function_start (thunk_fndecl, input_filename, lineno);
+      current_function_is_thunk = 1;
+      assemble_start_function (thunk_fndecl, fnname);
+      ASM_OUTPUT_MI_THUNK (asm_out_file, thunk_fndecl, delta, function);
+      assemble_end_function (thunk_fndecl, fnname);
+      permanent_allocation (1);
+      current_function_decl = 0;
+      current_function = 0;
+    }
 #else /* ASM_OUTPUT_MI_THUNK */
+  {
   /* If we don't have the necessary macro for efficient thunks, generate a
      thunk function that just makes a call to the real function.
      Unfortunately, this doesn't work for varargs.  */
@@ -2157,8 +2160,8 @@ emit_thunk (thunk_fndecl)
        output_inline_function (thunk_fndecl);
        permanent_allocation (1);
       }
-#endif /* ASM_OUTPUT_MI_THUNK */
   }
+#endif /* ASM_OUTPUT_MI_THUNK */
 
   TREE_SET_CODE (thunk_fndecl, THUNK_DECL);
 }
diff --git a/gcc/testsuite/g++.old-deja/g++.other/syntax2.C b/gcc/testsuite/g++.old-deja/g++.other/syntax2.C
new file mode 100644 (file)
index 0000000..5775af0
--- /dev/null
@@ -0,0 +1,28 @@
+// Build don't link:
+// Special g++ Options: -fsyntax-only
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+struct B 
+{
+  double d;
+  
+  virtual void f ();
+};
+
+struct C: virtual public B
+{
+  char c;
+};
+
+struct D: virtual public B
+{
+  int i;
+  virtual void f ();
+};
+
+struct E : public C, public D 
+{
+};
+
+E e;
+