Patchwork C++ PATCH: two minor constexpr-related fixes

login
register
mail settings
Submitter Jason Merrill
Date July 21, 2010, 2:37 p.m.
Message ID <4C470635.106@redhat.com>
Download mbox | patch
Permalink /patch/59446/
State New
Headers show

Comments

Jason Merrill - July 21, 2010, 2:37 p.m.
The first patch: The flags we pass here are eventually passed to 
convert_for_initialization, and we want LOOKUP_COMPLAIN so we get 
errors.  This may only have an effect on the constexpr branch, where we 
use digest_init for literal types, but is correct in any case.

The second patch: the code for comparing CONSTRUCTOR was long obsolete, 
as CONSTRUCTORs aren't expressions anymore.

Tested x86_64-pc-linux-gnu, applied to trunk.
Gabriel Dos Reis - July 21, 2010, 4:43 p.m.
On Wed, Jul 21, 2010 at 9:37 AM, Jason Merrill <jason@redhat.com> wrote:
> The first patch: The flags we pass here are eventually passed to
> convert_for_initialization, and we want LOOKUP_COMPLAIN so we get errors.
>  This may only have an effect on the constexpr branch, where we use
> digest_init for literal types, but is correct in any case.

OK

>
> The second patch: the code for comparing CONSTRUCTOR was long obsolete, as
> CONSTRUCTORs aren't expressions anymore.

Thanks for the correction.

-- Gaby

Patch

commit 7522c1e7833bf341fab09c10ff968288f8c34954
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jul 20 14:39:31 2010 -0400

    	* parser.c (cp_parser_init_declarator): Pass LOOKUP_NORMAL
    	to cp_finish_decl.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 19a158f..3fd96fb 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14089,7 +14089,7 @@  cp_parser_init_declarator (cp_parser* parser,
 			 `explicit' constructor is OK.  Otherwise, an
 			 `explicit' constructor cannot be used.  */
 		      ((is_direct_init || !is_initialized)
-		       ? 0 : LOOKUP_ONLYCONVERTING));
+		       ? LOOKUP_NORMAL : LOOKUP_IMPLICIT));
     }
   else if ((cxx_dialect != cxx98) && friend_p
 	   && decl && TREE_CODE (decl) == FUNCTION_DECL)

commit ea0c3d391045ce10b89c2360cca97aed5c225e81
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jul 21 09:23:35 2010 -0400

    	* tree.c (cp_tree_equal): Fix CONSTRUCTOR handling.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 2abd8dd..450b9e8 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2023,11 +2023,21 @@  cp_tree_equal (tree t1, tree t2)
       /* We need to do this when determining whether or not two
 	 non-type pointer to member function template arguments
 	 are the same.  */
-      if (!(same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))
-	    /* The first operand is RTL.  */
-	    && TREE_OPERAND (t1, 0) == TREE_OPERAND (t2, 0)))
+      if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))
+	  || CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2))
 	return false;
-      return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
+      {
+	tree field, value;
+	unsigned int i;
+	FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t1), i, field, value)
+	  {
+	    constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i);
+	    if (!cp_tree_equal (field, elt2->index)
+		|| !cp_tree_equal (value, elt2->value))
+	      return false;
+	  }
+      }
+      return true;
 
     case TREE_LIST:
       if (!cp_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))