eltinit = (perform_implicit_conversion_flags
(elttype, eltinit, complain,
LOOKUP_IMPLICIT|LOOKUP_NO_NARROWING));
- if (CLASS_TYPE_P (elttype) && new_ctx.object)
+ if (CLASS_TYPE_P (elttype)
+ && new_ctx.object
+ && !error_operand_p (eltinit))
/* Clarify what object is being initialized (118285). */
eltinit = build2 (INIT_EXPR, elttype, new_ctx.object, eltinit);
eltinit = cxx_eval_constant_expression (&new_ctx, eltinit, lval,
--- /dev/null
+// PR c++/123331
+// { dg-do compile }
+// { dg-additional-options "-O2" }
+
+struct A { virtual void foo () = 0; };
+struct B { A a[1]; }; // { dg-error "cannot declare field 'B::a' to be of abstract type 'A'" }
+// { dg-error "cannot construct an object of abstract type 'A'" "" { target *-*-* } .-1 }
+
+template <typename T>
+void
+bar (T x)
+{
+}
+
+int
+main ()
+{
+ B b;
+ bar (b);
+}