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