Mercurial > hg > CbC > CbC_gcc
comparison gcc/cp/semantics.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Perform the semantic phase of parsing, i.e., the process of | 1 /* Perform the semantic phase of parsing, i.e., the process of |
2 building tree structure, checking semantic consistency, and | 2 building tree structure, checking semantic consistency, and |
3 building RTL. These routines are used both during actual parsing | 3 building RTL. These routines are used both during actual parsing |
4 and during the instantiation of template functions. | 4 and during the instantiation of template functions. |
5 | 5 |
6 Copyright (C) 1998-2017 Free Software Foundation, Inc. | 6 Copyright (C) 1998-2018 Free Software Foundation, Inc. |
7 Written by Mark Mitchell (mmitchell@usa.net) based on code found | 7 Written by Mark Mitchell (mmitchell@usa.net) based on code found |
8 formerly in parse.y and pt.c. | 8 formerly in parse.y and pt.c. |
9 | 9 |
10 This file is part of GCC. | 10 This file is part of GCC. |
11 | 11 |
408 static tree | 408 static tree |
409 maybe_cleanup_point_expr (tree expr) | 409 maybe_cleanup_point_expr (tree expr) |
410 { | 410 { |
411 if (!processing_template_decl && stmts_are_full_exprs_p ()) | 411 if (!processing_template_decl && stmts_are_full_exprs_p ()) |
412 expr = fold_build_cleanup_point_expr (TREE_TYPE (expr), expr); | 412 expr = fold_build_cleanup_point_expr (TREE_TYPE (expr), expr); |
413 else | |
414 expr = do_dependent_capture (expr); | |
415 return expr; | 413 return expr; |
416 } | 414 } |
417 | 415 |
418 /* Like maybe_cleanup_point_expr except have the type of the new expression be | 416 /* Like maybe_cleanup_point_expr except have the type of the new expression be |
419 void so we don't need to create a temporary variable to hold the inner | 417 void so we don't need to create a temporary variable to hold the inner |
423 tree | 421 tree |
424 maybe_cleanup_point_expr_void (tree expr) | 422 maybe_cleanup_point_expr_void (tree expr) |
425 { | 423 { |
426 if (!processing_template_decl && stmts_are_full_exprs_p ()) | 424 if (!processing_template_decl && stmts_are_full_exprs_p ()) |
427 expr = fold_build_cleanup_point_expr (void_type_node, expr); | 425 expr = fold_build_cleanup_point_expr (void_type_node, expr); |
428 else | |
429 expr = do_dependent_capture (expr); | |
430 return expr; | 426 return expr; |
431 } | 427 } |
432 | 428 |
433 | 429 |
434 | 430 |
616 mark the used labels as used. */ | 612 mark the used labels as used. */ |
617 if (TREE_CODE (destination) == LABEL_DECL) | 613 if (TREE_CODE (destination) == LABEL_DECL) |
618 TREE_USED (destination) = 1; | 614 TREE_USED (destination) = 1; |
619 else | 615 else |
620 { | 616 { |
621 if (check_no_cilk (destination, | |
622 "Cilk array notation cannot be used as a computed goto expression", | |
623 "%<_Cilk_spawn%> statement cannot be used as a computed goto expression")) | |
624 destination = error_mark_node; | |
625 destination = mark_rvalue_use (destination); | 617 destination = mark_rvalue_use (destination); |
626 if (!processing_template_decl) | 618 if (!processing_template_decl) |
627 { | 619 { |
628 destination = cp_convert (ptr_type_node, destination, | 620 destination = cp_convert (ptr_type_node, destination, |
629 tf_warning_or_error); | 621 tf_warning_or_error); |
631 return NULL_TREE; | 623 return NULL_TREE; |
632 destination | 624 destination |
633 = fold_build_cleanup_point_expr (TREE_TYPE (destination), | 625 = fold_build_cleanup_point_expr (TREE_TYPE (destination), |
634 destination); | 626 destination); |
635 } | 627 } |
636 else | |
637 destination = do_dependent_capture (destination); | |
638 } | 628 } |
639 | 629 |
640 check_goto (destination); | 630 check_goto (destination); |
641 | 631 |
642 add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN)); | 632 add_stmt (build_predict_expr (PRED_GOTO, NOT_TAKEN)); |
654 if (!cond) | 644 if (!cond) |
655 return NULL_TREE; | 645 return NULL_TREE; |
656 | 646 |
657 /* Wait until we instantiate templates before doing conversion. */ | 647 /* Wait until we instantiate templates before doing conversion. */ |
658 if (processing_template_decl) | 648 if (processing_template_decl) |
659 return do_dependent_capture (cond); | 649 return cond; |
660 | 650 |
661 if (warn_sequence_point) | 651 if (warn_sequence_point) |
662 verify_sequence_points (cond); | 652 verify_sequence_points (cond); |
663 | 653 |
664 /* Do the conversion. */ | 654 /* Do the conversion. */ |
666 | 656 |
667 if (TREE_CODE (cond) == MODIFY_EXPR | 657 if (TREE_CODE (cond) == MODIFY_EXPR |
668 && !TREE_NO_WARNING (cond) | 658 && !TREE_NO_WARNING (cond) |
669 && warn_parentheses) | 659 && warn_parentheses) |
670 { | 660 { |
671 warning_at (EXPR_LOC_OR_LOC (cond, input_location), OPT_Wparentheses, | 661 warning_at (cp_expr_loc_or_loc (cond, input_location), OPT_Wparentheses, |
672 "suggest parentheses around assignment used as truth value"); | 662 "suggest parentheses around assignment used as truth value"); |
673 TREE_NO_WARNING (cond) = 1; | 663 TREE_NO_WARNING (cond) = 1; |
674 } | 664 } |
675 | 665 |
676 return condition_conversion (cond); | 666 return condition_conversion (cond); |
739 tree | 729 tree |
740 finish_if_stmt_cond (tree cond, tree if_stmt) | 730 finish_if_stmt_cond (tree cond, tree if_stmt) |
741 { | 731 { |
742 cond = maybe_convert_cond (cond); | 732 cond = maybe_convert_cond (cond); |
743 if (IF_STMT_CONSTEXPR_P (if_stmt) | 733 if (IF_STMT_CONSTEXPR_P (if_stmt) |
744 && is_constant_expression (cond) | 734 && !type_dependent_expression_p (cond) |
745 && !value_dependent_expression_p (cond)) | 735 && require_constant_expression (cond) |
736 && !instantiation_dependent_expression_p (cond) | |
737 /* Wait until instantiation time, since only then COND has been | |
738 converted to bool. */ | |
739 && TYPE_MAIN_VARIANT (TREE_TYPE (cond)) == boolean_type_node) | |
746 { | 740 { |
747 cond = instantiate_non_dependent_expr (cond); | 741 cond = instantiate_non_dependent_expr (cond); |
748 cond = cxx_constant_value (cond, NULL_TREE); | 742 cond = cxx_constant_value (cond, NULL_TREE); |
749 } | 743 } |
750 finish_cond (&IF_COND (if_stmt), cond); | 744 finish_cond (&IF_COND (if_stmt), cond); |
806 | 800 |
807 /* Process the COND of a while-statement, which may be given by | 801 /* Process the COND of a while-statement, which may be given by |
808 WHILE_STMT. */ | 802 WHILE_STMT. */ |
809 | 803 |
810 void | 804 void |
811 finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep) | 805 finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep, |
812 { | 806 unsigned short unroll) |
813 if (check_no_cilk (cond, | 807 { |
814 "Cilk array notation cannot be used as a condition for while statement", | |
815 "%<_Cilk_spawn%> statement cannot be used as a condition for while statement")) | |
816 cond = error_mark_node; | |
817 cond = maybe_convert_cond (cond); | 808 cond = maybe_convert_cond (cond); |
818 finish_cond (&WHILE_COND (while_stmt), cond); | 809 finish_cond (&WHILE_COND (while_stmt), cond); |
819 begin_maybe_infinite_loop (cond); | 810 begin_maybe_infinite_loop (cond); |
820 if (ivdep && cond != error_mark_node) | 811 if (ivdep && cond != error_mark_node) |
821 WHILE_COND (while_stmt) = build2 (ANNOTATE_EXPR, | 812 WHILE_COND (while_stmt) = build3 (ANNOTATE_EXPR, |
822 TREE_TYPE (WHILE_COND (while_stmt)), | 813 TREE_TYPE (WHILE_COND (while_stmt)), |
823 WHILE_COND (while_stmt), | 814 WHILE_COND (while_stmt), |
824 build_int_cst (integer_type_node, | 815 build_int_cst (integer_type_node, |
825 annot_expr_ivdep_kind)); | 816 annot_expr_ivdep_kind), |
817 integer_zero_node); | |
818 if (unroll && cond != error_mark_node) | |
819 WHILE_COND (while_stmt) = build3 (ANNOTATE_EXPR, | |
820 TREE_TYPE (WHILE_COND (while_stmt)), | |
821 WHILE_COND (while_stmt), | |
822 build_int_cst (integer_type_node, | |
823 annot_expr_unroll_kind), | |
824 build_int_cst (integer_type_node, | |
825 unroll)); | |
826 simplify_loop_decl_cond (&WHILE_COND (while_stmt), WHILE_BODY (while_stmt)); | 826 simplify_loop_decl_cond (&WHILE_COND (while_stmt), WHILE_BODY (while_stmt)); |
827 } | 827 } |
828 | 828 |
829 /* Finish a while-statement, which may be given by WHILE_STMT. */ | 829 /* Finish a while-statement, which may be given by WHILE_STMT. */ |
830 | 830 |
865 | 865 |
866 /* Finish a do-statement, which may be given by DO_STMT, and whose | 866 /* Finish a do-statement, which may be given by DO_STMT, and whose |
867 COND is as indicated. */ | 867 COND is as indicated. */ |
868 | 868 |
869 void | 869 void |
870 finish_do_stmt (tree cond, tree do_stmt, bool ivdep) | 870 finish_do_stmt (tree cond, tree do_stmt, bool ivdep, unsigned short unroll) |
871 { | 871 { |
872 if (check_no_cilk (cond, | |
873 "Cilk array notation cannot be used as a condition for a do-while statement", | |
874 "%<_Cilk_spawn%> statement cannot be used as a condition for a do-while statement")) | |
875 cond = error_mark_node; | |
876 cond = maybe_convert_cond (cond); | 872 cond = maybe_convert_cond (cond); |
877 end_maybe_infinite_loop (cond); | 873 end_maybe_infinite_loop (cond); |
878 if (ivdep && cond != error_mark_node) | 874 if (ivdep && cond != error_mark_node) |
879 cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, | 875 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, |
880 build_int_cst (integer_type_node, annot_expr_ivdep_kind)); | 876 build_int_cst (integer_type_node, annot_expr_ivdep_kind), |
877 integer_zero_node); | |
878 if (unroll && cond != error_mark_node) | |
879 cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond, | |
880 build_int_cst (integer_type_node, annot_expr_unroll_kind), | |
881 build_int_cst (integer_type_node, unroll)); | |
881 DO_COND (do_stmt) = cond; | 882 DO_COND (do_stmt) = cond; |
882 } | 883 } |
883 | 884 |
884 /* Finish a return-statement. The EXPRESSION returned, if any, is as | 885 /* Finish a return-statement. The EXPRESSION returned, if any, is as |
885 indicated. */ | 886 indicated. */ |
931 begin_for_stmt or begin_range_for_stmt. */ | 932 begin_for_stmt or begin_range_for_stmt. */ |
932 | 933 |
933 tree | 934 tree |
934 begin_for_scope (tree *init) | 935 begin_for_scope (tree *init) |
935 { | 936 { |
936 tree scope = NULL_TREE; | 937 tree scope = do_pushlevel (sk_for); |
937 if (flag_new_for_scope > 0) | |
938 scope = do_pushlevel (sk_for); | |
939 | 938 |
940 if (processing_template_decl) | 939 if (processing_template_decl) |
941 *init = push_stmt_list (); | 940 *init = push_stmt_list (); |
942 else | 941 else |
943 *init = NULL_TREE; | 942 *init = NULL_TREE; |
957 r = build_stmt (input_location, FOR_STMT, NULL_TREE, NULL_TREE, | 956 r = build_stmt (input_location, FOR_STMT, NULL_TREE, NULL_TREE, |
958 NULL_TREE, NULL_TREE, NULL_TREE); | 957 NULL_TREE, NULL_TREE, NULL_TREE); |
959 | 958 |
960 if (scope == NULL_TREE) | 959 if (scope == NULL_TREE) |
961 { | 960 { |
962 gcc_assert (!init || !(flag_new_for_scope > 0)); | 961 gcc_assert (!init); |
963 if (!init) | 962 scope = begin_for_scope (&init); |
964 scope = begin_for_scope (&init); | 963 } |
965 } | 964 |
966 FOR_INIT_STMT (r) = init; | 965 FOR_INIT_STMT (r) = init; |
967 FOR_SCOPE (r) = scope; | 966 FOR_SCOPE (r) = scope; |
968 | 967 |
969 return r; | 968 return r; |
970 } | 969 } |
984 | 983 |
985 /* Finish the COND of a for-statement, which may be given by | 984 /* Finish the COND of a for-statement, which may be given by |
986 FOR_STMT. */ | 985 FOR_STMT. */ |
987 | 986 |
988 void | 987 void |
989 finish_for_cond (tree cond, tree for_stmt, bool ivdep) | 988 finish_for_cond (tree cond, tree for_stmt, bool ivdep, unsigned short unroll) |
990 { | 989 { |
991 if (check_no_cilk (cond, | |
992 "Cilk array notation cannot be used in a condition for a for-loop", | |
993 "%<_Cilk_spawn%> statement cannot be used in a condition for a for-loop")) | |
994 cond = error_mark_node; | |
995 cond = maybe_convert_cond (cond); | 990 cond = maybe_convert_cond (cond); |
996 finish_cond (&FOR_COND (for_stmt), cond); | 991 finish_cond (&FOR_COND (for_stmt), cond); |
997 begin_maybe_infinite_loop (cond); | 992 begin_maybe_infinite_loop (cond); |
998 if (ivdep && cond != error_mark_node) | 993 if (ivdep && cond != error_mark_node) |
999 FOR_COND (for_stmt) = build2 (ANNOTATE_EXPR, | 994 FOR_COND (for_stmt) = build3 (ANNOTATE_EXPR, |
1000 TREE_TYPE (FOR_COND (for_stmt)), | 995 TREE_TYPE (FOR_COND (for_stmt)), |
1001 FOR_COND (for_stmt), | 996 FOR_COND (for_stmt), |
1002 build_int_cst (integer_type_node, | 997 build_int_cst (integer_type_node, |
1003 annot_expr_ivdep_kind)); | 998 annot_expr_ivdep_kind), |
999 integer_zero_node); | |
1000 if (unroll && cond != error_mark_node) | |
1001 FOR_COND (for_stmt) = build3 (ANNOTATE_EXPR, | |
1002 TREE_TYPE (FOR_COND (for_stmt)), | |
1003 FOR_COND (for_stmt), | |
1004 build_int_cst (integer_type_node, | |
1005 annot_expr_unroll_kind), | |
1006 build_int_cst (integer_type_node, | |
1007 unroll)); | |
1004 simplify_loop_decl_cond (&FOR_COND (for_stmt), FOR_BODY (for_stmt)); | 1008 simplify_loop_decl_cond (&FOR_COND (for_stmt), FOR_BODY (for_stmt)); |
1005 } | 1009 } |
1006 | 1010 |
1007 /* Finish the increment-EXPRESSION in a for-statement, which may be | 1011 /* Finish the increment-EXPRESSION in a for-statement, which may be |
1008 given by FOR_STMT. */ | 1012 given by FOR_STMT. */ |
1049 RANGE_FOR_BODY (for_stmt) = do_poplevel (RANGE_FOR_BODY (for_stmt)); | 1053 RANGE_FOR_BODY (for_stmt) = do_poplevel (RANGE_FOR_BODY (for_stmt)); |
1050 else | 1054 else |
1051 FOR_BODY (for_stmt) = do_poplevel (FOR_BODY (for_stmt)); | 1055 FOR_BODY (for_stmt) = do_poplevel (FOR_BODY (for_stmt)); |
1052 | 1056 |
1053 /* Pop the scope for the body of the loop. */ | 1057 /* Pop the scope for the body of the loop. */ |
1054 if (flag_new_for_scope > 0) | 1058 tree *scope_ptr = (TREE_CODE (for_stmt) == RANGE_FOR_STMT |
1055 { | 1059 ? &RANGE_FOR_SCOPE (for_stmt) |
1056 tree scope; | 1060 : &FOR_SCOPE (for_stmt)); |
1057 tree *scope_ptr = (TREE_CODE (for_stmt) == RANGE_FOR_STMT | 1061 tree scope = *scope_ptr; |
1058 ? &RANGE_FOR_SCOPE (for_stmt) | 1062 *scope_ptr = NULL; |
1059 : &FOR_SCOPE (for_stmt)); | 1063 |
1060 scope = *scope_ptr; | 1064 /* During parsing of the body, range for uses "__for_{range,begin,end} " |
1061 *scope_ptr = NULL; | 1065 decl names to make those unaccessible by code in the body. |
1062 add_stmt (do_poplevel (scope)); | 1066 Change it to ones with underscore instead of space, so that it can |
1063 } | 1067 be inspected in the debugger. */ |
1068 tree range_for_decl[3] = { NULL_TREE, NULL_TREE, NULL_TREE }; | |
1069 gcc_assert (CPTI_FOR_BEGIN__IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 1 | |
1070 && CPTI_FOR_END__IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 2 | |
1071 && CPTI_FOR_RANGE_IDENTIFIER == CPTI_FOR_RANGE__IDENTIFIER + 3 | |
1072 && CPTI_FOR_BEGIN_IDENTIFIER == CPTI_FOR_BEGIN__IDENTIFIER + 3 | |
1073 && CPTI_FOR_END_IDENTIFIER == CPTI_FOR_END__IDENTIFIER + 3); | |
1074 for (int i = 0; i < 3; i++) | |
1075 { | |
1076 tree id = cp_global_trees[CPTI_FOR_RANGE__IDENTIFIER + i]; | |
1077 if (IDENTIFIER_BINDING (id) | |
1078 && IDENTIFIER_BINDING (id)->scope == current_binding_level) | |
1079 { | |
1080 range_for_decl[i] = IDENTIFIER_BINDING (id)->value; | |
1081 gcc_assert (VAR_P (range_for_decl[i]) | |
1082 && DECL_ARTIFICIAL (range_for_decl[i])); | |
1083 } | |
1084 } | |
1085 | |
1086 add_stmt (do_poplevel (scope)); | |
1087 | |
1088 for (int i = 0; i < 3; i++) | |
1089 if (range_for_decl[i]) | |
1090 DECL_NAME (range_for_decl[i]) | |
1091 = cp_global_trees[CPTI_FOR_RANGE_IDENTIFIER + i]; | |
1064 } | 1092 } |
1065 | 1093 |
1066 /* Begin a range-for-statement. Returns a new RANGE_FOR_STMT. | 1094 /* Begin a range-for-statement. Returns a new RANGE_FOR_STMT. |
1067 SCOPE and INIT should be the return of begin_for_scope, | 1095 SCOPE and INIT should be the return of begin_for_scope, |
1068 or both NULL_TREE . | 1096 or both NULL_TREE . |
1069 To finish it call finish_for_stmt(). */ | 1097 To finish it call finish_for_stmt(). */ |
1070 | 1098 |
1071 tree | 1099 tree |
1072 begin_range_for_stmt (tree scope, tree init) | 1100 begin_range_for_stmt (tree scope, tree init) |
1073 { | 1101 { |
1074 tree r; | |
1075 | |
1076 begin_maybe_infinite_loop (boolean_false_node); | 1102 begin_maybe_infinite_loop (boolean_false_node); |
1077 | 1103 |
1078 r = build_stmt (input_location, RANGE_FOR_STMT, | 1104 tree r = build_stmt (input_location, RANGE_FOR_STMT, NULL_TREE, NULL_TREE, |
1079 NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE); | 1105 NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE); |
1080 | 1106 |
1081 if (scope == NULL_TREE) | 1107 if (scope == NULL_TREE) |
1082 { | 1108 { |
1083 gcc_assert (!init || !(flag_new_for_scope > 0)); | 1109 gcc_assert (!init); |
1084 if (!init) | 1110 scope = begin_for_scope (&init); |
1085 scope = begin_for_scope (&init); | 1111 } |
1086 } | 1112 |
1087 | 1113 /* Since C++20, RANGE_FOR_STMTs can use the init tree, so save it. */ |
1088 /* RANGE_FOR_STMTs do not use nor save the init tree, so we | 1114 RANGE_FOR_INIT_STMT (r) = init; |
1089 pop it now. */ | |
1090 if (init) | |
1091 pop_stmt_list (init); | |
1092 RANGE_FOR_SCOPE (r) = scope; | 1115 RANGE_FOR_SCOPE (r) = scope; |
1093 | 1116 |
1094 return r; | 1117 return r; |
1095 } | 1118 } |
1096 | 1119 |
1097 /* Finish the head of a range-based for statement, which may | 1120 /* Finish the head of a range-based for statement, which may |
1098 be given by RANGE_FOR_STMT. DECL must be the declaration | 1121 be given by RANGE_FOR_STMT. DECL must be the declaration |
1099 and EXPR must be the loop expression. */ | 1122 and EXPR must be the loop expression. */ |
1100 | 1123 |
1101 void | 1124 void |
1102 finish_range_for_decl (tree range_for_stmt, tree decl, tree expr) | 1125 finish_range_for_decl (tree range_for_stmt, tree decl, tree expr) |
1103 { | 1126 { |
1127 if (processing_template_decl) | |
1128 RANGE_FOR_INIT_STMT (range_for_stmt) | |
1129 = pop_stmt_list (RANGE_FOR_INIT_STMT (range_for_stmt)); | |
1104 RANGE_FOR_DECL (range_for_stmt) = decl; | 1130 RANGE_FOR_DECL (range_for_stmt) = decl; |
1105 RANGE_FOR_EXPR (range_for_stmt) = expr; | 1131 RANGE_FOR_EXPR (range_for_stmt) = expr; |
1106 add_stmt (range_for_stmt); | 1132 add_stmt (range_for_stmt); |
1107 RANGE_FOR_BODY (range_for_stmt) = do_pushlevel (sk_block); | 1133 RANGE_FOR_BODY (range_for_stmt) = do_pushlevel (sk_block); |
1108 } | 1134 } |
1119 language specific tree nodes; this works because | 1145 language specific tree nodes; this works because |
1120 block_may_fallthru returns true when given something it does not | 1146 block_may_fallthru returns true when given something it does not |
1121 understand. */ | 1147 understand. */ |
1122 if (!block_may_fallthru (cur_stmt_list)) | 1148 if (!block_may_fallthru (cur_stmt_list)) |
1123 return void_node; | 1149 return void_node; |
1150 note_break_stmt (); | |
1124 return add_stmt (build_stmt (input_location, BREAK_STMT)); | 1151 return add_stmt (build_stmt (input_location, BREAK_STMT)); |
1125 } | 1152 } |
1126 | 1153 |
1127 /* Finish a continue-statement. */ | 1154 /* Finish a continue-statement. */ |
1128 | 1155 |
1152 | 1179 |
1153 void | 1180 void |
1154 finish_switch_cond (tree cond, tree switch_stmt) | 1181 finish_switch_cond (tree cond, tree switch_stmt) |
1155 { | 1182 { |
1156 tree orig_type = NULL; | 1183 tree orig_type = NULL; |
1157 | |
1158 if (check_no_cilk (cond, | |
1159 "Cilk array notation cannot be used as a condition for switch statement", | |
1160 "%<_Cilk_spawn%> statement cannot be used as a condition for switch statement")) | |
1161 cond = error_mark_node; | |
1162 | 1184 |
1163 if (!processing_template_decl) | 1185 if (!processing_template_decl) |
1164 { | 1186 { |
1165 /* Convert the condition to an integer or enumeration type. */ | 1187 /* Convert the condition to an integer or enumeration type. */ |
1166 cond = build_expr_type_conversion (WANT_INT | WANT_ENUM, cond, true); | 1188 cond = build_expr_type_conversion (WANT_INT | WANT_ENUM, cond, true); |
1339 { | 1361 { |
1340 type = expand_start_catch_block (decl); | 1362 type = expand_start_catch_block (decl); |
1341 if (warn_catch_value | 1363 if (warn_catch_value |
1342 && type != NULL_TREE | 1364 && type != NULL_TREE |
1343 && type != error_mark_node | 1365 && type != error_mark_node |
1344 && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE) | 1366 && !TYPE_REF_P (TREE_TYPE (decl))) |
1345 { | 1367 { |
1346 tree orig_type = TREE_TYPE (decl); | 1368 tree orig_type = TREE_TYPE (decl); |
1347 if (CLASS_TYPE_P (orig_type)) | 1369 if (CLASS_TYPE_P (orig_type)) |
1348 { | 1370 { |
1349 if (TYPE_POLYMORPHIC_P (orig_type)) | 1371 if (TYPE_POLYMORPHIC_P (orig_type)) |
1509 || TREE_CODE (TREE_TYPE (operand)) == METHOD_TYPE | 1531 || TREE_CODE (TREE_TYPE (operand)) == METHOD_TYPE |
1510 /* If it's an aggregate and any field is const, then it is | 1532 /* If it's an aggregate and any field is const, then it is |
1511 effectively const. */ | 1533 effectively const. */ |
1512 || (CLASS_TYPE_P (TREE_TYPE (operand)) | 1534 || (CLASS_TYPE_P (TREE_TYPE (operand)) |
1513 && C_TYPE_FIELDS_READONLY (TREE_TYPE (operand))))) | 1535 && C_TYPE_FIELDS_READONLY (TREE_TYPE (operand))))) |
1514 cxx_readonly_error (operand, lv_asm); | 1536 cxx_readonly_error (input_location, operand, lv_asm); |
1537 | |
1538 tree *op = &operand; | |
1539 while (TREE_CODE (*op) == COMPOUND_EXPR) | |
1540 op = &TREE_OPERAND (*op, 1); | |
1541 switch (TREE_CODE (*op)) | |
1542 { | |
1543 case PREINCREMENT_EXPR: | |
1544 case PREDECREMENT_EXPR: | |
1545 case MODIFY_EXPR: | |
1546 *op = genericize_compound_lvalue (*op); | |
1547 op = &TREE_OPERAND (*op, 1); | |
1548 break; | |
1549 default: | |
1550 break; | |
1551 } | |
1515 | 1552 |
1516 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t))); | 1553 constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t))); |
1517 oconstraints[i] = constraint; | 1554 oconstraints[i] = constraint; |
1518 | 1555 |
1519 if (parse_output_constraint (&constraint, i, ninputs, noutputs, | 1556 if (parse_output_constraint (&constraint, i, ninputs, noutputs, |
1520 &allows_mem, &allows_reg, &is_inout)) | 1557 &allows_mem, &allows_reg, &is_inout)) |
1521 { | 1558 { |
1522 /* If the operand is going to end up in memory, | 1559 /* If the operand is going to end up in memory, |
1523 mark it addressable. */ | 1560 mark it addressable. */ |
1524 if (!allows_reg && !cxx_mark_addressable (operand)) | 1561 if (!allows_reg && !cxx_mark_addressable (*op)) |
1525 operand = error_mark_node; | 1562 operand = error_mark_node; |
1526 } | 1563 } |
1527 else | 1564 else |
1528 operand = error_mark_node; | 1565 operand = error_mark_node; |
1529 | 1566 |
1561 if (!allows_reg && allows_mem) | 1598 if (!allows_reg && allows_mem) |
1562 { | 1599 { |
1563 /* Strip the nops as we allow this case. FIXME, this really | 1600 /* Strip the nops as we allow this case. FIXME, this really |
1564 should be rejected or made deprecated. */ | 1601 should be rejected or made deprecated. */ |
1565 STRIP_NOPS (operand); | 1602 STRIP_NOPS (operand); |
1566 if (!cxx_mark_addressable (operand)) | 1603 |
1604 tree *op = &operand; | |
1605 while (TREE_CODE (*op) == COMPOUND_EXPR) | |
1606 op = &TREE_OPERAND (*op, 1); | |
1607 switch (TREE_CODE (*op)) | |
1608 { | |
1609 case PREINCREMENT_EXPR: | |
1610 case PREDECREMENT_EXPR: | |
1611 case MODIFY_EXPR: | |
1612 *op = genericize_compound_lvalue (*op); | |
1613 op = &TREE_OPERAND (*op, 1); | |
1614 break; | |
1615 default: | |
1616 break; | |
1617 } | |
1618 | |
1619 if (!cxx_mark_addressable (*op)) | |
1567 operand = error_mark_node; | 1620 operand = error_mark_node; |
1568 } | 1621 } |
1569 else if (!allows_reg && !allows_mem) | 1622 else if (!allows_reg && !allows_mem) |
1570 { | 1623 { |
1571 /* If constraint allows neither register nor memory, | 1624 /* If constraint allows neither register nor memory, |
1692 return expr; | 1745 return expr; |
1693 | 1746 |
1694 if (TREE_CODE (expr) == COMPONENT_REF | 1747 if (TREE_CODE (expr) == COMPONENT_REF |
1695 || TREE_CODE (expr) == SCOPE_REF) | 1748 || TREE_CODE (expr) == SCOPE_REF) |
1696 REF_PARENTHESIZED_P (expr) = true; | 1749 REF_PARENTHESIZED_P (expr) = true; |
1697 else if (type_dependent_expression_p (expr)) | 1750 else if (processing_template_decl) |
1698 expr = build1 (PAREN_EXPR, TREE_TYPE (expr), expr); | 1751 expr = build1 (PAREN_EXPR, TREE_TYPE (expr), expr); |
1699 else if (VAR_P (expr) && DECL_HARD_REGISTER (expr)) | |
1700 /* We can't bind a hard register variable to a reference. */; | |
1701 else | 1752 else |
1702 { | 1753 { |
1703 cp_lvalue_kind kind = lvalue_kind (expr); | 1754 expr = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (expr), expr); |
1704 if ((kind & ~clk_class) != clk_none) | 1755 REF_PARENTHESIZED_P (expr) = true; |
1705 { | |
1706 tree type = unlowered_expr_type (expr); | |
1707 bool rval = !!(kind & clk_rvalueref); | |
1708 type = cp_build_reference_type (type, rval); | |
1709 /* This inhibits warnings in, eg, cxx_mark_addressable | |
1710 (c++/60955). */ | |
1711 warning_sentinel s (extra_warnings); | |
1712 expr = build_static_cast (type, expr, tf_error); | |
1713 if (expr != error_mark_node) | |
1714 REF_PARENTHESIZED_P (expr) = true; | |
1715 } | |
1716 } | 1756 } |
1717 | 1757 |
1718 return expr; | 1758 return expr; |
1719 } | 1759 } |
1720 | 1760 |
1723 return T. */ | 1763 return T. */ |
1724 | 1764 |
1725 tree | 1765 tree |
1726 maybe_undo_parenthesized_ref (tree t) | 1766 maybe_undo_parenthesized_ref (tree t) |
1727 { | 1767 { |
1728 if (cxx_dialect >= cxx14 | 1768 if (cxx_dialect < cxx14) |
1729 && INDIRECT_REF_P (t) | 1769 return t; |
1730 && REF_PARENTHESIZED_P (t)) | 1770 |
1771 if (INDIRECT_REF_P (t) && REF_PARENTHESIZED_P (t)) | |
1731 { | 1772 { |
1732 t = TREE_OPERAND (t, 0); | 1773 t = TREE_OPERAND (t, 0); |
1733 while (TREE_CODE (t) == NON_LVALUE_EXPR | 1774 while (TREE_CODE (t) == NON_LVALUE_EXPR |
1734 || TREE_CODE (t) == NOP_EXPR) | 1775 || TREE_CODE (t) == NOP_EXPR) |
1735 t = TREE_OPERAND (t, 0); | 1776 t = TREE_OPERAND (t, 0); |
1736 | 1777 |
1737 gcc_assert (TREE_CODE (t) == ADDR_EXPR | 1778 gcc_assert (TREE_CODE (t) == ADDR_EXPR |
1738 || TREE_CODE (t) == STATIC_CAST_EXPR); | 1779 || TREE_CODE (t) == STATIC_CAST_EXPR); |
1739 t = TREE_OPERAND (t, 0); | 1780 t = TREE_OPERAND (t, 0); |
1740 } | 1781 } |
1782 else if (TREE_CODE (t) == PAREN_EXPR) | |
1783 t = TREE_OPERAND (t, 0); | |
1784 else if (TREE_CODE (t) == VIEW_CONVERT_EXPR | |
1785 && REF_PARENTHESIZED_P (t)) | |
1786 t = TREE_OPERAND (t, 0); | |
1741 | 1787 |
1742 return t; | 1788 return t; |
1743 } | 1789 } |
1744 | 1790 |
1745 /* Finish a parenthesized expression EXPR. */ | 1791 /* Finish a parenthesized expression EXPR. */ |
1806 TREE_USED (current_class_ptr) = 1; | 1852 TREE_USED (current_class_ptr) = 1; |
1807 if (processing_template_decl && !qualifying_scope) | 1853 if (processing_template_decl && !qualifying_scope) |
1808 { | 1854 { |
1809 tree type = TREE_TYPE (decl); | 1855 tree type = TREE_TYPE (decl); |
1810 | 1856 |
1811 if (TREE_CODE (type) == REFERENCE_TYPE) | 1857 if (TYPE_REF_P (type)) |
1812 /* Quals on the object don't matter. */; | 1858 /* Quals on the object don't matter. */; |
1813 else if (PACK_EXPANSION_P (type)) | 1859 else if (PACK_EXPANSION_P (type)) |
1814 /* Don't bother trying to represent this. */ | 1860 /* Don't bother trying to represent this. */ |
1815 type = NULL_TREE; | 1861 type = NULL_TREE; |
1816 else | 1862 else |
2001 return error_mark_node; | 2047 return error_mark_node; |
2002 | 2048 |
2003 if (template_p) | 2049 if (template_p) |
2004 { | 2050 { |
2005 if (TREE_CODE (expr) == UNBOUND_CLASS_TEMPLATE) | 2051 if (TREE_CODE (expr) == UNBOUND_CLASS_TEMPLATE) |
2006 /* cp_parser_lookup_name thought we were looking for a type, | 2052 { |
2007 but we're actually looking for a declaration. */ | 2053 /* cp_parser_lookup_name thought we were looking for a type, |
2008 expr = build_qualified_name (/*type*/NULL_TREE, | 2054 but we're actually looking for a declaration. */ |
2009 TYPE_CONTEXT (expr), | 2055 qualifying_class = TYPE_CONTEXT (expr); |
2010 TYPE_IDENTIFIER (expr), | 2056 expr = TYPE_IDENTIFIER (expr); |
2011 /*template_p*/true); | 2057 } |
2012 else | 2058 else |
2013 check_template_keyword (expr); | 2059 check_template_keyword (expr); |
2014 } | 2060 } |
2015 | 2061 |
2016 /* If EXPR occurs as the operand of '&', use special handling that | 2062 /* If EXPR occurs as the operand of '&', use special handling that |
2023 /*address_p=*/true, complain); | 2069 /*address_p=*/true, complain); |
2024 return expr; | 2070 return expr; |
2025 } | 2071 } |
2026 | 2072 |
2027 /* No need to check access within an enum. */ | 2073 /* No need to check access within an enum. */ |
2028 if (TREE_CODE (qualifying_class) == ENUMERAL_TYPE) | 2074 if (TREE_CODE (qualifying_class) == ENUMERAL_TYPE |
2075 && TREE_CODE (expr) != IDENTIFIER_NODE) | |
2029 return expr; | 2076 return expr; |
2030 | 2077 |
2031 /* Within the scope of a class, turn references to non-static | 2078 /* Within the scope of a class, turn references to non-static |
2032 members into expression of the form "this->...". */ | 2079 members into expression of the form "this->...". */ |
2033 if (template_arg_p) | 2080 if (template_arg_p) |
2068 we're looking at a member of the current instantiation, we | 2115 we're looking at a member of the current instantiation, we |
2069 know we have access and building up the SCOPE_REF confuses | 2116 know we have access and building up the SCOPE_REF confuses |
2070 non-type template argument handling. */ | 2117 non-type template argument handling. */ |
2071 if (processing_template_decl | 2118 if (processing_template_decl |
2072 && (!currently_open_class (qualifying_class) | 2119 && (!currently_open_class (qualifying_class) |
2120 || TREE_CODE (expr) == IDENTIFIER_NODE | |
2121 || TREE_CODE (expr) == TEMPLATE_ID_EXPR | |
2073 || TREE_CODE (expr) == BIT_NOT_EXPR)) | 2122 || TREE_CODE (expr) == BIT_NOT_EXPR)) |
2074 expr = build_qualified_name (TREE_TYPE (expr), | 2123 expr = build_qualified_name (TREE_TYPE (expr), |
2075 qualifying_class, expr, | 2124 qualifying_class, expr, |
2076 template_p); | 2125 template_p); |
2077 | 2126 |
2110 of the last statement is the value of the entire expression. */ | 2159 of the last statement is the value of the entire expression. */ |
2111 if (expr) | 2160 if (expr) |
2112 { | 2161 { |
2113 tree type = TREE_TYPE (expr); | 2162 tree type = TREE_TYPE (expr); |
2114 | 2163 |
2115 if (processing_template_decl) | 2164 if (type && type_unknown_p (type)) |
2165 { | |
2166 error ("a statement expression is an insufficient context" | |
2167 " for overload resolution"); | |
2168 TREE_TYPE (stmt_expr) = error_mark_node; | |
2169 return error_mark_node; | |
2170 } | |
2171 else if (processing_template_decl) | |
2116 { | 2172 { |
2117 expr = build_stmt (input_location, EXPR_STMT, expr); | 2173 expr = build_stmt (input_location, EXPR_STMT, expr); |
2118 expr = add_stmt (expr); | 2174 expr = add_stmt (expr); |
2119 /* Mark the last statement so that we can recognize it as such at | 2175 /* Mark the last statement so that we can recognize it as such at |
2120 template-instantiation time. */ | 2176 template-instantiation time. */ |
2286 if (complain & tf_error) | 2342 if (complain & tf_error) |
2287 fn = unqualified_fn_lookup_error (cp_expr (identifier, loc)); | 2343 fn = unqualified_fn_lookup_error (cp_expr (identifier, loc)); |
2288 else | 2344 else |
2289 fn = identifier; | 2345 fn = identifier; |
2290 } | 2346 } |
2347 else if (TREE_CODE (fn) == OVERLOAD && processing_template_decl) | |
2348 /* FIXME: We shouldn't really need to mark the lookup here, as | |
2349 resolving the (non-dependent) call should save the single | |
2350 function we resolve to. Related to PR c++/83529. */ | |
2351 lookup_keep (fn); | |
2291 } | 2352 } |
2292 | 2353 |
2293 if (fn && template_id && fn != error_mark_node) | 2354 if (fn && template_id && fn != error_mark_node) |
2294 fn = build2 (TEMPLATE_ID_EXPR, unknown_type_node, fn, tmpl_args); | 2355 fn = build2 (TEMPLATE_ID_EXPR, unknown_type_node, fn, tmpl_args); |
2295 | 2356 |
2311 finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual, | 2372 finish_call_expr (tree fn, vec<tree, va_gc> **args, bool disallow_virtual, |
2312 bool koenig_p, tsubst_flags_t complain) | 2373 bool koenig_p, tsubst_flags_t complain) |
2313 { | 2374 { |
2314 tree result; | 2375 tree result; |
2315 tree orig_fn; | 2376 tree orig_fn; |
2316 vec<tree, va_gc> *orig_args = NULL; | 2377 vec<tree, va_gc> *orig_args = *args; |
2317 | 2378 |
2318 if (fn == error_mark_node) | 2379 if (fn == error_mark_node) |
2319 return error_mark_node; | 2380 return error_mark_node; |
2320 | 2381 |
2321 gcc_assert (!TYPE_P (fn)); | 2382 gcc_assert (!TYPE_P (fn)); |
2343 expressions with no type as being dependent. */ | 2404 expressions with no type as being dependent. */ |
2344 if (type_dependent_expression_p (fn) | 2405 if (type_dependent_expression_p (fn) |
2345 || any_type_dependent_arguments_p (*args)) | 2406 || any_type_dependent_arguments_p (*args)) |
2346 { | 2407 { |
2347 result = build_min_nt_call_vec (orig_fn, *args); | 2408 result = build_min_nt_call_vec (orig_fn, *args); |
2348 SET_EXPR_LOCATION (result, EXPR_LOC_OR_LOC (fn, input_location)); | 2409 SET_EXPR_LOCATION (result, cp_expr_loc_or_loc (fn, input_location)); |
2349 KOENIG_LOOKUP_P (result) = koenig_p; | 2410 KOENIG_LOOKUP_P (result) = koenig_p; |
2350 if (is_overloaded_fn (fn)) | 2411 if (is_overloaded_fn (fn)) |
2351 { | 2412 fn = get_fns (fn); |
2352 fn = get_fns (fn); | |
2353 lookup_keep (fn, true); | |
2354 } | |
2355 | 2413 |
2356 if (cfun) | 2414 if (cfun) |
2357 { | 2415 { |
2358 bool abnormal = true; | 2416 bool abnormal = true; |
2359 for (lkp_iterator iter (fn); abnormal && iter; ++iter) | 2417 for (lkp_iterator iter (fn); abnormal && iter; ++iter) |
2485 sizeof_pointer_memaccess_warning | 2543 sizeof_pointer_memaccess_warning |
2486 (sizeof_arg_loc, fn, *args, | 2544 (sizeof_arg_loc, fn, *args, |
2487 sizeof_arg, same_type_ignoring_top_level_qualifiers_p); | 2545 sizeof_arg, same_type_ignoring_top_level_qualifiers_p); |
2488 } | 2546 } |
2489 | 2547 |
2548 if ((complain & tf_warning) | |
2549 && TREE_CODE (fn) == FUNCTION_DECL | |
2550 && fndecl_built_in_p (fn, BUILT_IN_MEMSET) | |
2551 && vec_safe_length (*args) == 3 | |
2552 && !any_type_dependent_arguments_p (*args)) | |
2553 { | |
2554 tree arg0 = (*orig_args)[0]; | |
2555 tree arg1 = (*orig_args)[1]; | |
2556 tree arg2 = (*orig_args)[2]; | |
2557 int literal_mask = ((literal_integer_zerop (arg1) << 1) | |
2558 | (literal_integer_zerop (arg2) << 2)); | |
2559 arg2 = instantiate_non_dependent_expr (arg2); | |
2560 warn_for_memset (input_location, arg0, arg2, literal_mask); | |
2561 } | |
2562 | |
2490 /* A call to a namespace-scope function. */ | 2563 /* A call to a namespace-scope function. */ |
2491 result = build_new_function_call (fn, args, complain); | 2564 result = build_new_function_call (fn, args, complain); |
2492 } | 2565 } |
2493 } | 2566 } |
2494 else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR) | 2567 else if (TREE_CODE (fn) == PSEUDO_DTOR_EXPR) |
2519 SET_EXPR_LOCATION (result, input_location); | 2592 SET_EXPR_LOCATION (result, input_location); |
2520 KOENIG_LOOKUP_P (result) = koenig_p; | 2593 KOENIG_LOOKUP_P (result) = koenig_p; |
2521 release_tree_vector (orig_args); | 2594 release_tree_vector (orig_args); |
2522 result = convert_from_reference (result); | 2595 result = convert_from_reference (result); |
2523 } | 2596 } |
2524 | |
2525 /* Free or retain OVERLOADs from lookup. */ | |
2526 if (is_overloaded_fn (orig_fn)) | |
2527 lookup_keep (get_fns (orig_fn), processing_template_decl); | |
2528 | 2597 |
2529 return result; | 2598 return result; |
2530 } | 2599 } |
2531 | 2600 |
2532 /* Finish a call to a postfix increment or decrement or EXPR. (Which | 2601 /* Finish a call to a postfix increment or decrement or EXPR. (Which |
2656 op_loc, expr.get_finish ()); | 2725 op_loc, expr.get_finish ()); |
2657 cp_expr result = build_x_unary_op (combined_loc, code, expr, complain); | 2726 cp_expr result = build_x_unary_op (combined_loc, code, expr, complain); |
2658 /* TODO: build_x_unary_op doesn't always honor the location. */ | 2727 /* TODO: build_x_unary_op doesn't always honor the location. */ |
2659 result.set_location (combined_loc); | 2728 result.set_location (combined_loc); |
2660 | 2729 |
2661 tree result_ovl, expr_ovl; | 2730 if (result == error_mark_node) |
2731 return result; | |
2662 | 2732 |
2663 if (!(complain & tf_warning)) | 2733 if (!(complain & tf_warning)) |
2664 return result; | 2734 return result; |
2665 | 2735 |
2666 result_ovl = result; | 2736 tree result_ovl = result; |
2667 expr_ovl = expr; | 2737 tree expr_ovl = expr; |
2668 | 2738 |
2669 if (!processing_template_decl) | 2739 if (!processing_template_decl) |
2670 expr_ovl = cp_fully_fold (expr_ovl); | 2740 expr_ovl = cp_fully_fold (expr_ovl); |
2671 | 2741 |
2672 if (!CONSTANT_CLASS_P (expr_ovl) | 2742 if (!CONSTANT_CLASS_P (expr_ovl) |
2692 fcl_t fcl_context) | 2762 fcl_t fcl_context) |
2693 { | 2763 { |
2694 if (type == error_mark_node) | 2764 if (type == error_mark_node) |
2695 return error_mark_node; | 2765 return error_mark_node; |
2696 | 2766 |
2697 if (TREE_CODE (type) == REFERENCE_TYPE) | 2767 if (TYPE_REF_P (type)) |
2698 { | 2768 { |
2699 compound_literal | 2769 compound_literal |
2700 = finish_compound_literal (TREE_TYPE (type), compound_literal, | 2770 = finish_compound_literal (TREE_TYPE (type), compound_literal, |
2701 complain, fcl_context); | 2771 complain, fcl_context); |
2702 return cp_build_c_cast (type, compound_literal, complain); | 2772 /* The prvalue is then used to direct-initialize the reference. */ |
2773 tree r = (perform_implicit_conversion_flags | |
2774 (type, compound_literal, complain, LOOKUP_NORMAL)); | |
2775 return convert_from_reference (r); | |
2703 } | 2776 } |
2704 | 2777 |
2705 if (!TYPE_OBJ_P (type)) | 2778 if (!TYPE_OBJ_P (type)) |
2706 { | 2779 { |
2707 if (complain & tf_error) | 2780 if (complain & tf_error) |
3289 return (outer_var_p (decl) | 3362 return (outer_var_p (decl) |
3290 && !TREE_STATIC (decl)); | 3363 && !TREE_STATIC (decl)); |
3291 } | 3364 } |
3292 | 3365 |
3293 /* DECL satisfies outer_automatic_var_p. Possibly complain about it or | 3366 /* DECL satisfies outer_automatic_var_p. Possibly complain about it or |
3294 rewrite it for lambda capture. */ | 3367 rewrite it for lambda capture. |
3368 | |
3369 If ODR_USE is true, we're being called from mark_use, and we complain about | |
3370 use of constant variables. If ODR_USE is false, we're being called for the | |
3371 id-expression, and we do lambda capture. */ | |
3295 | 3372 |
3296 tree | 3373 tree |
3297 process_outer_var_ref (tree decl, tsubst_flags_t complain, bool force_use) | 3374 process_outer_var_ref (tree decl, tsubst_flags_t complain, bool odr_use) |
3298 { | 3375 { |
3299 if (cp_unevaluated_operand) | 3376 if (cp_unevaluated_operand) |
3300 /* It's not a use (3.2) if we're in an unevaluated context. */ | 3377 /* It's not a use (3.2) if we're in an unevaluated context. */ |
3301 return decl; | 3378 return decl; |
3302 if (decl == error_mark_node) | 3379 if (decl == error_mark_node) |
3313 return error_mark_node; | 3390 return error_mark_node; |
3314 | 3391 |
3315 if (parsing_nsdmi ()) | 3392 if (parsing_nsdmi ()) |
3316 containing_function = NULL_TREE; | 3393 containing_function = NULL_TREE; |
3317 | 3394 |
3318 /* Core issue 696: Only an odr-use of an outer automatic variable causes a | |
3319 capture (or error), and a constant variable can decay to a prvalue | |
3320 constant without odr-use. So don't capture yet. */ | |
3321 if (decl_constant_var_p (decl) && !force_use) | |
3322 return decl; | |
3323 | |
3324 if (containing_function && LAMBDA_FUNCTION_P (containing_function)) | 3395 if (containing_function && LAMBDA_FUNCTION_P (containing_function)) |
3325 { | 3396 { |
3326 /* Check whether we've already built a proxy. */ | 3397 /* Check whether we've already built a proxy. */ |
3327 tree var = decl; | 3398 tree var = decl; |
3328 while (is_normal_capture_proxy (var)) | 3399 while (is_normal_capture_proxy (var)) |
3334 if (DECL_CONTEXT (d) == containing_function) | 3405 if (DECL_CONTEXT (d) == containing_function) |
3335 /* We already have an inner proxy. */ | 3406 /* We already have an inner proxy. */ |
3336 return d; | 3407 return d; |
3337 else | 3408 else |
3338 /* We need to capture an outer proxy. */ | 3409 /* We need to capture an outer proxy. */ |
3339 return process_outer_var_ref (d, complain, force_use); | 3410 return process_outer_var_ref (d, complain, odr_use); |
3340 } | 3411 } |
3341 } | 3412 } |
3342 | 3413 |
3343 /* If we are in a lambda function, we can move out until we hit | 3414 /* If we are in a lambda function, we can move out until we hit |
3344 1. the context, | 3415 1. the context, |
3380 { | 3451 { |
3381 if (complain & tf_error) | 3452 if (complain & tf_error) |
3382 error ("cannot capture member %qD of anonymous union", decl); | 3453 error ("cannot capture member %qD of anonymous union", decl); |
3383 return error_mark_node; | 3454 return error_mark_node; |
3384 } | 3455 } |
3385 if (context == containing_function) | 3456 /* Do lambda capture when processing the id-expression, not when |
3457 odr-using a variable. */ | |
3458 if (!odr_use && context == containing_function) | |
3386 { | 3459 { |
3387 decl = add_default_capture (lambda_stack, | 3460 decl = add_default_capture (lambda_stack, |
3388 /*id=*/DECL_NAME (decl), | 3461 /*id=*/DECL_NAME (decl), |
3389 initializer); | 3462 initializer); |
3390 } | 3463 } |
3464 /* Only an odr-use of an outer automatic variable causes an | |
3465 error, and a constant variable can decay to a prvalue | |
3466 constant without odr-use. So don't complain yet. */ | |
3467 else if (!odr_use && decl_constant_var_p (decl)) | |
3468 return decl; | |
3391 else if (lambda_expr) | 3469 else if (lambda_expr) |
3392 { | 3470 { |
3393 if (complain & tf_error) | 3471 if (complain & tf_error) |
3394 { | 3472 { |
3395 error ("%qD is not captured", decl); | 3473 error ("%qD is not captured", decl); |
3397 if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) | 3475 if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) |
3398 == CPLD_NONE) | 3476 == CPLD_NONE) |
3399 inform (location_of (closure), | 3477 inform (location_of (closure), |
3400 "the lambda has no capture-default"); | 3478 "the lambda has no capture-default"); |
3401 else if (TYPE_CLASS_SCOPE_P (closure)) | 3479 else if (TYPE_CLASS_SCOPE_P (closure)) |
3402 inform (0, "lambda in local class %q+T cannot " | 3480 inform (UNKNOWN_LOCATION, "lambda in local class %q+T cannot " |
3403 "capture variables from the enclosing context", | 3481 "capture variables from the enclosing context", |
3404 TYPE_CONTEXT (closure)); | 3482 TYPE_CONTEXT (closure)); |
3405 inform (DECL_SOURCE_LOCATION (decl), "%q#D declared here", decl); | 3483 inform (DECL_SOURCE_LOCATION (decl), "%q#D declared here", decl); |
3406 } | 3484 } |
3407 return error_mark_node; | 3485 return error_mark_node; |
3509 return id_expression; | 3587 return id_expression; |
3510 } | 3588 } |
3511 else | 3589 else |
3512 decl = id_expression; | 3590 decl = id_expression; |
3513 } | 3591 } |
3514 /* If DECL is a variable that would be out of scope under | |
3515 ANSI/ISO rules, but in scope in the ARM, name lookup | |
3516 will succeed. Issue a diagnostic here. */ | |
3517 else | |
3518 decl = check_for_out_of_scope_variable (decl); | |
3519 | 3592 |
3520 /* Remember that the name was used in the definition of | 3593 /* Remember that the name was used in the definition of |
3521 the current class so that we can check later to see if | 3594 the current class so that we can check later to see if |
3522 the meaning would have been different after the class | 3595 the meaning would have been different after the class |
3523 was entirely defined. */ | 3596 was entirely defined. */ |
3835 | 3908 |
3836 return underlying_type; | 3909 return underlying_type; |
3837 } | 3910 } |
3838 | 3911 |
3839 /* Implement the __direct_bases keyword: Return the direct base classes | 3912 /* Implement the __direct_bases keyword: Return the direct base classes |
3840 of type */ | 3913 of type. */ |
3841 | 3914 |
3842 tree | 3915 tree |
3843 calculate_direct_bases (tree type) | 3916 calculate_direct_bases (tree type, tsubst_flags_t complain) |
3844 { | 3917 { |
3845 vec<tree, va_gc> *vector = make_tree_vector(); | 3918 if (!complete_type_or_maybe_complain (type, NULL_TREE, complain) |
3846 tree bases_vec = NULL_TREE; | 3919 || !NON_UNION_CLASS_TYPE_P (type)) |
3847 vec<tree, va_gc> *base_binfos; | 3920 return make_tree_vec (0); |
3921 | |
3922 vec<tree, va_gc> *vector = make_tree_vector (); | |
3923 vec<tree, va_gc> *base_binfos = BINFO_BASE_BINFOS (TYPE_BINFO (type)); | |
3848 tree binfo; | 3924 tree binfo; |
3849 unsigned i; | 3925 unsigned i; |
3850 | 3926 |
3851 complete_type (type); | |
3852 | |
3853 if (!NON_UNION_CLASS_TYPE_P (type)) | |
3854 return make_tree_vec (0); | |
3855 | |
3856 base_binfos = BINFO_BASE_BINFOS (TYPE_BINFO (type)); | |
3857 | |
3858 /* Virtual bases are initialized first */ | 3927 /* Virtual bases are initialized first */ |
3859 for (i = 0; base_binfos->iterate (i, &binfo); i++) | 3928 for (i = 0; base_binfos->iterate (i, &binfo); i++) |
3860 { | 3929 if (BINFO_VIRTUAL_P (binfo)) |
3861 if (BINFO_VIRTUAL_P (binfo)) | 3930 vec_safe_push (vector, binfo); |
3862 { | |
3863 vec_safe_push (vector, binfo); | |
3864 } | |
3865 } | |
3866 | 3931 |
3867 /* Now non-virtuals */ | 3932 /* Now non-virtuals */ |
3868 for (i = 0; base_binfos->iterate (i, &binfo); i++) | 3933 for (i = 0; base_binfos->iterate (i, &binfo); i++) |
3869 { | 3934 if (!BINFO_VIRTUAL_P (binfo)) |
3870 if (!BINFO_VIRTUAL_P (binfo)) | 3935 vec_safe_push (vector, binfo); |
3871 { | 3936 |
3872 vec_safe_push (vector, binfo); | 3937 tree bases_vec = make_tree_vec (vector->length ()); |
3873 } | |
3874 } | |
3875 | |
3876 | |
3877 bases_vec = make_tree_vec (vector->length ()); | |
3878 | 3938 |
3879 for (i = 0; i < vector->length (); ++i) | 3939 for (i = 0; i < vector->length (); ++i) |
3880 { | 3940 TREE_VEC_ELT (bases_vec, i) = BINFO_TYPE ((*vector)[i]); |
3881 TREE_VEC_ELT (bases_vec, i) = BINFO_TYPE ((*vector)[i]); | 3941 |
3882 } | 3942 release_tree_vector (vector); |
3883 return bases_vec; | 3943 return bases_vec; |
3884 } | 3944 } |
3885 | 3945 |
3886 /* Implement the __bases keyword: Return the base classes | 3946 /* Implement the __bases keyword: Return the base classes |
3887 of type */ | 3947 of type */ |
3899 static tree | 3959 static tree |
3900 dfs_calculate_bases_post (tree binfo, void *data_) | 3960 dfs_calculate_bases_post (tree binfo, void *data_) |
3901 { | 3961 { |
3902 vec<tree, va_gc> **data = ((vec<tree, va_gc> **) data_); | 3962 vec<tree, va_gc> **data = ((vec<tree, va_gc> **) data_); |
3903 if (!BINFO_VIRTUAL_P (binfo)) | 3963 if (!BINFO_VIRTUAL_P (binfo)) |
3904 { | 3964 vec_safe_push (*data, BINFO_TYPE (binfo)); |
3905 vec_safe_push (*data, BINFO_TYPE (binfo)); | |
3906 } | |
3907 return NULL_TREE; | 3965 return NULL_TREE; |
3908 } | 3966 } |
3909 | 3967 |
3910 /* Calculates the morally non-virtual base classes of a class */ | 3968 /* Calculates the morally non-virtual base classes of a class */ |
3911 static vec<tree, va_gc> * | 3969 static vec<tree, va_gc> * |
3912 calculate_bases_helper (tree type) | 3970 calculate_bases_helper (tree type) |
3913 { | 3971 { |
3914 vec<tree, va_gc> *vector = make_tree_vector(); | 3972 vec<tree, va_gc> *vector = make_tree_vector (); |
3915 | 3973 |
3916 /* Now add non-virtual base classes in order of construction */ | 3974 /* Now add non-virtual base classes in order of construction */ |
3917 if (TYPE_BINFO (type)) | 3975 if (TYPE_BINFO (type)) |
3918 dfs_walk_all (TYPE_BINFO (type), | 3976 dfs_walk_all (TYPE_BINFO (type), |
3919 dfs_calculate_bases_pre, dfs_calculate_bases_post, &vector); | 3977 dfs_calculate_bases_pre, dfs_calculate_bases_post, &vector); |
3920 return vector; | 3978 return vector; |
3921 } | 3979 } |
3922 | 3980 |
3923 tree | 3981 tree |
3924 calculate_bases (tree type) | 3982 calculate_bases (tree type, tsubst_flags_t complain) |
3925 { | 3983 { |
3926 vec<tree, va_gc> *vector = make_tree_vector(); | 3984 if (!complete_type_or_maybe_complain (type, NULL_TREE, complain) |
3985 || !NON_UNION_CLASS_TYPE_P (type)) | |
3986 return make_tree_vec (0); | |
3987 | |
3988 vec<tree, va_gc> *vector = make_tree_vector (); | |
3927 tree bases_vec = NULL_TREE; | 3989 tree bases_vec = NULL_TREE; |
3928 unsigned i; | 3990 unsigned i; |
3929 vec<tree, va_gc> *vbases; | 3991 vec<tree, va_gc> *vbases; |
3930 vec<tree, va_gc> *nonvbases; | 3992 vec<tree, va_gc> *nonvbases; |
3931 tree binfo; | 3993 tree binfo; |
3932 | 3994 |
3933 complete_type (type); | |
3934 | |
3935 if (!NON_UNION_CLASS_TYPE_P (type)) | |
3936 return make_tree_vec (0); | |
3937 | |
3938 /* First go through virtual base classes */ | 3995 /* First go through virtual base classes */ |
3939 for (vbases = CLASSTYPE_VBASECLASSES (type), i = 0; | 3996 for (vbases = CLASSTYPE_VBASECLASSES (type), i = 0; |
3940 vec_safe_iterate (vbases, i, &binfo); i++) | 3997 vec_safe_iterate (vbases, i, &binfo); i++) |
3941 { | 3998 { |
3942 vec<tree, va_gc> *vbase_bases; | 3999 vec<tree, va_gc> *vbase_bases |
3943 vbase_bases = calculate_bases_helper (BINFO_TYPE (binfo)); | 4000 = calculate_bases_helper (BINFO_TYPE (binfo)); |
3944 vec_safe_splice (vector, vbase_bases); | 4001 vec_safe_splice (vector, vbase_bases); |
3945 release_tree_vector (vbase_bases); | 4002 release_tree_vector (vbase_bases); |
3946 } | 4003 } |
3947 | 4004 |
3948 /* Now for the non-virtual bases */ | 4005 /* Now for the non-virtual bases */ |
3952 | 4009 |
3953 /* Note that during error recovery vector->length can even be zero. */ | 4010 /* Note that during error recovery vector->length can even be zero. */ |
3954 if (vector->length () > 1) | 4011 if (vector->length () > 1) |
3955 { | 4012 { |
3956 /* Last element is entire class, so don't copy */ | 4013 /* Last element is entire class, so don't copy */ |
3957 bases_vec = make_tree_vec (vector->length() - 1); | 4014 bases_vec = make_tree_vec (vector->length () - 1); |
3958 | 4015 |
3959 for (i = 0; i < vector->length () - 1; ++i) | 4016 for (i = 0; i < vector->length () - 1; ++i) |
3960 TREE_VEC_ELT (bases_vec, i) = (*vector)[i]; | 4017 TREE_VEC_ELT (bases_vec, i) = (*vector)[i]; |
3961 } | 4018 } |
3962 else | 4019 else |
4009 } | 4066 } |
4010 if (TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE | 4067 if (TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE |
4011 || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE | 4068 || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE |
4012 || TREE_TYPE (expr) == unknown_type_node) | 4069 || TREE_TYPE (expr) == unknown_type_node) |
4013 { | 4070 { |
4014 if (INDIRECT_REF_P (expr)) | 4071 while (TREE_CODE (expr) == COMPONENT_REF |
4015 error ("second operand of %<offsetof%> is neither a single " | 4072 || TREE_CODE (expr) == COMPOUND_EXPR) |
4016 "identifier nor a sequence of member accesses and " | 4073 expr = TREE_OPERAND (expr, 1); |
4017 "array references"); | 4074 |
4075 if (DECL_P (expr)) | |
4076 { | |
4077 error ("cannot apply %<offsetof%> to member function %qD", expr); | |
4078 inform (DECL_SOURCE_LOCATION (expr), "declared here"); | |
4079 } | |
4018 else | 4080 else |
4019 { | 4081 error ("cannot apply %<offsetof%> to member function"); |
4020 if (TREE_CODE (expr) == COMPONENT_REF | 4082 return error_mark_node; |
4021 || TREE_CODE (expr) == COMPOUND_EXPR) | 4083 } |
4022 expr = TREE_OPERAND (expr, 1); | 4084 if (TREE_CODE (expr) == CONST_DECL) |
4023 error ("cannot apply %<offsetof%> to member function %qD", expr); | 4085 { |
4024 } | 4086 error ("cannot apply %<offsetof%> to an enumerator %qD", expr); |
4025 return error_mark_node; | 4087 return error_mark_node; |
4026 } | 4088 } |
4027 if (REFERENCE_REF_P (expr)) | 4089 if (REFERENCE_REF_P (expr)) |
4028 expr = TREE_OPERAND (expr, 0); | 4090 expr = TREE_OPERAND (expr, 0); |
4029 if (!complete_type_or_else (TREE_TYPE (TREE_TYPE (object_ptr)), object_ptr)) | 4091 if (!complete_type_or_else (TREE_TYPE (TREE_TYPE (object_ptr)), object_ptr)) |
4030 return error_mark_node; | 4092 return error_mark_node; |
4031 if (warn_invalid_offsetof | 4093 if (warn_invalid_offsetof |
4032 && CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (object_ptr))) | 4094 && CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (object_ptr))) |
4033 && CLASSTYPE_NON_STD_LAYOUT (TREE_TYPE (TREE_TYPE (object_ptr))) | 4095 && CLASSTYPE_NON_STD_LAYOUT (TREE_TYPE (TREE_TYPE (object_ptr))) |
4034 && cp_unevaluated_operand == 0) | 4096 && cp_unevaluated_operand == 0) |
4035 pedwarn (loc, OPT_Winvalid_offsetof, | 4097 warning_at (loc, OPT_Winvalid_offsetof, "offsetof within " |
4036 "offsetof within non-standard-layout type %qT is undefined", | 4098 "non-standard-layout type %qT is conditionally-supported", |
4037 TREE_TYPE (TREE_TYPE (object_ptr))); | 4099 TREE_TYPE (TREE_TYPE (object_ptr))); |
4038 return fold_offsetof (expr); | 4100 return fold_offsetof (expr); |
4039 } | 4101 } |
4040 | 4102 |
4041 /* Replace the AGGR_INIT_EXPR at *TP with an equivalent CALL_EXPR. This | 4103 /* Replace the AGGR_INIT_EXPR at *TP with an equivalent CALL_EXPR. This |
4042 function is broken out from the above for the benefit of the tree-ssa | 4104 function is broken out from the above for the benefit of the tree-ssa |
4076 CALL_FROM_THUNK_P (call_expr) = AGGR_INIT_FROM_THUNK_P (aggr_init_expr); | 4138 CALL_FROM_THUNK_P (call_expr) = AGGR_INIT_FROM_THUNK_P (aggr_init_expr); |
4077 CALL_EXPR_OPERATOR_SYNTAX (call_expr) | 4139 CALL_EXPR_OPERATOR_SYNTAX (call_expr) |
4078 = CALL_EXPR_OPERATOR_SYNTAX (aggr_init_expr); | 4140 = CALL_EXPR_OPERATOR_SYNTAX (aggr_init_expr); |
4079 CALL_EXPR_ORDERED_ARGS (call_expr) = CALL_EXPR_ORDERED_ARGS (aggr_init_expr); | 4141 CALL_EXPR_ORDERED_ARGS (call_expr) = CALL_EXPR_ORDERED_ARGS (aggr_init_expr); |
4080 CALL_EXPR_REVERSE_ARGS (call_expr) = CALL_EXPR_REVERSE_ARGS (aggr_init_expr); | 4142 CALL_EXPR_REVERSE_ARGS (call_expr) = CALL_EXPR_REVERSE_ARGS (aggr_init_expr); |
4081 /* Preserve CILK_SPAWN flag. */ | |
4082 EXPR_CILK_SPAWN (call_expr) = EXPR_CILK_SPAWN (aggr_init_expr); | |
4083 | 4143 |
4084 if (style == ctor) | 4144 if (style == ctor) |
4085 { | 4145 { |
4086 /* Replace the first argument to the ctor with the address of the | 4146 /* Replace the first argument to the ctor with the address of the |
4087 slot. */ | 4147 slot. */ |
4388 && DECL_ARTIFICIAL (decl) | 4448 && DECL_ARTIFICIAL (decl) |
4389 && DECL_LANG_SPECIFIC (decl) | 4449 && DECL_LANG_SPECIFIC (decl) |
4390 && DECL_OMP_PRIVATIZED_MEMBER (decl)) | 4450 && DECL_OMP_PRIVATIZED_MEMBER (decl)) |
4391 { | 4451 { |
4392 tree f = DECL_VALUE_EXPR (decl); | 4452 tree f = DECL_VALUE_EXPR (decl); |
4393 if (TREE_CODE (f) == INDIRECT_REF) | 4453 if (INDIRECT_REF_P (f)) |
4394 f = TREE_OPERAND (f, 0); | 4454 f = TREE_OPERAND (f, 0); |
4395 if (TREE_CODE (f) == COMPONENT_REF) | 4455 if (TREE_CODE (f) == COMPONENT_REF) |
4396 { | 4456 { |
4397 f = TREE_OPERAND (f, 1); | 4457 f = TREE_OPERAND (f, 1); |
4398 gcc_assert (TREE_CODE (f) == FIELD_DECL); | 4458 gcc_assert (TREE_CODE (f) == FIELD_DECL); |
4441 tree m = finish_non_static_data_member (t, NULL_TREE, NULL_TREE); | 4501 tree m = finish_non_static_data_member (t, NULL_TREE, NULL_TREE); |
4442 if (m == error_mark_node) | 4502 if (m == error_mark_node) |
4443 return error_mark_node; | 4503 return error_mark_node; |
4444 if (!omp_private_member_map && !shared) | 4504 if (!omp_private_member_map && !shared) |
4445 omp_private_member_map = new hash_map<tree, tree>; | 4505 omp_private_member_map = new hash_map<tree, tree>; |
4446 if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) | 4506 if (TYPE_REF_P (TREE_TYPE (t))) |
4447 { | 4507 { |
4448 gcc_assert (TREE_CODE (m) == INDIRECT_REF); | 4508 gcc_assert (INDIRECT_REF_P (m)); |
4449 m = TREE_OPERAND (m, 0); | 4509 m = TREE_OPERAND (m, 0); |
4450 } | 4510 } |
4451 tree vb = NULL_TREE; | 4511 tree vb = NULL_TREE; |
4452 tree &v = shared ? vb : omp_private_member_map->get_or_insert (t); | 4512 tree &v = shared ? vb : omp_private_member_map->get_or_insert (t); |
4453 if (v == NULL_TREE) | 4513 if (v == NULL_TREE) |
4759 TREE_PURPOSE (t) = lb; | 4819 TREE_PURPOSE (t) = lb; |
4760 low_bound = lb; | 4820 low_bound = lb; |
4761 } | 4821 } |
4762 } | 4822 } |
4763 } | 4823 } |
4764 else if (TREE_CODE (type) == POINTER_TYPE) | 4824 else if (TYPE_PTR_P (type)) |
4765 { | 4825 { |
4766 if (length == NULL_TREE) | 4826 if (length == NULL_TREE) |
4767 { | 4827 { |
4768 error_at (OMP_CLAUSE_LOCATION (c), | 4828 error_at (OMP_CLAUSE_LOCATION (c), |
4769 "for pointer type length expression must be specified"); | 4829 "for pointer type length expression must be specified"); |
4973 tree eltype = TREE_TYPE (first); | 5033 tree eltype = TREE_TYPE (first); |
4974 while (TREE_CODE (eltype) == ARRAY_TYPE) | 5034 while (TREE_CODE (eltype) == ARRAY_TYPE) |
4975 eltype = TREE_TYPE (eltype); | 5035 eltype = TREE_TYPE (eltype); |
4976 tree type = build_array_type (eltype, index_type); | 5036 tree type = build_array_type (eltype, index_type); |
4977 tree ptype = build_pointer_type (eltype); | 5037 tree ptype = build_pointer_type (eltype); |
4978 if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE | 5038 if (TYPE_REF_P (TREE_TYPE (t)) |
4979 && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t)))) | 5039 && INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (t)))) |
4980 t = convert_from_reference (t); | 5040 t = convert_from_reference (t); |
4981 else if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) | 5041 else if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) |
4982 t = build_fold_addr_expr (t); | 5042 t = build_fold_addr_expr (t); |
4983 tree t2 = build_fold_addr_expr (first); | 5043 tree t2 = build_fold_addr_expr (first); |
4984 t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c), | 5044 t2 = fold_convert_loc (OMP_CLAUSE_LOCATION (c), |
5049 t = build_fold_addr_expr (first); | 5109 t = build_fold_addr_expr (first); |
5050 t = fold_convert_loc (OMP_CLAUSE_LOCATION (c), | 5110 t = fold_convert_loc (OMP_CLAUSE_LOCATION (c), |
5051 ptrdiff_type_node, t); | 5111 ptrdiff_type_node, t); |
5052 tree ptr = OMP_CLAUSE_DECL (c2); | 5112 tree ptr = OMP_CLAUSE_DECL (c2); |
5053 ptr = convert_from_reference (ptr); | 5113 ptr = convert_from_reference (ptr); |
5054 if (!POINTER_TYPE_P (TREE_TYPE (ptr))) | 5114 if (!INDIRECT_TYPE_P (TREE_TYPE (ptr))) |
5055 ptr = build_fold_addr_expr (ptr); | 5115 ptr = build_fold_addr_expr (ptr); |
5056 t = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR, | 5116 t = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MINUS_EXPR, |
5057 ptrdiff_type_node, t, | 5117 ptrdiff_type_node, t, |
5058 fold_convert_loc (OMP_CLAUSE_LOCATION (c), | 5118 fold_convert_loc (OMP_CLAUSE_LOCATION (c), |
5059 ptrdiff_type_node, ptr)); | 5119 ptrdiff_type_node, ptr)); |
5060 OMP_CLAUSE_SIZE (c2) = t; | 5120 OMP_CLAUSE_SIZE (c2) = t; |
5061 OMP_CLAUSE_CHAIN (c2) = OMP_CLAUSE_CHAIN (c); | 5121 OMP_CLAUSE_CHAIN (c2) = OMP_CLAUSE_CHAIN (c); |
5062 OMP_CLAUSE_CHAIN (c) = c2; | 5122 OMP_CLAUSE_CHAIN (c) = c2; |
5063 ptr = OMP_CLAUSE_DECL (c2); | 5123 ptr = OMP_CLAUSE_DECL (c2); |
5064 if (OMP_CLAUSE_MAP_KIND (c2) != GOMP_MAP_FIRSTPRIVATE_POINTER | 5124 if (OMP_CLAUSE_MAP_KIND (c2) != GOMP_MAP_FIRSTPRIVATE_POINTER |
5065 && TREE_CODE (TREE_TYPE (ptr)) == REFERENCE_TYPE | 5125 && TYPE_REF_P (TREE_TYPE (ptr)) |
5066 && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (ptr)))) | 5126 && INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (ptr)))) |
5067 { | 5127 { |
5068 tree c3 = build_omp_clause (OMP_CLAUSE_LOCATION (c), | 5128 tree c3 = build_omp_clause (OMP_CLAUSE_LOCATION (c), |
5069 OMP_CLAUSE_MAP); | 5129 OMP_CLAUSE_MAP); |
5070 OMP_CLAUSE_SET_MAP_KIND (c3, OMP_CLAUSE_MAP_KIND (c2)); | 5130 OMP_CLAUSE_SET_MAP_KIND (c3, OMP_CLAUSE_MAP_KIND (c2)); |
5071 OMP_CLAUSE_DECL (c3) = ptr; | 5131 OMP_CLAUSE_DECL (c3) = ptr; |
5097 case BIT_AND_EXPR: | 5157 case BIT_AND_EXPR: |
5098 case BIT_XOR_EXPR: | 5158 case BIT_XOR_EXPR: |
5099 case BIT_IOR_EXPR: | 5159 case BIT_IOR_EXPR: |
5100 case TRUTH_ANDIF_EXPR: | 5160 case TRUTH_ANDIF_EXPR: |
5101 case TRUTH_ORIF_EXPR: | 5161 case TRUTH_ORIF_EXPR: |
5102 reduction_id = cp_operator_id (reduction_code); | 5162 reduction_id = ovl_op_identifier (false, reduction_code); |
5103 break; | 5163 break; |
5104 case MIN_EXPR: | 5164 case MIN_EXPR: |
5105 p = "min"; | 5165 p = "min"; |
5106 break; | 5166 break; |
5107 case MAX_EXPR: | 5167 case MAX_EXPR: |
5327 | 5387 |
5328 void | 5388 void |
5329 cp_check_omp_declare_reduction (tree udr) | 5389 cp_check_omp_declare_reduction (tree udr) |
5330 { | 5390 { |
5331 tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (udr))); | 5391 tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (udr))); |
5332 gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); | 5392 gcc_assert (TYPE_REF_P (type)); |
5333 type = TREE_TYPE (type); | 5393 type = TREE_TYPE (type); |
5334 int i; | 5394 int i; |
5335 location_t loc = DECL_SOURCE_LOCATION (udr); | 5395 location_t loc = DECL_SOURCE_LOCATION (udr); |
5336 | 5396 |
5337 if (type == error_mark_node) | 5397 if (type == error_mark_node) |
5378 { | 5438 { |
5379 error_at (loc, "function or array type %qT in " | 5439 error_at (loc, "function or array type %qT in " |
5380 "%<#pragma omp declare reduction%>", type); | 5440 "%<#pragma omp declare reduction%>", type); |
5381 return; | 5441 return; |
5382 } | 5442 } |
5383 else if (TREE_CODE (type) == REFERENCE_TYPE) | 5443 else if (TYPE_REF_P (type)) |
5384 { | 5444 { |
5385 error_at (loc, "reference type %qT in %<#pragma omp declare reduction%>", | 5445 error_at (loc, "reference type %qT in %<#pragma omp declare reduction%>", |
5386 type); | 5446 type); |
5387 return; | 5447 return; |
5388 } | 5448 } |
5487 return false; | 5547 return false; |
5488 } | 5548 } |
5489 tree type = TREE_TYPE (t); | 5549 tree type = TREE_TYPE (t); |
5490 if (TREE_CODE (t) == MEM_REF) | 5550 if (TREE_CODE (t) == MEM_REF) |
5491 type = TREE_TYPE (type); | 5551 type = TREE_TYPE (type); |
5492 if (TREE_CODE (type) == REFERENCE_TYPE) | 5552 if (TYPE_REF_P (type)) |
5493 type = TREE_TYPE (type); | 5553 type = TREE_TYPE (type); |
5494 if (TREE_CODE (type) == ARRAY_TYPE) | 5554 if (TREE_CODE (type) == ARRAY_TYPE) |
5495 { | 5555 { |
5496 tree oatype = type; | 5556 tree oatype = type; |
5497 gcc_assert (TREE_CODE (t) != MEM_REF); | 5557 gcc_assert (TREE_CODE (t) != MEM_REF); |
5570 { | 5630 { |
5571 OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = NULL_TREE; | 5631 OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = NULL_TREE; |
5572 return false; | 5632 return false; |
5573 } | 5633 } |
5574 else if (processing_template_decl) | 5634 else if (processing_template_decl) |
5575 return false; | 5635 { |
5636 if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == error_mark_node) | |
5637 return true; | |
5638 return false; | |
5639 } | |
5576 | 5640 |
5577 tree id = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c); | 5641 tree id = OMP_CLAUSE_REDUCTION_PLACEHOLDER (c); |
5578 | 5642 |
5579 type = TYPE_MAIN_VARIANT (type); | 5643 type = TYPE_MAIN_VARIANT (type); |
5580 OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = NULL_TREE; | 5644 OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) = NULL_TREE; |
5623 OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) = decl_placeholder; | 5687 OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (c) = decl_placeholder; |
5624 } | 5688 } |
5625 if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[0]))) | 5689 if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[0]))) |
5626 cxx_mark_addressable (placeholder); | 5690 cxx_mark_addressable (placeholder); |
5627 if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[1])) | 5691 if (TREE_ADDRESSABLE (DECL_EXPR_DECL (stmts[1])) |
5628 && TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) | 5692 && !TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c)))) |
5629 != REFERENCE_TYPE) | |
5630 cxx_mark_addressable (decl_placeholder ? decl_placeholder | 5693 cxx_mark_addressable (decl_placeholder ? decl_placeholder |
5631 : OMP_CLAUSE_DECL (c)); | 5694 : OMP_CLAUSE_DECL (c)); |
5632 tree omp_out = placeholder; | 5695 tree omp_out = placeholder; |
5633 tree omp_in = decl_placeholder ? decl_placeholder | 5696 tree omp_in = decl_placeholder ? decl_placeholder |
5634 : convert_from_reference (OMP_CLAUSE_DECL (c)); | 5697 : convert_from_reference (OMP_CLAUSE_DECL (c)); |
5742 continue; | 5805 continue; |
5743 for (tree c = TREE_VALUE (TREE_VALUE (ods)); c; c = OMP_CLAUSE_CHAIN (c)) | 5806 for (tree c = TREE_VALUE (TREE_VALUE (ods)); c; c = OMP_CLAUSE_CHAIN (c)) |
5744 if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR | 5807 if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LINEAR |
5745 && integer_zerop (OMP_CLAUSE_DECL (c)) | 5808 && integer_zerop (OMP_CLAUSE_DECL (c)) |
5746 && OMP_CLAUSE_LINEAR_STEP (c) | 5809 && OMP_CLAUSE_LINEAR_STEP (c) |
5747 && TREE_CODE (TREE_TYPE (OMP_CLAUSE_LINEAR_STEP (c))) | 5810 && TYPE_PTR_P (TREE_TYPE (OMP_CLAUSE_LINEAR_STEP (c)))) |
5748 == POINTER_TYPE) | |
5749 { | 5811 { |
5750 tree s = OMP_CLAUSE_LINEAR_STEP (c); | 5812 tree s = OMP_CLAUSE_LINEAR_STEP (c); |
5751 s = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, s); | 5813 s = fold_convert_loc (OMP_CLAUSE_LOCATION (c), sizetype, s); |
5752 s = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MULT_EXPR, | 5814 s = fold_build2_loc (OMP_CLAUSE_LOCATION (c), MULT_EXPR, |
5753 sizetype, s, TYPE_SIZE_UNIT (t)); | 5815 sizetype, s, TYPE_SIZE_UNIT (t)); |
5772 return false; | 5834 return false; |
5773 | 5835 |
5774 for (; t; t = TREE_CHAIN (t)) | 5836 for (; t; t = TREE_CHAIN (t)) |
5775 { | 5837 { |
5776 tree decl = TREE_VALUE (t); | 5838 tree decl = TREE_VALUE (t); |
5777 if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE) | 5839 if (TYPE_PTR_P (TREE_TYPE (decl))) |
5778 { | 5840 { |
5779 tree offset = TREE_PURPOSE (t); | 5841 tree offset = TREE_PURPOSE (t); |
5780 bool neg = wi::neg_p (wi::to_wide (offset)); | 5842 bool neg = wi::neg_p (wi::to_wide (offset)); |
5781 offset = fold_unary (ABS_EXPR, TREE_TYPE (offset), offset); | 5843 offset = fold_unary (ABS_EXPR, TREE_TYPE (offset), offset); |
5782 decl = mark_rvalue_use (decl); | 5844 decl = mark_rvalue_use (decl); |
5861 gcc_assert (TREE_CODE (t) == MEM_REF); | 5923 gcc_assert (TREE_CODE (t) == MEM_REF); |
5862 t = TREE_OPERAND (t, 0); | 5924 t = TREE_OPERAND (t, 0); |
5863 if (TREE_CODE (t) == POINTER_PLUS_EXPR) | 5925 if (TREE_CODE (t) == POINTER_PLUS_EXPR) |
5864 t = TREE_OPERAND (t, 0); | 5926 t = TREE_OPERAND (t, 0); |
5865 if (TREE_CODE (t) == ADDR_EXPR | 5927 if (TREE_CODE (t) == ADDR_EXPR |
5866 || TREE_CODE (t) == INDIRECT_REF) | 5928 || INDIRECT_REF_P (t)) |
5867 t = TREE_OPERAND (t, 0); | 5929 t = TREE_OPERAND (t, 0); |
5868 } | 5930 } |
5869 tree n = omp_clause_decl_field (t); | 5931 tree n = omp_clause_decl_field (t); |
5870 if (n) | 5932 if (n) |
5871 t = n; | 5933 t = n; |
5895 && !type_dependent_expression_p (t)) | 5957 && !type_dependent_expression_p (t)) |
5896 { | 5958 { |
5897 tree type = TREE_TYPE (t); | 5959 tree type = TREE_TYPE (t); |
5898 if ((OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF | 5960 if ((OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF |
5899 || OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_UVAL) | 5961 || OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_UVAL) |
5900 && TREE_CODE (type) != REFERENCE_TYPE) | 5962 && !TYPE_REF_P (type)) |
5901 { | 5963 { |
5902 error ("linear clause with %qs modifier applied to " | 5964 error ("linear clause with %qs modifier applied to " |
5903 "non-reference variable with %qT type", | 5965 "non-reference variable with %qT type", |
5904 OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF | 5966 OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF |
5905 ? "ref" : "uval", TREE_TYPE (t)); | 5967 ? "ref" : "uval", TREE_TYPE (t)); |
5906 remove = true; | 5968 remove = true; |
5907 break; | 5969 break; |
5908 } | 5970 } |
5909 if (TREE_CODE (type) == REFERENCE_TYPE) | 5971 if (TYPE_REF_P (type)) |
5910 type = TREE_TYPE (type); | 5972 type = TREE_TYPE (type); |
5911 if (ort == C_ORT_CILK) | 5973 if (OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_REF) |
5912 { | 5974 { |
5913 if (!INTEGRAL_TYPE_P (type) | 5975 if (!INTEGRAL_TYPE_P (type) |
5914 && !SCALAR_FLOAT_TYPE_P (type) | 5976 && !TYPE_PTR_P (type)) |
5915 && TREE_CODE (type) != POINTER_TYPE) | |
5916 { | |
5917 error ("linear clause applied to non-integral, " | |
5918 "non-floating, non-pointer variable with %qT type", | |
5919 TREE_TYPE (t)); | |
5920 remove = true; | |
5921 break; | |
5922 } | |
5923 } | |
5924 else if (OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_REF) | |
5925 { | |
5926 if (!INTEGRAL_TYPE_P (type) | |
5927 && TREE_CODE (type) != POINTER_TYPE) | |
5928 { | 5977 { |
5929 error ("linear clause applied to non-integral non-pointer" | 5978 error ("linear clause applied to non-integral non-pointer" |
5930 " variable with %qT type", TREE_TYPE (t)); | 5979 " variable with %qT type", TREE_TYPE (t)); |
5931 remove = true; | 5980 remove = true; |
5932 break; | 5981 break; |
5943 } | 5992 } |
5944 else if (!type_dependent_expression_p (t) | 5993 else if (!type_dependent_expression_p (t) |
5945 && !INTEGRAL_TYPE_P (TREE_TYPE (t)) | 5994 && !INTEGRAL_TYPE_P (TREE_TYPE (t)) |
5946 && (ort != C_ORT_OMP_DECLARE_SIMD | 5995 && (ort != C_ORT_OMP_DECLARE_SIMD |
5947 || TREE_CODE (t) != PARM_DECL | 5996 || TREE_CODE (t) != PARM_DECL |
5948 || TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE | 5997 || !TYPE_REF_P (TREE_TYPE (t)) |
5949 || !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (t))))) | 5998 || !INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (t))))) |
5950 { | 5999 { |
5951 error ("linear step expression must be integral"); | 6000 error ("linear step expression must be integral"); |
5952 remove = true; | 6001 remove = true; |
5953 break; | 6002 break; |
5976 break; | 6025 break; |
5977 } | 6026 } |
5978 } | 6027 } |
5979 t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); | 6028 t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); |
5980 tree type = TREE_TYPE (OMP_CLAUSE_DECL (c)); | 6029 tree type = TREE_TYPE (OMP_CLAUSE_DECL (c)); |
5981 if (TREE_CODE (type) == REFERENCE_TYPE) | 6030 if (TYPE_REF_P (type)) |
5982 type = TREE_TYPE (type); | 6031 type = TREE_TYPE (type); |
5983 if (OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF) | 6032 if (OMP_CLAUSE_LINEAR_KIND (c) == OMP_CLAUSE_LINEAR_REF) |
5984 { | 6033 { |
5985 type = build_pointer_type (type); | 6034 type = build_pointer_type (type); |
5986 tree d = fold_convert (type, OMP_CLAUSE_DECL (c)); | 6035 tree d = fold_convert (type, OMP_CLAUSE_DECL (c)); |
5994 { | 6043 { |
5995 remove = true; | 6044 remove = true; |
5996 break; | 6045 break; |
5997 } | 6046 } |
5998 } | 6047 } |
5999 else if (TREE_CODE (type) == POINTER_TYPE | 6048 else if (TYPE_PTR_P (type) |
6000 /* Can't multiply the step yet if *this | 6049 /* Can't multiply the step yet if *this |
6001 is still incomplete type. */ | 6050 is still incomplete type. */ |
6002 && (ort != C_ORT_OMP_DECLARE_SIMD | 6051 && (ort != C_ORT_OMP_DECLARE_SIMD |
6003 || TREE_CODE (OMP_CLAUSE_DECL (c)) != PARM_DECL | 6052 || TREE_CODE (OMP_CLAUSE_DECL (c)) != PARM_DECL |
6004 || !DECL_ARTIFICIAL (OMP_CLAUSE_DECL (c)) | 6053 || !DECL_ARTIFICIAL (OMP_CLAUSE_DECL (c)) |
6343 if (t == NULL) | 6392 if (t == NULL) |
6344 ; | 6393 ; |
6345 else if (t == error_mark_node) | 6394 else if (t == error_mark_node) |
6346 remove = true; | 6395 remove = true; |
6347 else if (!type_dependent_expression_p (t) | 6396 else if (!type_dependent_expression_p (t) |
6348 && (OMP_CLAUSE_SCHEDULE_KIND (c) | |
6349 != OMP_CLAUSE_SCHEDULE_CILKFOR) | |
6350 && !INTEGRAL_TYPE_P (TREE_TYPE (t))) | 6397 && !INTEGRAL_TYPE_P (TREE_TYPE (t))) |
6351 { | 6398 { |
6352 error ("schedule chunk size expression must be integral"); | 6399 error ("schedule chunk size expression must be integral"); |
6353 remove = true; | 6400 remove = true; |
6354 } | 6401 } |
6355 else | 6402 else |
6356 { | 6403 { |
6357 t = mark_rvalue_use (t); | 6404 t = mark_rvalue_use (t); |
6358 if (!processing_template_decl) | 6405 if (!processing_template_decl) |
6359 { | 6406 { |
6360 if (OMP_CLAUSE_SCHEDULE_KIND (c) | 6407 t = maybe_constant_value (t); |
6361 == OMP_CLAUSE_SCHEDULE_CILKFOR) | 6408 if (TREE_CODE (t) == INTEGER_CST |
6362 { | 6409 && tree_int_cst_sgn (t) != 1) |
6363 t = convert_to_integer (long_integer_type_node, t); | 6410 { |
6364 if (t == error_mark_node) | 6411 warning_at (OMP_CLAUSE_LOCATION (c), 0, |
6365 { | 6412 "chunk size value must be positive"); |
6366 remove = true; | 6413 t = integer_one_node; |
6367 break; | 6414 } |
6368 } | |
6369 } | |
6370 else | |
6371 { | |
6372 t = maybe_constant_value (t); | |
6373 if (TREE_CODE (t) == INTEGER_CST | |
6374 && tree_int_cst_sgn (t) != 1) | |
6375 { | |
6376 warning_at (OMP_CLAUSE_LOCATION (c), 0, | |
6377 "chunk size value must be positive"); | |
6378 t = integer_one_node; | |
6379 } | |
6380 } | |
6381 t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); | 6415 t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); |
6382 } | 6416 } |
6383 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t; | 6417 OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (c) = t; |
6384 } | 6418 } |
6385 break; | 6419 break; |
6533 else | 6567 else |
6534 error ("%qE is not a variable in %<aligned%> clause", t); | 6568 error ("%qE is not a variable in %<aligned%> clause", t); |
6535 remove = true; | 6569 remove = true; |
6536 } | 6570 } |
6537 else if (!type_dependent_expression_p (t) | 6571 else if (!type_dependent_expression_p (t) |
6538 && TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE | 6572 && !TYPE_PTR_P (TREE_TYPE (t)) |
6539 && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE | 6573 && TREE_CODE (TREE_TYPE (t)) != ARRAY_TYPE |
6540 && (TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE | 6574 && (!TYPE_REF_P (TREE_TYPE (t)) |
6541 || (!POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (t))) | 6575 || (!INDIRECT_TYPE_P (TREE_TYPE (TREE_TYPE (t))) |
6542 && (TREE_CODE (TREE_TYPE (TREE_TYPE (t))) | 6576 && (TREE_CODE (TREE_TYPE (TREE_TYPE (t))) |
6543 != ARRAY_TYPE)))) | 6577 != ARRAY_TYPE)))) |
6544 { | 6578 { |
6545 error_at (OMP_CLAUSE_LOCATION (c), | 6579 error_at (OMP_CLAUSE_LOCATION (c), |
6546 "%qE in %<aligned%> clause is neither a pointer nor " | 6580 "%qE in %<aligned%> clause is neither a pointer nor " |
6765 " clauses"); | 6799 " clauses"); |
6766 remove = true; | 6800 remove = true; |
6767 break; | 6801 break; |
6768 } | 6802 } |
6769 else if (!processing_template_decl | 6803 else if (!processing_template_decl |
6770 && TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE | 6804 && !TYPE_REF_P (TREE_TYPE (t)) |
6771 && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP | 6805 && (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP |
6772 || (OMP_CLAUSE_MAP_KIND (c) | 6806 || (OMP_CLAUSE_MAP_KIND (c) |
6773 != GOMP_MAP_FIRSTPRIVATE_POINTER)) | 6807 != GOMP_MAP_FIRSTPRIVATE_POINTER)) |
6774 && !cxx_mark_addressable (t)) | 6808 && !cxx_mark_addressable (t)) |
6775 remove = true; | 6809 remove = true; |
6777 && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER | 6811 && (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_POINTER |
6778 || (OMP_CLAUSE_MAP_KIND (c) | 6812 || (OMP_CLAUSE_MAP_KIND (c) |
6779 == GOMP_MAP_FIRSTPRIVATE_POINTER))) | 6813 == GOMP_MAP_FIRSTPRIVATE_POINTER))) |
6780 && t == OMP_CLAUSE_DECL (c) | 6814 && t == OMP_CLAUSE_DECL (c) |
6781 && !type_dependent_expression_p (t) | 6815 && !type_dependent_expression_p (t) |
6782 && !cp_omp_mappable_type ((TREE_CODE (TREE_TYPE (t)) | 6816 && !cp_omp_mappable_type (TYPE_REF_P (TREE_TYPE (t)) |
6783 == REFERENCE_TYPE) | |
6784 ? TREE_TYPE (TREE_TYPE (t)) | 6817 ? TREE_TYPE (TREE_TYPE (t)) |
6785 : TREE_TYPE (t))) | 6818 : TREE_TYPE (t))) |
6786 { | 6819 { |
6787 error_at (OMP_CLAUSE_LOCATION (c), | 6820 error_at (OMP_CLAUSE_LOCATION (c), |
6788 "%qD does not have a mappable type in %qs clause", t, | 6821 "%qD does not have a mappable type in %qs clause", t, |
6790 remove = true; | 6823 remove = true; |
6791 } | 6824 } |
6792 else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP | 6825 else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP |
6793 && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FORCE_DEVICEPTR | 6826 && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FORCE_DEVICEPTR |
6794 && !type_dependent_expression_p (t) | 6827 && !type_dependent_expression_p (t) |
6795 && !POINTER_TYPE_P (TREE_TYPE (t))) | 6828 && !INDIRECT_TYPE_P (TREE_TYPE (t))) |
6796 { | 6829 { |
6797 error ("%qD is not a pointer variable", t); | 6830 error ("%qD is not a pointer variable", t); |
6798 remove = true; | 6831 remove = true; |
6799 } | 6832 } |
6800 else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP | 6833 else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP |
6844 bitmap_set_bit (&map_field_head, DECL_UID (t)); | 6877 bitmap_set_bit (&map_field_head, DECL_UID (t)); |
6845 } | 6878 } |
6846 handle_map_references: | 6879 handle_map_references: |
6847 if (!remove | 6880 if (!remove |
6848 && !processing_template_decl | 6881 && !processing_template_decl |
6849 && (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP | 6882 && ort != C_ORT_DECLARE_SIMD |
6850 && TREE_CODE (TREE_TYPE (OMP_CLAUSE_DECL (c))) == REFERENCE_TYPE) | 6883 && TYPE_REF_P (TREE_TYPE (OMP_CLAUSE_DECL (c)))) |
6851 { | 6884 { |
6852 t = OMP_CLAUSE_DECL (c); | 6885 t = OMP_CLAUSE_DECL (c); |
6853 if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP) | 6886 if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP) |
6854 { | 6887 { |
6855 OMP_CLAUSE_DECL (c) = build_simple_mem_ref (t); | 6888 OMP_CLAUSE_DECL (c) = build_simple_mem_ref (t); |
7043 field_ok = (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP; | 7076 field_ok = (ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP; |
7044 t = OMP_CLAUSE_DECL (c); | 7077 t = OMP_CLAUSE_DECL (c); |
7045 if (!type_dependent_expression_p (t)) | 7078 if (!type_dependent_expression_p (t)) |
7046 { | 7079 { |
7047 tree type = TREE_TYPE (t); | 7080 tree type = TREE_TYPE (t); |
7048 if (TREE_CODE (type) != POINTER_TYPE | 7081 if (!TYPE_PTR_P (type) |
7049 && TREE_CODE (type) != ARRAY_TYPE | 7082 && TREE_CODE (type) != ARRAY_TYPE |
7050 && (TREE_CODE (type) != REFERENCE_TYPE | 7083 && (!TYPE_REF_P (type) |
7051 || (TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE | 7084 || (!TYPE_PTR_P (TREE_TYPE (type)) |
7052 && TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE))) | 7085 && TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE))) |
7053 { | 7086 { |
7054 error_at (OMP_CLAUSE_LOCATION (c), | 7087 error_at (OMP_CLAUSE_LOCATION (c), |
7055 "%qs variable is neither a pointer, nor an array " | 7088 "%qs variable is neither a pointer, nor an array " |
7056 "nor reference to pointer or array", | 7089 "nor reference to pointer or array", |
7072 case OMP_CLAUSE_PROC_BIND: | 7105 case OMP_CLAUSE_PROC_BIND: |
7073 case OMP_CLAUSE_NOGROUP: | 7106 case OMP_CLAUSE_NOGROUP: |
7074 case OMP_CLAUSE_THREADS: | 7107 case OMP_CLAUSE_THREADS: |
7075 case OMP_CLAUSE_SIMD: | 7108 case OMP_CLAUSE_SIMD: |
7076 case OMP_CLAUSE_DEFAULTMAP: | 7109 case OMP_CLAUSE_DEFAULTMAP: |
7077 case OMP_CLAUSE__CILK_FOR_COUNT_: | |
7078 case OMP_CLAUSE_AUTO: | 7110 case OMP_CLAUSE_AUTO: |
7079 case OMP_CLAUSE_INDEPENDENT: | 7111 case OMP_CLAUSE_INDEPENDENT: |
7080 case OMP_CLAUSE_SEQ: | 7112 case OMP_CLAUSE_SEQ: |
7113 case OMP_CLAUSE_IF_PRESENT: | |
7114 case OMP_CLAUSE_FINALIZE: | |
7081 break; | 7115 break; |
7082 | 7116 |
7083 case OMP_CLAUSE_TILE: | 7117 case OMP_CLAUSE_TILE: |
7084 for (tree list = OMP_CLAUSE_TILE_LIST (c); !remove && list; | 7118 for (tree list = OMP_CLAUSE_TILE_LIST (c); !remove && list; |
7085 list = TREE_CHAIN (list)) | 7119 list = TREE_CHAIN (list)) |
7288 if (need_complete_type || need_copy_assignment) | 7322 if (need_complete_type || need_copy_assignment) |
7289 { | 7323 { |
7290 t = require_complete_type (t); | 7324 t = require_complete_type (t); |
7291 if (t == error_mark_node) | 7325 if (t == error_mark_node) |
7292 remove = true; | 7326 remove = true; |
7293 else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE | 7327 else if (TYPE_REF_P (TREE_TYPE (t)) |
7294 && !complete_type_or_else (TREE_TYPE (TREE_TYPE (t)), t)) | 7328 && !complete_type_or_else (TREE_TYPE (TREE_TYPE (t)), t)) |
7295 remove = true; | 7329 remove = true; |
7296 } | 7330 } |
7297 if (need_implicitly_determined) | 7331 if (need_implicitly_determined) |
7298 { | 7332 { |
7299 const char *share_name = NULL; | 7333 const char *share_name = NULL; |
7300 | 7334 |
7301 if (VAR_P (t) && CP_DECL_THREAD_LOCAL_P (t)) | 7335 if (VAR_P (t) && CP_DECL_THREAD_LOCAL_P (t)) |
7302 share_name = "threadprivate"; | 7336 share_name = "threadprivate"; |
7303 else switch (cxx_omp_predetermined_sharing (t)) | 7337 else switch (cxx_omp_predetermined_sharing_1 (t)) |
7304 { | 7338 { |
7305 case OMP_CLAUSE_DEFAULT_UNSPECIFIED: | 7339 case OMP_CLAUSE_DEFAULT_UNSPECIFIED: |
7306 break; | 7340 break; |
7307 case OMP_CLAUSE_DEFAULT_SHARED: | 7341 case OMP_CLAUSE_DEFAULT_SHARED: |
7308 /* const vars may be specified in firstprivate clause. */ | 7342 /* const vars may be specified in firstprivate clause. */ |
7329 /* We're interested in the base element, not arrays. */ | 7363 /* We're interested in the base element, not arrays. */ |
7330 inner_type = type = TREE_TYPE (t); | 7364 inner_type = type = TREE_TYPE (t); |
7331 if ((need_complete_type | 7365 if ((need_complete_type |
7332 || need_copy_assignment | 7366 || need_copy_assignment |
7333 || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION) | 7367 || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION) |
7334 && TREE_CODE (inner_type) == REFERENCE_TYPE) | 7368 && TYPE_REF_P (inner_type)) |
7335 inner_type = TREE_TYPE (inner_type); | 7369 inner_type = TREE_TYPE (inner_type); |
7336 while (TREE_CODE (inner_type) == ARRAY_TYPE) | 7370 while (TREE_CODE (inner_type) == ARRAY_TYPE) |
7337 inner_type = TREE_TYPE (inner_type); | 7371 inner_type = TREE_TYPE (inner_type); |
7338 | 7372 |
7339 /* Check for special function availability by building a call to one. | 7373 /* Check for special function availability by building a call to one. |
7672 | 7706 |
7673 static bool | 7707 static bool |
7674 handle_omp_for_class_iterator (int i, location_t locus, enum tree_code code, | 7708 handle_omp_for_class_iterator (int i, location_t locus, enum tree_code code, |
7675 tree declv, tree orig_declv, tree initv, | 7709 tree declv, tree orig_declv, tree initv, |
7676 tree condv, tree incrv, tree *body, | 7710 tree condv, tree incrv, tree *body, |
7677 tree *pre_body, tree &clauses, tree *lastp, | 7711 tree *pre_body, tree &clauses, |
7678 int collapse, int ordered) | 7712 int collapse, int ordered) |
7679 { | 7713 { |
7680 tree diff, iter_init, iter_incr = NULL, last; | 7714 tree diff, iter_init, iter_incr = NULL, last; |
7681 tree incr_var = NULL, orig_pre_body, orig_body, c; | 7715 tree incr_var = NULL, orig_pre_body, orig_body, c; |
7682 tree decl = TREE_VEC_ELT (declv, i); | 7716 tree decl = TREE_VEC_ELT (declv, i); |
7976 | 8010 |
7977 TREE_VEC_ELT (declv, i) = decl; | 8011 TREE_VEC_ELT (declv, i) = decl; |
7978 TREE_VEC_ELT (initv, i) = init; | 8012 TREE_VEC_ELT (initv, i) = init; |
7979 TREE_VEC_ELT (condv, i) = cond; | 8013 TREE_VEC_ELT (condv, i) = cond; |
7980 TREE_VEC_ELT (incrv, i) = incr; | 8014 TREE_VEC_ELT (incrv, i) = incr; |
7981 *lastp = last; | 8015 TREE_VEC_ELT (orig_declv, i) |
8016 = tree_cons (TREE_VEC_ELT (orig_declv, i), last, NULL_TREE); | |
7982 | 8017 |
7983 return false; | 8018 return false; |
7984 } | 8019 } |
7985 | 8020 |
7986 /* Build and validate an OMP_FOR statement. CLAUSES, BODY, COND, INCR | 8021 /* Build and validate an OMP_FOR statement. CLAUSES, BODY, COND, INCR |
7994 finish_omp_for (location_t locus, enum tree_code code, tree declv, | 8029 finish_omp_for (location_t locus, enum tree_code code, tree declv, |
7995 tree orig_declv, tree initv, tree condv, tree incrv, | 8030 tree orig_declv, tree initv, tree condv, tree incrv, |
7996 tree body, tree pre_body, vec<tree> *orig_inits, tree clauses) | 8031 tree body, tree pre_body, vec<tree> *orig_inits, tree clauses) |
7997 { | 8032 { |
7998 tree omp_for = NULL, orig_incr = NULL; | 8033 tree omp_for = NULL, orig_incr = NULL; |
7999 tree decl = NULL, init, cond, incr, orig_decl = NULL_TREE, block = NULL_TREE; | 8034 tree decl = NULL, init, cond, incr; |
8000 tree last = NULL_TREE; | |
8001 location_t elocus; | 8035 location_t elocus; |
8002 int i; | 8036 int i; |
8003 int collapse = 1; | 8037 int collapse = 1; |
8004 int ordered = 0; | 8038 int ordered = 0; |
8005 | 8039 |
8160 { | 8194 { |
8161 error_at (elocus, "%<#pragma omp simd%> used with class " | 8195 error_at (elocus, "%<#pragma omp simd%> used with class " |
8162 "iteration variable %qE", decl); | 8196 "iteration variable %qE", decl); |
8163 return NULL; | 8197 return NULL; |
8164 } | 8198 } |
8165 if (code == CILK_FOR && i == 0) | |
8166 orig_decl = decl; | |
8167 if (handle_omp_for_class_iterator (i, locus, code, declv, orig_declv, | 8199 if (handle_omp_for_class_iterator (i, locus, code, declv, orig_declv, |
8168 initv, condv, incrv, &body, | 8200 initv, condv, incrv, &body, |
8169 &pre_body, clauses, &last, | 8201 &pre_body, clauses, |
8170 collapse, ordered)) | 8202 collapse, ordered)) |
8171 return NULL; | 8203 return NULL; |
8172 continue; | 8204 continue; |
8173 } | 8205 } |
8174 | 8206 |
8219 } | 8251 } |
8220 | 8252 |
8221 if (IS_EMPTY_STMT (pre_body)) | 8253 if (IS_EMPTY_STMT (pre_body)) |
8222 pre_body = NULL; | 8254 pre_body = NULL; |
8223 | 8255 |
8224 if (code == CILK_FOR && !processing_template_decl) | |
8225 block = push_stmt_list (); | |
8226 | |
8227 omp_for = c_finish_omp_for (locus, code, declv, orig_declv, initv, condv, | 8256 omp_for = c_finish_omp_for (locus, code, declv, orig_declv, initv, condv, |
8228 incrv, body, pre_body); | 8257 incrv, body, pre_body); |
8229 | 8258 |
8230 /* Check for iterators appearing in lb, b or incr expressions. */ | 8259 /* Check for iterators appearing in lb, b or incr expressions. */ |
8231 if (omp_for && !c_omp_check_loop_iv (omp_for, orig_declv, cp_walk_subtrees)) | 8260 if (omp_for && !c_omp_check_loop_iv (omp_for, orig_declv, cp_walk_subtrees)) |
8232 omp_for = NULL_TREE; | 8261 omp_for = NULL_TREE; |
8233 | 8262 |
8234 if (omp_for == NULL) | 8263 if (omp_for == NULL) |
8235 { | 8264 { |
8236 if (block) | |
8237 pop_stmt_list (block); | |
8238 return NULL; | 8265 return NULL; |
8239 } | 8266 } |
8240 | 8267 |
8241 add_stmt (omp_for); | 8268 add_stmt (omp_for); |
8242 | 8269 |
8291 { | 8318 { |
8292 case PREINCREMENT_EXPR: | 8319 case PREINCREMENT_EXPR: |
8293 case POSTINCREMENT_EXPR: | 8320 case POSTINCREMENT_EXPR: |
8294 /* c_omp_for_incr_canonicalize_ptr() should have been | 8321 /* c_omp_for_incr_canonicalize_ptr() should have been |
8295 called to massage things appropriately. */ | 8322 called to massage things appropriately. */ |
8296 gcc_assert (!POINTER_TYPE_P (TREE_TYPE (decl))); | 8323 gcc_assert (!INDIRECT_TYPE_P (TREE_TYPE (decl))); |
8297 OMP_CLAUSE_LINEAR_STEP (c) = build_int_cst (TREE_TYPE (decl), 1); | 8324 OMP_CLAUSE_LINEAR_STEP (c) = build_int_cst (TREE_TYPE (decl), 1); |
8298 break; | 8325 break; |
8299 case PREDECREMENT_EXPR: | 8326 case PREDECREMENT_EXPR: |
8300 case POSTDECREMENT_EXPR: | 8327 case POSTDECREMENT_EXPR: |
8301 /* c_omp_for_incr_canonicalize_ptr() should have been | 8328 /* c_omp_for_incr_canonicalize_ptr() should have been |
8302 called to massage things appropriately. */ | 8329 called to massage things appropriately. */ |
8303 gcc_assert (!POINTER_TYPE_P (TREE_TYPE (decl))); | 8330 gcc_assert (!INDIRECT_TYPE_P (TREE_TYPE (decl))); |
8304 OMP_CLAUSE_LINEAR_STEP (c) | 8331 OMP_CLAUSE_LINEAR_STEP (c) |
8305 = build_int_cst (TREE_TYPE (decl), -1); | 8332 = build_int_cst (TREE_TYPE (decl), -1); |
8306 break; | 8333 break; |
8307 case MODIFY_EXPR: | 8334 case MODIFY_EXPR: |
8308 gcc_assert (TREE_OPERAND (incr, 0) == decl); | 8335 gcc_assert (TREE_OPERAND (incr, 0) == decl); |
8322 break; | 8349 break; |
8323 default: | 8350 default: |
8324 gcc_unreachable (); | 8351 gcc_unreachable (); |
8325 } | 8352 } |
8326 stept = TREE_TYPE (decl); | 8353 stept = TREE_TYPE (decl); |
8327 if (POINTER_TYPE_P (stept)) | 8354 if (INDIRECT_TYPE_P (stept)) |
8328 stept = sizetype; | 8355 stept = sizetype; |
8329 step = fold_convert (stept, step); | 8356 step = fold_convert (stept, step); |
8330 if (TREE_CODE (incr) == MINUS_EXPR) | 8357 if (TREE_CODE (incr) == MINUS_EXPR) |
8331 step = fold_build1 (NEGATE_EXPR, stept, step); | 8358 step = fold_build1 (NEGATE_EXPR, stept, step); |
8332 OMP_CLAUSE_LINEAR_STEP (c) = step; | 8359 OMP_CLAUSE_LINEAR_STEP (c) = step; |
8334 default: | 8361 default: |
8335 gcc_unreachable (); | 8362 gcc_unreachable (); |
8336 } | 8363 } |
8337 } | 8364 } |
8338 | 8365 |
8339 if (block) | |
8340 { | |
8341 tree omp_par = make_node (OMP_PARALLEL); | |
8342 TREE_TYPE (omp_par) = void_type_node; | |
8343 OMP_PARALLEL_CLAUSES (omp_par) = NULL_TREE; | |
8344 tree bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL); | |
8345 TREE_SIDE_EFFECTS (bind) = 1; | |
8346 BIND_EXPR_BODY (bind) = pop_stmt_list (block); | |
8347 OMP_PARALLEL_BODY (omp_par) = bind; | |
8348 if (OMP_FOR_PRE_BODY (omp_for)) | |
8349 { | |
8350 add_stmt (OMP_FOR_PRE_BODY (omp_for)); | |
8351 OMP_FOR_PRE_BODY (omp_for) = NULL_TREE; | |
8352 } | |
8353 init = TREE_VEC_ELT (OMP_FOR_INIT (omp_for), 0); | |
8354 decl = TREE_OPERAND (init, 0); | |
8355 cond = TREE_VEC_ELT (OMP_FOR_COND (omp_for), 0); | |
8356 incr = TREE_VEC_ELT (OMP_FOR_INCR (omp_for), 0); | |
8357 tree t = TREE_OPERAND (cond, 1), c, clauses, *pc; | |
8358 clauses = OMP_FOR_CLAUSES (omp_for); | |
8359 OMP_FOR_CLAUSES (omp_for) = NULL_TREE; | |
8360 for (pc = &clauses; *pc; ) | |
8361 if (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_SCHEDULE) | |
8362 { | |
8363 gcc_assert (OMP_FOR_CLAUSES (omp_for) == NULL_TREE); | |
8364 OMP_FOR_CLAUSES (omp_for) = *pc; | |
8365 *pc = OMP_CLAUSE_CHAIN (*pc); | |
8366 OMP_CLAUSE_CHAIN (OMP_FOR_CLAUSES (omp_for)) = NULL_TREE; | |
8367 } | |
8368 else | |
8369 { | |
8370 gcc_assert (OMP_CLAUSE_CODE (*pc) == OMP_CLAUSE_FIRSTPRIVATE); | |
8371 pc = &OMP_CLAUSE_CHAIN (*pc); | |
8372 } | |
8373 if (TREE_CODE (t) != INTEGER_CST) | |
8374 { | |
8375 TREE_OPERAND (cond, 1) = get_temp_regvar (TREE_TYPE (t), t); | |
8376 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
8377 OMP_CLAUSE_DECL (c) = TREE_OPERAND (cond, 1); | |
8378 OMP_CLAUSE_CHAIN (c) = clauses; | |
8379 clauses = c; | |
8380 } | |
8381 if (TREE_CODE (incr) == MODIFY_EXPR) | |
8382 { | |
8383 t = TREE_OPERAND (TREE_OPERAND (incr, 1), 1); | |
8384 if (TREE_CODE (t) != INTEGER_CST) | |
8385 { | |
8386 TREE_OPERAND (TREE_OPERAND (incr, 1), 1) | |
8387 = get_temp_regvar (TREE_TYPE (t), t); | |
8388 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
8389 OMP_CLAUSE_DECL (c) = TREE_OPERAND (TREE_OPERAND (incr, 1), 1); | |
8390 OMP_CLAUSE_CHAIN (c) = clauses; | |
8391 clauses = c; | |
8392 } | |
8393 } | |
8394 t = TREE_OPERAND (init, 1); | |
8395 if (TREE_CODE (t) != INTEGER_CST) | |
8396 { | |
8397 TREE_OPERAND (init, 1) = get_temp_regvar (TREE_TYPE (t), t); | |
8398 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
8399 OMP_CLAUSE_DECL (c) = TREE_OPERAND (init, 1); | |
8400 OMP_CLAUSE_CHAIN (c) = clauses; | |
8401 clauses = c; | |
8402 } | |
8403 if (orig_decl && orig_decl != decl) | |
8404 { | |
8405 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
8406 OMP_CLAUSE_DECL (c) = orig_decl; | |
8407 OMP_CLAUSE_CHAIN (c) = clauses; | |
8408 clauses = c; | |
8409 } | |
8410 if (last) | |
8411 { | |
8412 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
8413 OMP_CLAUSE_DECL (c) = last; | |
8414 OMP_CLAUSE_CHAIN (c) = clauses; | |
8415 clauses = c; | |
8416 } | |
8417 c = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); | |
8418 OMP_CLAUSE_DECL (c) = decl; | |
8419 OMP_CLAUSE_CHAIN (c) = clauses; | |
8420 clauses = c; | |
8421 c = build_omp_clause (input_location, OMP_CLAUSE__CILK_FOR_COUNT_); | |
8422 OMP_CLAUSE_OPERAND (c, 0) | |
8423 = cilk_for_number_of_iterations (omp_for); | |
8424 OMP_CLAUSE_CHAIN (c) = clauses; | |
8425 OMP_PARALLEL_CLAUSES (omp_par) = finish_omp_clauses (c, C_ORT_CILK); | |
8426 add_stmt (omp_par); | |
8427 return omp_par; | |
8428 } | |
8429 else if (code == CILK_FOR && processing_template_decl) | |
8430 { | |
8431 tree c, clauses = OMP_FOR_CLAUSES (omp_for); | |
8432 if (orig_decl && orig_decl != decl) | |
8433 { | |
8434 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
8435 OMP_CLAUSE_DECL (c) = orig_decl; | |
8436 OMP_CLAUSE_CHAIN (c) = clauses; | |
8437 clauses = c; | |
8438 } | |
8439 if (last) | |
8440 { | |
8441 c = build_omp_clause (input_location, OMP_CLAUSE_FIRSTPRIVATE); | |
8442 OMP_CLAUSE_DECL (c) = last; | |
8443 OMP_CLAUSE_CHAIN (c) = clauses; | |
8444 clauses = c; | |
8445 } | |
8446 OMP_FOR_CLAUSES (omp_for) = clauses; | |
8447 } | |
8448 return omp_for; | 8366 return omp_for; |
8449 } | 8367 } |
8450 | 8368 |
8451 void | 8369 void |
8452 finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs, | 8370 finish_omp_atomic (enum tree_code code, enum tree_code opcode, tree lhs, |
8750 static assertion is a member of a class. */ | 8668 static assertion is a member of a class. */ |
8751 void | 8669 void |
8752 finish_static_assert (tree condition, tree message, location_t location, | 8670 finish_static_assert (tree condition, tree message, location_t location, |
8753 bool member_p) | 8671 bool member_p) |
8754 { | 8672 { |
8673 tsubst_flags_t complain = tf_warning_or_error; | |
8674 | |
8755 if (message == NULL_TREE | 8675 if (message == NULL_TREE |
8756 || message == error_mark_node | 8676 || message == error_mark_node |
8757 || condition == NULL_TREE | 8677 || condition == NULL_TREE |
8758 || condition == error_mark_node) | 8678 || condition == error_mark_node) |
8759 return; | 8679 return; |
8760 | 8680 |
8761 if (check_for_bare_parameter_packs (condition)) | 8681 if (check_for_bare_parameter_packs (condition)) |
8762 condition = error_mark_node; | 8682 condition = error_mark_node; |
8763 | 8683 |
8764 if (type_dependent_expression_p (condition) | 8684 if (instantiation_dependent_expression_p (condition)) |
8765 || value_dependent_expression_p (condition)) | |
8766 { | 8685 { |
8767 /* We're in a template; build a STATIC_ASSERT and put it in | 8686 /* We're in a template; build a STATIC_ASSERT and put it in |
8768 the right place. */ | 8687 the right place. */ |
8769 tree assertion; | 8688 tree assertion; |
8770 | 8689 |
8782 | 8701 |
8783 return; | 8702 return; |
8784 } | 8703 } |
8785 | 8704 |
8786 /* Fold the expression and convert it to a boolean value. */ | 8705 /* Fold the expression and convert it to a boolean value. */ |
8787 condition = instantiate_non_dependent_expr (condition); | 8706 condition = perform_implicit_conversion_flags (boolean_type_node, condition, |
8788 condition = cp_convert (boolean_type_node, condition, tf_warning_or_error); | 8707 complain, LOOKUP_NORMAL); |
8789 condition = maybe_constant_value (condition); | 8708 condition = fold_non_dependent_expr (condition, complain); |
8790 | 8709 |
8791 if (TREE_CODE (condition) == INTEGER_CST && !integer_zerop (condition)) | 8710 if (TREE_CODE (condition) == INTEGER_CST && !integer_zerop (condition)) |
8792 /* Do nothing; the condition is satisfied. */ | 8711 /* Do nothing; the condition is satisfied. */ |
8793 ; | 8712 ; |
8794 else | 8713 else |
8810 TREE_STRING_POINTER (message)); | 8729 TREE_STRING_POINTER (message)); |
8811 } | 8730 } |
8812 else if (condition && condition != error_mark_node) | 8731 else if (condition && condition != error_mark_node) |
8813 { | 8732 { |
8814 error ("non-constant condition for static assertion"); | 8733 error ("non-constant condition for static assertion"); |
8815 if (require_potential_rvalue_constant_expression (condition)) | 8734 if (require_rvalue_constant_expression (condition)) |
8816 cxx_constant_value (condition); | 8735 cxx_constant_value (condition); |
8817 } | 8736 } |
8818 input_location = saved_loc; | 8737 input_location = saved_loc; |
8819 } | 8738 } |
8820 } | 8739 } |
8994 { | 8913 { |
8995 /* Otherwise, where T is the type of e, if e is an lvalue, | 8914 /* Otherwise, where T is the type of e, if e is an lvalue, |
8996 decltype(e) is defined as T&; if an xvalue, T&&; otherwise, T. */ | 8915 decltype(e) is defined as T&; if an xvalue, T&&; otherwise, T. */ |
8997 cp_lvalue_kind clk = lvalue_kind (expr); | 8916 cp_lvalue_kind clk = lvalue_kind (expr); |
8998 type = unlowered_expr_type (expr); | 8917 type = unlowered_expr_type (expr); |
8999 gcc_assert (TREE_CODE (type) != REFERENCE_TYPE); | 8918 gcc_assert (!TYPE_REF_P (type)); |
9000 | 8919 |
9001 /* For vector types, pick a non-opaque variant. */ | 8920 /* For vector types, pick a non-opaque variant. */ |
9002 if (VECTOR_TYPE_P (type)) | 8921 if (VECTOR_TYPE_P (type)) |
9003 type = strip_typedefs (type); | 8922 type = strip_typedefs (type); |
9004 | 8923 |
9018 classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) | 8937 classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) |
9019 { | 8938 { |
9020 tree fns = NULL_TREE; | 8939 tree fns = NULL_TREE; |
9021 | 8940 |
9022 if (assign_p || TYPE_HAS_COPY_CTOR (type)) | 8941 if (assign_p || TYPE_HAS_COPY_CTOR (type)) |
9023 fns = get_class_binding (type, | 8942 fns = get_class_binding (type, assign_p ? assign_op_identifier |
9024 assign_p ? cp_assignment_operator_id (NOP_EXPR) | |
9025 : ctor_identifier); | 8943 : ctor_identifier); |
9026 | 8944 |
9027 bool saw_copy = false; | 8945 bool saw_copy = false; |
9028 for (ovl_iterator iter (fns); iter; ++iter) | 8946 for (ovl_iterator iter (fns); iter; ++iter) |
9029 { | 8947 { |
9375 error ("%qD is not captured", decl); | 9293 error ("%qD is not captured", decl); |
9376 return error_mark_node; | 9294 return error_mark_node; |
9377 | 9295 |
9378 case CPLD_COPY: | 9296 case CPLD_COPY: |
9379 type = TREE_TYPE (decl); | 9297 type = TREE_TYPE (decl); |
9380 if (TREE_CODE (type) == REFERENCE_TYPE | 9298 if (TYPE_REF_P (type) |
9381 && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE) | 9299 && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE) |
9382 type = TREE_TYPE (type); | 9300 type = TREE_TYPE (type); |
9383 break; | 9301 break; |
9384 | 9302 |
9385 case CPLD_REFERENCE: | 9303 case CPLD_REFERENCE: |
9386 type = TREE_TYPE (decl); | 9304 type = TREE_TYPE (decl); |
9387 if (TREE_CODE (type) != REFERENCE_TYPE) | 9305 if (!TYPE_REF_P (type)) |
9388 type = build_reference_type (TREE_TYPE (decl)); | 9306 type = build_reference_type (TREE_TYPE (decl)); |
9389 break; | 9307 break; |
9390 | 9308 |
9391 default: | 9309 default: |
9392 gcc_unreachable (); | 9310 gcc_unreachable (); |
9393 } | 9311 } |
9394 | 9312 |
9395 if (TREE_CODE (type) != REFERENCE_TYPE) | 9313 if (!TYPE_REF_P (type)) |
9396 { | 9314 { |
9397 if (!LAMBDA_EXPR_MUTABLE_P (lam)) | 9315 if (!LAMBDA_EXPR_MUTABLE_P (lam)) |
9398 type = cp_build_qualified_type (type, (cp_type_quals (type) | 9316 type = cp_build_qualified_type (type, (cp_type_quals (type) |
9399 |TYPE_QUAL_CONST)); | 9317 |TYPE_QUAL_CONST)); |
9400 type = build_reference_type (type); | 9318 type = build_reference_type (type); |
9480 if (!type_dependent_expression_p (arg)) | 9398 if (!type_dependent_expression_p (arg)) |
9481 arg = decay_conversion (arg, complain); | 9399 arg = decay_conversion (arg, complain); |
9482 if (error_operand_p (arg)) | 9400 if (error_operand_p (arg)) |
9483 return error_mark_node; | 9401 return error_mark_node; |
9484 if (!type_dependent_expression_p (arg) | 9402 if (!type_dependent_expression_p (arg) |
9485 && TREE_CODE (TREE_TYPE (arg)) != POINTER_TYPE) | 9403 && !TYPE_PTR_P (TREE_TYPE (arg))) |
9486 { | 9404 { |
9487 error_at (loc, "non-pointer argument to %<__builtin_launder%>"); | 9405 error_at (loc, "non-pointer argument to %<__builtin_launder%>"); |
9488 return error_mark_node; | 9406 return error_mark_node; |
9489 } | 9407 } |
9490 if (processing_template_decl) | 9408 if (processing_template_decl) |