From: Nathan Sidwell Date: Thu, 19 Nov 2020 16:00:49 +0000 (-0800) Subject: c++: Relax new assert [PR 97905] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=255483e5b70beade63efdf1f3efa6b814831da08;p=gcc.git c++: Relax new assert [PR 97905] It turns out there are legitimate cases for the new decl to not have lang-specific. PR c++/97905 gcc/cp/ * decl.c (duplicate_decls): Relax new assert. gcc/testsuite/ * g++.dg/lookup/pr97905.C: New. --- diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d90e9840f40..f5c6f5c0d10 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2749,9 +2749,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) with that from NEWDECL below. */ if (DECL_LANG_SPECIFIC (olddecl)) { - gcc_checking_assert (DECL_LANG_SPECIFIC (newdecl) - && (DECL_LANG_SPECIFIC (olddecl) - != DECL_LANG_SPECIFIC (newdecl))); + gcc_checking_assert (DECL_LANG_SPECIFIC (olddecl) + != DECL_LANG_SPECIFIC (newdecl)); ggc_free (DECL_LANG_SPECIFIC (olddecl)); } diff --git a/gcc/testsuite/g++.dg/lookup/pr97905.C b/gcc/testsuite/g++.dg/lookup/pr97905.C new file mode 100644 index 00000000000..22a7e5cf6d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/pr97905.C @@ -0,0 +1,7 @@ +// PR 97905 + + +template void a() { + extern int *b; // This decl gets an (unneeded) decl-lang-specific +} +int *b; // this does not