static tree
cp_parser_attributes_opt (cp_parser *parser)
{
- if (cp_next_tokens_can_be_gnu_attribute_p (parser))
- return cp_parser_gnu_attributes_opt (parser);
- return cp_parser_std_attribute_spec_seq (parser);
+ tree attrs = NULL_TREE;
+ while (true)
+ {
+ if (cp_next_tokens_can_be_gnu_attribute_p (parser))
+ attrs = attr_chainon (attrs, cp_parser_gnu_attributes_opt (parser));
+ else if (cp_next_tokens_can_be_std_attribute_p (parser))
+ attrs = attr_chainon (attrs, cp_parser_std_attribute_spec_seq (parser));
+ else
+ break;
+ }
+ return attrs;
}
/* Parse an (optional) series of attributes.
--- /dev/null
+// PR c++/102399
+// { dg-do compile { target c++11 } }
+// Test mixing the GNU and standard forms of attributes.
+
+#define EXPORT __attribute__((visibility("default")))
+
+struct [[nodiscard]] EXPORT Foo { Foo(); };
--- /dev/null
+// PR c++/69585
+// { dg-do compile { target c++11 } }
+
+struct __attribute__ ((aligned (2))) __attribute__ ((may_alias))
+S1 { };
+
+struct __attribute__ ((aligned (2))) [[gnu::may_alias]]
+S2 { };
+
+struct alignas (2) __attribute__ ((may_alias))
+S3 { };
+
+struct alignas (2) [[gnu::may_alias]]
+S4 { };
+
+
+struct __attribute__ ((may_alias)) __attribute__ ((aligned (2)))
+S1_2 { };
+
+struct [[gnu::may_alias]] __attribute__ ((aligned (2)))
+S2_2 { };
+
+struct __attribute__ ((may_alias)) alignas (2)
+S3_2 { };
+
+struct [[gnu::may_alias]] alignas (2)
+S4_2 { };
--- /dev/null
+// PR c++/69585
+// { dg-do compile { target c++11 } }
+// Test mixing the GNU and standard forms of attributes.
+
+__attribute__((deprecated)) [[maybe_unused]] void f1 ();
+[[maybe_unused]] __attribute__((deprecated)) void f2 ();
+[[maybe_unused]] __attribute__((deprecated)) [[nodiscard]] int f3 ();
+__attribute__((unused)) [[nodiscard]] __attribute__((deprecated)) int f4 ();
+
+struct [[maybe_unused]] __attribute__((aligned)) S1 { double d; };
+struct __attribute__((aligned)) [[maybe_unused]] S2 { double d; };
+
+enum E {
+ X [[maybe_unused]] __attribute__((unavailable)),
+ Y __attribute__((unavailable)) [[maybe_unused]],
+};
+
+void
+g ([[maybe_unused]] __attribute__((unavailable)) int i1,
+ __attribute__((unavailable)) [[maybe_unused]] int i2)
+{
+ [[maybe_unused]] __attribute__((aligned)) int i3;
+ __attribute__((aligned)) [[maybe_unused]] int i4;
+
+[[maybe_unused]]
+lab: __attribute__((cold));
+}