The invalid case in this PR trips on an assertion in
build_class_member_access_expr that build_base_path would never return
an error_mark_node, which is actually incorrect if the object involves a
tree with an error_mark_node DECL_INITIAL, like here.
This patch changes the assert to not fire if an error has been reported.
PR c++/118225
gcc/cp/ChangeLog:
* typeck.cc (build_class_member_access_expr): Let errors that
that have been reported go through.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/constexpr-ice21.C: New test.
/*nonnull=*/1, complain);
/* If we found the base successfully then we should be able
to convert to it successfully. */
- gcc_assert (object != error_mark_node);
+ gcc_assert (object != error_mark_node || seen_error ());
}
/* If MEMBER is from an anonymous aggregate, we have converted
--- /dev/null
+// PR c++/118225
+// { dg-do "compile" { target c++11} }
+
+struct NoMut1 { int a, b; };
+struct NoMut3 : virtual NoMut1 {
+ constexpr NoMut3(int a, int b) // { dg-error "virtual base" "" { target c++23 } }
+ : NoMut1{a, b}
+ {} // { dg-error "virtual base" }
+};
+void mutable_subobjects() {
+ constexpr NoMut3 nm3 = {1, 2}; // { dg-error "call to non" }
+ struct A {
+ void f() {
+ static_assert(nm3.a == 1, ""); // { dg-error "local variable" }
+ }
+ };
+}