Hi,

On 08/29/2013 09:40 PM, Jason Merrill wrote:
On 08/29/2013 11:24 AM, Paolo Carlini wrote:
+  if ((complain & tf_error)
+      && (flags & LOOKUP_DELEGATING_CONS)
+      && name == complete_ctor_identifier
+      && TREE_CODE (ret) == CALL_EXPR
+      && (DECL_ABSTRACT_ORIGIN (TREE_OPERAND (CALL_EXPR_FN (ret), 0))
+      == current_function_decl))
+    error ("constructor delegates to itself");
How about doing this check in perform_target_ctor instead, so you don't need another LOOKUP flag?
I should have explained some of that in better detail. The main issue I had yesterday, is that the pattern matching can easily become very difficult if not impossible: if you look at the second half of expand_default_init, in some cases we wrap the returned CALL_EXPR in a COND_EXPR, also, even more difficult, in case of constexpr constructors, we don't have CALL_EXPRs at all (yesterday my first drafts failed very badly for those). Only early enough, around the end of the first build_special_member_call call we uniformly have CALL_EXPRs.

I could, for example pass down a separate bit, instead of playing again with the LOOKUP_* bits. At some point yesterday I even had that version tested ;)

What do you think?

Thanks,
Paolo.

Reply via email to