From c7afb7822660a768be77fbeb63f93205e9ca9cd9 Mon Sep 17 00:00:00 2001 From: mpolacek Date: Thu, 1 Sep 2016 14:59:50 +0000 Subject: PR c/7652 gcc/c-family/ * c-common.c (resolve_overloaded_builtin): Fix formatting. Add FALLTHRU comments. gcc/c/ * c-typeck.c (composite_type): Add FALLTHRU comment. gcc/gcc/cp/ * error.c (dump_type): Fix falls through comment. (dump_decl): Likewise. (dump_expr): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239939 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-typeck.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3ac6648b45a..6b00f9a5f1e 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-09-01 Marek Polacek + + PR c/7652 + * c-typeck.c (composite_type): Add FALLTHRU comment. + 2016-08-31 David Malcolm * c-parser.c (c_parser_declaration_or_fndef): Add trailing space diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 51940273d69..fc7a71ef21a 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -605,8 +605,8 @@ composite_type (tree t1, tree t2) t1 = build_function_type (valtype, newargs); t1 = qualify_type (t1, t2); - /* ... falls through ... */ } + /* FALLTHRU */ default: return build_type_attribute_variant (t1, attributes); -- cgit v1.2.1 From 0b80c4b2d7a168c3da186901ff8f4b9b53eaab4a Mon Sep 17 00:00:00 2001 From: jakub Date: Fri, 2 Sep 2016 18:38:07 +0000 Subject: PR c/65467 * gimplify.c (gimplify_adjust_omp_clauses_1): Diagnose implicit map and firstprivate clauses on target construct for _Atomic qualified decls. (gimplify_adjust_omp_clauses): Diagnose explicit firstprivate clauses on target construct for _Atomic qualified decls. * omp-low.c (use_pointer_for_field): Return true for _Atomic qualified decls. * omp-simd-clone.c (simd_clone_clauses_extract): Warn and give up for _Atomic qualified arguments not mentioned in uniform clause. c/ * c-parser.c (c_parser_declspecs): Don't sorry about _Atomic if flag_openmp. (c_parser_omp_variable_list): Use convert_lvalue_to_rvalue instead of mark_exp_read on low_bound/length expression. (c_parser_omp_clause_num_gangs, c_parser_omp_clause_num_threads, c_parser_omp_clause_num_tasks, c_parser_omp_clause_grainsize, c_parser_omp_clause_priority, c_parser_omp_clause_hint, c_parser_omp_clause_num_workers, c_parser_oacc_shape_clause, c_parser_oacc_clause_tile, c_parser_omp_clause_schedule, c_parser_omp_clause_vector_length, c_parser_omp_clause_num_teams, c_parser_omp_clause_thread_limit, c_parser_omp_clause_aligned, c_parser_omp_clause_linear, c_parser_omp_clause_safelen, c_parser_omp_clause_simdlen, c_parser_omp_clause_device, c_parser_omp_clause_dist_schedule): Use convert_lvalue_to_rvalue instead of mark_expr_read. (c_parser_omp_declare_reduction): Reject _Atomic qualified types. * c-objc-common.h (LANG_HOOKS_OMP_CLAUSE_COPY_CTOR, LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP): Redefine. * c-tree.h (c_omp_clause_copy_ctor): New prototype. * c-typeck.c (handle_omp_array_sections_1): Diagnose _Atomic qualified array section bases outside of depend clause, for depend clause use convert_lvalue_to_rvalue on the base. (c_finish_omp_clauses): Reject _Atomic qualified vars in reduction, linear, aligned, map, to and from clauses. (c_omp_clause_copy_ctor): New function. c-family/ * c-omp.c (c_finish_omp_atomic): Reject _Atomic qualified expressions. (c_finish_omp_for): Reject _Atomic qualified iterators. testsuite/ * gcc.dg/gomp/_Atomic-1.c: New test. * gcc.dg/gomp/_Atomic-2.c: New test. * gcc.dg/gomp/_Atomic-3.c: New test. * gcc.dg/gomp/_Atomic-4.c: New test. * gcc.dg/gomp/_Atomic-5.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239964 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 29 ++++++++++++ gcc/c/c-objc-common.h | 6 +++ gcc/c/c-parser.c | 125 +++++++++++++++++++++++++++++++------------------- gcc/c/c-tree.h | 1 + gcc/c/c-typeck.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 234 insertions(+), 48 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 6b00f9a5f1e..d10dd6d0689 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,32 @@ +2016-09-02 Jakub Jelinek + + PR c/65467 + * c-parser.c (c_parser_declspecs): Don't sorry about _Atomic if + flag_openmp. + (c_parser_omp_variable_list): Use convert_lvalue_to_rvalue + instead of mark_exp_read on low_bound/length expression. + (c_parser_omp_clause_num_gangs, c_parser_omp_clause_num_threads, + c_parser_omp_clause_num_tasks, c_parser_omp_clause_grainsize, + c_parser_omp_clause_priority, c_parser_omp_clause_hint, + c_parser_omp_clause_num_workers, c_parser_oacc_shape_clause, + c_parser_oacc_clause_tile, c_parser_omp_clause_schedule, + c_parser_omp_clause_vector_length, c_parser_omp_clause_num_teams, + c_parser_omp_clause_thread_limit, c_parser_omp_clause_aligned, + c_parser_omp_clause_linear, c_parser_omp_clause_safelen, + c_parser_omp_clause_simdlen, c_parser_omp_clause_device, + c_parser_omp_clause_dist_schedule): Use convert_lvalue_to_rvalue + instead of mark_expr_read. + (c_parser_omp_declare_reduction): Reject _Atomic qualified types. + * c-objc-common.h (LANG_HOOKS_OMP_CLAUSE_COPY_CTOR, + LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP): Redefine. + * c-tree.h (c_omp_clause_copy_ctor): New prototype. + * c-typeck.c (handle_omp_array_sections_1): Diagnose _Atomic qualified + array section bases outside of depend clause, for depend clause + use convert_lvalue_to_rvalue on the base. + (c_finish_omp_clauses): Reject _Atomic qualified vars in reduction, + linear, aligned, map, to and from clauses. + (c_omp_clause_copy_ctor): New function. + 2016-09-01 Marek Polacek PR c/7652 diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h index ccb4903ee42..14554ace114 100644 --- a/gcc/c/c-objc-common.h +++ b/gcc/c/c-objc-common.h @@ -100,6 +100,12 @@ along with GCC; see the file COPYING3. If not see #undef LANG_HOOKS_OMP_PREDETERMINED_SHARING #define LANG_HOOKS_OMP_PREDETERMINED_SHARING c_omp_predetermined_sharing +#undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR +#define LANG_HOOKS_OMP_CLAUSE_COPY_CTOR c_omp_clause_copy_ctor + +#undef LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP +#define LANG_HOOKS_OMP_CLAUSE_ASSIGN_OP c_omp_clause_copy_ctor + #undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P #define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P c_vla_unspec_p #endif /* GCC_C_OBJC_COMMON */ diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 0581899e307..0aba51c9cde 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -2600,10 +2600,6 @@ c_parser_declspecs (c_parser *parser, struct c_declspecs *specs, and objc_types_are_equivalent may also need updates. */ if (c_dialect_objc ()) sorry ("%<_Atomic%> in Objective-C"); - /* C parser handling of OpenMP constructs needs checking for - correct lvalue-to-rvalue conversions. */ - if (flag_openmp) - sorry ("%<_Atomic%> with OpenMP"); if (flag_isoc99) pedwarn_c99 (loc, OPT_Wpedantic, "ISO C99 does not support the %<_Atomic%> qualifier"); @@ -10718,8 +10714,12 @@ c_parser_omp_variable_list (c_parser *parser, c_parser_consume_token (parser); if (!c_parser_next_token_is (parser, CPP_COLON)) { - low_bound = c_parser_expression (parser).value; - mark_exp_read (low_bound); + location_t expr_loc + = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, + false, true); + low_bound = expr.value; } if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) length = integer_one_node; @@ -10734,8 +10734,12 @@ c_parser_omp_variable_list (c_parser *parser, } if (!c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) { - length = c_parser_expression (parser).value; - mark_exp_read (length); + location_t expr_loc + = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, + false, true); + length = expr.value; } } /* Look for the closing `]'. */ @@ -11257,8 +11261,9 @@ c_parser_omp_clause_num_gangs (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11301,8 +11306,9 @@ c_parser_omp_clause_num_threads (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11345,8 +11351,9 @@ c_parser_omp_clause_num_tasks (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11389,8 +11396,9 @@ c_parser_omp_clause_grainsize (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11433,8 +11441,9 @@ c_parser_omp_clause_priority (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11477,8 +11486,10 @@ c_parser_omp_clause_hint (c_parser *parser, tree list) location_t hint_loc = c_parser_peek_token (parser)->location; if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11581,8 +11592,9 @@ c_parser_omp_clause_num_workers (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -11703,11 +11715,12 @@ c_parser_oacc_shape_clause (c_parser *parser, omp_clause_code kind, } location_t expr_loc = c_parser_peek_token (parser)->location; - tree expr = c_parser_expr_no_commas (parser, NULL).value; + c_expr cexpr = c_parser_expr_no_commas (parser, NULL); + cexpr = convert_lvalue_to_rvalue (expr_loc, cexpr, false, true); + tree expr = cexpr.value; if (expr == error_mark_node) goto cleanup_error; - mark_exp_read (expr); expr = c_fully_fold (expr, false, NULL); /* Attempt to statically determine when the number isn't a @@ -11842,7 +11855,9 @@ c_parser_oacc_clause_tile (c_parser *parser, tree list) else { expr_loc = c_parser_peek_token (parser)->location; - expr = c_parser_expr_no_commas (parser, NULL).value; + c_expr cexpr = c_parser_expr_no_commas (parser, NULL); + cexpr = convert_lvalue_to_rvalue (expr_loc, cexpr, false, true); + expr = cexpr.value; if (expr == error_mark_node) { @@ -11857,7 +11872,6 @@ c_parser_oacc_clause_tile (c_parser *parser, tree list) return list; } - mark_exp_read (expr); expr = c_fully_fold (expr, false, NULL); /* Attempt to statically determine when expr isn't positive. */ @@ -12180,8 +12194,9 @@ c_parser_omp_clause_schedule (c_parser *parser, tree list) c_parser_consume_token (parser); here = c_parser_peek_token (parser)->location; - t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (here, expr, false, true); + t = expr.value; t = c_fully_fold (t, false, NULL); if (OMP_CLAUSE_SCHEDULE_KIND (c) == OMP_CLAUSE_SCHEDULE_RUNTIME) @@ -12266,8 +12281,9 @@ c_parser_omp_clause_vector_length (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -12369,8 +12385,9 @@ c_parser_omp_clause_num_teams (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -12412,8 +12429,9 @@ c_parser_omp_clause_thread_limit (c_parser *parser, tree list) if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { location_t expr_loc = c_parser_peek_token (parser)->location; - tree c, t = c_parser_expression (parser).value; - mark_exp_read (t); + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -12465,8 +12483,10 @@ c_parser_omp_clause_aligned (c_parser *parser, tree list) if (c_parser_next_token_is (parser, CPP_COLON)) { c_parser_consume_token (parser); - tree alignment = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (alignment); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree alignment = expr.value; alignment = c_fully_fold (alignment, false, NULL); if (TREE_CODE (alignment) != INTEGER_CST || !INTEGRAL_TYPE_P (TREE_TYPE (alignment)) @@ -12528,8 +12548,10 @@ c_parser_omp_clause_linear (c_parser *parser, tree list, bool is_cilk_simd_fn) if (c_parser_next_token_is (parser, CPP_COLON)) { c_parser_consume_token (parser); - step = c_parser_expression (parser).value; - mark_exp_read (step); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expression (parser); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + step = expr.value; step = c_fully_fold (step, false, NULL); if (is_cilk_simd_fn && TREE_CODE (step) == PARM_DECL) { @@ -12569,8 +12591,10 @@ c_parser_omp_clause_safelen (c_parser *parser, tree list) if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) return list; - t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + t = expr.value; t = c_fully_fold (t, false, NULL); if (TREE_CODE (t) != INTEGER_CST || !INTEGRAL_TYPE_P (TREE_TYPE (t)) @@ -12605,8 +12629,10 @@ c_parser_omp_clause_simdlen (c_parser *parser, tree list) if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) return list; - t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + t = expr.value; t = c_fully_fold (t, false, NULL); if (TREE_CODE (t) != INTEGER_CST || !INTEGRAL_TYPE_P (TREE_TYPE (t)) @@ -12921,8 +12947,10 @@ c_parser_omp_clause_device (c_parser *parser, tree list) location_t clause_loc = c_parser_peek_token (parser)->location; if (c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>")) { - tree c, t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + tree c, t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); @@ -12970,8 +12998,10 @@ c_parser_omp_clause_dist_schedule (c_parser *parser, tree list) { c_parser_consume_token (parser); - t = c_parser_expr_no_commas (parser, NULL).value; - mark_exp_read (t); + location_t expr_loc = c_parser_peek_token (parser)->location; + c_expr expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); + t = expr.value; t = c_fully_fold (t, false, NULL); c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>"); } @@ -16876,6 +16906,9 @@ c_parser_omp_declare_reduction (c_parser *parser, enum pragma_context context) || TREE_CODE (type) == ARRAY_TYPE) error_at (loc, "function or array type in " "%<#pragma omp declare reduction%>"); + else if (TYPE_ATOMIC (type)) + error_at (loc, "%<_Atomic%> qualified type in " + "%<#pragma omp declare reduction%>"); else if (TYPE_QUALS_NO_ADDR_SPACE (type)) error_at (loc, "const, volatile or restrict qualified type in " "%<#pragma omp declare reduction%>"); diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 5a8ab6df483..e8060f8b197 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -682,6 +682,7 @@ extern tree c_finish_transaction (location_t, tree, int); extern bool c_tree_equal (tree, tree); extern tree c_build_function_call_vec (location_t, vec, tree, vec *, vec *); +extern tree c_omp_clause_copy_ctor (tree, tree, tree); /* Set to 0 at beginning of a function definition, set to 1 if a return statement that specifies a return value is seen. */ diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index fc7a71ef21a..d56c3d6b264 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -12072,6 +12072,13 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, if (error_operand_p (t)) return error_mark_node; ret = t; + if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND + && TYPE_ATOMIC (strip_array_types (TREE_TYPE (t)))) + { + error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qE in %qs clause", + t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + return error_mark_node; + } if (TREE_CODE (t) == COMPONENT_REF && ort == C_ORT_OMP && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP @@ -12109,13 +12116,35 @@ handle_omp_array_sections_1 (tree c, tree t, vec &types, return error_mark_node; } else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND - && VAR_P (t) && DECL_THREAD_LOCAL_P (t)) + && TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), "%<_Atomic%> %qD in %qs clause", + t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + return error_mark_node; + } + else if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND + && VAR_P (t) + && DECL_THREAD_LOCAL_P (t)) { error_at (OMP_CLAUSE_LOCATION (c), "%qD is threadprivate variable in %qs clause", t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_DEPEND + && TYPE_ATOMIC (TREE_TYPE (t)) + && POINTER_TYPE_P (TREE_TYPE (t))) + { + /* If the array section is pointer based and the pointer + itself is _Atomic qualified, we need to atomically load + the pointer. */ + c_expr expr; + memset (&expr, 0, sizeof (expr)); + expr.value = ret; + expr = convert_lvalue_to_rvalue (OMP_CLAUSE_LOCATION (c), + expr, false, false); + ret = expr.value; + } return ret; } @@ -12675,7 +12704,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) oacc_async = true; break; } - + for (pc = &clauses, c = clauses; c ; c = *pc) { bool remove = false; @@ -12750,6 +12779,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t = build2 (MEM_REF, atype, t, build_int_cst (ptype, 0)); OMP_CLAUSE_DECL (c) = t; } + if (TYPE_ATOMIC (type)) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qE in % clause", t); + remove = true; + break; + } if (OMP_CLAUSE_REDUCTION_PLACEHOLDER (c) == NULL_TREE && (FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE)) @@ -12964,6 +13000,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) remove = true; break; } + if (TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qD in % clause", t); + remove = true; + break; + } } if (ort == C_ORT_OMP_DECLARE_SIMD) { @@ -13112,6 +13155,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "an array", t); remove = true; } + else if (TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qD in % clause", t); + remove = true; + break; + } else if (bitmap_bit_p (&aligned_head, DECL_UID (t))) { error_at (OMP_CLAUSE_LOCATION (c), @@ -13197,6 +13247,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } + else if (TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qE in %qs clause", t, + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + remove = true; + } while (TREE_CODE (t) == ARRAY_REF) t = TREE_OPERAND (t, 0); if (TREE_CODE (t) == COMPONENT_REF @@ -13251,6 +13308,13 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } + else if (TYPE_ATOMIC (TREE_TYPE (t))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qE in %qs clause", t, + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + remove = true; + } while (TREE_CODE (t) == COMPONENT_REF) { if (TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) @@ -13304,6 +13368,15 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) omp_clause_code_name[OMP_CLAUSE_CODE (c)]); remove = true; } + else if (TREE_TYPE (t) == error_mark_node) + remove = true; + else if (TYPE_ATOMIC (strip_array_types (TREE_TYPE (t)))) + { + error_at (OMP_CLAUSE_LOCATION (c), + "%<_Atomic%> %qE in %qs clause", t, + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + remove = true; + } else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP && OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_FIRSTPRIVATE_POINTER) { @@ -13644,6 +13717,50 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) return clauses; } +/* Return code to initialize DST with a copy constructor from SRC. + C doesn't have copy constructors nor assignment operators, only for + _Atomic vars we need to perform __atomic_load from src into a temporary + followed by __atomic_store of the temporary to dst. */ + +tree +c_omp_clause_copy_ctor (tree clause, tree dst, tree src) +{ + if (!really_atomic_lvalue (dst) && !really_atomic_lvalue (src)) + return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src); + + location_t loc = OMP_CLAUSE_LOCATION (clause); + tree type = TREE_TYPE (dst); + tree nonatomic_type = build_qualified_type (type, TYPE_UNQUALIFIED); + tree tmp = create_tmp_var (nonatomic_type); + tree tmp_addr = build_fold_addr_expr (tmp); + TREE_ADDRESSABLE (tmp) = 1; + TREE_NO_WARNING (tmp) = 1; + tree src_addr = build_fold_addr_expr (src); + tree dst_addr = build_fold_addr_expr (dst); + tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST); + vec *params; + /* Expansion of a generic atomic load may require an addition + element, so allocate enough to prevent a resize. */ + vec_alloc (params, 4); + + /* Build __atomic_load (&src, &tmp, SEQ_CST); */ + tree fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD); + params->quick_push (src_addr); + params->quick_push (tmp_addr); + params->quick_push (seq_cst); + tree load = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL); + + vec_alloc (params, 4); + + /* Build __atomic_store (&dst, &tmp, SEQ_CST); */ + fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE); + params->quick_push (dst_addr); + params->quick_push (tmp_addr); + params->quick_push (seq_cst); + tree store = c_build_function_call_vec (loc, vNULL, fndecl, params, NULL); + return build2 (COMPOUND_EXPR, void_type_node, load, store); +} + /* Create a transaction node. */ tree -- cgit v1.2.1 From 92a44a68071e46ac8bc265615f441997feeb731e Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 5 Sep 2016 19:42:42 +0000 Subject: ChangeLog formatting fixes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239997 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index d10dd6d0689..7fee5b8556a 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -278,7 +278,7 @@ * c-typeck.c (build_conditional_expr): Return error_mark_node if c_common_type returns error_mark_node. -2016-06-19 Martin Sebor +2016-06-19 Martin Sebor PR c/69507 * c-parser.c (c_parser_alignof_expression): Avoid diagnosing @@ -2027,7 +2027,7 @@ * c-typeck.c (build_array_ref): Pass loc down to warn_array_subscript_with_type_char. -2014-12-20 Martin Uecker +2014-12-20 Martin Uecker * c-typeck.c: New behavious for pointers to arrays with qualifiers (common-pointer-type): For pointers to arrays take qualifiers from @@ -2349,7 +2349,7 @@ Likewise. (c_parser_postfix_expression) : Likewise. -2014-08-10 Marek Polacek +2014-08-10 Marek Polacek PR c/51849 * c-decl.c (build_array_declarator): Remove check for !flag_isoc99. @@ -2436,7 +2436,7 @@ function parameter. 2014-07-02 Jan Hubicka - Chen Gang + Chen Gang * c-decl.c (duplicate_decls): CLear DECL_STRUCT_FUNCTION before releasing symbol. -- cgit v1.2.1 From 3da97ff7272bb77bacf5293f67e597aa040fc4f1 Mon Sep 17 00:00:00 2001 From: dmalcolm Date: Wed, 7 Sep 2016 16:56:23 +0000 Subject: Move class substring_loc from c-family into gcc gcc/ChangeLog: * Makefile.in (OBJS): Add substring-locations.o. * langhooks-def.h (class substring_loc): New forward decl. (lhd_get_substring_location): New decl. (LANG_HOOKS_GET_SUBSTRING_LOCATION): New macro. (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_GET_SUBSTRING_LOCATION. * langhooks.c (lhd_get_substring_location): New function. * langhooks.h (class substring_loc): New forward decl. (struct lang_hooks): Add field get_substring_location. * substring-locations.c: New file, taking definition of format_warning_va and format_warning_at_substring from c-family/c-format.c, making them non-static. * substring-locations.h (class substring_loc): Move class here from c-family/c-common.h. Add and rewrite comments. (format_warning_va): New decl. (format_warning_at_substring): New decl. (get_source_location_for_substring): Add comment. gcc/c-family/ChangeLog: * c-common.c (get_cpp_ttype_from_string_type): Handle being passed a POINTER_TYPE. (substring_loc::get_location): Move to substring-locations.c, keeping implementation as... (c_get_substring_location): New function, from the above, reworked to use accessors rather than member lookup. * c-common.h (class substring_loc): Move to substring-locations.h, replacing with a forward decl. (c_get_substring_location): New decl. * c-format.c: Include "substring-locations.h". (format_warning_va): Move to substring-locations.c. (format_warning_at_substring): Likewise. gcc/c/ChangeLog: * c-lang.c (LANG_HOOKS_GET_SUBSTRING_LOCATION): Use c_get_substring_location for this new langhook. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_string_literals.c: Include "substring-locations.h". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240028 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-lang.c | 3 +++ 2 files changed, 8 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 7fee5b8556a..a6472638411 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-09-07 David Malcolm + + * c-lang.c (LANG_HOOKS_GET_SUBSTRING_LOCATION): Use + c_get_substring_location for this new langhook. + 2016-09-02 Jakub Jelinek PR c/65467 diff --git a/gcc/c/c-lang.c b/gcc/c/c-lang.c index b26be6ad92c..b4096d064ee 100644 --- a/gcc/c/c-lang.c +++ b/gcc/c/c-lang.c @@ -43,6 +43,9 @@ enum c_language_kind c_language = clk_c; #define LANG_HOOKS_RUN_LANG_SELFTESTS selftest::run_c_tests #endif /* #if CHECKING_P */ +#undef LANG_HOOKS_GET_SUBSTRING_LOCATION +#define LANG_HOOKS_GET_SUBSTRING_LOCATION c_get_substring_location + /* Each front end provides its own lang hook initializer. */ struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; -- cgit v1.2.1 From 7a21b590fb5d96a2a925f2a26ea1f20c89ae070f Mon Sep 17 00:00:00 2001 From: edlinger Date: Mon, 12 Sep 2016 20:18:16 +0000 Subject: gcc/c-family: 2016-09-12 Bernd Edlinger PR c++/77496 * c-common.c (warn_for_omitted_condop): Also warn for boolean data. gcc/c: 2016-09-12 Bernd Edlinger PR c++/77496 * c-parser.c (c_parser_conditional_expression): Pass the rightmost COMPOUND_EXPR to warn_for_omitted_condop. gcc/cp: 2016-09-12 Bernd Edlinger PR c++/77496 * call.c (build_conditional_expr_1): Call warn_for_omitted_condop. * class.c (instantiate_type): Look through the SAVE_EXPR. gcc/testsuite: 2016-09-12 Bernd Edlinger PR c++/77496 * c-c++-common/warn-ommitted-condop.c: Add more test cases. * g++.dg/ext/pr77496.C: New test. * g++.dg/warn/pr77496.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240098 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-parser.c | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index a6472638411..b474de193a5 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2016-09-12 Bernd Edlinger + + PR c++/77496 + * c-parser.c (c_parser_conditional_expression): Pass the rightmost + COMPOUND_EXPR to warn_for_omitted_condop. + 2016-09-07 David Malcolm * c-lang.c (LANG_HOOKS_GET_SUBSTRING_LOCATION): Use diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 0aba51c9cde..a3044244f6c 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -6425,14 +6425,17 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after, tree eptype = NULL_TREE; middle_loc = c_parser_peek_token (parser)->location; - pedwarn (middle_loc, OPT_Wpedantic, + pedwarn (middle_loc, OPT_Wpedantic, "ISO C forbids omitting the middle term of a ?: expression"); - warn_for_omitted_condop (middle_loc, cond.value); if (TREE_CODE (cond.value) == EXCESS_PRECISION_EXPR) { eptype = TREE_TYPE (cond.value); cond.value = TREE_OPERAND (cond.value, 0); } + tree e = cond.value; + while (TREE_CODE (e) == COMPOUND_EXPR) + e = TREE_OPERAND (e, 1); + warn_for_omitted_condop (middle_loc, e); /* Make sure first operand is calculated only once. */ exp1.value = c_save_expr (default_conversion (cond.value)); if (eptype) -- cgit v1.2.1 From 89bcb5a31a98ad7a315c8fd5cc4dcf87003f4cd6 Mon Sep 17 00:00:00 2001 From: mpolacek Date: Tue, 13 Sep 2016 10:42:39 +0000 Subject: * c-typeck.c (build_unary_op): Rename FLAG parameter to NOCONVERT. Use it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240109 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-typeck.c | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index b474de193a5..c8563749939 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-09-13 Marek Polacek + + * c-typeck.c (build_unary_op): Rename FLAG parameter to NOCONVERT. Use + it. + 2016-09-12 Bernd Edlinger PR c++/77496 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index d56c3d6b264..8c7f89542b7 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -4112,17 +4112,17 @@ cas_loop: /* Construct and perhaps optimize a tree representation for a unary operation. CODE, a tree_code, specifies the operation and XARG is the operand. - For any CODE other than ADDR_EXPR, FLAG nonzero suppresses + For any CODE other than ADDR_EXPR, NOCONVERT nonzero suppresses the default promotions (such as from short to int). - For ADDR_EXPR, the default promotions are not applied; FLAG nonzero + For ADDR_EXPR, the default promotions are not applied; NOCONVERT nonzero allows non-lvalues; this is only used to handle conversion of non-lvalue arrays to pointers in C99. LOCATION is the location of the operator. */ tree -build_unary_op (location_t location, - enum tree_code code, tree xarg, int flag) +build_unary_op (location_t location, enum tree_code code, tree xarg, + int noconvert) { /* No default_conversion here. It causes trouble for ADDR_EXPR. */ tree arg = xarg; @@ -4131,7 +4131,6 @@ build_unary_op (location_t location, tree val; tree ret = error_mark_node; tree eptype = NULL_TREE; - int noconvert = flag; const char *invalid_op_diag; bool int_operands; @@ -4276,7 +4275,8 @@ build_unary_op (location_t location, if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR) { tree inner = build_unary_op (location, code, - C_MAYBE_CONST_EXPR_EXPR (arg), flag); + C_MAYBE_CONST_EXPR_EXPR (arg), + noconvert); if (inner == error_mark_node) return error_mark_node; ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner), @@ -4486,7 +4486,7 @@ build_unary_op (location_t location, /* Anything not already handled and not a true memory reference or a non-lvalue array is an error. */ - if (typecode != FUNCTION_TYPE && !flag + if (typecode != FUNCTION_TYPE && !noconvert && !lvalue_or_else (location, arg, lv_addressof)) return error_mark_node; @@ -4495,7 +4495,8 @@ build_unary_op (location_t location, if (TREE_CODE (arg) == C_MAYBE_CONST_EXPR) { tree inner = build_unary_op (location, code, - C_MAYBE_CONST_EXPR_EXPR (arg), flag); + C_MAYBE_CONST_EXPR_EXPR (arg), + noconvert); ret = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (inner), C_MAYBE_CONST_EXPR_PRE (arg), inner); gcc_assert (!C_MAYBE_CONST_EXPR_INT_OPERANDS (arg)); -- cgit v1.2.1 From 68ef907cd5704cca533b3cdf6db112b973e52b74 Mon Sep 17 00:00:00 2001 From: dmalcolm Date: Tue, 13 Sep 2016 16:08:59 +0000 Subject: fix-it hints: insert_before vs insert_after The API for adding "insert text" fix-it hints was unclear about exactly where the text should be inserted relative to the given insertion point. This patch clarifies things by renaming the pertinent methods from richloc.add_fixit_insert to richloc.add_fixit_insert_before and adding: richloc.add_fixit_insert_after The latter allows us to consolidate some failure-handling into class rich_location, rather than having to have every such diagnostic check for it. The patch also adds a description of how fix-it hints work to the comment for class rich_location within libcpp/include/line-map.h. gcc/c-family/ChangeLog: * c-common.c (warn_logical_not_parentheses): Replace rich_location::add_fixit_insert calls with add_fixit_insert_before and add_fixit_insert_after, eliminating the "next_loc" calculation. gcc/c/ChangeLog: * c-parser.c (c_parser_declaration_or_fndef): Update for renaming of add_fixit_insert to add_fixit_insert_before. gcc/cp/ChangeLog: * parser.c (cp_parser_class_specifier_1): Update for renaming of add_fixit_insert to add_fixit_insert_before. (cp_parser_class_head): Likewise. gcc/ChangeLog: * diagnostic-show-locus.c (selftest::test_one_liner_fixit_insert): Rename to... (selftest::test_one_liner_fixit_insert_before): ...this, and update for renaming of add_fixit_insert to add_fixit_insert_before. (selftest::test_one_liner_fixit_insert_after): New function. (selftest::test_one_liner_fixit_validation_adhoc_locations): Update for renaming of add_fixit_insert to add_fixit_insert_before. (selftest::test_one_liner_many_fixits): Likewise. (selftest::test_diagnostic_show_locus_one_liner): Update for renaming, call new test function. (selftest::test_diagnostic_show_locus_fixit_lines): Update for renaming of add_fixit_insert to add_fixit_insert_before. (selftest::test_fixit_consolidation): Likewise. * diagnostic.c (selftest::test_print_parseable_fixits_insert): Likewise. * edit-context.c (selftest::test_applying_fixits_insert): Rename to... (selftest::test_applying_fixits_insert_before): ...this. (selftest::test_applying_fixits_insert): Update for renaming of add_fixit_insert to add_fixit_insert_before. (selftest::test_applying_fixits_insert_after): New function. (selftest::test_applying_fixits_insert_after_at_line_end): New function. (selftest::test_applying_fixits_insert_after_failure): New function. (selftest::test_applying_fixits_multiple): Update for renaming of add_fixit_insert to add_fixit_insert_before. (selftest::change_line): Likewise. (selftest::test_applying_fixits_unreadable_file): Likewise. (selftest::test_applying_fixits_line_out_of_range): Likewise. (selftest::test_applying_fixits_column_validation): Likewise. (selftest::test_applying_fixits_column_validation): Likewise. (selftest::edit_context_c_tests): Update for renamed test function; call new test functions. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (test_show_locus): Replace rich_location::add_fixit_insert calls with add_fixit_insert_before and add_fixit_insert_after. libcpp/ChangeLog: * include/line-map.h (class rich_location): Add description of fix-it hints to leading comment. (rich_location::add_fixit_insert): Rename both overloaded methods to.. (rich_location::add_fixit_insert_before): ...this, updating their comments. (rich_location::add_fixit_insert_after): Two new overloaded methods. (rich_location::stop_supporting_fixits): New method. * line-map.c (rich_location::add_fixit_insert): Rename both overloaded methods to.. (rich_location::add_fixit_insert_before): ...this, updating their comments. (rich_location::add_fixit_insert_after): Two new methods. (rich_location::reject_impossible_fixit): Split out failure-handling into... (rich_location::stop_supporting_fixits): New method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240115 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-parser.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c8563749939..4a9881d351a 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2016-09-13 David Malcolm + + * c-parser.c (c_parser_declaration_or_fndef): Update for renaming + of add_fixit_insert to add_fixit_insert_before. + 2016-09-13 Marek Polacek * c-typeck.c (build_unary_op): Rename FLAG parameter to NOCONVERT. Use diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index a3044244f6c..e71c0d5b9b5 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1685,7 +1685,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, if (tag_exists_p (RECORD_TYPE, name)) { /* This is not C++ with its implicit typedef. */ - richloc.add_fixit_insert ("struct "); + richloc.add_fixit_insert_before ("struct "); error_at_rich_loc (&richloc, "unknown type name %qE;" " use % keyword to refer to the type", @@ -1693,7 +1693,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, } else if (tag_exists_p (UNION_TYPE, name)) { - richloc.add_fixit_insert ("union "); + richloc.add_fixit_insert_before ("union "); error_at_rich_loc (&richloc, "unknown type name %qE;" " use % keyword to refer to the type", @@ -1701,7 +1701,7 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, } else if (tag_exists_p (ENUMERAL_TYPE, name)) { - richloc.add_fixit_insert ("enum "); + richloc.add_fixit_insert_before ("enum "); error_at_rich_loc (&richloc, "unknown type name %qE;" " use % keyword to refer to the type", -- cgit v1.2.1 From b99cc6da54d7496dd9293a29157ec540914a06b7 Mon Sep 17 00:00:00 2001 From: mpolacek Date: Wed, 14 Sep 2016 15:05:00 +0000 Subject: * c-common.c (c_common_truthvalue_conversion): Use false instead of 0. * c-common.h (build_unary_op): Change nonconvert parameter type to bool. * c-omp.c (c_finish_omp_atomic): Use false instead of 0. * c-array-notation.c (create_cmp_incr): Use false instead of 0. (fix_array_notation_expr): Likewise. * c-decl.c (finish_decl): Likewise. * c-parser.c (c_parser_postfix_expression_after_primary): Likewise. * c-typeck.c (array_to_pointer_conversion): Use true instead of 1. (function_to_pointer_conversion): Use false instead of 0. (convert_lvalue_to_rvalue): Likewise. (parser_build_unary_op): Likewise. (build_atomic_assign): Likewise. (build_unary_op): Change nonconvert parameter type to bool, use true/false instead of 1/0. (build_binary_op): Use true instead of 1. * cp-tree.h (cp_build_unary_op): Change nonconvert parameter type to bool. * decl2.c (one_static_initialization_or_destruction): Use true instead of 1. * init.c (build_vec_init): Use false instead of 0. * pt.c (tsubst_copy_and_build): Likewise. * semantics.c (simplify_loop_decl_cond): Likewise. * typeck.c (rationalize_conditional_expr): Likewise. (cp_build_binary_op): Use true instead of 1. (cp_build_unary_op): Change nonconvert parameter type to bool. Use true instead of 1. (build_unary_op): Change nonconvert parameter type to bool. (unary_complex_lvalue): Use false instead of 0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240137 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 15 +++++++++++++++ gcc/c/c-array-notation.c | 4 ++-- gcc/c/c-decl.c | 2 +- gcc/c/c-parser.c | 8 ++++---- gcc/c/c-typeck.c | 46 ++++++++++++++++++++++++---------------------- 5 files changed, 46 insertions(+), 29 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 4a9881d351a..46c296992b5 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,18 @@ +2016-09-14 Marek Polacek + + * c-array-notation.c (create_cmp_incr): Use false instead of 0. + (fix_array_notation_expr): Likewise. + * c-decl.c (finish_decl): Likewise. + * c-parser.c (c_parser_postfix_expression_after_primary): Likewise. + * c-typeck.c (array_to_pointer_conversion): Use true instead of 1. + (function_to_pointer_conversion): Use false instead of 0. + (convert_lvalue_to_rvalue): Likewise. + (parser_build_unary_op): Likewise. + (build_atomic_assign): Likewise. + (build_unary_op): Change nonconvert parameter type to bool, use + true/false instead of 1/0. + (build_binary_op): Use true instead of 1. + 2016-09-13 David Malcolm * c-parser.c (c_parser_declaration_or_fndef): Update for renaming diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c index c7cf66a2c81..ce609112089 100644 --- a/gcc/c/c-array-notation.c +++ b/gcc/c/c-array-notation.c @@ -104,7 +104,7 @@ create_cmp_incr (location_t loc, vec *node, size_t rank, { tree var = (*node)[ii].var; tree length = an_info[0][ii].length; - (*node)[ii].incr = build_unary_op (loc, POSTINCREMENT_EXPR, var, 0); + (*node)[ii].incr = build_unary_op (loc, POSTINCREMENT_EXPR, var, false); (*node)[ii].cmp = build2 (LT_EXPR, boolean_type_node, var, length); } } @@ -1088,7 +1088,7 @@ fix_array_notation_expr (location_t location, enum tree_code code, arg = default_function_array_read_conversion (location, arg); if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR) - arg.value = build_unary_op (location, code, arg.value, 0); + arg.value = build_unary_op (location, code, arg.value, false); else if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR) arg = parser_build_unary_op (location, code, arg); diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 8f49c35237d..d15b8f89b0a 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -5102,7 +5102,7 @@ finish_decl (tree decl, location_t init_loc, tree init, vec *v; /* Build "cleanup(&decl)" for the destructor. */ - cleanup = build_unary_op (input_location, ADDR_EXPR, decl, 0); + cleanup = build_unary_op (input_location, ADDR_EXPR, decl, false); vec_alloc (v, 1); v->quick_push (cleanup); cleanup = c_build_function_call_vec (DECL_SOURCE_LOCATION (decl), diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index e71c0d5b9b5..58424a9e8e5 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -8478,8 +8478,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser, else { expr = default_function_array_read_conversion (expr_loc, expr); - expr.value = build_unary_op (op_loc, - POSTINCREMENT_EXPR, expr.value, 0); + expr.value = build_unary_op (op_loc, POSTINCREMENT_EXPR, + expr.value, false); } set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; @@ -8497,8 +8497,8 @@ c_parser_postfix_expression_after_primary (c_parser *parser, else { expr = default_function_array_read_conversion (expr_loc, expr); - expr.value = build_unary_op (op_loc, - POSTDECREMENT_EXPR, expr.value, 0); + expr.value = build_unary_op (op_loc, POSTDECREMENT_EXPR, + expr.value, false); } set_c_expr_source_range (&expr, start, finish); expr.original_code = ERROR_MARK; diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 8c7f89542b7..4dec397225e 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -1880,7 +1880,7 @@ array_to_pointer_conversion (location_t loc, tree exp) "is ill-formed in C++"); } - adr = build_unary_op (loc, ADDR_EXPR, exp, 1); + adr = build_unary_op (loc, ADDR_EXPR, exp, true); return convert (ptrtype, adr); } @@ -1897,7 +1897,7 @@ function_to_pointer_conversion (location_t loc, tree exp) if (TREE_NO_WARNING (orig_exp)) TREE_NO_WARNING (exp) = 1; - return build_unary_op (loc, ADDR_EXPR, exp, 0); + return build_unary_op (loc, ADDR_EXPR, exp, false); } /* Mark EXP as read, not just set, for set but not used -Wunused @@ -2042,7 +2042,7 @@ convert_lvalue_to_rvalue (location_t loc, struct c_expr exp, vec *params; tree nonatomic_type, tmp, tmp_addr, fndecl, func_call; tree expr_type = TREE_TYPE (exp.value); - tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, 0); + tree expr_addr = build_unary_op (loc, ADDR_EXPR, exp.value, false); tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST); gcc_assert (TYPE_ATOMIC (expr_type)); @@ -2055,7 +2055,7 @@ convert_lvalue_to_rvalue (location_t loc, struct c_expr exp, create the VAL temp variable to hold the RHS. */ nonatomic_type = build_qualified_type (expr_type, TYPE_UNQUALIFIED); tmp = create_tmp_var_raw (nonatomic_type); - tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, 0); + tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false); TREE_ADDRESSABLE (tmp) = 1; TREE_NO_WARNING (tmp) = 1; @@ -3575,7 +3575,7 @@ parser_build_unary_op (location_t loc, enum tree_code code, struct c_expr arg) } else { - result.value = build_unary_op (loc, code, arg.value, 0); + result.value = build_unary_op (loc, code, arg.value, false); if (TREE_OVERFLOW_P (result.value) && !TREE_OVERFLOW_P (arg.value)) overflow_warning (loc, result.value); @@ -3872,7 +3872,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode, tree loop_label, loop_decl, done_label, done_decl; tree lhs_type = TREE_TYPE (lhs); - tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, 0); + tree lhs_addr = build_unary_op (loc, ADDR_EXPR, lhs, false); tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST); tree rhs_type = TREE_TYPE (rhs); @@ -3909,7 +3909,7 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode, if (modifycode == NOP_EXPR) { /* Build __atomic_store (&lhs, &val, SEQ_CST) */ - rhs = build_unary_op (loc, ADDR_EXPR, val, 0); + rhs = build_unary_op (loc, ADDR_EXPR, val, false); fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_STORE); params->quick_push (lhs_addr); params->quick_push (rhs); @@ -4014,12 +4014,12 @@ build_atomic_assign (location_t loc, tree lhs, enum tree_code modifycode, cas_loop: /* Create the variables and labels required for the op= form. */ old = create_tmp_var_raw (nonatomic_lhs_type); - old_addr = build_unary_op (loc, ADDR_EXPR, old, 0); + old_addr = build_unary_op (loc, ADDR_EXPR, old, false); TREE_ADDRESSABLE (old) = 1; TREE_NO_WARNING (old) = 1; newval = create_tmp_var_raw (nonatomic_lhs_type); - newval_addr = build_unary_op (loc, ADDR_EXPR, newval, 0); + newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false); TREE_ADDRESSABLE (newval) = 1; TREE_NO_WARNING (newval) = 1; @@ -4112,17 +4112,17 @@ cas_loop: /* Construct and perhaps optimize a tree representation for a unary operation. CODE, a tree_code, specifies the operation and XARG is the operand. - For any CODE other than ADDR_EXPR, NOCONVERT nonzero suppresses - the default promotions (such as from short to int). - For ADDR_EXPR, the default promotions are not applied; NOCONVERT nonzero - allows non-lvalues; this is only used to handle conversion of non-lvalue - arrays to pointers in C99. + For any CODE other than ADDR_EXPR, NOCONVERT suppresses the default + promotions (such as from short to int). + For ADDR_EXPR, the default promotions are not applied; NOCONVERT allows + non-lvalues; this is only used to handle conversion of non-lvalue arrays + to pointers in C99. LOCATION is the location of the operator. */ tree build_unary_op (location_t location, enum tree_code code, tree xarg, - int noconvert) + bool noconvert) { /* No default_conversion here. It causes trouble for ADDR_EXPR. */ tree arg = xarg; @@ -4324,9 +4324,11 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, if (!atomic_op) { arg = stabilize_reference (arg); - real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg, 1); - imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg, 1); - real = build_unary_op (EXPR_LOCATION (arg), code, real, 1); + real = build_unary_op (EXPR_LOCATION (arg), REALPART_EXPR, arg, + true); + imag = build_unary_op (EXPR_LOCATION (arg), IMAGPART_EXPR, arg, + true); + real = build_unary_op (EXPR_LOCATION (arg), code, real, true); if (real == error_mark_node || imag == error_mark_node) return error_mark_node; ret = build2 (COMPLEX_EXPR, TREE_TYPE (arg), @@ -11513,9 +11515,9 @@ build_binary_op (location_t location, enum tree_code code, { op0 = c_save_expr (op0); real = build_unary_op (EXPR_LOCATION (orig_op0), REALPART_EXPR, - op0, 1); + op0, true); imag = build_unary_op (EXPR_LOCATION (orig_op0), IMAGPART_EXPR, - op0, 1); + op0, true); switch (code) { case MULT_EXPR: @@ -11535,9 +11537,9 @@ build_binary_op (location_t location, enum tree_code code, { op1 = c_save_expr (op1); real = build_unary_op (EXPR_LOCATION (orig_op1), REALPART_EXPR, - op1, 1); + op1, true); imag = build_unary_op (EXPR_LOCATION (orig_op1), IMAGPART_EXPR, - op1, 1); + op1, true); switch (code) { case MULT_EXPR: -- cgit v1.2.1 From d80c1c6c041a9df8d92d194aefbb0002d70e4a53 Mon Sep 17 00:00:00 2001 From: mpolacek Date: Fri, 16 Sep 2016 10:18:06 +0000 Subject: * c-typeck.c (lvalue_p): Use true and false instead of 1 and 0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240185 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 4 ++++ gcc/c/c-typeck.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 46c296992b5..4c2fc5dda65 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,7 @@ +2016-09-16 Marek Polacek + + * c-typeck.c (lvalue_p): Use true and false instead of 1 and 0. + 2016-09-14 Marek Polacek * c-array-notation.c (create_cmp_incr): Use false instead of 0. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 4dec397225e..059ad1fc2e0 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -4631,7 +4631,7 @@ lvalue_p (const_tree ref) case COMPOUND_LITERAL_EXPR: case STRING_CST: - return 1; + return true; case INDIRECT_REF: case ARRAY_REF: @@ -4647,7 +4647,7 @@ lvalue_p (const_tree ref) return TREE_CODE (TREE_TYPE (ref)) == ARRAY_TYPE; default: - return 0; + return false; } } -- cgit v1.2.1