re PR c++/49520 ([C++0x] using-declaration and operator&& confuses constexpr)
authorJason Merrill <jason@redhat.com>
Wed, 29 Jun 2011 17:15:16 +0000 (13:15 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 29 Jun 2011 17:15:16 +0000 (13:15 -0400)
PR c++/49520
* semantics.c (constexpr_fn_retval): Handle CLEANUP_POINT_EXPR here.
(massage_constexpr_body): Not here.

From-SVN: r175658

gcc/cp/ChangeLog
gcc/cp/cp-tree.def
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-using2.C [new file with mode: 0644]

index 083d5459662559e91a01e9ce9d3f53200d61f8c2..858ad8414d57ea3d0517f5ebb993f77e98c50422 100644 (file)
@@ -1,5 +1,9 @@
 2011-06-29  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49520
+       * semantics.c (constexpr_fn_retval): Handle CLEANUP_POINT_EXPR here.
+       (massage_constexpr_body): Not here.
+
        PR c++/49554
        * semantics.c (lambda_proxy_type): New.
        (build_capture_proxy): Use it.
index 12c01cb15f5069054bad65bdfc49b7763fa27046..bb1b753c71bdb69c943278a72382624a935d6652 100644 (file)
@@ -207,7 +207,7 @@ DEFTREECODE (UNBOUND_CLASS_TEMPLATE, "unbound_class_template", tcc_type, 0)
 DEFTREECODE (USING_DECL, "using_decl", tcc_declaration, 0)
 
 /* A using directive. The operand is USING_STMT_NAMESPACE.  */
-DEFTREECODE (USING_STMT, "using_directive", tcc_statement, 1)
+DEFTREECODE (USING_STMT, "using_stmt", tcc_statement, 1)
 
 /* An un-parsed default argument.  Holds a vector of input tokens and
    a vector of places where the argument was instantiated before
index fb984d4799a5dbe4e224e657b626e541d5657a73..ad68a012d17bede5e4d1ee773352ac0c9b077ae3 100644 (file)
@@ -5657,6 +5657,9 @@ constexpr_fn_retval (tree body)
        return NULL_TREE;
       return error_mark_node;
 
+    case CLEANUP_POINT_EXPR:
+      return constexpr_fn_retval (TREE_OPERAND (body, 0));
+
     case USING_STMT:
       return NULL_TREE;
 
@@ -5683,8 +5686,6 @@ massage_constexpr_body (tree fun, tree body)
         body = EH_SPEC_STMTS (body);
       if (TREE_CODE (body) == MUST_NOT_THROW_EXPR)
        body = TREE_OPERAND (body, 0);
-      if (TREE_CODE (body) == CLEANUP_POINT_EXPR)
-        body = TREE_OPERAND (body, 0);
       body = constexpr_fn_retval (body);
     }
   return body;
index 522c41cac6bdb03e37e59a5118b94151d9dd3749..d817d854cfb275d7b6320c719f2398a2b418aec1 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-29  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49520
+       * g++.dg/cpp0x/constexpr-using2.C: New.
+
        * g++.dg/cpp0x/lambda/lambda-template3.C: New.
 
        PR c++/45923
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-using2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-using2.C
new file mode 100644 (file)
index 0000000..6b28281
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/49520
+// { dg-options -std=c++0x }
+
+namespace x { void foo(); }
+
+template<typename T>
+struct traits
+{
+    static constexpr bool f() { return true; }
+
+    static constexpr bool g()
+    {
+        using x::foo;
+        return f() && noexcept(foo());
+    }
+};
+
+template struct traits<int>;