From e10299116384e44987062a728c3f363121b0e072 Mon Sep 17 00:00:00 2001 From: jakub Date: Thu, 24 Apr 2014 21:20:28 +0000 Subject: gcc/c/ * c-parser.c (c_parser_omp_atomic): Allow seq_cst before atomic-clause, allow comma in between atomic-clause and seq_cst. gcc/cp/ * parser.c (cp_parser_omp_atomic): Allow seq_cst before atomic-clause, allow comma in between atomic-clause and seq_cst. gcc/testsuite/ * c-c++-common/gomp/atomic-16.c: Remove all dg-error directives. Replace load with read and store with write. libgomp/ * testsuite/libgomp.c++/atomic-14.C: Allow seq_cst and atomic type clauses in any order and optional comma in between. * testsuite/libgomp.c++/atomic-15.C: Likewise. * testsuite/libgomp.c/atomic-17.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209762 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-parser.c | 30 +++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 2d182f354d5..3ee2594afd6 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-04-24 Jakub Jelinek + + * c-parser.c (c_parser_omp_atomic): Allow seq_cst before + atomic-clause, allow comma in between atomic-clause and + seq_cst. + 2014-04-22 Jakub Jelinek PR c/59073 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 0deab840456..6eb235c5c43 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -11195,6 +11195,18 @@ c_parser_omp_atomic (location_t loc, c_parser *parser) bool swapped = false; bool seq_cst = false; + if (c_parser_next_token_is (parser, CPP_NAME)) + { + const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value); + if (!strcmp (p, "seq_cst")) + { + seq_cst = true; + c_parser_consume_token (parser); + if (c_parser_next_token_is (parser, CPP_COMMA) + && c_parser_peek_2nd_token (parser)->type == CPP_NAME) + c_parser_consume_token (parser); + } + } if (c_parser_next_token_is (parser, CPP_NAME)) { const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value); @@ -11212,13 +11224,21 @@ c_parser_omp_atomic (location_t loc, c_parser *parser) if (p) c_parser_consume_token (parser); } - if (c_parser_next_token_is (parser, CPP_NAME)) + if (!seq_cst) { - const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value); - if (!strcmp (p, "seq_cst")) + if (c_parser_next_token_is (parser, CPP_COMMA) + && c_parser_peek_2nd_token (parser)->type == CPP_NAME) + c_parser_consume_token (parser); + + if (c_parser_next_token_is (parser, CPP_NAME)) { - seq_cst = true; - c_parser_consume_token (parser); + const char *p + = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value); + if (!strcmp (p, "seq_cst")) + { + seq_cst = true; + c_parser_consume_token (parser); + } } } c_parser_skip_to_pragma_eol (parser); -- cgit v1.2.1 From 85d2d1a8916ea9f20f8e790f9e8b142f5b5989fb Mon Sep 17 00:00:00 2001 From: law Date: Thu, 24 Apr 2014 21:29:45 +0000 Subject: * c-parser.c (c_parser_sizeof_expression): Reorganize slightly to avoid goto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209765 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-parser.c | 31 +++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3ee2594afd6..14e616903cb 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2014-04-24 Prathamesh Kulkarni + + * c-parser.c (c_parser_sizeof_expression): Reorganize slightly to + avoid goto. + 2014-04-24 Jakub Jelinek * c-parser.c (c_parser_omp_atomic): Allow seq_cst before diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 6eb235c5c43..c229bdb47ad 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -6514,30 +6514,29 @@ c_parser_sizeof_expression (c_parser *parser) return ret; } if (c_parser_next_token_is (parser, CPP_OPEN_BRACE)) + expr = c_parser_postfix_expression_after_paren_type (parser, + type_name, + expr_loc); + else { - expr = c_parser_postfix_expression_after_paren_type (parser, - type_name, - expr_loc); - goto sizeof_expr; + /* sizeof ( type-name ). */ + c_inhibit_evaluation_warnings--; + in_sizeof--; + return c_expr_sizeof_type (expr_loc, type_name); } - /* sizeof ( type-name ). */ - c_inhibit_evaluation_warnings--; - in_sizeof--; - return c_expr_sizeof_type (expr_loc, type_name); } else { expr_loc = c_parser_peek_token (parser)->location; expr = c_parser_unary_expression (parser); - sizeof_expr: - c_inhibit_evaluation_warnings--; - in_sizeof--; - mark_exp_read (expr.value); - if (TREE_CODE (expr.value) == COMPONENT_REF - && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1))) - error_at (expr_loc, "% applied to a bit-field"); - return c_expr_sizeof_expr (expr_loc, expr); } + c_inhibit_evaluation_warnings--; + in_sizeof--; + mark_exp_read (expr.value); + if (TREE_CODE (expr.value) == COMPONENT_REF + && DECL_C_BIT_FIELD (TREE_OPERAND (expr.value, 1))) + error_at (expr_loc, "% applied to a bit-field"); + return c_expr_sizeof_expr (expr_loc, expr); } /* Parse an alignof expression. */ -- cgit v1.2.1 From adc93f318aa9da3277035ea5a1179a1e07c2a967 Mon Sep 17 00:00:00 2001 From: mpolacek Date: Fri, 25 Apr 2014 10:49:56 +0000 Subject: PR c/60114 c/ * c-parser.c (c_parser_initelt): Pass input_location to process_init_element. (c_parser_initval): Pass loc to process_init_element. * c-tree.h (process_init_element): Adjust declaration. * c-typeck.c (push_init_level): Pass input_location to process_init_element. (pop_init_level): Likewise. (set_designator): Likewise. (output_init_element): Add location_t parameter. Pass loc to digest_init. (output_pending_init_elements): Pass input_location to output_init_element. (process_init_element): Add location_t parameter. Pass loc to output_init_element. testsuite/ * gcc.dg/pr60114.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209794 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 18 ++++++++++++++++ gcc/c/c-parser.c | 11 ++++++---- gcc/c/c-tree.h | 3 ++- gcc/c/c-typeck.c | 65 ++++++++++++++++++++++++++++---------------------------- 4 files changed, 60 insertions(+), 37 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 14e616903cb..7369065d20e 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,21 @@ +2014-04-25 Marek Polacek + + PR c/60114 + * c-parser.c (c_parser_initelt): Pass input_location to + process_init_element. + (c_parser_initval): Pass loc to process_init_element. + * c-tree.h (process_init_element): Adjust declaration. + * c-typeck.c (push_init_level): Pass input_location to + process_init_element. + (pop_init_level): Likewise. + (set_designator): Likewise. + (output_init_element): Add location_t parameter. Pass loc to + digest_init. + (output_pending_init_elements): Pass input_location to + output_init_element. + (process_init_element): Add location_t parameter. Pass loc to + output_init_element. + 2014-04-24 Prathamesh Kulkarni * c-parser.c (c_parser_sizeof_expression): Reorganize slightly to diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index c229bdb47ad..56f79f6a795 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -4219,7 +4219,8 @@ c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack) init.original_type = NULL; c_parser_error (parser, "expected identifier"); c_parser_skip_until_found (parser, CPP_COMMA, NULL); - process_init_element (init, false, braced_init_obstack); + process_init_element (input_location, init, false, + braced_init_obstack); return; } } @@ -4351,7 +4352,8 @@ c_parser_initelt (c_parser *parser, struct obstack * braced_init_obstack) init.original_type = NULL; c_parser_error (parser, "expected %<=%>"); c_parser_skip_until_found (parser, CPP_COMMA, NULL); - process_init_element (init, false, braced_init_obstack); + process_init_element (input_location, init, false, + braced_init_obstack); return; } } @@ -4372,18 +4374,19 @@ c_parser_initval (c_parser *parser, struct c_expr *after, { struct c_expr init; gcc_assert (!after || c_dialect_objc ()); + location_t loc = c_parser_peek_token (parser)->location; + if (c_parser_next_token_is (parser, CPP_OPEN_BRACE) && !after) init = c_parser_braced_init (parser, NULL_TREE, true); else { - location_t loc = c_parser_peek_token (parser)->location; init = c_parser_expr_no_commas (parser, after); if (init.value != NULL_TREE && TREE_CODE (init.value) != STRING_CST && TREE_CODE (init.value) != COMPOUND_LITERAL_EXPR) init = convert_lvalue_to_rvalue (loc, init, true, true); } - process_init_element (init, false, braced_init_obstack); + process_init_element (loc, init, false, braced_init_obstack); } /* Parse a compound statement (possibly a function body) (C90 6.6.2, diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index 85df8858dea..53768d619b7 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -612,7 +612,8 @@ extern void push_init_level (int, struct obstack *); extern struct c_expr pop_init_level (int, struct obstack *); extern void set_init_index (tree, tree, struct obstack *); extern void set_init_label (tree, struct obstack *); -extern void process_init_element (struct c_expr, bool, struct obstack *); +extern void process_init_element (location_t, struct c_expr, bool, + struct obstack *); extern tree build_compound_literal (location_t, tree, tree, bool); extern void check_compound_literal_type (location_t, struct c_type_name *); extern tree c_start_case (location_t, location_t, tree); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 65aad45651c..62c72dfdd70 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -102,8 +102,8 @@ static int spelling_length (void); static char *print_spelling (char *); static void warning_init (int, const char *); static tree digest_init (location_t, tree, tree, tree, bool, bool, int); -static void output_init_element (tree, tree, bool, tree, tree, int, bool, - struct obstack *); +static void output_init_element (location_t, tree, tree, bool, tree, tree, int, + bool, struct obstack *); static void output_pending_init_elements (int, struct obstack *); static int set_designator (int, struct obstack *); static void push_range_stack (tree, struct obstack *); @@ -7183,13 +7183,15 @@ push_init_level (int implicit, struct obstack * braced_init_obstack) if ((TREE_CODE (constructor_type) == RECORD_TYPE || TREE_CODE (constructor_type) == UNION_TYPE) && constructor_fields == 0) - process_init_element (pop_init_level (1, braced_init_obstack), + process_init_element (input_location, + pop_init_level (1, braced_init_obstack), true, braced_init_obstack); else if (TREE_CODE (constructor_type) == ARRAY_TYPE && constructor_max_index && tree_int_cst_lt (constructor_max_index, constructor_index)) - process_init_element (pop_init_level (1, braced_init_obstack), + process_init_element (input_location, + pop_init_level (1, braced_init_obstack), true, braced_init_obstack); else break; @@ -7389,10 +7391,9 @@ pop_init_level (int implicit, struct obstack * braced_init_obstack) /* When we come to an explicit close brace, pop any inner levels that didn't have explicit braces. */ while (constructor_stack->implicit) - { - process_init_element (pop_init_level (1, braced_init_obstack), - true, braced_init_obstack); - } + process_init_element (input_location, + pop_init_level (1, braced_init_obstack), + true, braced_init_obstack); gcc_assert (!constructor_range_stack); } @@ -7570,10 +7571,9 @@ set_designator (int array, struct obstack * braced_init_obstack) /* Designator list starts at the level of closest explicit braces. */ while (constructor_stack->implicit) - { - process_init_element (pop_init_level (1, braced_init_obstack), - true, braced_init_obstack); - } + process_init_element (input_location, + pop_init_level (1, braced_init_obstack), + true, braced_init_obstack); constructor_designated = 1; return 0; } @@ -8193,9 +8193,9 @@ find_init_member (tree field, struct obstack * braced_init_obstack) existing initializer. */ static void -output_init_element (tree value, tree origtype, bool strict_string, tree type, - tree field, int pending, bool implicit, - struct obstack * braced_init_obstack) +output_init_element (location_t loc, tree value, tree origtype, + bool strict_string, tree type, tree field, int pending, + bool implicit, struct obstack * braced_init_obstack) { tree semantic_type = NULL_TREE; bool maybe_const = true; @@ -8293,8 +8293,8 @@ output_init_element (tree value, tree origtype, bool strict_string, tree type, if (semantic_type) value = build1 (EXCESS_PRECISION_EXPR, semantic_type, value); - value = digest_init (input_location, type, value, origtype, npc, - strict_string, require_constant_value); + value = digest_init (loc, type, value, origtype, npc, strict_string, + require_constant_value); if (value == error_mark_node) { constructor_erroneous = 1; @@ -8421,8 +8421,8 @@ output_pending_init_elements (int all, struct obstack * braced_init_obstack) { if (tree_int_cst_equal (elt->purpose, constructor_unfilled_index)) - output_init_element (elt->value, elt->origtype, true, - TREE_TYPE (constructor_type), + output_init_element (input_location, elt->value, elt->origtype, + true, TREE_TYPE (constructor_type), constructor_unfilled_index, 0, false, braced_init_obstack); else if (tree_int_cst_lt (constructor_unfilled_index, @@ -8476,8 +8476,8 @@ output_pending_init_elements (int all, struct obstack * braced_init_obstack) if (tree_int_cst_equal (elt_bitpos, ctor_unfilled_bitpos)) { constructor_unfilled_fields = elt->purpose; - output_init_element (elt->value, elt->origtype, true, - TREE_TYPE (elt->purpose), + output_init_element (input_location, elt->value, elt->origtype, + true, TREE_TYPE (elt->purpose), elt->purpose, 0, false, braced_init_obstack); } @@ -8550,7 +8550,7 @@ output_pending_init_elements (int all, struct obstack * braced_init_obstack) existing initializer. */ void -process_init_element (struct c_expr value, bool implicit, +process_init_element (location_t loc, struct c_expr value, bool implicit, struct obstack * braced_init_obstack) { tree orig_value = value.value; @@ -8594,14 +8594,14 @@ process_init_element (struct c_expr value, bool implicit, if ((TREE_CODE (constructor_type) == RECORD_TYPE || TREE_CODE (constructor_type) == UNION_TYPE) && constructor_fields == 0) - process_init_element (pop_init_level (1, braced_init_obstack), + process_init_element (loc, pop_init_level (1, braced_init_obstack), true, braced_init_obstack); else if ((TREE_CODE (constructor_type) == ARRAY_TYPE || TREE_CODE (constructor_type) == VECTOR_TYPE) && constructor_max_index && tree_int_cst_lt (constructor_max_index, constructor_index)) - process_init_element (pop_init_level (1, braced_init_obstack), + process_init_element (loc, pop_init_level (1, braced_init_obstack), true, braced_init_obstack); else break; @@ -8679,7 +8679,7 @@ process_init_element (struct c_expr value, bool implicit, if (value.value) { push_member_name (constructor_fields); - output_init_element (value.value, value.original_type, + output_init_element (loc, value.value, value.original_type, strict_string, fieldtype, constructor_fields, 1, implicit, braced_init_obstack); @@ -8771,7 +8771,7 @@ process_init_element (struct c_expr value, bool implicit, if (value.value) { push_member_name (constructor_fields); - output_init_element (value.value, value.original_type, + output_init_element (loc, value.value, value.original_type, strict_string, fieldtype, constructor_fields, 1, implicit, braced_init_obstack); @@ -8823,7 +8823,7 @@ process_init_element (struct c_expr value, bool implicit, if (value.value) { push_array_bounds (tree_to_uhwi (constructor_index)); - output_init_element (value.value, value.original_type, + output_init_element (loc, value.value, value.original_type, strict_string, elttype, constructor_index, 1, implicit, braced_init_obstack); @@ -8858,7 +8858,7 @@ process_init_element (struct c_expr value, bool implicit, { if (TREE_CODE (value.value) == VECTOR_CST) elttype = TYPE_MAIN_VARIANT (constructor_type); - output_init_element (value.value, value.original_type, + output_init_element (loc, value.value, value.original_type, strict_string, elttype, constructor_index, 1, implicit, braced_init_obstack); @@ -8887,7 +8887,7 @@ process_init_element (struct c_expr value, bool implicit, else { if (value.value) - output_init_element (value.value, value.original_type, + output_init_element (loc, value.value, value.original_type, strict_string, constructor_type, NULL_TREE, 1, implicit, braced_init_obstack); @@ -8906,8 +8906,8 @@ process_init_element (struct c_expr value, bool implicit, while (constructor_stack != range_stack->stack) { gcc_assert (constructor_stack->implicit); - process_init_element (pop_init_level (1, - braced_init_obstack), + process_init_element (loc, + pop_init_level (1, braced_init_obstack), true, braced_init_obstack); } for (p = range_stack; @@ -8915,7 +8915,8 @@ process_init_element (struct c_expr value, bool implicit, p = p->prev) { gcc_assert (constructor_stack->implicit); - process_init_element (pop_init_level (1, braced_init_obstack), + process_init_element (loc, + pop_init_level (1, braced_init_obstack), true, braced_init_obstack); } -- cgit v1.2.1 From 4a026b4805910fdfa7588b48cb44bd358903b163 Mon Sep 17 00:00:00 2001 From: mpolacek Date: Fri, 25 Apr 2014 11:04:40 +0000 Subject: PR c/18079 c/ * c-decl.c (diagnose_mismatched_decls): Warn for mismatched always_inline/noinline and hot/cold attributes. c-family/ * c-common.c (handle_noinline_attribute): Warn if the attribute conflicts with always_inline attribute. (handle_always_inline_attribute): Warn if the attribute conflicts with noinline attribute. testsuite/ * gcc.dg/pr18079.c: New test. * gcc.dg/pr18079-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209796 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-decl.c | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 10 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 7369065d20e..80841af40ee 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2014-04-25 Marek Polacek + + PR c/18079 + * c-decl.c (diagnose_mismatched_decls): Warn for mismatched + always_inline/noinline and hot/cold attributes. + 2014-04-25 Marek Polacek PR c/60114 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index df84980e309..e30876cbd1b 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -2099,18 +2099,38 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, /* Diagnose inline __attribute__ ((noinline)) which is silly. */ if (DECL_DECLARED_INLINE_P (newdecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) - { - warned |= warning (OPT_Wattributes, - "inline declaration of %qD follows " - "declaration with attribute noinline", newdecl); - } + warned |= warning (OPT_Wattributes, + "inline declaration of %qD follows " + "declaration with attribute noinline", newdecl); else if (DECL_DECLARED_INLINE_P (olddecl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) - { - warned |= warning (OPT_Wattributes, - "declaration of %q+D with attribute " - "noinline follows inline declaration ", newdecl); - } + warned |= warning (OPT_Wattributes, + "declaration of %q+D with attribute " + "noinline follows inline declaration ", newdecl); + else if (lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)) + && lookup_attribute ("always_inline", DECL_ATTRIBUTES (olddecl))) + warned |= warning (OPT_Wattributes, + "declaration of %q+D with attribute " + "%qs follows declaration with attribute %qs", + newdecl, "noinline", "always_inline"); + else if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (newdecl)) + && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) + warned |= warning (OPT_Wattributes, + "declaration of %q+D with attribute " + "%qs follows declaration with attribute %qs", + newdecl, "always_inline", "noinline"); + else if (lookup_attribute ("cold", DECL_ATTRIBUTES (newdecl)) + && lookup_attribute ("hot", DECL_ATTRIBUTES (olddecl))) + warned |= warning (OPT_Wattributes, + "declaration of %q+D with attribute %qs follows " + "declaration with attribute %qs", newdecl, "cold", + "hot"); + else if (lookup_attribute ("hot", DECL_ATTRIBUTES (newdecl)) + && lookup_attribute ("cold", DECL_ATTRIBUTES (olddecl))) + warned |= warning (OPT_Wattributes, + "declaration of %q+D with attribute %qs follows " + "declaration with attribute %qs", newdecl, "hot", + "cold"); } else /* PARM_DECL, VAR_DECL */ { -- cgit v1.2.1