From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/49520 (bogus error with using in constexpr)
Date: Wed, 29 Jun 2011 17:36:00 -0000 [thread overview]
Message-ID: <4E0B5E63.5010205@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 132 bytes --]
A CLEANUP_POINT_EXPR wraps each statement, so we need to strip it at a
lower level.
Tested x86_64-pc-linux-gnu, applied to trunk.
[-- Attachment #2: 49520.patch --]
[-- Type: text/x-patch, Size: 2153 bytes --]
commit 505b4baa3619375d81b409f9ff2bde95cce0f50a
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jun 29 12:43:19 2011 -0400
PR c++/49520
* semantics.c (constexpr_fn_retval): Handle CLEANUP_POINT_EXPR here.
(massage_constexpr_body): Not here.
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 12c01cb..bb1b753 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -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
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index fb984d4..ad68a01 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-using2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-using2.C
new file mode 100644
index 0000000..6b28281
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-using2.C
@@ -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>;
reply other threads:[~2011-06-29 17:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E0B5E63.5010205@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).