This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

(C++) patch: -fno-enforce-eh-specs


throw() specs are now useful for optimization, but they also incur a
penalty, as we need to trap any passing exception and call
unexpected.  -fno-enforce-eh-specs disables that checking, much like
defining NDEBUG in code that uses assert.

2000-03-10  Jason Merrill  <jason@casey.cygnus.com>

	* lang-options.h, decl2.c: Add -fno-enforce-eh-specs.
	* cp-tree.h: Declare flag_enforce_eh_specs.
	* decl.c (store_parm_decls, finish_function): Check it.

Index: invoke.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/invoke.texi,v
retrieving revision 1.177
diff -c -p -r1.177 invoke.texi
*** invoke.texi	2000/02/29 01:42:52	1.177
--- invoke.texi	2000/03/10 11:52:21
*************** which is only used to initialize another
*** 1064,1069 ****
--- 1064,1075 ----
  Specifying this option disables that optimization, and forces g++ to
  call the copy constructor in all cases.
  
+ @item -fno-enforce-eh-specs
+ Don't check for violation of exception specifications at runtime.  This
+ option violates the C++ standard, but may be useful for reducing code
+ size in production builds, much like defining @samp{NDEBUG}.  The compiler
+ will still optimize based on the exception specifications.
+ 
  @item -fexternal-templates
  Cause template instantiations to obey @samp{#pragma interface} and
  @samp{implementation}; template instances are emitted or not according
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.414
diff -c -p -r1.414 cp-tree.h
*** cp-tree.h	2000/03/10 09:25:44	1.414
--- cp-tree.h	2000/03/10 11:44:19
*************** extern int flag_vtable_gc;
*** 1149,1154 ****
--- 1149,1160 ----
     The value of this flag is ignored if -pedantic is specified.  */
  extern int flag_permissive;
  
+ /* Nonzero means to implement standard semantics for exception
+    specifications, calling unexpected if an exception is thrown that
+    doesn't match the specification.  Zero means to treat them as
+    assertions and optimize accordingly, but not check them.  */
+ extern int flag_enforce_eh_specs;
+ 
  /* Nonzero if we want to obey access control semantics.  */
  
  extern int flag_access_control;
Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.562
diff -c -p -r1.562 decl.c
*** decl.c	2000/03/10 09:25:44	1.562
--- decl.c	2000/03/10 11:44:30
*************** store_parm_decls ()
*** 13563,13568 ****
--- 13566,13572 ----
  
    /* Do the starting of the exception specifications, if we have any.  */
    if (flag_exceptions && !processing_template_decl
+       && flag_enforce_eh_specs
        && building_stmt_tree ()
        && TYPE_RAISES_EXCEPTIONS (TREE_TYPE (current_function_decl)))
      current_eh_spec_try_block = expand_start_eh_spec ();
*************** finish_function (lineno, flags)
*** 13840,13845 ****
--- 13844,13850 ----
  
        /* Finish dealing with exception specifiers.  */
        if (flag_exceptions && !processing_template_decl
+ 	  && flag_enforce_eh_specs
  	  && TYPE_RAISES_EXCEPTIONS (TREE_TYPE (current_function_decl)))
  	expand_end_eh_spec (TYPE_RAISES_EXCEPTIONS
  			    (TREE_TYPE (current_function_decl)),
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.316
diff -c -p -r1.316 decl2.c
*** decl2.c	2000/03/07 20:39:07	1.316
--- decl2.c	2000/03/10 11:44:33
*************** int flag_vtable_gc;
*** 490,495 ****
--- 490,502 ----
  
  int flag_permissive;
  
+ /* Nonzero means to implement standard semantics for exception
+    specifications, calling unexpected if an exception is thrown that
+    doesn't match the specification.  Zero means to treat them as
+    assertions and optimize accordingly, but not check them.  */
+ 
+ int flag_enforce_eh_specs = 1;
+ 
  /* If this variable is defined to a non-NULL value, it will be called
     after the file has been completely parsed.  */
  
*************** lang_f_options[] =
*** 524,529 ****
--- 531,537 ----
    {"default-inline", &flag_default_inline, 1},
    {"dollars-in-identifiers", &dollars_in_ident, 1},
    {"elide-constructors", &flag_elide_constructors, 1},
+   {"enforce-eh-specs", &flag_enforce_eh_specs, 1},
    {"external-templates", &flag_external_templates, 1},
    {"for-scope", &flag_new_for_scope, 2},
    {"gnu-keywords", &flag_no_gnu_keywords, 0},
Index: lang-options.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lang-options.h,v
retrieving revision 1.32
diff -c -p -r1.32 lang-options.h
*** lang-options.h	2000/02/27 00:57:13	1.32
--- lang-options.h	2000/03/10 11:44:34
*************** DEFINE_LANG_NAME ("C++")
*** 45,50 ****
--- 45,52 ----
    { "-fno-rtti", "Do not generate run time type descriptor information" },
    { "-felide-constructors", "" },
    { "-fno-elide-constructors", "" },
+   { "-fenforce-eh-specs", "" },
+   { "-fno-enforce-eh-specs", "Do not generate code to check exception specifications" },
    { "-fenum-int-equiv", "" },
    { "-fno-enum-int-equiv", "" },
    { "-fexternal-templates", "" },

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]