Commit d54faccc by Marek Polacek Committed by Marek Polacek

PR c++/92134 - constinit malfunction in static data member.

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
parent ce001b30
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.
......
......@@ -990,6 +990,9 @@ grokfield (const cp_declarator *declarator,
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.
......
// 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; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment