When evaluating a NOP_EXPR of a PTRMEM_CST, we should fold it into the
PTRMEM_CST rather than wrap it.

Tested x86_64-pc-linux-gnu, applying to trunk and 6.
commit fa9d4e0435f71a0a335ecc00af23b1cfe568de3c
Author: Jason Merrill <ja...@redhat.com>
Date:   Wed Nov 23 17:15:29 2016 -0500

            PR c++/77907 - static init and PMF
    
            * constexpr.c (cxx_eval_constant_expression): Use cp_fold_convert.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 40d1e7b..f93dd47 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -4226,7 +4226,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
tree t,
          {
            if (same_type_ignoring_top_level_qualifiers_p (type,
                                                           TREE_TYPE (op)))
-             STRIP_NOPS (t);
+             return cp_fold_convert (type, op);
            else
              {
                if (!ctx->quiet)
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr77907.C 
b/gcc/testsuite/g++.dg/cpp0x/pr77907.C
index d46c707..8128e8c 100644
--- a/gcc/testsuite/g++.dg/cpp0x/pr77907.C
+++ b/gcc/testsuite/g++.dg/cpp0x/pr77907.C
@@ -1,6 +1,7 @@
 // PR c++/77907
 // { dg-do run { target c++11 } }
-// { dg-options "-O2" }
+// { dg-options "-O2 -save-temps" }
+// { dg-final { scan-assembler-not "static_initialization" } }
 
 struct A {
   int foo () { return 1; }

Reply via email to