===================================================================
@@ -6860,7 +6860,8 @@ finish_static_assert (tree condition, tree message
else if (condition && condition != error_mark_node)
{
error ("non-constant condition for static assertion");
- cxx_constant_value (condition);
+ if (require_potential_rvalue_constant_expression (condition))
+ cxx_constant_value (condition);
}
input_location = saved_loc;
}
===================================================================
@@ -0,0 +1,8 @@
+// PR c++/60254
+// { dg-do compile { target c++11 } }
+
+template<typename T> bool foo(T)
+{
+ int i;
+ static_assert(foo(i), "Error"); // { dg-error "non-constant condition|not usable" }
+}
===================================================================
@@ -0,0 +1,10 @@
+// PR c++/60254
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ template<typename T> bool foo(T)
+ {
+ static_assert(foo(0), "Error"); // { dg-error "non-constant condition|constant expression" }
+ }
+};
===================================================================
@@ -1,4 +1,4 @@
// { dg-do compile { target c++11 } }
static_assert(7 / 0, "X"); // { dg-error "non-constant condition" "non-constant" }
// { dg-warning "division by zero" "zero" { target *-*-* } 2 }
-// { dg-error "7 / 0.. is not a constant expression" "not a constant" { target *-*-* } 2 }
+// { dg-error "division by zero is not a constant-expression" "not a constant" { target *-*-* } 2 }