LEFT | RIGHT |
1 /* Functions related to invoking methods and overloaded functions. | 1 /* Functions related to invoking methods and overloaded functions. |
2 Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, | 2 Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, | 3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
4 2010, 2011, 2012 | 4 2010, 2011, 2012 |
5 Free Software Foundation, Inc. | 5 Free Software Foundation, Inc. |
6 Contributed by Michael Tiemann (tiemann@cygnus.com) and | 6 Contributed by Michael Tiemann (tiemann@cygnus.com) and |
7 modified by Brendan Kehoe (brendan@cygnus.com). | 7 modified by Brendan Kehoe (brendan@cygnus.com). |
8 | 8 |
9 This file is part of GCC. | 9 This file is part of GCC. |
10 | 10 |
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 from = TREE_TYPE (from); | 1089 from = TREE_TYPE (from); |
1090 } | 1090 } |
1091 qualified_to = to; | 1091 qualified_to = to; |
1092 to = strip_top_quals (to); | 1092 to = strip_top_quals (to); |
1093 from = strip_top_quals (from); | 1093 from = strip_top_quals (from); |
1094 | 1094 |
1095 if ((TYPE_PTRFN_P (to) || TYPE_PTRMEMFUNC_P (to)) | 1095 if ((TYPE_PTRFN_P (to) || TYPE_PTRMEMFUNC_P (to)) |
1096 && expr && type_unknown_p (expr)) | 1096 && expr && type_unknown_p (expr)) |
1097 { | 1097 { |
1098 tsubst_flags_t tflags = tf_conv; | 1098 tsubst_flags_t tflags = tf_conv; |
1099 if (!(flags & LOOKUP_PROTECT)) | |
1100 tflags |= tf_no_access_control; | |
1101 expr = instantiate_type (to, expr, tflags); | 1099 expr = instantiate_type (to, expr, tflags); |
1102 if (expr == error_mark_node) | 1100 if (expr == error_mark_node) |
1103 return NULL; | 1101 return NULL; |
1104 from = TREE_TYPE (expr); | 1102 from = TREE_TYPE (expr); |
1105 } | 1103 } |
1106 | 1104 |
1107 fcode = TREE_CODE (from); | 1105 fcode = TREE_CODE (from); |
1108 tcode = TREE_CODE (to); | 1106 tcode = TREE_CODE (to); |
1109 | 1107 |
1110 conv = build_identity_conv (from, expr); | 1108 conv = build_identity_conv (from, expr); |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 if (from == error_mark_node || to == error_mark_node | 1687 if (from == error_mark_node || to == error_mark_node |
1690 || expr == error_mark_node) | 1688 || expr == error_mark_node) |
1691 return NULL; | 1689 return NULL; |
1692 | 1690 |
1693 /* Other flags only apply to the primary function in overload | 1691 /* Other flags only apply to the primary function in overload |
1694 resolution, or after we've chosen one. */ | 1692 resolution, or after we've chosen one. */ |
1695 flags &= (LOOKUP_ONLYCONVERTING|LOOKUP_NO_CONVERSION|LOOKUP_COPY_PARM | 1693 flags &= (LOOKUP_ONLYCONVERTING|LOOKUP_NO_CONVERSION|LOOKUP_COPY_PARM |
1696 |LOOKUP_NO_TEMP_BIND|LOOKUP_NO_RVAL_BIND|LOOKUP_PREFER_RVALUE | 1694 |LOOKUP_NO_TEMP_BIND|LOOKUP_NO_RVAL_BIND|LOOKUP_PREFER_RVALUE |
1697 |LOOKUP_NO_NARROWING|LOOKUP_PROTECT); | 1695 |LOOKUP_NO_NARROWING|LOOKUP_PROTECT); |
1698 | 1696 |
| 1697 /* FIXME: actually we don't want warnings either, but we can't just |
| 1698 have 'complain &= ~(tf_warning|tf_error)' because it would cause |
| 1699 the regression of, eg, g++.old-deja/g++.benjamin/16077.C. |
| 1700 We really ought not to issue that warning until we've committed |
| 1701 to that conversion. */ |
| 1702 complain &= ~tf_error; |
| 1703 |
1699 if (TREE_CODE (to) == REFERENCE_TYPE) | 1704 if (TREE_CODE (to) == REFERENCE_TYPE) |
1700 conv = reference_binding (to, from, expr, c_cast_p, flags, complain); | 1705 conv = reference_binding (to, from, expr, c_cast_p, flags, complain); |
1701 else | 1706 else |
1702 conv = standard_conversion (to, from, expr, c_cast_p, flags); | 1707 conv = standard_conversion (to, from, expr, c_cast_p, flags); |
1703 | 1708 |
1704 if (conv) | 1709 if (conv) |
1705 return conv; | 1710 return conv; |
1706 | 1711 |
1707 if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr)) | 1712 if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr)) |
1708 { | 1713 { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1913 goto out; | 1918 goto out; |
1914 | 1919 |
1915 /* Second, for F to be a viable function, there shall exist for each | 1920 /* Second, for F to be a viable function, there shall exist for each |
1916 argument an implicit conversion sequence that converts that argument | 1921 argument an implicit conversion sequence that converts that argument |
1917 to the corresponding parameter of F. */ | 1922 to the corresponding parameter of F. */ |
1918 | 1923 |
1919 parmnode = parmlist; | 1924 parmnode = parmlist; |
1920 | 1925 |
1921 for (i = 0; i < len; ++i) | 1926 for (i = 0; i < len; ++i) |
1922 { | 1927 { |
1923 tree arg, argtype, to_type; | 1928 tree argtype, to_type; |
| 1929 tree arg; |
1924 conversion *t; | 1930 conversion *t; |
1925 int is_this; | 1931 int is_this; |
1926 | 1932 |
1927 if (parmnode == void_list_node) | 1933 if (parmnode == void_list_node) |
1928 break; | 1934 break; |
1929 | 1935 |
1930 if (i == 0 && first_arg != NULL_TREE) | 1936 if (i == 0 && first_arg != NULL_TREE) |
1931 arg = first_arg; | 1937 arg = first_arg; |
1932 else | 1938 else |
1933 » arg = VEC_index (tree, args, | 1939 » arg = CONST_CAST_TREE ( |
1934 » » » i + skip - (first_arg != NULL_TREE ? 1 : 0)); | 1940 » » VEC_index (tree, args, |
| 1941 » » » i + skip - (first_arg != NULL_TREE ? 1 : 0))); |
1935 argtype = lvalue_type (arg); | 1942 argtype = lvalue_type (arg); |
1936 | 1943 |
1937 is_this = (i == 0 && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn) | 1944 is_this = (i == 0 && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn) |
1938 && ! DECL_CONSTRUCTOR_P (fn)); | 1945 && ! DECL_CONSTRUCTOR_P (fn)); |
1939 | 1946 |
1940 if (parmnode) | 1947 if (parmnode) |
1941 { | 1948 { |
1942 tree parmtype = TREE_VALUE (parmnode); | 1949 tree parmtype = TREE_VALUE (parmnode); |
1943 int lflags = flags; | 1950 int lflags = flags; |
1944 | 1951 |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3601 if (!any_viable_p) | 3608 if (!any_viable_p) |
3602 { | 3609 { |
3603 if (args) | 3610 if (args) |
3604 release_tree_vector (args); | 3611 release_tree_vector (args); |
3605 return NULL; | 3612 return NULL; |
3606 } | 3613 } |
3607 | 3614 |
3608 cand = tourney (candidates, complain); | 3615 cand = tourney (candidates, complain); |
3609 if (cand == 0) | 3616 if (cand == 0) |
3610 { | 3617 { |
3611 if ((flags & LOOKUP_COMPLAIN) | 3618 if (complain & tf_error) |
3612 » && (complain & tf_error)) | |
3613 { | 3619 { |
3614 error ("conversion from %qT to %qT is ambiguous", | 3620 error ("conversion from %qT to %qT is ambiguous", |
3615 fromtype, totype); | 3621 fromtype, totype); |
3616 print_z_candidates (location_of (expr), candidates); | 3622 print_z_candidates (location_of (expr), candidates); |
3617 } | 3623 } |
3618 | 3624 |
3619 cand = candidates; /* any one will do */ | 3625 cand = candidates; /* any one will do */ |
3620 cand->second_conv = build_ambiguous_conv (totype, expr); | 3626 cand->second_conv = build_ambiguous_conv (totype, expr); |
3621 cand->second_conv->user_conv_p = true; | 3627 cand->second_conv->user_conv_p = true; |
3622 if (!any_strictly_viable (candidates)) | 3628 if (!any_strictly_viable (candidates)) |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4363 tsubst_flags_t complain) | 4369 tsubst_flags_t complain) |
4364 { | 4370 { |
4365 tree arg2_type; | 4371 tree arg2_type; |
4366 tree arg3_type; | 4372 tree arg3_type; |
4367 tree result = NULL_TREE; | 4373 tree result = NULL_TREE; |
4368 tree result_type = NULL_TREE; | 4374 tree result_type = NULL_TREE; |
4369 bool lvalue_p = true; | 4375 bool lvalue_p = true; |
4370 struct z_candidate *candidates = 0; | 4376 struct z_candidate *candidates = 0; |
4371 struct z_candidate *cand; | 4377 struct z_candidate *cand; |
4372 void *p; | 4378 void *p; |
| 4379 tree orig_arg2, orig_arg3; |
4373 | 4380 |
4374 /* As a G++ extension, the second argument to the conditional can be | 4381 /* As a G++ extension, the second argument to the conditional can be |
4375 omitted. (So that `a ? : c' is roughly equivalent to `a ? a : | 4382 omitted. (So that `a ? : c' is roughly equivalent to `a ? a : |
4376 c'.) If the second operand is omitted, make sure it is | 4383 c'.) If the second operand is omitted, make sure it is |
4377 calculated only once. */ | 4384 calculated only once. */ |
4378 if (!arg2) | 4385 if (!arg2) |
4379 { | 4386 { |
4380 if (complain & tf_error) | 4387 if (complain & tf_error) |
4381 pedwarn (input_location, OPT_Wpedantic,· | 4388 pedwarn (input_location, OPT_Wpedantic,· |
4382 "ISO C++ forbids omitting the middle term of a ?: expression"); | 4389 "ISO C++ forbids omitting the middle term of a ?: expression"); |
(...skipping 19 matching lines...) Expand all Loading... |
4402 || error_operand_p (arg3)) | 4409 || error_operand_p (arg3)) |
4403 return error_mark_node; | 4410 return error_mark_node; |
4404 | 4411 |
4405 /* [expr.cond] | 4412 /* [expr.cond] |
4406 | 4413 |
4407 If either the second or the third operand has type (possibly | 4414 If either the second or the third operand has type (possibly |
4408 cv-qualified) void, then the lvalue-to-rvalue (_conv.lval_), | 4415 cv-qualified) void, then the lvalue-to-rvalue (_conv.lval_), |
4409 array-to-pointer (_conv.array_), and function-to-pointer | 4416 array-to-pointer (_conv.array_), and function-to-pointer |
4410 (_conv.func_) standard conversions are performed on the second | 4417 (_conv.func_) standard conversions are performed on the second |
4411 and third operands. */ | 4418 and third operands. */ |
| 4419 orig_arg2 = arg2; |
| 4420 orig_arg3 = arg3; |
4412 arg2_type = unlowered_expr_type (arg2); | 4421 arg2_type = unlowered_expr_type (arg2); |
4413 arg3_type = unlowered_expr_type (arg3); | 4422 arg3_type = unlowered_expr_type (arg3); |
4414 if (VOID_TYPE_P (arg2_type) || VOID_TYPE_P (arg3_type)) | 4423 if (VOID_TYPE_P (arg2_type) || VOID_TYPE_P (arg3_type)) |
4415 { | 4424 { |
4416 /* Do the conversions. We don't these for `void' type arguments | 4425 /* Do the conversions. We don't these for `void' type arguments |
4417 since it can't have any effect and since decay_conversion | 4426 since it can't have any effect and since decay_conversion |
4418 does not handle that case gracefully. */ | 4427 does not handle that case gracefully. */ |
4419 if (!VOID_TYPE_P (arg2_type)) | 4428 if (!VOID_TYPE_P (arg2_type)) |
4420 arg2 = decay_conversion (arg2, complain); | 4429 arg2 = decay_conversion (arg2, complain); |
4421 if (!VOID_TYPE_P (arg3_type)) | 4430 if (!VOID_TYPE_P (arg3_type)) |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4699 result_type = type_after_usual_arithmetic_conversions (arg2_type, | 4708 result_type = type_after_usual_arithmetic_conversions (arg2_type, |
4700 arg3_type); | 4709 arg3_type); |
4701 do_warn_double_promotion (result_type, arg2_type, arg3_type, | 4710 do_warn_double_promotion (result_type, arg2_type, arg3_type, |
4702 "implicit conversion from %qT to %qT to " | 4711 "implicit conversion from %qT to %qT to " |
4703 "match other result of conditional", | 4712 "match other result of conditional", |
4704 input_location); | 4713 input_location); |
4705 | 4714 |
4706 if (TREE_CODE (arg2_type) == ENUMERAL_TYPE | 4715 if (TREE_CODE (arg2_type) == ENUMERAL_TYPE |
4707 && TREE_CODE (arg3_type) == ENUMERAL_TYPE) | 4716 && TREE_CODE (arg3_type) == ENUMERAL_TYPE) |
4708 { | 4717 { |
4709 if (complain & tf_warning) | 4718 » if (TREE_CODE (orig_arg2) == CONST_DECL |
| 4719 » && TREE_CODE (orig_arg3) == CONST_DECL |
| 4720 » && DECL_CONTEXT (orig_arg2) == DECL_CONTEXT (orig_arg3)) |
| 4721 » /* Two enumerators from the same enumeration can have different |
| 4722 » types when the enumeration is still being defined. */; |
| 4723 else if (complain & tf_warning) |
4710 warning (OPT_Wenum_compare,· | 4724 warning (OPT_Wenum_compare,· |
4711 "enumeral mismatch in conditional expression: %qT vs %qT", | 4725 "enumeral mismatch in conditional expression: %qT vs %qT", |
4712 arg2_type, arg3_type); | 4726 arg2_type, arg3_type); |
4713 } | 4727 } |
4714 else if (extra_warnings | 4728 else if (extra_warnings |
4715 && ((TREE_CODE (arg2_type) == ENUMERAL_TYPE | 4729 && ((TREE_CODE (arg2_type) == ENUMERAL_TYPE |
4716 && !same_type_p (arg3_type, type_promotes_to (arg2_type))) | 4730 && !same_type_p (arg3_type, type_promotes_to (arg2_type))) |
4717 || (TREE_CODE (arg3_type) == ENUMERAL_TYPE | 4731 || (TREE_CODE (arg3_type) == ENUMERAL_TYPE |
4718 && !same_type_p (arg2_type, type_promotes_to (arg3_type))
))) | 4732 && !same_type_p (arg2_type, type_promotes_to (arg3_type))
))) |
4719 { | 4733 { |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5102 case POSTDECREMENT_EXPR: | 5116 case POSTDECREMENT_EXPR: |
5103 /* Don't try anything fancy if we're not allowed to produce | 5117 /* Don't try anything fancy if we're not allowed to produce |
5104 errors. */ | 5118 errors. */ |
5105 if (!(complain & tf_error)) | 5119 if (!(complain & tf_error)) |
5106 return error_mark_node; | 5120 return error_mark_node; |
5107 | 5121 |
5108 /* Look for an `operator++ (int)'. Pre-1985 C++ didn't | 5122 /* Look for an `operator++ (int)'. Pre-1985 C++ didn't |
5109 distinguish between prefix and postfix ++ and | 5123 distinguish between prefix and postfix ++ and |
5110 operator++() was used for both, so we allow this with | 5124 operator++() was used for both, so we allow this with |
5111 -fpermissive. */ | 5125 -fpermissive. */ |
5112 » if (flags & LOOKUP_COMPLAIN) | 5126 » else |
5113 { | 5127 { |
5114 const char *msg = (flag_permissive)· | 5128 const char *msg = (flag_permissive)· |
5115 ? G_("no %<%D(int)%> declared for postfix %qs," | 5129 ? G_("no %<%D(int)%> declared for postfix %qs," |
5116 " trying prefix operator instead") | 5130 " trying prefix operator instead") |
5117 : G_("no %<%D(int)%> declared for postfix %qs"); | 5131 : G_("no %<%D(int)%> declared for postfix %qs"); |
5118 permerror (loc, msg, fnname, operator_name_info[code].name); | 5132 permerror (loc, msg, fnname, operator_name_info[code].name); |
5119 } | 5133 } |
5120 | 5134 |
5121 if (!flag_permissive) | 5135 if (!flag_permissive) |
5122 return error_mark_node; | 5136 return error_mark_node; |
5123 | 5137 |
5124 if (code == POSTINCREMENT_EXPR) | 5138 if (code == POSTINCREMENT_EXPR) |
5125 code = PREINCREMENT_EXPR; | 5139 code = PREINCREMENT_EXPR; |
5126 else | 5140 else |
5127 code = PREDECREMENT_EXPR; | 5141 code = PREDECREMENT_EXPR; |
5128 result = build_new_op_1 (loc, code, flags, arg1, NULL_TREE, | 5142 result = build_new_op_1 (loc, code, flags, arg1, NULL_TREE, |
5129 NULL_TREE, overload, complain); | 5143 NULL_TREE, overload, complain); |
5130 break; | 5144 break; |
5131 | 5145 |
5132 /* The caller will deal with these. */ | 5146 /* The caller will deal with these. */ |
5133 case ADDR_EXPR: | 5147 case ADDR_EXPR: |
5134 case COMPOUND_EXPR: | 5148 case COMPOUND_EXPR: |
5135 case COMPONENT_REF: | 5149 case COMPONENT_REF: |
5136 result = NULL_TREE; | 5150 result = NULL_TREE; |
5137 result_valid_p = true; | 5151 result_valid_p = true; |
5138 break; | 5152 break; |
5139 | 5153 |
5140 default: | 5154 default: |
5141 » if ((flags & LOOKUP_COMPLAIN) && (complain & tf_error)) | 5155 » if (complain & tf_error) |
5142 { | 5156 { |
5143 /* If one of the arguments of the operator represents | 5157 /* If one of the arguments of the operator represents |
5144 an invalid use of member function pointer, try to report | 5158 an invalid use of member function pointer, try to report |
5145 a meaningful error ... */ | 5159 a meaningful error ... */ |
5146 if (invalid_nonstatic_memfn_p (arg1, tf_error) | 5160 if (invalid_nonstatic_memfn_p (arg1, tf_error) |
5147 || invalid_nonstatic_memfn_p (arg2, tf_error) | 5161 || invalid_nonstatic_memfn_p (arg2, tf_error) |
5148 || invalid_nonstatic_memfn_p (arg3, tf_error)) | 5162 || invalid_nonstatic_memfn_p (arg3, tf_error)) |
5149 /* We displayed the error message. */; | 5163 /* We displayed the error message. */; |
5150 else | 5164 else |
5151 { | 5165 { |
5152 /* ... Otherwise, report the more generic | 5166 /* ... Otherwise, report the more generic |
5153 "no matching operator found" error */ | 5167 "no matching operator found" error */ |
5154 op_error (loc, code, code2, arg1, arg2, arg3, FALSE); | 5168 op_error (loc, code, code2, arg1, arg2, arg3, FALSE); |
5155 print_z_candidates (loc, candidates); | 5169 print_z_candidates (loc, candidates); |
5156 } | 5170 } |
5157 } | 5171 } |
5158 result = error_mark_node; | 5172 result = error_mark_node; |
5159 break; | 5173 break; |
5160 } | 5174 } |
5161 } | 5175 } |
5162 else | 5176 else |
5163 { | 5177 { |
5164 cand = tourney (candidates, complain); | 5178 cand = tourney (candidates, complain); |
5165 if (cand == 0) | 5179 if (cand == 0) |
5166 { | 5180 { |
5167 » if ((flags & LOOKUP_COMPLAIN) && (complain & tf_error)) | 5181 » if (complain & tf_error) |
5168 { | 5182 { |
5169 op_error (loc, code, code2, arg1, arg2, arg3, TRUE); | 5183 op_error (loc, code, code2, arg1, arg2, arg3, TRUE); |
5170 print_z_candidates (loc, candidates); | 5184 print_z_candidates (loc, candidates); |
5171 } | 5185 } |
5172 result = error_mark_node; | 5186 result = error_mark_node; |
5173 } | 5187 } |
5174 else if (TREE_CODE (cand->fn) == FUNCTION_DECL) | 5188 else if (TREE_CODE (cand->fn) == FUNCTION_DECL) |
5175 { | 5189 { |
5176 if (overload) | 5190 if (overload) |
5177 *overload = cand->fn; | 5191 *overload = cand->fn; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5219 don't cause errors. This should not remove any important | 5233 don't cause errors. This should not remove any important |
5220 conversions, because builtins don't apply to class | 5234 conversions, because builtins don't apply to class |
5221 objects directly. */ | 5235 objects directly. */ |
5222 conv = cand->convs[0]; | 5236 conv = cand->convs[0]; |
5223 if (conv->kind == ck_ref_bind) | 5237 if (conv->kind == ck_ref_bind) |
5224 conv = next_conversion (conv); | 5238 conv = next_conversion (conv); |
5225 arg1 = convert_like (conv, arg1, complain); | 5239 arg1 = convert_like (conv, arg1, complain); |
5226 | 5240 |
5227 if (arg2) | 5241 if (arg2) |
5228 { | 5242 { |
| 5243 conv = cand->convs[1]; |
| 5244 if (conv->kind == ck_ref_bind) |
| 5245 conv = next_conversion (conv); |
| 5246 else |
| 5247 arg2 = decay_conversion (arg2, complain); |
| 5248 |
5229 /* We need to call warn_logical_operator before | 5249 /* We need to call warn_logical_operator before |
5230 » » converting arg2 to a boolean_type. */ | 5250 » » converting arg2 to a boolean_type, but after |
| 5251 » » decaying an enumerator to its value. */ |
5231 if (complain & tf_warning) | 5252 if (complain & tf_warning) |
5232 warn_logical_operator (loc, code, boolean_type_node, | 5253 warn_logical_operator (loc, code, boolean_type_node, |
5233 code_orig_arg1, arg1, | 5254 code_orig_arg1, arg1, |
5234 code_orig_arg2, arg2); | 5255 code_orig_arg2, arg2); |
5235 | 5256 |
5236 conv = cand->convs[1]; | |
5237 if (conv->kind == ck_ref_bind) | |
5238 conv = next_conversion (conv); | |
5239 arg2 = convert_like (conv, arg2, complain); | 5257 arg2 = convert_like (conv, arg2, complain); |
5240 } | 5258 } |
5241 if (arg3) | 5259 if (arg3) |
5242 { | 5260 { |
5243 conv = cand->convs[2]; | 5261 conv = cand->convs[2]; |
5244 if (conv->kind == ck_ref_bind) | 5262 if (conv->kind == ck_ref_bind) |
5245 conv = next_conversion (conv); | 5263 conv = next_conversion (conv); |
5246 arg3 = convert_like (conv, arg3, complain); | 5264 arg3 = convert_like (conv, arg3, complain); |
5247 } | 5265 } |
5248 | 5266 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5383 | 5401 |
5384 If this call to "operator delete" is being generated as part to | 5402 If this call to "operator delete" is being generated as part to |
5385 deallocate memory allocated via a new-expression (as per [expr.new] | 5403 deallocate memory allocated via a new-expression (as per [expr.new] |
5386 which requires that if the initialization throws an exception then | 5404 which requires that if the initialization throws an exception then |
5387 we call a deallocation function), then ALLOC_FN is the allocation | 5405 we call a deallocation function), then ALLOC_FN is the allocation |
5388 function. */ | 5406 function. */ |
5389 | 5407 |
5390 tree | 5408 tree |
5391 build_op_delete_call (enum tree_code code, tree addr, tree size, | 5409 build_op_delete_call (enum tree_code code, tree addr, tree size, |
5392 bool global_p, tree placement, | 5410 bool global_p, tree placement, |
5393 » » tree alloc_fn) | 5411 » » tree alloc_fn, tsubst_flags_t complain) |
5394 { | 5412 { |
5395 tree fn = NULL_TREE; | 5413 tree fn = NULL_TREE; |
5396 tree fns, fnname, type, t; | 5414 tree fns, fnname, type, t; |
5397 | 5415 |
5398 if (addr == error_mark_node) | 5416 if (addr == error_mark_node) |
5399 return error_mark_node; | 5417 return error_mark_node; |
5400 | 5418 |
5401 type = strip_array_types (TREE_TYPE (TREE_TYPE (addr))); | 5419 type = strip_array_types (TREE_TYPE (TREE_TYPE (addr))); |
5402 | 5420 |
5403 fnname = ansi_opname (code); | 5421 fnname = ansi_opname (code); |
(...skipping 13 matching lines...) Expand all Loading... |
5417 if (fns == error_mark_node) | 5435 if (fns == error_mark_node) |
5418 return error_mark_node; | 5436 return error_mark_node; |
5419 } | 5437 } |
5420 else | 5438 else |
5421 fns = NULL_TREE; | 5439 fns = NULL_TREE; |
5422 | 5440 |
5423 if (fns == NULL_TREE) | 5441 if (fns == NULL_TREE) |
5424 fns = lookup_name_nonclass (fnname); | 5442 fns = lookup_name_nonclass (fnname); |
5425 | 5443 |
5426 /* Strip const and volatile from addr. */ | 5444 /* Strip const and volatile from addr. */ |
5427 addr = cp_convert (ptr_type_node, addr); | 5445 addr = cp_convert (ptr_type_node, addr, complain); |
5428 | 5446 |
5429 if (placement) | 5447 if (placement) |
5430 { | 5448 { |
5431 /* "A declaration of a placement deallocation function matches the | 5449 /* "A declaration of a placement deallocation function matches the |
5432 declaration of a placement allocation function if it has the same | 5450 declaration of a placement allocation function if it has the same |
5433 number of parameters and, after parameter transformations (8.3.5), | 5451 number of parameters and, after parameter transformations (8.3.5), |
5434 all parameter types except the first are identical." | 5452 all parameter types except the first are identical." |
5435 | 5453 |
5436 So we build up the function type we want and ask instantiate_type | 5454 So we build up the function type we want and ask instantiate_type |
5437 to get it for us. */ | 5455 to get it for us. */ |
(...skipping 18 matching lines...) Expand all Loading... |
5456 the usual deallocation function, so we shouldn't complain | 5474 the usual deallocation function, so we shouldn't complain |
5457 about using the operator delete (void *, size_t). */ | 5475 about using the operator delete (void *, size_t). */ |
5458 for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; | 5476 for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; |
5459 t; t = OVL_NEXT (t)) | 5477 t; t = OVL_NEXT (t)) |
5460 { | 5478 { |
5461 tree elt = OVL_CURRENT (t); | 5479 tree elt = OVL_CURRENT (t); |
5462 if (non_placement_deallocation_fn_p (elt) | 5480 if (non_placement_deallocation_fn_p (elt) |
5463 && FUNCTION_ARG_CHAIN (elt) == void_list_node) | 5481 && FUNCTION_ARG_CHAIN (elt) == void_list_node) |
5464 goto ok; | 5482 goto ok; |
5465 } | 5483 } |
5466 » permerror (0, "non-placement deallocation function %q+D", fn); | 5484 » if (complain & tf_error) |
5467 » permerror (input_location, "selected for placement delete"); | 5485 » { |
| 5486 » permerror (0, "non-placement deallocation function %q+D", fn); |
| 5487 » permerror (input_location, "selected for placement delete"); |
| 5488 » } |
| 5489 » else |
| 5490 » return error_mark_node; |
5468 ok:; | 5491 ok:; |
5469 } | 5492 } |
5470 } | 5493 } |
5471 else | 5494 else |
5472 /* "Any non-placement deallocation function matches a non-placement | 5495 /* "Any non-placement deallocation function matches a non-placement |
5473 allocation function. If the lookup finds a single matching | 5496 allocation function. If the lookup finds a single matching |
5474 deallocation function, that function will be called; otherwise, no | 5497 deallocation function, that function will be called; otherwise, no |
5475 deallocation function will be called." */ | 5498 deallocation function will be called." */ |
5476 for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; | 5499 for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; |
5477 t; t = OVL_NEXT (t)) | 5500 t; t = OVL_NEXT (t)) |
(...skipping 18 matching lines...) Expand all Loading... |
5496 } | 5519 } |
5497 | 5520 |
5498 /* If we have a matching function, call it. */ | 5521 /* If we have a matching function, call it. */ |
5499 if (fn) | 5522 if (fn) |
5500 { | 5523 { |
5501 gcc_assert (TREE_CODE (fn) == FUNCTION_DECL); | 5524 gcc_assert (TREE_CODE (fn) == FUNCTION_DECL); |
5502 | 5525 |
5503 /* If the FN is a member function, make sure that it is | 5526 /* If the FN is a member function, make sure that it is |
5504 accessible. */ | 5527 accessible. */ |
5505 if (BASELINK_P (fns)) | 5528 if (BASELINK_P (fns)) |
5506 » perform_or_defer_access_check (BASELINK_BINFO (fns), fn, fn); | 5529 » perform_or_defer_access_check (BASELINK_BINFO (fns), fn, fn, |
| 5530 » » » » complain); |
5507 | 5531 |
5508 /* Core issue 901: It's ok to new a type with deleted delete. */ | 5532 /* Core issue 901: It's ok to new a type with deleted delete. */ |
5509 if (DECL_DELETED_FN (fn) && alloc_fn) | 5533 if (DECL_DELETED_FN (fn) && alloc_fn) |
5510 return NULL_TREE; | 5534 return NULL_TREE; |
5511 | 5535 |
5512 if (placement) | 5536 if (placement) |
5513 { | 5537 { |
5514 /* The placement args might not be suitable for overload | 5538 /* The placement args might not be suitable for overload |
5515 resolution at this point, so build the call directly. */ | 5539 resolution at this point, so build the call directly. */ |
5516 int nargs = call_expr_nargs (placement); | 5540 int nargs = call_expr_nargs (placement); |
5517 tree *argarray = XALLOCAVEC (tree, nargs); | 5541 tree *argarray = XALLOCAVEC (tree, nargs); |
5518 int i; | 5542 int i; |
5519 argarray[0] = addr; | 5543 argarray[0] = addr; |
5520 for (i = 1; i < nargs; i++) | 5544 for (i = 1; i < nargs; i++) |
5521 argarray[i] = CALL_EXPR_ARG (placement, i); | 5545 argarray[i] = CALL_EXPR_ARG (placement, i); |
5522 mark_used (fn); | 5546 mark_used (fn); |
5523 return build_cxx_call (fn, nargs, argarray); | 5547 return build_cxx_call (fn, nargs, argarray); |
5524 } | 5548 } |
5525 else | 5549 else |
5526 { | 5550 { |
5527 tree ret; | 5551 tree ret; |
5528 VEC(tree,gc) *args = VEC_alloc (tree, gc, 2); | 5552 VEC(tree,gc) *args = VEC_alloc (tree, gc, 2); |
5529 VEC_quick_push (tree, args, addr); | 5553 VEC_quick_push (tree, args, addr); |
5530 if (FUNCTION_ARG_CHAIN (fn) != void_list_node) | 5554 if (FUNCTION_ARG_CHAIN (fn) != void_list_node) |
5531 VEC_quick_push (tree, args, size); | 5555 VEC_quick_push (tree, args, size); |
5532 » ret = cp_build_function_call_vec (fn, &args, tf_warning_or_error); | 5556 » ret = cp_build_function_call_vec (fn, &args, complain); |
5533 VEC_free (tree, gc, args); | 5557 VEC_free (tree, gc, args); |
5534 return ret; | 5558 return ret; |
5535 } | 5559 } |
5536 } | 5560 } |
5537 | 5561 |
5538 /* [expr.new] | 5562 /* [expr.new] |
5539 | 5563 |
5540 If no unambiguous matching deallocation function can be found, | 5564 If no unambiguous matching deallocation function can be found, |
5541 propagating the exception does not cause the object's memory to | 5565 propagating the exception does not cause the object's memory to |
5542 be freed. */ | 5566 be freed. */ |
5543 if (alloc_fn) | 5567 if (alloc_fn) |
5544 { | 5568 { |
5545 if (!placement) | 5569 if ((complain & tf_warning) |
| 5570 » && !placement) |
5546 warning (0, "no corresponding deallocation function for %qD", | 5571 warning (0, "no corresponding deallocation function for %qD", |
5547 alloc_fn); | 5572 alloc_fn); |
5548 return NULL_TREE; | 5573 return NULL_TREE; |
5549 } | 5574 } |
5550 | 5575 |
5551 error ("no suitable %<operator %s%> for %qT", | 5576 if (complain & tf_error) |
5552 » operator_name_info[(int)code].name, type); | 5577 error ("no suitable %<operator %s%> for %qT", |
| 5578 » operator_name_info[(int)code].name, type); |
5553 return error_mark_node; | 5579 return error_mark_node; |
5554 } | 5580 } |
5555 | 5581 |
5556 /* If the current scope isn't allowed to access DECL along | 5582 /* If the current scope isn't allowed to access DECL along |
5557 BASETYPE_PATH, give an error. The most derived class in | 5583 BASETYPE_PATH, give an error. The most derived class in |
5558 BASETYPE_PATH is the one used to qualify DECL. DIAG_DECL is | 5584 BASETYPE_PATH is the one used to qualify DECL. DIAG_DECL is |
5559 the declaration to use in the error diagnostic. */ | 5585 the declaration to use in the error diagnostic. */ |
5560 | 5586 |
5561 bool | 5587 bool |
5562 enforce_access (tree basetype_path, tree decl, tree diag_decl) | 5588 enforce_access (tree basetype_path, tree decl, tree diag_decl, |
| 5589 » » tsubst_flags_t complain) |
5563 { | 5590 { |
5564 gcc_assert (TREE_CODE (basetype_path) == TREE_BINFO); | 5591 gcc_assert (TREE_CODE (basetype_path) == TREE_BINFO); |
5565 | 5592 |
5566 if (!accessible_p (basetype_path, decl, true)) | 5593 if (!accessible_p (basetype_path, decl, true)) |
5567 { | 5594 { |
5568 if (TREE_PRIVATE (decl)) | 5595 if (complain & tf_error) |
5569 » error ("%q+#D is private", diag_decl); | 5596 » { |
5570 else if (TREE_PROTECTED (decl)) | 5597 » if (TREE_PRIVATE (decl)) |
5571 » error ("%q+#D is protected", diag_decl); | 5598 » error ("%q+#D is private", diag_decl); |
5572 else | 5599 » else if (TREE_PROTECTED (decl)) |
5573 » error ("%q+#D is inaccessible", diag_decl); | 5600 » error ("%q+#D is protected", diag_decl); |
5574 error ("within this context"); | 5601 » else |
| 5602 » error ("%q+#D is inaccessible", diag_decl); |
| 5603 » error ("within this context"); |
| 5604 » } |
5575 return false; | 5605 return false; |
5576 } | 5606 } |
5577 | 5607 |
5578 return true; | 5608 return true; |
5579 } | 5609 } |
5580 | 5610 |
5581 /* Initialize a temporary of type TYPE with EXPR. The FLAGS are a | 5611 /* Initialize a temporary of type TYPE with EXPR. The FLAGS are a |
5582 bitwise or of LOOKUP_* values. If any errors are warnings are | 5612 bitwise or of LOOKUP_* values. If any errors are warnings are |
5583 generated, set *DIAGNOSTIC_FN to "error" or "warning", | 5613 generated, set *DIAGNOSTIC_FN to "error" or "warning", |
5584 respectively. If no diagnostics are generated, set *DIAGNOSTIC_FN | 5614 respectively. If no diagnostics are generated, set *DIAGNOSTIC_FN |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5689 { | 5719 { |
5690 permerror (loc, "invalid user-defined conversion " | 5720 permerror (loc, "invalid user-defined conversion " |
5691 "from %qT to %qT", TREE_TYPE (expr), totype); | 5721 "from %qT to %qT", TREE_TYPE (expr), totype); |
5692 print_z_candidate (loc, "candidate is:", t->cand); | 5722 print_z_candidate (loc, "candidate is:", t->cand); |
5693 expr = convert_like_real (t, expr, fn, argnum, 1, | 5723 expr = convert_like_real (t, expr, fn, argnum, 1, |
5694 /*issue_conversion_warnings=*/false, | 5724 /*issue_conversion_warnings=*/false, |
5695 /*c_cast_p=*/false, | 5725 /*c_cast_p=*/false, |
5696 complain); | 5726 complain); |
5697 if (convs->kind == ck_ref_bind) | 5727 if (convs->kind == ck_ref_bind) |
5698 return convert_to_reference (totype, expr, CONV_IMPLICIT, | 5728 return convert_to_reference (totype, expr, CONV_IMPLICIT, |
5699 » » » » » LOOKUP_NORMAL, NULL_TREE); | 5729 » » » » » LOOKUP_NORMAL, NULL_TREE, |
| 5730 » » » » » complain); |
5700 else | 5731 else |
5701 » » return cp_convert (totype, expr); | 5732 » » return cp_convert (totype, expr, complain); |
5702 } | 5733 } |
5703 else if (t->kind == ck_user || !t->bad_p) | 5734 else if (t->kind == ck_user || !t->bad_p) |
5704 { | 5735 { |
5705 expr = convert_like_real (t, expr, fn, argnum, 1, | 5736 expr = convert_like_real (t, expr, fn, argnum, 1, |
5706 /*issue_conversion_warnings=*/false, | 5737 /*issue_conversion_warnings=*/false, |
5707 /*c_cast_p=*/false, | 5738 /*c_cast_p=*/false, |
5708 complain); | 5739 complain); |
5709 break; | 5740 break; |
5710 } | 5741 } |
5711 else if (t->kind == ck_ambig) | 5742 else if (t->kind == ck_ambig) |
5712 return convert_like_real (t, expr, fn, argnum, 1, | 5743 return convert_like_real (t, expr, fn, argnum, 1, |
5713 /*issue_conversion_warnings=*/false, | 5744 /*issue_conversion_warnings=*/false, |
5714 /*c_cast_p=*/false, | 5745 /*c_cast_p=*/false, |
5715 complain); | 5746 complain); |
5716 else if (t->kind == ck_identity) | 5747 else if (t->kind == ck_identity) |
5717 break; | 5748 break; |
5718 } | 5749 } |
5719 | 5750 |
5720 permerror (loc, "invalid conversion from %qT to %qT", | 5751 permerror (loc, "invalid conversion from %qT to %qT", |
5721 TREE_TYPE (expr), totype); | 5752 TREE_TYPE (expr), totype); |
5722 if (fn) | 5753 if (fn) |
5723 permerror (DECL_SOURCE_LOCATION (fn), | 5754 permerror (DECL_SOURCE_LOCATION (fn), |
5724 " initializing argument %P of %qD", argnum, fn); | 5755 " initializing argument %P of %qD", argnum, fn); |
5725 | 5756 |
5726 return cp_convert (totype, expr); | 5757 return cp_convert (totype, expr, complain); |
5727 } | 5758 } |
5728 | 5759 |
5729 if (issue_conversion_warnings && (complain & tf_warning)) | 5760 if (issue_conversion_warnings && (complain & tf_warning)) |
5730 conversion_null_warnings (totype, expr, fn, argnum); | 5761 conversion_null_warnings (totype, expr, fn, argnum); |
5731 | 5762 |
5732 switch (convs->kind) | 5763 switch (convs->kind) |
5733 { | 5764 { |
5734 case ck_user: | 5765 case ck_user: |
5735 { | 5766 { |
5736 struct z_candidate *cand = convs->cand; | 5767 struct z_candidate *cand = convs->cand; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5855 TREE_CONSTANT (new_ctor) = false; | 5886 TREE_CONSTANT (new_ctor) = false; |
5856 } | 5887 } |
5857 /* Build up the array. */ | 5888 /* Build up the array. */ |
5858 elttype = cp_build_qualified_type | 5889 elttype = cp_build_qualified_type |
5859 (elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST); | 5890 (elttype, cp_type_quals (elttype) | TYPE_QUAL_CONST); |
5860 array = build_array_of_n_type (elttype, len); | 5891 array = build_array_of_n_type (elttype, len); |
5861 array = finish_compound_literal (array, new_ctor, complain); | 5892 array = finish_compound_literal (array, new_ctor, complain); |
5862 /* Take the address explicitly rather than via decay_conversion | 5893 /* Take the address explicitly rather than via decay_conversion |
5863 to avoid the error about taking the address of a temporary. */ | 5894 to avoid the error about taking the address of a temporary. */ |
5864 array = cp_build_addr_expr (array, complain); | 5895 array = cp_build_addr_expr (array, complain); |
5865 » array = cp_convert (build_pointer_type (elttype), array); | 5896 » array = cp_convert (build_pointer_type (elttype), array, complain); |
5866 | 5897 |
5867 /* Build up the initializer_list object. */ | 5898 /* Build up the initializer_list object. */ |
5868 totype = complete_type (totype); | 5899 totype = complete_type (totype); |
5869 field = next_initializable_field (TYPE_FIELDS (totype)); | 5900 field = next_initializable_field (TYPE_FIELDS (totype)); |
5870 CONSTRUCTOR_APPEND_ELT (vec, field, array); | 5901 CONSTRUCTOR_APPEND_ELT (vec, field, array); |
5871 field = next_initializable_field (DECL_CHAIN (field)); | 5902 field = next_initializable_field (DECL_CHAIN (field)); |
5872 CONSTRUCTOR_APPEND_ELT (vec, field, size_int (len)); | 5903 CONSTRUCTOR_APPEND_ELT (vec, field, size_int (len)); |
5873 new_ctor = build_constructor (totype, vec); | 5904 new_ctor = build_constructor (totype, vec); |
5874 return get_target_expr (new_ctor); | 5905 return get_target_expr (new_ctor); |
5875 } | 5906 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6021 /* Take the address of the thing to which we will bind the | 6052 /* Take the address of the thing to which we will bind the |
6022 reference. */ | 6053 reference. */ |
6023 expr = cp_build_addr_expr (expr, complain); | 6054 expr = cp_build_addr_expr (expr, complain); |
6024 if (expr == error_mark_node) | 6055 if (expr == error_mark_node) |
6025 return error_mark_node; | 6056 return error_mark_node; |
6026 | 6057 |
6027 /* Convert it to a pointer to the type referred to by the | 6058 /* Convert it to a pointer to the type referred to by the |
6028 reference. This will adjust the pointer if a derived to | 6059 reference. This will adjust the pointer if a derived to |
6029 base conversion is being performed. */ | 6060 base conversion is being performed. */ |
6030 expr = cp_convert (build_pointer_type (TREE_TYPE (ref_type)), | 6061 expr = cp_convert (build_pointer_type (TREE_TYPE (ref_type)), |
6031 » » » expr); | 6062 » » » expr, complain); |
6032 /* Convert the pointer to the desired reference type. */ | 6063 /* Convert the pointer to the desired reference type. */ |
6033 return build_nop (ref_type, expr); | 6064 return build_nop (ref_type, expr); |
6034 } | 6065 } |
6035 | 6066 |
6036 case ck_lvalue: | 6067 case ck_lvalue: |
6037 return decay_conversion (expr, complain); | 6068 return decay_conversion (expr, complain); |
6038 | 6069 |
6039 case ck_qual: | 6070 case ck_qual: |
6040 /* Warn about deprecated conversion if appropriate. */ | 6071 /* Warn about deprecated conversion if appropriate. */ |
6041 string_conv_p (totype, expr, 1); | 6072 string_conv_p (totype, expr, 1); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6103 } | 6134 } |
6104 else if (NULLPTR_TYPE_P (arg_type)) | 6135 else if (NULLPTR_TYPE_P (arg_type)) |
6105 arg = null_pointer_node; | 6136 arg = null_pointer_node; |
6106 else if (INTEGRAL_OR_ENUMERATION_TYPE_P (arg_type)) | 6137 else if (INTEGRAL_OR_ENUMERATION_TYPE_P (arg_type)) |
6107 { | 6138 { |
6108 if (SCOPED_ENUM_P (arg_type) && !abi_version_at_least (6)) | 6139 if (SCOPED_ENUM_P (arg_type) && !abi_version_at_least (6)) |
6109 { | 6140 { |
6110 if (complain & tf_warning) | 6141 if (complain & tf_warning) |
6111 warning_at (loc, OPT_Wabi, "scoped enum %qT will not promote to an " | 6142 warning_at (loc, OPT_Wabi, "scoped enum %qT will not promote to an " |
6112 "integral type in a future version of GCC", arg_type); | 6143 "integral type in a future version of GCC", arg_type); |
6113 » arg = cp_convert (ENUM_UNDERLYING_TYPE (arg_type), arg); | 6144 » arg = cp_convert (ENUM_UNDERLYING_TYPE (arg_type), arg, complain); |
6114 » } | 6145 » } |
6115 arg = perform_integral_promotions (arg); | 6146 arg = cp_perform_integral_promotions (arg, complain); |
6116 } | 6147 } |
6117 | 6148 |
6118 arg = require_complete_type (arg); | 6149 arg = require_complete_type (arg); |
6119 arg_type = TREE_TYPE (arg); | 6150 arg_type = TREE_TYPE (arg); |
6120 | 6151 |
6121 if (arg != error_mark_node | 6152 if (arg != error_mark_node |
6122 /* In a template (or ill-formed code), we can have an incomplete type | 6153 /* In a template (or ill-formed code), we can have an incomplete type |
6123 even after require_complete_type, in which case we don't know | 6154 even after require_complete_type, in which case we don't know |
6124 whether it has trivial copy or not. */ | 6155 whether it has trivial copy or not. */ |
6125 && COMPLETE_TYPE_P (arg_type)) | 6156 && COMPLETE_TYPE_P (arg_type)) |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6340 if (val == error_mark_node) | 6371 if (val == error_mark_node) |
6341 ; | 6372 ; |
6342 /* Pass classes with copy ctors by invisible reference. */ | 6373 /* Pass classes with copy ctors by invisible reference. */ |
6343 else if (TREE_ADDRESSABLE (type)) | 6374 else if (TREE_ADDRESSABLE (type)) |
6344 val = build1 (ADDR_EXPR, build_reference_type (type), val); | 6375 val = build1 (ADDR_EXPR, build_reference_type (type), val); |
6345 else if (targetm.calls.promote_prototypes (type) | 6376 else if (targetm.calls.promote_prototypes (type) |
6346 && INTEGRAL_TYPE_P (type) | 6377 && INTEGRAL_TYPE_P (type) |
6347 && COMPLETE_TYPE_P (type) | 6378 && COMPLETE_TYPE_P (type) |
6348 && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), | 6379 && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), |
6349 TYPE_SIZE (integer_type_node))) | 6380 TYPE_SIZE (integer_type_node))) |
6350 val = perform_integral_promotions (val); | 6381 val = cp_perform_integral_promotions (val, complain); |
6351 if ((complain & tf_warning) | 6382 if ((complain & tf_warning) |
6352 && warn_suggest_attribute_format) | 6383 && warn_suggest_attribute_format) |
6353 { | 6384 { |
6354 tree rhstype = TREE_TYPE (val); | 6385 tree rhstype = TREE_TYPE (val); |
6355 const enum tree_code coder = TREE_CODE (rhstype); | 6386 const enum tree_code coder = TREE_CODE (rhstype); |
6356 const enum tree_code codel = TREE_CODE (type); | 6387 const enum tree_code codel = TREE_CODE (type); |
6357 if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE) | 6388 if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE) |
6358 && coder == codel | 6389 && coder == codel |
6359 && check_missing_format_attribute (type, rhstype)) | 6390 && check_missing_format_attribute (type, rhstype)) |
6360 warning (OPT_Wsuggest_attribute_format, | 6391 warning (OPT_Wsuggest_attribute_format, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6488 In case #2, where `B<int>::g' has a DECL_TEMPLATE_INFO simply | 6519 In case #2, where `B<int>::g' has a DECL_TEMPLATE_INFO simply |
6489 because it is a member of class template B, DECL_ACCESS is | 6520 because it is a member of class template B, DECL_ACCESS is |
6490 recorded in the specialization `B<int>::g'. We cannot use its | 6521 recorded in the specialization `B<int>::g'. We cannot use its |
6491 primary template because `B<T>::g' and `B<int>::g' may have | 6522 primary template because `B<T>::g' and `B<int>::g' may have |
6492 different access. */ | 6523 different access. */ |
6493 if (DECL_TEMPLATE_INFO (fn) | 6524 if (DECL_TEMPLATE_INFO (fn) |
6494 && DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (fn))) | 6525 && DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (fn))) |
6495 access_fn = DECL_TI_TEMPLATE (fn); | 6526 access_fn = DECL_TI_TEMPLATE (fn); |
6496 else | 6527 else |
6497 access_fn = fn; | 6528 access_fn = fn; |
6498 if (flags & LOOKUP_SPECULATIVE) | 6529 if (!perform_or_defer_access_check (cand->access_path, access_fn, |
6499 » { | 6530 » » » » » fn, complain)) |
6500 » if (!speculative_access_check (cand->access_path, access_fn, fn, | 6531 » return error_mark_node; |
6501 » » » » » !!(flags & LOOKUP_COMPLAIN))) | |
6502 » return error_mark_node; | |
6503 » } | |
6504 else | |
6505 » perform_or_defer_access_check (cand->access_path, access_fn, fn); | |
6506 } | 6532 } |
6507 | 6533 |
6508 /* If we're checking for implicit delete, don't bother with argument | 6534 /* If we're checking for implicit delete, don't bother with argument |
6509 conversions. */ | 6535 conversions. */ |
6510 if (flags & LOOKUP_SPECULATIVE) | 6536 if (flags & LOOKUP_SPECULATIVE) |
6511 { | 6537 { |
6512 if (DECL_DELETED_FN (fn)) | 6538 if (DECL_DELETED_FN (fn)) |
6513 { | 6539 { |
6514 » if (flags & LOOKUP_COMPLAIN) | 6540 » if (complain & tf_error) |
6515 mark_used (fn); | 6541 mark_used (fn); |
6516 return error_mark_node; | 6542 return error_mark_node; |
6517 } | 6543 } |
6518 if (cand->viable == 1) | 6544 if (cand->viable == 1) |
6519 return fn; | 6545 return fn; |
6520 else if (!(flags & LOOKUP_COMPLAIN)) | 6546 else if (!(complain & tf_error)) |
6521 /* Reject bad conversions now. */ | 6547 /* Reject bad conversions now. */ |
6522 return error_mark_node; | 6548 return error_mark_node; |
6523 /* else continue to get conversion error. */ | 6549 /* else continue to get conversion error. */ |
6524 } | 6550 } |
6525 | 6551 |
6526 /* Find maximum size of vector to hold converted arguments. */ | 6552 /* Find maximum size of vector to hold converted arguments. */ |
6527 parmlen = list_length (parm); | 6553 parmlen = list_length (parm); |
6528 nargs = VEC_length (tree, args) + (first_arg != NULL_TREE ? 1 : 0); | 6554 nargs = VEC_length (tree, args) + (first_arg != NULL_TREE ? 1 : 0); |
6529 if (parmlen > nargs) | 6555 if (parmlen > nargs) |
6530 nargs = parmlen; | 6556 nargs = parmlen; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6848 the version that will checked for dispatching first. If this | 6874 the version that will checked for dispatching first. If this |
6849 version is inlinable, a direct call can be made otherwise it | 6875 version is inlinable, a direct call can be made otherwise it |
6850 should go through the dispatcher. */ | 6876 should go through the dispatcher. */ |
6851 | 6877 |
6852 if (DECL_FUNCTION_VERSIONED (fn) | 6878 if (DECL_FUNCTION_VERSIONED (fn) |
6853 && !targetm.target_option.can_inline_p (current_function_decl, fn)) | 6879 && !targetm.target_option.can_inline_p (current_function_decl, fn)) |
6854 { | 6880 { |
6855 tree dispatcher_decl = NULL; | 6881 tree dispatcher_decl = NULL; |
6856 struct cgraph_node *node = cgraph_get_node (fn); | 6882 struct cgraph_node *node = cgraph_get_node (fn); |
6857 if (node != NULL) | 6883 if (node != NULL) |
6858 dispatcher_decl = cgraph_get_node (fn)->dispatcher_fndecl; | 6884 dispatcher_decl = cgraph_get_node (fn)->version_dispatcher_decl; |
6859 if (dispatcher_decl == NULL) | 6885 if (dispatcher_decl == NULL) |
6860 { | 6886 { |
6861 error_at (input_location, "Call to multiversioned function" | 6887 error_at (input_location, "Call to multiversioned function" |
6862 " without a default is not allowed"); | 6888 " without a default is not allowed"); |
6863 return NULL; | 6889 return NULL; |
6864 } | 6890 } |
6865 retrofit_lang_decl (dispatcher_decl); | 6891 retrofit_lang_decl (dispatcher_decl); |
6866 gcc_assert (dispatcher_decl != NULL); | 6892 gcc_assert (dispatcher_decl != NULL); |
6867 fn = dispatcher_decl; | 6893 fn = dispatcher_decl; |
6868 } | 6894 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6902 } | 6928 } |
6903 | 6929 |
6904 /* Build and return a call to FN, using NARGS arguments in ARGARRAY. | 6930 /* Build and return a call to FN, using NARGS arguments in ARGARRAY. |
6905 This function performs no overload resolution, conversion, or other | 6931 This function performs no overload resolution, conversion, or other |
6906 high-level operations. */ | 6932 high-level operations. */ |
6907 | 6933 |
6908 tree | 6934 tree |
6909 build_cxx_call (tree fn, int nargs, tree *argarray) | 6935 build_cxx_call (tree fn, int nargs, tree *argarray) |
6910 { | 6936 { |
6911 tree fndecl; | 6937 tree fndecl; |
| 6938 int optimize_sav; |
6912 | 6939 |
6913 /* Remember roughly where this call is. */ | 6940 /* Remember roughly where this call is. */ |
6914 location_t loc = EXPR_LOC_OR_HERE (fn); | 6941 location_t loc = EXPR_LOC_OR_HERE (fn); |
6915 fn = build_call_a (fn, nargs, argarray); | 6942 fn = build_call_a (fn, nargs, argarray); |
6916 SET_EXPR_LOCATION (fn, loc); | 6943 SET_EXPR_LOCATION (fn, loc); |
6917 | 6944 |
6918 fndecl = get_callee_fndecl (fn); | 6945 fndecl = get_callee_fndecl (fn); |
6919 | 6946 |
6920 /* Check that arguments to builtin functions match the expectations. */ | 6947 /* Check that arguments to builtin functions match the expectations. */ |
6921 if (fndecl | 6948 if (fndecl |
6922 && DECL_BUILT_IN (fndecl) | 6949 && DECL_BUILT_IN (fndecl) |
6923 && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL | 6950 && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL |
6924 && !check_builtin_function_arguments (fndecl, nargs, argarray)) | 6951 && !check_builtin_function_arguments (fndecl, nargs, argarray)) |
6925 return error_mark_node; | 6952 return error_mark_node; |
6926 | 6953 |
6927 /* Some built-in function calls will be evaluated at compile-time in | 6954 /* Some built-in function calls will be evaluated at compile-time in |
6928 fold (). */ | 6955 fold (). Set optimize to 1 when folding __builtin_constant_p inside |
| 6956 a constexpr function so that fold_builtin_1 doesn't fold it to 0. */ |
| 6957 optimize_sav = optimize; |
| 6958 if (!optimize && fndecl && DECL_IS_BUILTIN_CONSTANT_P (fndecl) |
| 6959 && current_function_decl |
| 6960 && DECL_DECLARED_CONSTEXPR_P (current_function_decl)) |
| 6961 optimize = 1; |
6929 fn = fold_if_not_in_template (fn); | 6962 fn = fold_if_not_in_template (fn); |
| 6963 optimize = optimize_sav; |
6930 | 6964 |
6931 if (VOID_TYPE_P (TREE_TYPE (fn))) | 6965 if (VOID_TYPE_P (TREE_TYPE (fn))) |
6932 return fn; | 6966 return fn; |
6933 | 6967 |
6934 fn = require_complete_type (fn); | 6968 fn = require_complete_type (fn); |
6935 if (fn == error_mark_node) | 6969 if (fn == error_mark_node) |
6936 return error_mark_node; | 6970 return error_mark_node; |
6937 | 6971 |
6938 if (MAYBE_CLASS_TYPE_P (TREE_TYPE (fn))) | 6972 if (MAYBE_CLASS_TYPE_P (TREE_TYPE (fn))) |
6939 fn = build_cplus_new (TREE_TYPE (fn), fn, tf_warning_or_error); | 6973 fn = build_cplus_new (TREE_TYPE (fn), fn, tf_warning_or_error); |
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8118 static int | 8152 static int |
8119 joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn, | 8153 joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn, |
8120 tsubst_flags_t complain) | 8154 tsubst_flags_t complain) |
8121 { | 8155 { |
8122 int winner = 0; | 8156 int winner = 0; |
8123 int off1 = 0, off2 = 0; | 8157 int off1 = 0, off2 = 0; |
8124 size_t i; | 8158 size_t i; |
8125 size_t len; | 8159 size_t len; |
8126 | 8160 |
8127 /* For Candidates of a multi-versioned function, make the version with | 8161 /* For Candidates of a multi-versioned function, make the version with |
8128 the most specialized target attributes, highest priority win. This | 8162 the highest priority win. This version will be checked for dispatching |
8129 version will be checked for dispatching first. If this version can | 8163 first. If this version can be inlined into the caller the front-end |
8130 be inlined into the caller the front-end will simply make a direct | 8164 will simply make a direct call to this function. */ |
8131 call to this function. */ | |
8132 | 8165 |
8133 if ((TREE_CODE (cand1->fn) == FUNCTION_DECL | 8166 if ((TREE_CODE (cand1->fn) == FUNCTION_DECL |
8134 && DECL_FUNCTION_VERSIONED (cand1->fn)) | 8167 && DECL_FUNCTION_VERSIONED (cand1->fn)) |
8135 ||(TREE_CODE (cand2->fn) == FUNCTION_DECL | 8168 ||(TREE_CODE (cand2->fn) == FUNCTION_DECL |
8136 && DECL_FUNCTION_VERSIONED (cand2->fn))) | 8169 && DECL_FUNCTION_VERSIONED (cand2->fn))) |
8137 { | 8170 { |
8138 /* Both functions must be marked versioned. */ | 8171 /* Both functions must be marked versioned. */ |
8139 gcc_assert (DECL_FUNCTION_VERSIONED (cand1->fn) | 8172 gcc_assert (DECL_FUNCTION_VERSIONED (cand1->fn) |
8140 && DECL_FUNCTION_VERSIONED (cand2->fn)); | 8173 && DECL_FUNCTION_VERSIONED (cand2->fn)); |
8141 | 8174 |
8142 /* Always make the version with the higher priority, more | 8175 /* Always make the version with the higher priority, more |
8143 specialized, win. */ | 8176 specialized, win. */ |
8144 if (targetm.compare_versions (cand1->fn, cand2->fn) >= 0) | 8177 gcc_assert (targetm.compare_version_priority); |
| 8178 if (targetm.compare_version_priority (cand1->fn, cand2->fn) >= 0) |
8145 return 1; | 8179 return 1; |
8146 else | 8180 else |
8147 return -1; | 8181 return -1; |
8148 } | 8182 } |
8149 | 8183 |
8150 /* Candidates that involve bad conversions are always worse than those | 8184 /* Candidates that involve bad conversions are always worse than those |
8151 that don't. */ | 8185 that don't. */ |
8152 if (cand1->viable > cand2->viable) | 8186 if (cand1->viable > cand2->viable) |
8153 return 1; | 8187 return 1; |
8154 if (cand1->viable < cand2->viable) | 8188 if (cand1->viable < cand2->viable) |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8496 generating the dispatcher body later if necessary. */ | 8530 generating the dispatcher body later if necessary. */ |
8497 | 8531 |
8498 if (TREE_CODE (candidates->fn) == FUNCTION_DECL | 8532 if (TREE_CODE (candidates->fn) == FUNCTION_DECL |
8499 && DECL_FUNCTION_VERSIONED (candidates->fn)) | 8533 && DECL_FUNCTION_VERSIONED (candidates->fn)) |
8500 { | 8534 { |
8501 VEC (tree, heap) *fn_ver_vec = NULL; | 8535 VEC (tree, heap) *fn_ver_vec = NULL; |
8502 struct z_candidate *ver = candidates; | 8536 struct z_candidate *ver = candidates; |
8503 fn_ver_vec = VEC_alloc (tree, heap, 2); | 8537 fn_ver_vec = VEC_alloc (tree, heap, 2); |
8504 for (;ver; ver = ver->next) | 8538 for (;ver; ver = ver->next) |
8505 VEC_safe_push (tree, heap, fn_ver_vec, ver->fn); | 8539 VEC_safe_push (tree, heap, fn_ver_vec, ver->fn); |
8506 build_dispatcher_for_function_versions (fn_ver_vec); | 8540 gcc_assert (targetm.get_function_versions_dispatcher); |
| 8541 targetm.get_function_versions_dispatcher (fn_ver_vec); |
8507 VEC_free (tree, heap, fn_ver_vec); | 8542 VEC_free (tree, heap, fn_ver_vec); |
8508 } | 8543 } |
8509 | 8544 |
8510 /* Walk through the list once, comparing each current champ to the next | 8545 /* Walk through the list once, comparing each current champ to the next |
8511 candidate, knocking out a candidate or two with each comparison. */ | 8546 candidate, knocking out a candidate or two with each comparison. */ |
8512 | 8547 |
8513 for (challenger = champ->next; challenger; ) | 8548 for (challenger = champ->next; challenger; ) |
8514 { | 8549 { |
8515 fate = joust (champ, challenger, 0, complain); | 8550 fate = joust (champ, challenger, 0, complain); |
8516 if (fate == 1) | 8551 if (fate == 1) |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9051 args = TREE_CHAIN (args); | 9086 args = TREE_CHAIN (args); |
9052 | 9087 |
9053 if (args && args != void_list_node && !TREE_PURPOSE (args)) | 9088 if (args && args != void_list_node && !TREE_PURPOSE (args)) |
9054 /* There are more non-defaulted parms. */ | 9089 /* There are more non-defaulted parms. */ |
9055 return false; | 9090 return false; |
9056 | 9091 |
9057 return true; | 9092 return true; |
9058 } | 9093 } |
9059 | 9094 |
9060 #include "gt-cp-call.h" | 9095 #include "gt-cp-call.h" |
LEFT | RIGHT |