aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
AgeCommit message (Collapse)AuthorFilesLines
2023-06-17Daily bump.GCC Administrator1-0/+6
2023-06-15c: add name hints to c_parser_declspecs [PR107583]David Malcolm1-1/+13
PR c/107583 notes that we weren't issuing a hint for struct foo { time_t mytime; /* missing <time.h> include should trigger fixit */ }; in the C frontend. The root cause is that one of the "unknown type name" diagnostics was missing logic to emit hints, which this patch fixes. gcc/c/ChangeLog: PR c/107583 * c-parser.cc (c_parser_declspecs): Add hints to "unknown type name" error. gcc/testsuite/ChangeLog: PR c/107583 * c-c++-common/spellcheck-pr107583.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-06-13Daily bump.GCC Administrator1-0/+5
2023-06-12OpenMP: Cleanups related to the 'present' modifierTobias Burnus1-3/+2
Reduce number of enum values passed to libgomp as GOMP_MAP_PRESENT_{TO,TOFROM,FROM,ALLOC} have the same semantic as GOMP_MAP_FORCE_PRESENT (i.e. abort if not present, otherwise ignore); that's different to GOMP_MAP_ALWAYS_PRESENT_{TO,TOFROM,FROM} which also abort if not present but copy data when present. This is is a follow-up to the commit r14-1579-g4ede915d5dde93 done 6 days ago. Additionally, the commit improves a libgomp run-time and a C/C++ compile-time error wording and extends testcases a tiny bit. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_clause_map): Reword error message for clearness especially with 'omp target (enter/exit) data.' gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_clause_map): Reword error message for clearness especially with 'omp target (enter/exit) data.' * semantics.cc (handle_omp_array_sections): Handle GOMP_MAP_{ALWAYS_,}PRESENT_{TO,TOFROM,FROM,ALLOC} enum values. gcc/ChangeLog: * gimplify.cc (gimplify_adjust_omp_clauses_1): Use GOMP_MAP_FORCE_PRESENT for 'present alloc' implicit mapping. (gimplify_adjust_omp_clauses): Change GOMP_MAP_PRESENT_{TO,TOFROM,FROM,ALLOC} to the equivalent GOMP_MAP_FORCE_PRESENT. * omp-low.cc (lower_omp_target): Remove handling of no-longer valid GOMP_MAP_PRESENT_{TO,TOFROM,FROM,ALLOC}; update map kinds used for to/from clauses with present modifier. include/ChangeLog: * gomp-constants.h (enum gomp_map_kind): Change the enum values GOMP_MAP_PRESENT_{TO,TOFROM,FROM,ALLOC} to be compiler only. (GOMP_MAP_PRESENT_P): Update to include also GOMP_MAP_FORCE_PRESENT. libgomp/ChangeLog: * target.c (gomp_to_device_kind_p, gomp_map_vars_internal): Replace GOMP_MAP_PRESENT_{FROM,TO,TOFROM,ACLLOC} by GOMP_MAP_FORCE_PRESENT. (gomp_map_vars_internal, gomp_update): Likewise; unify and improve error message. * testsuite/libgomp.c-c++-common/target-present-2.c: Update for changed error message. * testsuite/libgomp.fortran/target-present-1.f90: Likewise. * testsuite/libgomp.fortran/target-present-2.f90: Likewise. * testsuite/libgomp.oacc-c-c++-common/present-1.c: Likewise. * testsuite/libgomp.c-c++-common/target-present-1.c: Likewise and extend testcase to check that data is copied when needed. * testsuite/libgomp.c-c++-common/target-present-3.c: Likewise. * testsuite/libgomp.fortran/target-present-3.f90: Likewise. gcc/testsuite/ChangeLog: * c-c++-common/gomp/defaultmap-4.c: Update scan-tree-dump. * c-c++-common/gomp/map-9.c: Likewise. * gfortran.dg/gomp/defaultmap-8.f90: Likewise. * gfortran.dg/gomp/map-11.f90: Likewise. * gfortran.dg/gomp/target-update-1.f90: Likewise. * gfortran.dg/gomp/map-12.f90: Likewise; also check original dump. * c-c++-common/gomp/map-6.c: Update dg-error and also check clause error with 'target (enter/exit) data'.
2023-06-07Daily bump.GCC Administrator1-0/+13
2023-06-06openmp: Add support for the 'present' modifierTobias Burnus1-18/+105
This implements support for the OpenMP 5.1 'present' modifier, which can be used in map clauses in the 'target', 'target data', 'target data enter' and 'target data exit' constructs, and in the 'to' and 'from' clauses of the 'target update' construct. It is also supported in defaultmap. The modifier triggers a fatal runtime error if the data specified by the clause is not already present on the target device. It can also be combined with 'always' in map clauses. 2023-06-06 Kwok Cheung Yeung <kcy@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> gcc/c/ * c-parser.cc (c_parser_omp_clause_defaultmap, c_parser_omp_clause_map): Parse 'present'. (c_parser_omp_clause_to, c_parser_omp_clause_from): Remove. (c_parser_omp_clause_from_to): New; parse to/from clauses with optional present modifer. (c_parser_omp_all_clauses): Update call. (c_parser_omp_target_data, c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Handle new map enum values for 'present' mapping. gcc/cp/ * parser.cc (cp_parser_omp_clause_defaultmap, cp_parser_omp_clause_map): Parse 'present'. (cp_parser_omp_clause_from_to): New; parse to/from clauses with optional 'present' modifier. (cp_parser_omp_all_clauses): Update call. (cp_parser_omp_target_data, cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data): Handle new enum value for 'present' mapping. * semantics.cc (finish_omp_target): Likewise. gcc/fortran/ * dump-parse-tree.cc (show_omp_namelist): Display 'present' map modifier. (show_omp_clauses): Display 'present' motion modifier for 'to' and 'from' clauses. * gfortran.h (enum gfc_omp_map_op): Add entries with 'present' modifiers. (struct gfc_omp_namelist): Add 'present_modifer'. * openmp.cc (gfc_match_motion_var_list): New, handles optional 'present' modifier for to/from clauses. (gfc_match_omp_clauses): Call it for to/from clauses; parse 'present' in defaultmap and map clauses. (resolve_omp_clauses): Allow 'present' modifiers on 'target', 'target data', 'target enter' and 'target exit' directives. * trans-openmp.cc (gfc_trans_omp_clauses): Apply 'present' modifiers to tree node for 'map', 'to' and 'from' clauses. Apply 'present' for defaultmap. gcc/ * gimplify.cc (omp_notice_variable): Apply GOVD_MAP_ALLOC_ONLY flag and defaultmap flags if the defaultmap has GOVD_MAP_FORCE_PRESENT flag set. (omp_get_attachment): Handle map clauses with 'present' modifier. (omp_group_base): Likewise. (gimplify_scan_omp_clauses): Reorder present maps to come first. Set GOVD flags for present defaultmaps. (gimplify_adjust_omp_clauses_1): Set map kind for present defaultmaps. * omp-low.cc (scan_sharing_clauses): Handle 'always, present' map clauses. (lower_omp_target): Handle map clauses with 'present' modifier. Handle 'to' and 'from' clauses with 'present'. * tree-core.h (enum omp_clause_defaultmap_kind): Add OMP_CLAUSE_DEFAULTMAP_PRESENT defaultmap kind. * tree-pretty-print.cc (dump_omp_clause): Handle 'map', 'to' and 'from' clauses with 'present' modifier. Handle present defaultmap. * tree.h (OMP_CLAUSE_MOTION_PRESENT): New #define. include/ * gomp-constants.h (GOMP_MAP_FLAG_SPECIAL_5): New. (GOMP_MAP_FLAG_FORCE): Redefine. (GOMP_MAP_FLAG_PRESENT, GOMP_MAP_FLAG_ALWAYS_PRESENT): New. (enum gomp_map_kind): Add map kinds with 'present' modifiers. (GOMP_MAP_COPY_TO_P, GOMP_MAP_COPY_FROM_P): Evaluate to true for map variants with 'present' (GOMP_MAP_ALWAYS_TO_P, GOMP_MAP_ALWAYS_FROM_P): Evaluate to true for map variants with 'always, present' modifiers. (GOMP_MAP_ALWAYS): Redefine. (GOMP_MAP_FORCE_P, GOMP_MAP_PRESENT_P): New. libgomp/ * libgomp.texi (OpenMP 5.1 Impl. status): Set 'present' support for defaultmap to 'Y', add 'Y' entry for 'present' on to/from/map clauses. * target.c (gomp_to_device_kind_p): Add map kinds with 'present' modifier. (gomp_map_vars_existing): Use new GOMP_MAP_FORCE_P macro. (gomp_map_vars_internal, gomp_update, gomp_target_rev): Emit runtime error if memory region not present. * testsuite/libgomp.c-c++-common/target-present-1.c: New test. * testsuite/libgomp.c-c++-common/target-present-2.c: New test. * testsuite/libgomp.c-c++-common/target-present-3.c: New test. * testsuite/libgomp.fortran/target-present-1.f90: New test. * testsuite/libgomp.fortran/target-present-2.f90: New test. * testsuite/libgomp.fortran/target-present-3.f90: New test. gcc/testsuite/ * c-c++-common/gomp/map-6.c: Update dg-error, extend to test for duplicated 'present' and extend scan-dump tests for 'present'. * gfortran.dg/gomp/defaultmap-1.f90: Update dg-error. * gfortran.dg/gomp/map-7.f90: Extend parse and dump test for 'present'. * gfortran.dg/gomp/map-8.f90: Extend for duplicate 'present' modifier checking. * c-c++-common/gomp/defaultmap-4.c: New test. * c-c++-common/gomp/map-9.c: New test. * c-c++-common/gomp/target-update-1.c: New test. * gfortran.dg/gomp/defaultmap-8.f90: New test. * gfortran.dg/gomp/map-11.f90: New test. * gfortran.dg/gomp/map-12.f90: New test. * gfortran.dg/gomp/target-update-1.f90: New test.
2023-05-31Daily bump.GCC Administrator1-0/+6
2023-05-30OpenMP: Improve C/C++ parsing error message [PR109999]Tobias Burnus1-2/+2
Replace error: expected '#pragma omp' clause before ... by the the more readable/clearer error: expected an OpenMP clause before ... (And likewise for '#pragma acc' and OpenACC.) PR c/109999 gcc/c/ChangeLog: * c-parser.cc (c_parser_oacc_all_clauses, c_parser_omp_all_clauses): Improve error wording. gcc/cp/ChangeLog: * parser.cc (cp_parser_oacc_all_clauses, cp_parser_omp_all_clauses): Improve error wording. gcc/testsuite/ChangeLog: * c-c++-common/goacc/asyncwait-1.c: Update dg-error. * c-c++-common/goacc/clauses-fail.c: Likewise. * c-c++-common/goacc/data-2.c: Likewise. * c-c++-common/gomp/declare-target-2.c: Likewise. * c-c++-common/gomp/directive-1.c: Likewise. * g++.dg/goacc/data-1.C: Likewise.
2023-05-24Daily bump.GCC Administrator1-0/+27
2023-05-23Fix ICEs related to VM types in C 2/2 [PR109450]Martin Uecker1-52/+60
Size expressions were sometimes lost and not gimplified correctly, leading to ICEs and incorrect evaluation order. Fix this by 1) not recursing pointers when gimplifying parameters, which was incorrect because it might access variables declared later for incomplete structs, and 2) adding a decl expr for variably-modified arrays that are pointed to by parameters declared as arrays. PR c/109450 gcc/ * function.cc (gimplify_parm_type): Remove function. (gimplify_parameters): Call gimplify_type_sizes. gcc/c/ * c-decl.cc (add_decl_expr): New function. (grokdeclarator): Add decl expr for size expression in types pointed to by parameters declared as arrays. gcc/testsuite/ * gcc.dg/pr109450-1.c: New test. * gcc.dg/pr109450-2.c: New test. * gcc.dg/vla-26.c: New test.
2023-05-23Fix ICEs related to VM types in C 1/2 [PR70418, PR107557, PR108423]Martin Uecker3-27/+36
Size expressions were sometimes lost and not gimplified correctly, leading to ICEs and incorrect evaluation order. Fix this by 1) not recursing into pointers when gimplifying parameters in the middle-end (the code is merged with gimplify_type_sizes), which is incorrect because it might access variables declared later for incomplete structs, and 2) tracking size expressions for struct/union members correctly, 3) emitting code to evaluate size expressions for missing cases (nested functions, empty declarations, and structs/unions). PR c/70418 PR c/106465 PR c/107557 PR c/108423 gcc/c/ * c-decl.cc (start_decl): Make sure size expression are evaluated only in correct context. (grokdeclarator): Size expression in fields may need a bind expression, make sure DECL_EXPR is always created. (grokfield, declspecs_add_type): Pass along size expressions. (finish_struct): Remove unneeded DECL_EXPR. (start_function): Evaluate size expressions for nested functions. * c-parser.cc (c_parser_struct_declarations, c_parser_struct_or_union_specifier): Pass along size expressions. (c_parser_declaration_or_fndef): Evaluate size expression. (c_parser_objc_at_property_declaration, c_parser_objc_class_instance_variables): Adapt. * c-tree.h (grokfield): Adapt declaration. gcc/testsuite/ * gcc.dg/nested-vla-1.c: New test. * gcc.dg/nested-vla-2.c: New test. * gcc.dg/nested-vla-3.c: New test. * gcc.dg/pr70418.c: New test. * gcc.dg/pr106465.c: New test. * gcc.dg/pr107557-1.c: New test. * gcc.dg/pr107557-2.c: New test. * gcc.dg/pr108423-1.c: New test. * gcc.dg/pr108423-2.c: New test. * gcc.dg/pr108423-3.c: New test. * gcc.dg/pr108423-4.c: New test. * gcc.dg/pr108423-5.c: New test. * gcc.dg/pr108423-6.c: New test. * gcc.dg/typename-vla-2.c: New test. * gcc.dg/typename-vla-3.c: New test. * gcc.dg/typename-vla-4.c: New test. * gcc.misc-tests/gcov-pr85350.c: Adapt.
2023-05-20Daily bump.GCC Administrator1-0/+16
2023-05-19c: Remove dead code related to type compatibility across TUs.Martin Uecker2-79/+27
Code to detect struct/unions across the same TU is not needed anymore. Code for determining compatibility of tagged types is preserved as it will be used for C2X. Some errors in the unused code are fixed. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-decl.cc (set_type_context): Remove. (pop_scope, diagnose_mismatched_decls, pushdecl): Remove dead code. * c-typeck.cc (comptypes_internal): Remove dead code. (same_translation_unit_p): Remove. (tagged_types_tu_compatible_p): Some fixes.
2023-05-19c: Do not allow thread-local tentative definitions for C2xJoseph Myers1-3/+17
C2x makes it clear that thread-local declarations can never be tentative definitions (the legacy feature of C where you can e.g. do "int i;" more than once at file scope, possibly with one of the declarations initialized, and it counts as exactly one definition), but are always definitions in the absence of "extern". The wording about external definitions was unclear in the thread-local case in C11 / C17 (both about what counts as a tentative definition, and what is a "definition" at all), not having been updated to cover the addition of thread-local storage. Implement this C2x requirement. Arguably this is a defect fix that would be appropriate to apply for all standard versions, but for now the change is conditional on flag_isoc2x (however, it doesn't handle _Thread_local / thread_local any different from GNU __thread). Making the change unconditional results in various TLS tests failing to compile (gcc.dg/c11-thread-local-1.c gcc.dg/tls/thr-init-1.c gcc.dg/tls/thr-init-2.c gcc.dg/torture/tls/thr-init-2.c objc.dg/torture/tls/thr-init.m), though it's not clear if those tests reflect any real code similarly trying to make use of thread-local tentative definitions. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-decl.cc (diagnose_mismatched_decls): Do not handle thread-local declarations as tentative definitions for C2x. (finish_decl): Do not allow thread-local definition with incomplete type for C2x. gcc/testsuite/ * gcc.dg/c2x-thread-local-2.c: New test.
2023-05-19Daily bump.GCC Administrator1-0/+20
2023-05-18c: use _P() defines from tree.hBernhard Reutner-Fischer5-34/+34
gcc/c-family/ChangeLog: * c-ada-spec.cc (has_static_fields): Use _P() defines from tree.h. (dump_ada_declaration): Ditto. (dump_ada_structure): Ditto. * c-common.cc (unsafe_conversion_p): Ditto. (shorten_compare): Ditto. (pointer_int_sum): Ditto. (c_common_truthvalue_conversion): Ditto. (scalar_to_vector): Ditto. * c-common.h (gnu_vector_type_p): Ditto. * c-omp.cc (c_omp_depend_t_p): Ditto. (c_omp_split_clauses): Ditto. * c-ubsan.cc (ubsan_instrument_division): Ditto. * c-warn.cc (conversion_warning): Ditto. (warnings_for_convert_and_check): Ditto. gcc/c/ChangeLog: * c-convert.cc (c_convert): Ditto. * c-decl.cc (merge_decls): Ditto. * c-parser.cc (c_parser_omp_clause_reduction): Ditto. (c_parser_omp_declare_reduction): Ditto. * c-typeck.cc (build_component_ref): Ditto. (convert_argument): Ditto. (pointer_diff): Ditto. (build_unary_op): Ditto. (build_c_cast): Ditto. (build_modify_expr): Ditto. (store_init_value): Ditto. (constexpr_init_fits_real_type): Ditto. (check_constexpr_init): Ditto. (c_finish_return): Ditto. (handle_omp_array_sections_1): Ditto. (c_finish_omp_clauses): Ditto. * gimple-parser.cc (c_finish_gimple_return): Ditto. libcc1/ChangeLog: * libcc1plugin.cc (plugin_float_type): Ditto. * libcp1plugin.cc (plugin_reactivate_decl): Ditto. (plugin_get_float_type): Ditto.
2023-05-17Daily bump.GCC Administrator1-0/+5
2023-05-16c: Remove restrictions on declarations in 'for' loops for C2XJoseph Myers1-17/+21
C2X removes a restriction that the only declarations in the declaration part of a 'for' loop are declarations of objects with storage class auto or register. Implement this change, making the diagnostics into pedwarn_c11 calls instead of errors (as usual for features added in a new standard version that were invalid code in a previous version), so now pedwarn-if-pedantic for older standards and diagnosed also with -Wc11-c2x-compat. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-decl.cc (check_for_loop_decls): Use pedwarn_c11 for diagnostics. gcc/testsuite/ * gcc.dg/c11-fordecl-1.c, gcc.dg/c11-fordecl-2.c, gcc.dg/c11-fordecl-3.c, gcc.dg/c11-fordecl-4.c, gcc.dg/c2x-fordecl-1.c, gcc.dg/c2x-fordecl-2.c, gcc.dg/c2x-fordecl-3.c, gcc.dg/c2x-fordecl-4.c: New tests. * gcc.dg/c99-fordecl-2.c: Test diagnostic for typedef declaration in for loop here. * gcc.dg/pr67784-2.c, gcc.dg/pr68320.c, objc.dg/foreach-7.m: Do not expect errors for typedef declaration in for loop.
2023-05-16Daily bump.GCC Administrator1-0/+5
2023-05-15c: Ignore _Atomic on function return type for C2xJoseph Myers1-2/+5
For C2x it was decided that _Atomic would be completely ignored on function return types (just as was done for qualifiers in C11 DR#423), to eliminate the potential for an rvalue returned by a function having _Atomic-qualified type when an rvalue resulting from lvalue-to-rvalue conversion could not have such a type. Implement this for GCC. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-decl.cc (grokdeclarator): Ignore _Atomic on function return type for C2x. gcc/testsuite/ * gcc.dg/qual-return-9.c, gcc.dg/qual-return-10.c: New tests.
2023-05-01Daily bump.GCC Administrator1-0/+11
2023-04-30Improve error message for excess elements in array initializer from {"a"}Andrew Pinski1-1/+1
So char arrays are not the only type that be initialized from {"a"}. We can have wchar_t (L"") and char16_t (u"") types too. So let's print out the type of the array instead of just saying char. Note in the testsuite I used regex . to match '[' and ']' as I could not figure out how many '\' I needed. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/c/ChangeLog: * c-typeck.cc (process_init_element): Print out array type for excessive elements. gcc/testsuite/ChangeLog: * gcc.dg/init-bad-1.c: Update error message. * gcc.dg/init-bad-2.c: Likewise. * gcc.dg/init-bad-3.c: Likewise. * gcc.dg/init-excess-3.c: Likewise. * gcc.dg/pr61096-1.c: Likewise.
2023-04-30Fix C/107926: Wrong error message when initializing char arrayAndrew Pinski1-5/+10
The problem here is the code which handles {"a"} is supposed to handle the case where the is something after the string but it only handles the case where there is another string so we go down the other path and error out saying "excess elements in struct initializer" even though this was a character array. To fix this, we need to move the ckeck if the initializer is a string after the check for array and initializer. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Adnrew Pinski gcc/c/ChangeLog: PR c/107926 * c-typeck.cc (process_init_element): Move the check for string cst until after the error message. gcc/testsuite/ChangeLog: PR c/107926 * gcc.dg/init-excess-3.c: New test.
2023-04-29Daily bump.GCC Administrator1-0/+4
2023-04-28Fix autoprofiledbootstrap buildEugene Rozenfeld1-3/+29
1. Fix gcov version 2. Merge perf data collected when compiling the compiler and runtime libraries 3. Fix documentation typo Tested on x86_64-pc-linux-gnu. ChangeLog: * Makefile.in: Define PROFILE_MERGER * Makefile.tpl: Define PROFILE_MERGER gcc/c/ChangeLog: * Make-lang.in: Merge perf data collected when compiling cc1 and runtime libraries gcc/cp/ChangeLog: * Make-lang.in: Merge perf data collected when compiling cc1plus and runtime libraries gcc/lto/ChangeLog: * Make-lang.in: Merge perf data collected when compiling lto1 and runtime libraries gcc/ChangeLog: * doc/install.texi: Fix documentation typo
2023-04-28Daily bump.GCC Administrator1-0/+14
2023-04-27c: Fix up error-recovery on non-empty VLA initializers [PR109409]Jakub Jelinek1-4/+7
On the following testcase we ICE, because after we emit the variable-sized object may not be initialized except with an empty initializer error we don't really reset the initializer to error_mark_node and then at -Wformat checking time we ICE on seeing STRING_CST initializer for a VLA. The following patch just arranges for error_mark_node to be returned after the error diagnostics. 2023-04-27 Jakub Jelinek <jakub@redhat.com> PR c/109409 * c-parser.cc (c_parser_initializer): Move diagnostics about initialization of variable sized object with non-empty initializer after c_parser_expr_no_commas call and ret.set_error (); after it. * gcc.dg/pr109409.c: New test.
2023-04-27c: Fix up error-recovery on functions initialized as variables [PR109412]Jakub Jelinek1-0/+5
The change to allow empty initializers in C broke error-recovery on the following testcase. We are emitting function %qD is initialized like a variable error early; if the initializer is non-empty, we just emit another error that the initializer is invalid. Previously if it was empty, we'd emit another error that scalar is being initialized by empty initializer (not really correct), but now we instead just try to build_zero_cst for the FUNCTION_TYPE and ICE on it. The following patch just emits the same diagnostics for the empty initializers as we emit for the non-empty ones. 2023-04-27 Jakub Jelinek <jakub@redhat.com> PR c/107682 PR c/109412 * c-typeck.cc (pop_init_level): If constructor_type is FUNCTION_TYPE, reject empty initializer as invalid. * gcc.dg/pr109412.c: New test.
2023-04-27Daily bump.GCC Administrator1-0/+5
2023-04-26More last_stmt removalRichard Biener1-2/+1
This adjusts more users of last_stmt where it is clear that debug stmt skipping is unnecessary. In most cases this also allowed significant code simplification. gcc/c/ * gimple-parser.cc (c_parser_parse_gimple_body): Avoid last_stmt. gcc/ * gimple-range-path.cc (path_range_query::compute_outgoing_relations): Avoid last_stmt. * ipa-pure-const.cc (pass_nothrow::execute): Likewise. * predict.cc (apply_return_prediction): Likewise. * sese.cc (set_ifsese_condition): Likewise. Simplify. * tree-cfg.cc (assert_unreachable_fallthru_edge_p): Avoid last_stmt. (make_edges_bb): Likewise. (make_cond_expr_edges): Likewise. (end_recording_case_labels): Likewise. (make_gimple_asm_edges): Likewise. (cleanup_dead_labels): Likewise. (group_case_labels): Likewise. (gimple_can_merge_blocks_p): Likewise. (gimple_merge_blocks): Likewise. (find_taken_edge): Likewise. Also handle empty fallthru blocks. (gimple_duplicate_sese_tail): Avoid last_stmt. (find_loop_dist_alias): Likewise. (gimple_block_ends_with_condjump_p): Likewise. (gimple_purge_dead_eh_edges): Likewise. (gimple_purge_dead_abnormal_call_edges): Likewise. (pass_warn_function_return::execute): Likewise. (execute_fixup_cfg): Likewise. * tree-eh.cc (redirect_eh_edge_1): Likewise. (pass_lower_resx::execute): Likewise. (pass_lower_eh_dispatch::execute): Likewise. (cleanup_empty_eh): Likewise. * tree-if-conv.cc (if_convertible_bb_p): Likewise. (predicate_bbs): Likewise. (ifcvt_split_critical_edges): Likewise. * tree-loop-distribution.cc (create_edge_for_control_dependence): Likewise. (loop_distribution::transform_reduction_loop): Likewise. * tree-parloops.cc (transform_to_exit_first_loop_alt): Likewise. (try_transform_to_exit_first_loop_alt): Likewise. (transform_to_exit_first_loop): Likewise. (create_parallel_loop): Likewise. * tree-scalar-evolution.cc (get_loop_exit_condition): Likewise. * tree-ssa-dce.cc (mark_last_stmt_necessary): Likewise. (eliminate_unnecessary_stmts): Likewise. * tree-ssa-dom.cc (dom_opt_dom_walker::set_global_ranges_from_unreachable_edges): Likewise. * tree-ssa-ifcombine.cc (ifcombine_ifandif): Likewise. (pass_tree_ifcombine::execute): Likewise. * tree-ssa-loop-ch.cc (entry_loop_condition_is_static): Likewise. (should_duplicate_loop_header_p): Likewise. * tree-ssa-loop-ivcanon.cc (create_canonical_iv): Likewise. (tree_estimate_loop_size): Likewise. (try_unroll_loop_completely): Likewise. * tree-ssa-loop-ivopts.cc (tree_ssa_iv_optimize_loop): Likewise. * tree-ssa-loop-manip.cc (ip_normal_pos): Likewise. (canonicalize_loop_ivs): Likewise. * tree-ssa-loop-niter.cc (determine_value_range): Likewise. (bound_difference): Likewise. (number_of_iterations_popcount): Likewise. (number_of_iterations_cltz): Likewise. (number_of_iterations_cltz_complement): Likewise. (simplify_using_initial_conditions): Likewise. (number_of_iterations_exit_assumptions): Likewise. (loop_niter_by_eval): Likewise. (estimate_numbers_of_iterations): Likewise.
2023-04-26Daily bump.GCC Administrator1-0/+5
2023-04-25'omp scan' struct block seq update for OpenMP 5.xTobias Burnus1-2/+20
While OpenMP 5.0 required a single structured block before and after the 'omp scan' directive, OpenMP 5.1 changed this to a 'structured block sequence, denoting 2 or more executable statements in OpenMP 5.1 (whoops!) and zero or more in OpenMP 5.2. This commit updates C/C++ to accept zero statements (but till requires the '{' ... '}' for the final-loop-body) and updates Fortran to accept zero or more than one statements. If there is no preceeding or succeeding executable statement, a warning is shown. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_scan_loop_body): Handle zero exec statements before/after 'omp scan'. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_scan_loop_body): Handle zero exec statements before/after 'omp scan'. gcc/fortran/ChangeLog: * openmp.cc (gfc_resolve_omp_do_blocks): Handle zero or more than one exec statements before/after 'omp scan'. * trans-openmp.cc (gfc_trans_omp_do): Likewise. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/scan-1.c: New test. * testsuite/libgomp.c/scan-23.c: New test. * testsuite/libgomp.fortran/scan-2.f90: New test. gcc/testsuite/ChangeLog: * g++.dg/gomp/attrs-7.C: Update dg-error/dg-warning. * gfortran.dg/gomp/loop-2.f90: Likewise. * gfortran.dg/gomp/reduction5.f90: Likewise. * gfortran.dg/gomp/reduction6.f90: Likewise. * gfortran.dg/gomp/scan-1.f90: Likewise. * gfortran.dg/gomp/taskloop-2.f90: Likewise. * c-c++-common/gomp/scan-6.c: New test. * gfortran.dg/gomp/scan-8.f90: New test.
2023-04-21Daily bump.GCC Administrator1-0/+6
2023-04-20c: Avoid -Wenum-int-mismatch warning for redeclaration of builtin ↵Jakub Jelinek1-1/+8
acc_on_device [PR107041] The new -Wenum-int-mismatch warning triggers with -Wsystem-headers in <openacc.h>, for obvious reasons the builtin acc_on_device uses int type argument rather than enum which isn't defined yet when the builtin is created, while the OpenACC spec requires it to have acc_device_t enum argument. The header makes sure it has int underlying type by using negative and __INT_MAX__ enumerators. I've tried to make the builtin typegeneric or just varargs, but that changes behavior e.g. when one calls it with some C++ class which has cast operator to acc_device_t, so the following patch instead disables the warning for this builtin. 2023-04-20 Jakub Jelinek <jakub@redhat.com> PR c/107041 * c-decl.cc (diagnose_mismatched_decls): Avoid -Wenum-int-mismatch warning on acc_on_device declaration. * gcc.dg/goacc/pr107041.c: New test.
2023-03-29Daily bump.GCC Administrator1-0/+6
2023-03-28Don't emit -Wxor-used-as-pow on macro expansions [PR107002]David Malcolm1-1/+1
PR c/107002 reports an assertion failure from deep inside the diagnostic_shows_locus when attempting to print fix-it hints relating to -Wxor-used-as-pow. The case involves macro expansions with -ftrack-macro-expansion=0. It doesn't seem to make much sense to emit this warning for macro expansions, so this patch updates the warning not to (which seems to also be clang's behavior). The patch also adds some bulletproofing to diagnostic-show-locus.cc to be more robust against such invalid fix-it hints. Doing so fixes the ICE. gcc/c-family/ChangeLog: PR c/107002 * c-common.h (check_for_xor_used_as_pow): Add "rhs_loc" param. * c-warn.cc (check_for_xor_used_as_pow): Add "rhs_loc" param. Reject cases where involving macro expansions. gcc/c/ChangeLog: PR c/107002 * c-typeck.cc (parser_build_binary_op): Update for new param of check_for_xor_used_as_pow. gcc/cp/ChangeLog: PR c/107002 * parser.cc (cp_parser_binary_expression): Update for new param of check_for_xor_used_as_pow. gcc/ChangeLog: PR c/107002 * diagnostic-show-locus.cc (column_range::column_range): Factor out assertion conditional into... (column_range::valid_p): ...this new function. (line_corrections::add_hint): Don't attempt to consolidate hints if it would lead to invalid column_range instances. gcc/testsuite/ChangeLog: PR c/107002 * c-c++-common/Wxor-used-as-pow-1.c: Add macro test. * c-c++-common/Wxor-used-as-pow-pr107002-0.c: New test. * c-c++-common/Wxor-used-as-pow-pr107002-1.c: New test. * c-c++-common/Wxor-used-as-pow-pr107002-2.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2023-03-11Daily bump.GCC Administrator1-0/+6
2023-03-10c, c++, cgraphunit: Prevent duplicated -Wunused-value warnings [PR108079]Jakub Jelinek1-1/+4
On the following testcase, we warn with -Wunused-value twice, once in the FEs and later on cgraphunit again with slightly different wording. The following patch fixes that by registering a warning suppression in the FEs when we warn and not warning in cgraphunit anymore if that happened. 2023-03-10 Jakub Jelinek <jakub@redhat.com> PR c/108079 gcc/ * cgraphunit.cc (check_global_declaration): Don't warn for unused variables which have OPT_Wunused_variable warning suppressed. gcc/c/ * c-decl.cc (pop_scope): Suppress OPT_Wunused_variable warning after diagnosing it. gcc/cp/ * decl.cc (poplevel): Suppress OPT_Wunused_variable warning after diagnosing it. gcc/testsuite/ * c-c++-common/Wunused-var-18.c: New test.
2023-03-01Daily bump.GCC Administrator1-0/+7
2023-02-28ubsan: Honor -fstrict-flex-arrays= in -fsanitize=bounds [PR108894]Jakub Jelinek1-30/+1
While this isn't really a regression, the -fstrict-flex-arrays* option is new in GCC 13 and so I think we should make -fsanitize=bounds play with it well from the beginning. The current behavior is that -fsanitize=bounds considers all trailing arrays as flexible member-like arrays and both -fsanitize=bounds and -fsanitize=bounds-strict because of a bug don't even instrument [0] arrays at all, not as trailing nor when followed by other members. I think -fstrict-flex-arrays* options can be considered as language mode changing options, by default flexible member-like arrays are handled like flexible arrays, but that option can change the set of the arrays which are treated like that. So, -fsanitize=bounds should change with that on what is considered acceptable and what isn't. While -fsanitize=bounds-strict should reject them all always to continue previous behavior. The following patch implements that. To support [0] array instrumentation, I had to change the meaning of the bounds argument to .UBSAN_BOUNDS, previously it was the TYPE_MAX_VALUE of the domain unless ignore_off_by_one (used for taking address of the array element rather than accessing it; in that case 1 is added to the bound argument) and the later lowered checks were if (index > bound) report_failure (). The problem with that is that for [0] arrays where (at least for C++) the max value is all ones, for accesses that condition will be never true; for addresses of elements it was working (in C++) correctly before. This patch changes it to add 1 + ignore_off_by_one, so -1 becomes 0 or 1 for &array_ref and changing the lowering to be if (index >= bound) report_failure (). Furthermore, as C represents the [0] arrays with NULL TYPE_MAX_VALUE, I treated those like the C++ ones. 2023-02-28 Jakub Jelinek <jakub@redhat.com> PR sanitizer/108894 gcc/ * ubsan.cc (ubsan_expand_bounds_ifn): Emit index >= bound comparison rather than index > bound. * gimple-fold.cc (gimple_fold_call): Use tree_int_cst_lt rather than tree_int_cst_le for IFN_UBSAN_BOUND comparison. * doc/invoke.texi (-fsanitize=bounds): Document that whether flexible array member-like arrays are instrumented or not depends on -fstrict-flex-arrays* options of strict_flex_array attributes. (-fsanitize=bounds-strict): Document that flexible array members are not instrumented. gcc/c-family/ * c-common.h (c_strict_flex_array_level_of): Declare. * c-common.cc (c_strict_flex_array_level_of): New function, moved and renamed from c-decl.cc's strict_flex_array_level_of. * c-ubsan.cc (ubsan_instrument_bounds): Fix comment typo. For C check c_strict_flex_array_level_of whether a trailing array should be treated as flexible member like. Handle C [0] arrays. Add 1 + index_off_by_one rather than index_off_by_one to bounds and use tree_int_cst_lt rather than tree_int_cst_le for idx vs. bounds comparison. gcc/c/ * c-decl.cc (strict_flex_array_level_of): Move to c-common.cc and rename to c_strict_flex_array_level_of. (is_flexible_array_member_p): Adjust caller. gcc/testsuite/ * gcc.dg/ubsan/bounds-4.c: New test. * gcc.dg/ubsan/bounds-4a.c: New test. * gcc.dg/ubsan/bounds-4b.c: New test. * gcc.dg/ubsan/bounds-4c.c: New test. * gcc.dg/ubsan/bounds-4d.c: New test. * g++.dg/ubsan/bounds-1.C: New test.
2023-02-19Daily bump.GCC Administrator1-0/+21
2023-02-18C: Detect all variably modified types [PR108375]Martin Uecker6-41/+50
Some variably modified types were not detected correctly. Define C_TYPE_VARIABLY_MODIFIED via TYPE_LANG_FLAG 6 in the CFE. This flag records whether a type is variably modified and is set for all such types including arrays with variably modified element type or structures and unions with variably modified members. This is then used to detect such types in the C FE and middle-end (via the existing language hook). gcc/c/ChangeLog: PR c/108375 * c-decl.cc (decl_jump_unsafe): Use c_type_variably_modified_p. (diagnose_mismatched_decl): Dito. (warn_about_goto): Dito: (c_check_switch_jump_warnings): Dito. (finish_decl): Dito. (finish_struct): Dito. (grokdeclarator): Set C_TYPE_VARIABLY_MODIFIED. (finish_struct): Set C_TYPE_VARIABLY_MODIFIED. * c-objc-common.cc (c_var_mod_p): New function. (c_var_unspec_p): Remove. * c-objc-common.h: Set lang hook. * c-parser.cc (c_parser_declararion_or_fndef): Use c_type_variably_modified_p. (c_parser_typeof_specifier): Dito. (c_parser_has_attribute_expression): Dito. (c_parser_generic_selection): Dito. * c-tree.h: Define C_TYPE_VARIABLY_MODIFIED and define c_var_mode_p. * c-typeck.cc: Remove c_vla_mod_p and use C_TYPE_VARIABLY_MODIFIED. gcc/testsuite/ChangeLog: PR c/108375 * gcc.dg/pr108375-1.c: New test. * gcc.dg/pr108375-2.c: New test.
2023-02-17Daily bump.GCC Administrator1-0/+5
2023-02-16don't declare header-defined functions both static and inlinePatrick Palka1-3/+3
Many functions defined in our headers are declared 'static inline' which is a C idiom whose use predates our move to C++ as the implementation language. But in C++ the inline keyword is more than just a compiler hint, and is sufficient to give the function the intended semantics. In fact declaring a function both static and inline is a pessimization since static effectively disables the desired definition merging behavior enabled by inline, and is also a source of (harmless) ODR violations when a static inline function gets called from a non-static inline one (such as tree_operand_check calling tree_operand_length). This patch mechanically fixes the vast majority of occurrences of this anti-pattern throughout the compiler's headers via the command line sed -i 's/^static inline/inline/g' gcc/*.h gcc/*/*.h There's also a manual change to remove the redundant declarations of is_ivar and lookup_category in gcc/objc/objc-act.cc which would otherwise conflict with their modified definitions in objc-act.h (due to the difference in staticness). Besides fixing some ODR violations, this speeds up stage1 cc1plus by about 2% and reduces the size of its text segment by 1.5MB. gcc/ChangeLog: * addresses.h: Mechanically drop 'static' from 'static inline' functions via s/^static inline/inline/g. * asan.h: Likewise. * attribs.h: Likewise. * basic-block.h: Likewise. * bitmap.h: Likewise. * cfghooks.h: Likewise. * cfgloop.h: Likewise. * cgraph.h: Likewise. * cselib.h: Likewise. * data-streamer.h: Likewise. * debug.h: Likewise. * df.h: Likewise. * diagnostic.h: Likewise. * dominance.h: Likewise. * dumpfile.h: Likewise. * emit-rtl.h: Likewise. * except.h: Likewise. * expmed.h: Likewise. * expr.h: Likewise. * fixed-value.h: Likewise. * gengtype.h: Likewise. * gimple-expr.h: Likewise. * gimple-iterator.h: Likewise. * gimple-predict.h: Likewise. * gimple-range-fold.h: Likewise. * gimple-ssa.h: Likewise. * gimple.h: Likewise. * graphite.h: Likewise. * hard-reg-set.h: Likewise. * hash-map.h: Likewise. * hash-set.h: Likewise. * hash-table.h: Likewise. * hwint.h: Likewise. * input.h: Likewise. * insn-addr.h: Likewise. * internal-fn.h: Likewise. * ipa-fnsummary.h: Likewise. * ipa-icf-gimple.h: Likewise. * ipa-inline.h: Likewise. * ipa-modref.h: Likewise. * ipa-prop.h: Likewise. * ira-int.h: Likewise. * ira.h: Likewise. * lra-int.h: Likewise. * lra.h: Likewise. * lto-streamer.h: Likewise. * memmodel.h: Likewise. * omp-general.h: Likewise. * optabs-query.h: Likewise. * optabs.h: Likewise. * plugin.h: Likewise. * pretty-print.h: Likewise. * range.h: Likewise. * read-md.h: Likewise. * recog.h: Likewise. * regs.h: Likewise. * rtl-iter.h: Likewise. * rtl.h: Likewise. * sbitmap.h: Likewise. * sched-int.h: Likewise. * sel-sched-ir.h: Likewise. * sese.h: Likewise. * sparseset.h: Likewise. * ssa-iterators.h: Likewise. * system.h: Likewise. * target-globals.h: Likewise. * target.h: Likewise. * timevar.h: Likewise. * tree-chrec.h: Likewise. * tree-data-ref.h: Likewise. * tree-iterator.h: Likewise. * tree-outof-ssa.h: Likewise. * tree-phinodes.h: Likewise. * tree-scalar-evolution.h: Likewise. * tree-sra.h: Likewise. * tree-ssa-alias.h: Likewise. * tree-ssa-live.h: Likewise. * tree-ssa-loop-manip.h: Likewise. * tree-ssa-loop.h: Likewise. * tree-ssa-operands.h: Likewise. * tree-ssa-propagate.h: Likewise. * tree-ssa-sccvn.h: Likewise. * tree-ssa.h: Likewise. * tree-ssanames.h: Likewise. * tree-streamer.h: Likewise. * tree-switch-conversion.h: Likewise. * tree-vectorizer.h: Likewise. * tree.h: Likewise. * wide-int.h: Likewise. gcc/c-family/ChangeLog: * c-common.h: Mechanically drop static from static inline functions via s/^static inline/inline/g. gcc/c/ChangeLog: * c-parser.h: Mechanically drop static from static inline functions via s/^static inline/inline/g. gcc/cp/ChangeLog: * cp-tree.h: Mechanically drop static from static inline functions via s/^static inline/inline/g. gcc/fortran/ChangeLog: * gfortran.h: Mechanically drop static from static inline functions via s/^static inline/inline/g. gcc/jit/ChangeLog: * jit-dejagnu.h: Mechanically drop static from static inline functions via s/^static inline/inline/g. * jit-recording.h: Likewise. gcc/objc/ChangeLog: * objc-act.h: Mechanically drop static from static inline functions via s/^static inline/inline/g. * objc-map.h: Likewise. * objc-act.cc: Remove the redundant redeclarations of is_ivar and lookup_category.
2023-02-11Daily bump.GCC Administrator1-0/+10
2023-02-10c: Allow conversions of null pointer constants to nullptr_tJoseph Myers3-6/+23
WG14 has agreed to allow conversions (explicit and implicit) from null pointer constants to nullptr_t; update GCC's nullptr_t implementation to match. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-convert.cc (c_convert): Allow conversion of a null pointer constant to nullptr_t. * c-typeck.cc (null_pointer_constant_p): Remove static. (convert_for_assignment): Allow conversion of a null pointer constant to nullptr_t. (digest_init): Handle NULLPTR_TYPE among scalar conversions. * c-tree.h (null_pointer_constant_p): Declare. gcc/testsuite/ * gcc.dg/c2x-nullptr-1.c: Test conversion of null pointer constants to nullptr_t. * gcc.dg/c2x-nullptr-3.c: Do not expect errors for conversion of null pointer constants to nullptr_t. Do test errors for conversion of other values to nullptr_t and for unary '+' on nullptr_t.
2023-02-10Daily bump.GCC Administrator1-0/+5
2023-02-09OpenMP: Parse align clause in allocate directive in C/C++Tobias Burnus1-23/+65
gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_allocate): Parse align clause and check for restrictions. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_allocate): Parse align clause and check for restrictions. gcc/testsuite/ChangeLog: * c-c++-common/gomp/allocate-5.c: Extend for align clause.
2023-02-09Daily bump.GCC Administrator1-0/+7
2023-02-08c: Update checks on constexpr pointer initializersJoseph Myers1-15/+10
WG14 has agreed a change of the rules on constexpr pointer initializers, so that a (constant) null value that is not a null pointer constant is accepted in that context, rather than only accepting null pointer constants. (In particular, this means that a constexpr variable of pointer type can be used to initializer another such variable.) Remove the null pointer constant restriction in GCC, instead checking just whether the value is null. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c/ * c-typeck.cc (check_constexpr_init): Remove argument null_pointer_constant. Only check pointer initializers for being null. (digest_init): Update calls to check_constexpr_init. gcc/testsuite/ * gcc.dg/c2x-constexpr-1.c: Test initialization of constexpr pointers with null values that are not null pointer constants. * gcc.dg/c2x-constexpr-3.c: Test initialization of constexpr pointers with non-null values, not with null values that are not null pointer constants.