aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
AgeCommit message (Collapse)AuthorFilesLines
2022-08-16docs: remove link to www.bullfreeware.com from installMartin Liska1-4/+0
As mentioned at https://gcc.gnu.org/PR106637#c2, the discontinued providing binaries. PR target/106637 gcc/ChangeLog: * doc/install.texi: Remove link to www.bullfreeware.com
2022-08-16Merge branch 'master' into devel/sphinxMartin Liska1-5/+31
2022-08-16Adjust max-jump-thread-paths docsRichard Biener1-3/+3
The following fixes spelling and changes edge degree for number of incoming edges. * doc/invoke.texi (max-jump-thread-paths): Adjust.
2022-08-12[Committed] arm: Document +no options for Cortex-M55 CPU.Srinath Parvathaneni1-2/+13
This patch documents the following options for Arm Cortex-M55 CPU under -mcpu= list. +nomve.fp (disables MVE single precision floating point instructions) +nomve (disables MVE integer and single precision floating point instructions) +nodsp (disables dsp, MVE integer and single precision floating point instructions) +nofp (disables floating point instructions) Committed as obvious to master. gcc/ChangeLog: 2022-08-12 Srinath Parvathaneni <srinath.parvathaneni@arm.com> * doc/invoke.texi (Arm Options): Document -mcpu=cortex-m55 options.
2022-08-12analyzer: out-of-bounds checker [PR106000]Tim Lange1-0/+15
This patch adds an experimental out-of-bounds checker to the analyzer. The checker was tested on coreutils, curl, httpd and openssh. It is mostly accurate but does produce false-positives on yacc-generated files and sometimes when the analyzer misses an invariant. These cases will be documented in bugzilla. Regression-tested on Linux x86-64, further ran the analyzer tests with the -m32 option. 2022-08-11 Tim Lange <mail@tim-lange.me> gcc/analyzer/ChangeLog: PR analyzer/106000 * analyzer.opt: Add Wanalyzer-out-of-bounds. * region-model.cc (class out_of_bounds): Diagnostics base class for all out-of-bounds diagnostics. (class past_the_end): Base class derived from out_of_bounds for the buffer_overflow and buffer_overread diagnostics. (class buffer_overflow): Buffer overflow diagnostics. (class buffer_overread): Buffer overread diagnostics. (class buffer_underflow): Buffer underflow diagnostics. (class buffer_underread): Buffer overread diagnostics. (region_model::check_region_bounds): New function to check region bounds for out-of-bounds accesses. (region_model::check_region_access): Add call to check_region_bounds. (region_model::get_representative_tree): New function that accepts a region instead of an svalue. * region-model.h (class region_model): Add region_model::check_region_bounds. * region.cc (region::symbolic_p): New predicate. (offset_region::get_byte_size_sval): Only return the remaining byte size on offset_regions. * region.h: Add region::symbolic_p. * store.cc (byte_range::intersects_p): Add new function equivalent to bit_range::intersects_p. (byte_range::exceeds_p): New function. (byte_range::falls_short_of_p): New function. * store.h (struct byte_range): Add byte_range::intersects_p, byte_range::exceeds_p and byte_range::falls_short_of_p. gcc/ChangeLog: PR analyzer/106000 * doc/invoke.texi: Add Wanalyzer-out-of-bounds. gcc/testsuite/ChangeLog: PR analyzer/106000 * g++.dg/analyzer/pr100244.C: Disable out-of-bounds warning. * gcc.dg/analyzer/allocation-size-3.c: Disable out-of-bounds warning. * gcc.dg/analyzer/memcpy-2.c: Disable out-of-bounds warning. * gcc.dg/analyzer/pr101962.c: Add dg-warning. * gcc.dg/analyzer/pr96764.c: Disable out-of-bounds warning. * gcc.dg/analyzer/pr97029.c: Add dummy buffer to prevent an out-of-bounds warning. * gcc.dg/analyzer/realloc-5.c: Add dg-warning. * gcc.dg/analyzer/test-setjmp.h: Add dummy buffer to prevent an out-of-bounds warning. * gcc.dg/analyzer/zlib-3.c: Add dg-bogus. * g++.dg/analyzer/out-of-bounds-placement-new.C: New test. * gcc.dg/analyzer/out-of-bounds-1.c: New test. * gcc.dg/analyzer/out-of-bounds-2.c: New test. * gcc.dg/analyzer/out-of-bounds-3.c: New test. * gcc.dg/analyzer/out-of-bounds-container_of.c: New test. * gcc.dg/analyzer/out-of-bounds-coreutils.c: New test. * gcc.dg/analyzer/out-of-bounds-curl.c: New test.
2022-08-10Merge branch 'master' into devel/sphinxMartin Liska1-0/+81
2022-08-09docs: add notes on which functions -fanalyzer has hardcoded knowledge ofDavid Malcolm1-0/+81
gcc/ChangeLog: * doc/invoke.texi (Static Analyzer Options): Add notes on which functions the analyzer has hardcoded knowledge of. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-08-09Merge branch 'master' into devel/sphinxMartin Liska1-3/+7
2022-08-09Remove --param max-fsm-thread-lengthRichard Biener1-3/+0
This removes max-fsm-thread-length which is obsoleted by max-jump-thread-paths. * doc/invoke.texi (max-fsm-thread-length): Remove. * params.opt (max-fsm-thread-length): Likewise. * tree-ssa-threadbackward.cc (back_threader_profitability::profitable_path_p): Do not check max-fsm-thread-length.
2022-08-09tree-optimization/106514 - add --param max-jump-thread-pathsRichard Biener1-0/+7
The following adds a limit for the exponential greedy search of the backwards jump threader. The idea is to limit the search space in a way that the paths considered are the same if the search were in BFS order rather than DFS. In particular it stops considering incoming edges into a block if the product of the in-degrees of blocks on the path exceeds the specified limit. When considering the low stmt copying limit of 7 (or 1 in the size optimize case) this means the degenerate case with maximum search space is a sequence of conditions with no actual code B1 |\ | empty |/ B2 |\ ... Bn |\ GIMPLE_CONDs are costed 2, an equivalent GIMPLE_SWITCH already 4, so we reach 7 already with 3 middle conditions (B1 and Bn do not count). The search space would be 2^4 == 16 to reach this. The FSM threads historically allowed for a thread length of 10 but is really looking for a single multiway branch threaded across the backedge. I've chosen the default of the new parameter to 64 which effectively limits the outdegree of the switch statement (the cases reaching the backedge) to that number (divided by 2 until I add some special pruning for FSM threads due to the loop header indegree). The testcase ssa-dom-thread-7.c requires 56 at the moment (as said, some special FSM thread pruning of considered edges would bring it down to half of that), but we now get one more threading and quite some more in later threadfull. This testcase seems to be difficult to check for expected transforms. The new testcases add the degenerate case we currently thread (without deciding whether that's a good idea ...) plus one with an approripate limit that should prevent the threading. This obsoletes the mentioned --param max-fsm-thread-length but I am not removing it as part of this patch. When the search space is limited the thread stmt size limit effectively provides max-fsm-thread-length. The param with its default does not help PR106514 enough to unleash path searching with the higher FSM stmt count limit. PR tree-optimization/106514 * params.opt (max-jump-thread-paths): New. * doc/invoke.texi (max-jump-thread-paths): Document. * tree-ssa-threadbackward.cc (back_threader::find_paths_to_names): Honor max-jump-thread-paths, take overall_path argument. (back_threader::find_paths): Pass 1 as initial overall_path. * gcc.dg/tree-ssa/ssa-thread-16.c: New testcase. * gcc.dg/tree-ssa/ssa-thread-17.c: Likewise. * gcc.dg/tree-ssa/ssa-dom-thread-7.c: Adjust.
2022-08-08Merge branch 'master' into devel/sphinxMartin Liska2-1/+18
2022-08-05New warning: -Wanalyzer-jump-through-null [PR105947]David Malcolm1-0/+12
This patch adds a new warning to -fanalyzer for jumps through NULL function pointers. gcc/analyzer/ChangeLog: PR analyzer/105947 * analyzer.opt (Wanalyzer-jump-through-null): New option. * engine.cc (class jump_through_null): New. (exploded_graph::process_node): Complain about jumps through NULL function pointers. gcc/ChangeLog: PR analyzer/105947 * doc/invoke.texi: Add -Wanalyzer-jump-through-null. gcc/testsuite/ChangeLog: PR analyzer/105947 * gcc.dg/analyzer/function-ptr-5.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-08-03gcov-dump: add --stable optionMartin Liska1-0/+5
The option prints TOP N counters in a stable format usage for comparison (diff). gcc/ChangeLog: * doc/gcov-dump.texi: Document the new option. * gcov-dump.cc (main): Parse the new option. (print_usage): Show the option. (tag_counters): Sort key:value pairs of TOP N counter.
2022-08-01docs: fix copy&paste error in -Wanalyzer-putenv-of-auto-varDavid Malcolm1-1/+1
gcc/ChangeLog: * doc/invoke.texi (-Wanalyzer-putenv-of-auto-var): Fix copy&paste error. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-08-01Merge branch 'master' into devel/sphinxMartin Liska2-7/+68
2022-07-28analyzer: new warning: -Wanalyzer-putenv-of-auto-var [PR105893]David Malcolm1-0/+14
This patch implements a new -fanalyzer warning: -Wanalyzer-putenv-of-auto-var which complains about stack pointers passed to putenv(3) calls, as per SEI CERT C Coding Standard rule POS34-C ("Do not call putenv() with a pointer to an automatic variable as the argument"). For example, given: #include <stdio.h> #include <stdlib.h> void test_arr (void) { char arr[] = "NAME=VALUE"; putenv (arr); } it emits: demo.c: In function ‘test_arr’: demo.c:7:3: warning: ‘putenv’ on a pointer to automatic variable ‘arr’ [POS34-C] [-Wanalyzer-putenv-of-auto-var] 7 | putenv (arr); | ^~~~~~~~~~~~ ‘test_arr’: event 1 | | 7 | putenv (arr); | | ^~~~~~~~~~~~ | | | | | (1) ‘putenv’ on a pointer to automatic variable ‘arr’ | demo.c:6:8: note: ‘arr’ declared on stack here 6 | char arr[] = "NAME=VALUE"; | ^~~ demo.c:7:3: note: perhaps use ‘setenv’ rather than ‘putenv’ 7 | putenv (arr); | ^~~~~~~~~~~~ gcc/analyzer/ChangeLog: PR analyzer/105893 * analyzer.opt (Wanalyzer-putenv-of-auto-var): New. * region-model-impl-calls.cc (class putenv_of_auto_var): New. (region_model::impl_call_putenv): New. * region-model.cc (region_model::on_call_pre): Handle putenv. * region-model.h (region_model::impl_call_putenv): New decl. gcc/ChangeLog: PR analyzer/105893 * doc/invoke.texi: Add -Wanalyzer-putenv-of-auto-var. gcc/testsuite/ChangeLog: PR analyzer/105893 * gcc.dg/analyzer/putenv-1.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-28analyzer: add CWE identifier URLs to docsDavid Malcolm1-5/+45
gcc/analyzer/ChangeLog: * sm-malloc.cc (free_of_non_heap::emit): Add comment about CWE. * sm-taint.cc (tainted_size::emit): Likewise. gcc/ChangeLog: * doc/invoke.texi (-fdiagnostics-show-cwe): Use uref rather than url. (Static Analyzer Options): Likewise. Add urefs for all of the warnings that have associated CWE identifiers. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-28doc: Clarify FENV_ACCESS pragma semantics WRT `-ftrapping-math'Maciej W. Rozycki2-2/+9
Our documentation indicates that it is the `-frounding-math' invocation option that controls whether we respect what the FENV_ACCESS pragma would imply, should we implement it, regarding the floating point environment. It is only a part of the picture however, because the `-ftrapping-math' invocation option also affects how we handle said environment. Clarify that in the description of both options then, as well as the FENV_ACCESS pragma itself. gcc/ * doc/implement-c.texi (Floating point implementation): Mention `-fno-trapping-math' in the context of FENV_ACCESS pragma. * doc/invoke.texi (Optimize Options): Clarify FENV_ACCESS pragma implication in the descriptions of `-fno-trapping-math' and `-frounding-math'.
2022-07-28docs: Fix outdated reference to LOOPS_HAVE_MARKED_SINGLE_EXITSAndrew Carlotti1-1/+1
gcc/ChangeLog: * doc/loop.texi: Refer to LOOPS_HAVE_RECORDED_EXITS instead.
2022-07-28LoongArch: document -m[no-]explicit-relocsWANG Xuerui1-0/+13
gcc/ChangeLog: * doc/invoke.texi: Document -m[no-]explicit-relocs for LoongArch.
2022-07-27docs: Fix outdated reference to LOOPS_HAVE_MARKED_SINGLE_EXITSAndrew Carlotti1-1/+1
gcc/ChangeLog: * doc/loop.texi: Refer to LOOPS_HAVE_RECORDED_EXITS instead.
2022-07-27LoongArch: document -m[no-]explicit-relocsWANG Xuerui1-0/+13
gcc/ChangeLog: * doc/invoke.texi: Document -m[no-]explicit-relocs for LoongArch.
2022-07-26Merge branch 'master' into devel/sphinxMartin Liska2-2/+2
2022-07-26docs: fix previsou commitMartin Liska2-2/+2
gcc/ChangeLog: * doc/tm.texi.in: Fix placement of defmac. * doc/tm.texi: Copy.
2022-07-26Merge branch 'master' into devel/sphinxMartin Liska2-4/+10
2022-07-26docs: fix crossing declaration of @defmac and @hook.Martin Liska2-10/+10
gcc/ChangeLog: * doc/tm.texi.in: Fix cross @defmac and @hook. * doc/tm.texi: Copy.
2022-07-25Merge branch 'master' into devel/sphinxMartin Liska2-6/+59
2022-07-25docs: remove recently added trailing whitespacesMartin Liska2-11/+11
gcc/ChangeLog: * doc/extend.texi: Remove trailing whitespaces. * doc/invoke.texi: Likewise.
2022-07-23Adding three new function attributes for static analysis of file descriptorsImmad Mir2-1/+54
This patch adds three new function attributes to GCC that are used for static analysis of usage of file descriptors: 1) __attribute__ ((fd_arg(N))): The attributes may be applied to a function that takes an open file descriptor at refrenced argument N. It indicates that the passed filedescriptor must not have been closed. Therefore, when the analyzer is enabled with -fanalyzer, the analyzer may emit a -Wanalyzer-fd-use-after-close diagnostic if it detects a code path in which a function with this attribute is called with a closed file descriptor. The attribute also indicates that the file descriptor must have been checked for validity before usage. Therefore, analyzer may emit -Wanalyzer-fd-use-without-check diagnostic if it detects a code path in which a function with this attribute is called with a file descriptor that has not been checked for validity. 2) __attribute__((fd_arg_read(N))): The attribute is identical to fd_arg, but with the additional requirement that it might read from the file descriptor, and thus, the file descriptor must not have been opened as write-only. The analyzer may emit a -Wanalyzer-access-mode-mismatch diagnostic if it detects a code path in which a function with this attribute is called on a file descriptor opened with O_WRONLY. 3) __attribute__((fd_arg_write(N))): The attribute is identical to fd_arg_read except that the analyzer may emit a -Wanalyzer-access-mode-mismatch diagnostic if it detects a code path in which a function with this attribute is called on a file descriptor opened with O_RDONLY. gcc/analyzer/ChangeLog: * sm-fd.cc (fd_param_diagnostic): New diagnostic class. (fd_access_mode_mismatch): Change inheritance from fd_diagnostic to fd_param_diagnostic. Add new overloaded constructor. (fd_use_after_close): Likewise. (unchecked_use_of_fd): Likewise and also change name to fd_use_without_check. (double_close): Change name to fd_double_close. (enum access_directions): New. (fd_state_machine::on_stmt): Handle calls to function with the new three function attributes. (fd_state_machine::check_for_fd_attrs): New. (fd_state_machine::on_open): Use the new overloaded constructors of diagnostic classes. gcc/c-family/ChangeLog: * c-attribs.cc: (c_common_attribute_table): add three new attributes namely: fd_arg, fd_arg_read and fd_arg_write. (handle_fd_arg_attribute): New. gcc/ChangeLog: * doc/extend.texi: Add fd_arg, fd_arg_read and fd_arg_write under "Common Function Attributes" section. * doc/invoke.texi: Add docs to -Wanalyzer-fd-access-mode-mismatch, -Wanalyzer-use-after-close, -Wanalyzer-fd-use-without-check that these warnings may be emitted through usage of three function attributes used for static analysis of file descriptors namely fd_arg, fd_arg_read and fd_arg_write. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/fd-5.c: New test. * gcc.dg/analyzer/fd-4.c: Remove quotes around 'read-only' and 'write-only'. * c-c++-common/attr-fd.c: New test. Signed-off-by: Immad Mir <mirimmad17@gmail.com>
2022-07-19Merge branch 'master' into devel/sphinxMartin Liska2-6/+24
2022-07-19Remote trailing : for subheading.Martin Liska1-2/+2
gcc/ChangeLog: * doc/extend.texi: Remove trailing :.
2022-07-18RISC-V/doc: Add index references for `mrelax' and `mriscv-attribute'Maciej W. Rozycki1-0/+2
Add missing index references for the `-mrelax' and `-mriscv-attribute' invocation options. gcc/ * doc/invoke.texi (RISC-V Options): Add index references for `mrelax' and `mriscv-attribute'.
2022-07-18RISC-V/doc: Correct the formatting of `-mstack-protector-guard-reg='Maciej W. Rozycki1-1/+1
Add missing second space around the `-mstack-protector-guard-reg=' invocation option. gcc/ * doc/invoke.texi (Option Summary): Add missing second space around `-mstack-protector-guard-reg='.
2022-07-18RISC-V/doc: Correct the name of `-mriscv-attribute'Maciej W. Rozycki1-3/+3
Correct the name of the `-mriscv-attribute' invocation option, including a typo in the negated form. gcc/ * doc/invoke.texi (Option Summary): Fix `-mno-riscv-attribute'. (RISC-V Options): Likewise, and `-mriscv-attribute'.
2022-07-18arc: Add ARCHS release 310a tune variant.Claudiu Zissulescu1-0/+16
Add mtune and mcpu options for ARCHS release 310a type CPU. The mtune=release31a is designed to be used as an alternative to the mcpu=hs4x_rel31 option. ARCHS4x release 31a uses DSP instructions which are implemented a bit different than mpy9. Hence, use safer mpy2 option. gcc/ * config/arc/arc-arch.h (arc_tune_attr): Add ARC_TUNE_ARCHS4X_REL31A variant. * config/arc/arc.cc (arc_override_options): Tune options for release 310a. (arc_sched_issue_rate): Use correct enum. (arc600_corereg_hazard): Textual change. (arc_hazard): Add release 310a tunning. * config/arc/arc.md (tune): Update and take into consideration new tune option. (tune_dspmpy): Likewise. (tune_store): New attribute. * config/arc/arc.opt (mtune): New tune option. * config/arc/arcHS4x.md (hs4x_brcc0, hs4x_brcc1): New cpu units. (hs4x_brcc_op): New instruction rezervation. (hs4x_data_store_1_op): Likewise. * config/arc/arc-cpus.def (hs4x_rel31): New cpu variant. * config/arc/arc-tables.opt: Regenerate. * config/arc/t-multilib: Likewise. * doc/invoke.texi (ARC): Update mcpu and tune sections. Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2022-07-18Merge branch 'master' into devel/sphinxMartin Liska1-0/+10
2022-07-15analyzer: documentation nits relating to new fd warningsDavid Malcolm1-0/+10
gcc/ChangeLog: * doc/invoke.texi (Static Analyzer Options): Add the new fd warnings to the initial gccoptlist, and to the list of those disabled by -fanalyzer-checker=taint. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-07-14Merge branch 'master' into devel/sphinxMartin Liska1-2/+2
2022-07-14docs: fix position of @end deftypefnMartin Liska1-2/+2
gcc/ChangeLog: * doc/gimple.texi: Close properly a deftypefn.
2022-07-14Merge branch 'master' into devel/sphinxMartin Liska1-2/+1
2022-07-14docs: fix position of @end deftypefnMartin Liska1-2/+1
gcc/ChangeLog: * doc/gimple.texi: Close properly a deftypefn.
2022-07-10Merge branch 'master' into devel/sphinxMartin Liska5-335/+169
2022-07-03loongarch: use -mno-check-zero-division as the default for optimized codeXi Ruoyao1-1/+2
Integer division by zero is undefined behavior anyway, and there are already many platforms where neither the GCC port and the hardware do anything to trap on division by zero. So any portable program shall not rely on SIGFPE on division by zero, in both theory and practice. As the result, there is no real reason to cost two additional instructions just for the trap on division by zero with a new ISA. One remaining reason to trap on division by zero may be debugging, especially while -fsanitize=integer-divide-by-zero is not implemented for LoongArch yet. To make debugging easier, keep -mcheck-zero-division as the default for -O0 and -Og, but use -mno-check-zero-division as the default for all other optimization levels. Co-authored-by: Lulu Cheng <chenglulu@loongson.cn> gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_check_zero_div_p): New static function. (loongarch_idiv_insns): Use loongarch_check_zero_div_p instead of TARGET_CHECK_ZERO_DIV. (loongarch_output_division): Likewise. * common/config/loongarch/loongarch-common.cc (TARGET_DEFAULT_TARGET_FLAGS): Remove unneeded hook. * doc/invoke.texi: Update to match the new behavior. gcc/testsuite/ChangeLog: * gcc.c-torture/execute/20101011-1.c (dg-additional-options): add -mcheck-zero-division for LoongArch targets.
2022-07-02analyzer: add allocation size checker [PR105900]Tim Lange1-0/+14
This patch adds an checker that warns about code paths in which a buffer is assigned to a incompatible type, i.e. when the allocated buffer size is not a multiple of the pointee's size. Regression-tested on x86_64 Linux. Also compiled coreutils, curl, openssh and httpd with the patch enabled. 2022-07-01 Tim Lange <mail@tim-lange.me> gcc/analyzer/ChangeLog: PR analyzer/105900 * analyzer.opt: Added Wanalyzer-allocation-size. * checker-path.cc (region_creation_event::get_desc): Added call to new virtual function pending_diagnostic::describe_region_creation_event. * checker-path.h: Added region_creation_event::get_desc. * diagnostic-manager.cc (diagnostic_manager::add_event_on_final_node): New function. * diagnostic-manager.h: Added diagnostic_manager::add_event_on_final_node. * pending-diagnostic.h (struct region_creation): New event_desc struct. (pending_diagnostic::describe_region_creation_event): Added virtual function to overwrite description of a region creation. * region-model.cc (class dubious_allocation_size): New class. (capacity_compatible_with_type): New helper function. (class size_visitor): New class. (struct_or_union_with_inheritance_p): New helper function. (is_any_cast_p): New helper function. (region_model::check_region_size): New function. (region_model::set_value): Added call to region_model::check_region_size. * region-model.h (class region_model): New function check_region_size. * svalue.cc (region_svalue::accept): Changed to post-order traversal. (initial_svalue::accept): Likewise. (unaryop_svalue::accept): Likewise. (binop_svalue::accept): Likewise. (sub_svalue::accept): Likewise. (repeated_svalue::accept): Likewise. (bits_within_svalue::accept): Likewise. (widening_svalue::accept): Likewise. (unmergeable_svalue::accept): Likewise. (compound_svalue::accept): Likewise. (conjured_svalue::accept): Likewise. (asm_output_svalue::accept): Likewise. (const_fn_result_svalue::accept): Likewise. gcc/ChangeLog: PR analyzer/105900 * doc/invoke.texi: Added Wanalyzer-allocation-size. gcc/testsuite/ChangeLog: PR analyzer/105900 * gcc.dg/analyzer/pr96639.c: Changed buffer size to omit warning. * gcc.dg/analyzer/allocation-size-1.c: New test. * gcc.dg/analyzer/allocation-size-2.c: New test. * gcc.dg/analyzer/allocation-size-3.c: New test. * gcc.dg/analyzer/allocation-size-4.c: New test. * gcc.dg/analyzer/allocation-size-5.c: New test. Signed-off-by: Tim Lange <mail@tim-lange.me>
2022-07-02analyzer: implement five new warnings for misuse of POSIX file descriptor ↵Immad Mir1-0/+55
APIs [PR106003]. This patch adds a new state machine to the analyzer for checking usage of POSIX file descriptor APIs with five new warnings. It adds: - check for FD leaks (CWE 775). - check for double "close" of a FD (CWE-1341). - check for read/write of a closed file descriptor. - check whether a file descriptor was used without being checked for validity. - check for read/write of a descriptor opened for just writing/reading. gcc/ChangeLog: PR analyzer/106003 * Makefile.in (ANALYZER_OBJS): Add sm-fd.o. * doc/invoke.texi: Add -Wanalyzer-fd-double-close, -Wanalyzer-fd-leak, -Wanalyzer-fd-access-mode-mismatch, -Wanalyzer-fd-use-without-check, -Wanalyzer-fd-use-after-close. gcc/analyzer/ChangeLog: PR analyzer/106003 * analyzer.opt (Wanalyzer-fd-leak): New option. (Wanalyzer-fd-access-mode-mismatch): New option. (Wanalyzer-fd-use-without-check): New option. (Wanalyzer-fd-double-close): New option. (Wanalyzer-fd-use-after-close): New option. * sm.h (make_fd_state_machine): New decl. * sm.cc (make_checkers): Call make_fd_state_machine. * sm-fd.cc: New file. gcc/testsuite/ChangeLog: PR analyzer/106003 * gcc.dg/analyzer/fd-1.c: New test. * gcc.dg/analyzer/fd-2.c: New test. * gcc.dg/analyzer/fd-3.c: New test. * gcc.dg/analyzer/fd-4.c: New test.
2022-06-29docs: remove removed param from documentationMartin Liska1-3/+0
gcc/ChangeLog: * doc/invoke.texi: Remove removed evrp-mode.
2022-06-28testsuite: Add new target check for no_alignment_constraintsDimitar Dimitrov1-0/+9
A few testcases were marked for avr target, which has no alignment requirements. But those tests in fact should filter for any target having __BIGGEST_ALIGNMENT__=1. A new effective target check is introduced: no_alignment_constraints. It checks whether __BIGGEST_ALIGNMENT__ is declared as 1. This change fixes the testsuite cases for PRU target. It was regression-tested on x86_64-pc-linux-gnu. The following two existing macros were considered, but they check for subtly different target behaviour: 1. non_strict_align If true, non-aligned access is permitted. But it also allows variables to be naturally aligned, which is not true for no_alignment_constraints. 2. default_packed Whether structures are packed by default is not necessarily the same as lacking constraints for non-aggregate types. For example, BIGGEST_FIELD_ALIGNMENT or ADJUST_FIELD_ALIGN could be defined for a target as something other than BIGGEST_ALIGNMENT. gcc/ChangeLog: * doc/sourcebuild.texi: Document new no_alignment_constraints effective target check. gcc/testsuite/ChangeLog: * c-c++-common/Wcast-align.c: Silence warnings for targets with no_alignment_constraints. * gcc.dg/c11-align-4.c: Skip for no_alignment_constraints. * gcc.dg/strlenopt-10.c: Replace checks for avr with checks for any target with no_alignment_constraints. * gcc.dg/strlenopt-11.c: Ditto. * gcc.dg/strlenopt-13.c: Ditto. * lib/target-supports.exp (check_effective_target_no_alignment_constraints): New. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2022-06-25Remove long deprecated tilegx and tilepro portsJeff Law4-316/+1
/ * MAINTAINERS: Remove tilegx and tilepro entries. * configure.ac: Remove tilegx and tilepro stanzas. * configure: Rebuilt. contrib/ * config-list.mk: Remove tilegx and tilepro entries. * gcc_update: Remove tilegx and tilepro entries. gcc/ * common/config/tilegx/tilegx-common.cc: Removed. * common/config/tilepro/tilepro-common.cc: Removed. * config.gcc: Remove tilegx and tilepro entries. * config/tilegx/constraints.md: Removed. * config/tilegx/feedback.h: Removed. * config/tilegx/linux.h: Removed. * config/tilegx/mul-tables.cc: Removed. * config/tilegx/predicates.md: Removed. * config/tilegx/sync.md: Removed. * config/tilegx/t-tilegx: Removed. * config/tilegx/tilegx-builtins.h: Removed. * config/tilegx/tilegx-c.cc: Removed. * config/tilegx/tilegx-generic.md: Removed. * config/tilegx/tilegx-modes.def: Removed. * config/tilegx/tilegx-multiply.h: Removed. * config/tilegx/tilegx-opts.h: Removed. * config/tilegx/tilegx-protos.h: Removed. * config/tilegx/tilegx.cc: Removed. * config/tilegx/tilegx.h: Removed. * config/tilegx/tilegx.md: Removed. * config/tilegx/tilegx.opt: Removed. * config/tilepro/constraints.md: Removed. * config/tilepro/feedback.h: Removed. * config/tilepro/gen-mul-tables.cc: Removed. * config/tilepro/linux.h: Removed. * config/tilepro/mul-tables.cc: Removed. * config/tilepro/predicates.md: Removed. * config/tilepro/t-tilepro: Removed. * config/tilepro/tilepro-builtins.h: Removed. * config/tilepro/tilepro-c.cc: Removed. * config/tilepro/tilepro-generic.md: Removed. * config/tilepro/tilepro-modes.def: Removed. * config/tilepro/tilepro-multiply.h: Removed. * config/tilepro/tilepro-protos.h: Removed. * config/tilepro/tilepro.cc: Removed. * config/tilepro/tilepro.h: Removed. * config/tilepro/tilepro.md: Removed. * config/tilepro/tilepro.opt: Removed. * configure.ac: Remove tilegx and tilepro entries. * configure: Rebuilt. * doc/extend.texi: Remove tilegx and tilepro entries. * doc/install.texi: Remove tilegx and tilepro entries. * doc/invoke.texi: Remove tilegx and tilepro entries. * doc/md.texi: Remove tilegx and tilepro entries. gcc/testsuite/ * gcc.dg/lower-subreg-1.c: Remove tilegx and tilepro entries. * gcc.misc-tests/linkage.exp: Remove tilegx and tilepro entries. libgcc/ * config.host: Removed tilegx and tilepro entries. * config/tilegx/sfp-machine.h: Removed. * config/tilegx/sfp-machine32.h: Removed. * config/tilegx/sfp-machine64.h: Removed. * config/tilegx/t-crtstuff: Removed. * config/tilegx/t-softfp: Removed. * config/tilegx/t-tilegx: Removed. * config/tilepro/atomic.c: Removed. * config/tilepro/atomic.h: Removed. * config/tilepro/linux-unwind.h: Removed. * config/tilepro/sfp-machine.h: Removed. * config/tilepro/softdivide.c: Removed. * config/tilepro/softmpy.S: Removed. * config/tilepro/t-crtstuff: Removed. * config/tilepro/t-tilepro: Removed.
2022-06-24c++: Include -Woverloaded-virtual in -Wall [PR87729]Jason Merrill1-1/+25
This seems like a good warning to have in -Wall, as requested. But as pointed out in PR20423, some users want a warning only when a derived function doesn't override any base function. So let's put that lesser version in -Wall (and -Woverloaded-virtual=1) while leaving the semantics for the existing option the same. PR c++/87729 PR c++/20423 gcc/c-family/ChangeLog: * c.opt (Woverloaded-virtual): Add levels, include in -Wall. gcc/ChangeLog: * doc/invoke.texi: Document changes. gcc/cp/ChangeLog: * class.cc (warn_hidden): Handle -Woverloaded-virtual=1. gcc/testsuite/ChangeLog: * g++.dg/warn/Woverloaded-virt1.C: New test. * g++.dg/warn/Woverloaded-virt2.C: New test.
2022-06-23Introduce -nostdlib++ optionAlexandre Oliva1-1/+5
Using g++ to link without libstdc++, as in g++.dg/abi/pure-virtual1.C, is error prone, because there's no way to tell g++ to drop libstdc++ without also dropping libc and any other libraries that the target implicitly links in. This has often led to the need for manual adjustments to this testcase. I figured adding support for -nostdlib++, even though redundant, makes some sense. One could presumably use gcc rather than g++ for linking, for the same effect, but sometimes changing the link command is harder than adding an option, as in our testsuite. Since clang already had an option with this effect, we've adopted the same spelling. for gcc/ChangeLog * common.opt (nostdlib++): New. * doc/invoke.texi (-nostdlib++): Document it. for gcc/cp/ChangeLog * g++spec.cc (lang_specific_driver): Implement -nostdlib++. for gcc/testsuite/ChangeLog * g++.dg/abi/pure-virtual1.C: Use -nostdlib++.