gcc-patches@gcc.gnu.org
[Top] [All Lists]

Re: C++ PATCH for constexpr

Subject: Re: C++ PATCH for constexpr
From: Jason Merrill
Date: Sun, 29 Nov 2009 10:47:38 -0500
On 11/26/2009 08:39 PM, Gabriel Dos Reis wrote:
+      if (!same_type_p (TREE_TYPE (lhs_arg), TREE_TYPE (rhs_arg)))
+        return 0;

You were going to turn this into an assert?

+      /* For member function, the first argument is a pointer to the implied
+         object.  And for an object contruction, don't bind `this' before
+         it is fully constructed.  */
+      if (i == 0 && TREE_CODE (t) == AGGR_INIT_EXPR)
+        continue;

Here you're still assuming that all AGGR_INIT_EXPR are constructor calls. Again, check DECL_CONSTRUCTOR_P (fun) instead.

+constexpr_call_equal(const void *p, const void *q)
+    cxx_eval_constant_expression(&new_call, new_call.fundef->body);
+  return VEC_index(constructor_elt, CONSTRUCTOR_ELTS (ary),

Missing space before (.

+    case CONVERT_EXPR:
+    case VIEW_CONVERT_EXPR:
+      /* -- an array-to-pointer conversion that is applied to an lvalue
+            that designates an object with thread or automatic storage
+            duration;
+         -- a type conversion from a pointer or pointer-to-member type
+            to a literal type.  */
+      {
+        tree from = TREE_OPERAND (t, 0);
+        tree source = TREE_TYPE (from);
+        tree target = TREE_TYPE (t);
+        if (TYPE_ARRAY_P (source) && TYPE_PTR_P (target)
+            && has_automatic_or_tls (from))

The array-to-pointer conversion is expressed with ADDR_EXPR; see decay_conversion.

Jason

<Prev in Thread] Current Thread [Next in Thread>