2019-11-02 Jakub Jelinek <jakub@redhat.com>
+ PR c++/89640
+ * parser.c (cp_parser_decl_specifier_seq): Don't parse attributes
+ if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR.
+
PR c++/88335 - Implement P1073R3: Immediate functions
* cp-tree.h (struct lang_decl_fn): Add immediate_fn_p bit.
(DECL_IMMEDIATE_FUNCTION_P, SET_DECL_IMMEDIATE_FUNCTION_P): Define.
if (!start_token)
start_token = token;
/* Handle attributes. */
- if (cp_next_tokens_can_be_attribute_p (parser))
+ if ((flags & CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR) == 0
+ && cp_next_tokens_can_be_attribute_p (parser))
{
/* Parse the attributes. */
tree attrs = cp_parser_attributes_opt (parser);
2019-11-02 Jakub Jelinek <jakub@redhat.com>
+ PR c++/89640
+ * g++.dg/cpp1z/attr-lambda1.C: New test.
+ * g++.dg/ext/attr-lambda2.C: New test.
+
* c-c++-common/gomp/declare-variant-6.c: Expect construct rather than
constructor in diagnostic messages.
* c-c++-common/gomp/declare-variant-7.c: Likewise.
--- /dev/null
+// PR c++/89640
+// { dg-options "-Wno-attributes" }
+// { dg-do compile { target c++17 } }
+
+void test() {
+ []() mutable [[gnu::cold]] constexpr {}(); // { dg-error "expected" }
+ []() constexpr [[gnu::cold]] mutable {}(); // { dg-error "expected" }
+ []() [[gnu::cold]] mutable constexpr {}(); // { dg-error "expected" }
+ []() [[gnu::cold]] constexpr mutable {}(); // { dg-error "expected" }
+ []() mutable constexpr [[gnu::cold]] {}();
+ []() constexpr mutable [[gnu::cold]] {}();
+}
--- /dev/null
+// PR c++/89640
+// { dg-options "-Wno-attributes" }
+// { dg-do compile { target c++17 } }
+
+void test() {
+ []() mutable __attribute__((cold)) constexpr {}(); // { dg-error "expected" }
+ []() constexpr __attribute__((cold)) mutable {}(); // { dg-error "expected" }
+ []() __attribute__((cold)) mutable constexpr {}(); // { dg-error "expected" }
+ []() __attribute__((cold)) constexpr mutable {}(); // { dg-error "expected" }
+ []() mutable constexpr __attribute__((cold)) {}();
+ []() constexpr mutable __attribute__((cold)) {}();
+}