Commit Graph

178055 Commits

Author SHA1 Message Date
Patrick Palka
9845b7b456 c++: wrong pretty printing of nested type [PR95303]
In the testcase below, we pretty print the nested type A<int>::B as
A<int>::B<int> because we don't check whether B is itself a class
template before printing the innermost set of template arguments from
B's TEMPLATE_INFO (which in this case belong to A).  This patch fixes
this by checking PRIMARY_TEMPLATE_P beforehand.

gcc/cp/ChangeLog:

	PR c++/95303
	* cxx-pretty-print.c (pp_cxx_unqualified_id): Check
	PRIMARY_TEMPLATE_P before printing the innermost template
	arguments.

gcc/testsuite/ChangeLog:

	PR c++/95303
	* g++.dg/concepts/diagnostic14.C: New test.
2020-07-07 16:33:12 -04:00
Aaron Sawdey
7126583af5 rs6000: fix power10_hw test
The code snippet for this test was returning 1 if power10
instructions executed correctly. It should return 0 if the
test passes.

	* lib/target-supports.exp (check_power10_hw_available):
	Return 0 for passing test.
2020-07-07 14:16:01 -05:00
Nathan Sidwell
7fd1b9dc85 testsuite: missed testcase
I discovered I'd missed applying a testcase when fixing up the EOF
token location a while back.

gcc/testsuite/
	* c-c++-common/cpp/pragma-eof.c: New
2020-07-07 11:45:16 -07:00
Nathan Sidwell
6bf2ff0d52 preprocessor: Better line info for <builtin> & <command-line>
With C++ module header units it becomes important to distinguish
between macros defined in forced headers (& commandline & builtins)
from those defined in the header file being processed.  We weren't
making that easy because we treated the builtins and command-line
locations somewhat file-like, with incrementing line numbers, and
showing them as included from line 1 of the main file.  This patch does
3 things:

0) extend the idiom that 'line 0' of a file means 'the file as a whole'

1) builtins and command-line macros are shown as-if included from line zero.

2) when emitting preprocessed output we keep resetting the line number
so that re-reading that preprocessed output will get the same set of
locations for the command line etc.

For instance the new c-c++-common/cpp/line-2.c test, now emits

In file included from <command-line>:
./line-2.h:4:2: error: #error wrong
    4 | #error wrong
      |  ^~~~~
line-2.c:3:11: error: macro "bill" passed 1 arguments, but takes just 0
    3 | int bill(1);
      |           ^
In file included from <command-line>:
./line-2.h:3: note: macro "bill" defined here
    3 | #define bill() 2
      |

Before it told you about including from <command-line>:31.

the preprocessed output looks like:
...

(There's a new optimization in do_line_marker to stop each of these
line markers causing a new line map.  We can simply rewind the
location, and keep using the same line map.)

	libcpp/
	* directives.c (do_linemarker): Optimize rewinding to line zero.
	* files.c (_cpp_stack_file): Start on line zero when about to inject
	headers.
	(cpp_push_include, cpp_push_default_include): Use highest_line as
	the location.
	* include/cpplib.h (cpp_read_main_file): Add injecting parm.
	* init.c (cpp_read_main_file): Likewise, inform _cpp_stack_file.
	* internal.h (enum include_type): Add IT_MAIN_INJECT.
	gcc/c-family/
	* c-opts.c (c_common_post_options): Add 'injecting' arg to
	cpp_read_main_file.
	(c_finish_options): Add linemap_line_start calls for builtin and cmd
	maps.  Force token position to line_table's highest line.
	* c-ppoutput.c (print_line_1): Refactor, print line zero.
	(cb_define): Always increment source line.
	gcc/testsuite/
	* c-c++-common/cpp/line-2.c: New.
	* c-c++-common/cpp/line-2.h: New.
	* c-c++-common/cpp/line-3.c: New.
	* c-c++-common/cpp/line-4.c: New.
	* c-c++-common/cpp/line-4.h: New.
2020-07-07 11:40:04 -07:00
Martin Sebor
6f9c9ea40a Avoid printing informational notes when -Wmismatched-tags is suppressed in system headers (PR c++/96063)
Related:
PR c++/96063 - mismatched-tags warnings in stdlib headers

gcc/cp/ChangeLog:

	PR c++/96063
	* parser.c (class_decl_loc_t::diag_mismatched_tags): Print notes only
	if warning_at returns nonzero.

gcc/testsuite/ChangeLog:

	PR c++/96063
	* g++.dg/warn/Wmismatched-tags-7.C: New test.
	* g++.dg/warn/Wmismatched-tags-8.C: New test.
2020-07-07 11:23:50 -06:00
Anton Youdkevitch
2aeccecbf0 Aarch64: Change costs for TX2 to expose more vectorization opportunities
Make the costs such that they do not exaclty reflect
the actual instructions costs from the manual but make
the codegen emit the code we want it to.

gcc/ChangeLog:

	* config/aarch64/aarch64.c (thunderx2t99_regmove_cost,
	thunderx2t99_vector_cost): Likewise.
2020-07-07 16:25:37 +01:00
Richard Biener
f75211822f fix detection of negative step DR groups
This fixes a condition that caused all negative step DR groups to
be detected as single element interleaving.  Such groups are
rejected by interleaving vectorization but miscompiled by SLP
which is fixed by forcing VMAT_STRIDED_SLP for now.

2020-07-07  Richard Biener  <rguenther@suse.de>

	* tree-vect-data-refs.c (vect_analyze_data_ref_accesses): Fix
	group overlap condition to allow negative step DR groups.
	* tree-vect-stmts.c (get_group_load_store_type): For
	multi element SLP groups force VMAT_STRIDED_SLP when the step
	is negative.

	* gcc.dg/vect/slp-47.c: New testcase.
	* gcc.dg/vect/slp-48.c: Likewise.
2020-07-07 16:09:21 +02:00
Eric Botcazou
e1b0956a8e [Ada] Small adjustment in the handling of alignment for arrays
gcc/ada/

	* freeze.adb (Freeze_Array_Type): Use Ctyp more consistently.
	Move code setting the alignment in the non-packed case to...
	* layout.adb (Layout_Type): ...here.
2020-07-07 05:27:00 -04:00
Bob Duff
e997d94b29 [Ada] Avoid crash on node extension
gcc/ada/

	* treepr.adb (Print_Node): Add code to test Is_Extension.
2020-07-07 05:27:00 -04:00
Arnaud Charlet
a21df0b6a4 [Ada] Assert failure on invalid Variable_Indexing
gcc/ada/

	* sem_ch4.adb (Try_Container_Indexing): Add ??? comment. Protect
	against malformed tree in case of errors.
2020-07-07 05:27:00 -04:00
Piotr Trojanek
eada422063 [Ada] Use Is_Generic_Subprogram where possible
gcc/ada/

	* einfo.adb, sem_ch10.adb, sem_ch12.adb, sem_ch8.adb: Use
	Is_Generic_Subprogram.
2020-07-07 05:26:59 -04:00
Piotr Trojanek
e082411903 [Ada] Fix typo in code to get a better error message
gcc/ada/

	* sem_ch8.adb (Analyze_Use_Package): Replace low-level,
	error-prone Ekind_In tests with high-level Is_Generic_Subprogram
	and Is_Subprogram.
2020-07-07 05:26:59 -04:00
Arnaud Charlet
8bda08f130 [Ada] ACATS 4.1J - B854003 - Subtype conformance check missed #2
gcc/ada/

	* sem_ch6.adb (Check_Formal_Subprogram_Conformance): New
	subprogram to handle checking without systematically emitting an
	error.
	(Check_Conformance): Update call to
	Check_Formal_Subprogram_Conformance and fix handling of Conforms
	and Errmsg parameters.
2020-07-07 05:26:59 -04:00
Arnaud Charlet
ead7594ff5 [Ada] ACATS 4.1K - C452003
gcc/ada/

	* exp_ch4.adb (Tagged_Membership): Generate a call to
	CW_Membership instead of using Build_CW_Membership.
	(Expand_N_In): Remove wrong handling of null access types and
	corresponding comment.
	* exp_intr.adb (Expand_Dispatching_Constructor_Call): Generate a
	call to CW_Membership instead of using Build_CW_Membership.
	* rtsfind.ads: Add CW_Membership.
	* exp_atag.ads, exp_atag.adb (Build_CW_Membership): Removed.
	* einfo.ads: Fix typo.
	* libgnat/a-tags.ads, libgnat/a-tags.adb (CW_Membership): Moved
	back to spec.
2020-07-07 05:26:59 -04:00
Ed Schonberg
9b501e59d1 [Ada] Errors in handling of access_to_subprogram contracts
gcc/ada/

	* exp_ch3.adb (Build_Access_Subprogram_Wrapper_Body): Create
	proper subprogram specification for body, using names in the
	subprogram declaration but distinct entities.
	* exp_ch6.adb (Expand_Call): If this is an indirect call
	involving a subprogram wrapper, insert pointer parameter in list
	of actuals with a parameter association, not as a positional
	parameter.
2020-07-07 05:26:58 -04:00
Justin Squirek
7bf53b1a61 [Ada] Hang on conditional expression as actual
gcc/ada/

	* exp_ch6.adb (Expand_Branch): Verify the original node is a
	conditional expression before recursing further.
	(Insert_Level_Assign): Transform assertion into an explicit
	raise.
2020-07-07 05:26:58 -04:00
Steve Baird
1c4b5a795a [Ada] Simplify statically known Max_Size_In_Storage_Elements attribute in more cases
gcc/ada/

	* sem_attr.adb (Eval_Attribute): Generalize static evaluation of
	Size attribute references to also handle
	Max_Size_In_Storage_Elements references.
2020-07-07 05:26:58 -04:00
Javier Miranda
865ec5b024 [Ada] Ada2020: AI12-0198 potentially unevaluated components of arrays
gcc/ada/

	* sem_util.adb (Is_Potentially_Unevaluated): Code cleanup.
2020-07-07 05:26:57 -04:00
Eric Botcazou
451187a3e5 [Ada] Move generation of range checks for entry families to expander
gcc/ada/

	* checks.ads (Expander Routines): Update the description of the
	Do_Range_Check mechanism.
	* checks.adb (Selected_Range_Checks): Fix typo.
	* exp_ch9.adb: Add with and use clause for Checks.
	(Actual_Index_Expression): Generate a range check if requested.
	(Entry_Index_Expression): Likewise.
	* sem_attr.adb (Resolve_Attribute) <Attribute_Count>: Call
	Apply_Scalar_Range_Check instead of Apply_Range_Check.
	* sem_ch9.adb (Analyze_Accept_Statement): Likewise.
	* sem_res.adb (Resolve_Entry): Likewise, after having set the
	actual index type on the prefix of the indexed component.
	(Resolve_Indexed_Component): Remove useless conditional construct.
2020-07-07 05:26:57 -04:00
Piotr Trojanek
2e724314af [Ada] Freeze aspect expression relocated to pragma Precondition
gcc/ada/

	* contracts.adb (Analyze_Entry_Or_Subprogram_Contract,
	Process_Preconditions_For): Freeze expression that has been
	relocated to pragma Precondition, not the expression which is
	still in the aspect.
2020-07-07 05:26:57 -04:00
Arnaud Charlet
e378df6d39 [Ada] ACATS 4.1H - BC60005 - null exclusion matching for formal subprograms
gcc/ada/

	* sem_ch6.adb (Check_Conformance): Remove unnecessary (and
	wrong) code.
	* sem_ch8.adb (Check_Null_Exclusion): Post error at proper
	location.  Introduce new helper Null_Exclusion_Mismatch and fix
	implementation wrt formal subprograms used in generic bodies.
	(Analyze_Subprogram_Renaming): Fix missing setting of
	Error_Msg_Sloc.
	(Analyze_Object_Renaming): Replace "in Anonymous_Access_Kind" by
	Is_Anonymous_Access_Type.
	* sem_util.adb (Has_Null_Exclusion): Fix handling of
	N_Parameter_Specification.
	* sem_ch12.adb (Instantiate_Object): Replace "in
	Anonymous_Access_Kind" by Is_Anonymous_Access_Type.
2020-07-07 05:26:57 -04:00
Ed Schonberg
dae09f9b55 [Ada] Handle explicit dereferences in expression functions
gcc/ada/

	* freeze.adb (Freeze_Expr_Types): Freeze the designated type of
	the explicit dereference.
2020-07-07 05:26:56 -04:00
Javier Miranda
572fa852f2 [Ada] Ada2020: AI12-0198 potentially unevaluated components of arrays
gcc/ada/

	* sem_util.adb (Is_Potentially_Unevaluated): Protect reading
	attribute Etype.
2020-07-07 05:26:56 -04:00
Bob Duff
3a70a9811f [Ada] Use pragma Unsuppress in Time_IO
gcc/ada/

	* libgnat/g-catiio.adb (Value, Parse_ISO_8601): Unsuppress
	checks, and don't rely on 'Valid.
2020-07-07 05:26:56 -04:00
Arnaud Charlet
8deaec2952 [Ada] Add support for XDR streaming in the default runtime
gcc/ada/

	* Makefile.rtl: Remove dead code.
	* doc/gnat_ugn/building_executable_programs_with_gnat.rst:
	Document gnatbind -xdr switch.
	* gnat_ugn.texi: Regenerate.
2020-07-07 05:26:56 -04:00
Piotr Trojanek
31c1fdbe0d [Ada] Fix documentation of -gnatVa switch
gcc/ada/

	* doc/gnat_ugn/building_executable_programs_with_gnat.rst
	(Validity Checking): Add "p" to the list of switches enabled by
	-gnatVa.
	* gnat_ugn.texi: Regenerate.
2020-07-07 05:26:55 -04:00
Ghjuvan Lacambre
d4175ef48b [Ada] Ensure No_Specification_Of_Aspect forbids pragmas and repr. clauses
gcc/ada/

	* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Add call
	to Check_Restriction_No_Specification_Of_Aspect.
	* sem_prag.adb (Analyze_Pragma): Likewise.
	* restrict.ads (Check_Restriction_No_Specification_Of_Aspect):
	Mention possible new node kinds in documentation.
	* restrict.adb (Check_Restriction_No_Specification_Of_Aspect):
	Retrieve aspect id from different fields if given node is an
	N_Pragma or an N_Attribute_Definition_Clause.
2020-07-07 05:26:55 -04:00
Gary Dismukes
58e07eaae4 [Ada] Checking type invariants on in params of procedures, not functions (AI12-0044)
gcc/ada/

	* contracts.adb (Add_Invariant_And_Predicate_Checks): Relax the
	condition for doing invariant checks so that in-mode parameters
	of procedures are also checked (required by AI05-0289, and
	restricted to procedures by AI12-0044). This is done in a
	procedure's nested postconditions procedure.
	* exp_ch6.adb (Expand_Actuals): Also perform postcall invariant
	checks for in parameters of procedures (but not functions).
	Moved invariant-checking code to end of Expand_Actuals
	(including the nested function Is_Public_Subp).
2020-07-07 05:26:55 -04:00
Piotr Trojanek
845c49360b [Ada] Change local object from variable to constant
gcc/ada/

	* sem_aggr.adb (Resolve_Delta_Array_Aggregate): Make Index_Type
	a constant.
2020-07-07 05:26:54 -04:00
Piotr Trojanek
c78efe921c [Ada] Fix expansion of delta aggregates with slices
gcc/ada/

	* exp_aggr.adb (Expand_N_Delta_Aggregate): Use type of the delta
	base expression for the anonymous object of the delta aggregate.
2020-07-07 05:26:54 -04:00
Javier Miranda
dab6432039 [Ada] Ada2020: AI12-0198 potentially unevaluated components of arrays
gcc/ada/

	* sem_util.ads (Interval_Lists): Reordering routine.
	* sem_util.adb (Interval_Lists): Reordering routines to keep
	them alphabetically ordered.
2020-07-07 05:26:54 -04:00
Piotr Trojanek
4ea624b0f9 [Ada] Remove extra checks for non-static context from resolving 'Update
gcc/ada/

	* sem_attr.adb (Resolve_Attribute): Do not call
	Check_Non_Static_Context.
2020-07-07 05:26:53 -04:00
Arnaud Charlet
1948dcab16 [Ada] Spurious elaboration warnings with -gnatc and null procedures
gcc/ada/

	* sem_elab.adb (Is_Guaranteed_ABE): Take into account null
	procedures.
2020-07-07 05:26:53 -04:00
Piotr Trojanek
62226c3554 [Ada] Minor cleanup with Is_Assignable
gcc/ada/

	* sem_ch5.adb (Analyze_Assignment): Reuse Is_Assignable.
2020-07-07 05:26:53 -04:00
Piotr Trojanek
db290a9e37 [Ada] Set range checks for for 'Update on arrays in GNATprove expansion
gcc/ada/

	* exp_spark.adb (Expand_SPARK_N_Attribute_Reference): Add scalar
	range checks for 'Update on arrays just like for 'Update on
	records.
	* sem_attr.adb (Analyze_Array_Component_Update): Do not set
	range checks for single-dimensional arrays.
	(Resolve_Attribute): Do not set range checks for both single-
	and multi- dimensional arrays.
2020-07-07 05:26:53 -04:00
Piotr Trojanek
c0ceffbebd [Ada] Style fixes in the description of Analysis-Resolution-Expansion
gcc/ada/

	* sem.ads (Sem): Fix description.
2020-07-07 05:26:52 -04:00
Piotr Trojanek
aeef2df937 [Ada] Allow aspect Relaxed_Initialization on protected entries
gcc/ada/

	* sem_ch13.adb (Analyze_Relaxed_Parameter): Fix for protected
	entries.
2020-07-07 05:26:52 -04:00
Qian Jianhua
0ac15b175a Fix a typo in doc/generic.texi
gcc/
	* doc/generic.texi: Fix typo.
2020-07-07 10:12:07 +01:00
Kaipeng Zhou
7ab4f58a85 Pass correct parameters to c_parser_do_statement.
gcc/c/ChangeLog:

	* c-parser.c (c_parser_statement_after_labels): Pass correct
	parameters to c_parser_do_statement.
2020-07-07 10:07:28 +01:00
Jonathan Wakely
92cae0785e libstdc++: Add PR number to ChangeLog entry and fix typos 2020-07-07 08:23:12 +01:00
Alexandre Oliva
a759bfc7cf
accept <case> and [cond] in ChangeLog
Only '(' and ':' currently terminate file lists in ChangeLog entries
in the ChangeLog parser.  This rules out such legitimate entries as:

* filename <CASE>:
* filename [COND]:

This patch extends the ChangeLog parser to recognize these forms.

for  contrib/ChangeLog

	* gcc-changelog/git_commit.py: Support CASE and COND.
	* gcc-changelog/test_patches.txt: Add test.
	* gcc-changelog/test_email.py: Add test.

Co-Authored-By: Martin Liska <mliska@suse.cz>
2020-07-07 09:05:10 +02:00
Richard Biener
c50502ca4e fix LTO streaming order dependence on randomness
This fixes the sorting of to copy symbols in lto_output introduced
with GCC 10 to not depend on the actual values of the randomness
we append to LTO section names but instead on the order they appear
in the unsorted array.

This fixed observed debug info differences due to tree merging
prevailing different early debug pointers.

2020-07-06  Richard Biener  <rguenther@suse.de>

	* lto-streamer-out.c (cmp_symbol_files): Use the computed
	order map to sort symbols from the same sub-file together.
	(lto_output): Compute a map of sub-file to an order number
	it appears in the symbol output array.
2020-07-07 08:43:23 +02:00
GCC Administrator
4077d74c6d Daily bump. 2020-07-07 00:16:40 +00:00
Martin Sebor
67a493a0b9 Exclude calls to variadic lambda stubs from -Wnonnull checking (PR c++/95984).
Resolves:
PR c++/95984 - Internal compiler error: Error reporting routines re-entered in -Wnonnull on a variadic lamnda
PR c++/96021 - missing -Wnonnull passing nullptr to a nonnull variadic lambda

gcc/c-family/ChangeLog:

	PR c++/95984
	* c-common.c (check_function_nonnull): Avoid checking syntesized calls
	to stub lambda objects with null this pointer.
	(check_nonnull_arg): Handle C++ nullptr.

gcc/cp/ChangeLog:

	PR c++/95984
	* call.c (build_over_call): Check calls only when tf_warning is set.

gcc/testsuite/ChangeLog:

	PR c++/95984
	* g++.dg/warn/Wnonnull6.C: New test.
2020-07-06 15:23:37 -06:00
Jonathan Wakely
6e1c9715b3 libstdc++: Cleanup whitespace and type trait usage in <optional>
This makes the formatting in <optional> consistent and also removes
redundant && tokens from template arguments for traits like
is_constructible and is_convertible.

libstdc++-v3/ChangeLog:

	* include/std/optional (_Optional_payload_base, _Optional_base)
	(optional, __optional_hash_call_base): Adjust whitespace and
	other formatting. Remove redundant && tokens on template
	arguments to type traits.
2020-07-06 21:55:50 +01:00
Jonathan Wakely
bcfe4681f9 libstdc++: Constrain std::make_optional
The standard rquires that std::make_optional is constrained similarly to
the std::optional constructors, which our implementation fails to do.

As a conforming extension this also adds a noexcept-specifier to each
std::make_optional overload.

libstdc++-v3/ChangeLog:

	* include/std/optional (make_optional): Add enable_if
	constraints and noexcept-specifier to each overload.
	* testsuite/20_util/optional/make_optional-2.cc: New test.
2020-07-06 21:54:59 +01:00
Jonathan Wakely
8992cd1892 libstdc++: Add noexcept to std::optional initialization (PR 96036)
libstdc++-v3/ChangeLog:

	PR libstdc++/96036
	* include/std/optional (optional): Add noexcept-specifier to
	every constructor, assignment operator, emplace function and
	dereference operator.
	* testsuite/20_util/optional/assignment/noexcept.cc: New test.
	* testsuite/20_util/optional/cons/noexcept.cc: New test.
2020-07-06 21:54:12 +01:00
Nathan Sidwell
e88218fd5a c++: Always use pushdecl for exception library helpers
The ABI exception helpers like __throw were being created by first
looking for them, and then adding if not found.  Primarily because
libitm wasn't declaring them with the correct exception specifiers.  I
fixed libitm a while back, so let's just use push_library_fn and let
the symbol table machinery deal with duplicates.  push_library_fn was
making the assumtion there wasn't already a decl available, by always
returning the new decl.  Bad things would happen if there was a
duplicate, because duplicate_decls explicitly gcc_frees the new decl.
Fixed by having it return whatever pushdecl returns.

	gcc/cp/
	* decl.c (push_library_fn): Return the decl pushdecl_toplevel returns.
	* except.c (verify_library_fn): Replace with ...
	(declare_library_fn_1): ... this fn.  Always push the fn.
	(declare_library_fn): Call it.
	(build_throw): Call declare_library_fn_1.
	gcc/testsuite/
	* g++.dg/eh/builtin10.C: Adjust expected errors.
	* g++.dg/eh/builtin11.C: Likewise.
	* g++.dg/eh/builtin5.C: Likewise.
	* g++.dg/eh/builtin6.C: Likewise.
	* g++.dg/eh/builtin7.C: Likewise.
	* g++.dg/eh/builtin9.C: Likewise.
	* g++.dg/parse/crash55.C: Likewise.
2020-07-06 10:02:46 -07:00
Harald Anlauf
f2151227df PR fortran/95980 - ICE on using sync images with -fcheck=bounds
In SELECT TYPE, the argument may be an incorrectly specified unlimited
polymorphic variable.  Avoid a NULL pointer dereference for clean error
recovery.

gcc/fortran/
	PR fortran/95980
	* match.c (copy_ts_from_selector_to_associate, build_class_sym):
	Distinguish between unlimited polymorphic and ordinary variables
	to avoid NULL pointer dereference.
	* resolve.c (resolve_select_type):
	Distinguish between unlimited polymorphic and ordinary variables
	to avoid NULL pointer dereference.
2020-07-06 19:00:10 +02:00
Harald Anlauf
824084e72e PR fortran/95709 - ICE in gfc_resolve_code, at fortran/resolve.c:11807
The legacy "assigned GOTO" accepts only scalar integer variables.
Check for proper arguments.

gcc/fortran/
	PR fortran/95709
	* resolve.c (gfc_resolve_code): Check for valid arguments to
	assigned GOTO.
2020-07-06 18:52:39 +02:00