Commit Graph

135 Commits

Author SHA1 Message Date
GCC Administrator
2d14d64bf2 Daily bump. 2021-08-18 00:16:48 +00:00
Iain Sandoe
b240450b63 Darwin, libcc1: Handle hosts with mdynamic-no-pic support.
The default for building host-side binaries for mdynamic-no-pic
hosts is to enable this.  However, it is not compatible with
dynamic libraries, so must be switched off for libcc1.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

libcc1/ChangeLog:

	* Makefile.am: Switch mdynamic-no-pic to fPIC.
	* Makefile.in: Regenerated.
2021-08-17 20:03:56 +01:00
GCC Administrator
c8abc2058e Daily bump. 2021-06-29 00:16:42 +00:00
Martin Sebor
3f44889076 libcc1: Add support for per-location warning groups.
libcc1/ChangeLog:

	* libcp1plugin.cc (record_decl_address): Replace a direct use
	of TREE_NO_WARNING with suppress_warning.
2021-06-28 15:09:46 -06:00
GCC Administrator
449480114a Daily bump. 2021-05-06 00:16:37 +00:00
Tom Tromey
61d48b1e2b libcc1: avoid a call to c_str
This is a trivial change to libcc1 to avoid an explicit call to c_str.
Passing by const reference is slightly less wordy.

libcc1

	* compiler.cc (make_regexp): Take const std::string.
	(cc1_plugin::compiler_triplet_regexp::find): Update.
2021-05-05 00:08:52 -06:00
Tom Tromey
96deddca2e libcc1: avoid extra string copies
PR c/94669 points out that a couple of spots in libcc1 take a
std::string where a reference would do.  This changes these spots to
take a const char *, to reduce the number of copies.

libcc1

	PR c/94669
	* compiler.hh (compiler_driver_filename): Take const char *.
	(compiler_triplet_regexp): Likewise.
2021-05-05 00:08:34 -06:00
Tom Tromey
8fdffa48c5 libcc1: use variadic templates for callbacks
This patch completes the transition of libcc1 from the use of separate
template functions for different arities to the use of variadic
functions.  This is how I had wanted it to work from the very
beginning, and is possible now with C++11.

I had thought that variadic callbacks required C++17, but it turns out
that the approach taken here is basically equivalent to std::apply --
just a bit wordier.

libcc1

	* rpc.hh (argument_wrapper) <get>: Replace cast operator.
	(argument_wrapper<T *>) <get>: Likewise.
	(unmarshall): Add std::tuple overloads.
	(callback): Remove.
	(class invoker): New.
	* libcp1plugin.cc (plugin_init): Update.
	* libcp1.cc (libcp1::add_callbacks): Update.
	* libcc1plugin.cc (plugin_init): Update.
	* libcc1.cc (libcc1::add_callbacks): Update.
	* connection.cc (cc1_plugin::connection::do_wait): Update.
2021-05-05 00:06:18 -06:00
Tom Tromey
ee75ca6b72 libcc1: fix a memory leak
libcc1 has a memory leak when calling fork_exec -- it allocates a new
vector of arguments, but then does not free it anywhere.  This patch
changes this code to use std::vector instead.

Note that the previous code tried to avoid bad_alloc.  I don't believe
this is very important.  For one thing, plenty of other allocations do
not bother with this.

libcc1

	* gdbctx.hh (do_compile): Use std::vector.
2021-05-05 00:06:18 -06:00
Tom Tromey
a8deb8323b libcc1: share the GCC interface code
Both the C and C++ side of the GDB plugin in libcc1 share a lot of
code relating to the base GCC interface.  It was all copy-and-pasted,
but is essentially identical between the two.  This is by design, as
the base GCC API is intended to be shared.

This patch merges the implementations into base_gdb_plugin, which was
introduced earlier for this purpose.

libcc1

	* libcp1.cc (libcp1): Change parameters.  Update.
	(libcp1_set_verbose, libcp1_set_arguments)
	(libcp1_set_triplet_regexp, libcp1_set_driver_filename)
	(libcp1_set_source_file, libcp1_set_print_callback, fork_exec)
	(libcp1_compile, libcp1_destroy, vtable): Remove.
	(libcp1::add_callbacks): New method, extracted from
	libcp1_compile.
	(gcc_c_fe_context): Update.
	* libcc1.cc (libcc1): Change parameters.  Update.
	(libcc1_set_verbose, libcc1_set_arguments)
	(libcc1_set_triplet_regexp, libcc1_set_driver_filename)
	(libcc1_set_source_file, libcc1_set_print_callback, fork_exec)
	(libcc1_compile, libcc1_destroy, vtable): Remove.
	(libcc1::add_callbacks): New method, extracted from
	libcc1_compile.
	(gcc_c_fe_context): Update.
	* gdbctx.hh (base_gdb_plugin): Change parameters.
	(~base_gdb_plugin): New.
	<add_callbacks>: New virtual method.
	<plugin_name, fe_version, compiler_name, vtable>: New members.
	(get_self, do_set_verbose, do_set_arguments)
	(do_set_triplet_regexp, do_set_driver_filename)
	(do_set_arguments_v0, do_set_source_file, do_set_print_callback)
	(fork_exec, do_compile, do_compile_v0, do_destroy): New methods.
2021-05-05 00:06:18 -06:00
Tom Tromey
b65c0bcbe1 libcc1: use GCC_FE_VERSION_1 in C++ plugin
The C++ plugin defaults to version 0 of the base compiler API.
However, this is a mistake -- version 1 was introduced before the C++
API was even implemented.  This switches the default to version 1.
Note that the compiler-side plugin will accept this version, so it
should remain compatible.

libcc1

	* libcp1.cc (vtable): Use GCC_FE_VERSION_1.
2021-05-05 00:06:18 -06:00
Tom Tromey
1a51cb2990 libcc1: share GDB plugin code
The two GDB plugins in libcc1 share a fair amount of code.  This was
done by copy-and-paste, though in reality the underlying code is
nearly identical.

libcc1

	* libcp1.cc (struct libcp1): Derive from base_gdb_plugin.  Remove
	shared code.
	(class libcp1_connection): Remove.
	(rpc): Remove.
	(libcp1_set_verbose, libcp1_compile): Update.
	(cp_call_binding_oracle, cp_call_symbol_address)
	(cp_call_enter_scope, cp_call_leave_scope): Update.
	* libcc1.cc (struct libcc1): Derive from base_gdb_plugin.  Remove
	shared code.
	(class libcc1_connection): Remove.
	(c_call_binding_oracle, c_call_symbol_address): Update.
	(rpc): Remove.
	(libcc1_set_verbose, libcc1_compile): Update.
	* gdbctx.hh: New file.
2021-05-05 00:06:17 -06:00
Tom Tromey
0624823260 libcc1: share basic context code
Both plugins in libcc1 share a fair amount of boilerplate.  They both
share error-emission code, context management code, and tree GC code.
This patch unifies these two bodies of code, avoiding needless
duplication.

libcc1

	* libcc1plugin.cc: Move code to context.cc.
	* libcp1plugin.cc: Move code to context.cc.
	* context.hh: New file.
	* context.cc: New file.
	* Makefile.in: Rebuild.
	* Makefile.am (AM_CPPFLAGS): Add more gcc flags.
	(CPPFLAGS_FOR_C, CPPFLAGS_FOR_CXX): Update.
	(libcc1plugin_la_SOURCES): Add context.hh, context.cc.
	(libcp1plugin_la_SOURCES): Likewise.
2021-05-05 00:06:17 -06:00
Tom Tromey
0ed83e1d03 libcc1: use static_assert
This changes one spot in libcc1 to use static_assert rather than the
old-style array declaration.

libcc1

	* libcp1plugin.cc: Use static assert.
2021-05-05 00:06:17 -06:00
Tom Tromey
7c4e5d5eaa libcc1: use foreach
This changes libcc1 to ues foreach in a couple of spots.

libcc1

	* libcp1plugin.cc (plugin_context::mark): Use foreach.
	* libcc1plugin.cc (plugin_context::mark): Use foreach.
2021-05-05 00:06:17 -06:00
Tom Tromey
1d9c972601 libcc1: unify compiler handling
Both libcc1 plugins have nearly identical copies of code to find the
underlying compiler.  This seemed wasteful to me, so this patch
unifies the copies.

Two minor API changes were needed.

First, the old code used a back-link from the compiler object to the
plugin object to check the 'verbose' setting.  This patch adds a
'verbose' setting directly to the compiler object instead.

Second, the 'find' method implicitly knew which compiler base name
("gcc" or "g++") to use.  This patch makes this a parameter that is
passed in by the plugin.

libcc1

	* libcp1.cc (compiler, compiler_triplet_regexp)
	(compiler_driver_filename): Remove.
	(libcp1::libcp1): Update.
	(make_regexp, libcp1::compiler::find)
	(libcp1::compiler_triplet_regexp::find)
	(libcp1::compiler_driver_filename::find): Remove.
	(libcp1_set_verbose, libcp1_set_arguments)
	(libcp1_set_triplet_regexp, libcp1_set_driver_filename): Update.
	* libcc1.cc (compiler, compiler_triplet_regexp)
	(compiler_driver_filename): Remove.
	(libcc1::libcc1): Update.
	(make_regexp, libcc1::compiler::find)
	(libcc1::compiler_triplet_regexp::find)
	(libcc1::compiler_driver_filename::find): Remove.
	(libcc1_set_verbose, libcc1_set_arguments)
	(libcc1_set_triplet_regexp, libcc1_set_driver_filename): Update.
	* compiler.cc: New file.
	* compiler.hh: New file.
	* Makefile.in: Rebuild.
	* Makefile.am (libcc1_la_SOURCES): Add compiler.hh, compiler.cc.
2021-05-05 00:06:17 -06:00
Tom Tromey
30c9604c2c libcc1: use unique_ptr more
This changes libcc1 to use unique_ptr in a few more places, removing
some manual memory management.

libcc1

	* libcp1.cc (struct libcp1) <connection, compilerp>: Use
	unique_ptr.
	(~libcp1): Remove.
	(libcp1_compile, libcp1_set_triplet_regexp)
	(libcp1_set_driver_filename): Update.
	* libcc1.cc (struct libcc1) <connection, compilerp>: Use
	unique_ptr.
	(~libcc1): Remove.
	(libcc1_set_triplet_regexp, libcc1_set_driver_filename)
	(libcc1_compile): Update.
2021-05-05 00:06:17 -06:00
Tom Tromey
0f237df286 libcc1: add more uses of 'deleter'
This changes libcc1 to use the 'deleter' template in a few more
places.  The template and basic specializations are moved to a new
header, then some unmarshall functions are changed to use this code.
This change avoids the need to repeat cleanup code in the
unmarshallers.

libcc1

	* rpc.hh (deleter): Move template and some specializations to
	deleter.hh.
	(argument_wrapper<const T *>): Use cc1_plugin::unique_ptr.
	* marshall.cc (cc1_plugin::unmarshall): Use
	cc1_plugin::unique_ptr.
	* marshall-cp.hh (deleter): New specializations.
	(unmarshall): Use cc1_plugin::unique_ptr.
	* deleter.hh: New file.
2021-05-05 00:06:17 -06:00
Tom Tromey
0d5a0b9af5 libcc1: add deleter objects
This adds deleter objects for various kinds of protocol pointers to
libcc1.  Existing specializations of argument_wrapper are then
replaced with a single specialization that handles all pointer types
via the appropriate deleter.  The result here is a bit nicer because
the argument_wrapper boilerplate code is completely shared, leaving
just the memory-management detail to the particular specializations.

libcc1

	* rpc.hh (struct deleter): New template class and
	specializations.
	(argument_wrapper): Remove specializations.  Add specialization
	for any pointer type.
2021-05-05 00:06:17 -06:00
Tom Tromey
e702c60e65 libcc1: use std::vector when building function types
This changes libcc1 to use std::vector in the code that builds
function types.  This avoids some explicit memory management.

libcc1

	* libcp1plugin.cc (plugin_build_function_type): Use std::vector.
	* libcc1plugin.cc (plugin_build_function_type): Use std::vector.
2021-05-05 00:06:16 -06:00
Tom Tromey
410d5719b7 libcc1: use variadic templates for "rpc"
This changes libcc1 to use variadic templates for the "rpc" functions.
This simplifies the code and removes some possibility for mistakes.

libcc1

	* libcp1.cc (rpc): Use variadic template.  Remove overloads.
	* libcc1.cc (rpc): Use variadic template.  Remove overloads.
2021-05-05 00:06:16 -06:00
Tom Tromey
dc6be7c022 libcc1: use variadic templates for "call"
This changes libcc1 to use variadic templates for the "call"
functions.  The primary benefit is that this simplifies the code.

libcc1

	* rpc.hh (call): Use variadic template.  Remove overloads.
	* marshall.hh (marshall): Add base overload.  Use variadic
	template.
2021-05-05 00:06:16 -06:00
Tom Tromey
c10a3b13fe libcc1: delete copy constructor and assignment operators
Change libcc1 to use "= delete" for the copy constructor and
assignment operator, rather than the old approach of private methods
that are nowhere defined.

libcc1

	* rpc.hh (argument_wrapper): Use delete for copy constructor.
	* connection.hh (class connection): Use delete for copy
	constructor.
	* callbacks.hh (class callbacks): Use delete for copy constructor.
2021-05-05 00:06:16 -06:00
Tom Tromey
41f4381648 libcc1: inline some simple methods
This changes libcc1 to inline a trivial method and to use the default
constructor.

libcc1

	* connection.hh (~connection): Use default.
	(print): Inline.
	* connection.cc (cc1_plugin::connection::~connection)
	(cc1_plugin::connection::print): Remove definitions.
2021-05-05 00:06:16 -06:00
Tom Tromey
e1f5252e4d libcc1: use "override"
This changes libcc1 to use "override" where appropriate.

libcc1

	* libcp1.cc (class compiler_triplet_regexp)
	(class compiler_driver_filename, class libcp1_connection): Use
	"override".
	* libcc1.cc (class compiler_triplet_regexp)
	(class compiler_driver_filename, class libcc1_connection): Use
	"override".
2021-05-05 00:06:16 -06:00
Tom Tromey
25d1a6ecdc libcc1: use templates to unmarshall enums
Now that C++11 can be used in GCC, libcc1 can be changed to use
templates and type traits to handle unmarshalling all kinds of enums.

libcc1

	* marshall.hh (cc1_plugin::unmarshall): Use type traits.
	* marshall-cp.hh (cc1_plugin::unmarshall): Remove overloads.
	* marshall-c.hh: Remove.
	* libcc1plugin.cc: Update includes.
	* libcc1.cc: Update includes.
2021-05-05 00:06:16 -06:00
GCC Administrator
e690396da7 Daily bump. 2021-05-04 00:16:53 +00:00
H.J. Lu
3f57062135 GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs
Check if host supports multi-byte NOPs before enabling CET on host.

gcc/

	PR bootstrap/99703
	* configure: Regenerated.

libbacktrace/

	PR bootstrap/99703
	* configure: Regenerated.

libcc1/

	PR bootstrap/99703
	* configure: Regenerated.

libcpp/

	PR bootstrap/99703
	* configure: Regenerated.

libdecnumber/

	PR bootstrap/99703
	* configure: Regenerated.

lto-plugin/

	PR bootstrap/99703
	* configure: Regenerated.
2021-05-03 05:01:23 -07:00
GCC Administrator
651b8a50a6 Daily bump. 2021-01-06 00:16:55 +00:00
Samuel Thibault
f56de3557f Update GNU/Hurd configure support
ChangeLog:

	* libtool.m4: Match gnu* along other GNU systems.
	* libgo/config/libtool.m4: Match gnu* along other GNU systems.
	* libgo/configure: Re-generate.

libffi/
	* configure: Re-generate.

libgomp/
	* configure: Re-generate.

gcc/

	* configure: Re-generate.

libatomic/

	* configure: Re-generate.

libbacktrace/

	* configure: Re-generate.

libcc1/

	* configure: Re-generate.

libgfortran/

	* configure: Re-generate.

libgomp/

	* configure: Re-generate.

libhsail-rt/

	* configure: Re-generate.

libitm/

	* configure: Re-generate.

libobjc/

	* configure: Re-generate.

liboffloadmic/

	* configure: Re-generate.
	* plugin/configure: Re-generate.

libphobos/

	* configure: Re-generate.

libquadmath/

	* configure: Re-generate.

libsanitizer/

	* configure: Re-generate.

libssp/

	* configure: Re-generate.

libstdc++-v3/

	* configure: Re-generate.

libvtv/

	* configure: Re-generate.

lto-plugin/

	* configure: Re-generate.

zlib/

	* configure: Re-generate.
2021-01-05 16:04:14 -07:00
Jakub Jelinek
99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
GCC Administrator
b1a2242e24 Daily bump. 2020-12-19 00:16:31 +00:00
Jakub Jelinek
5dc998933e libcc1: Fix up libcc1 configure [PR98330]
Either we should write test x$darwin_dynamic_lookup = xyes
or we should make sure the variable is always defined to non-empty string.

2020-12-18  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/98380
	* configure.ac: Set darwin_dynamic_lookup=no instead to empty
	string.
	* configure: Regenerated.
2020-12-18 20:25:26 +01:00
GCC Administrator
6e1edf48eb Daily bump. 2020-12-06 00:16:44 +00:00
Iain Sandoe
1352bc88a0 Darwin : Update libtool and dependencies for Darwin20 [PR97865]
The change in major version (and the increment from Darwin19 to 20)
caused libtool tests to fail which resulted in incorrect build settings
for shared libraries.

We take this opportunity to sort out the shared undefined symbols state
rather than propagating the current unsound behaviour into a new rev.

This change means that we default to the case that missing symbols are
considered an error, and if one wants to allow this intentionally, the
confiuration for that case should be set appropriately.

Three existing cases need undefined dynamic lookup:
 libitm, where there is already a configuration mechanism to add the
         flags.
 libcc1, where we add simple configuration to add the flags for Darwin.
 libsanitizer, where we can add to the existing extra flags.

libcc1/ChangeLog:

	PR target/97865
	* Makefile.am: Add dynamic_lookup to LD flags for Darwin.
	* configure.ac: Test for Darwin host and set a flag.
	* Makefile.in: Regenerate.
	* configure: Regenerate.

libitm/ChangeLog:

	PR target/97865
	* configure.tgt: Add dynamic_lookup to XLDFLAGS for Darwin.
	* configure: Regenerate.

libsanitizer/ChangeLog:

	PR target/97865
	* configure.tgt: Add dynamic_lookup to EXTRA_CXXFLAGS for
	Darwin.
	* configure: Regenerate.

ChangeLog:

	PR target/97865
	* libtool.m4: Update handling of Darwin platform link flags
	for Darwin20.

gcc/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libatomic/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libbacktrace/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libffi/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libgfortran/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libgomp/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libhsail-rt/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libobjc/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libphobos/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libquadmath/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libssp/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libstdc++-v3/ChangeLog:

	PR target/97865
	* configure: Regenerate.

libvtv/ChangeLog:

	PR target/97865
	* configure: Regenerate.

zlib/ChangeLog:

	PR target/97865
	* configure: Regenerate.
2020-12-05 08:43:20 +00:00
GCC Administrator
a9625c50dd Daily bump. 2020-11-30 00:16:27 +00:00
John David Anglin
4e4ba6478a Fix hppa64-hpux11 build to remove source paths from embedded path.
This change adds the +nodefaultrpath ld option to remove all library
paths that were specified with the -L option from the embedded path.

2020-11-29  John David Anglin  <danglin@gcc.gnu.org>

ChangeLog:
	* libtool.m4 (archive_cmds): Add +nodefaultrpath ld option on
	hppa64-*-hpux11*.

libatomic/ChangeLog:
	* configure: Regenerate.

libbacktrace/ChangeLog:
	* configure: Regenerate.

libcc1/ChangeLog:
	* configure: Regenerate.

libffi/ChangeLog:
	* configure: Regenerate.

libgfortran/ChangeLog:
	* configure: Regenerate.

libgomp/ChangeLog:
	* configure: Regenerate.

libhsail-rt/ChangeLog:
	* configure: Regenerate.

libitm/ChangeLog:
	* configure: Regenerate.

libobjc/ChangeLog:
	* configure: Regenerate.

liboffloadmic/ChangeLog:
	* configure: Regenerate.
	* plugin/configure: Regenerate.

libquadmath/ChangeLog:
	* configure: Regenerate.

libsanitizer/ChangeLog:
	* configure: Regenerate.

libssp/ChangeLog:
	* configure: Regenerate.

libstdc++-v3/ChangeLog:
	* configure: Regenerate.

libvtv/ChangeLog:
	* configure: Regenerate.

lto-plugin/ChangeLog:
	* configure: Regenerate.

zlib/ChangeLog:
	* configure: Regenerate.
2020-11-29 20:11:38 +00:00
GCC Administrator
0f5f9ed5e5 Daily bump. 2020-11-12 00:16:39 +00:00
Patrick Palka
61827d5d9a c++: Correct the handling of alignof(expr) [PR88115]
We're currently neglecting to set the ALIGNOF_EXPR_STD_P flag on an
ALIGNOF_EXPR when its operand is an expression.  This leads to us
handling alignof(expr) as if it were written __alignof__(expr), and
returning the preferred alignment instead of the ABI alignment.  In the
testcase below, this causes the first and third static_assert to fail on
x86.

gcc/cp/ChangeLog:

	PR c++/88115
	* cp-tree.h (cxx_sizeof_or_alignof_expr): Add bool parameter.
	* decl.c (fold_sizeof_expr): Pass false to
	cxx_sizeof_or_alignof_expr.
	* parser.c (cp_parser_unary_expression): Pass std_alignof to
	cxx_sizeof_or_alignof_expr.
	* pt.c (tsubst_copy): Pass false to cxx_sizeof_or_alignof_expr.
	(tsubst_copy_and_build): Pass std_alignof to
	cxx_sizeof_or_alignof_expr.
	* typeck.c (cxx_alignof_expr): Add std_alignof bool parameter
	and pass it to cxx_sizeof_or_alignof_type.  Set ALIGNOF_EXPR_STD_P
	appropriately.
	(cxx_sizeof_or_alignof_expr): Add std_alignof bool parameter
	and pass it to cxx_alignof_expr.  Assert op is either
	SIZEOF_EXPR or ALIGNOF_EXPR.

libcc1/ChangeLog:

	PR c++/88115
	* libcp1plugin.cc (plugin_build_unary_expr): Pass true to
	cxx_sizeof_or_alignof_expr.

gcc/testsuite/ChangeLog:

	PR c++/88115
	* g++.dg/cpp0x/alignof6.C: New test.
2020-11-11 14:43:38 -05:00
GCC Administrator
bb6226419f Daily bump. 2020-11-11 00:16:36 +00:00
Marek Polacek
8c0c83feb0 c++: Improve static_assert diagnostic [PR97518]
Currently, when a static_assert fails, we only say "static assertion failed".
It would be more useful if we could also print the expression that
evaluated to false; this is especially useful when the condition uses
template parameters.  Consider the motivating example, in which we have
this line:

  static_assert(is_same<X, Y>::value);

if this fails, the user has to play dirty games to get the compiler to
print the template arguments.  With this patch, we say:

  error: static assertion failed
  note: 'is_same<int*, int>::value' evaluates to false

which I think is much better.  However, always printing the condition that
evaluated to 'false' wouldn't be very useful: e.g. noexcept(fn) is
always parsed to true/false, so we would say "'false' evaluates to false"
which doesn't help.  So I wound up only printing the condition when it was
instantiation-dependent, that is, we called finish_static_assert from
tsubst_expr.

Moreover, this patch also improves the diagnostic when the condition
consists of a logical AND.  Say you have something like this:

  static_assert(fn1() && fn2() && fn3() && fn4() && fn5());

where fn4() evaluates to false and the other ones to true.  Highlighting
the whole thing is not that helpful because it won't say which clause
evaluated to false.  With the find_failing_clause tweak in this patch
we emit:

  error: static assertion failed
    6 | static_assert(fn1() && fn2() && fn3() && fn4() && fn5());
      |                                          ~~~^~

so you know right away what's going on.  Unfortunately, when you combine
both things, that is, have an instantiation-dependent expr and && in
a static_assert, we can't yet quite point to the clause that failed.  It
is because when we tsubstitute something like is_same<X, Y>::value, we
generate a VAR_DECL that doesn't have any location.  It would be awesome
if we could wrap it with a location wrapper, but I didn't see anything
obvious.

In passing, I've cleaned up some things:
* use iloc_sentinel when appropriate,
* it's nicer to call contextual_conv_bool instead of the rather verbose
  perform_implicit_conversion_flags,
* no need to check for INTEGER_CST before calling integer_zerop.

gcc/cp/ChangeLog:

	PR c++/97518
	* cp-tree.h (finish_static_assert): Adjust declaration.
	* parser.c (cp_parser_static_assert): Pass false to
	finish_static_assert.
	* pt.c (tsubst_expr): Pass true to finish_static_assert.
	* semantics.c (find_failing_clause_r): New function.
	(find_failing_clause): New function.
	(finish_static_assert): Add a bool parameter.  Use
	iloc_sentinel.  Call contextual_conv_bool instead of
	perform_implicit_conversion_flags.  Don't check for INTEGER_CST before
	calling integer_zerop.  Call find_failing_clause and maybe use its
	location.  Print the original condition or the failing clause if
	SHOW_EXPR_P.

gcc/testsuite/ChangeLog:

	PR c++/97518
	* g++.dg/diagnostic/pr87386.C: Adjust expected output.
	* g++.dg/diagnostic/static_assert1.C: New test.
	* g++.dg/diagnostic/static_assert2.C: New test.

libcc1/ChangeLog:

	PR c++/97518
	* libcp1plugin.cc (plugin_add_static_assert): Pass false to
	finish_static_assert.
2020-11-10 15:08:06 -05:00
GCC Administrator
44cab2d8fd Daily bump. 2020-11-07 00:16:39 +00:00
Nathan Sidwell
ba6498124c core: Rename DECL_IS_BUILTIN -> DECL_IS_UNDECLARED_BUILTIN
In cleaning up C++'s handling of hidden decls, I renamed its
DECL_BUILTIN_P, which checks for loc == BUILTINS_LOCATION to
DECL_UNDECLARED_BUILTIN_P, because the location gets updated, if user
source declares the builtin, and the predicate no longer holds.  The
original name was confusing me.  (The builtin may still retain builtin
properties in the redeclaration, and other predicates can still detect
that.)

I discovered that tree.h had its own variant 'DECL_IS_BUILTIN', which
behaves in (almost) the same manner.  And therefore has the same
mutating behaviour.

This patch deletes the C++ one, and renames tree.h's to
DECL_IS_UNDECLARED_BUILTIN, to emphasize its non-constantness.  I
guess _IS_ wins over _P

	gcc/
	* tree.h (DECL_IS_BUILTIN): Rename to ...
	(DECL_IS_UNDECLARED_BUILTIN): ... here.  No need to use SOURCE_LOCUS.
	* calls.c (maybe_warn_alloc_args_overflow): Adjust for rename.
	* cfgexpand.c (pass_expand::execute): Likewise.
	* dwarf2out.c (base_type_die, is_naming_typedef_decl): Likewise.
	* godump.c (go_decl, go_type_decl): Likewise.
	* print-tree.c (print_decl_identifier): Likewise.
	* tree-pretty-print.c (dump_generic_node): Likewise.
	* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Likewise.
	* xcoffout.c (xcoff_assign_fundamental_type_number): Likewise.
	gcc/c-family/
	* c-ada-spec.c (collect_ada_nodes): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	(collect_ada_node): Likewise.
	(dump_forward_type): Likewise.
	* c-common.c (set_underlying_type): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	(user_facing_original_type, c_common_finalize_early_debug): Likewise.
	gcc/c/
	* c-decl.c (diagnose_mismatched_decls): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	(warn_if_shadowing, implicitly_declare, names_builtin_p)
	(collect_source_refs): Likewise.
	* c-typeck.c (inform_declaration, inform_for_arg)
	(convert_for_assignment): Likewise.
	gcc/cp/
	* cp-tree.h (DECL_UNDECLARED_BUILTIN_P): Delete.
	* cp-objcp-common.c (names_bultin_p): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	* decl.c (decls_match): Likewise.  Replace
	DECL_UNDECLARED_BUILTIN_P with DECL_IS_UNDECLARED_BUILTIN.
	(duplicate_decls): Likewise.
	* decl2.c (collect_source_refs): Likewise.
	* name-lookup.c (anticipated_builtin_p, print_binding_level)
	(do_nonmember_using_decl): Likewise.
	* pt.c (builtin_pack_fn_p): Likewise.
	* typeck.c (error_args_num): Likewise.
	gcc/lto/
	* lto-symtab.c (lto_symtab_merge_decls_1): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	gcc/go/
	* go-gcc.cc (Gcc_backend::call_expression): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	libcc1/
	* libcc1plugin.cc (address_rewriter): Rename
	DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
	* libcp1plugin.cc (supplement_binding): Likewise.
2020-11-06 10:50:51 -08:00
GCC Administrator
b2698c21f2 Daily bump. 2020-10-15 00:16:34 +00:00
Nathan Sidwell
068644a149 c++: DECL_FRIEND_P cleanup
DECL_FRIEND_P's meaning has changed over time.  It now (almost) means
the the friend function decl has not been met via an explicit decl.
This completes that transition, renaming it to DECL_UNIQUE_FRIEND_P,
so one doesn't think it is the sole indicator of friendliness (plenty
of friends do not have the flag set).  This allows reduction in the
complexity of managing the field -- all in duplicate_decls now.

	gcc/cp/
	* cp-tree.h (struct lang_decl_fn): Adjust context comment.
	(DECL_FRIEND_P): Replace with ...
	(DECL_UNIQUE_FRIEND_P): ... this.  Only for FUNCTION_DECLs.
	(DECL_FRIEND_CONTEXT): Adjust.
	* class.c (add_implicitly_declared_members): Detect friendly
	spaceship from context.
	* constraint.cc (remove_constraints): Use a checking assert.
	(maybe_substitute_reqs_for): Use DECL_UNIQUE_FRIEND_P.
	* decl.c (check_no_redeclaration_friend_default_args):
	DECL_UNIQUE_FRIEND_P is signficant, not hiddenness.
	(duplicate_decls): Adjust DECL_UNIQUE_FRIEND_P clearing.
	(redeclaration_error_message): Use DECL_UNIQUE_FRIEND_P.
	(start_preparsed_function): Correct in-class friend processing.
	Refactor some initializers.
	(grokmethod): Directly check friend decl-spec.
	* decl2.c (grokfield): Check DECL_UNIQUE_FRIEND_P.
	* friend.c (do_friend): Set DECL_UNIQUE_FRIEND_P first, remove
	extraneous conditions.  Don't re set it afterwards.
	* name-lookup.c (lookup_elaborated_type_1): Simplify revealing
	code.
	(do_pushtag): Likewise.
	* pt.c (optimize_specialization_lookup_p): Check
	DECL_UNIQUE_FRIEND_P.
	(push_template_decl): Likewise.  Drop unneeded friend setting.
	(type_dependent_expression_p): Check DECL_UNIQUE_FRIEND_P.
	libcc1/
	* libcp1plugin.cc (plugin_add_friend): Set DECL_UNIQUE_FRIEND_P.
2020-10-14 10:04:18 -07:00
GCC Administrator
6caec77e3b Daily bump. 2020-10-08 00:16:30 +00:00
Nathan Sidwell
99e9b54313 c++: Rename DECL_BUILTIN_P to DECL_UNDECLARED_BUILTIN_P
I realized I'd misnamed DECL_BUILTIN_P, it's only true of compiler
builtins unless and until the user declares them -- at that point
they're real decls, and will have a location in the user's source.
(BUILT_IN_FN and friends still work though).  This renames them so
future-me is not confused as to why the predicate becomes false.

	gcc/cp/
	* cp-tree.h (DECL_BUILTIN_P): Rename to ...
	(DECL_UNDECLARED_BUILTIN_P): ... here.
	* decl.c (duplicate_decls): Adjust.
	* name-lookup.c (anticipated_builtin_p): Adjust.
	(do_nonmember_using_decl): Likewise.
	libcc1/
	* libcp1plugin.cc (supplement_binding): Rename
	DECL_BUILTIN_P.
2020-10-07 05:06:52 -07:00
GCC Administrator
b0b9b8f02a Daily bump. 2020-10-03 00:16:25 +00:00
Nathan Sidwell
679dbc9dce c++: Kill DECL_ANTICIPATED
Here's the patch to remove DECL_ANTICIPATED, and with it hiddenness is
managed entirely in the symbol table.  Sadly I couldn't get rid of the
actual field without more investigation -- it's repurposed for
OMP_PRIVATIZED_MEMBER.  It looks like a the VAR-related flags in
lang_decl_base are not completely orthogonal, so perhaps some can be
turned into an enumeration or something.  But that's more than I want
to do right now.

DECL_FRIEND_P Is still slightly suspect as it appears to mean more
than just in-class definition.  However, I'm leaving that for now.

	gcc/cp/
	* cp-tree.h (lang_decl_base): anticipated_p is not used for
	anticipatedness.
	(DECL_ANTICIPATED): Delete.
	* decl.c (duplicate_decls): Delete DECL_ANTICIPATED_management,
	use was_hidden.
	(cxx_builtin_function): Drop DECL_ANTICIPATED setting.
	(xref_tag_1): Drop DECL_ANTICIPATED assert.
	* name-lookup.c (name_lookup::adl_class_only): Drop
	DECL_ANTICIPATED check.
	(name_lookup::search_adl): Always dedup.
	(anticipated_builtin_p): Reimplement.
	(do_pushdecl): Drop DECL_ANTICIPATED asserts & update.
	(lookup_elaborated_type_1): Drop DECL_ANTICIPATED update.
	(do_pushtag): Drop DECL_ANTICIPATED setting.
	* pt.c (push_template_decl): Likewise.
	(tsubst_friend_class): Likewise.
	libcc1/
	* libcp1plugin.cc (libcp1plugin.cc): Drop DECL_ANTICIPATED test.
2020-10-02 12:21:08 -07:00
GCC Administrator
cdd8f031c7 Daily bump. 2020-09-26 00:16:25 +00:00