This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


This patch fixes a bug in the parser which cause an internal compiler
error when copying attributes from cloned methods.  The bug occurs
when a class has both an annotated constructor and a template method.

Bootstrapped and passed gcc regression testsuite on
x86_64-unknown-linux-gnu.  Okay for google/gcc-4_6?

 -DeLesley

cp/Changelog.google-4_6:
2011-9-27  DeLesley Hutchins  <delesley@google.com>

      * cp/parser.c  (cp_parser_late_parsing_attribute_arg_lists)
         fixed case where the potential clone is a template.

testsuite/Changelog.google-4_6:
2011-9-27  DeLesley Hutchins  <delesley@google.com>

      * testsuite/g++.dg/thread-ann/thread_annot_lock-81.C
        (new regression test)

-- 
DeLesley Hutchins | Software Engineer | delesley@google.com | 505-206-0315
Index: testsuite/g++.dg/thread-ann/thread_annot_lock-81.C
===================================================================
--- testsuite/g++.dg/thread-ann/thread_annot_lock-81.C	(revision 0)
+++ testsuite/g++.dg/thread-ann/thread_annot_lock-81.C	(revision 0)
@@ -0,0 +1,17 @@
+// Test template methods in the presence of cloned constructors.
+// Regression test for bugfix.  
+// { dg-do compile }
+// { dg-options "-Wthread-safety -O" }
+
+#include "thread_annot_common.h"
+
+Mutex mu_;
+Mutex mu2_;
+
+class Foo {
+  Foo() LOCKS_EXCLUDED(mu_)	{ }
+  
+  template <class T>
+  void bar(T* t) LOCKS_EXCLUDED(mu2_) { }
+};
+
Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 179283)
+++ cp/parser.c	(working copy)
@@ -19328,7 +19328,8 @@ cp_parser_late_parsing_attribute_arg_lists (cp_par
           tree clone;
           for (clone = TREE_CHAIN (decl); clone; clone = TREE_CHAIN (clone))
             {
-              if (DECL_CLONED_FUNCTION (clone) == decl)
+              tree* clonefun = &DECL_CLONED_FUNCTION (clone);
+              if (clonefun && *clonefun == decl)
                 DECL_ATTRIBUTES (clone) = DECL_ATTRIBUTES (decl);
             }
         }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]