diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-02-11 15:02:44 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-02-11 15:02:44 -0800 |
commit | 9a510fb0970d3d9a4201bce8965cabe67850386b (patch) | |
tree | 43d7fd2bbfd7ad8c9625a718a5e8718889351994 /gcc/c | |
parent | a6d3012b274f38b20e2a57162106f625746af6c6 (diff) | |
parent | 8dc2499aa62f768c6395c9754b8cabc1ce25c494 (diff) | |
download | gcc-9a510fb0970d3d9a4201bce8965cabe67850386b.zip gcc-9a510fb0970d3d9a4201bce8965cabe67850386b.tar.gz gcc-9a510fb0970d3d9a4201bce8965cabe67850386b.tar.bz2 |
Merge from trunk revision 8dc2499aa62f768c6395c9754b8cabc1ce25c494
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 230 | ||||
-rw-r--r-- | gcc/c/Make-lang.in | 16 | ||||
-rw-r--r-- | gcc/c/c-aux-info.cc (renamed from gcc/c/c-aux-info.c) | 2 | ||||
-rw-r--r-- | gcc/c/c-convert.cc (renamed from gcc/c/c-convert.c) | 47 | ||||
-rw-r--r-- | gcc/c/c-decl.cc (renamed from gcc/c/c-decl.c) | 57 | ||||
-rw-r--r-- | gcc/c/c-errors.cc (renamed from gcc/c/c-errors.c) | 2 | ||||
-rw-r--r-- | gcc/c/c-fold.cc (renamed from gcc/c/c-fold.c) | 3 | ||||
-rw-r--r-- | gcc/c/c-lang.cc (renamed from gcc/c/c-lang.c) | 2 | ||||
-rw-r--r-- | gcc/c/c-lang.h | 2 | ||||
-rw-r--r-- | gcc/c/c-objc-common.cc (renamed from gcc/c/c-objc-common.c) | 2 | ||||
-rw-r--r-- | gcc/c/c-objc-common.h | 6 | ||||
-rw-r--r-- | gcc/c/c-parser.cc (renamed from gcc/c/c-parser.c) | 228 | ||||
-rw-r--r-- | gcc/c/c-parser.h | 4 | ||||
-rw-r--r-- | gcc/c/c-tree.h | 26 | ||||
-rw-r--r-- | gcc/c/c-typeck.cc (renamed from gcc/c/c-typeck.c) | 183 | ||||
-rw-r--r-- | gcc/c/config-lang.in | 4 | ||||
-rw-r--r-- | gcc/c/gccspec.cc (renamed from gcc/c/gccspec.c) | 2 | ||||
-rw-r--r-- | gcc/c/gimple-parser.cc (renamed from gcc/c/gimple-parser.c) | 24 | ||||
-rw-r--r-- | gcc/c/gimple-parser.h | 2 |
19 files changed, 693 insertions, 149 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 08ef6ae..29c7b74 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,231 @@ +2022-02-10 Marcel Vollweiler <marcel@codesourcery.com> + + * c-parser.cc (c_parser_omp_clause_name): Parse 'has_device_addr' + clause. + (c_parser_omp_variable_list): Handle array sections. + (c_parser_omp_clause_has_device_addr): Added. + (c_parser_omp_all_clauses): Added PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR + case. + (c_parser_omp_target_exit_data): Added HAS_DEVICE_ADDR to + OMP_CLAUSE_MASK. + * c-typeck.cc (handle_omp_array_sections): Handle clause restrictions. + (c_finish_omp_clauses): Handle array sections. + +2022-02-09 Jakub Jelinek <jakub@redhat.com> + + PR c/104427 + * c-parser.cc (c_parser_postfix_expression) + <case RID_BUILTIN_ASSOC_BARRIER>: Use parser_build_unary_op + instead of build1_loc to build PAREN_EXPR. + * c-typeck.cc (build_unary_op): Handle PAREN_EXPR. + * c-fold.cc (c_fully_fold_internal): Likewise. + +2022-01-17 Martin Liska <mliska@suse.cz> + + * Make-lang.in: Rename .c names to .cc. + * c-convert.cc: Likewise. + * c-decl.cc (struct lang_identifier): Likewise. + (pop_scope): Likewise. + (finish_decl): Likewise. + * c-objc-common.h (GCC_C_OBJC_COMMON): Likewise. + * c-parser.cc (c_parser_skip_to_end_of_block_or_statement): Likewise. + * c-parser.h (GCC_C_PARSER_H): Likewise. + * c-tree.h (c_keyword_starts_typename): Likewise. + (finish_declspecs): Likewise. + (c_get_alias_set): Likewise. + (enum c_oracle_request): Likewise. + (tag_exists_p): Likewise. + (set_c_expr_source_range): Likewise. + * c-typeck.cc (c_common_type): Likewise. + (c_finish_omp_clauses): Likewise. + * config-lang.in: Likewise. + +2022-01-17 Martin Liska <mliska@suse.cz> + + * c-aux-info.c: Moved to... + * c-aux-info.cc: ...here. + * c-convert.c: Moved to... + * c-convert.cc: ...here. + * c-decl.c: Moved to... + * c-decl.cc: ...here. + * c-errors.c: Moved to... + * c-errors.cc: ...here. + * c-fold.c: Moved to... + * c-fold.cc: ...here. + * c-lang.c: Moved to... + * c-lang.cc: ...here. + * c-objc-common.c: Moved to... + * c-objc-common.cc: ...here. + * c-parser.c: Moved to... + * c-parser.cc: ...here. + * c-typeck.c: Moved to... + * c-typeck.cc: ...here. + * gccspec.c: Moved to... + * gccspec.cc: ...here. + * gimple-parser.c: Moved to... + * gimple-parser.cc: ...here. + +2022-01-17 Andrew Stubbs <ams@codesourcery.com> + + * c-parser.c (c_parser_omp_requires): Don't "sorry" dynamic_allocators. + +2022-01-14 Chung-Lin Tang <cltang@codesourcery.com> + + PR c++/103705 + * c-typeck.c (c_finish_omp_clauses): Also continue peeling off of + outer node for ARRAY_REFs. + +2022-01-01 Jakub Jelinek <jakub@redhat.com> + + PR objc/103639 + * c-typeck.c (c_finish_bc_stmt): For break inside of switch inside of + ObjC foreach, emit normal BREAK_STMT rather than goto to label. + +2021-12-17 Marek Polacek <polacek@redhat.com> + + PR c/103649 + * c-decl.c (c_warn_unused_attributes): Don't warn for + attribute_ignored_p. + * c-parser.c (c_parser_std_attribute): Skip parsing of the attribute + arguments when the attribute is ignored. + +2021-12-14 Jakub Jelinek <jakub@redhat.com> + + PR c/103587 + * c-parser.c (c_parser_balanced_token_sequence): For CPP_PRAGMA, + consume the pragma and silently skip to the pragma eol. + +2021-12-12 Jonathan Wakely <jwakely@redhat.com> + + * c-decl.c: Define INCLUDE_MEMORY instead of INCLUDE_UNIQUE_PTR. + * c-parser.c: Likewise. + +2021-12-09 Jakub Jelinek <jakub@redhat.com> + + PR pch/71934 + * c-decl.c (resort_field_decl_cmp): Pass the same pointer twice + to resort_data.new_value. + +2021-12-08 Chung-Lin Tang <cltang@codesourcery.com> + + * c-parser.c (struct omp_dim): New struct type for use inside + c_parser_omp_variable_list. + (c_parser_omp_variable_list): Allow multiple levels of array and + component accesses in array section base-pointer expression. + (c_parser_omp_clause_to): Set 'allow_deref' to true in call to + c_parser_omp_var_list_parens. + (c_parser_omp_clause_from): Likewise. + * c-typeck.c (handle_omp_array_sections_1): Extend allowed range + of base-pointer expressions involving INDIRECT/MEM/ARRAY_REF and + POINTER_PLUS_EXPR. + (c_finish_omp_clauses): Extend allowed ranged of expressions + involving INDIRECT/MEM/ARRAY_REF and POINTER_PLUS_EXPR. + +2021-12-08 Chung-Lin Tang <cltang@codesourcery.com> + + PR middle-end/92120 + * c-parser.c (c_parser_omp_clause_map): Set 'allow_deref' argument in + call to c_parser_omp_variable_list to 'true'. + * c-typeck.c (handle_omp_array_sections_1): Add strip of MEM_REF in + array base handling. + (c_finish_omp_clauses): Handle 'A->member' case in map clauses. + +2021-11-30 Thomas Schwinge <thomas@codesourcery.com> + + * c-typeck.c (c_finish_omp_clauses): Remove "gang reduction on an + orphan loop" checking. + +2021-11-30 Cesar Philippidis <cesar@codesourcery.com> + Thomas Schwinge <thomas@codesourcery.com> + + * c-typeck.c (c_finish_omp_clauses): Emit an error on orphan + OpenACC gang reductions. + +2021-11-30 Richard Biener <rguenther@suse.de> + + * gimple-parser.c (c_parser_gimple_postfix_expression): + avoid unreachable code after break. + +2021-11-29 Eric Gallager <egallager@gcc.gnu.org> + + PR other/103021 + * Make-lang.in: Use ETAGS variable in TAGS target. + +2021-11-29 Richard Biener <rguenther@suse.de> + + * c-typeck.c (c_tree_equal): Remove unreachable return. + * c-parser.c (get_matching_symbol): Likewise. + +2021-11-23 Jakub Jelinek <jakub@redhat.com> + + * c-typeck.c (c_clone_omp_udr): Don't initialize + id.transform_lang_insert_block. + +2021-11-19 Martin Sebor <msebor@redhat.com> + + PR c++/33925 + PR c/102867 + * c-typeck.c (maybe_warn_for_null_address): Suppress warnings for + code resulting from macro expansion. + +2021-11-19 Martin Liska <mliska@suse.cz> + + Revert: + 2021-11-19 Martin Liska <mliska@suse.cz> + + * c-parser.c (add_debug_begin_stmt): Use option directly. + +2021-11-18 Matthias Kretz <m.kretz@gsi.de> + + * c-decl.c (names_builtin_p): Handle RID_BUILTIN_ASSOC_BARRIER. + * c-parser.c (c_parser_postfix_expression): Likewise. + +2021-11-18 Martin Liska <mliska@suse.cz> + + * c-parser.c (add_debug_begin_stmt): Use option directly. + +2021-11-17 Martin Sebor <msebor@redhat.com> + + PR c/101702 + * c-decl.c (get_parm_array_spec): Strip casts earlier and fold array + bounds before deciding if they're constant. + +2021-11-15 Jakub Jelinek <jakub@redhat.com> + + * c-parser.c (OMP_TARGET_CLAUSE_MASK): Add + PRAGMA_OMP_CLAUSE_THREAD_LIMIT. + +2021-11-11 Jakub Jelinek <jakub@redhat.com> + + * c-parser.c (c_parser_omp_clause_num_teams): Parse optional + lower-bound and store it into OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR. + Use OMP_CLAUSE_NUM_TEAMS_UPPER_EXPR instead of + OMP_CLAUSE_NUM_TEAMS_EXPR. + (c_parser_omp_target): For OMP_CLAUSE_NUM_TEAMS evaluate before + combined target teams even lower-bound expression. + +2021-11-11 Richard Biener <rguenther@suse.de> + + * gimple-parser.c: Shuffle bitmap.h include. + +2021-11-03 Joseph Myers <joseph@codesourcery.com> + + PR c/103031 + * c-convert.c (c_convert): New function, based on convert. + (convert): Make into wrapper of c_convert. + (convert_init): New function. + * c-typeck.c (enum impl_conv): Add ic_init_const. + (convert_for_assignment): Handle ic_init_const like ic_init. Add + new argument to convert_and_check call. + (digest_init): Pass ic_init_const to convert_for_assignment for + initializers required to be constant. + +2021-11-02 Richard Sandiford <richard.sandiford@arm.com> + + * c-tree.h (c_simulate_record_decl): Declare. + * c-objc-common.h (LANG_HOOKS_SIMULATE_RECORD_DECL): Override. + * c-decl.c (c_simulate_record_decl): New function. + 2021-10-22 Eric Gallager <egallager@gcc.gnu.org> PR other/102663 @@ -8007,7 +8235,7 @@ * c-decl.c: Likewise. Include gt-c-c-decl.h, not gt-c-decl.h. * c-parser.c: Likewise. Include gt-c-c-parser.h, not gt-c-parser.h. -Copyright (C) 2012-2021 Free Software Foundation, Inc. +Copyright (C) 2012-2022 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in index 67a40fc..1367a10 100644 --- a/gcc/c/Make-lang.in +++ b/gcc/c/Make-lang.in @@ -1,5 +1,5 @@ # Top level -*- makefile -*- fragment for GNU C - C language. -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2022 Free Software Foundation, Inc. #This file is part of GCC. @@ -71,15 +71,15 @@ endif # compute checksum over all object files and the options # re-use the checksum from the prev-final stage so it passes # the bootstrap comparison and allows comparing of the cc1 binary -cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \ +cc1-checksum.cc : build/genchecksum$(build_exeext) checksum-options \ $(C_OBJS) $(BACKEND) $(LIBDEPS) if [ -f ../stage_final ] \ && cmp -s ../stage_current ../stage_final; then \ - cp ../prev-gcc/cc1-checksum.c cc1-checksum.c; \ + cp ../prev-gcc/cc1-checksum.cc cc1-checksum.cc; \ else \ build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \ - checksum-options > cc1-checksum.c.tmp && \ - $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c; \ + checksum-options > cc1-checksum.cc.tmp && \ + $(srcdir)/../move-if-change cc1-checksum.cc.tmp cc1-checksum.cc; \ fi cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS) @@ -106,11 +106,11 @@ c.all.cross: c.start.encap: c.rest.encap: c.srcinfo: -c.srcextra: gengtype-lex.c +c.srcextra: gengtype-lex.cc -cp -p $^ $(srcdir) c.tags: force - cd $(srcdir)/c; etags -o TAGS.sub *.c *.h; \ - etags --include TAGS.sub --include ../TAGS.sub + cd $(srcdir)/c; $(ETAGS) -o TAGS.sub *.c *.h; \ + $(ETAGS) --include TAGS.sub --include ../TAGS.sub c.man: c.srcman: diff --git a/gcc/c/c-aux-info.c b/gcc/c/c-aux-info.cc index 81860cb..bf01315 100644 --- a/gcc/c/c-aux-info.c +++ b/gcc/c/c-aux-info.cc @@ -1,7 +1,7 @@ /* Generate information regarding function declarations and definitions based on information stored in GCC's tree structure. This code implements the -aux-info option. - Copyright (C) 1989-2021 Free Software Foundation, Inc. + Copyright (C) 1989-2022 Free Software Foundation, Inc. Contributed by Ron Guilmette (rfg@segfault.us.com). This file is part of GCC. diff --git a/gcc/c/c-convert.c b/gcc/c/c-convert.cc index d0035a3..18083d5 100644 --- a/gcc/c/c-convert.c +++ b/gcc/c/c-convert.cc @@ -1,5 +1,5 @@ /* Language-level data type conversion for GNU C. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -45,12 +45,12 @@ along with GCC; see the file COPYING3. If not see Here is a list of all the functions that assume that widening and narrowing is always done with a NOP_EXPR: - In convert.c, convert_to_integer. - In c-typeck.c, build_binary_op (boolean ops), and + In convert.cc, convert_to_integer. + In c-typeck.cc, build_binary_op (boolean ops), and c_common_truthvalue_conversion. - In expr.c: expand_expr, for operands of a MULT_EXPR. - In fold-const.c: fold. - In tree.c: get_narrower and get_unwidened. */ + In expr.cc: expand_expr, for operands of a MULT_EXPR. + In fold-const.cc: fold. + In tree.cc: get_narrower and get_unwidened. */ /* Subroutines of `convert'. */ @@ -60,10 +60,13 @@ along with GCC; see the file COPYING3. If not see converted to type TYPE. The TREE_TYPE of the value is always TYPE. This function implements all reasonable conversions; callers should filter out those that are - not permitted by the language being compiled. */ + not permitted by the language being compiled. + INIT_CONST is true if the conversion is for arithmetic types for a static + initializer and folding must apply accordingly (discarding floating-point + exceptions and assuming the default rounding mode is in effect). */ -tree -convert (tree type, tree expr) +static tree +c_convert (tree type, tree expr, bool init_const) { tree e = expr; enum tree_code code = TREE_CODE (type); @@ -115,7 +118,7 @@ convert (tree type, tree expr) && COMPLETE_TYPE_P (type)) { expr = save_expr (expr); - expr = c_fully_fold (expr, false, NULL); + expr = c_fully_fold (expr, init_const, NULL); tree check = ubsan_instrument_float_cast (loc, type, expr); expr = fold_build1 (FIX_TRUNC_EXPR, type, expr); if (check == NULL_TREE) @@ -173,10 +176,32 @@ convert (tree type, tree expr) maybe_fold: if (TREE_CODE (ret) != C_MAYBE_CONST_EXPR) - ret = fold (ret); + ret = init_const ? fold_init (ret) : fold (ret); return ret; } error ("conversion to non-scalar type requested"); return error_mark_node; } + +/* Create an expression whose value is that of EXPR, converted to type TYPE. + The TREE_TYPE of the value is always TYPE. This function implements all + reasonable conversions; callers should filter out those that are not + permitted by the language being compiled. */ + +tree +convert (tree type, tree expr) +{ + return c_convert (type, expr, false); +} + +/* Create an expression whose value is that of EXPR, converted to type TYPE, in + a static initializer. The TREE_TYPE of the value is always TYPE. This + function implements all reasonable conversions; callers should filter out + those that are not permitted by the language being compiled. */ + +tree +convert_init (tree type, tree expr) +{ + return c_convert (type, expr, true); +} diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.cc index 771efa3..c701f07 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.cc @@ -1,5 +1,5 @@ /* Process declarations and variables for C compiler. - Copyright (C) 1988-2021 Free Software Foundation, Inc. + Copyright (C) 1988-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #define INCLUDE_STRING -#define INCLUDE_UNIQUE_PTR +#define INCLUDE_MEMORY #include "system.h" #include "coretypes.h" #include "target.h" @@ -225,7 +225,7 @@ struct GTY(()) lang_identifier { struct c_binding *label_binding; /* labels */ }; -/* Validate c-lang.c's assumptions. */ +/* Validate c-lang.cc's assumptions. */ extern char C_SIZEOF_STRUCT_LANG_IDENTIFIER_isnt_accurate [(sizeof(struct lang_identifier) == C_SIZEOF_STRUCT_LANG_IDENTIFIER) ? 1 : -1]; @@ -1367,7 +1367,7 @@ pop_scope (void) gcc_fallthrough (); /* Parameters go in DECL_ARGUMENTS, not BLOCK_VARS, and have already been put there by store_parm_decls. Unused- - parameter warnings are handled by function.c. + parameter warnings are handled by function.cc. error_mark_node obviously does not go in BLOCK_VARS and does not get unused-variable warnings. */ case PARM_DECL: @@ -4643,7 +4643,7 @@ c_warn_unused_attributes (tree attrs) constraint violation. */ pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored", get_attribute_name (t)); - else + else if (!attribute_ignored_p (t)) warning (OPT_Wattributes, "%qE attribute ignored", get_attribute_name (t)); } @@ -5527,7 +5527,7 @@ finish_decl (tree decl, location_t init_loc, tree init, if (TREE_PUBLIC (decl)) c_determine_visibility (decl); - /* This is a no-op in c-lang.c or something real in objc-act.c. */ + /* This is a no-op in c-lang.cc or something real in objc-act.cc. */ if (c_dialect_objc ()) objc_check_decl (decl); @@ -5866,6 +5866,12 @@ get_parm_array_spec (const struct c_parm *parm, tree attrs) if (pd->u.array.static_p) spec += 's'; + if (!INTEGRAL_TYPE_P (TREE_TYPE (nelts))) + /* Avoid invalid NELTS. */ + return attrs; + + STRIP_NOPS (nelts); + nelts = c_fully_fold (nelts, false, nullptr); if (TREE_CODE (nelts) == INTEGER_CST) { /* Skip all constant bounds except the most significant one. @@ -5883,13 +5889,9 @@ get_parm_array_spec (const struct c_parm *parm, tree attrs) spec += buf; break; } - else if (!INTEGRAL_TYPE_P (TREE_TYPE (nelts))) - /* Avoid invalid NELTS. */ - return attrs; /* Each variable VLA bound is represented by a dollar sign. */ spec += "$"; - STRIP_NOPS (nelts); vbchain = tree_cons (NULL_TREE, nelts, vbchain); } @@ -9038,8 +9040,8 @@ resort_field_decl_cmp (const void *x_p, const void *y_p) { tree d1 = DECL_NAME (*x); tree d2 = DECL_NAME (*y); - resort_data.new_value (&d1, resort_data.cookie); - resort_data.new_value (&d2, resort_data.cookie); + resort_data.new_value (&d1, &d1, resort_data.cookie); + resort_data.new_value (&d2, &d2, resort_data.cookie); if (d1 < d2) return -1; } @@ -9436,6 +9438,36 @@ c_simulate_enum_decl (location_t loc, const char *name, input_location = saved_loc; return enumtype; } + +/* Implement LANG_HOOKS_SIMULATE_RECORD_DECL. */ + +tree +c_simulate_record_decl (location_t loc, const char *name, + array_slice<const tree> fields) +{ + location_t saved_loc = input_location; + input_location = loc; + + class c_struct_parse_info *struct_info; + tree ident = get_identifier (name); + tree type = start_struct (loc, RECORD_TYPE, ident, &struct_info); + + for (unsigned int i = 0; i < fields.size (); ++i) + { + DECL_FIELD_CONTEXT (fields[i]) = type; + if (i > 0) + DECL_CHAIN (fields[i - 1]) = fields[i]; + } + + finish_struct (loc, type, fields[0], NULL_TREE, struct_info); + + tree decl = build_decl (loc, TYPE_DECL, ident, type); + set_underlying_type (decl); + lang_hooks.decls.pushdecl (decl); + + input_location = saved_loc; + return type; +} /* Create the FUNCTION_DECL for a function definition. DECLSPECS, DECLARATOR and ATTRIBUTES are the parts of @@ -10589,6 +10621,7 @@ names_builtin_p (const char *name) case RID_BUILTIN_HAS_ATTRIBUTE: case RID_BUILTIN_SHUFFLE: case RID_BUILTIN_SHUFFLEVECTOR: + case RID_BUILTIN_ASSOC_BARRIER: case RID_CHOOSE_EXPR: case RID_OFFSETOF: case RID_TYPES_COMPATIBLE_P: diff --git a/gcc/c/c-errors.c b/gcc/c/c-errors.cc index de98958..ced12ed 100644 --- a/gcc/c/c-errors.c +++ b/gcc/c/c-errors.cc @@ -1,5 +1,5 @@ /* Various diagnostic subroutines for the GNU C language. - Copyright (C) 2000-2021 Free Software Foundation, Inc. + Copyright (C) 2000-2022 Free Software Foundation, Inc. Contributed by Gabriel Dos Reis <gdr@codesourcery.com> This file is part of GCC. diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.cc index 0ebcb46..76ea25b 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.cc @@ -1,5 +1,5 @@ /* Support for fully folding sub-trees of an expression for C compiler. - Copyright (C) 1992-2021 Free Software Foundation, Inc. + Copyright (C) 1992-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -465,6 +465,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, case BIT_NOT_EXPR: case TRUTH_NOT_EXPR: case CONJ_EXPR: + case PAREN_EXPR: unary: /* Unary operations. */ orig_op0 = op0 = TREE_OPERAND (expr, 0); diff --git a/gcc/c/c-lang.c b/gcc/c/c-lang.cc index 778a6f2..eecc0a0 100644 --- a/gcc/c/c-lang.c +++ b/gcc/c/c-lang.cc @@ -1,5 +1,5 @@ /* Language-specific hook definitions for C front end. - Copyright (C) 1991-2021 Free Software Foundation, Inc. + Copyright (C) 1991-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-lang.h b/gcc/c/c-lang.h index 2f62ee1..7bdab47 100644 --- a/gcc/c/c-lang.h +++ b/gcc/c/c-lang.h @@ -1,5 +1,5 @@ /* Definitions for C language specific types. - Copyright (C) 2009-2021 Free Software Foundation, Inc. + Copyright (C) 2009-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.cc index cdb2242..97850ad 100644 --- a/gcc/c/c-objc-common.c +++ b/gcc/c/c-objc-common.cc @@ -1,5 +1,5 @@ /* Some code common to C and ObjC front ends. - Copyright (C) 2001-2021 Free Software Foundation, Inc. + Copyright (C) 2001-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h index 7d35a06..0b60df9 100644 --- a/gcc/c/c-objc-common.h +++ b/gcc/c/c-objc-common.h @@ -1,5 +1,5 @@ /* Language hooks common to C and ObjC front ends. - Copyright (C) 2004-2021 Free Software Foundation, Inc. + Copyright (C) 2004-2022 Free Software Foundation, Inc. Contributed by Ziemowit Laski <zlaski@apple.com> This file is part of GCC. @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see #define GCC_C_OBJC_COMMON /* Lang hooks that are shared between C and ObjC are defined here. Hooks - specific to C or ObjC go in c-lang.c and objc/objc-lang.c, respectively. */ + specific to C or ObjC go in c-lang.cc and objc/objc-lang.cc, respectively. */ #undef LANG_HOOKS_IDENTIFIER_SIZE #define LANG_HOOKS_IDENTIFIER_SIZE C_SIZEOF_STRUCT_LANG_IDENTIFIER @@ -81,6 +81,8 @@ along with GCC; see the file COPYING3. If not see #undef LANG_HOOKS_SIMULATE_ENUM_DECL #define LANG_HOOKS_SIMULATE_ENUM_DECL c_simulate_enum_decl +#undef LANG_HOOKS_SIMULATE_RECORD_DECL +#define LANG_HOOKS_SIMULATE_RECORD_DECL c_simulate_record_decl #undef LANG_HOOKS_TYPE_FOR_MODE #define LANG_HOOKS_TYPE_FOR_MODE c_common_type_for_mode #undef LANG_HOOKS_TYPE_FOR_SIZE diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.cc index 80dd61d..3b1d2d4 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.cc @@ -1,5 +1,5 @@ /* Parser for C and Objective-C. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. Parser actions based on the old Bison parser; structure somewhat influenced by and fragments based on the C++ parser. @@ -36,7 +36,7 @@ along with GCC; see the file COPYING3. If not see location rather than implicitly using input_location. */ #include "config.h" -#define INCLUDE_UNIQUE_PTR +#define INCLUDE_MEMORY #include "system.h" #include "coretypes.h" #include "target.h" @@ -1132,7 +1132,6 @@ get_matching_symbol (enum cpp_ttype type) { default: gcc_unreachable (); - return ""; case CPP_CLOSE_PAREN: return "("; case CPP_CLOSE_BRACE: @@ -1414,7 +1413,7 @@ c_parser_skip_to_end_of_block_or_statement (c_parser *parser) parser->error = false; } -/* CPP's options (initialized by c-opts.c). */ +/* CPP's options (initialized by c-opts.cc). */ extern cpp_options *cpp_opts; /* Save the warning flags which are controlled by __extension__. */ @@ -4847,6 +4846,11 @@ c_parser_balanced_token_sequence (c_parser *parser) case CPP_EOF: return; + case CPP_PRAGMA: + c_parser_consume_pragma (parser); + c_parser_skip_to_pragma_eol (parser, false); + break; + default: c_parser_consume_token (parser); break; @@ -4939,7 +4943,9 @@ c_parser_std_attribute (c_parser *parser, bool for_tm) parens.skip_until_found_close (parser); return error_mark_node; } - if (as) + /* If this is a fake attribute created to handle -Wno-attributes, + we must skip parsing the arguments. */ + if (as && !attribute_ignored_p (as)) { bool takes_identifier = (ns != NULL_TREE @@ -8962,6 +8968,7 @@ c_parser_predefined_identifier (c_parser *parser) assignment-expression , assignment-expression, ) __builtin_convertvector ( assignment-expression , type-name ) + __builtin_assoc_barrier ( assignment-expression ) offsetof-member-designator: identifier @@ -10107,6 +10114,24 @@ c_parser_postfix_expression (c_parser *parser) } } break; + case RID_BUILTIN_ASSOC_BARRIER: + { + location_t start_loc = loc; + c_parser_consume_token (parser); + matching_parens parens; + if (!parens.require_open (parser)) + { + expr.set_error (); + break; + } + e1 = c_parser_expr_no_commas (parser, NULL); + mark_exp_read (e1.value); + location_t end_loc = c_parser_peek_token (parser)->get_finish (); + parens.skip_until_found_close (parser); + expr = parser_build_unary_op (loc, PAREN_EXPR, e1); + set_c_expr_source_range (&expr, start_loc, end_loc); + } + break; case RID_AT_SELECTOR: { gcc_assert (c_dialect_objc ()); @@ -12746,7 +12771,9 @@ c_parser_omp_clause_name (c_parser *parser) result = PRAGMA_OMP_CLAUSE_GRAINSIZE; break; case 'h': - if (!strcmp ("hint", p)) + if (!strcmp ("has_device_addr", p)) + result = PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR; + else if (!strcmp ("hint", p)) result = PRAGMA_OMP_CLAUSE_HINT; else if (!strcmp ("host", p)) result = PRAGMA_OACC_CLAUSE_HOST; @@ -12970,19 +12997,29 @@ c_parser_oacc_wait_list (c_parser *parser, location_t clause_loc, tree list) The optional ALLOW_DEREF argument is true if list items can use the deref (->) operator. */ +struct omp_dim +{ + tree low_bound, length; + location_t loc; + bool no_colon; + omp_dim (tree lb, tree len, location_t lo, bool nc) + : low_bound (lb), length (len), loc (lo), no_colon (nc) {} +}; + static tree c_parser_omp_variable_list (c_parser *parser, location_t clause_loc, enum omp_clause_code kind, tree list, bool allow_deref = false) { + auto_vec<omp_dim> dims; + bool array_section_p; auto_vec<c_token> tokens; unsigned int tokens_avail = 0; bool first = true; while (1) { - bool array_section_p = false; if (kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY) { if (c_parser_next_token_is_not (parser, CPP_NAME) @@ -13101,6 +13138,7 @@ c_parser_omp_variable_list (c_parser *parser, case OMP_CLAUSE_MAP: case OMP_CLAUSE_FROM: case OMP_CLAUSE_TO: + start_component_ref: while (c_parser_next_token_is (parser, CPP_DOT) || (allow_deref && c_parser_next_token_is (parser, CPP_DEREF))) @@ -13128,9 +13166,14 @@ c_parser_omp_variable_list (c_parser *parser, case OMP_CLAUSE_REDUCTION: case OMP_CLAUSE_IN_REDUCTION: case OMP_CLAUSE_TASK_REDUCTION: + case OMP_CLAUSE_HAS_DEVICE_ADDR: + array_section_p = false; + dims.truncate (0); while (c_parser_next_token_is (parser, CPP_OPEN_SQUARE)) { + location_t loc = UNKNOWN_LOCATION; tree low_bound = NULL_TREE, length = NULL_TREE; + bool no_colon = false; c_parser_consume_token (parser); if (!c_parser_next_token_is (parser, CPP_COLON)) @@ -13141,9 +13184,13 @@ c_parser_omp_variable_list (c_parser *parser, expr = convert_lvalue_to_rvalue (expr_loc, expr, false, true); low_bound = expr.value; + loc = expr_loc; } if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE)) - length = integer_one_node; + { + length = integer_one_node; + no_colon = true; + } else { /* Look for `:'. */ @@ -13172,8 +13219,33 @@ c_parser_omp_variable_list (c_parser *parser, break; } - t = tree_cons (low_bound, length, t); + dims.safe_push (omp_dim (low_bound, length, loc, no_colon)); } + + if (t != error_mark_node) + { + if ((kind == OMP_CLAUSE_MAP + || kind == OMP_CLAUSE_FROM + || kind == OMP_CLAUSE_TO) + && !array_section_p + && (c_parser_next_token_is (parser, CPP_DOT) + || (allow_deref + && c_parser_next_token_is (parser, + CPP_DEREF)))) + { + for (unsigned i = 0; i < dims.length (); i++) + { + gcc_assert (dims[i].length == integer_one_node); + t = build_array_ref (dims[i].loc, + t, dims[i].low_bound); + } + goto start_component_ref; + } + else + for (unsigned i = 0; i < dims.length (); i++) + t = tree_cons (dims[i].low_bound, dims[i].length, t); + } + if ((kind == OMP_CLAUSE_DEPEND || kind == OMP_CLAUSE_AFFINITY) && t != error_mark_node && parser->tokens_avail != 2) @@ -14255,6 +14327,16 @@ c_parser_omp_clause_use_device_addr (c_parser *parser, tree list) list); } +/* OpenMP 5.1: + has_device_addr ( variable-list ) */ + +static tree +c_parser_omp_clause_has_device_addr (c_parser *parser, tree list) +{ + return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_HAS_DEVICE_ADDR, + list); +} + /* OpenMP 4.5: is_device_ptr ( variable-list ) */ @@ -15175,7 +15257,10 @@ c_parser_omp_clause_orderedkind (c_parser *parser ATTRIBUTE_UNUSED, } /* OpenMP 4.0: - num_teams ( expression ) */ + num_teams ( expression ) + + OpenMP 5.1: + num_teams ( expression : expression ) */ static tree c_parser_omp_clause_num_teams (c_parser *parser, tree list) @@ -15184,34 +15269,68 @@ c_parser_omp_clause_num_teams (c_parser *parser, tree list) matching_parens parens; if (parens.require_open (parser)) { - location_t expr_loc = c_parser_peek_token (parser)->location; + location_t upper_loc = c_parser_peek_token (parser)->location; + location_t lower_loc = UNKNOWN_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); + expr = convert_lvalue_to_rvalue (upper_loc, expr, false, true); + tree c, upper = expr.value, lower = NULL_TREE; + upper = c_fully_fold (upper, false, NULL); + + if (c_parser_next_token_is (parser, CPP_COLON)) + { + c_parser_consume_token (parser); + lower_loc = upper_loc; + lower = upper; + upper_loc = c_parser_peek_token (parser)->location; + expr = c_parser_expr_no_commas (parser, NULL); + expr = convert_lvalue_to_rvalue (upper_loc, expr, false, true); + upper = expr.value; + upper = c_fully_fold (upper, false, NULL); + } parens.skip_until_found_close (parser); - if (!INTEGRAL_TYPE_P (TREE_TYPE (t))) + if (!INTEGRAL_TYPE_P (TREE_TYPE (upper)) + || (lower && !INTEGRAL_TYPE_P (TREE_TYPE (lower)))) { c_parser_error (parser, "expected integer expression"); return list; } /* Attempt to statically determine when the number isn't positive. */ - c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t, - build_int_cst (TREE_TYPE (t), 0)); - protected_set_expr_location (c, expr_loc); + c = fold_build2_loc (upper_loc, LE_EXPR, boolean_type_node, upper, + build_int_cst (TREE_TYPE (upper), 0)); + protected_set_expr_location (c, upper_loc); if (c == boolean_true_node) { - warning_at (expr_loc, 0, "%<num_teams%> value must be positive"); - t = integer_one_node; + warning_at (upper_loc, 0, "%<num_teams%> value must be positive"); + upper = integer_one_node; + } + if (lower) + { + c = fold_build2_loc (lower_loc, LE_EXPR, boolean_type_node, lower, + build_int_cst (TREE_TYPE (lower), 0)); + protected_set_expr_location (c, lower_loc); + if (c == boolean_true_node) + { + warning_at (lower_loc, 0, "%<num_teams%> value must be positive"); + lower = NULL_TREE; + } + else if (TREE_CODE (lower) == INTEGER_CST + && TREE_CODE (upper) == INTEGER_CST + && tree_int_cst_lt (upper, lower)) + { + warning_at (lower_loc, 0, "%<num_teams%> lower bound %qE bigger " + "than upper bound %qE", lower, upper); + lower = NULL_TREE; + } } check_no_duplicate_clause (list, OMP_CLAUSE_NUM_TEAMS, "num_teams"); c = build_omp_clause (num_teams_loc, OMP_CLAUSE_NUM_TEAMS); - OMP_CLAUSE_NUM_TEAMS_EXPR (c) = t; + OMP_CLAUSE_NUM_TEAMS_UPPER_EXPR (c) = upper; + OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (c) = lower; OMP_CLAUSE_CHAIN (c) = list; list = c; } @@ -16138,7 +16257,8 @@ c_parser_omp_clause_map (c_parser *parser, tree list) c_parser_consume_token (parser); } - nl = c_parser_omp_variable_list (parser, clause_loc, OMP_CLAUSE_MAP, list); + nl = c_parser_omp_variable_list (parser, clause_loc, OMP_CLAUSE_MAP, list, + true); for (c = nl; c != list; c = OMP_CLAUSE_CHAIN (c)) OMP_CLAUSE_SET_MAP_KIND (c, kind); @@ -16382,7 +16502,7 @@ c_parser_omp_clause_device_type (c_parser *parser, tree list) static tree c_parser_omp_clause_to (c_parser *parser, tree list) { - return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO, list); + return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_TO, list, true); } /* OpenMP 4.0: @@ -16391,7 +16511,7 @@ c_parser_omp_clause_to (c_parser *parser, tree list) static tree c_parser_omp_clause_from (c_parser *parser, tree list) { - return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_FROM, list); + return c_parser_omp_var_list_parens (parser, OMP_CLAUSE_FROM, list, true); } /* OpenMP 4.0: @@ -16945,6 +17065,10 @@ c_parser_omp_all_clauses (c_parser *parser, omp_clause_mask mask, clauses = c_parser_omp_clause_use_device_addr (parser, clauses); c_name = "use_device_addr"; break; + case PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR: + clauses = c_parser_omp_clause_has_device_addr (parser, clauses); + c_name = "has_device_addr"; + break; case PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR: clauses = c_parser_omp_clause_is_device_ptr (parser, clauses); c_name = "is_device_ptr"; @@ -20926,7 +21050,9 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser, | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEFAULTMAP) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IN_REDUCTION) \ - | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)) + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_THREAD_LIMIT) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR)\ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR)) static bool c_parser_omp_target (c_parser *parser, enum pragma_context context, bool *if_p) @@ -21016,31 +21142,31 @@ c_parser_omp_target (c_parser *parser, enum pragma_context context, bool *if_p) if (ret == NULL_TREE) return false; if (ccode == OMP_TEAMS) - { - /* For combined target teams, ensure the num_teams and - thread_limit clause expressions are evaluated on the host, - before entering the target construct. */ - tree c; - for (c = cclauses[C_OMP_CLAUSE_SPLIT_TEAMS]; - c; c = OMP_CLAUSE_CHAIN (c)) - if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TEAMS - || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_THREAD_LIMIT) - && TREE_CODE (OMP_CLAUSE_OPERAND (c, 0)) != INTEGER_CST) - { - tree expr = OMP_CLAUSE_OPERAND (c, 0); - tree tmp = create_tmp_var_raw (TREE_TYPE (expr)); - expr = build4 (TARGET_EXPR, TREE_TYPE (expr), tmp, - expr, NULL_TREE, NULL_TREE); - add_stmt (expr); - OMP_CLAUSE_OPERAND (c, 0) = expr; - tree tc = build_omp_clause (OMP_CLAUSE_LOCATION (c), - OMP_CLAUSE_FIRSTPRIVATE); - OMP_CLAUSE_DECL (tc) = tmp; - OMP_CLAUSE_CHAIN (tc) - = cclauses[C_OMP_CLAUSE_SPLIT_TARGET]; - cclauses[C_OMP_CLAUSE_SPLIT_TARGET] = tc; - } - } + /* For combined target teams, ensure the num_teams and + thread_limit clause expressions are evaluated on the host, + before entering the target construct. */ + for (tree c = cclauses[C_OMP_CLAUSE_SPLIT_TEAMS]; + c; c = OMP_CLAUSE_CHAIN (c)) + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TEAMS + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_THREAD_LIMIT) + for (int i = 0; + i <= (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TEAMS); ++i) + if (OMP_CLAUSE_OPERAND (c, i) + && TREE_CODE (OMP_CLAUSE_OPERAND (c, i)) != INTEGER_CST) + { + tree expr = OMP_CLAUSE_OPERAND (c, i); + tree tmp = create_tmp_var_raw (TREE_TYPE (expr)); + expr = build4 (TARGET_EXPR, TREE_TYPE (expr), tmp, + expr, NULL_TREE, NULL_TREE); + add_stmt (expr); + OMP_CLAUSE_OPERAND (c, i) = expr; + tree tc = build_omp_clause (OMP_CLAUSE_LOCATION (c), + OMP_CLAUSE_FIRSTPRIVATE); + OMP_CLAUSE_DECL (tc) = tmp; + OMP_CLAUSE_CHAIN (tc) + = cclauses[C_OMP_CLAUSE_SPLIT_TARGET]; + cclauses[C_OMP_CLAUSE_SPLIT_TARGET] = tc; + } tree stmt = make_node (OMP_TARGET); TREE_TYPE (stmt) = void_type_node; OMP_TARGET_CLAUSES (stmt) = cclauses[C_OMP_CLAUSE_SPLIT_TARGET]; @@ -22474,7 +22600,7 @@ c_parser_omp_requires (c_parser *parser) c_parser_skip_to_pragma_eol (parser, false); return; } - if (p) + if (p && this_req != OMP_REQUIRES_DYNAMIC_ALLOCATORS) sorry_at (cloc, "%qs clause on %<requires%> directive not " "supported yet", p); if (p) diff --git a/gcc/c/c-parser.h b/gcc/c/c-parser.h index 773aa43..3d256b6 100644 --- a/gcc/c/c-parser.h +++ b/gcc/c/c-parser.h @@ -1,5 +1,5 @@ /* Declarations for the parser for C and Objective-C. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. Parser actions based on the old Bison parser; structure somewhat influenced by and fragments based on the C++ parser. @@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see #ifndef GCC_C_PARSER_H #define GCC_C_PARSER_H -/* The C lexer intermediates between the lexer in cpplib and c-lex.c +/* The C lexer intermediates between the lexer in cpplib and c-lex.cc and the C parser. Unlike the C++ lexer, the parser structure stores the lexer information instead of using a separate structure. Identifiers are separated into ordinary identifiers, type names, diff --git a/gcc/c/c-tree.h b/gcc/c/c-tree.h index a046c6b..c70f0ba 100644 --- a/gcc/c/c-tree.h +++ b/gcc/c/c-tree.h @@ -1,5 +1,5 @@ /* Definitions for C parsing and type checking. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-common.h" #include "diagnostic.h" -/* struct lang_identifier is private to c-decl.c, but langhooks.c needs to - know how big it is. This is sanity-checked in c-decl.c. */ +/* struct lang_identifier is private to c-decl.cc, but langhooks.cc needs to + know how big it is. This is sanity-checked in c-decl.cc. */ #define C_SIZEOF_STRUCT_LANG_IDENTIFIER \ (sizeof (struct c_common_identifier) + 3 * sizeof (void *)) @@ -538,14 +538,14 @@ enum c_inline_static_type { }; -/* in c-parser.c */ +/* in c-parser.cc */ extern void c_parse_init (void); extern bool c_keyword_starts_typename (enum rid keyword); -/* in c-aux-info.c */ +/* in c-aux-info.cc */ extern void gen_aux_info_record (tree, int, int, int); -/* in c-decl.c */ +/* in c-decl.cc */ struct c_spot_bindings; class c_struct_parse_info; extern struct obstack parser_obstack; @@ -598,6 +598,8 @@ extern tree finish_struct (location_t, tree, tree, tree, class c_struct_parse_info *); extern tree c_simulate_enum_decl (location_t, const char *, vec<string_int_pair> *); +extern tree c_simulate_record_decl (location_t, const char *, + array_slice<const tree>); extern struct c_arg_info *build_arg_info (void); extern struct c_arg_info *get_parm_info (bool, tree); extern tree grokfield (location_t, struct c_declarator *, @@ -658,7 +660,7 @@ extern struct c_declspecs *declspecs_add_alignas (location_t, struct c_declspecs *, tree); extern struct c_declspecs *finish_declspecs (struct c_declspecs *); -/* in c-objc-common.c */ +/* in c-objc-common.cc */ extern bool c_objc_common_init (void); extern bool c_missing_noreturn_ok_p (tree); extern bool c_warn_unused_global_decl (const_tree); @@ -666,7 +668,7 @@ extern void c_initialize_diagnostics (diagnostic_context *); extern bool c_vla_unspec_p (tree x, tree fn); extern alias_set_type c_get_alias_set (tree); -/* in c-typeck.c */ +/* in c-typeck.cc */ extern int in_alignof; extern int in_sizeof; extern int in_typeof; @@ -781,7 +783,7 @@ extern int current_function_returns_null; extern int current_function_returns_abnormally; -/* In c-decl.c */ +/* In c-decl.cc */ /* Tell the binding oracle what kind of binding we are looking for. */ @@ -796,7 +798,7 @@ enum c_oracle_request create bindings when needed by the C compiler. The oracle is told the name and type of the binding to create. It can call pushdecl or the like to ensure the binding is visible; or do nothing, - leaving the binding untouched. c-decl.c takes note of when the + leaving the binding untouched. c-decl.cc takes note of when the oracle has been called and will not call it again if it fails to create a given binding. */ @@ -814,7 +816,7 @@ extern void c_pushtag (location_t, tree, tree); extern void c_bind (location_t, tree, bool); extern bool tag_exists_p (enum tree_code, tree); -/* In c-errors.c */ +/* In c-errors.cc */ extern bool pedwarn_c90 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); extern bool pedwarn_c99 (location_t, int opt, const char *, ...) @@ -830,7 +832,7 @@ extern void set_c_expr_source_range (c_expr *expr, source_range src_range); -/* In c-fold.c */ +/* In c-fold.cc */ extern vec<tree> incomplete_record_decls; #if CHECKING_P diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.cc index 0aac978..3075c88 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.cc @@ -1,5 +1,5 @@ /* Build expressions with type checking for C compiler. - Copyright (C) 1987-2021 Free Software Foundation, Inc. + Copyright (C) 1987-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -53,12 +53,13 @@ along with GCC; see the file COPYING3. If not see #include "attribs.h" #include "asan.h" -/* Possible cases of implicit bad conversions. Used to select - diagnostic messages in convert_for_assignment. */ +/* Possible cases of implicit conversions. Used to select diagnostic messages + and control folding initializers in convert_for_assignment. */ enum impl_conv { ic_argpass, ic_assign, ic_init, + ic_init_const, ic_return }; @@ -1008,7 +1009,7 @@ c_common_type (tree t1, tree t2) return t2; } -/* Wrapper around c_common_type that is used by c-common.c and other +/* Wrapper around c_common_type that is used by c-common.cc and other front end optimizations that remove promotions. ENUMERAL_TYPEs are allowed here and are converted to their compatible integer types. BOOLEAN_TYPEs are allowed here and return either boolean_type_node or @@ -4920,6 +4921,10 @@ build_unary_op (location_t location, enum tree_code code, tree xarg, ret = val; goto return_build_unary_op; + case PAREN_EXPR: + ret = build1 (code, TREE_TYPE (arg), arg); + goto return_build_unary_op; + default: gcc_unreachable (); } @@ -6802,6 +6807,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, pedwarn (LOCATION, OPT, AS); \ break; \ case ic_init: \ + case ic_init_const: \ pedwarn_init (LOCATION, OPT, IN); \ break; \ case ic_return: \ @@ -6838,6 +6844,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, warning_at (LOCATION, OPT, AS, QUALS); \ break; \ case ic_init: \ + case ic_init_const: \ if (PEDWARN) \ pedwarn (LOCATION, OPT, IN, QUALS); \ else \ @@ -6886,6 +6893,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, break; case ic_init: + case ic_init_const: parmno = -2; break; @@ -6919,6 +6927,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, "%qT in assignment is invalid in C++", rhstype, type); break; case ic_init: + case ic_init_const: pedwarn_init (location, OPT_Wc___compat, "enum conversion from " "%qT to %qT in initialization is invalid in C++", rhstype, type); @@ -7029,7 +7038,8 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, && sanitize_flags_p (SANITIZE_FLOAT_CAST))) in_late_binary_op = true; tree ret = convert_and_check (expr_loc != UNKNOWN_LOCATION - ? expr_loc : location, type, orig_rhs); + ? expr_loc : location, type, orig_rhs, + errtype == ic_init_const); in_late_binary_op = save; return ret; } @@ -7252,6 +7262,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, break; } case ic_init: + case ic_init_const: { const char msg[] = G_("initialization from pointer to " "non-enclosed address space"); @@ -7296,6 +7307,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, "a candidate for a format attribute"); break; case ic_init: + case ic_init_const: warning_at (location, OPT_Wsuggest_attribute_format, "initialization left-hand side might be " "a candidate for a format attribute"); @@ -7339,6 +7351,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, "incompatible scalar storage order", type, rhstype); break; case ic_init: + case ic_init_const: /* Likewise. */ if (TREE_CODE (rhs) != CALL_EXPR || (t = get_callee_fndecl (rhs)) == NULL_TREE @@ -7465,6 +7478,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, "differ in signedness", rhstype, type); break; case ic_init: + case ic_init_const: pedwarn_init (location, OPT_Wpointer_sign, "pointer targets in initialization of %qT " "from %qT differ in signedness", type, @@ -7530,6 +7544,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, type, rhstype); break; case ic_init: + case ic_init_const: if (bltin) pedwarn_init (location, OPT_Wincompatible_pointer_types, "initialization of %qT from pointer to " @@ -7599,6 +7614,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, "without a cast", type, rhstype); break; case ic_init: + case ic_init_const: pedwarn_init (location, OPT_Wint_conversion, "initialization of %qT from %qT makes pointer from " "integer without a cast", type, rhstype); @@ -7635,6 +7651,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, "without a cast", type, rhstype); break; case ic_init: + case ic_init_const: pedwarn_init (location, OPT_Wint_conversion, "initialization of %qT from %qT makes integer from " "pointer without a cast", type, rhstype); @@ -7686,6 +7703,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, break; } case ic_init: + case ic_init_const: { const char msg[] = G_("incompatible types when initializing type %qT using type %qT"); @@ -8195,7 +8213,9 @@ digest_init (location_t init_loc, tree type, tree init, tree origtype, if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE) inside_init = convert_for_assignment (init_loc, UNKNOWN_LOCATION, type, inside_init, origtype, - ic_init, null_pointer_constant, + (require_constant + ? ic_init_const + : ic_init), null_pointer_constant, NULL_TREE, NULL_TREE, 0); return inside_init; } @@ -8215,7 +8235,8 @@ digest_init (location_t init_loc, tree type, tree init, tree origtype, inside_init); inside_init = convert_for_assignment (init_loc, UNKNOWN_LOCATION, type, - inside_init, origtype, ic_init, + inside_init, origtype, + require_constant ? ic_init_const : ic_init, null_pointer_constant, NULL_TREE, NULL_TREE, 0); @@ -11240,7 +11261,8 @@ c_finish_bc_stmt (location_t loc, tree label, bool is_break) if (skip) return NULL_TREE; - else if (in_statement & IN_OBJC_FOREACH) + else if ((in_statement & IN_OBJC_FOREACH) + && !(is_break && (in_statement & IN_SWITCH_STMT))) { /* The foreach expander produces low-level code using gotos instead of a structured loop construct. */ @@ -11571,7 +11593,10 @@ build_vec_cmp (tree_code code, tree type, static void maybe_warn_for_null_address (location_t loc, tree op, tree_code code) { - if (!warn_address || warning_suppressed_p (op, OPT_Waddress)) + /* Prevent warnings issued for macro expansion. */ + if (!warn_address + || warning_suppressed_p (op, OPT_Waddress) + || from_macro_expansion_at (loc)) return; if (TREE_CODE (op) == NOP_EXPR) @@ -13200,6 +13225,18 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types, t, omp_clause_code_name[OMP_CLAUSE_CODE (c)]); return error_mark_node; } + while (TREE_CODE (t) == INDIRECT_REF) + { + t = TREE_OPERAND (t, 0); + STRIP_NOPS (t); + if (TREE_CODE (t) == POINTER_PLUS_EXPR) + t = TREE_OPERAND (t, 0); + } + while (TREE_CODE (t) == COMPOUND_EXPR) + { + t = TREE_OPERAND (t, 1); + STRIP_NOPS (t); + } if (TREE_CODE (t) == COMPONENT_REF && (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_TO @@ -13221,6 +13258,15 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types, return error_mark_node; } t = TREE_OPERAND (t, 0); + while (TREE_CODE (t) == MEM_REF + || TREE_CODE (t) == INDIRECT_REF + || TREE_CODE (t) == ARRAY_REF) + { + t = TREE_OPERAND (t, 0); + STRIP_NOPS (t); + if (TREE_CODE (t) == POINTER_PLUS_EXPR) + t = TREE_OPERAND (t, 0); + } if (ort == C_ORT_ACC && TREE_CODE (t) == MEM_REF) { if (maybe_ne (mem_ref_offset (t), 0)) @@ -13508,15 +13554,25 @@ handle_omp_array_sections_1 (tree c, tree t, vec<tree> &types, return error_mark_node; } /* If there is a pointer type anywhere but in the very first - array-section-subscript, the array section can't be contiguous. */ + array-section-subscript, the array section could be non-contiguous. */ if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_DEPEND && OMP_CLAUSE_CODE (c) != OMP_CLAUSE_AFFINITY && TREE_CODE (TREE_CHAIN (t)) == TREE_LIST) { - error_at (OMP_CLAUSE_LOCATION (c), - "array section is not contiguous in %qs clause", - omp_clause_code_name[OMP_CLAUSE_CODE (c)]); - return error_mark_node; + /* If any prior dimension has a non-one length, then deem this + array section as non-contiguous. */ + for (tree d = TREE_CHAIN (t); TREE_CODE (d) == TREE_LIST; + d = TREE_CHAIN (d)) + { + tree d_length = TREE_VALUE (d); + if (d_length == NULL_TREE || !integer_onep (d_length)) + { + error_at (OMP_CLAUSE_LOCATION (c), + "array section is not contiguous in %qs clause", + omp_clause_code_name[OMP_CLAUSE_CODE (c)]); + return error_mark_node; + } + } } } else @@ -13748,6 +13804,8 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) } first = c_fully_fold (first, false, NULL); OMP_CLAUSE_DECL (c) = first; + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR) + return false; if (size) size = c_fully_fold (size, false, NULL); OMP_CLAUSE_SIZE (c) = size; @@ -13828,7 +13886,6 @@ c_clone_omp_udr (tree stmt, tree omp_decl1, tree omp_decl2, id.transform_call_graph_edges = CB_CGE_DUPLICATE; id.transform_new_cfg = true; id.transform_return_to_modify = false; - id.transform_lang_insert_block = NULL; id.eh_lp_nr = 0; walk_tree (&stmt, copy_tree_body_r, &id, NULL); return stmt; @@ -14054,7 +14111,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) { bitmap_head generic_head, firstprivate_head, lastprivate_head; bitmap_head aligned_head, map_head, map_field_head, map_firstprivate_head; - bitmap_head oacc_reduction_head; + bitmap_head oacc_reduction_head, is_on_device_head; tree c, t, type, *pc; tree simdlen = NULL_TREE, safelen = NULL_TREE; bool branch_seen = false; @@ -14066,6 +14123,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) tree ordered_clause = NULL_TREE; tree schedule_clause = NULL_TREE; bool oacc_async = false; + bool indir_component_ref_p = false; tree last_iterators = NULL_TREE; bool last_iterators_remove = false; tree *nogroup_seen = NULL; @@ -14089,6 +14147,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) /* If ort == C_ORT_OMP used as nontemporal_head or use_device_xxx_head instead and for ort == C_ORT_OMP_TARGET used as in_reduction_head. */ bitmap_initialize (&oacc_reduction_head, &bitmap_default_obstack); + bitmap_initialize (&is_on_device_head, &bitmap_default_obstack); if (ort & C_ORT_ACC) for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) @@ -14517,7 +14576,9 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "%qE appears more than once in data clauses", t); remove = true; } - else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE + else if ((OMP_CLAUSE_CODE (c) == OMP_CLAUSE_PRIVATE + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR) && bitmap_bit_p (&map_head, DECL_UID (t))) { if (ort == C_ORT_ACC) @@ -14865,8 +14926,21 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) if (TREE_CODE (t) == COMPONENT_REF && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) { - while (TREE_CODE (t) == COMPONENT_REF) - t = TREE_OPERAND (t, 0); + do + { + t = TREE_OPERAND (t, 0); + if (TREE_CODE (t) == MEM_REF + || TREE_CODE (t) == INDIRECT_REF) + { + t = TREE_OPERAND (t, 0); + STRIP_NOPS (t); + if (TREE_CODE (t) == POINTER_PLUS_EXPR) + t = TREE_OPERAND (t, 0); + } + } + while (TREE_CODE (t) == COMPONENT_REF + || TREE_CODE (t) == ARRAY_REF); + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP && OMP_CLAUSE_MAP_IMPLICIT (c) && (bitmap_bit_p (&map_head, DECL_UID (t)) @@ -14931,8 +15005,34 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)) /* For attach/detach clauses, set OMP_CLAUSE_SIZE (representing a bias) to zero here, so it is not set erroneously to the pointer - size later on in gimplify.c. */ + size later on in gimplify.cc. */ OMP_CLAUSE_SIZE (c) = size_zero_node; + while (TREE_CODE (t) == INDIRECT_REF + || TREE_CODE (t) == ARRAY_REF) + { + t = TREE_OPERAND (t, 0); + STRIP_NOPS (t); + if (TREE_CODE (t) == POINTER_PLUS_EXPR) + t = TREE_OPERAND (t, 0); + } + while (TREE_CODE (t) == COMPOUND_EXPR) + { + t = TREE_OPERAND (t, 1); + STRIP_NOPS (t); + } + indir_component_ref_p = false; + if (TREE_CODE (t) == COMPONENT_REF + && (TREE_CODE (TREE_OPERAND (t, 0)) == MEM_REF + || TREE_CODE (TREE_OPERAND (t, 0)) == INDIRECT_REF + || TREE_CODE (TREE_OPERAND (t, 0)) == ARRAY_REF)) + { + t = TREE_OPERAND (TREE_OPERAND (t, 0), 0); + indir_component_ref_p = true; + STRIP_NOPS (t); + if (TREE_CODE (t) == POINTER_PLUS_EXPR) + t = TREE_OPERAND (t, 0); + } + if (TREE_CODE (t) == COMPONENT_REF && OMP_CLAUSE_CODE (c) != OMP_CLAUSE__CACHE_) { @@ -14968,7 +15068,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) break; } t = TREE_OPERAND (t, 0); - if (ort == C_ORT_ACC && TREE_CODE (t) == MEM_REF) + if (TREE_CODE (t) == MEM_REF) { if (maybe_ne (mem_ref_offset (t), 0)) error_at (OMP_CLAUSE_LOCATION (c), @@ -14977,6 +15077,15 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) else t = TREE_OPERAND (t, 0); } + while (TREE_CODE (t) == MEM_REF + || TREE_CODE (t) == INDIRECT_REF + || TREE_CODE (t) == ARRAY_REF) + { + t = TREE_OPERAND (t, 0); + STRIP_NOPS (t); + if (TREE_CODE (t) == POINTER_PLUS_EXPR) + t = TREE_OPERAND (t, 0); + } } if (remove) break; @@ -15005,6 +15114,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) else if ((OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER)) + && !indir_component_ref_p && !c_mark_addressable (t)) remove = true; else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP @@ -15047,7 +15157,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "%qD appears more than once in data clauses", t); remove = true; } - else if (bitmap_bit_p (&map_head, DECL_UID (t))) + else if (bitmap_bit_p (&map_head, DECL_UID (t)) + && !bitmap_bit_p (&map_field_head, DECL_UID (t))) { if (ort == C_ORT_ACC) error_at (OMP_CLAUSE_LOCATION (c), @@ -15061,8 +15172,7 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) bitmap_set_bit (&map_firstprivate_head, DECL_UID (t)); } else if (bitmap_bit_p (&map_head, DECL_UID (t)) - && (ort == C_ORT_ACC - || !bitmap_bit_p (&map_field_head, DECL_UID (t)))) + && !bitmap_bit_p (&map_field_head, DECL_UID (t))) { if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP) error_at (OMP_CLAUSE_LOCATION (c), @@ -15082,7 +15192,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) "%qD appears more than once in data clauses", t); remove = true; } - else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t))) + else if (bitmap_bit_p (&firstprivate_head, DECL_UID (t)) + || bitmap_bit_p (&is_on_device_head, DECL_UID (t))) { if (ort == C_ORT_ACC) error_at (OMP_CLAUSE_LOCATION (c), @@ -15167,6 +15278,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) case OMP_CLAUSE_IS_DEVICE_PTR: case OMP_CLAUSE_USE_DEVICE_PTR: t = OMP_CLAUSE_DECL (c); + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_IS_DEVICE_PTR) + bitmap_set_bit (&is_on_device_head, DECL_UID (t)); if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE) { if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR @@ -15187,6 +15300,24 @@ c_finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } goto check_dup_generic; + case OMP_CLAUSE_HAS_DEVICE_ADDR: + t = OMP_CLAUSE_DECL (c); + if (TREE_CODE (t) == TREE_LIST) + { + if (handle_omp_array_sections (c, ort)) + remove = true; + else + { + t = OMP_CLAUSE_DECL (c); + while (TREE_CODE (t) == ARRAY_REF) + t = TREE_OPERAND (t, 0); + } + } + bitmap_set_bit (&is_on_device_head, DECL_UID (t)); + if (VAR_P (t) || TREE_CODE (t) == PARM_DECL) + c_mark_addressable (t); + goto check_dup_generic_t; + case OMP_CLAUSE_USE_DEVICE_ADDR: t = OMP_CLAUSE_DECL (c); if (VAR_P (t) || TREE_CODE (t) == PARM_DECL) @@ -15965,8 +16096,6 @@ c_tree_equal (tree t1, tree t2) default: gcc_unreachable (); } - /* We can get here with --disable-checking. */ - return false; } /* Returns true when the function declaration FNDECL is implicit, diff --git a/gcc/c/config-lang.in b/gcc/c/config-lang.in index b9cf5f3..4526f63 100644 --- a/gcc/c/config-lang.in +++ b/gcc/c/config-lang.in @@ -1,5 +1,5 @@ # Top level configure fragment for GNU C - C language. -# Copyright (C) 1994-2021 Free Software Foundation, Inc. +# Copyright (C) 1994-2022 Free Software Foundation, Inc. #This file is part of GCC. @@ -29,4 +29,4 @@ compilers="cc1\$(exeext)" target_libs= -gtfiles="\$(srcdir)/c/c-lang.c \$(srcdir)/c/c-tree.h \$(srcdir)/c/c-decl.c \$(srcdir)/c-family/c-common.c \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-cppbuiltin.c \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.c \$(srcdir)/c-family/c-format.c \$(srcdir)/c/c-objc-common.c \$(srcdir)/c/c-parser.h \$(srcdir)/c/c-parser.c \$(srcdir)/c/c-lang.h" +gtfiles="\$(srcdir)/c/c-lang.cc \$(srcdir)/c/c-tree.h \$(srcdir)/c/c-decl.cc \$(srcdir)/c-family/c-common.cc \$(srcdir)/c-family/c-common.h \$(srcdir)/c-family/c-objc.h \$(srcdir)/c-family/c-cppbuiltin.cc \$(srcdir)/c-family/c-pragma.h \$(srcdir)/c-family/c-pragma.cc \$(srcdir)/c-family/c-format.cc \$(srcdir)/c/c-objc-common.cc \$(srcdir)/c/c-parser.h \$(srcdir)/c/c-parser.cc \$(srcdir)/c/c-lang.h" diff --git a/gcc/c/gccspec.c b/gcc/c/gccspec.cc index db353a3..d1165dd 100644 --- a/gcc/c/gccspec.c +++ b/gcc/c/gccspec.cc @@ -1,5 +1,5 @@ /* Specific flags and argument handling of the C front-end. - Copyright (C) 1999-2021 Free Software Foundation, Inc. + Copyright (C) 1999-2022 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.cc index f3d9935..31075237 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.cc @@ -1,5 +1,5 @@ /* Parser for GIMPLE. - Copyright (C) 2016-2021 Free Software Foundation, Inc. + Copyright (C) 2016-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -56,13 +56,13 @@ along with GCC; see the file COPYING3. If not see #include "internal-fn.h" #include "cfg.h" #include "cfghooks.h" +#include "bitmap.h" #include "cfganal.h" #include "tree-cfg.h" #include "gimple-iterator.h" #include "cfgloop.h" #include "tree-phinodes.h" #include "tree-into-ssa.h" -#include "bitmap.h" /* GIMPLE parser state. */ @@ -860,9 +860,10 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) if (lhs.value != error_mark_node && rhs.value != error_mark_node) { - /* If we parsed a comparison and the next token is a '?' then - parse a conditional expression. */ - if (COMPARISON_CLASS_P (rhs.value) + /* If we parsed a comparison or an identifier and the next token + is a '?' then parse a conditional expression. */ + if ((COMPARISON_CLASS_P (rhs.value) + || SSA_VAR_P (rhs.value)) && c_parser_next_token_is (parser, CPP_QUERY)) { struct c_expr trueval, falseval; @@ -874,7 +875,10 @@ c_parser_gimple_statement (gimple_parser &parser, gimple_seq *seq) if (trueval.value == error_mark_node || falseval.value == error_mark_node) return; - rhs.value = build3_loc (loc, COND_EXPR, TREE_TYPE (trueval.value), + rhs.value = build3_loc (loc, + VECTOR_TYPE_P (TREE_TYPE (rhs.value)) + ? VEC_COND_EXPR : COND_EXPR, + TREE_TYPE (trueval.value), rhs.value, trueval.value, falseval.value); } if (get_gimple_rhs_class (TREE_CODE (rhs.value)) == GIMPLE_INVALID_RHS) @@ -1698,13 +1702,7 @@ c_parser_gimple_postfix_expression (gimple_parser &parser) } break; } - else - { - c_parser_error (parser, "expected expression"); - expr.set_error (); - break; - } - break; + /* Fallthru. */ default: c_parser_error (parser, "expected expression"); expr.set_error (); diff --git a/gcc/c/gimple-parser.h b/gcc/c/gimple-parser.h index 6501bcf..2881a65 100644 --- a/gcc/c/gimple-parser.h +++ b/gcc/c/gimple-parser.h @@ -1,5 +1,5 @@ /* Declarations for the parser for GIMPLE. - Copyright (C) 2016-2021 Free Software Foundation, Inc. + Copyright (C) 2016-2022 Free Software Foundation, Inc. This file is part of GCC. |