[PATCH] [Annotalysis] Fix internal compiler error on template methods

Diego Novillo dnovillo@google.com
Thu Sep 29 21:45:00 GMT 2011


On 11-09-29 15:19 , Delesley Hutchins wrote:

> However, I'm not convinced that it will work in all cases.  I wish I
> could come up with a test case, but like I said, I don't understand
> enough about clones to understand what's happening here.  If you are
> confident that DECL_CLONED_FUNCTION_P is correct, then we can use
> that; I personally had no such confidence.

Yes, there is no case in which a TEMPLATE_DECL will match 
DECL_CLONED_FUNCTION_P.  I agree with you that the logic in 
decl_cloned_function_p seems like it may allow that, but clones of 
functions are created as FUNCTION_DECLs.

In looking at the code again, I think we could even simplify it a bit 
more using FOR_EACH_CLONE.  This does the same work as the if()/for() 
combination in a more compact way.


Diego.

Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 179065)
+++ cp/parser.c (working copy)
@@ -19279,6 +19279,7 @@ cp_parser_late_parsing_attribute_arg_lis
        cp_token_cache *tokens = (cp_token_cache *) TREE_VALUE 
(artificial_node);
        tree ctype;
        VEC(tree,gc) *vec;
+      tree clone;

        gcc_assert (tokens);
        gcc_assert (decl && decl != error_mark_node);
@@ -19322,16 +19323,9 @@ cp_parser_late_parsing_attribute_arg_lis

        /* If decl has clones (when it is a ctor or a dtor), we need to
           modify the clones' attributes as well.  */
-      if (TREE_CODE (decl) == FUNCTION_DECL
-          && (DECL_CONSTRUCTOR_P (decl) || DECL_DESTRUCTOR_P (decl)))
-        {
-          tree clone;
-          for (clone = TREE_CHAIN (decl); clone; clone = TREE_CHAIN 
(clone))
-            {
-              if (DECL_CLONED_FUNCTION (clone) == decl)
-                DECL_ATTRIBUTES (clone) = DECL_ATTRIBUTES (decl);
-            }
-        }
+      FOR_EACH_CLONE (clone, decl)
+        if (DECL_CLONED_FUNCTION (clone) == decl)
+          DECL_ATTRIBUTES (clone) = DECL_ATTRIBUTES (decl);

        pop_nested_class ();



More information about the Gcc-patches mailing list