From 96cfd68ee5ad94c8e8c222f89e8c8bb9d8e68dd6 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 7 Sep 2006 18:38:03 -0400 Subject: [PATCH] re PR c++/26195 (pragma interface no longer handles explicit names) PR c++/26195 * decl.c (make_rtl_for_nonlocal_decl), (start_preparsed_function): Don't use lbasename on input_filename when calling get_fileinfo. * semantics.c (begin_class_definition): Likewise. * lex.c (cxx_make_type): Likewise. (handle_pragma_interface): Call get_fileinfo on input_filename, not on the parameter to the directive. PR c++/26696 * cvt.c (convert_to_void): Replace a subexpression with no side effects with void_zero_node. * tree.c (is_overloaded_fn): Look through COMPONENT_REF. (get_first_fn): Ditto. * decl.c (grokdeclarator): No need to look through COMPONENT_REF. PR c++/26571 * parser.c (cp_parser_diagnose_invalid_type_name): Handle the case where the name is a type used incorrectly. PR c++/26671 * typeck.c (maybe_warn_about_returning_address_of_local): Look through COMPONENT_REF and ARRAY_REF. PR c++/19809 * pt.c (tsubst_friend_function): Set DECL_INITIAL before pushdecl. From-SVN: r116764 --- gcc/cp/ChangeLog | 33 +++++++++++++++++++++++++++++++++ gcc/cp/cvt.c | 2 ++ gcc/cp/decl.c | 6 ++---- gcc/cp/lex.c | 4 ++-- gcc/cp/parser.c | 3 +++ gcc/cp/pt.c | 4 ++++ gcc/cp/semantics.c | 2 +- gcc/cp/tree.c | 5 ++++- gcc/cp/typeck.c | 4 ++++ 9 files changed, 55 insertions(+), 8 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b8eb591833fd..4fe764991087 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,36 @@ +2006-09-06 Zak Kipling + + PR c++/26195 + * decl.c (make_rtl_for_nonlocal_decl), + (start_preparsed_function): Don't use lbasename on + input_filename when calling get_fileinfo. + * semantics.c (begin_class_definition): Likewise. + * lex.c (cxx_make_type): Likewise. + (handle_pragma_interface): Call get_fileinfo on input_filename, + not on the parameter to the directive. + +2006-09-06 Jason Merrill + + PR c++/26696 + * cvt.c (convert_to_void): Replace a subexpression with no side + effects with void_zero_node. + * tree.c (is_overloaded_fn): Look through COMPONENT_REF. + (get_first_fn): Ditto. + * decl.c (grokdeclarator): No need to look through COMPONENT_REF. + +2006-09-05 Jason Merrill + + PR c++/26571 + * parser.c (cp_parser_diagnose_invalid_type_name): Handle the case + where the name is a type used incorrectly. + + PR c++/26671 + * typeck.c (maybe_warn_about_returning_address_of_local): Look + through COMPONENT_REF and ARRAY_REF. + + PR c++/19809 + * pt.c (tsubst_friend_function): Set DECL_INITIAL before pushdecl. + 2006-08-28 Jason Merrill PR c++/26577 diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 0e1a8431202c..6b9067600a39 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -947,6 +947,8 @@ convert_to_void (tree expr, const char *implicit) } expr = build1 (CONVERT_EXPR, void_type_node, expr); } + if (! TREE_SIDE_EFFECTS (expr)) + expr = void_zero_node; return expr; } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index cddfcb2f7389..61b12863f1a8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4621,7 +4621,7 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec) { /* Fool with the linkage of static consts according to #pragma interface. */ - struct c_fileinfo *finfo = get_fileinfo (lbasename (input_filename)); + struct c_fileinfo *finfo = get_fileinfo (input_filename); if (!finfo->interface_unknown && !TREE_PUBLIC (decl)) { TREE_PUBLIC (decl) = 1; @@ -6584,8 +6584,6 @@ grokdeclarator (const cp_declarator *declarator, tree fns = TREE_OPERAND (decl, 0); dname = fns; - if (TREE_CODE (dname) == COMPONENT_REF) - dname = TREE_OPERAND (dname, 1); if (TREE_CODE (dname) != IDENTIFIER_NODE) { gcc_assert (is_overloaded_fn (dname)); @@ -9915,7 +9913,7 @@ start_preparsed_function (tree decl1, tree attrs, int flags) struct cp_binding_level *bl; tree current_function_parms; struct c_fileinfo *finfo - = get_fileinfo (lbasename (LOCATION_FILE (DECL_SOURCE_LOCATION (decl1)))); + = get_fileinfo (LOCATION_FILE (DECL_SOURCE_LOCATION (decl1))); /* Sanity check. */ gcc_assert (TREE_CODE (TREE_VALUE (void_list_node)) == VOID_TYPE); diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index e0626f7e5682..0a565115df11 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -467,7 +467,7 @@ handle_pragma_interface (cpp_reader* dfile ATTRIBUTE_UNUSED ) else filename = ggc_strdup (TREE_STRING_POINTER (fname)); - finfo = get_fileinfo (filename); + finfo = get_fileinfo (input_filename); if (impl_file_chain == 0) { @@ -773,7 +773,7 @@ cxx_make_type (enum tree_code code) /* Set up some flags that give proper default behavior. */ if (IS_AGGR_TYPE_CODE (code)) { - struct c_fileinfo *finfo = get_fileinfo (lbasename (input_filename)); + struct c_fileinfo *finfo = get_fileinfo (input_filename); SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, finfo->interface_unknown); CLASSTYPE_INTERFACE_ONLY (t) = finfo->interface_only; } diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 5d04a2fedadd..0d840e7d375e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2052,6 +2052,9 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree scope, tree id) error ("invalid use of template-name %qE without an argument list", decl); else if (TREE_CODE (id) == BIT_NOT_EXPR) error ("invalid use of destructor %qD as a type", id); + else if (TREE_CODE (decl) == TYPE_DECL) + /* Something like 'unsigned A a;' */ + error ("invalid combination of multiple type-specifiers"); else if (!parser->scope || parser->scope == error_mark_node) { /* Issue an error message. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9ae563f50be8..75b063b75588 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5206,6 +5206,10 @@ tsubst_friend_function (tree decl, tree args) else new_friend_result_template_info = NULL_TREE; + /* Make the init_value nonzero so pushdecl knows this is a defn. */ + if (new_friend_is_defn) + DECL_INITIAL (new_friend) = error_mark_node; + /* Inside pushdecl_namespace_level, we will push into the current namespace. However, the friend function should go into the namespace of the template. */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 099f346e20dd..4a0acad9bdf6 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2123,7 +2123,7 @@ begin_class_definition (tree t) before. */ if (! TYPE_ANONYMOUS_P (t)) { - struct c_fileinfo *finfo = get_fileinfo (lbasename (input_filename)); + struct c_fileinfo *finfo = get_fileinfo (input_filename); CLASSTYPE_INTERFACE_ONLY (t) = finfo->interface_only; SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, finfo->interface_unknown); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index b9b2030584ce..72670c185cd4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -807,7 +807,8 @@ int is_overloaded_fn (tree x) { /* A baselink is also considered an overloaded function. */ - if (TREE_CODE (x) == OFFSET_REF) + if (TREE_CODE (x) == OFFSET_REF + || TREE_CODE (x) == COMPONENT_REF) x = TREE_OPERAND (x, 1); if (BASELINK_P (x)) x = BASELINK_FUNCTIONS (x); @@ -836,6 +837,8 @@ get_first_fn (tree from) { gcc_assert (is_overloaded_fn (from)); /* A baselink is also considered an overloaded function. */ + if (TREE_CODE (from) == COMPONENT_REF) + from = TREE_OPERAND (from, 1); if (BASELINK_P (from)) from = BASELINK_FUNCTIONS (from); return OVL_CURRENT (from); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index a48115461632..ed7258399b39 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6083,6 +6083,10 @@ maybe_warn_about_returning_address_of_local (tree retval) } } + while (TREE_CODE (whats_returned) == COMPONENT_REF + || TREE_CODE (whats_returned) == ARRAY_REF) + whats_returned = TREE_OPERAND (whats_returned, 0); + if (DECL_P (whats_returned) && DECL_NAME (whats_returned) && DECL_FUNCTION_SCOPE_P (whats_returned) -- 2.47.2