public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Gabriel Dos Reis <gdr@integrable-solutions.net>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: C++ PATCH for c++/49528 (omitting destructor for temporary with constant value)
Date: Mon, 27 Jun 2011 03:21:00 -0000	[thread overview]
Message-ID: <4E07D809.3040909@redhat.com> (raw)
In-Reply-To: <BANLkTikc6M3rRFn6wgzPsQaz42P43dmBaA@mail.gmail.com>

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

But yes, I think checking for literal type is a better idea.

Tested x86_64-pc-linux-gnu, applying to trunk.


[-- Attachment #2: 49528-2.patch --]
[-- Type: text/x-patch, Size: 1808 bytes --]

commit 81e093c1d6f2657c8c3c2abc2af559111ca82da4
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Jun 26 15:23:00 2011 -0400

    	PR c++/49528
    	* semantics.c (potential_constant_expression_1): Check
    	for non-literality rather than cleanup.
    	(cxx_eval_constant_expression): Likewise.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 5404c9f..d1af0c6 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -7020,11 +7020,10 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
       break;
 
     case TARGET_EXPR:
-      /* A cleanup isn't constant.  */
-      if (TARGET_EXPR_CLEANUP (t))
+      if (!literal_type_p (TREE_TYPE (t)))
 	{
 	  if (!allow_non_constant)
-	    error ("temporary of type %qT needing destruction in a "
+	    error ("temporary of non-literal type %qT in a "
 		   "constant expression", TREE_TYPE (t));
 	  *non_constant_p = true;
 	  break;
@@ -7851,11 +7850,10 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
 					      want_rval, flags);
 
     case TARGET_EXPR:
-      /* A cleanup isn't constant.  */
-      if (TARGET_EXPR_CLEANUP (t))
+      if (!literal_type_p (TREE_TYPE (t)))
 	{
 	  if (flags & tf_error)
-	    error ("temporary of type %qT needing destruction in a "
+	    error ("temporary of non-literal type %qT in a "
 		   "constant expression", TREE_TYPE (t));
 	  return false;
 	}
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C
index b3fb9a8..de17f3d 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-cleanup.C
@@ -6,4 +6,4 @@ struct A
   ~A();
 };
 
-constexpr int i = A().i;	// { dg-error "destruction" }
+constexpr int i = A().i;	// { dg-error "non-literal" }

  reply	other threads:[~2011-06-27  1:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-26 14:28 Jason Merrill
2011-06-26 14:47 ` Jason Merrill
2011-06-26 18:51   ` Jakub Jelinek
2011-06-26 17:10 ` Gabriel Dos Reis
2011-06-27  3:21   ` Jason Merrill [this message]
2011-06-26 17:45 Jason Merrill
2011-06-27  1:08 ` Gabriel Dos Reis

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=4E07D809.3040909@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    /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).