diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-02 19:22:40 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-02 19:22:40 +0000 |
commit | e18a8ca20bda043a85e95113e7288b4170023785 (patch) | |
tree | 5903f739377a9d23396281e6491570f3103529de /gcc/cp | |
parent | dabe786b59ca225bc2389fbfa5616e5ddd85d2fa (diff) | |
download | gcc-e18a8ca20bda043a85e95113e7288b4170023785.tar.gz |
2012-10-02 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 191993 using svnmerge.py
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@191994 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 92 | ||||
-rw-r--r-- | gcc/cp/Make-lang.in | 2 | ||||
-rw-r--r-- | gcc/cp/call.c | 3 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 30 | ||||
-rw-r--r-- | gcc/cp/decl.c | 72 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 22 | ||||
-rw-r--r-- | gcc/cp/error.c | 2 | ||||
-rw-r--r-- | gcc/cp/init.c | 40 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 7 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 1 | ||||
-rw-r--r-- | gcc/cp/parser.c | 16 | ||||
-rw-r--r-- | gcc/cp/pt.c | 3 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 29 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 14 |
14 files changed, 228 insertions, 105 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0a5292f2729..f868739be6e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,87 @@ +2012-10-01 Jason Merrill <jason@redhat.com> + + * decl.c (check_initializer): Set DECL_NONTRIVIALLY_INITIALIZED_P + for a constructor call. + (decl_jump_unsafe): So don't bother checking + type_has_nontrivial_default_init. + * call.c (set_up_extended_ref_temp): Set + DECL_NONTRIVIALLY_INITIALIZED_P. + + * cp-tree.h (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK): New. + (DECL_FRIEND_P, DECL_ANTICIPATED): Use it. + (TYPE_FUNCTION_OR_TEMPLATE_DECL_P): New. + * name-lookup.c (hidden_name_p): Use it. + + * cp-tree.h (DECL_PRETTY_FUNCTION_P): Just look at the name. + * decl.c (cp_make_fname_decl): Adjust. + +2012-09-30 Sharad Singhai <singhai@google.com> + + * decl2.c (cp_write_global_declarations): Use a different method + to determine if the dump has ben initialized. + +2012-09-29 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54738 + * decl2.c (build_offset_ref_call_from_tree): Add tsubst_flags_t + parameter. + * pt.c (tsubst_copy_and_build): Adjust. + * parser.c (cp_parser_postfix_expression): Likewise. + * cp-tree.h: Adjust declaration. + +2012-09-28 Dodji Seketeli <dodji@redhat.com> + + PR c++/54372 - unused attribute inactive on dependant entities + * decl2.c (is_late_template_attribute): "unused" attribute is to + be applied at compile time. + +2012-09-25 Dodji Seketeli <dodji@redhat.com> + + PR c++/29028 - Missed unused warning on using declaration + * decl.c (poplevel<warn_unused*>): Do not forget that some local + bindings are represented by a TREE_LIST. + +2012-09-25 Dodji Seketeli <dodji@redhat.com> + + PR c++/53551 - -Wunused-local-typedefs misses uses + * decl.c (make_typename_type): Record the use of typedefs. + +2012-09-27 Jakub Jelinek <jakub@redhat.com> + + * init.c (build_new_1): Don't test TREE_CONSTANT + of INTEGER_CST. + +2012-09-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54526 + * parser.c (cp_parser_template_id): In C++11 mode simply accept + X<::A>. + +2012-09-25 Zhenqiang Chen <zhenqiang.chen@linaro.org> + + PR c++/50970 + * typeck.c (cp_build_binary_op): Check side effects before generating + pfn and delta related expressions. + +2012-09-24 Lawrence Crowl <crowl@google.com> + + * init.c (build_new_1): Change to new double_int API. + * decl.c (build_enumerator): Likewise. + * typeck2.c (process_init_constructor_array): Likewise. + * mangle.c (write_array_type): Likewise. + +2012-09-24 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/50828 + * error.c (dump_function_decl): Strip TFF_TEMPLATE_NAME from flags + at the outset. + +2012-09-24 Jason Merrill <jason@redhat.com> + + * decl.c (get_atexit_node): Remove dead code. + + * Make-lang.in (cp/parser.o): Depend on decl.h. + 2012-09-20 Paolo Carlini <paolo.carlini@oracle.com> PR c++/52432 @@ -305,6 +389,14 @@ (ARGUMENT_PACK_INCOMPLETE_P): Use TREE_ADDRESSABLE instead of TREE_LANG_FLAG_0 on TREE_VECs. +2012-08-20 Florian Weimer <fweimer@redhat.com> + + PR c++/19351 + * call.c (build_operator_new_call): Add size_check argument and + evaluate it. + * cp-tree.h (build_operator_new_call): Adjust declaration. + * init.c (build_new_1): Compute array size check and apply it. + 2012-08-20 Paolo Carlini <paolo.carlini@oracle.com> PR c++/10416 diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index 6233f06c3f9..7b1d4e644cd 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -336,7 +336,7 @@ cp/optimize.o: cp/optimize.c $(CXX_TREE_H) $(TM_H) \ cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) $(REAL_H) \ gt-cp-mangle.h $(TARGET_H) $(TM_P_H) $(CGRAPH_H) cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) $(DIAGNOSTIC_CORE_H) \ - gt-cp-parser.h $(TARGET_H) $(PLUGIN_H) intl.h \ + gt-cp-parser.h $(TARGET_H) $(PLUGIN_H) intl.h cp/decl.h \ c-family/c-objc.h tree-pretty-print.h $(CXX_PARSER_H) $(TIMEVAR_H) cp/cp-gimplify.o: cp/cp-gimplify.c $(CXX_TREE_H) $(C_COMMON_H) \ $(TM_H) coretypes.h pointer-set.h tree-iterator.h $(SPLAY_TREE_H) diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 6f7e34669ce..d0492d8deef 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -8792,6 +8792,9 @@ set_up_extended_ref_temp (tree decl, tree expr, VEC(tree,gc) **cleanups, TARGET_EXPR_INITIAL (expr) = extend_ref_init_temps (decl, TARGET_EXPR_INITIAL (expr), cleanups); + /* Any reference temp has a non-trivial initializer. */ + DECL_NONTRIVIALLY_INITIALIZED_P (var) = true; + /* If the initializer is constant, put it in DECL_INITIAL so we get static initialization and use in constant expressions. */ init = maybe_constant_init (expr); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ded247d93d1..bfe7ad70e0c 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -56,7 +56,6 @@ c-common.h, not after. AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR) PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF, SCOPE_REF) PAREN_STRING_LITERAL (in STRING_CST) - DECL_PRETTY_FUNCTION_P (in VAR_DECL) KOENIG_LOOKUP_P (in CALL_EXPR) STATEMENT_LIST_NO_SCOPE (in STATEMENT_LIST). EXPR_STMT_STMT_EXPR_RESULT (in EXPR_STMT) @@ -203,6 +202,13 @@ c-common.h, not after. #define VAR_OR_FUNCTION_DECL_CHECK(NODE) \ TREE_CHECK2(NODE,VAR_DECL,FUNCTION_DECL) +#define TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK(NODE) \ + TREE_CHECK3(NODE,TYPE_DECL,TEMPLATE_DECL,FUNCTION_DECL) + +#define TYPE_FUNCTION_OR_TEMPLATE_DECL_P(NODE) \ + (TREE_CODE (NODE) == TYPE_DECL || TREE_CODE (NODE) == TEMPLATE_DECL \ + || TREE_CODE (NODE) == FUNCTION_DECL) + #define VAR_FUNCTION_OR_PARM_DECL_CHECK(NODE) \ TREE_CHECK3(NODE,VAR_DECL,FUNCTION_DECL,PARM_DECL) @@ -1876,8 +1882,8 @@ struct GTY(()) lang_decl_base { unsigned initialized_in_class : 1; /* var or fn */ unsigned repo_available_p : 1; /* var or fn */ unsigned threadprivate_or_deleted_p : 1; /* var or fn */ - unsigned anticipated_p : 1; /* fn or type */ - unsigned friend_attr : 1; /* fn or type */ + unsigned anticipated_p : 1; /* fn, type or template */ + unsigned friend_attr : 1; /* fn, type or template */ unsigned template_conv_p : 1; /* var or template */ unsigned odr_used : 1; /* var or fn */ unsigned u2sel : 1; @@ -2265,12 +2271,13 @@ struct GTY((variable_size)) lang_decl { /* Nonzero for a VAR_DECL means that the variable's initialization (if any) has been processed. (In general, DECL_INITIALIZED_P is - !DECL_EXTERN, but static data members may be initialized even if + !DECL_EXTERNAL, but static data members may be initialized even if not defined.) */ #define DECL_INITIALIZED_P(NODE) \ (TREE_LANG_FLAG_1 (VAR_DECL_CHECK (NODE))) -/* Nonzero for a VAR_DECL iff an explicit initializer was provided. */ +/* Nonzero for a VAR_DECL iff an explicit initializer was provided + or a non-trivial constructor is called. */ #define DECL_NONTRIVIALLY_INITIALIZED_P(NODE) \ (TREE_LANG_FLAG_3 (VAR_DECL_CHECK (NODE))) @@ -2294,7 +2301,9 @@ struct GTY((variable_size)) lang_decl { /* Nonzero for DECL means that this decl is just a friend declaration, and should not be added to the list of members for this class. */ -#define DECL_FRIEND_P(NODE) (DECL_LANG_SPECIFIC (NODE)->u.base.friend_attr) +#define DECL_FRIEND_P(NODE) \ + (DECL_LANG_SPECIFIC (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK (NODE)) \ + ->u.base.friend_attr) /* A TREE_LIST of the types which have befriended this FUNCTION_DECL. */ #define DECL_BEFRIENDING_CLASSES(NODE) \ @@ -2410,7 +2419,8 @@ struct GTY((variable_size)) lang_decl { /* Nonzero if this DECL is the __PRETTY_FUNCTION__ variable in a template function. */ #define DECL_PRETTY_FUNCTION_P(NODE) \ - (TREE_LANG_FLAG_0 (VAR_DECL_CHECK (NODE))) + (DECL_NAME (NODE) \ + && !strcmp (IDENTIFIER_POINTER (DECL_NAME (NODE)), "__PRETTY_FUNCTION__")) /* The _TYPE context in which this _DECL appears. This field holds the class where a virtual function instance is actually defined. */ @@ -3101,7 +3111,8 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) declared inside a class. In the latter case DECL_HIDDEN_FRIEND_P will be set. */ #define DECL_ANTICIPATED(NODE) \ - (DECL_LANG_SPECIFIC (DECL_COMMON_CHECK (NODE))->u.base.anticipated_p) + (DECL_LANG_SPECIFIC (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK (NODE)) \ + ->u.base.anticipated_p) /* Nonzero if NODE is a FUNCTION_DECL which was declared as a friend within a class but has not been declared in the surrounding scope. @@ -5149,7 +5160,8 @@ extern void determine_visibility (tree); extern void constrain_class_visibility (tree); extern void import_export_decl (tree); extern tree build_cleanup (tree); -extern tree build_offset_ref_call_from_tree (tree, VEC(tree,gc) **); +extern tree build_offset_ref_call_from_tree (tree, VEC(tree,gc) **, + tsubst_flags_t); extern bool decl_constant_var_p (tree); extern bool decl_maybe_constant_var_p (tree); extern void check_default_args (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6b5b986fee7..d0933efc8dd 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -617,26 +617,32 @@ poplevel (int keep, int reverse, int functionbody) /* Before we remove the declarations first check for unused variables. */ if ((warn_unused_variable || warn_unused_but_set_variable) && !processing_template_decl) - for (decl = getdecls (); decl; decl = TREE_CHAIN (decl)) - if (TREE_CODE (decl) == VAR_DECL - && (! TREE_USED (decl) || !DECL_READ_P (decl)) - && ! DECL_IN_SYSTEM_HEADER (decl) - && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl) - && TREE_TYPE (decl) != error_mark_node - && (!CLASS_TYPE_P (TREE_TYPE (decl)) - || !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))) - { - if (! TREE_USED (decl)) - warning (OPT_Wunused_variable, "unused variable %q+D", decl); - else if (DECL_CONTEXT (decl) == current_function_decl - && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE - && errorcount == unused_but_set_errorcount) - { - warning (OPT_Wunused_but_set_variable, - "variable %q+D set but not used", decl); - unused_but_set_errorcount = errorcount; - } - } + for (tree d = getdecls (); d; d = TREE_CHAIN (d)) + { + /* There are cases where D itself is a TREE_LIST. See in + push_local_binding where the list of decls returned by + getdecls is built. */ + decl = TREE_CODE (d) == TREE_LIST ? TREE_VALUE (d) : d; + if (TREE_CODE (decl) == VAR_DECL + && (! TREE_USED (decl) || !DECL_READ_P (decl)) + && ! DECL_IN_SYSTEM_HEADER (decl) + && DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl) + && TREE_TYPE (decl) != error_mark_node + && (!CLASS_TYPE_P (TREE_TYPE (decl)) + || !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))) + { + if (! TREE_USED (decl)) + warning (OPT_Wunused_variable, "unused variable %q+D", decl); + else if (DECL_CONTEXT (decl) == current_function_decl + && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE + && errorcount == unused_but_set_errorcount) + { + warning (OPT_Wunused_but_set_variable, + "variable %q+D set but not used", decl); + unused_but_set_errorcount = errorcount; + } + } + } /* Remove declarations for all the DECLs in this level. */ for (link = decls; link; link = TREE_CHAIN (link)) @@ -2673,8 +2679,7 @@ decl_jump_unsafe (tree decl) type = strip_array_types (type); - if (type_has_nontrivial_default_init (TREE_TYPE (decl)) - || DECL_NONTRIVIALLY_INITIALIZED_P (decl)) + if (DECL_NONTRIVIALLY_INITIALIZED_P (decl)) return 2; if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl))) @@ -3326,7 +3331,9 @@ make_typename_type (tree context, tree name, enum tag_types tag_type, if (DECL_ARTIFICIAL (t) || !(complain & tf_keep_type_decl)) t = TREE_TYPE (t); - + + maybe_record_typedef_use (t); + return t; } @@ -3821,7 +3828,6 @@ cp_make_fname_decl (location_t loc, tree id, int type_dep) /* As we're using pushdecl_with_scope, we must set the context. */ DECL_CONTEXT (decl) = current_function_decl; - DECL_PRETTY_FUNCTION_P (decl) = type_dep; TREE_STATIC (decl) = 1; TREE_READONLY (decl) = 1; @@ -5574,6 +5580,11 @@ check_initializer (tree decl, tree init, int flags, VEC(tree,gc) **cleanups) { init_code = build_aggr_init_full_exprs (decl, init, flags); + /* A constructor call is a non-trivial initializer even if + it isn't explicitly written. */ + if (TREE_SIDE_EFFECTS (init_code)) + DECL_NONTRIVIALLY_INITIALIZED_P (decl) = true; + /* If this is a constexpr initializer, expand_default_init will have returned an INIT_EXPR rather than a CALL_EXPR. In that case, pull the initializer back out and pass it down into @@ -6515,7 +6526,6 @@ get_atexit_node (void) fn_type = build_function_type_list (integer_type_node, argtype0, argtype1, argtype2, NULL_TREE); - fn_ptr_type = build_pointer_type (fn_type); if (use_aeabi_atexit) name = "__aeabi_atexit"; else @@ -12463,8 +12473,6 @@ build_enumerator (tree name, tree value, tree enumtype, location_t loc) { if (TYPE_VALUES (enumtype)) { - HOST_WIDE_INT hi; - unsigned HOST_WIDE_INT lo; tree prev_value; bool overflowed; @@ -12480,15 +12488,13 @@ build_enumerator (tree name, tree value, tree enumtype, location_t loc) value = error_mark_node; else { - overflowed = add_double (TREE_INT_CST_LOW (prev_value), - TREE_INT_CST_HIGH (prev_value), - 1, 0, &lo, &hi); + double_int di = TREE_INT_CST (prev_value) + .add_with_sign (double_int_one, + false, &overflowed); if (!overflowed) { - double_int di; tree type = TREE_TYPE (prev_value); - bool pos = (TYPE_UNSIGNED (type) || hi >= 0); - di.low = lo; di.high = hi; + bool pos = TYPE_UNSIGNED (type) || !di.is_negative (); if (!double_int_fits_to_tree_p (type, di)) { unsigned int itk; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 0df461340bc..9b1a5a1856d 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1104,6 +1104,11 @@ is_late_template_attribute (tree attr, tree decl) if (is_attribute_p ("weak", name)) return true; + /* Attribute unused is applied directly, as it appertains to + decls. */ + if (is_attribute_p ("unused", name)) + return false; + /* If any of the arguments are dependent expressions, we can't evaluate the attribute until instantiation time. */ for (arg = args; arg; arg = TREE_CHAIN (arg)) @@ -3693,9 +3698,9 @@ cp_write_global_declarations (void) cgraph_process_same_body_aliases (); /* Handle -fdump-ada-spec[-slim] */ - if (dump_enabled_p (TDI_ada)) + if (dump_initialized_p (TDI_ada)) { - if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM) + if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM) collect_source_ref (main_input_filename); else collect_source_refs (global_namespace); @@ -4082,7 +4087,8 @@ cp_write_global_declarations (void) ARGS. */ tree -build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args) +build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args, + tsubst_flags_t complain) { tree orig_fn; VEC(tree,gc) *orig_args = NULL; @@ -4110,7 +4116,7 @@ build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args) if (TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) { if (TREE_CODE (fn) == DOTSTAR_EXPR) - object = cp_build_addr_expr (object, tf_warning_or_error); + object = cp_build_addr_expr (object, complain); VEC_safe_insert (tree, gc, *args, 0, object); } /* Now that the arguments are done, transform FN. */ @@ -4125,17 +4131,17 @@ build_offset_ref_call_from_tree (tree fn, VEC(tree,gc) **args) void B::g() { (this->*p)(); } */ if (TREE_CODE (fn) == OFFSET_REF) { - tree object_addr = cp_build_addr_expr (object, tf_warning_or_error); + tree object_addr = cp_build_addr_expr (object, complain); fn = TREE_OPERAND (fn, 1); fn = get_member_function_from_ptrfunc (&object_addr, fn, - tf_warning_or_error); + complain); VEC_safe_insert (tree, gc, *args, 0, object_addr); } if (CLASS_TYPE_P (TREE_TYPE (fn))) - expr = build_op_call (fn, args, tf_warning_or_error); + expr = build_op_call (fn, args, complain); else - expr = cp_build_function_call_vec (fn, args, tf_warning_or_error); + expr = cp_build_function_call_vec (fn, args, complain); if (processing_template_decl && expr != error_mark_node) expr = build_min_non_dep_call_vec (expr, orig_fn, orig_args); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 30fa0182a8f..c8b614b165c 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1348,7 +1348,7 @@ dump_function_decl (tree t, int flags) return; } - flags &= ~TFF_UNQUALIFIED_NAME; + flags &= ~(TFF_UNQUALIFIED_NAME | TFF_TEMPLATE_NAME); if (TREE_CODE (t) == TEMPLATE_DECL) t = DECL_TEMPLATE_RESULT (t); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index d097443af55..40d0ce325f3 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2235,14 +2235,13 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, { tree inner_nelts = array_type_nelts_top (elt_type); tree inner_nelts_cst = maybe_constant_value (inner_nelts); - if (TREE_CONSTANT (inner_nelts_cst) - && TREE_CODE (inner_nelts_cst) == INTEGER_CST) - { - double_int result; - if (mul_double (TREE_INT_CST_LOW (inner_nelts_cst), - TREE_INT_CST_HIGH (inner_nelts_cst), - inner_nelts_count.low, inner_nelts_count.high, - &result.low, &result.high)) + if (TREE_CODE (inner_nelts_cst) == INTEGER_CST) + { + bool overflow; + double_int result = TREE_INT_CST (inner_nelts_cst) + .mul_with_sign (inner_nelts_count, + false, &overflow); + if (overflow) { if (complain & tf_error) error ("integer overflow in array size"); @@ -2344,8 +2343,8 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, /* Maximum available size in bytes. Half of the address space minus the cookie size. */ double_int max_size - = double_int_lshift (double_int_one, TYPE_PRECISION (sizetype) - 1, - HOST_BITS_PER_DOUBLE_INT, false); + = double_int_one.llshift (TYPE_PRECISION (sizetype) - 1, + HOST_BITS_PER_DOUBLE_INT); /* Size of the inner array elements. */ double_int inner_size; /* Maximum number of outer elements which can be allocated. */ @@ -2355,22 +2354,21 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, gcc_assert (TREE_CODE (size) == INTEGER_CST); cookie_size = targetm.cxx.get_cookie_size (elt_type); gcc_assert (TREE_CODE (cookie_size) == INTEGER_CST); - gcc_checking_assert (double_int_ucmp - (TREE_INT_CST (cookie_size), max_size) < 0); + gcc_checking_assert (TREE_INT_CST (cookie_size).ult (max_size)); /* Unconditionally substract the cookie size. This decreases the maximum object size and is safe even if we choose not to use a cookie after all. */ - max_size = double_int_sub (max_size, TREE_INT_CST (cookie_size)); - if (mul_double (TREE_INT_CST_LOW (size), TREE_INT_CST_HIGH (size), - inner_nelts_count.low, inner_nelts_count.high, - &inner_size.low, &inner_size.high) - || double_int_ucmp (inner_size, max_size) > 0) + max_size -= TREE_INT_CST (cookie_size); + bool overflow; + inner_size = TREE_INT_CST (size) + .mul_with_sign (inner_nelts_count, false, &overflow); + if (overflow || inner_size.ugt (max_size)) { if (complain & tf_error) error ("size of array is too large"); return error_mark_node; } - max_outer_nelts = double_int_udiv (max_size, inner_size, TRUNC_DIV_EXPR); + max_outer_nelts = max_size.udiv (inner_size, TRUNC_DIV_EXPR); /* Only keep the top-most seven bits, to simplify encoding the constant in the instruction stream. */ { @@ -2378,10 +2376,8 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, - (max_outer_nelts.high ? clz_hwi (max_outer_nelts.high) : (HOST_BITS_PER_WIDE_INT + clz_hwi (max_outer_nelts.low))); max_outer_nelts - = double_int_lshift (double_int_rshift - (max_outer_nelts, shift, - HOST_BITS_PER_DOUBLE_INT, false), - shift, HOST_BITS_PER_DOUBLE_INT, false); + = max_outer_nelts.lrshift (shift, HOST_BITS_PER_DOUBLE_INT) + .llshift (shift, HOST_BITS_PER_DOUBLE_INT); } max_outer_nelts_tree = double_int_to_tree (sizetype, max_outer_nelts); diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 469953a5365..13c658b29e2 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3119,12 +3119,11 @@ write_array_type (const tree type) { /* The ABI specifies that we should mangle the number of elements in the array, not the largest allowed index. */ - double_int dmax - = double_int_add (tree_to_double_int (max), double_int_one); + double_int dmax = tree_to_double_int (max) + double_int_one; /* Truncate the result - this will mangle [0, SIZE_INT_MAX] number of elements as zero. */ - dmax = double_int_zext (dmax, TYPE_PRECISION (TREE_TYPE (max))); - gcc_assert (double_int_fits_in_uhwi_p (dmax)); + dmax = dmax.zext (TYPE_PRECISION (TREE_TYPE (max))); + gcc_assert (dmax.fits_uhwi ()); write_unsigned_number (dmax.low); } else diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index e4e982764c3..cd328b31c72 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4174,6 +4174,7 @@ hidden_name_p (tree val) { if (DECL_P (val) && DECL_LANG_SPECIFIC (val) + && TYPE_FUNCTION_OR_TEMPLATE_DECL_P (val) && DECL_ANTICIPATED (val)) return true; return false; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e8c037885ef..155b51a180d 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5749,7 +5749,8 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, || TREE_CODE (postfix_expression) == MEMBER_REF || TREE_CODE (postfix_expression) == DOTSTAR_EXPR) postfix_expression = (build_offset_ref_call_from_tree - (postfix_expression, &args)); + (postfix_expression, &args, + tf_warning_or_error)); else if (idk == CP_ID_KIND_QUALIFIED) /* A call to a static class member, or a namespace-scope function. */ @@ -12479,9 +12480,11 @@ cp_parser_template_id (cp_parser *parser, return error_mark_node; } /* Otherwise, emit an error about the invalid digraph, but continue - parsing because we got our argument list. */ - if (permerror (next_token->location, - "%<<::%> cannot begin a template-argument list")) + parsing because we got our argument list. In C++11 do not emit + any error, per 2.5/3. */ + if (cxx_dialect < cxx0x + && permerror (next_token->location, + "%<<::%> cannot begin a template-argument list")) { static bool hint = false; inform (next_token->location, @@ -12489,8 +12492,9 @@ cp_parser_template_id (cp_parser *parser, " Insert whitespace between %<<%> and %<::%>"); if (!hint && !flag_permissive) { - inform (next_token->location, "(if you use %<-fpermissive%>" - " G++ will accept your code)"); + inform (next_token->location, "(if you use %<-fpermissive%> " + "or %<-std=c++11%>, or %<-std=gnu++11%> G++ will " + "accept your code)"); hint = true; } } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index d00470eec18..104d4dd6898 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13783,7 +13783,8 @@ tsubst_copy_and_build (tree t, mark_used (function); if (TREE_CODE (function) == OFFSET_REF) - ret = build_offset_ref_call_from_tree (function, &call_args); + ret = build_offset_ref_call_from_tree (function, &call_args, + complain); else if (TREE_CODE (function) == COMPONENT_REF) { tree instance = TREE_OPERAND (function, 0); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index ad4b0903d67..884f7d0573b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -4159,18 +4159,23 @@ cp_build_binary_op (location_t location, if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta) { - tree pfn0 = pfn_from_ptrmemfunc (op0); - tree delta0 = delta_from_ptrmemfunc (op0); - tree e1 = cp_build_binary_op (location, - EQ_EXPR, - pfn0, - build_zero_cst (TREE_TYPE (pfn0)), - complain); - tree e2 = cp_build_binary_op (location, - BIT_AND_EXPR, - delta0, - integer_one_node, - complain); + tree pfn0, delta0, e1, e2; + + if (TREE_SIDE_EFFECTS (op0)) + op0 = save_expr (op0); + + pfn0 = pfn_from_ptrmemfunc (op0); + delta0 = delta_from_ptrmemfunc (op0); + e1 = cp_build_binary_op (location, + EQ_EXPR, + pfn0, + build_zero_cst (TREE_TYPE (pfn0)), + complain); + e2 = cp_build_binary_op (location, + BIT_AND_EXPR, + delta0, + integer_one_node, + complain); if ((complain & tf_warning) && c_inhibit_evaluation_warnings == 0 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 58b2db679a3..3dbfcb6663a 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1058,14 +1058,12 @@ process_init_constructor_array (tree type, tree init, { tree domain = TYPE_DOMAIN (type); if (domain) - len = double_int_ext - (double_int_add - (double_int_sub - (tree_to_double_int (TYPE_MAX_VALUE (domain)), - tree_to_double_int (TYPE_MIN_VALUE (domain))), - double_int_one), - TYPE_PRECISION (TREE_TYPE (domain)), - TYPE_UNSIGNED (TREE_TYPE (domain))).low; + len = (tree_to_double_int (TYPE_MAX_VALUE (domain)) + - tree_to_double_int (TYPE_MIN_VALUE (domain)) + + double_int_one) + .ext (TYPE_PRECISION (TREE_TYPE (domain)), + TYPE_UNSIGNED (TREE_TYPE (domain))) + .low; else unbounded = true; /* Take as many as there are. */ } |