This is the same issue as solved in
r16-1759-g98fd493db6216c for auto,
but this time for arrays with size deduced from their initializers.
PR c++/122422
gcc/cp/ChangeLog:
* decl.cc (maybe_deduce_size_from_array_init): Propagate type to
corresponding TEMPLATE_DECL.
gcc/testsuite/ChangeLog:
* g++.dg/modules/merge-20.h: New test.
* g++.dg/modules/merge-20_a.H: New test.
* g++.dg/modules/merge-20_b.C: New test.
Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
cp_apply_type_quals_to_decl (cp_type_quals (TREE_TYPE (decl)), decl);
relayout_decl (decl);
+
+ /* Update the type of the corresponding TEMPLATE_DECL to match. */
+ if (DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl))
+ {
+ tree tmpl = template_for_substitution (decl);
+ if (DECL_TEMPLATE_RESULT (tmpl) == decl)
+ TREE_TYPE (tmpl) = TREE_TYPE (decl);
+ }
}
}
--- /dev/null
+// PR c++/122422
+template <typename> struct Type {
+ constexpr static int arr[] = { 42, 43, 44 };
+};
+inline Type<int> tt;
--- /dev/null
+// PR c++/122422
+// { dg-additional-options "-fmodule-header" }
+// { dg-module-cmi {} }
+
+#include "merge-20.h"
--- /dev/null
+// PR c++/122422
+// { dg-additional-options "-fmodules -fno-module-lazy" }
+
+#include "merge-20.h"
+import "merge-20_a.H";