===================================================================
@@ -6811,7 +6811,11 @@ cp_finish_decl (tree decl, tree init, bool init_co
}
if (!ensure_literal_type_for_constexpr_object (decl))
- DECL_DECLARED_CONSTEXPR_P (decl) = 0;
+ {
+ DECL_DECLARED_CONSTEXPR_P (decl) = 0;
+ TREE_TYPE (decl) = error_mark_node;
+ return;
+ }
if (VAR_P (decl)
&& DECL_CLASS_SCOPE_P (decl)
===================================================================
@@ -25,7 +25,7 @@ struct complex // { dg-message "no .constexpr.
};
constexpr complex co1(0, 1); // { dg-error "not literal" }
-constexpr double dd2 = co1.real(); // { dg-error "|in .constexpr. expansion of " }
+constexpr double dd2 = co1.real();
// --------------------
===================================================================
@@ -0,0 +1,13 @@
+// PR c++/81054
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ volatile int i;
+ constexpr A() : i() {}
+};
+
+struct B
+{
+ static constexpr A a {}; // { dg-error "not literal" }
+};