We don't yet support constexpr evaluation of pre-generic statements,
though that's a goal; in the mean time, it's trivial to ignore
USING_STMT.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 21cab302d01fddc26b26f6ad6286f235322728e1
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri Feb 16 15:19:25 2018 -0500

            PR c++/81853 - using-directive and constexpr.
    
            * constexpr.c (cxx_eval_constant_expression): Handle USING_STMT.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index d89bdd5a6a4..91148aa8d72 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -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
index 00000000000..f46523a5875
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/stmtexpr22.C
@@ -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;
+}

Reply via email to