aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-11-16analyzer: split out checker-path.cc into a new checker-event.ccDavid Malcolm3-1149/+1215
gcc/ChangeLog: * Makefile.in (ANALYZER_OBJS): Add analyzer/checker-event.o. gcc/analyzer/ChangeLog: * checker-event.cc: New file, split out from... * checker-path.cc: ...this file. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-16gcc: m68k: fix PR target/107645Max Filippov1-0/+2
gcc/ PR target/107645 * config/m68k/predicates.md (symbolic_operand): Return false when UNSPEC is under the CONST node.
2022-11-16doc: invoke: pru/riscv: Fix option list formattingChristoph Müllner1-3/+3
This patch fixes a wrong placed closing bracket in the RISC-V option list and an unneeded @gol in the PRU option list in invoke.texi. gcc/ChangeLog: * doc/invoke.texi: Fix PRU/RISC-V option list formatting.
2022-11-16c++: Implement CWG 2654 - Un-deprecation of compound volatile assignmentsJakub Jelinek6-32/+19
The following patch implements CWG 2654. 2022-11-16 Jakub Jelinek <jakub@redhat.com> * typeck.cc (cp_build_modify_expr): Implement CWG 2654 - Un-deprecation of compound volatile assignments. Remove -Wvolatile warning about compound volatile assignments. * g++.dg/cpp2a/volatile1.C (fn2, fn3, racoon): Adjust expected diagnostics. * g++.dg/cpp2a/volatile3.C (fn2, fn3, racoon): Likewise. * g++.dg/cpp2a/volatile5.C (f): Likewise. * g++.dg/ext/vector25.C (foo): Don't expect a warning. * g++.dg/cpp1y/new1.C (test_unused): Likewise.
2022-11-16nvptx/mkoffload.cc: Fix "$nohost" checkTobias Burnus1-2/+4
If lhd_set_decl_assembler_name is invoked - in particular if !TREE_PUBLIC (decl) && !DECL_FILE_SCOPE_P (decl) - the '.nohost' suffix might change to '.nohost.2'. This happens for the existing reverse offload testcases via cgraph_node::analyze and is a side effect of r13-3455-g178ac530fe67e4f2fc439cc4ce89bc19d571ca31 for some reason. The solution is to not only check for a tailing '$nohost' but also for '$nohost$' in nvptx/mkoffload.cc. gcc/ChangeLog: * config/nvptx/mkoffload.cc (process): Recognize '$nohost$...' besides tailing '$nohost' as being for reverse offload.
2022-11-16c++: Allow attributes on concepts - DR 2428Jakub Jelinek10-10/+44
The following patch adds parsing of attributes to concept definition, allows deprecated attribute to be specified (as CONCEPT_DECL now needs to be checked in c-family/c-attribs.cc, I had to move its declaration from cp/*.def to c-family/*.def) and checks TREE_DEPRECATED in build_standard_check (not sure if that is the right spot, or whether it shouldn't be checked also for variable and function concepts and how to write testcase coverage for that). 2022-11-16 Jakub Jelinek <jakub@redhat.com> gcc/c-family/ * c-common.def (CONCEPT_DECL): New tree, moved here from cp-tree.def. * c-common.cc (c_common_init_ts): Handle CONCEPT_DECL. * c-attribs.cc (handle_deprecated_attribute): Allow deprecated attribute on CONCEPT_DECL. gcc/cp/ * cp-tree.def (CONCEPT_DECL): Move to c-common.def. * cp-objcp-common.cc (cp_common_init_ts): Don't handle CONCEPT_DECL here. * cp-tree.h (finish_concept_definition): Add ATTRS parameter. * parser.cc (cp_parser_concept_definition): Parse attributes in between identifier and =. Adjust finish_concept_definition caller. * pt.cc (finish_concept_definition): Add ATTRS parameter. Call cplus_decl_attributes. * constraint.cc (build_standard_check): If CONCEPT_DECL is TREE_DEPRECATED, emit -Wdeprecated-declaration warnings. gcc/testsuite/ * g++.dg/cpp2a/concepts-dr2428.C: New test.
2022-11-16ragen-op-float: Fix up float_binary_op_range_finish [PR107668]Jakub Jelinek2-1/+14
The following testcase ICEs, because when !HONOR_NANS but HONOR_SIGNED_ZEROS, if we see lhs = op1 * op2; and know that lhs is [-0.0, 0.0] and op2 is [0.0, 0.0], the division of these two yields UNDEFINED and clear_nan () on it fails an assert. With HONOR_NANS it would actually result in a known NAN, but when NANs aren't honored, we clear the NAN bits. Now, for the above case we actually don't know anything about the op1 range (except that it isn't a NAN/INF because of !HONOR_NANS !HONOR_INFINITIES), so I think the best is just to return VARYING for the case we get UNDEFINED as well. If we want, the op[12]_range methods perhaps can handle the corner cases earlier separately, say for lhs [0.0, 0.0] and op2 [0.0, 0.0] when HONOR_SIGNED_ZEROS this would be just [0.0, MAX]. 2022-11-16 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/107668 * range-op-float.cc (float_binary_op_range_finish): Set VARYING also when r is UNDEFINED. * gcc.dg/ubsan/pr107668.c: New test.
2022-11-16libstdc++: Fix gdb FilteringTypePrinterFrançois Dumont1-35/+49
Once we found a matching FilteringTypePrinter instance we look for the associated typedef and check that the returned Python Type is equal to the Type to recognize. But gdb Python Type includes properties to distinguish a typedef from the actual type. So use gdb.types.get_basic_type to check if we are indeed on the same type. Additionnaly enhance FilteringTypePrinter matching mecanism by introducing targ1 that, if not None, will be used as the 1st template parameter. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (FilteringTypePrinter): Rename 'match' field 'template'. Add self.targ1 to specify the first template parameter of the instantiation to match. (add_one_type_printer): Add targ1 optional parameter, default to None. Use gdb.types.get_basic_type to compare the type to recognize and the type returned from the typedef lookup. (register_type_printers): Adapt calls to add_one_type_printers.
2022-11-15rtl: Try to remove EH edges after {pro,epi}logue generation [PR90259]Kewen Lin2-3/+113
After prologue and epilogue generation, the judgement on whether one memory access onto stack frame may trap or not could change, since we get more exact stack information by now. As PR90259 shows, some memory access becomes impossible to trap any more after prologue and epilogue generation, it can make subsequent optimization be able to remove it if safe, but it results in unexpected control flow status due to REG_EH_REGION note missing. This patch proposes to try to remove EH edges with function purge_all_dead_edges after prologue and epilogue generation, it simplifies CFG as early as we can and don't need any fixup in downstream passes. CFG simplification result with PR90259's case as example: *before* 18: %1:TF=call [`__gcc_qdiv'] argc:0 REG_EH_REGION 0x2 77: NOTE_INSN_BASIC_BLOCK 3 19: NOTE_INSN_DELETED 20: NOTE_INSN_DELETED 110: [%31:SI+0x20]=%1:DF REG_EH_REGION 0x2 116: NOTE_INSN_BASIC_BLOCK 4 111: [%31:SI+0x28]=%2:DF REG_EH_REGION 0x2 22: NOTE_INSN_BASIC_BLOCK 5 108: %0:DF=[%31:SI+0x20] REG_EH_REGION 0x2 117: NOTE_INSN_BASIC_BLOCK 6 109: %1:DF=[%31:SI+0x28] REG_EH_REGION 0x2 79: NOTE_INSN_BASIC_BLOCK 7 26: [%31:SI+0x18]=%0:DF 104: pc=L69 105: barrier *after* 18: %1:TF=call [`__gcc_qdiv'] argc:0 REG_EH_REGION 0x2 77: NOTE_INSN_BASIC_BLOCK 3 19: NOTE_INSN_DELETED 20: NOTE_INSN_DELETED 110: [%31:SI+0x20]=%1:DF 111: [%31:SI+0x28]=%2:DF 108: %0:DF=[%31:SI+0x20] 109: %1:DF=[%31:SI+0x28] 26: [%31:SI+0x18]=%0:DF 104: pc=L69 105: barrier PR rtl-optimization/90259 gcc/ChangeLog: * function.cc (rest_of_handle_thread_prologue_and_epilogue): Add parameter fun, and call function purge_all_dead_edges. (pass_thread_prologue_and_epilogue::execute): Name unamed parameter as fun, and use it for rest_of_handle_thread_prologue_and_epilogue. gcc/testsuite/ChangeLog: * g++.target/powerpc/pr90259.C: New.
2022-11-16Daily bump.GCC Administrator15-1/+482
2022-11-15Rebuilt generated files post merge.Gaius Mulley9-11/+579
Rebuilt configure and Makefile.in after the recent merge. ChangeLog: * Makefile.in: Rebuilt. * configure: Rebuilt. libgm2/ChangeLog: * Makefile.in: Rebuilt. * configure: Rebuilt. * libm2cor/Makefile.in: Rebuilt. * libm2iso/Makefile.in: Rebuilt. * libm2log/Makefile.in: Rebuilt. * libm2min/Makefile.in: Rebuilt. * libm2pim/Makefile.in: Rebuilt. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2022-11-15c++: Disable -Wignored-qualifiers for template args [PR107492]Marek Polacek2-1/+29
It seems wrong to issue a -Wignored-qualifiers warning for code like: static_assert(!is_same_v<void(*)(), const void(*)()>); because there the qualifier matters. Likewise in template specialization: template<typename T> struct S { }; template<> struct S<void(*)()> { }; template<> struct S<const void(*)()> { }; // OK, not a redefinition And likewise in other type-id contexts such as trailing-return-type: auto g() -> const void (*)(); This patch limits the warning to the function declaration context only. PR c++/107492 gcc/cp/ChangeLog: * decl.cc (grokdeclarator): Only emit a -Wignored-qualifiers warning when funcdecl_p. gcc/testsuite/ChangeLog: * g++.dg/warn/Wignored-qualifiers3.C: New test.
2022-11-15RISC-V: Zihintpause: add __builtin_riscv_pausePhilipp Tomsich6-3/+28
The Zihintpause extension uses an opcode from the 'fence' opcode range to add a true hint instruction (i.e. if it is not supported on any given platform, the 'fence' that is encoded will not enforce any specific ordering on memory accesses) for entering a low-power state (e.g. in an idle thread). We expose this new instruction through a machine-dependent builtin to allow generating it without a requirement for any inline assembly. Given that the encoding of 'pause' is valid (as a 'fence' encoding) even for processors that do not (yet) support Zihintpause, we make this builtin available without any further TARGET_* constraints. gcc/ChangeLog: * config/riscv/riscv-builtins.cc (struct riscv_builtin_description): add the pause machine-dependent builtin with no result and no arguments; mark it as always present (pause is a true hint that encodes into a fence-insn, if not supported with the new pause semantics). * config/riscv/riscv-ftypes.def: Add type for void -> void. * config/riscv/riscv.md (riscv_pause): Add risc_pause and UNSPECV_PAUSE * doc/extend.texi: Document __builtin_riscv_pause. * optabs.cc (maybe_gen_insn): Allow nops == 0 (void -> void). gcc/testsuite/ChangeLog: * gcc.target/riscv/builtin_pause.c: New test.
2022-11-15Merge branch 'master' into devel/modula-2Gaius Mulley2183-358562/+215376
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2022-11-15Revert autogenerated files before merge and doc files.Gaius Mulley4-1260/+122
ChangeLog: * Makefile.in: Reverted. gcc/ChangeLog: * configure: Reverted. * doc/install.texi: Reverted. * doc/sourcebuild.texi: Reverted. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2022-11-15Bugfix -fm2-whole-program linking.Gaius Mulley28-323/+749
Linking a project using -fm2-whole-program would fail under the new linking schema. The bugfixes here fix them. The problem was that the naming of the dtor/ctor/init/fini functions (for outer modules) must not get name mangled. Ensure that the special variables exported from M2LINK are only created once. Subsequent attempts return with the existing variables. Also fixed an obvious attribute name. Allow the ZTYPE to be compared to WORD and BYTE without requiring a cast. Definition for "C" no longer automatically implies export unqualified. gcc/m2/ChangeLog: * Make-lang.in (CPP_GM2): Removed. -fpermissive removed. Ensure that M2LINK.o is linked in to stage1/m2/cc1gm2. * gm2-compiler/M2Base.mod: Allow the ZTYPE to be compared to WORD and BYTE without requiring a cast. * gm2-compiler/M2AsmUtil.mod (SymbolTable): Import list added identifiers IsExtern, IsMonoName and IsPublic. (StringToKey): Reformatted. (GetFullScopeAsmName): Rewritten. * gm2-compiler/M2Base.mod: Allow the ZTYPE to be compared to WORD and BYTE without requiring a cast. * gm2-compiler/M2Batch.mod: Improved comment. * gm2-compiler/M2GCCDeclare.def (DeclareM2linkGlobals): Add to export list. * gm2-compiler/M2GCCDeclare.mod: Ensure that DeclareModuleInit is called when -fm2-whole-program is employed. (DoVariableDeclaration) check to see if the special M2LINK variables require an initial value. (AddEntryM2Link) New procedure. (GetEntryM2Link) New procedure function. (DeclareM2linkGlobals) New procedure. (DetectM2LinkInitial) New procedure. (DeclareVariableWholeProgram) Rewritten. (InitM2LinkModule) New procedure. * gm2-compiler/M2GenGCC.mod: Call to DeclareM2linkGlobals change parameters. * gm2-compiler/M2Quad.mod (BuildTry): New procedure. (BuildExcept) New procedure. (BuildM2MainFunction) create try/catch around _M2_init/_M2_fini providing exceptions are allowed. * gm2-compiler/M2Scaffold.mod: Add extra parameter to calls to PutModuleCtorExtern. Call PutMonoName for all init/fini/link/main functions. (initialized) New variable. * gm2-compiler/P1SymBuild.mod: Changed behaviour of definition for "C" to be consistant and the same as the bootstrap tool mc. Definition for "C" no longer automatically implies export unqualified. * gm2-compiler/P2Build.bnf: Corrected ident comparison to unused. * gm2-compiler/SymbolTable.def: New definitions for IsMonoName and PutMonoName. * gm2-compiler/SymbolTable.mod: (IsMonoName) New procedure function. (PutMonoName) New procedure. ctor, init, fini, dep use MonoName as appropriate. (PutModuleCtorExtern): Add new parameter. (MakeProcedure): Initialize IsMonoName. * gm2-gcc/init.cc: Remove declarations for M2LINK variables. * gm2-gcc/m2decl.def (DeclareM2linkForcedModuleInitOrder) New procedure. (DeclareM2linkStaticInitialization) New procedure. (BuildPtrToTypeString) New function. * tools-src/boilerplate.py: Change all double quotes to single quotes. * tools-src/def2doc.py: Change all double quotes to single quotes. gcc/testsuite/gm2/ChangeLog: * calling-c/datatypes/unbounded/run/pass/c.def: Add EXPORT UNQUALIFIED. * examples/callingC/run/pass/c.def: Add EXPORT UNQUALIFIED. * extensions/run/pass/cvararg.def: Add EXPORT UNQUALIFIED. * pim/run/pass/minhello.mod: New file. * switches/check-all/run/fail/tinyrange.mod: New file. * switches/whole-program/pass/run/hello.mod: New file. * switches/whole-program/pass/run/hello2.mod: New file. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2022-11-15bpf: avoid possible use of uninitialized variableDavid Faust1-2/+5
Fix a maybe-uninitialized warning introduced in commit: 068baae1864 bpf: add preserve_field_info builtin gcc/ * config/bpf/bpf.cc (bpf_expand_builtin): Avoid use of uninitialized variable in error case.
2022-11-15analyzer: add warnings relating to sockets [PR106140]David Malcolm30-60/+3007
This patch generalizes the analyzer's file descriptor state machine so that it tracks the states of sockets. It adds two new warnings relating to misuses of socket APIs: * -Wanalyzer-fd-phase-mismatch (e.g. calling 'accept' on a socket before calling 'listen' on it) * -Wanalyzer-fd-type-mismatch (e.g. using a stream socket operation on a datagram socket) gcc/analyzer/ChangeLog: PR analyzer/106140 * analyzer-language.cc (on_finish_translation_unit): Stash named constants "SOCK_STREAM" and "SOCK_DGRAM". * analyzer.opt (Wanalyzer-fd-phase-mismatch): New. (Wanalyzer-fd-type-mismatch): New. * engine.cc (impl_region_model_context::get_state_map_by_name): Add "out_sm_context" param. Allow out_sm_idx to be NULL. * exploded-graph.h (impl_region_model_context::get_state_map_by_name): Add "out_sm_context" param. * region-model-impl-calls.cc (region_model::impl_call_accept): New. (region_model::impl_call_bind): New. (region_model::impl_call_connect): New. (region_model::impl_call_listen): New. (region_model::impl_call_socket): New. * region-model.cc (region_model::on_call_pre): Special-case "bind". (region_model::on_call_post): Special-case "accept", "bind", "connect", "listen", and "socket". * region-model.h (region_model::impl_call_accept): New decl. (region_model::impl_call_bind): New decl. (region_model::impl_call_connect): New decl. (region_model::impl_call_listen): New decl. (region_model::impl_call_socket): New decl. (region_model::on_socket): New decl. (region_model::on_bind): New decl. (region_model::on_listen): New decl. (region_model::on_accept): New decl. (region_model::on_connect): New decl. (region_model::add_constraint): Make public. (region_model::check_for_poison): Make public. (region_model_context::get_state_map_by_name): Add out_sm_context param. (region_model_context::get_fd_map): Likewise. (region_model_context::get_malloc_map): Likewise. (region_model_context::get_taint_map): Likewise. (noop_region_model_context::get_state_map_by_name): Likewise. (region_model_context_decorator::get_state_map_by_name): Likewise. * sm-fd.cc: Include "analyzer/supergraph.h" and "analyzer/analyzer-language.h". (enum expected_phase): New enum. (fd_state_machine::m_new_datagram_socket): New. (fd_state_machine::m_new_stream_socket): New. (fd_state_machine::m_new_unknown_socket): New. (fd_state_machine::m_bound_datagram_socket): New. (fd_state_machine::m_bound_stream_socket): New. (fd_state_machine::m_bound_unknown_socket): New. (fd_state_machine::m_listening_stream_socket): New. (fd_state_machine::m_m_connected_stream_socket): New. (fd_state_machine::m_SOCK_STREAM): New. (fd_state_machine::m_SOCK_DGRAM): New. (fd_diagnostic::describe_state_change): Handle socket states. (fd_diagnostic::get_meaning_for_state_change): Likewise. (class fd_phase_mismatch): New. (enum expected_type): New enum. (class fd_type_mismatch): New. (fd_state_machine::fd_state_machine): Initialize new states and stashed named constants. (fd_state_machine::is_socket_fd_p): New. (fd_state_machine::is_datagram_socket_fd_p): New. (fd_state_machine::is_stream_socket_fd_p): New. (fd_state_machine::on_close): Handle the socket states. (fd_state_machine::check_for_open_fd): Complain about fncalls on sockets in the wrong phase. Support socket FDs. (add_constraint_ge_zero): New. (fd_state_machine::get_state_for_socket_type): New. (fd_state_machine::on_socket): New. (fd_state_machine::check_for_socket_fd): New. (fd_state_machine::check_for_new_socket_fd): New. (fd_state_machine::on_bind): New. (fd_state_machine::on_listen): New. (fd_state_machine::on_accept): New. (fd_state_machine::on_connect): New. (fd_state_machine::can_purge_p): Don't purge socket values. (get_fd_state): New. (region_model::mark_as_valid_fd): Use get_fd_state. (region_model::on_socket): New. (region_model::on_bind): New. (region_model::on_listen): New. (region_model::on_accept): New. (region_model::on_connect): New. * sm-fd.dot: Update to reflect sm-fd.cc changes. gcc/ChangeLog: PR analyzer/106140 * doc/invoke.texi (Static Analyzer Options): Add -Wanalyzer-fd-phase-mismatch and -Wanalyzer-fd-type-mismatch. Add "socket", "bind", "listen", "accept", and "connect" to the list of functions known to the analyzer. gcc/testsuite/ChangeLog: PR analyzer/106140 * gcc.dg/analyzer/fd-accept.c: New test. * gcc.dg/analyzer/fd-bind.c: New test. * gcc.dg/analyzer/fd-connect.c: New test. * gcc.dg/analyzer/fd-datagram-socket.c: New test. * gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c: New test. * gcc.dg/analyzer/fd-glibc-byte-stream-socket.c: New test. * gcc.dg/analyzer/fd-glibc-datagram-client.c: New test. * gcc.dg/analyzer/fd-glibc-datagram-socket.c: New test. * gcc.dg/analyzer/fd-glibc-make_named_socket.h: New test. * gcc.dg/analyzer/fd-listen.c: New test. * gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c: New test. * gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c: New test. * gcc.dg/analyzer/fd-socket-meaning.c: New test. * gcc.dg/analyzer/fd-socket-misuse.c: New test. * gcc.dg/analyzer/fd-stream-socket-active-open.c: New test. * gcc.dg/analyzer/fd-stream-socket-passive-open.c: New test. * gcc.dg/analyzer/fd-stream-socket.c: New test. * gcc.dg/analyzer/fd-symbolic-socket.c: New test. * gcc.dg/analyzer/pr104369-1.c: Add -Wno-analyzer-too-complex and -Wno-analyzer-fd-leak to options. * gcc.dg/analyzer/pr104369-2.c: Add -Wno-analyzer-fd-leak to options. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-15c, analyzer: support named constants in analyzer [PR106302]David Malcolm21-10/+513
The analyzer's file-descriptor state machine tracks the access mode of opened files, so that it can emit -Wanalyzer-fd-access-mode-mismatch. To do this, its symbolic execution needs to "know" the values of the constants "O_RDONLY", "O_WRONLY", and "O_ACCMODE". Currently analyzer/sm-fd.cc simply uses these values directly from the build-time header files, but these are the values on the host, not those from the target, which could be different (PR analyzer/106302). In an earlier discussion of this issue: https://gcc.gnu.org/pipermail/gcc/2022-June/238954.html we talked about adding a target hook for this. However, I've also been experimenting with extending the fd state machine to track sockets (PR analyzer/106140). For this, it's useful to "know" the values of the constants "SOCK_STREAM" and "SOCK_DGRAM". Unfortunately, these seem to have many arbitrary differences from target to target. For example: Linux/glibc general has SOCK_STREAM == 1, SOCK_DGRAM == 2, as does AIX, but annoyingly, e.g. Linux on MIPS has them the other way around. It seems to me that as the analyzer grows more ambitious modeling of the behavior of APIs (perhaps via plugins) it's more likely that the analyzer will need to know the values of named constants, which might not even exist on the host. For example, at LPC it was suggested to me that -fanalyzer could check rules about memory management inside the Linux kernel (probably via a plugin), but doing so involves a bunch of GFP_* flags (see PR 107472). So rather than trying to capture all this knowledge in a target hook, this patch attempts to get at named constant values from the user's source code. The patch adds an interface for frontends to call into the analyzer as the translation unit finishes. The analyzer can then call back into the frontend to ask about the values of the named constants it cares about whilst the frontend's data structures are still around. The patch implements this for the C frontend, which looks up the names by looking for named CONST_DECLs (which handles enum values). Failing that, it attempts to look up the values of macros but only the simplest cases are supported (a non-traditional macro with a single CPP_NUMBER token). It does this by building a buffer containing the macro definition and rerunning a lexer on it. The analyzer gracefully handles the cases where named values aren't found (such as anything more complicated than described above). The patch ports the analyzer to use this mechanism for "O_RDONLY", "O_WRONLY", and "O_ACCMODE". I have successfully tested my socket patch to also use this for "SOCK_STREAM" and "SOCK_DGRAM", so the technique seems to work. gcc/ChangeLog: PR analyzer/106302 * Makefile.in (ANALYZER_OBJS): Add analyzer/analyzer-language.o. (GTFILES): Add analyzer/analyzer-language.cc. * doc/analyzer.texi: Document __analyzer_dump_named_constant. gcc/analyzer/ChangeLog: PR analyzer/106302 * analyzer-language.cc: New file. * analyzer-language.h: New file. * analyzer.h (get_stashed_constant_by_name): New decl. (log_stashed_constants): New decl. * engine.cc (impl_run_checkers): Call log_stashed_constants. * region-model-impl-calls.cc (region_model::impl_call_analyzer_dump_named_constant): New. * region-model.cc (region_model::on_stmt_pre): Handle __analyzer_dump_named_constant. * region-model.h (region_model::impl_call_analyzer_dump_named_constant): New decl. * sm-fd.cc (fd_state_machine::m_O_ACCMODE): New. (fd_state_machine::m_O_RDONLY): New. (fd_state_machine::m_O_WRONLY): New. (fd_state_machine::fd_state_machine): Initialize the new fields. (fd_state_machine::get_access_mode_from_flag): Use the new fields, rather than using the host values. gcc/c/ChangeLog: PR analyzer/106302 * c-parser.cc: Include "analyzer/analyzer-language.h" and "toplev.h". (class ana::c_translation_unit): New. (c_parser_translation_unit): Call ana::on_finish_translation_unit. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/analyzer-decls.h (__analyzer_dump_named_constant): New decl. * gcc.dg/analyzer/fd-4.c (void): Likewise. (O_ACCMODE): Define. * gcc.dg/analyzer/fd-access-mode-enum.c: New test, based on . * gcc.dg/analyzer/fd-5.c: ...this. Rename to... * gcc.dg/analyzer/fd-access-mode-macros.c: ...this. (O_ACCMODE): Define. * gcc.dg/analyzer/fd-access-mode-target-headers.c: New test, also based on fd-5.c. (test_sm_fd_constants): New. * gcc.dg/analyzer/fd-dup-1.c (O_ACCMODE): Define. * gcc.dg/analyzer/named-constants-via-enum.c: New test. * gcc.dg/analyzer/named-constants-via-enum-and-macro.c: New test. * gcc.dg/analyzer/named-constants-via-macros-2.c: New test. * gcc.dg/analyzer/named-constants-via-macros.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-15demangler: Templated lambda demanglingNathan Sidwell3-24/+295
Templated lambdas have a template-head, which is part of their signature. GCC ABI 18 mangles that into the lambda name. This adds support to the demangler. We have to introduce artificial template parameter names, as we need to refer to them from later components of the lambda signature. We use $T:n, $N:n and $TT:n for type, non-type and template parameters. Non-type parameter names are not shown in the strictly correct location -- for instance 'int (&NT) ()' would be shown as 'int (&) $N:n'. That's unfortunate, but an orthogonal issue. The 'is_lambda_arg' field is now repurposed as indicating the number of explicit template parameters (1-based). include/ * demangle.h (enum demangle_component_type): Add DEMANGLE_COMPONENT_TEMPLATE_HEAD, DEMANGLE_COMPONENT_TEMPLATE_TYPE_PARM, DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM, DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM, DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM. libiberty/ * cp-demangle.c (struct d_print_info): Rename is_lambda_arg to lambda_tpl_parms. Augment semantics. (d_make_comp): Add checks for new components. (d_template_parm, d_template_head): New. (d_lambda): Add templated lambda support. (d_print_init): Adjust. (d_print_lambda_parm_name): New. (d_print_comp_inner): Support templated lambdas, * testsuite/demangle-expected: Add testcases.
2022-11-15diagnostics: Remove null-termination requirement for json::stringLewis Hyatt2-4/+24
json::string currently handles null-terminated data and so can't work with data that may contain embedded null bytes or that is not null-terminated. Supporting such data will make json::string more robust in some contexts, such as SARIF output, which uses it to output user source code that may contain embedded null bytes. gcc/ChangeLog: * json.h (class string): Add M_LEN member to store the length of the data. Add constructor taking an explicit length. * json.cc (string::string): Implement the new constructor. (string::print): Support printing strings that are not null-terminated. Escape embdedded null bytes on output. (test_writing_strings): Test the new null-byte-related features of json::string.
2022-11-15diagnostics: Use an inline function rather than hardcoding <built-in> stringLewis Hyatt7-8/+17
The string "<built-in>" is hard-coded in several places throughout the diagnostics code, and in some of those places, it is used incorrectly with respect to internationalization. (Comparing a translated string to an untranslated string.) The error is not currently observable in any output GCC actually produces, hence no testcase added here, but it's worth fixing, and also, I am shortly going to add a new such string and want to avoid hardcoding that one in similar places. gcc/c-family/ChangeLog: * c-opts.cc (c_finish_options): Use special_fname_builtin () rather than a hard-coded string. gcc/ChangeLog: * diagnostic.cc (diagnostic_get_location_text): Use special_fname_builtin () rather than a hardcoded string (which was also incorrectly left untranslated previously.) * input.cc (special_fname_builtin): New function. (expand_location_1): Use special_fname_builtin () rather than a hard-coded string. (test_builtins): Likewise. * input.h (special_fname_builtin): Declare. gcc/fortran/ChangeLog: * cpp.cc (gfc_cpp_init): Use special_fname_builtin () rather than a hardcoded string (which was also incorrectly left untranslated previously.) * error.cc (gfc_diagnostic_build_locus_prefix): Likewise. * f95-lang.cc (gfc_init): Likewise.
2022-11-15diagnostics: Fix macro tracking for ad-hoc locationsLewis Hyatt2-2/+9
The result of linemap_resolve_location() can be an ad-hoc location, if that is what was stored in a relevant macro map. maybe_unwind_expanded_macro_loc() did not previously handle this case, causing it to print the wrong tracking information for an example such as the new testcase macro-trace-1.c. Fix that by checking for ad-hoc locations where needed. gcc/ChangeLog: * tree-diagnostic.cc (maybe_unwind_expanded_macro_loc): Handle ad-hoc location in return value of linemap_resolve_location(). gcc/testsuite/ChangeLog: * c-c++-common/cpp/macro-trace-1.c: New test.
2022-11-15libsanitizer: update LOCAL_PATCHESMartin Liska1-2/+1
libsanitizer/ChangeLog: * LOCAL_PATCHES: Update local patches.
2022-11-15asan: update expected format based on ASANMartin Liska10-42/+42
gcc/testsuite/ChangeLog: * c-c++-common/asan/global-overflow-1.c: Update expected format. * c-c++-common/asan/heap-overflow-1.c: Likewise. * c-c++-common/asan/strlen-overflow-1.c: Likewise. * c-c++-common/asan/strncpy-overflow-1.c: Likewise. * c-c++-common/hwasan/heap-overflow.c: Likewise. * g++.dg/asan/asan_mem_test.cc: Likewise. * g++.dg/asan/asan_oob_test.cc: Likewise. * g++.dg/asan/asan_str_test.cc: Likewise. * g++.dg/asan/asan_test.cc: Likewise. * g++.dg/asan/large-func-test-1.C: Likewise.
2022-11-15libsanitizer: Apply local patchesMartin Liska14-81/+94
2022-11-15libsanitizer: merge from upstream ae59131d3ef311fb4b1e50627c6457be00e60dc9Martin Liska45-251/+523
2022-11-15libatomic: Add support for LSE and LSE2Wilco Dijkstra5-18/+527
Add support for AArch64 LSE and LSE2 to libatomic. Disable outline atomics, and use LSE ifuncs for 1-8 byte atomics and LSE2 ifuncs for 16-byte atomics. On Neoverse V1, 16-byte atomics are ~4x faster due to avoiding locks. Note this is safe since we swap all 16-byte atomics using the same ifunc, so they either use locks or LSE2 atomics, but never a mix. This also improves ABI compatibility with LLVM: its inlined 16-byte atomics are compatible with the new libatomic if LSE2 is supported. libatomic/ * Makefile.in: Regenerated with automake 1.15.1. * Makefile.am: Add atomic_16.S for AArch64. * configure.tgt: Disable outline atomics in AArch64 build. * config/linux/aarch64/atomic_16.S: New file - implementation of ifuncs for 16-byte atomics. * config/linux/aarch64/host-config.h: Enable ifuncs, use LSE (HWCAP_ATOMICS) for 1-8-byte atomics and LSE2 (HWCAP_USCAT) for 16-byte atomics.
2022-11-15c++: remove i_c_e_p parm from tsubst_copy_and_buildPatrick Palka8-185/+94
It seems the only and original purpose of tsubst_copy_and_build's integral_constant_expression_p boolean parameter (added in r116276, which predates the constexpr machinery) is to diagnose certain constructs that aren't allowed to appear in a C++98 integral constant expression context, specifically casts to a non-integral type (diagnosed from the *_CAST_EXPR case of tsubst_copy_and_build) or dependent names that resolve to a non-constant decl (diagnosed from the IDENTIFIER_NODE case of tsubst_copy_and_build). The parameter has no effect outside of C++98 AFAICT. But diagnosing such constructs should arguably be the job of the constexpr machinery (e.g. is_constant_expression) after substitution, and doing it during substitution by way of an additional parameter complicates the API of this workhorse function for what amounts to a couple of archaic C++98 restrictions. And it seems is_constant_expression already does a good job of diagnosing the aforementioned two constructs in C++98 mode, at least as far as our testsuite is concerned. So this patch removes this parameter from tsubst_copy_and_build, tsubst_expr and tsubst_copy_and_build_call_args. The only interesting changes are to potential_constant_expression_1 and the IDENTIFIER_NODE and *_CAST_EXPR cases of tsubst_copy_and_build; the rest are mechanical adjustments to the functions' signatures and their call sites. gcc/cp/ChangeLog: * constexpr.cc (potential_constant_expression_1) <case *_CAST_EXPR>: Use cast_valid_in_integral_constant_expression_p instead of open coding it. * constraint.cc (tsubst_valid_expression_requirement): Adjust calls to tsubst_copy_and_build and tsubst_expr. (tsubst_constraint): Likewise. (satisfy_atom): Likewise. (diagnose_trait_expr): Likewise. * cp-tree.h (tsubst_copy_and_build): Remove i_c_e_p parameter. (tsubst_expr): Likewise. * init.cc (get_nsdmi): Adjust calls to tsubst_copy_and_build and tsubst_expr. * pt.cc (expand_integer_pack): Likewise. (instantiate_non_dependent_expr_internal): Likewise. (tsubst_friend_function): Likewise. (tsubst_attribute): Likewise. (instantiate_class_template): Likewise. (tsubst_template_arg): Likewise. (gen_elem_of_pack_expansion_instantiation): Likewise. (tsubst_fold_expr_init): Likewise. (tsubst_pack_expansion): Likewise. (tsubst_default_argument): Likewise. (tsubst_function_decl): Likewise. (tsubst_decl): Likewise. (tsubst_arg_types): Likewise. (tsubst_exception_specification): Likewise. (tsubst): Likewise. (tsubst_init): Likewise. (tsubst_copy): Likewise. (tsubst_omp_clause_decl): Likewise. (tsubst_omp_clauses): Likewise. (tsubst_copy_asm_operands): Likewise. (tsubst_omp_for_iterator): Likewise. (tsubst_expr): Likewise. Remove i_c_e_p parameter. (tsubst_omp_udr): Likewise. (tsubst_non_call_postfix_expression): Likewise. Remove i_c_e_p parameter. (tsubst_lambda_expr): Likewise. (tsubst_copy_and_build_call_args): Likewise. (tsubst_copy_and_build): Likewise. Remove i_c_e_p parameter. <case IDENTIFIER_NODE>: Adjust call to finish_id_expression following removal of i_c_e_p. <case *_CAST_EXPR>: Remove C++98-specific cast validity check guarded by i_c_e_p. (maybe_instantiate_noexcept): Adjust calls to tsubst_copy_and_build and tsubst_expr. (instantiate_body): Likewise. (instantiate_decl): Likewise. (tsubst_initializer_list): Likewise. (tsubst_enum): Likewise. gcc/objcp/ChangeLog: * objcp-lang.cc (objcp_tsubst_copy_and_build): Adjust calls to tsubst_copy_and_build and tsubst_expr. gcc/testsuite/ChangeLog: * g++.dg/template/crash55.C: Don't expect additional C++98-specific diagnostics. * g++.dg/template/ref3.C: Remove C++98-specific xfail.
2022-11-15c++: remove function_p parm from tsubst_copy_and_buildPatrick Palka6-42/+19
The function_p parameter of tsubst_copy_and_build (added in r69316) is inspected only in its IDENTIFIER_NODE case, where it controls whether we diagnose unqualified name lookup failure for the given identifier. But I think ever since r173965, we never substitute an IDENTIFIER_NODE with function_p=true for which the lookup can possibly fail, and therefore the flag is effectively unneeded. Before that commit, we would incorrectly repeat unqualified lookup for an ADL-enabled CALL_EXPR at instantiation time, which naturally could fail and thus motivated the flag. Afterwards, we no longer substitute an IDENTIFIER_NODE callee when koenig_p is true, so the flag isn't needed for its original purpose. What about when koenig_p=false? Apparently we still may have an IDENTIFIER_NODE callee in this case, namely when unqualified name lookup found a dependent local function declaration, but repeating that lookup can't fail (ditto for USING_DECL callees). So this patch removes this effectively unneeded parameter from tsubst_copy_and_build. It also updates an outdated comment in the CALL_EXPR case about when we may see an IDENTIFIER_NODE callee with koenig_p=false. gcc/cp/ChangeLog: * cp-lang.cc (objcp_tsubst_copy_and_build): Remove function_p parameter. * cp-objcp-common.h (objcp_tsubst_copy_and_build): Likewise. * cp-tree.h (tsubst_copy_and_build): Likewise. * init.cc (get_nsdmi): Adjust calls to tsubst_copy_and_build. * pt.cc (expand_integer_pack): Likewise. (instantiate_non_dependent_expr_internal): Likewise. (tsubst_function_decl): Likewise. (tsubst_arg_types): Likewise. (tsubst_exception_specification): Likewise. (tsubst): Likewise. (tsubst_copy_asm_operands): Likewise. (tsubst_expr): Likewise. (tsubst_non_call_postfix_expression): Likewise. (tsubst_lambda_expr): Likewise. (tsubst_copy_and_build_call_args): Likewise. (tsubst_copy_and_build): Remove function_p parameter and adjust function comment. Adjust recursive calls. <case CALL_EXPR>: Update outdated comment about when we can see an IDENTIFIER_NODE callee with koenig_p=false. (maybe_instantiate_noexcept): Adjust calls to tsubst_copy_and_build. gcc/objcp/ChangeLog: * objcp-lang.cc (objcp_tsubst_copy_and_build): Remove function_p parameter.
2022-11-15libstdc++: Fix std::format test for strict -std=c++20 modeJonathan Wakely1-3/+4
Adjust a test to avoid using std::make_unsigned_t<__int128>. That's ill-formed in strict modes because std::is_integral_v<__int128> is false. libstdc++-v3/ChangeLog: * testsuite/std/format/functions/format.cc: Do not use std::make_unsigned_t<__int128>.
2022-11-15Bugfix for tiny modules importing from definition for "C".Gaius Mulley1-2/+38
If a tiny application module imports only from a definition for "C" the import graph will not join with the core modula-2 libraries. Thus if a range exception were to occur in the application the libraries might be uninitialized. This patch forces the application module to be initialized last. gcc/m2/ChangeLog: * gm2-libs/M2Dependent.mod (DisplayModuleInfo): Use variable count to display entry number. (CheckApplication) Check that the application is the last entry in the list and move the list head if appropriate. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2022-11-15libstc++: std::formattable concept should not be defined for C++20Jonathan Wakely4-46/+77
This concept was added by a C++23 proposal, so don't define it for C++20. Split the format/formatter/formatter.cc test into two parts, one that tests the C++20 requirements and one that tests the C++23 concept. libstdc++-v3/ChangeLog: * include/std/format (formattable): Only define for C++23/ * testsuite/std/format/formatter.cc: Moved to... * testsuite/std/format/formatter/requirements.cc: ...here. * testsuite/std/format/formatter/concept.cc: New test. * testsuite/std/format/functions/format.cc: Replace use of std::formattable in C++20.
2022-11-15libstdc++: Fix detection of std::format support for __float128 [PR107693]Jonathan Wakely2-37/+58
std::format gives linker errors on targets that define __float128 but do not support using it with std::to_chars. This improves the handling of 128-bit flaoting-point types so they are disabled if unsupportable. libstdc++-v3/ChangeLog: PR libstdc++/107693 * include/std/format (_GLIBCXX_FORMAT_F128): Define to 2 when basic_format_arg needs to use its _M_f128 member. (__extended_floating_point, __floating_point): Replace with ... (__formattable_floating_point): New concept. * testsuite/std/format/functions/format.cc: Check whether __float128 is supported. Also test _Float128.
2022-11-15libsanitizer: use git clone --depth 1Martin Liska1-1/+1
Using depth == 1 it makes the cloning much faster. libsanitizer/ChangeLog: * merge.sh: Use git clone --depth 1.
2022-11-15Revert "docs: Fix expected diagnostics URL [PR107599]"Martin Liska5-5/+5
This reverts commit f94c2eff6b0e000ee2feadedf354590958308760.
2022-11-15libstdc++: Document use of Markdown for Doxygen commentsJonathan Wakely2-15/+34
libstdc++-v3/ChangeLog: * doc/xml/manual/documentation_hacking.xml: Document use of Markdown for Doxygen comments. Tweak formatting. * doc/html/manual/documentation_hacking.html: Regenerate.
2022-11-15doc: Format region pragmas as separate itemsJonathan Wakely1-1/+2
This seems consistent with how other paired pragmas are documented in texinfo, e.g. push_options and pop_options. gcc/ChangeLog: * doc/cpp.texi (Pragmas): Use @item and @itemx for region pragmas.
2022-11-15ira: Remove duplicate `memset' over `full_costs' from `assign_hard_reg'Maciej W. Rozycki1-1/+0
Remove duplicate clearing of `full_costs' made in `assign_hard_reg', which has been there since the beginning, i.e. commit 058e97ecf33a ("IRA has been merged into trunk"), <https://gcc.gnu.org/ml/gcc-patches/2008-08/msg01932.html>. gcc/ * ira-color.cc (assign_hard_reg): Remove duplicate `memset' over `full_costs'.
2022-11-15aarch64: Add support for widening LDAPR instructionsAndre Vieira2-0/+116
gcc/ChangeLog: * config/aarch64/atomics.md (*aarch64_atomic_load<ALLX:mode>_rcpc_zext): New pattern. (*aarch64_atomic_load<ALLX:mode>_rcpc_sext): New pattern. gcc/testsuite/ChangeLog: * gcc.target/aarch64/ldapr-ext.c: New test.
2022-11-15aarch64: Enable the use of LDAPR for load-acquire semanticsAndre Vieira5-4/+74
This patch enables the use of LDAPR for load-acquire semantics. 2022-11-15 Andre Vieira <andre.simoesdiasvieira@arm.com> Kyrylo Tkachov <kyrylo.tkachov@arm.com> gcc/ChangeLog: * config/aarch64/aarch64.h (AARCH64_ISA_RCPC): New Macro. (TARGET_RCPC): New Macro. * config/aarch64/atomics.md (atomic_load<mode>): Change into an expand. (aarch64_atomic_load<mode>_rcpc): New define_insn for ldapr. (aarch64_atomic_load<mode>): Rename of old define_insn for ldar. * config/aarch64/iterators.md (UNSPEC_LDAP): New unspec enum value. * doc/invoke.texi (rcpc): Ammend documentation to mention the effects on code generation. gcc/testsuite/ChangeLog: * gcc.target/aarch64/ldapr.c: New test.
2022-11-15gcc-changelog: revert temporary rule relaxationMartin Liska1-2/+0
contrib/ChangeLog: * gcc-changelog/git_commit.py: Revert temporary rule relaxation.
2022-11-15Daily bump.GCC Administrator20-1/+5762
2022-11-15c++: Fix a typo in function nameJakub Jelinek3-4/+4
I've noticed I've made a typo in the name of the function. Fixed thusly. 2022-11-15 Jakub Jelinek <jakub@redhat.com> * cp-tree.h (next_common_initial_seqence): Rename to ... (next_common_initial_sequence): ... this. * typeck.cc (next_common_initial_seqence): Rename to ... (next_common_initial_sequence): ... this. (layout_compatible_type_p): Call next_common_initial_sequence rather than next_common_initial_seqence. * semantics.cc (is_corresponding_member_aggr): Likewise.
2022-11-15libatomic: Handle AVX+CX16 AMD like Intel for 16b atomics [PR104688]Jakub Jelinek1-2/+4
We got a response from AMD in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104688#c10 so the following patch starts treating AMD with AVX and CMPXCHG16B ISAs like Intel by using vmovdqa for atomic load/store in libatomic. We still don't have confirmation from Zhaoxin and VIA (anything else with CPUs featuring AVX and CX16?). 2022-11-15 Jakub Jelinek <jakub@redhat.com> PR target/104688 * config/x86/init.c (__libat_feat1_init): Don't clear bit_AVX on AMD CPUs.
2022-11-15c++: Add testcase for DR 2392Jakub Jelinek1-0/+12
The testcase from DR 2392 passes, so I assume we don't need to do anything further for the DR. 2022-11-15 Jakub Jelinek <jakub@redhat.com> * g++.dg/DRs/dr2392.C: Add testcase for DR 2392.
2022-11-15c++: Implement C++23 P2589R1 - - static operator[]Jakub Jelinek6-47/+97
Here is a patch that implements the static operator[] paper. One thing that doesn't work properly is the same problem as I've filed yesterday for static operator() - PR107624 - that side-effects of the postfix-expression on which the call or subscript operator are applied are thrown away, I assume we have to add them into COMPOUND_EXPR somewhere after we find out that the we've chosen a static member function operator. 2022-11-15 Jakub Jelinek <jakub@redhat.com> gcc/c-family/ * c-cppbuiltin.cc (c_cpp_builtins): Bump C++23 __cpp_multidimensional_subscript macro value to 202211L. gcc/cp/ * decl.cc (grok_op_properties): Implement C++23 P2589R1 - static operator[]. Handle operator[] similarly to operator() - allow static member functions, but pedwarn on it for C++20 and older. Unlike operator(), perform rest of checks on it though for C++20. * call.cc (add_operator_candidates): For operator[] with class typed first parameter, pass that parameter as first_arg and an adjusted arglist without that parameter. gcc/testsuite/ * g++.dg/cpp23/subscript9.C: New test. * g++.dg/cpp23/feat-cxx2b.C: Expect a newer __cpp_multidimensional_subscript value. * g++.old-deja/g++.bugs/900210_10.C: Don't expect an error for C++23 or later.
2022-11-15c++: Add testcase for DR 2604Jakub Jelinek1-0/+53
As the following testcase shows, I think we don't inherit template's attributes into specializations. 2022-11-15 Jakub Jelinek <jakub@redhat.com> * g++.dg/DRs/dr2604.C: New test.
2022-11-15Optimize VEC_PERM_EXPR with same permutation index and operationHongyu Wang2-0/+98
The sequence c1 = VEC_PERM_EXPR (a, a, mask) c2 = VEC_PERM_EXPR (b, b, mask) c3 = c1 op c2 can be optimized to c = a op b c3 = VEC_PERM_EXPR (c, c, mask) for all integer vector operation, and float operation with full permutation. gcc/ChangeLog: PR target/98167 * match.pd: New perm + vector op patterns for int and fp vector. gcc/testsuite/ChangeLog: PR target/98167 * gcc.target/i386/pr98167.c: New test.
2022-11-15Remove Score documentationAndrew Pinski1-52/+0
Score target support was removed in r5-3909-g3daa7bbf791203 but it looks like some of the documentation was missed. This removes it. Committed as obvious after a "make html". Thanks, Andrew gcc/ChangeLog: * doc/invoke.texi: Remove Score option section.