c++: Relax new assert [PR 97905]
authorNathan Sidwell <nathan@acm.org>
Thu, 19 Nov 2020 16:00:49 +0000 (08:00 -0800)
committerNathan Sidwell <nathan@acm.org>
Thu, 19 Nov 2020 17:56:30 +0000 (09:56 -0800)
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.

gcc/cp/decl.c
gcc/testsuite/g++.dg/lookup/pr97905.C [new file with mode: 0644]

index d90e9840f401232b344440ef454a8084ae81e33c..f5c6f5c0d10f76903ab5c2fd8883daf916d44a8c 100644 (file)
@@ -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 (file)
index 0000000..22a7e5c
--- /dev/null
@@ -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