std/time/traits/is_clock.cc was getting a warning about applying the
deprecated attribute to a variant of auto_ptr, which was wrong because it's
on the primary type. This turned out to be because we were ignoring the
attributes on the definition of auto_ptr because the forward declaration in
unique_ptr.h has no attributes. We need to merge attributes as usual in a
redeclaration.
gcc/cp/ChangeLog:
* module.cc (trees_in::decl_value): Merge attributes.
gcc/testsuite/ChangeLog:
* g++.dg/modules/attrib-1_a.C: New test.
* g++.dg/modules/attrib-1_b.C: New test.
TYPE_STUB_DECL (type) = stub_decl ? stub_decl : inner;
if (stub_decl)
TREE_TYPE (stub_decl) = type;
+
+ /* Handle separate declarations with different attributes. */
+ tree &eattr = TYPE_ATTRIBUTES (TREE_TYPE (existing));
+ eattr = merge_attributes (eattr, TYPE_ATTRIBUTES (type));
}
if (inner_tag)
--- /dev/null
+// { dg-additional-options "-fmodules -Wno-global-module" }
+// { dg-module-cmi M }
+
+module;
+
+template <class T> struct A {
+ void f() const { }
+} __attribute__ ((deprecated ("y tho")));
+
+export module M;
+
+export template <class T>
+A<T> a; // { dg-warning "deprecated" }
--- /dev/null
+// { dg-additional-options -fmodules }
+
+template <class T> struct A;
+
+import M;
+
+int main()
+{
+ a<int>.f();
+}