From: Jakub Jelinek Date: Tue, 13 Mar 2018 20:32:54 +0000 (+0100) Subject: re PR c++/84843 (C++ ICE on builtin redefinition since r258391) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=949aab190a4ff95d4ba71f55e8b77a2aae61457f;p=gcc.git re PR c++/84843 (C++ ICE on builtin redefinition since r258391) PR c++/84843 * decl.c (duplicate_decls): For redefinition of built-in, use error and return error_mark_node. For redeclaration, return error_mark_node rather than olddecl if !flag_permissive. * g++.dg/ext/pr84843-1.C: New test. * g++.dg/ext/pr84843-2.C: New test. From-SVN: r258503 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index da81495e8a4..09dc2b1ac12 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-03-13 Jakub Jelinek + + PR c++/84843 + * decl.c (duplicate_decls): For redefinition of built-in, use error + and return error_mark_node. For redeclaration, return error_mark_node + rather than olddecl if !flag_permissive. + 2018-03-13 Jason Merrill PR c++/82565 - ICE with concepts and generic lambda. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index afd04cea630..ff6dd66e769 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1583,13 +1583,20 @@ next_arg:; || memcmp (name + len - strlen ("_chk"), "_chk", strlen ("_chk") + 1) != 0)) { + if (DECL_INITIAL (newdecl)) + { + error_at (DECL_SOURCE_LOCATION (newdecl), + "definition of %q#D ambiguates built-in " + "declaration %q#D", newdecl, olddecl); + return error_mark_node; + } 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; + return flag_permissive ? olddecl : error_mark_node; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c518ebeff22..a06dc24703a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-03-13 Jakub Jelinek + + PR c++/84843 + * g++.dg/ext/pr84843-1.C: New test. + * g++.dg/ext/pr84843-2.C: New test. + 2018-03-13 David Pagan PR c/46921 diff --git a/gcc/testsuite/g++.dg/ext/pr84843-1.C b/gcc/testsuite/g++.dg/ext/pr84843-1.C new file mode 100644 index 00000000000..050d3e55bd4 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pr84843-1.C @@ -0,0 +1,9 @@ +// PR c++/84843 +// { dg-do compile } +// { dg-options "-fpermissive" } + +extern "C" int +__atomic_compare_exchange (int x, int y) // { dg-error "ambiguates built-in declaration" } +{ + return x + y; +} diff --git a/gcc/testsuite/g++.dg/ext/pr84843-2.C b/gcc/testsuite/g++.dg/ext/pr84843-2.C new file mode 100644 index 00000000000..adf92faaa69 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pr84843-2.C @@ -0,0 +1,9 @@ +// PR c++/84843 +// { dg-do compile } +// { dg-options "" } + +extern "C" int +__atomic_compare_exchange (int x, int y) // { dg-error "ambiguates built-in declaration" } +{ + return x + y; +}