PR c++/81853 - using-directive and constexpr.
authorJason Merrill <jason@redhat.com>
Fri, 16 Feb 2018 21:02:55 +0000 (16:02 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 16 Feb 2018 21:02:55 +0000 (16:02 -0500)
* constexpr.c (cxx_eval_constant_expression): Handle USING_STMT.

From-SVN: r257762

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/ext/stmtexpr22.C [new file with mode: 0644]

index b7d45707d5e91d4a01fa321d86d7212e0327a7b0..07788c0d516325875abb8dc1fa52da3e8927faac 100644 (file)
@@ -1,5 +1,8 @@
 2018-02-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/81853 - using-directive and constexpr.
+       * constexpr.c (cxx_eval_constant_expression): Handle USING_STMT.
+
        PR c++/84420 - ICE with structured binding in lambda.
        * lambda.c (is_capture_proxy): Check DECL_DECOMPOSITION_P.
 
index d89bdd5a6a43bd903be728b0082314ab4a87deb7..91148aa8d72be69ec11141b80c990c1fbe416e94 100644 (file)
@@ -4726,6 +4726,10 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
                                        jump_target);
       break;
 
+    case USING_STMT:
+      r = void_node;
+      break;
+
     default:
       if (STATEMENT_CODE_P (TREE_CODE (t)))
        {
diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr22.C b/gcc/testsuite/g++.dg/ext/stmtexpr22.C
new file mode 100644 (file)
index 0000000..f46523a
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/81853
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+namespace N {
+  enum { i };
+}
+
+int g ()
+{
+  constexpr int j = ({ using namespace N; i; });
+  return j;
+}