@@ -10086,6 +10086,7 @@ apply_late_template_attributes (tree *de
if (TREE_TYPE (*decl_p) == error_mark_node)
return;
p = &DECL_ATTRIBUTES (*decl_p);
+ *p = NULL_TREE;
}
else
p = &TYPE_ATTRIBUTES (*decl_p);
@@ -10094,6 +10095,7 @@ apply_late_template_attributes (tree *de
{
tree late_attrs = NULL_TREE;
tree *q = &late_attrs;
+ tree prev = *p;
for (*p = attributes; *p; )
{
@@ -10110,9 +10112,14 @@ apply_late_template_attributes (tree *de
else
p = &TREE_CHAIN (t);
}
+ *p = prev;
cplus_decl_attributes (decl_p, late_attrs, attr_flags);
}
+ else if (*p == NULL)
+ *p = attributes;
+ else if (attributes)
+ *p = chainon (copy_list (attributes), *p);
}
/* Perform (or defer) access check for typedefs that were referenced
@@ -0,0 +1,14 @@
+// PR c++/79502
+// { dg-do compile { target c++11 } }
+
+template<typename>
+struct [[nodiscard]] missiles {};
+
+missiles<void> make() { return {}; }
+missiles<void> (*fnptr)() = make;
+
+int main()
+{
+ make(); // { dg-warning "ignoring returned value of type" }
+ fnptr(); // { dg-warning "ignoring returned value of type" }
+}
@@ -0,0 +1,21 @@
+// { dg-do compile { target c++11 } }
+
+inline namespace N __attribute__((__abi_tag__ ("foo"))) {}
+template <typename> struct A;
+namespace N {
+template <typename> class B;
+}
+template <typename> class C {};
+template <typename> struct D {
+ template <typename _Up> using G = C<_Up>;
+};
+template <typename T> struct F {
+ template <typename U> struct H {
+ typedef typename D<T>::template G<U> I;
+ };
+};
+template <typename T, typename = C<T>> struct J {
+ C<A<const B<char>>> L;
+ typedef F<C<int>>::H<A<const B<char>>>::I M;
+ J<M> *a;
+};
@@ -0,0 +1,21 @@
+// { dg-do compile { target c++11 } }
+
+inline namespace N __attribute__((__abi_tag__ ("foo"))) {}
+template <typename> struct A {};
+namespace N {
+template <typename> class B {};
+}
+template <typename T> class __attribute__((__aligned__ (sizeof (T)))) C {};
+template <typename> struct D {
+ template <typename _Up> using G = C<_Up>;
+};
+template <typename T> struct F {
+ template <typename U> struct H {
+ typedef typename D<T>::template G<U> I;
+ };
+};
+template <typename T, typename = C<T>> struct J {
+ C<A<const B<char>>> L;
+ typedef F<C<int>>::H<A<const B<char>>>::I M;
+ J<M> *a;
+};
@@ -0,0 +1,21 @@
+// { dg-do compile { target c++11 } }
+
+inline namespace N __attribute__((__abi_tag__ ("foo"))) {}
+template <typename> struct A {};
+namespace N {
+template <typename> class B {};
+}
+template <typename T> class __attribute__((__unused__)) C {};
+template <typename> struct D {
+ template <typename _Up> using G = C<_Up>;
+};
+template <typename T> struct F {
+ template <typename U> struct H {
+ typedef typename D<T>::template G<U> I;
+ };
+};
+template <typename T, typename = C<T>> struct J {
+ C<A<const B<char>>> L;
+ typedef F<C<int>>::H<A<const B<char>>>::I M;
+ J<M> *a;
+};