On Thu, Mar 24, 2011 at 15:30, Le-Chun Wu <[email protected]> wrote: > 2011-03-24 Le-Chun Wu <[email protected]> > > * Makefile.in: Add new source file and headers in dependencies. > * attribs.c (decl_attributes): Handle lock attributes. > (is_lock_attribute_with_args): New function. > (is_lock_attribute_p): Likewise. > (extract_lock_attributes): Likewise. > (merge_lock_attr_args): Likewise. > * c-decl.c (undeclared_variable): Suppress errors for lock attributes. > * c-parser.c (c_parser_declaration_or_fndef): Allow lock attributes on > function definitions. Add support for suppressing errors for lock > attributes. > (c_parser_attributes): Replace the original code that handles the > argument list with a call to c_parser_attr_arg_list. > (c_parser_attr_arg_list): New function. > * common.opt: Add new flags for lock annotations and analysis. > * doc/invoke.texi: Add documentation for new flags for lock annotations > and analysis. > * gimplify.c (lookup_tmp_var): Copy thread safety attributes to tmp > variable and save the original variable name. > * langhooks-def.h: Define new language hooks. > * langhooks.c (lhd_do_nothing_t_return_int): New function. > (lhd_do_nothing_t_return_bool): Likewise. > (lhd_do_nothing_t_t_return_null_tree): Likewise. > * langhooks.h: Add new hook functions in the lang_hooks struct. > * passes.c (init_optimization_passes): Add a new pass. > * pointer-set.c (pointer_set_copy): New function. > (pointer_set_delete): Likewise. > (pointer_set_intersection_complement): Likewise. > (pointer_set_union_inplace): Likewise. > (pointer_set_cardinality): Likewise. > * pointer-set.h: Add declarations of new functions. > * timevar.def: Add a new time var for thread safety analysis pass. > * toplev.c (compile_file): Clean up the global data structures > used by the thread safety analysis. > * tree-pass.h: Add a new pass declaration. > * tree-threadsafe-analyze.c: New file. > * tree-threadsafe-analyze.h: New file. > * tree.h: Declaration for new functions. > > c-family/ > * c-common.c (c_common_attribute_table): Add new functions to process > lock attributes. > (attribute_takes_identifier_p): Handle lock attributes. > (handle_lockable_attribute): New Handler. > (handle_guarded_by_attribute): Likewise. > (handle_point_to_guarded_by_attribute): Likewise. > (handle_guarded_attribute): Likewise. > (handle_point_to_guarded_attribute): Likewise. > (handle_acquired_order_attribute): Likewise. > (handle_lock_attribute): Likewise. > (handle_unlock_attribute): Likewise. > (handle_locks_required_excluded_attribute): Likewise. > (handle_lock_returned_attribute): Likewise. > (handle_no_thread_safety_analysis_attribute): Likewise. > (supported_lock_expression): New helper function. > (get_lock_decl): Likewise. > (populate_acquired_after_map): Likewise. > (is_lock_formal_parameter): Likewise. > (check_lock_unlock_attr_args): Likewise. > * c-cppbuiltin.c (c_cpp_builtins): Define annotalysis-related macros. > * c-pretty-print.c (pp_c_expression): Handle SSA_NAME. > > cp/ > * Make-lang.in: Add new includes. > * call.c (build_new_op): Support for non-const non-modifying methods. > (find_const_memfunc_with_identical_prototype): New function. > (build_new_method_call): Suppress errors for calls in lock attributes. > Support for non-const non-modifying methods. > * class.c (cp_get_virtual_function_decl): New function. > (cp_fold_obj_type_ref): Refactored to call > cp_get_virtual_function_decl. > (cp_decl_is_base_field): New function. > (cp_decl_is_constructor): Likewise. > (cp_decl_is_destructor): Likewise. > (cp_decl_is_const_member_func): Likewise. > * cp-lang.c: New language hooks. > * cp-tree.h: New function declarations. > * decl2.c (is_late_template_attribute): Handle delay parsing of lock > attribute arguments. > * error.c (dump_expr): Handle SSA_NAME. > * lex.c (unqualified_name_lookup_error): Suppress errors for lock > attributes. > * name-lookup.c (lookup_name_in_func_params): New function. > * name-lookup.h: New function declaration. > * parser.c (cp_parser): New fields. > (cp_parser_name_lookup_error): Suppress errors for lock attributes. > (cp_parser_new): Initialize unparsed_attribute_args_queue. > (cp_parser_postfix_expression): Add function parameter lookup support. > (cp_parser_parenthesized_expression_list): Fix a problem in parsing > identifier arguments and skip folding for decl arguments. > (cp_parser_lambda_declarator_opt): Add a new argument to > cp_parser_attributes_opt. > (cp_parser_label_for_labeled_statement): Likewise. > (cp_parser_condition): Likewise. > (cp_parser_decl_specifier_seq): Likewise. > (cp_parser_conversion_type_id): Likewise. > (cp_parser_elaborated_type_specifier): Likewise. > (cp_parser_enum_specifier): Likewise. > (cp_parser_namespace_definition): Likewise. > (cp_parser_using_directive): Likewise. > (cp_parser_init_declarator): Allow lock attributes on function > definitions. Support function parameter lookup. Also add a new > argument to cp_parser_attributes_opt. > (cp_parser_declarator): Add a new argument to calls to > cp_parser_attributes_opt. > (cp_parser_type_specifier_seq): Likewise. > (cp_parser_parameter_declaration): Likewise. > (cp_parser_class_specifier): Late-parse the lock attribute arguments. > Also add a new argument to cp_parser_attributes_opt. > (cp_parser_class_head): Add a new argument to cp_parser_attributes_opt. > (cp_parser_member_declaration): Likewise. > (cp_parser_asm_label_list): Likewise. > (cp_parser_attributes_opt): Add a new parameter 'member_p' and call > cp_parser_attribute_list with it. > (cp_parser_save_attribute_arg_list): New function. > (cp_parser_attribute_list): Add a new parameter 'member_p'. Also delay > parsing of lock attribute arguments by saving the tokens. > (cp_parser_late_parsing_attribute_arg_lists): New function. > (cp_parser_function_definition_from_specifiers_and_declarator): Parse > unbound lock attribute arguments. > (cp_parser_objc_method_keyword_params): Add a new argument to > cp_parser_attributes_opt. > (cp_parser_objc_method_tail_params_opt): Likewise. > (cp_parser_objc_method_maybe_bad_prefix_attributes): Likewise. > (cp_parser_objc_class_ivars): Likewise. > (cp_parser_objc_struct_declaration): Likewise. > (cp_parser_omp_for_loop): Likewise. > * pt.c (find_parameter_packs_r): Skip walking the subtrees if the tree > list node is created for delay parsing. > (apply_late_template_attributes): Defer instantiation of lock > attributes. > (pa_reverse): New function. > (instantiate_class_template): Instantiate the deferred lock attributes > and apply them to the corresponding declarations. > (tsubst_copy): Suppress errors for lock attributes. > (tsubst_copy_and_build): Support function parameter lookup. > * semantics.c (finish_non_static_data_member): Suppress errors for lock > attributes. > * typeck.c (finish_class_member_access_expr): Suppress errors for lock > attributes. > * typeck2.c (cxx_incomplete_type_diagnostic): Suppress errors for lock > attributes. > > testsuite/ > * g++.dg/README: Add an entry for the new thread-ann sub-directory. > * g++.dg/thread-ann: New test sub-directory. > * g++.dg/thread-ann/thread_annot_common.h: New test header file. > * g++.dg/thread-ann/thread_annot_lock-1.C: New test. > * g++.dg/thread-ann/thread_annot_lock-2.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-3.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-4.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-5.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-6.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-7.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-8.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-9.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-10.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-11.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-12.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-13.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-14.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-15.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-16.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-17.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-18.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-19.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-20.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-21.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-22.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-23.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-24.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-25.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-26.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-27.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-28.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-29.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-30.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-31.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-32.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-33.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-34.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-35.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-36.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-37.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-38.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-39.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-40.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-41.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-42.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-43.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-44.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-45.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-46.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-47.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-48.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-49.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-50.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-51.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-52.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-53.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-54.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-55.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-56.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-57.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-58.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-59.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-60.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-61.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-62.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-63.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-64.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-65.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-66.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-67.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-68.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-69.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-70.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-71.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-72.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-73.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-74.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-75.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-76.C: Likewise. > * g++.dg/thread-ann/thread_annot_lock-77.C: Likewise. > * gcc.dg/thread_annot_common_c.h: New test header file for C. > * gcc.dg/thread_annot_lock-23.c: New test. > * gcc.dg/thread_annot_lock-23.c: New test. > * gcc.dg/thread_annot_lock-24.c: Likewise. > * gcc.dg/thread_annot_lock-25.c: Likewise. > * gcc.dg/thread_annot_lock-26.c: Likewise. > * gcc.dg/thread_annot_lock-27.c: Likewise. > * gcc.dg/thread_annot_lock-42.c: Likewise.
Looks OK with some fixes below. Could you also update http://gcc.gnu.org/wiki/ThreadSafetyAnnotation? It still points to the old branch and seems to have stale content. Any plans for mainline merge? Diego. http://codereview.appspot.com/4275075/diff/2001/gcc/common.opt File gcc/common.opt (right): http://codereview.appspot.com/4275075/diff/2001/gcc/common.opt#newcode682 gcc/common.opt:682: Make the thread safety analysis try to bind the function parameters used in the attributes Hmm, you've added these warnings twice now. I had added the flags to fix our builds. The warnings I added are just above these. If there's anything new, you can just overwrite it. http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c File gcc/cp/parser.c (left): http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c#oldcode5766 gcc/cp/parser.c:5766: is_attribute_list = non_attr; Why are you taking this out? http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c#oldcode5802 gcc/cp/parser.c:5802: VEC_safe_insert (tree, gc, expression_list, 0, identifier); Likewise. http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c File gcc/cp/parser.c (right): http://codereview.appspot.com/4275075/diff/2001/gcc/cp/parser.c#newcode1742 gcc/cp/parser.c:1742: tree current_declarator_scope; You're going to find some amusing merge conflicts the next time google/main merges from trunk ;) All this has been factored out of cp/parser.c http://codereview.appspot.com/4275075/diff/2001/gcc/tree.h File gcc/tree.h (right): http://codereview.appspot.com/4275075/diff/2001/gcc/tree.h#newcode5366 gcc/tree.h:5366: /* Extract and return all lock attributes from the given attribute list. */ Blank line above comment. Diego.
