Mentioning a noreturn function does not involve an lvalue-rvalue
conversion.
gcc/cp/ChangeLog:
* constexpr.cc (potential_constant_expression_1): Fix
check for loading volatile lvalue.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/constexpr-noreturn1.C: New test.
available, so we don't bother with switch tracking. */
return true;
- if (TREE_THIS_VOLATILE (t) && want_rval)
+ if (TREE_THIS_VOLATILE (t) && want_rval
+ && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (t)))
{
if (flags & tf_error)
constexpr_error (loc, fundef_p, "lvalue-to-rvalue conversion of "
--- /dev/null
+// { dg-do compile { target c++11 } }
+// { dg-additional-options -Winvalid-constexpr }
+
+// We were giving a wrong error about loading a volatile value instead of the
+// proper error about calling a non-constexpr function.
+
+[[noreturn]] void f();
+
+constexpr int g()
+{
+ return f(), 42; // { dg-message "call to non-'constexpr' function" }
+}