The testcases in this bug reveal cases where an early generated
type is collected because it was unused but gets attempted to
be recreated later when a late DIE for a function (an OpenMP
reduction) is created. That's unexpected and possibly the fault
of OpenMP but the following allows the re-creation of the context
type to succeed.
PR ipa/106124
* dwarf2out.cc (lookup_type_die): Reset TREE_ASM_WRITTEN
so we can re-create the DIE for the type if required.
* g++.dg/gomp/pr106124.C: New testcase.
if (die && die->removed)
{
TYPE_SYMTAB_DIE (type) = NULL;
+ TREE_ASM_WRITTEN (type) = 0;
return NULL;
}
return die;
--- /dev/null
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-options "-g -O2 -fopenmp -fkeep-inline-functions" }
+
+int q;
+struct A
+{
+ typedef int T;
+#pragma omp declare reduction (x : T : omp_out += omp_in + [] (){ return q; }()) initializer (omp_priv = [](){ return 0; }())
+ static void foo ();
+};
+void bar (int &, int &);
+void
+A::foo ()
+{
+ int r = 0, s = 0;
+#pragma omp parallel reduction (x : r, s)
+ bar (r, s);
+}