java/4775

Bryce McKinlay bryce@waitaki.otago.ac.nz
Mon Nov 26 19:23:00 GMT 2001


Alexandre Petit-Bianco wrote:

>>I'm curious why the second part of this patch is neccessary
>>
>
>Last time I checked (some time ago, I'd have to re-check,) proper
>finals initialization is carried out by checking that at least a ctor
>in the chain of call will initialize a final properly. So it's faster
>and prevents things from breaking when regular non static methods are
>being found invoked in ctor bodies...
>

But regular method calls can just be ignored, right? They are not 
allowed to initialize finals anyway. I don't see why TREE_CODE (decl) != 
FUNCTION_DECL needs to be an error condition.

Also it seems fragile to check explicitly the tree structure of the call 
(eg the NOP_EXPR etc), because that could change, so why not just do this?

@@ -12670,8 +12665,10 @@
        if (TREE_CODE (decl) != FUNCTION_DECL)
          decl = TREE_OPERAND (TREE_OPERAND (decl, 0), 0);
-       if (TREE_CODE (decl) != FUNCTION_DECL)
-         abort ();
+       /* Skip something that isn't a call to a ctor */
+       if ((TREE_CODE (decl) == FUNCTION_DECL && !DECL_CONSTRUCTOR_P 
(decl))
+           || TREE_CODE (decl) != FUNCTION_DECL)
+         return -1;
        if (DECL_FUNCTION_ALL_FINAL_INITIALIZED (decl))
          return 1;
        if (DECL_FINIT_P (decl) || DECL_CONTEXT (decl) != current_class)


regards

Bryce.




More information about the Gcc-bugs mailing list