Commit Graph

190565 Commits

Author SHA1 Message Date
Siddhesh Poyarekar cc032ec1ec tree-optimization/103759: Use sizetype everywhere for object sizes
Since all computations in tree-object-size are now done in sizetype and
not HOST_WIDE_INT, comparisons with HOST_WIDE_INT based unknown and
initval would be incorrect.  Instead, use the sizetype trees directly to
generate and evaluate initval and unknown size values.

gcc/ChangeLog:

	PR tree-optimization/103759
	* tree-object-size.c (unknown, initval): Remove functions.
	(size_unknown, size_initval, size_unknown_p): Operate directly
	on trees.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2021-12-18 16:46:44 +05:30
François-Xavier Coudert 21423a1dfa Fortran: Cast arguments of <ctype.h> functions to unsigned char
Functions from <ctype.h> should only be called on values that can be
represented by unsigned char. On targets where char is a signed type,
some of libgfortran calls have undefined behaviour.

The solution is to cast the argument to unsigned char type. I’ve defined
macros in libgfortran.h to do so, to retain legibility of the library
code.

PR libfortran/95177

libgfortran/ChangeLog

	* libgfortran.h: include ctype.h, provide safe macros.
	* io/format.c: use safe macros.
	* io/list_read.c: use safe macros.
	* io/read.c: use safe macros.
	* io/write.c: use safe macros.
	* runtime/environ.c: use safe macros.
2021-12-18 09:21:16 +01:00
François-Xavier Coudert f18cbc1ee1 Darwin: Future-proof and homogeneize detection of darwin versions
The current GCC branch will become 12.1.0, which will be the stable
version of GCC when the next macOS version is released. There are some
places in GCC that don’t handle darwin22 as a version, so we need to
future-proof it (gcc/config.gcc and gcc/config/darwin-driver.c). We
align that code with what Apple clang does, i.e. accept all potential
major macOS versions until 99.

This patch also homogenises the handling of darwin version numbers,
where the majority of places use darwin2*, but some used darwin2[0-9]*.
Since there never was a darwin2.x version, the two are equivalent, and
we prefer the simpler darwin2*

gcc/ChangeLog:

	* config/darwin-driver.c: Make version code more future-proof.
	* config.gcc: Homogeneize darwin versions.
	* configure.ac: Homogeneize darwin versions.
	* configure: Regenerate.

gcc/testsuite/ChangeLog:

	* gcc.dg/darwin-minversion-link.c: Test darwin21.
	* obj-c++.dg/cxx-ivars-3.mm: Homogeneize darwin versions.
	* obj-c++.dg/objc-gc-3.mm: Homogeneize darwin versions.
	* objc.dg/objc-gc-4.m: Homogeneize darwin versions.
2021-12-18 09:20:49 +01:00
GCC Administrator 2554e2da92 Daily bump. 2021-12-18 00:16:23 +00:00
Marek Polacek 6afb8a68a9 attribs: Fix wrong error with -Wno-attribute=A::b [PR103649]
My patch to implement -Wno-attribute=A::b caused a bogus error when
parsing

  [[foo::bar(1, 2)]];

when -Wno-attributes=foo::bar was specified on the command line, because
when we create a fake foo::bar attribute and insert it into our attribute
table, it is created with max_length == 0 which doesn't allow any args.
That is wrong -- we know nothing about the attribute, so we shouldn't
require any specific number of arguments.  And since unknown attributes
can be rather complex (see for example omp::{directive,sequence}), we
must skip parsing their arguments.  To that end, I'm using max_length
with value -2.

Also let's not warn about things like

  [[vendor::assume(true)]];

because they may have some meaning (this is reminiscent of C++ Portable
Assumptions).

	PR c/103649

gcc/ChangeLog:

	* attribs.c (handle_ignored_attributes_option): Create the fake
	attribute with max_length == -2.
	(attribute_ignored_p): New overloads.
	* attribs.h (attribute_ignored_p): Declare them.
	* tree-core.h (struct attribute_spec): Document that max_length
	can be -2.

gcc/c/ChangeLog:

	* c-decl.c (c_warn_unused_attributes): Don't warn for
	attribute_ignored_p.
	* c-parser.c (c_parser_std_attribute): Skip parsing of the attribute
	arguments when the attribute is ignored.

gcc/cp/ChangeLog:

	* parser.c (cp_parser_declaration): Don't warn for attribute_ignored_p.
	(cp_parser_std_attribute): Skip parsing of the attribute
	arguments when the attribute is ignored.

gcc/testsuite/ChangeLog:

	* c-c++-common/Wno-attributes-6.c: New test.
2021-12-17 17:56:26 -05:00
David Edelsohn 00ea158fa0 testsuite: update expected results for ilp32.
gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/fold-vec-insert-float-p9.c
2021-12-17 17:30:55 -05:00
Olivier Hainque d7ca2a79b8 Add -mdejagnu-cpu=power7 to dg-options for pr97142.c
To match the tests expectations for toolchains
configured to default to not so capable cpus.

2021-12-17  Olivier Hainque  <hainque@adacore.com>

gcc/testsuite/
	* gcc.target/powerpc/pr97142.c: Add -mdejagnu-cpu=power7
	to the dg-options.
2021-12-17 18:10:00 +00:00
Marek Polacek fae0168626 c++: Improve diagnostic for class tmpl/class redecl [PR103749]
For code like

  template<typename>
  struct bar;

  struct bar {
    int baz;
  };

  bar var;

we emit a fairly misleading and unwieldy diagnostic:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ g++ -c u.cc
u.cc:6:8: error: template argument required for 'struct bar'
    6 | struct bar {
      |        ^~~
u.cc:10:5: error: class template argument deduction failed:
   10 | bar var;
      |     ^~~
u.cc:10:5: error: no matching function for call to 'bar()'
u.cc:3:17: note: candidate: 'template<class> bar()-> bar< <template-parameter-1-1> >'
    3 |   friend struct bar;
      |                 ^~~
u.cc:3:17: note:   template argument deduction/substitution failed:
u.cc:10:5: note:   couldn't deduce template parameter '<template-parameter-1-1>'
   10 | bar var;
      |     ^~~
u.cc:3:17: note: candidate: 'template<class> bar(bar< <template-parameter-1-1> >)-> bar< <template-parameter-1-1> >'
    3 |   friend struct bar;
      |                 ^~~
u.cc:3:17: note:   template argument deduction/substitution failed:
u.cc:10:5: note:   candidate expects 1 argument, 0 provided
   10 | bar var;
      |     ^~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

but with this patch we get:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
z.C:4:10: error: class template 'bar' redeclared as non-template
    4 |   struct bar {
      |          ^~~
z.C:2:10: note: previous declaration here
    2 |   struct bar;
      |          ^~~
z.C:8:7: error: 'bar<...auto...> var' has incomplete type
    8 |   bar var;
      |       ^~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

which is clearer about what the problem is.

I thought it'd be nice to avoid printing the messages about failed CTAD,
too.  To that end, I'm using CLASSTYPE_ERRONEOUS to suppress CTAD.  Not
sure if that's entirely kosher.

The other direction (first a non-template class declaration followed by
a class template definition) we handle quite well:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
z.C:11:8: error: 'bar' is not a template
   11 | struct bar {};
      |        ^~~
z.C:8:8: note: previous declaration here
    8 | struct bar;
      |        ^~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	PR c++/103749

gcc/cp/ChangeLog:

	* decl.c (lookup_and_check_tag): Give an error when a class was
	declared as template but no template header has been provided.
	* pt.c (do_class_deduction): Don't deduce CLASSTYPE_ERRONEOUS
	types.

gcc/testsuite/ChangeLog:

	* g++.dg/template/redecl4.C: Adjust dg-error.
	* g++.dg/diagnostic/redeclaration-2.C: New test.
2021-12-17 13:08:17 -05:00
Segher Boessenkool 87ae8d7613 rs6000: Update darn testcases
Make the darn testcases work (and be tested) in 32-bit mode as well.
They used to ICE, but they no longer do.

2021-12-17  Segher Boessenkool <segher@kernel.crashing.org>

gcc/testsuite/
	PR target/103624
	* gcc.target/powerpc/darn-0.c: Remove target clause.
	* gcc.target/powerpc/darn-1.c: Remove target clause. Remove lp64
	requirement.  Change return type to long.
	* gcc.target/powerpc/darn-2.c: Ditto.
	* gcc.target/powerpc/darn-3.c: Remove target clause.
2021-12-17 17:30:34 +00:00
Segher Boessenkool 7194397966 rs6000: Redo darn (PR103624)
The builtins now all return "long".  The patterns have :GPR as the
output mode, so they can be 32-bit as well (the instruction makes sense
in 32 bit just fine).  The builtins expand to the DImode version
normally, but to the SImode if {32bit} is true.

2021-12-17  Segher Boessenkool <segher@kernel.crashing.org>

	PR target/103624
	* config/rs6000/rs6000-builtins.def (__builtin_darn): Expand to
	darn_64_di.  Add {32bit} attribute.  Return long.
	(__builtin_darn_32): Expand to darn_32_di.  Add {32bit} attribute.
	Return long.
	(__builtin_darn_raw): Expand to darn_raw_di.  Add {32bit} attribute.
	Return long.
	* config/rs6000/rs6000-call.c (rs6000_expand_builtin): Expand the darn
	builtins to the _si variants for -m32.
	* config/rs6000/rs6000.md (UNSPECV_DARN_32, UNSPECV_DARN_RAW): Delete.
	(UNSPECV_DARN): Update comment.
	(darn_32, darn_raw, darn): Delete.
	(darn_32_<mode>, darn_64_<mode>, darn_raw_<mode> for GPR): New.
	(@darn<mode> for GPR): New.
2021-12-17 17:30:34 +00:00
Iain Sandoe 2466a8d0dd coroutines: Handle initial awaiters with non-void returns [PR 100127].
The way in which a C++20 coroutine is specified discards any value
that might be returned from the initial or final await expressions.

This ICE was caused by an initial await expression with an
await_resume () returning a reference, the function rewrite code
was not set up to expect this.

Fixed by looking through any indirection present and by explicitly
discarding the value, if any, returned by await_resume().

It does not seem useful to make a diagnostic for this, since
the user could define a generic awaiter that usefully returns
values when used in a different position from the initial (or
final) await expressions.

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

	PR c++/100127

gcc/cp/ChangeLog:

	* coroutines.cc (coro_rewrite_function_body): Handle initial
	await expressions that try to produce a reference value.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr100127.C: New test.
2021-12-17 16:57:47 +00:00
Iain Sandoe 921942a8a1 coroutines: Pass lvalues to user-defined operator new [PR 100772].
The wording of the standard has been clarified to be explicit that
the the parameters to any user-defined operator-new in the promise
class should be lvalues.

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

	PR c++/100772

gcc/cp/ChangeLog:

	* coroutines.cc (morph_fn_to_coro): Convert function parms
	from reference before constructing any operator-new args
	list.

gcc/testsuite/ChangeLog:

	* g++.dg/coroutines/pr100772-a.C: New test.
	* g++.dg/coroutines/pr100772-b.C: New test.
2021-12-17 16:56:53 +00:00
Iain Sandoe 39d2ec4150 coroutines, c++: Add test for PR 96517.
This PR was fixed by r12-5255-gdaa9c6b015, this adds
the testcase.

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

gcc/testsuite/ChangeLog:

	PR c++/96517
	* g++.dg/coroutines/pr96517.C: New test.
2021-12-17 16:54:35 +00:00
Bill Schmidt dfedfc304a rs6000: Fix fake vec_promote overload
rs6000-overload.def defines one instance of vec_promote so that it can be
registered with the front end.  Actual expansion of the vec_promote overload
is done with special-case code in rs6000-c.c.  During another cleanup, I
observed that the fake instance has the wrong number of arguments.  Fix that.

2021-12-17  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-overload.def (__builtin_vec_promote): Add second
	argument.
2021-12-17 10:39:00 -06:00
David Edelsohn 9315f02b1b testsuite: pragma-optimize.c requires ifunc.
gcc/testsuite/ChangeLog:

	* gcc.target/powerpc/pragma-optimize.c: Require ifunc support.
2021-12-17 09:48:16 -05:00
Richard Sandiford e781cb93d7 vect: Fix multi-vector SLP gather loads [PR103744]
This PR shows that I didn't properly test the multi-vector case when
adding support for SLP gather loads.  The patch fixes that case using
the same approach as we do for non-SLP cases: keep the scalar base
the same, but iterate through the (also multi-vector) vector offsets.
“vec_num * j + i” is already used elsewhere as a way of handling both
the multi-vector SLP case and the multi-vector non-SLP case.

gcc/
	PR tree-optimization/103744
	* tree-vect-stmts.c (vectorizable_load): Handle multi-vector
	SLP gather loads.

gcc/testsuite/
	PR tree-optimization/103744
	* gcc.dg/vect/pr103744-1.c: New test.
	* gcc.dg/vect/pr103744-2.c: Likewise.
2021-12-17 14:18:39 +00:00
Martin Liska 7dca2ad649 docs: fix option name reference
gcc/ChangeLog:

	* doc/invoke.texi: Rename to -fstack-protector.
2021-12-17 14:56:52 +01:00
Martin Liska 7fa2a20467 docs: Fix spelling issues in -fipa-strict-aliasing.
gcc/ChangeLog:

	* doc/invoke.texi: Fix spelling issues.
2021-12-17 14:33:35 +01:00
Tamar Christina 411ac94611 slp: check that the operation we're combing is a boolean operation [PR103741]
It seems I forgot to check that the operation we're combing when masking the
predicated together are actually predicates types.

Without it we end up accidentally trying to combine a value and a mask.

gcc/ChangeLog:

	PR tree-optimization/103741
	* tree-vect-stmts.c (vectorizable_operation): Check for boolean.

gcc/testsuite/ChangeLog:

	PR tree-optimization/103741
	* gcc.target/aarch64/pr103741.c: New test.
2021-12-17 10:59:33 +00:00
Iain Sandoe 574c09da48 libgcc, Darwin: Add missing build dependencies.
There was a race condition where the link for the new shared EH library
(only used on earlier Darwin) could fail because the new crts had not been
copied to the gcc directory.  This can cause a build failure (although
currently only seen on powerpc-darwin).

Fixed by adding specific dependency on the crts and on the multi target.
We also add the declaration header for the Darwin10 unwinder shim to the
powerpc cases, since we build that there for Rosetta use.

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

libgcc/ChangeLog:

	* config.host: Add shim declaration header to powerpc*-darwin builds.
	* config/rs6000/t-darwin-ehs: Remove dependency on the powerpc end
	file.
	* config/t-darwin-ehs: Add dependencies to the shared unwinder
	objects.
	* config/t-slibgcc-darwin: Add extra_parts to the dependencies for
	the shared EH lib.  Add all-multi to the dependencies for the
	libgcc_s.1.dylib redirections.
2021-12-17 10:12:53 +00:00
Martin Liska 80091f9426 Sync config.sub: 2021-10-27
ChangeLog:

	* config.sub: Sync from master.
2021-12-17 10:54:16 +01:00
Iain Sandoe ff56eea24e Darwin, Driver: Avoid a link line for empty commands.
We were pushing a spec value for weak_reference_mismatches unconditionally
which is not needed (the value was the default) and the side-effect of
this was that we appeared to need to drive a link command; leading to
unexpected diagnostics for cases where gcc was invoked with an empty
command line.

Also we were pushing flags for sysroot, os minimum version and controls
even if the command line was empty.

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

gcc/ChangeLog:

	* config/darwin-driver.c (darwin_driver_init): Exit from the
	option handling early if the command line is definitely enpty.
	* config/darwin.h (SUBTARGET_DRIVER_SELF_SPECS): Remove
	setting for the default content of weak_reference_mismatches.
2021-12-17 09:47:04 +00:00
Iain Sandoe 7c0ceaed0c Darwin, ppc: Additional change for r12-5974.
This adds a missed change from r12-5974-g926d64906af.
The builin_decls array has been renamed to drop the trailing
_x that was used during the main changes to the builtins.

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

gcc/ChangeLog:

	* config/rs6000/darwin.h: Drop trailing _x from the
	builtin_decls array name.
2021-12-17 09:43:55 +00:00
Martin Liska 744428312e Revert "Fixed typo"
This reverts commit 06cd44b438.
2021-12-17 09:54:53 +01:00
Haochen Jiang 456b53654a Add combine splitter to transform vpternlogd/vpcmpeqd/vpxor/vblendvps to vblendvps for ~op0
gcc/ChangeLog:

	PR target/100738
	* config/i386/sse.md (*avx_cmp<mode>3_lt, *avx_cmp<mode>3_ltint):
	Remove MEM_P restriction and add force_reg for operands[2].
	(*avx_cmp<mode>3_ltint_not): Add new define_insn_and_split.

gcc/testsuite/ChangeLog:

	PR target/100738
	* g++.target/i386/avx512vl-pr100738-1.C: New test.
2021-12-17 13:56:07 +08:00
Siddhesh Poyarekar 79a89108dd __builtin_dynamic_object_size: Recognize builtin
Recognize the __builtin_dynamic_object_size builtin and add paths in the
object size path to deal with it, but treat it like
__builtin_object_size for now.  Also add tests to provide the same
testing coverage for the new builtin name.

gcc/ChangeLog:

	* builtins.def (BUILT_IN_DYNAMIC_OBJECT_SIZE): New builtin.
	* tree-object-size.h: Move object size type bits enum from
	tree-object-size.c and add new value OST_DYNAMIC.
	* builtins.c (expand_builtin, fold_builtin_2): Handle it.
	(fold_builtin_object_size): Handle new builtin and adjust for
	change to compute_builtin_object_size.
	* tree-object-size.c: Include builtins.h.
	(compute_builtin_object_size): Adjust.
	(early_object_sizes_execute_one,
	dynamic_object_sizes_execute_one): New functions.
	(object_sizes_execute): Rename insert_min_max_p argument to
	early.  Handle BUILT_IN_DYNAMIC_OBJECT_SIZE and call the new
	functions.
	* doc/extend.texi (__builtin_dynamic_object_size): Document new
	builtin.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/builtin-dynamic-object-size1.C: New test.
	* g++.dg/ext/builtin-dynamic-object-size2.C: Likewise.
	* gcc.dg/builtin-dynamic-alloc-size.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-1.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-10.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-11.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-12.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-13.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-14.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-15.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-16.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-17.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-18.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-19.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-2.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-3.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-4.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-5.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-6.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-7.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-8.c: Likewise.
	* gcc.dg/builtin-dynamic-object-size-9.c: Likewise.
	* gcc.dg/builtin-object-size-16.c: Adjust to allow inclusion
	from builtin-dynamic-object-size-16.c.
	* gcc.dg/builtin-object-size-17.c: Likewise.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2021-12-17 09:34:44 +05:30
Siddhesh Poyarekar 422f9eb701 tree-object-size: Use trees and support negative offsets
Transform tree-object-size to operate on tree objects instead of host
wide integers.  This makes it easier to extend to dynamic expressions
for object sizes.

The compute_builtin_object_size interface also now returns a tree
expression instead of HOST_WIDE_INT, so callers have been adjusted to
account for that.

The trees in object_sizes are each an object_size object with members
size (the bytes from the pointer to the end of the object) and wholesize
(the size of the whole object).  This allows analysis of negative
offsets, which can now be allowed to the extent of the object bounds.
Tests have been added to verify that it actually works.

gcc/ChangeLog:

	* tree-object-size.h (compute_builtin_object_size): Return tree
	instead of HOST_WIDE_INT.
	* builtins.c (fold_builtin_object_size): Adjust.
	* gimple-fold.c (gimple_fold_builtin_strncat): Likewise.
	* ubsan.c (instrument_object_size): Likewise.
	* tree-object-size.c (object_size): New structure.
	(object_sizes): Change type to vec<object_size>.
	(initval): New function.
	(unknown): Use it.
	(size_unknown_p, size_initval, size_unknown): New functions.
	(object_sizes_unknown_p): Use it.
	(object_sizes_get): Return tree.
	(object_sizes_initialize): Rename from object_sizes_set_force
	and set VAL parameter type as tree.  Add new parameter WHOLEVAL.
	(object_sizes_set): Set VAL parameter type as tree and adjust
	implementation.  Add new parameter WHOLEVAL.
	(size_for_offset): New function.
	(decl_init_size): Adjust comment.
	(addr_object_size): Change PSIZE parameter to tree and adjust
	implementation.  Add new parameter PWHOLESIZE.
	(alloc_object_size): Return tree.
	(compute_builtin_object_size): Return tree in PSIZE.
	(expr_object_size, call_object_size, unknown_object_size):
	Adjust for object_sizes_set change.
	(merge_object_sizes): Drop OFFSET parameter and adjust
	implementation for tree change.
	(plus_stmt_object_size): Call collect_object_sizes_for directly
	instead of merge_object_size and call size_for_offset to get net
	size.
	(cond_expr_object_size, collect_object_sizes_for,
	object_sizes_execute): Adjust for change of type from
	HOST_WIDE_INT to tree.
	(check_for_plus_in_loops_1): Likewise and skip non-positive
	offsets.

gcc/testsuite/ChangeLog:

	* gcc.dg/builtin-object-size-1.c (test9): New test.
	(main): Call it.
	* gcc.dg/builtin-object-size-2.c (test8): New test.
	(main): Call it.
	* gcc.dg/builtin-object-size-3.c (test9): New test.
	(main): Call it.
	* gcc.dg/builtin-object-size-4.c (test8): New test.
	(main): Call it.
	* gcc.dg/builtin-object-size-5.c (test5, test6, test7): New
	tests.

Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
2021-12-17 09:15:30 +05:30
Jason Merrill 871504b0dd c++: tweak comment
The comment documented a parameter that no longer exists.

gcc/cp/ChangeLog:

	* constraint.cc (deduce_concept_introduction): Adjust comment.
2021-12-16 22:28:49 -05:00
Jason Merrill a37e8ce3b6 c++: layout of aggregate base with DMI [PR103681]
C++14 changed the definition of 'aggregate' to allow default member
initializers, but such classes still need to be considered "non-POD for the
purpose of layout" for ABI compatibility with C++11 code.  It seems rare to
derive from such a class, as evidenced by how long this bug has
survived (since r216750 in 2014), but it's certainly worth fixing.

We only warn when we were failing to allocate another field into the
tail padding of the newly aggregate class; this is the only ABI impact.

This also changes end_of_class to consider all data members, not just empty
data members; that used to be an additional flag, removed in r9-5710, but I
don't see any reason not to always include them.  This makes the result of
the function correspond to the ABI nvsize term and its nameless counterpart
that does include virtual bases.

When looking closely at other users of end_of_class, I realized that we were
assuming that the latter corresponded to the ABI dsize term, but it doesn't
if the class ends with an empty virtual base (in the rare case that the
empty base can't be assigned offset 0), and this matters for layout of
[[no_unique_address]].  So I added another mode that returns the desired
value for that case.  I'm not adding a warning for this ABI fix because it's
a C++20 feature.

	PR c++/103681

gcc/ChangeLog:

	* common.opt (fabi-version): Add v17.

gcc/cp/ChangeLog:

	* cp-tree.h (struct lang_type): Add non_pod_aggregate.
	(CLASSTYPE_NON_POD_AGGREGATE): New.
	* class.c (check_field_decls): Set it.
	(check_bases_and_members): Check it.
	(check_non_pod_aggregate): New.
	(enum eoc_mode): New.
	(end_of_class): Always include non-empty fields.
	Add eoc_nv_or_dsize mode.
	(include_empty_classes, layout_class_type): Adjust.

gcc/c-family/ChangeLog:

	* c-opts.c (c_common_post_options): Update defaults.

gcc/testsuite/ChangeLog:

	* g++.dg/abi/macro0.C: Update value.
	* g++.dg/abi/no_unique_address6.C: New test.
	* g++.dg/abi/nsdmi-aggr1.C: New test.
	* g++.dg/abi/nsdmi-aggr1a.C: New test.
2021-12-16 22:27:10 -05:00
GCC Administrator 774269aa4b Daily bump. 2021-12-17 00:16:20 +00:00
Sandra Loosemore 840a22e0fe Testsuite: Tweak gcc.dg/20021029-1.c for nios2.
This test needs to be built with -G0 on nios2 to avoid treating the array
as small data.

2021-12-16  Sandra Loosemore  <sandra@codesourcery.com>

	gcc/testsuite/
	* gcc.dg/20021029-1.c: Build with -G0 for nios2.
2021-12-16 15:17:14 -08:00
Marek Polacek 06041b2c67 c++: delayed noexcept in member function template [PR99980]
Some time ago I noticed that we don't properly delay parsing of
noexcept for member function templates.  This patch fixes that.

It didn't work because even though we set CP_PARSER_FLAGS_DELAY_NOEXCEPT
in cp_parser_member_declaration, member template declarations take
a different path: we call cp_parser_template_declaration and return
prior to setting the flag.

	PR c++/99980

gcc/cp/ChangeLog:

	* parser.c (cp_parser_single_declaration): Maybe pass
	CP_PARSER_FLAGS_DELAY_NOEXCEPT down to cp_parser_init_declarator.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/noexcept71.C: New test.
2021-12-16 17:38:02 -05:00
Martin Sebor 93faac7e32 Check for class type before assuming a type is one [PR103703].
Resolves:
PR c++/103703 - ICE with -Wmismatched-tags with friends and templates

gcc/cp/ChangeLog:

	PR c++/103703
	* parser.c (class_decl_loc_t::diag_mismatched_tags): Check for class
	type before assuming a type is one.

gcc/testsuite/ChangeLog:

	PR c++/103703
	* g++.dg/warn/Wmismatched-tags-9.C: New test.
2021-12-16 15:11:45 -07:00
Martin Sebor f91814c225 Fix member alignment for all targets [PR103751].
Resolves:
PR testsuite/103751 - FAIL: gcc.dg/Warray-bounds-48.c (test for excess errors)

gcc/testsuite/ChangeLog:
	PR testsuite/103751
	* gcc.dg/Warray-bounds-48.c: Fix member alignment.
2021-12-16 12:34:24 -07:00
Patrick Palka bb2a7f80a9 c++: two-stage name lookup for overloaded operators [PR51577]
In order to properly implement two-stage name lookup for dependent
operator expressions, we need to remember the result of unqualified
lookup of the operator at template definition time, and reuse that
result rather than performing another unqualified lookup at
instantiation time.

Ideally we could just store the lookup in the expression directly, but
as pointed out in r9-6405 this isn't really possible since we use the
standard tree codes to represent most dependent operator expressions.

We could perhaps create a new tree code to represent dependent operator
expressions, with enough operands to store the lookup along with
everything else, but that'd require a lot of careful work to make sure
we handle this new tree code properly across the frontend.

But currently type-dependent operator (and call) expressions are given
an empty TREE_TYPE, which dependent_type_p treats as dependent, so this
field is effectively unused except to signal that the expression is
type-dependent.  It'd be convenient if we could store the lookup there
while preserving the dependent-ness of the expression.

To that end, this patch creates a new kind of type, called
DEPENDENT_OPERATOR_TYPE, which we give to dependent operator expressions
and into which we can store the result of operator lookup at template
definition time (DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS).  Since this
type is always dependent (by definition), and since the frontend doesn't
seem to care much about the exact type of a type-dependent expression,
using this type in place of a NULL_TREE type seems to "just work"; only
dependent_type_p and WILDCARD_TYPE_P need to be adjusted to return true
for this new type.

The rest of the patch mostly consists of adding the necessary plumbing
to pass DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS to add_operator_candidates,
adjusting all callers of build_x_* appropriately, and removing the now
unnecessary push_operator_bindings mechanism.

In passing, this patch simplifies finish_constraint_binary_op to avoid
using build_x_binary_op for building a binary constraint-expr; we don't
need to consider operator overloads here, as the &&/|| inside a
constraint effectively always has the built-in meaning (since atomic
constraints must have bool type).

This patch also makes FOLD_EXPR_OP yield a tree_code instead of a raw
INTEGER_CST.

Finally, this patch adds the XFAILed test operator-8.C which is about
broken two-stage name lookup for rewritten non-dependent operator
expressions, an existing bug that's otherwise only documented in
build_new_op.

	PR c++/51577
	PR c++/83035
	PR c++/100465

gcc/cp/ChangeLog:

	* call.c (add_operator_candidates): Add lookups parameter.
	Use it to avoid performing a second unqualified lookup when
	instantiating a dependent operator expression.
	(build_new_op): Add lookups parameter and pass it appropriately.
	* constraint.cc (finish_constraint_binary_op): Use
	build_min_nt_loc instead of build_x_binary_op.
	* coroutines.cc (build_co_await): Adjust call to build_new_op.
	* cp-objcp-common.c (cp_common_init_ts): Mark
	DEPENDENT_OPERATOR_TYPE appropriately.
	* cp-tree.def (DEPENDENT_OPERATOR_TYPE): Define.
	* cp-tree.h (WILDCARD_TYPE_P): Accept DEPENDENT_OPERATOR_TYPE.
	(FOLD_EXPR_OP_RAW): New, renamed from ...
	(FOLD_EXPR_OP): ... this.  Change this to return the tree_code directly.
	(DEPENDENT_OPERATOR_TYPE_SAVED_LOOKUPS): Define.
	(templated_operator_saved_lookups): Define.
	(build_new_op): Add lookups parameter.
	(build_dependent_operator_type): Declare.
	(build_x_indirect_ref): Add lookups parameter.
	(build_x_binary_op): Likewise.
	(build_x_unary_op): Likewise.
	(build_x_compound_expr): Likewise.
	(build_x_modify_expr): Likewise.
	* cxx-pretty-print.c (get_fold_operator): Adjust after
	FOLD_EXPR_OP change.
	* decl.c (start_preparsed_function): Don't call
	push_operator_bindings.
	* decl2.c (grok_array_decl): Adjust calls to build_new_op.
	* method.c (do_one_comp): Likewise.
	(build_comparison_op): Likewise.
	* module.cc (trees_out::type_node): Handle DEPENDENT_OPERATOR_TYPE.
	(trees_in::tree_node): Likewise.
	* name-lookup.c (lookup_name): Revert r11-2876 change.
	(op_unqualified_lookup): Remove.
	(maybe_save_operator_binding): Remove.
	(discard_operator_bindings): Remove.
	(push_operator_bindings): Remove.
	* name-lookup.h (maybe_save_operator_binding): Remove.
	(push_operator_bindings): Remove.
	(discard_operator_bindings): Remove.
	* parser.c (cp_parser_unary_expression): Adjust calls to build_x_*.
	(cp_parser_binary_expression): Likewise.
	(cp_parser_assignment_expression): Likewise.
	(cp_parser_expression): Likewise.
	(do_range_for_auto_deduction): Likewise.
	(cp_convert_range_for): Likewise.
	(cp_parser_perform_range_for_lookup): Likewise.
	(cp_parser_template_argument): Likewise.
	(cp_parser_omp_for_cond): Likewise.
	(cp_parser_omp_for_incr): Likewise.
	(cp_parser_omp_for_loop_init): Likewise.
	(cp_convert_omp_range_for): Likewise.
	(cp_finish_omp_range_for): Likewise.
	* pt.c (fold_expression): Adjust after FOLD_EXPR_OP change. Pass
	templated_operator_saved_lookups to build_x_*.
	(tsubst_omp_for_iterator): Adjust call to build_x_modify_expr.
	(tsubst_expr) <case COMPOUND_EXPR>: Pass
	templated_operator_saved_lookups to build_x_*.
	(tsubst_copy_and_build) <case INDIRECT_REF>: Likewise.
	<case tcc_unary>: Likewise.
	<case tcc_binary>: Likewise.
	<case MODOP_EXPR>: Likewise.
	<case COMPOUND_EXPR>: Likewise.
	(dependent_type_p_r): Return true for DEPENDENT_OPERATOR_TYPE.
	* ptree.c (cxx_print_type): Handle DEPENDENT_OPERATOR_TYPE.
	* semantics.c (finish_increment_expr): Adjust call to
	build_x_unary_op.
	(finish_unary_op_expr): Likewise.
	(handle_omp_for_class_iterator): Adjust calls to build_x_*.
	(finish_omp_cancel): Likewise.
	(finish_unary_fold_expr): Use build_dependent_operator_type.
	(finish_binary_fold_expr): Likewise.
	* tree.c (cp_free_lang_data): Don't call discard_operator_bindings.
	* typeck.c (rationalize_conditional_expr): Adjust call to
	build_x_binary_op.
	(op_unqualified_lookup): Define.
	(build_dependent_operator_type): Define.
	(build_x_indirect_ref): Add lookups parameter and use
	build_dependent_operator_type.
	(build_x_binary_op): Likewise.
	(build_x_array_ref): Likewise.
	(build_x_unary_op): Likewise.
	(build_x_compound_expr_from_list): Adjust call to
	build_x_compound_expr.
	(build_x_compound_expr_from_vec): Likewise.
	(build_x_compound_expr): Add lookups parameter and use
	build_dependent_operator_type.
	(cp_build_modify_expr): Adjust call to build_new_op.
	(build_x_modify_expr): Add lookups parameter and use
	build_dependent_operator_type.
	* typeck2.c (build_x_arrow): Adjust call to build_new_op.

libcc1/ChangeLog:

	* libcp1plugin.cc (plugin_build_unary_expr): Adjust call to
	build_x_unary_op.
	(plugin_build_binary_expr): Adjust call to build_x_binary_op.

gcc/testsuite/ChangeLog:

	* g++.dg/lookup/operator-3.C: Split out operator overload
	declarations into ...
	* g++.dg/lookup/operator-3-ops.h: ... here.
	* g++.dg/lookup/operator-3a.C: New test.
	* g++.dg/lookup/operator-4.C: New test.
	* g++.dg/lookup/operator-4a.C: New test.
	* g++.dg/lookup/operator-5.C: New test.
	* g++.dg/lookup/operator-5a.C: New test.
	* g++.dg/lookup/operator-6.C: New test.
	* g++.dg/lookup/operator-7.C: New test.
	* g++.dg/lookup/operator-8.C: New test.
2021-12-16 13:40:42 -05:00
Uros Bizjak 271e36d9d5 i386: Enable VxHF vector modes lower ABI levels [PR103571]
Enable VxHF vector modes for SSE2, AVX and AVX512F ABIs.

2021-12-16  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

	PR target/103571
	* config/i386/i386.h (VALID_AVX256_REG_MODE): Add V16HFmode.
	(VALID_AVX256_REG_OR_OI_VHF_MODE): Replace with ...
	(VALID_AVX256_REG_OR_OI_MODE): ... this.  Remove V16HFmode.
	(VALID_AVX512F_SCALAR_MODE): Remove HImode and HFmode.
	(VALID_AVX512FP16_SCALAR_MODE): New.
	(VALID_AVX512F_REG_MODE): Add V32HFmode.
	(VALID_SSE2_REG_MODE): Add V8HFmode, V4HFmode and V2HFmode.
	(VALID_SSE2_REG_VHF_MODE): Remove.
	(VALID_INT_MODE_P): Add V2HFmode.
	* config/i386/i386.c (function_arg_advance_64):
	Remove explicit mention of V16HFmode and V32HFmode.
	(ix86_hard_regno_mode_ok): Remove explicit mention of XImode
	and V32HFmode, use VALID_AVX512F_REG_OR_XI_MODE instead.
	Use VALID_AVX512FP_SCALAR_MODE for TARGET_aVX512FP16.
	Use VALID_AVX256_REG_OR_OI_MODE instead of
	VALID_AVX256_REG_OR_OI_VHF_MODE and VALID_SSE2_REG_MODE instead
	of VALID_SSE2_REG_VHF_MODE.
	(ix86_set_reg_reg_cost): Remove usge of VALID_AVX512FP16_REG_MODE.
	(ix86_vector_mode_supported): Ditto.

gcc/testsuite/ChangeLog:

	PR target/103571
	* gcc.target/i386/pr102812.c (dg-final): Do not scan for movdqa.
2021-12-16 19:35:37 +01:00
Matthias Seidel 06cd44b438 Fixed typo
ChangeLog:

	* config.sub: Fix typo.
2021-12-16 17:54:45 +01:00
Martin Liska 54e6d3ef50 opts: do not do sanity check when an error is seen
PR target/103709

gcc/c-family/ChangeLog:

	* c-pragma.c (handle_pragma_pop_options): Do not check
	global options modification when an error is seen in parsing
	of options (pragmas or attributes).
2021-12-16 17:49:59 +01:00
Martin Liska 5b8f5a50a9 pragma: respect pragma in lambda functions
In g:01ad8c54fdca we started supporting target pragma changes
that are primarily caused by optimization option. The same can happen
in the opposite way and we need to check for changes both
in optimization_current_node and target_option_current_node.

	PR c++/103696

gcc/ChangeLog:

	* attribs.c (decl_attributes): Check if
	target_option_current_node is changed.

gcc/testsuite/ChangeLog:

	* g++.target/i386/pr103696.C: New test.
2021-12-16 17:49:49 +01:00
Francois-Xavier Coudert c14f38d429 Fix FLUSH IOSTAT value
PR libfortran/101255

libgfortran/ChangeLog:

	* io/file_pos.c: Fix error code.

gcc/testsuite/ChangeLog:

	* gfortran.dg/iostat_5.f90: New file.
2021-12-16 17:46:28 +01:00
Francois-Xavier Coudert 3f624a624a Fix timezone handling near year boundaries
PR libfortran/98507

libgfortran/ChangeLog:

	* intrinsics/time_1.h: Prefer clock_gettime() over
	  gettimeofday().
	* intrinsics/date_and_time.c: Fix timezone wrapping.

gcc/testsuite/ChangeLog:

	* gfortran.dg/date_and_time_1.f90: New file.
2021-12-16 17:45:51 +01:00
Martin Liska 41cc28405c docs: add missing leading dash for option.
gcc/ChangeLog:

	* doc/invoke.texi: Add missing dash.
2021-12-16 15:22:03 +01:00
Bill Schmidt ab3f5b71dc rs6000: Refactor altivec_build_resolved_builtin
While replacing the built-in machinery, we agreed to defer some necessary
refactoring of the overload processing.  This patch cleans it up considerably.

I've put in one FIXME for an additional level of cleanup that should be done
independently.  The various helper functions (resolve_VEC_*) can be simplified
if we move the argument processing in altivec_resolve_overloaded_builtin
earlier.  But this requires making nontrivial changes to those functions that
will need careful review.  Let's do that in a later patch.

2021-12-16  Bill Schmidt  <wschmidt@linux.ibm.com>

gcc/
	* config/rs6000/rs6000-c.c (resolution): New enum.
	(resolve_vec_mul): New function.
	(resolve_vec_cmpne): Likewise.
	(resolve_vec_adde_sube): Likewise.
	(resolve_vec_addec_subec): Likewise.
	(resolve_vec_splats): Likewise.
	(resolve_vec_extract): Likewise.
	(resolve_vec_insert): Likewise.
	(resolve_vec_step): Likewise.
	(find_instance): Likewise.
	(altivec_resolve_overloaded_builtin): Many cleanups.  Call factored-out
	functions.  Move variable declarations closer to uses.  Add commentary.
	Remove unnecessary levels of braces.  Avoid use of gotos.  Change
	misleading variable names.  Use switches over if-else-if chains.
2021-12-16 07:51:26 -06:00
Przemyslaw Wirkus 0a68862e78 aarch64: fix: ls64 tests fail on aarch64_be [PR103729]
This patch is sorting issue with LS64 intrinsics tests failing with
AArch64_be targets.

gcc/ChangeLog:

	PR target/103729
	* config/aarch64/aarch64-simd.md (aarch64_movv8di): Allow big endian
	targets to move V8DI.
2021-12-16 10:50:29 +00:00
Tobias Burnus 2c1ac0bf3d For -foffload= suggest also 'disable' and 'default' [PR103644]
gcc/ChangeLog:

	PR driver/103644
	* gcc.c (check_offload_target_name): Add 'default' and 'disable'
	to the candidate list.
2021-12-16 11:19:37 +01:00
H.J. Lu ab18659afc Revert "Sync with binutils: GCC: Pass --plugin to AR and RANLIB"
This reverts commit bf8cdd3511.
2021-12-15 20:45:58 -08:00
Xionghu Luo e1f8c14b9a Verbose support in analyze_brprob_spec
Also add verbose argument support like analyze_brprob.py

contrib/ChangeLog:

	* analyze_brprob_spec.py: Add verbose argument.
2021-12-15 19:58:10 -06:00
GCC Administrator 8a89c39be0 Daily bump. 2021-12-16 00:16:28 +00:00
Marek Polacek 06d5dcef72 c++: Allow constexpr decltype(auto) [PR102229]
My r11-2202 was trying to enforce [dcl.type.auto.deduct]/4, which says
"If the placeholder-type-specifier is of the form type-constraint[opt]
decltype(auto), T shall be the placeholder alone."  But this made us
reject 'constexpr decltype(auto)', which, after clarification from CWG,
should be valid.  [dcl.type.auto.deduct]/4 is supposed to be a syntactic
constraint, not semantic, so it's OK that the constexpr marks the object
as const.

As a consequence, checking TYPE_QUALS in do_auto_deduction is too late,
and we have a FIXME there anyway.  So in this patch I'm attempting to
detect 'const decltype(auto)' earlier.  If I'm going to use TYPE_QUALS,
it needs to happen before we mark the object as const due to constexpr,
that is, before grokdeclarator's

  /* A `constexpr' specifier used in an object declaration declares
     the object as `const'.  */
  if (constexpr_p && innermost_code != cdk_function)
    ...

Constrained decltype(auto) was a little problem, hence the TYPENAME
check.  But in a typename context you can't use decltype(auto) anyway,
I think.

	PR c++/102229

gcc/cp/ChangeLog:

	* decl.c (check_decltype_auto): New.
	(grokdeclarator): Call it.
	* pt.c (do_auto_deduction): Don't check decltype(auto) here.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/decltype-auto5.C: New test.
2021-12-15 17:47:43 -05:00
Thomas Schwinge 45b768cb80 testsuite: Be more informative for ICEs
For example, for the two (FAIL, XFAIL)
'gcc/testsuite/lib/gcc-dg.exp:gcc-dg-test-1' cases:

    -FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (internal compiler error)
    +FAIL: g++.dg/modules/xtreme-header-3_a.H -std=c++17 (internal compiler error: tree check: expected var_decl or function_decl or field_decl or type_decl or concept_decl or template_decl, have namespace_decl in get_merge_kind, at cp/module.cc:10072)

    -FAIL: gfortran.dg/gomp/clauses-1.f90   -O  (internal compiler error)
    +FAIL: gfortran.dg/gomp/clauses-1.f90   -O  (internal compiler error: Segmentation fault)

    -XFAIL: c-c++-common/goacc/kernels-decompose-ice-1.c (internal compiler error)
    +XFAIL: c-c++-common/goacc/kernels-decompose-ice-1.c (internal compiler error: in lower_omp_target, at omp-low.c:13147)

    -XFAIL: g++.dg/cpp1z/constexpr-lambda26.C  -std=c++17 (internal compiler error)
    +XFAIL: g++.dg/cpp1z/constexpr-lambda26.C  -std=c++17 (internal compiler error: in cxx_eval_constant_expression, at cp/constexpr.c:6954)

That allows for more easily spotting when during development you're trading one
ICE for another.

	gcc/testsuite/
	* lib/fortran-torture.exp (fortran-torture-compile)
	(fortran-torture-execute): Be more informative for ICEs.
	* lib/gcc-defs.exp (${tool}_check_compile): Likewise.
	* lib/gcc-dg.exp (gcc-dg-test-1): Likewise.
	* lib/go-torture.exp (go-torture-compile, go-torture-execute):
	Likewise.
2021-12-15 23:26:26 +01:00