public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/81853, constexpr and using-directive
@ 2018-02-16 21:01 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2018-02-16 21:01 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 192 bytes --]

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.

[-- Attachment #2: 81853.diff --]
[-- Type: text/plain, Size: 1069 bytes --]

commit 21cab302d01fddc26b26f6ad6286f235322728e1
Author: Jason Merrill <jason@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;
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-16 21:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-16 21:01 C++ PATCH for c++/81853, constexpr and using-directive Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).