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.

pushing to trunk

--
Nathan Sidwell
diff --git c/gcc/cp/decl.c w/gcc/cp/decl.c
index d90e9840f40..f5c6f5c0d10 100644
--- c/gcc/cp/decl.c
+++ w/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 c/gcc/testsuite/g++.dg/lookup/pr97905.C w/gcc/testsuite/g++.dg/lookup/pr97905.C
new file mode 100644
index 00000000000..22a7e5cf6d4
--- /dev/null
+++ w/gcc/testsuite/g++.dg/lookup/pr97905.C
@@ -0,0 +1,7 @@
+// PR 97905
+
+
+template <typename> void a() {
+  extern int *b; // This decl gets an (unneeded) decl-lang-specific
+}
+int *b; // this does not

Reply via email to