Commit Graph

4 Commits

Author SHA1 Message Date
Jakub Jelinek
07a767c7a5 libcody: Make it buildable by C++11 to C++26
The following builds with -std=c++11 and c++14 and c++17 and c++20 and c++23
and c++26.

I see the u8 string literals are mixed e.g. with strerror, so in
-fexec-charset=IBM1047 there will still be garbage, so am not 100% sure if
the u8 literals everywhere are worth it either.

2025-11-21  Jakub Jelinek  <jakub@redhat.com>

	* cody.hh (S2C): For __cpp_char8_t >= 201811 use char8_t instead of
	char in argument type.
	(MessageBuffer::Space): Revert 2025-11-15 change.
	(MessageBuffer::Append): For __cpp_char8_t >= 201811 add overload
	with char8_t const * type of first argument.
	(Packet::Packet): Similarly for first argument.
	* client.cc (CommunicationError, Client::ProcessResponse,
	Client::Connect, ConnectResponse, PathnameResponse, OKResponse,
	IncludeTranslateResponse): Cast u8 string literals to (const char *)
	where needed.
	* server.cc (Server::ProcessRequests, ConnectRequest): Likewise.
2025-11-21 16:25:58 +01:00
Jakub Jelinek
b4a37c4b8c GCC, meet C++20
I've tried to test a patch to switch -std=gnu++17 C++ default
to -std=gnu++20 (will post momentarily), but ran into various problems
during GCC bootstraps, our codebase isn't fully C++20 ready.

The most common problems are arithmetic or bitwise operations
between enumerators of different enum types (or between enumerator
and floating point in the testsuite), ambiguous overloaded
operator == because of forgotten const qualification of const inside
of the argument and then libcody being largely stuck in C++ and incompatible
with C++20 which introduced char8_t type and uses it for u8 literals.

The following patch fixes various issues I've run into, for libcody
this patch just makes sure code including cody.hh can be compiled
with -std=gnu++20, libcody itself I have a tweak in the other patch.

Nothing in this patch will make the code invalid for C++14.

2025-11-17  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* tree-core.h (enum built_in_function): Avoid arithmetics or
	bitwise operations between enumerators from different enums.
	* lto-streamer.h (lto_tag_is_gimple_code_p): Likewise.
	* gimple.h (gimple_omp_atomic_set_memory_order): Likewise.
	* common/config/i386/i386-cpuinfo.h (M_CPU_SUBTYPE_START,
	M_CPU_TYPE): Likewise.
	* tree-complex.cc (expand_complex_libcall): Likewise.
	* ipa-modref-tree.h (modref_access_node::operator ==): Change
	argument type from modref_access_node & to
	const modref_access_node &.
	* ipa-modref-tree.cc (modref_access_node::operator ==): Likewise.
gcc/cobol/
	* symbols.cc (symbol_table_init): Avoid arithmetics or
	bitwise operations between enumerators from different enums.
gcc/fortran/
	* parse.cc (gfc_parse_file): Avoid arithmetics or
	bitwise operations between enumerators from different enums.
libcody/
	* cody.hh (MessageBuffer::Space): For C++14 or newer use
	(char) u8' ' instead of Detail::S2C(u8" ").
2025-11-17 09:44:05 +01:00
Nathan Sidwell
b7b6879f0b c++: Another solaris header use [PR 98315]
Rather than early-include sys/socket.h, let's allow the includer to
tell cody no networking.

	libcody/
	* cody.hh: Allow user to set CODY_NETWORKING.
	gcc/cp/
	* mapper-resolver.cc: Remove early include of
	sys/socket.h.  Specify no CODY_NETWORKING instead.
	* module.cc: Specify no CODY_NETWORKING.
2020-12-16 11:57:31 -08:00
Nathan Sidwell
362303298a Add libcody
In order to separate compiler from build system, C++ Modules, as
implemented in GCC introduces a communication channel between those
two entities.  This is implemented by libcody.  It is anticipated that
other implementations will also implement this protocol, or use
libcody to provide it.

	* Makefile.def: Add libcody.
	* configure.ac: Add libcody.
	* Makefile.in: Regenerated.
	* configure: Regenerated.
	gcc/
	* Makefile.in (CODYINC, CODYLIB, CODYLIB_H): New. Use them.
	libcody/
	* configure.ac: New.
	* CMakeLists.txt: New.
	* CODING.md: New.
	* CONTRIB.md: New.
	* LICENSE: New.
	* LICENSE.gcc: New.
	* Makefile.in: New.
	* Makesub.in: New.
	* README.md: New.
	* buffer.cc: New.
	* build-aux/config.guess: New.
	* build-aux/config.sub: New.
	* build-aux/install-sh: New.
	* client.cc: New.
	* cmake/libcody-config-ix.cmake
	* cody.hh: New.
	* config.h.in: New.
	* config.m4: New.
	* configure: New.
	* configure.ac: New.
	* dox.cfg.in: New.
	* fatal.cc: New.
	* gdbinit.in: New.
	* internal.hh: New.
	* netclient.cc: New.
	* netserver.cc: New.
	* packet.cc: New.
	* resolver.cc: New.
	* server.cc: New.
	* tests/01-serialize/connect.cc: New.
	* tests/01-serialize/decoder.cc: New.
	* tests/01-serialize/encoder.cc: New.
	* tests/02-comms/client-1.cc: New.
	* tests/02-comms/pivot-1.cc: New.
	* tests/02-comms/server-1.cc: New.
	* tests/Makesub.in: New.
	* tests/jouster: New.
2020-12-15 07:09:59 -08:00