From: Jason Merrill Date: Sun, 25 Oct 1998 17:35:47 +0000 (-0500) Subject: parse.y (condition): Convert VAR_DECL from reference to indirect reference. X-Git-Tag: prereleases/egcs-1.1.1-pre~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54659c296e212e55ee5ce5730f1b06935d5cb805;p=thirdparty%2Fgcc.git parse.y (condition): Convert VAR_DECL from reference to indirect reference. * parse.y (condition): Convert VAR_DECL from reference to indirect reference. * decl2.c (validate_nonmember_using_decl): Fix using-directives of std if std is ignored. * method.c (build_decl_overload_real): Clear numeric_output_need_bar after __. * decl.c (cp_finish_decl): Make statics in extern inlines and templates common, if possible and the target doesn't support weak symbols. * decl2.c (merge_functions): Remove duplicates. * typeck.c (build_conditional_expr): Only fold if ifexp is an INTEGER_CST. From-SVN: r23322 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 26dda4449468..8b0faa7ad8c5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,7 +1,17 @@ +1998-10-23 Martin von Löwis + + * parse.y (condition): Convert VAR_DECL from reference to indirect + reference. + 1998-10-18 Jason Merrill * method.c (hack_identifier): Just return a member function. +1998-10-18 Martin von Löwis + + * decl2.c (validate_nonmember_using_decl): Fix using-directives of + std if std is ignored. + 1998-10-14 Jason Merrill * spew.c (yylex): Clear looking_for_typename if we got @@ -24,6 +34,24 @@ * tinfo.cc: Add #pragma implementation. (operator==): Move from inc/typeinfo and tinfo2.cc. +1998-10-05 Martin von Löwis + + * method.c (build_decl_overload_real): Clear + numeric_output_need_bar after __. + +1998-10-04 Jason Merrill + + * decl.c (cp_finish_decl): Make statics in extern inlines and + templates common, if possible and the target doesn't support weak + symbols. + +1998-10-03 Jason Merrill + + * decl2.c (merge_functions): Remove duplicates. + + * typeck.c (build_conditional_expr): Only fold if ifexp is an + INTEGER_CST. + Fri Oct 2 02:07:26 1998 Mumit Khan * parse.y (nomods_initdcl0): Set up the parser stack correctly. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 496158d942b4..02330ee5132f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7191,20 +7191,52 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags) if (was_temp) end_temporary_allocation (); - /* Extern inline function static data has external linkage. - Instead of trying to deal with that, we disable inlining of - such functions. The ASM_WRITTEN check is to avoid hitting this - for __FUNCTION__. */ + /* Static data in a function with comdat linkage also has comdat + linkage. */ if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) + /* Don't mess with __FUNCTION__. */ && ! TREE_ASM_WRITTEN (decl) && current_function_decl && DECL_CONTEXT (decl) == current_function_decl - && DECL_THIS_INLINE (current_function_decl) + && (DECL_THIS_INLINE (current_function_decl) + || DECL_TEMPLATE_INSTANTIATION (current_function_decl)) && TREE_PUBLIC (current_function_decl)) { + /* Rather than try to get this right with inlining, we suppress + inlining of such functions. */ current_function_cannot_inline = "function with static variable cannot be inline"; + + /* If flag_weak, we don't need to mess with this, as we can just + make the function weak, and let it refer to its unique local + copy. This works because we don't allow the function to be + inlined. */ + if (! flag_weak) + { + if (DECL_INTERFACE_KNOWN (current_function_decl)) + { + TREE_PUBLIC (decl) = 1; + DECL_EXTERNAL (decl) = DECL_EXTERNAL (current_function_decl); + } + else if (DECL_INITIAL (decl) == NULL_TREE + || DECL_INITIAL (decl) == error_mark_node) + { + TREE_PUBLIC (decl) = 1; + DECL_COMMON (decl) = 1; + } + /* else we lose. We can only do this if we can use common, + which we can't if it has been initialized. */ + + if (TREE_PUBLIC (decl)) + DECL_ASSEMBLER_NAME (decl) + = build_static_name (current_function_decl, DECL_NAME (decl)); + else if (! DECL_ARTIFICIAL (decl)) + { + cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl); + cp_warning_at (" you can work around this by removing the initializer"), decl; + } + } } else if (TREE_CODE (decl) == VAR_DECL diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index cc2c3332c514..2df2ac0d5c11 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3910,22 +3910,22 @@ add_using_namespace (user, used, indirect) add_using_namespace (TREE_PURPOSE (t), used, 1); } -/* Combines two sets of overloaded functions into an OVERLOAD chain. - The first list becomes the tail of the result. */ +/* Combines two sets of overloaded functions into an OVERLOAD chain, removing + duplicates. The first list becomes the tail of the result. + + The algorithm is O(n^2). */ static tree merge_functions (s1, s2) tree s1; tree s2; { - if (TREE_CODE (s2) == OVERLOAD) - while (s2) - { - s1 = build_overload (OVL_FUNCTION (s2), s1); - s2 = OVL_CHAIN (s2); - } - else - s1 = build_overload (s2, s1); + for (; s2; s2 = OVL_NEXT (s2)) + { + tree fn = OVL_CURRENT (s2); + if (! ovl_member (fn, s1)) + s1 = build_overload (fn, s1); + } return s1; } @@ -4458,8 +4458,11 @@ validate_nonmember_using_decl (decl, scope, name) { if (TREE_CODE (decl) == SCOPE_REF && TREE_OPERAND (decl, 0) == std_node) - return NULL_TREE; - if (TREE_CODE (decl) == SCOPE_REF) + { + *scope = global_namespace; + *name = TREE_OPERAND (decl, 1); + } + else if (TREE_CODE (decl) == SCOPE_REF) { *scope = TREE_OPERAND (decl, 0); *name = TREE_OPERAND (decl, 1); diff --git a/gcc/cp/method.c b/gcc/cp/method.c index f6af6e98ed3a..29b31c426468 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1533,6 +1533,7 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs, and figure out its name without any extra encoding. */ OB_PUTC2 ('_', '_'); + numeric_output_need_bar = 0; if (tparms) { diff --git a/gcc/cp/parse.c b/gcc/cp/parse.c index f0edf7c23326..da7e6b9f3639 100644 --- a/gcc/cp/parse.c +++ b/gcc/cp/parse.c @@ -4751,7 +4751,7 @@ case 187: { cp_finish_decl (yyvsp[-1].ttype, yyvsp[0].ttype, yyvsp[-3].ttype, 1, LOOKUP_ONLYCONVERTING); resume_momentary (yyvsp[-2].itype); - yyval.ttype = yyvsp[-1].ttype; + yyval.ttype = convert_from_reference (yyvsp[-1].ttype); if (TREE_CODE (TREE_TYPE (yyval.ttype)) == ARRAY_TYPE) cp_error ("definition of array `%#D' in condition", yyval.ttype); ; diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 61a0d8773313..279cec338b85 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -991,7 +991,7 @@ condition: { cp_finish_decl ($6, $7, $4, 1, LOOKUP_ONLYCONVERTING); resume_momentary ($5); - $$ = $6; + $$ = convert_from_reference ($6); if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE) cp_error ("definition of array `%#D' in condition", $$); } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 197aab7d985a..4e1d4fd44bf0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5262,7 +5262,7 @@ build_conditional_expr (ifexp, op1, op2) op2 = convert_for_initialization (NULL_TREE, result_type, op2, LOOKUP_NORMAL, "converting", NULL_TREE, 0); - if (TREE_CONSTANT (ifexp)) + if (TREE_CODE (ifexp) == INTEGER_CST) return integer_zerop (ifexp) ? op2 : op1; return convert_from_reference