Doing diffs in tree.c.~1~: *** tree.c.~1~ Thu Feb 13 18:09:15 2003 --- tree.c Sat Feb 15 08:02:58 2003 *************** static int next_decl_uid; *** 95,100 **** --- 95,106 ---- /* Unique id for next type created. */ static int next_type_uid = 1; + int + get_next_decl_uid () + { + return next_decl_uid; + } + /* Since we cannot rehash a type after it is in the table, we have to keep the hash code. */ -------------- Doing diffs in cp/call.c.~1~: *** cp/call.c.~1~ Thu Jan 30 11:26:44 2003 --- cp/call.c Sat Feb 15 14:10:45 2003 *************** equal_functions (fn1, fn2) *** 5596,5601 **** --- 5596,5610 ---- return fn1 == fn2; } + + static int + rejoust (cand1, cand2) + struct z_candidate *cand1, *cand2; + { + /* FIX this */ + return -1; + } + /* Compare two candidates for overloading as described in [over.match.best]. Return values: *************** tourney (candidates) *** 5899,5904 **** --- 5908,5925 ---- { if (fate == 0) { + fate = rejoust (champ, challenger); + if (fate == 1) + { + challenger = challenger->next; + continue; + } + else if (fate == -1) + { + champ = challenger; + champ_compared_to_predecessor = 1; + continue; + } champ = challenger->next; if (champ == 0) return 0; -------------- Doing diffs in cp/cp-tree.h.~1~: *** cp/cp-tree.h.~1~ Sat Feb 15 06:00:41 2003 --- cp/cp-tree.h Sat Feb 15 15:42:49 2003 *************** enum overload_flags { NO_SPECIAL = 0, DT *** 3532,3537 **** --- 3532,3551 ---- ? TYPE_TI_TEMPLATE (NODE) \ : TYPE_NAME (NODE)) + extern unsigned int first_decl_uid_in_unit; + + static bool in_other_unit (tree); + + static inline bool in_other_unit (tree t) + { + if (t == error_mark_node) + return 0; + + if (DECL_UID (t) < first_decl_uid_in_unit) + return 1; + return 0; + } + /* in lex.c */ extern void init_reswords PARAMS ((void)); -------------- Doing diffs in cp/decl.c.~1~: *** cp/decl.c.~1~ Thu Feb 13 18:09:34 2003 --- cp/decl.c Sat Feb 15 11:10:49 2003 *************** int adding_implicit_members = 0; *** 300,305 **** --- 300,307 ---- processed. */ bool have_extern_spec; + unsigned int first_decl_uid_in_unit = 0; + /* For each binding contour we allocate a binding_level structure which records the names defined in that contour. *************** duplicate_decls (newdecl, olddecl) *** 3321,3326 **** --- 3323,3330 ---- const char *errmsg = redeclaration_error_message (newdecl, olddecl); if (errmsg) { + if (in_other_unit (olddecl)) + return 0; error (errmsg, newdecl); if (DECL_NAME (olddecl) != NULL_TREE) cp_error_at ((DECL_INITIAL (olddecl) *************** pushdecl (x) *** 3937,3943 **** t = NULL_TREE; cp_error_at ("`%#D' used prior to declaration", x); } ! else if (t != NULL_TREE) { if (different_binding_level) { --- 3941,3948 ---- t = NULL_TREE; cp_error_at ("`%#D' used prior to declaration", x); } ! else if (t != NULL_TREE ! && ! in_other_unit (t)) { if (different_binding_level) { *************** check_static_variable_definition (decl, *** 9895,9909 **** required. */ if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE) { ! error ("invalid in-class initialization of static data member of non-integral type `%T'", ! type); ! /* If we just return the declaration, crashes will sometimes ! occur. We therefore return void_type_node, as if this was a ! friend declaration, to cause callers to completely ignore ! this declaration. */ ! return 1; } ! else if (!CP_TYPE_CONST_P (type)) error ("ISO C++ forbids in-class initialization of non-const static member `%D'", decl); else if (pedantic && !INTEGRAL_TYPE_P (type)) --- 9900,9920 ---- required. */ if (!ARITHMETIC_TYPE_P (type) && TREE_CODE (type) != ENUMERAL_TYPE) { ! if (CLASS_TYPE_P (type) || TREE_CODE (type) == REFERENCE_TYPE) ! { ! error ("invalid in-class initialization of static data member of non-integral type `%T'", ! type); ! /* If we just return the declaration, crashes will sometimes ! occur. We therefore return void_type_node, as if this was a ! friend declaration, to cause callers to completely ignore ! this declaration. */ ! return 1; ! } ! pedwarn ("invalid in-class initialization of static data member of non-integral type `%T'", ! type); ! return 0; } ! if (!CP_TYPE_CONST_P (type)) error ("ISO C++ forbids in-class initialization of non-const static member `%D'", decl); else if (pedantic && !INTEGRAL_TYPE_P (type)) -------------- Doing diffs in cp/decl2.c.~1~: *** cp/decl2.c.~1~ Thu Feb 13 18:09:35 2003 --- cp/decl2.c Sat Feb 15 11:25:26 2003 *************** ambiguous_decl (name, old, new, flags) *** 3946,3952 **** val = NULL_TREE; } ! if (!BINDING_VALUE (old)) BINDING_VALUE (old) = val; else if (val && val != BINDING_VALUE (old)) { --- 3946,3956 ---- val = NULL_TREE; } ! if (!BINDING_VALUE (old) ! || (! is_overloaded_fn (BINDING_VALUE (old)) ! && in_other_unit (BINDING_VALUE (old)) ! && val != 0 ! && ! is_overloaded_fn (val))) BINDING_VALUE (old) = val; else if (val && val != BINDING_VALUE (old)) { -------------- Doing diffs in cp/lex.c.~1~: *** cp/lex.c.~1~ Thu Feb 13 18:09:35 2003 --- cp/lex.c Sat Feb 15 15:28:49 2003 *************** static void handle_pragma_unit PARAMS (( *** 60,65 **** --- 60,66 ---- static void handle_pragma_interface PARAMS ((cpp_reader *)); static void handle_pragma_implementation PARAMS ((cpp_reader *)); static void handle_pragma_java_exceptions PARAMS ((cpp_reader *)); + static void handle_pragma_translationunit PARAMS ((cpp_reader *)); #ifdef GATHER_STATISTICS #ifdef REDUCE_LENGTH *************** init_cp_pragma () *** 689,694 **** --- 690,697 ---- handle_pragma_implementation); cpp_register_pragma (parse_in, "GCC", "java_exceptions", handle_pragma_java_exceptions); + cpp_register_pragma (parse_in, 0, "translationunit", + handle_pragma_translationunit); } /* Initialize the C++ front end. This function is very sensitive to *************** handle_pragma_java_exceptions (dfile) *** 1165,1170 **** --- 1168,1203 ---- warning ("junk at end of #pragma GCC java_exceptions"); choose_personality_routine (lang_java); + } + + static void + handle_pragma_translationunit (dfile) + cpp_reader *dfile ATTRIBUTE_UNUSED; + { + tree fname = parse_strconst_pragma ("translationunit", 1); + const char *main_filename; + + if (fname == (tree)-1) + return; + else if (fname == 0) + { + abort (); + main_filename = lbasename (input_filename); + } + else + main_filename = TREE_STRING_POINTER (fname); + + if (0) + { + main_input_filename = main_filename; + first_global_object_name = 0; + weak_global_object_name = 0; + anonymous_namespace_name = 0; + } + + first_decl_uid_in_unit = get_next_decl_uid (); + + printf("saw unit %s\n", main_filename); } void -------------- Doing diffs in cp/semantics.c.~1~: *** cp/semantics.c.~1~ Thu Feb 13 18:09:36 2003 --- cp/semantics.c Sat Feb 15 12:03:20 2003 *************** finish_parmlist (parms, ellipsis) *** 1686,1691 **** --- 1686,1700 ---- return parms; } + bool + is_decl_again (tree t) + { + if (DECL_SOURCE_LINE (TYPE_NAME (t)) == lineno + && strcmp (DECL_SOURCE_FILE (TYPE_NAME (t)), input_filename) == 0) + return 1; + return 0; + } + /* Begin a class definition, as indicated by T. */ tree *************** begin_class_definition (t) *** 1783,1789 **** /* If this type was already complete, and we see another definition, that's an error. */ else if (COMPLETE_TYPE_P (t)) ! duplicate_tag_error (t); /* Update the location of the decl. */ DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename; --- 1792,1805 ---- /* If this type was already complete, and we see another definition, that's an error. */ else if (COMPLETE_TYPE_P (t)) ! { ! if (is_decl_again (t)) ! { ! /* This case is hard to recover from, punt for now. */ ! error ("please add include guards to this file"); ! } ! duplicate_tag_error (t); ! } /* Update the location of the decl. */ DECL_SOURCE_FILE (TYPE_NAME (t)) = input_filename; --------------