get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.2/patches/807229/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 807229,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/807229/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/CADzB+2=Yyc-+ycat027rikpvdn4Vgg3bmMt=cQPkm+ZKrD81vg@mail.gmail.com/",
    "project": {
        "id": 17,
        "url": "http://patchwork.ozlabs.org/api/1.2/projects/17/?format=api",
        "name": "GNU Compiler Collection",
        "link_name": "gcc",
        "list_id": "gcc-patches.gcc.gnu.org",
        "list_email": "gcc-patches@gcc.gnu.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<CADzB+2=Yyc-+ycat027rikpvdn4Vgg3bmMt=cQPkm+ZKrD81vg@mail.gmail.com>",
    "list_archive_url": null,
    "date": "2017-08-29T18:46:23",
    "name": "C++ PATCH to add immediate version of potential_constant_expression",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "7e09d755143d9a52e80a21b1ea76c5b7b5774fbb",
    "submitter": {
        "id": 4337,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/4337/?format=api",
        "name": "Jason Merrill",
        "email": "jason@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/CADzB+2=Yyc-+ycat027rikpvdn4Vgg3bmMt=cQPkm+ZKrD81vg@mail.gmail.com/mbox/",
    "series": [
        {
            "id": 436,
            "url": "http://patchwork.ozlabs.org/api/1.2/series/436/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=436",
            "date": "2017-08-29T18:46:23",
            "name": "C++ PATCH to add immediate version of potential_constant_expression",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/436/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/807229/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/807229/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<gcc-patches-return-461108-incoming=patchwork.ozlabs.org@gcc.gnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "mailing list gcc-patches@gcc.gnu.org"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461108-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"twGIdYL5\"; dkim-atps=neutral",
            "sourceware.org; auth=none"
        ],
        "Received": [
            "from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xhd0T65y5z9sP5\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 30 Aug 2017 04:47:05 +1000 (AEST)",
            "(qmail 11671 invoked by alias); 29 Aug 2017 18:46:56 -0000",
            "(qmail 11648 invoked by uid 89); 29 Aug 2017 18:46:55 -0000",
            "from mail-io0-f170.google.com (HELO mail-io0-f170.google.com)\n\t(209.85.223.170) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tTue, 29 Aug 2017 18:46:45 +0000",
            "by mail-io0-f170.google.com with SMTP id k22so24508588iod.2 for\n\t<gcc-patches@gcc.gnu.org>; Tue, 29 Aug 2017 11:46:45 -0700 (PDT)",
            "by 10.107.181.23 with HTTP; Tue, 29 Aug 2017 11:46:23 -0700 (PDT)"
        ],
        "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:from:date:message-id:subject:to:content-type; q=\n\tdns; s=default; b=EGnZ1ZEaACZ57IdP9tyhS3wCaaCdcqLD2oa6evNNH68Uk0\n\tewdBqRpt49xD/x4SQkg7news+nzv2J41zwXai7v+Qq4gQSAyuXoUpCvv5BusNBid\n\twUv3rT8FxRm1xYL+jhdni4IZqdzsnSdNWGBzF+OrUayuPQno7iBAu8m1EB/T8=",
        "DKIM-Signature": "v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:from:date:message-id:subject:to:content-type; s=\n\tdefault; bh=RmQxLTxJr1XvxBHDTiNH1u+T7NY=; b=twGIdYL5mlrwfIi9boLH\n\tY9sjn9ZxoJnVeCgR0+CygJC83bFMfOJ79N6KdrU0RW9YspQyvW8oz44iQmt+F/I4\n\tvUlzo8AohiVpLlqk3ugnW1GCPDj0ADs9SfWSVYdPJYpQ4QqhIBSB7X77J3Go7cxe\n\tl5ZIwFd5FhohaCODyhVlOUQ=",
        "Mailing-List": "contact gcc-patches-help@gcc.gnu.org; run by ezmlm",
        "Precedence": "bulk",
        "List-Id": "<gcc-patches.gcc.gnu.org>",
        "List-Unsubscribe": "<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>",
        "List-Archive": "<http://gcc.gnu.org/ml/gcc-patches/>",
        "List-Post": "<mailto:gcc-patches@gcc.gnu.org>",
        "List-Help": "<mailto:gcc-patches-help@gcc.gnu.org>",
        "Sender": "gcc-patches-owner@gcc.gnu.org",
        "X-Virus-Found": "No",
        "X-Spam-SWARE-Status": "No, score=-24.1 required=5.0 tests=AWL, BAYES_00,\n\tGIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy=qualifies",
        "X-HELO": "mail-io0-f170.google.com",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:mime-version:from:date:message-id:subject:to;\n\tbh=8em1DVvWthLrobogmojKJEO3QIsmhAzkKNzeUeRGUdY=;\n\tb=KbEHG2XzTz1hSpAvLz5yIGR+BcCX7vVzS4wVJaUtYzJe89lZq774poyW01GDRewpf9\n\tQpTLyzTrZJFIYQSj61Cem2BhiwOSucOgpCleBDgi/d0ELqD2SU2TpAJQBP1RLljHCT7O\n\trFQoaD8jYA8DZRHalAweHm/W2xTA2qAG3WeBVcE7gk73Ea0COZqhdqAt2TZE2IG9MRtk\n\tZl3tcRFViYkueEy3Q3EW+KR0o4kZb8FQLi81+fAORjidCeUkNasCwQdZA2fKfxBQ6nea\n\tR9BzozzQkpUIy9ezrXKWkDFU3isRgThtAylavEbUR2WUKy/HAhEiKfXQLJeMnfFW7e1d\n\tpUkA==",
        "X-Gm-Message-State": "AHYfb5iGpQitjUi7Y+cjpISTBrHyZbslNKZoydvHsOHXLWcYs/eX1Bk8\t0JijKhNu0Mt4feRnUgfPlmjH7PjJMENGnTc=",
        "X-Received": "by 10.107.53.150 with SMTP id k22mr4824444ioo.285.1504032403653;\n\tTue, 29 Aug 2017 11:46:43 -0700 (PDT)",
        "MIME-Version": "1.0",
        "From": "Jason Merrill <jason@redhat.com>",
        "Date": "Tue, 29 Aug 2017 14:46:23 -0400",
        "Message-ID": "<CADzB+2=Yyc-+ycat027rikpvdn4Vgg3bmMt=cQPkm+ZKrD81vg@mail.gmail.com>",
        "Subject": "C++ PATCH to add immediate version of potential_constant_expression",
        "To": "gcc-patches List <gcc-patches@gcc.gnu.org>",
        "Content-Type": "multipart/mixed; boundary=\"001a1144947e26c26a0557e8d5a0\"",
        "X-IsSubscribed": "yes"
    },
    "content": "potential_constant_expression returns whether or not an expression\ncould be a constant expression after constexpr substitution of\nparameters, but some of the places that we have been using this\npredicate aren't subject to constexpr substitution, so it would be\ngood to have a version that doesn't consider parameters potentially\nconstant.\n\nThis patch adds such a variant, and calls it is_constant_expression.\nThat isn't quite accurate, since actual evaluation might fail to\nproduce a constant value, in which case the expression isn't actually\na constant expression, but I haven't come up with a better name.\n\nTested x86_64-pc-linux-gnu, applying to trunk.\ncommit e8401fb168ffdbc03123fd449807c821e0ee4331\nAuthor: Jason Merrill <jason@redhat.com>\nDate:   Fri Jul 7 18:23:27 2017 -0400\n\n            Add immediate potential_constant_expression variants.\n    \n            * constexpr.c (potential_constant_expression_1): Add \"now\" parm.\n            (is_constant_expression, require_constant_expression): New.\n            (is_static_init_expression, is_nondependent_constant_expression)\n            (is_nondependent_static_init_expression): Drop \"potential\".\n            * except.c (build_must_not_throw_expr): Do type conversion on\n            value-dependent argument.\n            * pt.c, semantics.c, typeck2.c: Use variants without \"potential\".",
    "diff": "diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c\nindex 29ba2c3..8cfc5a4 100644\n--- a/gcc/cp/constexpr.c\n+++ b/gcc/cp/constexpr.c\n@@ -1181,7 +1181,7 @@ cxx_eval_builtin_function_call (const constexpr_ctx *ctx, tree t, tree fun,\n       return t;\n     }\n \n-  if (!potential_constant_expression (new_call))\n+  if (!is_constant_expression (new_call))\n     {\n       if (!*non_constant_p && !ctx->quiet)\n \terror (\"%q+E is not a constant expression\", new_call);\n@@ -4861,7 +4861,7 @@ maybe_constant_value (tree t, tree decl)\n {\n   tree r;\n \n-  if (!potential_nondependent_constant_expression (t))\n+  if (!is_nondependent_constant_expression (t))\n     {\n       if (TREE_OVERFLOW_P (t))\n \t{\n@@ -4929,7 +4929,7 @@ fold_non_dependent_expr (tree t)\n      as two declarations of the same function, for example.  */\n   if (processing_template_decl)\n     {\n-      if (potential_nondependent_constant_expression (t))\n+      if (is_nondependent_constant_expression (t))\n \t{\n \t  processing_template_decl_sentinel s;\n \t  t = instantiate_non_dependent_expr_internal (t, tf_none);\n@@ -4982,7 +4982,7 @@ maybe_constant_init (tree t, tree decl)\n     t = TREE_OPERAND (t, 1);\n   if (TREE_CODE (t) == TARGET_EXPR)\n     t = TARGET_EXPR_INITIAL (t);\n-  if (!potential_nondependent_static_init_expression (t))\n+  if (!is_nondependent_static_init_expression (t))\n     /* Don't try to evaluate it.  */;\n   else if (CONSTANT_CLASS_P (t))\n     /* No evaluation needed.  */;\n@@ -5025,7 +5025,9 @@ check_automatic_or_tls (tree ref)\n \n /* Return true if T denotes a potentially constant expression.  Issue\n    diagnostic as appropriate under control of FLAGS.  If WANT_RVAL is true,\n-   an lvalue-rvalue conversion is implied.\n+   an lvalue-rvalue conversion is implied.  If NOW is true, we want to\n+   consider the expression in the current context, independent of constexpr\n+   substitution.\n \n    C++0x [expr.const] used to say\n \n@@ -5041,10 +5043,12 @@ check_automatic_or_tls (tree ref)\n       not evaluated are not considered.   */\n \n static bool\n-potential_constant_expression_1 (tree t, bool want_rval, bool strict,\n+potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,\n \t\t\t\t tsubst_flags_t flags)\n {\n-#define RECUR(T,RV) potential_constant_expression_1 ((T), (RV), strict, flags)\n+#define RECUR(T,RV) \\\n+  potential_constant_expression_1 ((T), (RV), strict, now, flags)\n+\n   enum { any = false, rval = true };\n   int i;\n   tree tmp;\n@@ -5087,7 +5091,6 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,\n     case USERDEF_LITERAL:\n       /* We can see a FIELD_DECL in a pointer-to-member expression.  */\n     case FIELD_DECL:\n-    case PARM_DECL:\n     case RESULT_DECL:\n     case USING_DECL:\n     case USING_STMT:\n@@ -5098,6 +5101,15 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,\n     case STATIC_ASSERT:\n       return true;\n \n+    case PARM_DECL:\n+      if (now)\n+\t{\n+\t  if (flags & tf_error)\n+\t    error (\"%qE is not a constant expression\", t);\n+\t  return false;\n+\t}\n+      return true;\n+\n     case AGGR_INIT_EXPR:\n     case CALL_EXPR:\n       /* -- an invocation of a function other than a constexpr function\n@@ -5173,7 +5185,11 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,\n \t\t    tree x = get_nth_callarg (t, 0);\n \t\t    if (is_this_parameter (x))\n \t\t      return true;\n-\t\t    else if (!RECUR (x, rval))\n+\t\t    /* Don't require an immediately constant value, as\n+\t\t       constexpr substitution might not use the value.  */\n+\t\t    bool sub_now = false;\n+\t\t    if (!potential_constant_expression_1 (x, rval, strict,\n+\t\t\t\t\t\t\t  sub_now, flags))\n \t\t      return false;\n \t\t    i = 1;\n \t\t  }\n@@ -5203,7 +5219,11 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,\n \t       REFERENCE_TYPE and we might not even know if the parameter\n \t       is a reference, so accept lvalue constants too.  */\n \t    bool rv = processing_template_decl ? any : rval;\n-\t    if (!RECUR (x, rv))\n+\t    /* Don't require an immediately constant value, as constexpr\n+\t       substitution might not use the value of the argument.  */\n+\t    bool sub_now = false;\n+\t    if (!potential_constant_expression_1 (x, rv, strict,\n+\t\t\t\t\t\t  sub_now, flags))\n \t      return false;\n           }\n         return true;\n@@ -5759,7 +5779,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,\n \treturn RECUR (TREE_OPERAND (t, 1), want_rval);\n       for (i = 1; i < 3; ++i)\n \tif (potential_constant_expression_1 (TREE_OPERAND (t, i),\n-\t\t\t\t\t     want_rval, strict, tf_none))\n+\t\t\t\t\t     want_rval, strict, now, tf_none))\n \t  return true;\n       if (flags & tf_error)\n \terror_at (loc, \"expression %qE is not a constant expression\", t);\n@@ -5816,13 +5836,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,\n bool\n potential_constant_expression (tree t)\n {\n-  return potential_constant_expression_1 (t, false, true, tf_none);\n-}\n-\n-bool\n-potential_static_init_expression (tree t)\n-{\n-  return potential_constant_expression_1 (t, false, false, tf_none);\n+  return potential_constant_expression_1 (t, false, true, false, tf_none);\n }\n \n /* As above, but require a constant rvalue.  */\n@@ -5830,7 +5844,7 @@ potential_static_init_expression (tree t)\n bool\n potential_rvalue_constant_expression (tree t)\n {\n-  return potential_constant_expression_1 (t, true, true, tf_none);\n+  return potential_constant_expression_1 (t, true, true, false, tf_none);\n }\n \n /* Like above, but complain about non-constant expressions.  */\n@@ -5838,7 +5852,7 @@ potential_rvalue_constant_expression (tree t)\n bool\n require_potential_constant_expression (tree t)\n {\n-  return potential_constant_expression_1 (t, false, true, tf_warning_or_error);\n+  return potential_constant_expression_1 (t, false, true, false, tf_warning_or_error);\n }\n \n /* Cross product of the above.  */\n@@ -5846,7 +5860,38 @@ require_potential_constant_expression (tree t)\n bool\n require_potential_rvalue_constant_expression (tree t)\n {\n-  return potential_constant_expression_1 (t, true, true, tf_warning_or_error);\n+  return potential_constant_expression_1 (t, true, true, false, tf_warning_or_error);\n+}\n+\n+/* Like potential_constant_expression, but don't consider possible constexpr\n+   substitution of the current function.  That is, PARM_DECL qualifies under\n+   potential_constant_expression, but not here.\n+\n+   This is basically what you can check when any actual constant values might\n+   be value-dependent.  */\n+\n+bool\n+is_constant_expression (tree t)\n+{\n+  return potential_constant_expression_1 (t, false, true, true, tf_none);\n+}\n+\n+/* Like above, but complain about non-constant expressions.  */\n+\n+bool\n+require_constant_expression (tree t)\n+{\n+  return potential_constant_expression_1 (t, false, true, true,\n+\t\t\t\t\t  tf_warning_or_error);\n+}\n+\n+/* Like is_constant_expression, but allow const variables that are not allowed\n+   under constexpr rules.  */\n+\n+bool\n+is_static_init_expression (tree t)\n+{\n+  return potential_constant_expression_1 (t, false, false, true, tf_none);\n }\n \n /* Returns true if T is a potential constant expression that is not\n@@ -5854,11 +5899,11 @@ require_potential_rvalue_constant_expression (tree t)\n    in a template.  */\n \n bool\n-potential_nondependent_constant_expression (tree t)\n+is_nondependent_constant_expression (tree t)\n {\n   return (!type_unknown_p (t)\n \t  && !BRACE_ENCLOSED_INITIALIZER_P (t)\n-\t  && potential_constant_expression (t)\n+\t  && is_constant_expression (t)\n \t  && !instantiation_dependent_expression_p (t));\n }\n \n@@ -5866,11 +5911,11 @@ potential_nondependent_constant_expression (tree t)\n    instantiation-dependent.  */\n \n bool\n-potential_nondependent_static_init_expression (tree t)\n+is_nondependent_static_init_expression (tree t)\n {\n   return (!type_unknown_p (t)\n \t  && !BRACE_ENCLOSED_INITIALIZER_P (t)\n-\t  && potential_static_init_expression (t)\n+\t  && is_static_init_expression (t)\n \t  && !instantiation_dependent_expression_p (t));\n }\n \ndiff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h\nindex 7d601ab..f2e54a8 100644\n--- a/gcc/cp/cp-tree.h\n+++ b/gcc/cp/cp-tree.h\n@@ -7325,11 +7325,13 @@ extern bool is_valid_constexpr_fn\t\t(tree, bool);\n extern bool check_constexpr_ctor_body           (tree, tree, bool);\n extern tree ensure_literal_type_for_constexpr_object (tree);\n extern bool potential_constant_expression       (tree);\n-extern bool potential_nondependent_constant_expression (tree);\n-extern bool potential_nondependent_static_init_expression (tree);\n-extern bool potential_static_init_expression    (tree);\n+extern bool is_constant_expression (tree);\n+extern bool is_nondependent_constant_expression (tree);\n+extern bool is_nondependent_static_init_expression (tree);\n+extern bool is_static_init_expression    (tree);\n extern bool potential_rvalue_constant_expression (tree);\n extern bool require_potential_constant_expression (tree);\n+extern bool require_constant_expression (tree);\n extern bool require_potential_rvalue_constant_expression (tree);\n extern tree cxx_constant_value\t\t\t(tree, tree = NULL_TREE);\n extern tree maybe_constant_value\t\t(tree, tree = NULL_TREE);\ndiff --git a/gcc/cp/except.c b/gcc/cp/except.c\nindex b25b91b..2ee7e97 100644\n--- a/gcc/cp/except.c\n+++ b/gcc/cp/except.c\n@@ -261,13 +261,19 @@ build_must_not_throw_expr (tree body, tree cond)\n   if (!flag_exceptions)\n     return body;\n \n-  if (cond && !value_dependent_expression_p (cond))\n+  if (!cond)\n+    /* OK, unconditional.  */;\n+  else\n     {\n-      cond = perform_implicit_conversion_flags (boolean_type_node, cond,\n-\t\t\t\t\t\ttf_warning_or_error,\n-\t\t\t\t\t\tLOOKUP_NORMAL);\n-      cond = instantiate_non_dependent_expr (cond);\n-      cond = cxx_constant_value (cond);\n+      tree conv = NULL_TREE;\n+      if (!type_dependent_expression_p (cond))\n+\tconv = perform_implicit_conversion_flags (boolean_type_node, cond,\n+\t\t\t\t\t\t  tf_warning_or_error,\n+\t\t\t\t\t\t  LOOKUP_NORMAL);\n+      if (tree inst = instantiate_non_dependent_or_null (conv))\n+\tcond = cxx_constant_value (inst);\n+      else\n+\trequire_constant_expression (cond);\n       if (integer_zerop (cond))\n \treturn body;\n       else if (integer_onep (cond))\ndiff --git a/gcc/cp/pt.c b/gcc/cp/pt.c\nindex 6b62ee0..d5d6dd0 100644\n--- a/gcc/cp/pt.c\n+++ b/gcc/cp/pt.c\n@@ -5827,7 +5827,7 @@ instantiate_non_dependent_expr_sfinae (tree expr, tsubst_flags_t complain)\n \n      as two declarations of the same function, for example.  */\n   if (processing_template_decl\n-      && potential_nondependent_constant_expression (expr))\n+      && is_nondependent_constant_expression (expr))\n     {\n       processing_template_decl_sentinel s;\n       expr = instantiate_non_dependent_expr_internal (expr, complain);\n@@ -5851,7 +5851,7 @@ instantiate_non_dependent_or_null (tree expr)\n     return NULL_TREE;\n   if (processing_template_decl)\n     {\n-      if (!potential_nondependent_constant_expression (expr))\n+      if (!is_nondependent_constant_expression (expr))\n \texpr = NULL_TREE;\n       else\n \t{\n@@ -6437,15 +6437,11 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)\n       && has_value_dependent_address (expr))\n     /* If we want the address and it's value-dependent, don't fold.  */;\n   else if (processing_template_decl\n-\t   && potential_nondependent_constant_expression (expr))\n+\t   && is_nondependent_constant_expression (expr))\n     non_dep = true;\n   if (error_operand_p (expr))\n     return error_mark_node;\n   expr_type = TREE_TYPE (expr);\n-  if (TREE_CODE (type) == REFERENCE_TYPE)\n-    expr = mark_lvalue_use (expr);\n-  else\n-    expr = mark_rvalue_use (expr);\n \n   /* If the argument is non-dependent, perform any conversions in\n      non-dependent context as well.  */\n@@ -6493,6 +6489,11 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)\n \t}\n     }\n \n+  if (TREE_CODE (type) == REFERENCE_TYPE)\n+    expr = mark_lvalue_use (expr);\n+  else\n+    expr = mark_rvalue_use (expr);\n+\n   /* HACK: Due to double coercion, we can get a\n      NOP_EXPR<REFERENCE_TYPE>(ADDR_EXPR<POINTER_TYPE> (arg)) here,\n      which is the tree that we built on the first call (see\ndiff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c\nindex 14e680f..86ce9ce 100644\n--- a/gcc/cp/semantics.c\n+++ b/gcc/cp/semantics.c\n@@ -735,7 +735,7 @@ finish_if_stmt_cond (tree cond, tree if_stmt)\n {\n   cond = maybe_convert_cond (cond);\n   if (IF_STMT_CONSTEXPR_P (if_stmt)\n-      && require_potential_rvalue_constant_expression (cond)\n+      && is_constant_expression (cond)\n       && !value_dependent_expression_p (cond))\n     {\n       cond = instantiate_non_dependent_expr (cond);\ndiff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c\nindex 06c079e..e9aca39 100644\n--- a/gcc/cp/typeck2.c\n+++ b/gcc/cp/typeck2.c\n@@ -821,7 +821,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)\n \t  || (DECL_IN_AGGR_P (decl) && !DECL_VAR_DECLARED_INLINE_P (decl)))\n \t{\n \t  /* Diagnose a non-constant initializer for constexpr.  */\n-\t  if (!require_potential_constant_expression (value))\n+\t  if (!require_constant_expression (value))\n \t    value = error_mark_node;\n \t  else\n \t    value = cxx_constant_value (value, decl);\ndiff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-conv2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-conv2.C\nnew file mode 100644\nindex 0000000..c64fb3d\n--- /dev/null\n+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-conv2.C\n@@ -0,0 +1,15 @@\n+// { dg-do compile { target c++11 } }\n+\n+template <int I> void f();\n+\n+struct A { constexpr operator int() { return 24; } };\n+\n+template <class T> constexpr void g(T t)\n+{\n+  f<t>();\n+}\n+\n+int main()\n+{\n+  g(A());\n+}\n",
    "prefixes": []
}