Commit 1660cb3a by Jason Merrill Committed by Jason Merrill

lang-options.h, decl2.c: Add -fno-enforce-eh-specs.

        * 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.

        C library functions don't throw.
        * Makefile.in (cfns.h): New target.
        (except.o): Depend on it.
        * Make-lang.in (cc1plus): Depend on cfns.gperf.
        * cfns.gperf: New file.
        * cfns.h: Generated.
        * except.c: Include it.
        (nothrow_libfn_p): New fn.
        * decl.c (grokfndecl): Use it.
        * cp-tree.h: Declare it.

From-SVN: r32469
parent 0c11ada6
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.
C library functions don't throw.
* Makefile.in (cfns.h): New target.
(except.o): Depend on it.
* Make-lang.in (cc1plus): Depend on cfns.gperf.
* cfns.gperf: New file.
* cfns.h: Generated.
* except.c: Include it.
(nothrow_libfn_p): New fn.
* decl.c (grokfndecl): Use it.
* cp-tree.h: Declare it.
* decl.c (push_overloaded_decl_1, auto_function,
define_function): Lose.
(build_library_fn_1): New static fn.
......
......@@ -123,7 +123,7 @@ CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/class.c $(srcdir)/cp/cp-tree.def \
cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o \
c-pragma.o $(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def \
$(srcdir)/cp/gxx.gperf hash.o
$(srcdir)/cp/gxx.gperf $(srcdir)/cp/cfns.gperf hash.o
cd cp; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1plus$(exeext)
#
# Build hooks:
......
......@@ -242,6 +242,10 @@ $(srcdir)/hash.h: $(srcdir)/gxx.gperf
echo " ftp://sourceware.cygnus.com/pub/egcs/infrastructure/gperf*" >&2 ; \
exit 1 )
$(srcdir)/cfns.h: $(srcdir)/cfns.gperf
gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' \
$(srcdir)/cfns.gperf > $(srcdir)/cfns.h
spew.o : spew.c $(CXX_TREE_H) $(PARSE_H) $(srcdir)/../flags.h \
lex.h $(srcdir)/../toplev.h
lex.o : lex.c $(CXX_TREE_H) \
......@@ -283,7 +287,7 @@ ptree.o : ptree.c $(CXX_TREE_H) $(srcdir)/../system.h
rtti.o : rtti.c $(CXX_TREE_H) $(srcdir)/../flags.h \
$(srcdir)/../toplev.h
except.o : except.c $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H) \
$(srcdir)/../except.h $(srcdir)/../toplev.h
$(srcdir)/../except.h $(srcdir)/../toplev.h cfns.h
expr.o : expr.c $(CXX_TREE_H) $(RTL_H) $(srcdir)/../flags.h \
$(EXPR_H) $(srcdir)/../toplev.h $(srcdir)/../except.h
xref.o : xref.c $(CXX_TREE_H) $(srcdir)/../input.h \
......
# The standard C library functions, for feeding to gperf; the result is used
# by nothrow_libfn_p.
#
# [lib.res.on.exception.handling]: None of the functions from the
# Standard C library shall report an error by throwing an
# exception, unless it calls a program-supplied function that
# throws an exception.
#
# bsearch and qsort are commented out because they can call such functions.
#
abort
abs
acos
asctime
asin
atan
atan2
atexit
atof
atoi
atol
#bsearch
btowc
calloc
ceil
clearerr
clock
cos
cosh
ctime
difftime
div
exit
exp
fabs
fclose
feof
ferror
fflush
fgetc
fgetpos
fgets
fgetwc
fgetws
floor
fmod
fopen
fprintf
fputc
fputs
fputwc
fputws
fread
free
freopen
frexp
fscanf
fseek
fsetpos
ftell
fwide
fwprintf
fwrite
fwscanf
getc
getchar
getenv
gets
getwc
getwchar
gmtime
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
iswalnum
iswalpha
iswcntrl
iswctype
iswdigit
iswgraph
iswlower
iswprint
iswpunct
iswspace
iswupper
iswxdigit
isxdigit
labs
ldexp
ldiv
localeconv
localtime
log
log10
longjmp
malloc
mblen
mbrlen
mbrtowc
mbsinit
mbsrtowcs
mbstowcs
mbtowc
memchr
memcmp
memcpy
memmove
memset
mktime
modf
perror
pow
printf
putc
putchar
puts
putwc
putwchar
#qsort
raise
rand
realloc
remove
rename
rewind
scanf
setbuf
setlocale
setvbuf
signal
sin
sinh
sprintf
sqrt
srand
sscanf
strcat
strchr
strcmp
strcoll
strcpy
strcspn
strerror
strftime
strlen
strncat
strncmp
strncpy
strpbrk
strrchr
strspn
strstr
strtod
strtok
strtol
strtoul
strxfrm
swprintf
swscanf
system
tan
tanh
time
tmpfile
tmpnam
tolower
toupper
towctrans
towlower
towupper
ungetc
ungetwc
vfprintf
vfwprintf
vprintf
vsprintf
vswprintf
vwprintf
wcrtomb
wcscat
wcschr
wcscmp
wcscoll
wcscpy
wcscspn
wcsftime
wcslen
wcsncat
wcsncmp
wcsncpy
wcspbrk
wcsrchr
wcsrtombs
wcsspn
wcsstr
wcstod
wcstok
wcstol
wcstombs
wcstoul
wcsxfrm
wctob
wctomb
wctrans
wctype
wmemchr
wmemcmp
wmemcpy
wmemmove
wmemset
wprintf
wscanf
This diff is collapsed. Click to expand it.
......@@ -1149,6 +1149,12 @@ extern int flag_vtable_gc;
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;
......@@ -3922,6 +3928,7 @@ extern void expand_end_eh_spec PARAMS ((tree, tree));
extern void expand_exception_blocks PARAMS ((void));
extern tree build_throw PARAMS ((tree));
extern void mark_all_runtime_matches PARAMS ((void));
extern int nothrow_libfn_p PARAMS ((tree));
/* in expr.c */
extern void init_cplus_expand PARAMS ((void));
......
......@@ -8668,6 +8668,9 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
tentative. error_mark_node is replaced later with the BLOCK. */
DECL_INITIAL (decl) = error_mark_node;
if (nothrow_libfn_p (decl))
TREE_NOTHROW (decl) = 1;
/* Caller will do the rest of this. */
if (check < 0)
return decl;
......@@ -13563,6 +13566,7 @@ store_parm_decls ()
/* 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 ();
......@@ -13840,6 +13844,7 @@ finish_function (lineno, flags)
/* 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)),
......
......@@ -490,6 +490,13 @@ int flag_vtable_gc;
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. */
......@@ -524,6 +531,7 @@ lang_f_options[] =
{"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},
......
......@@ -1027,3 +1027,30 @@ complete_ptr_ref_or_void_ptr_p (type, from)
return 1;
}
/* Returns nonzero if FN is a declaration of a standard C library
function which is known not to throw.
[lib.res.on.exception.handling]: None of the functions from the
Standard C library shall report an error by throwing an
exception, unless it calls a program-supplied function that
throws an exception. */
#include "cfns.h"
int
nothrow_libfn_p (fn)
tree fn;
{
tree id;
if (TREE_PUBLIC (fn)
&& DECL_EXTERNAL (fn)
&& DECL_LANGUAGE (fn) == lang_c)
/* OK */;
else
/* Can't be a C library function. */
return 0;
id = DECL_ASSEMBLER_NAME (fn);
return !!libc_name_p (IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
}
......@@ -45,6 +45,8 @@ DEFINE_LANG_NAME ("C++")
{ "-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", "" },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment