diff options
author | Jakub Jelinek <jakub@redhat.com> | 2018-03-09 19:01:22 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2018-03-09 19:01:22 +0100 |
commit | 060ad85254de126c82bdbfbf6af603701ccf503c (patch) | |
tree | bba1401709b780137f4b983f7472833883788a05 /gcc/cp | |
parent | e0cd6bc00966de0a3a77b642f9507d9c83b398f1 (diff) | |
download | gcc-060ad85254de126c82bdbfbf6af603701ccf503c.zip gcc-060ad85254de126c82bdbfbf6af603701ccf503c.tar.gz gcc-060ad85254de126c82bdbfbf6af603701ccf503c.tar.bz2 |
re PR c++/84724 (internal compiler error: in single_succ_edge, at basic-block.h:339 with a declaration of __builtin_trap)
PR c++/84724
* decl.c (duplicate_decls): Don't override __* prefixed builtins
except for __[^b]*_chk, instead issue permerror and for -fpermissive
also a note and return olddecl.
* g++.dg/ext/pr84724.C: New test.
From-SVN: r258391
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 27 |
2 files changed, 34 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eeaf71d..ae980fd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-03-09 Jakub Jelinek <jakub@redhat.com> + + PR c++/84724 + * decl.c (duplicate_decls): Don't override __* prefixed builtins + except for __[^b]*_chk, instead issue permerror and for -fpermissive + also a note and return olddecl. + 2018-03-09 Nathan Sidwell <nathan@acm.org> PR c++/84733 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b2e19a6..afd04ce 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1566,6 +1566,33 @@ next_arg:; || compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)), TYPE_ARG_TYPES (TREE_TYPE (olddecl)))) { + /* Don't really override olddecl for __* prefixed builtins + except for __[^b]*_chk, the compiler might be using those + explicitly. */ + if (DECL_BUILT_IN (olddecl)) + { + tree id = DECL_NAME (olddecl); + const char *name = IDENTIFIER_POINTER (id); + size_t len; + + if (name[0] == '_' + && name[1] == '_' + && (strncmp (name + 2, "builtin_", + strlen ("builtin_")) == 0 + || (len = strlen (name)) <= strlen ("___chk") + || memcmp (name + len - strlen ("_chk"), + "_chk", strlen ("_chk") + 1) != 0)) + { + if (permerror (DECL_SOURCE_LOCATION (newdecl), + "new declaration %q#D ambiguates built-in" + " declaration %q#D", newdecl, olddecl) + && flag_permissive) + inform (DECL_SOURCE_LOCATION (newdecl), + "ignoring the %q#D declaration", newdecl); + return olddecl; + } + } + /* A near match; override the builtin. */ if (TREE_PUBLIC (newdecl)) |