I wasn't properly setting LOOKUP_CONSTINIT in grokfield and so we didn't
detect a non-const initializer.
* decl2.c (grokfield): Set LOOKUP_CONSTINIT.
* g++.dg/cpp2a/constinit14.C: New test.
From-SVN: r277636
+2019-10-30 Marek Polacek <polacek@redhat.com>
+
+ PR c++/92134 - constinit malfunction in static data member.
+ * decl2.c (grokfield): Set LOOKUP_CONSTINIT.
+
2019-10-30 Jakub Jelinek <jakub@redhat.com>
* cp-tree.h (omp_declare_variant_finalize, build_local_temp): Declare.
else
flags = LOOKUP_IMPLICIT;
+ if (decl_spec_seq_has_spec_p (declspecs, ds_constinit))
+ flags |= LOOKUP_CONSTINIT;
+
switch (TREE_CODE (value))
{
case VAR_DECL:
+2019-10-30 Marek Polacek <polacek@redhat.com>
+
+ PR c++/92134 - constinit malfunction in static data member.
+ * g++.dg/cpp2a/constinit14.C: New test.
+
2019-10-30 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc.target/msp430/mlarge-use-430-insn.c: New test.
--- /dev/null
+// PR c++/92134 - constinit malfunction in static data member.
+// { dg-do compile { target c++2a } }
+
+struct Value {
+ Value() : v{new int{42}} {}
+ int* v;
+};
+
+struct S {
+ static constinit inline Value v{}; // { dg-error "variable .S::v. does not have a constant initializer|call to non-.constexpr. function" }
+};
+
+int main() { return *S::v.v; }