aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
AgeCommit message (Collapse)AuthorFilesLines
2019-12-10Replace label_text ctor with "borrow" and "take"David Malcolm2-2/+7
libcpp's label_text class wraps a text buffer, along with a flag to determine if it "owns" the buffer. The existing ctor exposed this directly, but I found it difficult to remember the sense of flag, so this patch hides the ctor, in favor of static member functions "borrow" and "take", to make the effect on ownership explicit in the name. gcc/c-family/ChangeLog: * c-format.c (range_label_for_format_type_mismatch::get_text): Replace label_text ctor called with true with label_text::take. gcc/c/ChangeLog: * c-objc-common.c (range_label_for_type_mismatch::get_text): Replace label_text ctor calls. gcc/cp/ChangeLog: * error.c (range_label_for_type_mismatch::get_text): Replace label_text ctor calls with label_text::borrow. gcc/ChangeLog: * gcc-rich-location.c (maybe_range_label_for_tree_type_mismatch::get_text): Replace label_text ctor call with label_text::borrow. * gcc-rich-location.h (text_range_label::get_text): Replace label_text ctor called with false with label_text::borrow. libcpp/ChangeLog: * include/line-map.h (label_text::label_text): Make private. (label_text::borrow): New. (label_text::take): New. (label_text::take_or_copy): New. From-SVN: r279153
2019-12-04Fix C handling of use of lvalues of incomplete types (PR c/36941, PR c/88827).Joseph Myers3-13/+12
Bug 88827 points out that GCC should not be rejecting C code that dereferences a pointer to an incomplete type in the case that uses &* to take the address of the resulting lvalue, because no constraint is violated in that case (other than for C90 when the incomplete type is unqualified void, which we already handle correctly) and as the lvalue never gets converted to an rvalue there is no undefined behavior either. This means that the diagnostic for such a dereference is bogus and should be removed; if the lvalue gets converted to an rvalue, there should be an appropriate error later for the use of the incomplete type. In most cases, there is, but bug 36941 points out the lack of a diagnostic when the incomplete (non-void) type gets cast to void (where a diagnostic seems appropriate for this undefined behavior as a matter of quality of implementation). This patch removes the bogus diagnostic (and C_TYPE_ERROR_REPORTED which was only used in the code that is removed - only that one, bogus diagnostic had this duplicate suppression, not any of the other, more legitimate diagnostics for use of incomplete types) and makes convert_lvalue_to_rvalue call require_complete_type for arguments not of void types, so that all relevant code paths (possibly except some for ObjC) get incomplete types diagnosed. It's possible that this makes some other checks for incomplete types obsolete, but no attempt is made to remove any such checks. Bootstrapped with no regressions for x86_64-pc-linux-gnu. PR c/36941 PR c/88827 gcc/c: * c-typeck.c (convert_lvalue_to_rvalue): Call require_complete_type for arguments not of void types. (build_indirect_ref): Do not diagnose dereferencing pointers to incomplete types. * c-tree.h (C_TYPE_ERROR_REPORTED): Remove. gcc/testsuite: * gcc.dg/lvalue-9.c, gcc.dg/lvalue-10.c: New tests. * gcc.dg/array-8.c, gcc.dg/enum-incomplete-1.c, gcc.dg/enum-incomplete-3.c, gcc.dg/noncompile/incomplete-3.c, gcc.dg/pr48552-1.c, gcc.dg/pr48552-2.c, gcc.dg/pr63543.c, gcc.dg/pr69796.c: Update expected diagnostics. From-SVN: r278976
2019-12-03Diagnose use of [*] in old-style parameter definitions (PR c/88704).Joseph Myers2-0/+9
GCC wrongly accepts [*] in old-style parameter definitions because because parm_flag is set on the scope used for those definitions and, unlike the case of a prototype in a function definition, there is no subsequent check to disallow this invalid usage. This patch adds such a check. (At this point we don't have location information for the [*], so the diagnostic location isn't ideal.) Bootstrapped with no regressions for x86_64-pc-linux-gnu. PR c/88704 gcc/c: * c-decl.c (store_parm_decls_oldstyle): Diagnose use of [*] in old-style parameter definitions. gcc/testsuite: * gcc.dg/vla-25.c: New test. From-SVN: r278917
2019-12-01Fix bugs relating to flexibly-sized objects in nios2 backend.Sandra Loosemore2-33/+6
2019-12-01 Sandra Loosemore <sandra@codesourcery.com> Fix bugs relating to flexibly-sized objects in nios2 backend. PR target/92499 gcc/c/ * c-decl.c (flexible_array_type_p): Move to common code. gcc/ * config/nios2/nios2.c (nios2_in_small_data_p): Do not consider objects of flexible types to be small if they have internal linkage or are declared extern. * config/nios2/nios2.h (ASM_OUTPUT_ALIGNED_LOCAL): Replace with... (ASM_OUTPUT_ALIGNED_DECL_LOCAL): ...this. Use targetm.in_small_data_p instead of the size of the object initializer. * tree.c (flexible_array_type_p): Move from C front end, and generalize to handle fields in non-C structures. * tree.h (flexible_array_type_p): Declare. gcc/testsuite/ * gcc.target/nios2/pr92499-1.c: New. * gcc.target/nios2/pr92499-2.c: New. * gcc.target/nios2/pr92499-3.c: New. From-SVN: r278891
2019-11-30[C] Add a target hook that allows targets to verify type usageRichard Sandiford3-2/+49
This patch adds a new target hook to check whether there are any target-specific reasons why a type cannot be used in a certain source-language context. It works in a similar way to existing hooks like TARGET_INVALID_CONVERSION and TARGET_INVALID_UNARY_OP. The reason for adding the hook is to report invalid uses of SVE types. Throughout a TU, the SVE vector and predicate types represent values that can be stored in an SVE vector or predicate register. At certain points in the TU we might be able to generate code that assumes the registers have a particular size, but often we can't. In some cases we might even make multiple different assumptions in the same TU (e.g. when implementing an ifunc for multiple vector lengths). But SVE types themselves are the same type throughout. The register size assumptions change how we generate code, but they don't change the definition of the types. This means that the types do not have a fixed size at the C level even when -msve-vector-bits=N is in effect. It also means that the size does not work in the same way as for C VLAs, where the abstract machine evaluates the size at a particular point and then carries that size forward to later code. The SVE ACLE deals with this by making it invalid to use C and C++ constructs that depend on the size or layout of SVE types. The spec refers to the types as "sizeless" types and defines their semantics as edits to the standards. See: https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00868.html for a fuller description and: https://gcc.gnu.org/ml/gcc/2019-11/msg00088.html for a recent update on the status. However, since all current sizeless types are target-specific built-in types, there's no real reason for the frontends to handle them directly. They can just hand off the checks to target code instead. It's then possible for the errors to refer to "SVE types" rather than "sizeless types", which is likely to be more meaningful to users. There is a slight overlap between the new tests and the ones for gnu_vector_type_p in r277950, but here the emphasis is on testing sizelessness. 2019-11-30 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.h (type_context_kind): New enum. (verify_type_context): Declare. * target.def (verify_type_context): New target hook. * doc/tm.texi.in (TARGET_VERIFY_TYPE_CONTEXT): Likewise. * doc/tm.texi: Regenerate. * tree.c (verify_type_context): New function. * config/aarch64/aarch64-protos.h (aarch64_sve::verify_type_context): Declare. * config/aarch64/aarch64-sve-builtins.cc (verify_type_context): New function. * config/aarch64/aarch64.c (aarch64_verify_type_context): Likewise. (TARGET_VERIFY_TYPE_CONTEXT): Define. gcc/c-family/ * c-common.c (pointer_int_sum): Use verify_type_context to check whether the target allows pointer arithmetic for the types involved. (c_sizeof_or_alignof_type, c_alignof_expr): Use verify_type_context to check whether the target allows sizeof and alignof operations for the types involved. gcc/c/ * c-decl.c (start_decl): Allow initialization of variables whose size is a POLY_INT_CST. (finish_decl): Use verify_type_context to check whether the target allows variables with a particular type to have static or thread-local storage duration. Don't raise a second error if such variables do not have a constant size. (grokdeclarator): Use verify_type_context to check whether the target allows fields or array elements to have a particular type. * c-typeck.c (pointer_diff): Use verify_type_context to test whether the target allows pointer difference for the types involved. (build_unary_op): Likewise for pointer increment and decrement. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general-c/sizeless-1.c: New test. * gcc.target/aarch64/sve/acle/general-c/sizeless-2.c: Likewise. From-SVN: r278877
2019-11-29Handle C2x attributes in Objective-C.Joseph Myers2-13/+158
When adding the initial support for C2x attributes, I deferred the unbounded lookahead support required to support such attributes in Objective-C (except for the changes to string literal handling, which were the riskier piece of preparation for such lookahead support). This patch adds that remaining ObjC support. For C, the parser continues to work exactly as it did before. For ObjC, however, when checking for whether '[[' starts attributes, it lexes however many tokens are needed to check for a matching ']]', but in a raw mode that omits all the context-sensitive processing that c_lex_with_flags normally does, so that that processing can be done later when the right context-sensitive flags are set. Those tokens are saved in a separate raw_tokens vector in the parser, and normal c_lex_one_token calls will get tokens from there and perform the remaining processing on them, if any tokens are found there, so all parsing not using the new interfaces gets the same tokens as it did before. (For C, this raw lexing never occurs and the vector of raw tokens is always NULL.) Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c: * c-parser.c (struct c_parser): Add members raw_tokens and raw_tokens_used. (c_lex_one_token): Add argument raw. Handle lexing raw tokens and using previously-lexed raw tokens. (c_parser_peek_nth_token_raw) (c_parser_check_balanced_raw_token_sequence): New functions. (c_parser_nth_token_starts_std_attributes): Use c_parser_check_balanced_raw_token_sequence for Objective-C. gcc/testsuite: * objc.dg/attributes/gnu2x-attr-syntax-1.m: New test. From-SVN: r278827
2019-11-25Prevent all uses of DFP when unsupported (PR c/91985).Joseph Myers2-1/+9
Code that directly uses _Decimal* types on architectures not supporting DFP is properly diagnosed ("error: decimal floating-point not supported for this target"), via a call to targetm.decimal_float_supported_p, if the _Decimal32, _Decimal64 or _Decimal128 keywords are used to access it. Use via mode attributes is also diagnosed ("unable to emulate 'SD'"); so is use of the FLOAT_CONST_DECIMAL64 pragma. However, it is possible to access those types via typeof applied to constants or built-in functions without such an error. I expect that there are ways to get an ICE from this; certainly it uses a completely undefined ABI. This patch arranges for the types not to exist in the compiler at all when DFP is not supported. As is done with unsupported _FloatN / _FloatNx types, the global tree nodes are left as NULL_TREE, and the built-in function machinery is made to use error_mark_node for them in that case in builtin-types.def, so that the built-in functions are unavailable. Code handling constants is adjusted to give an error, and other code that might not work with the global tree nodes being NULL_TREE is also updated. Bootstrapped with no regressions for x86_64-pc-linux-gnu. Also tested with no regressions for cross to aarch64-linux-gnu, as a configuration without DFP support. PR c/91985 gcc: * builtin-types.def (BT_DFLOAT32, BT_DFLOAT64, BT_DFLOAT128) (BT_DFLOAT32_PTR, BT_DFLOAT64_PTR, BT_DFLOAT128_PTR): Define to error_mark_node if corresponding global tree node is NULL. * tree.c (build_common_tree_nodes): Do not initialize dfloat32_type_node, dfloat64_type_node or dfloat128_type_node if decimal floating-point not supported. gcc/c: * c-decl.c (finish_declspecs): Use int instead of decimal floating-point types if decimal floating-point not supported. gcc/c-family: * c-common.c (c_common_type_for_mode): Handle decimal floating-point types being NULL_TREE. * c-format.c (get_format_for_type_1): Handle specified types being NULL_TREE. * c-lex.c (interpret_float): Give an error for decimal floating-point constants when decimal floating-point not supported. gcc/lto: * lto-lang.c (lto_type_for_mode): Handle decimal floating-point types being NULL_TREE. gcc/testsuite: * gcc.dg/c2x-no-dfp-1.c, gcc.dg/gnu2x-builtins-no-dfp-1.c: New tests. * gcc.dg/fltconst-pedantic-dfp.c: Expect errors when decimal floating-point not supported. From-SVN: r278684
2019-11-25Properly handle C2x attributes on types.Joseph Myers5-43/+63
attribs.c has code to ignore all scoped attributes appertaining to types except when they are part of the definition of that type. I think the premise of that code is incorrect, and its presence is a bug; such attributes are clearly valid in both C and C++, which explicitly specify that attributes in certain syntactic positions appertain to a particular type, only for that use of that type and not for other uses of the same type specifiers without that attribute specified, and while the standard attributes in C2x aren't relevant in such contexts, some gnu:: attributes certainly are. Where some attributes are invalid on some types in such contexts, that's a matter for the individual attribute handlers to diagnose (or the front end if the requirements on a standard attribute in the standard are more strict than those of a handler shared with a GNU attribute). Thus, this patch removes the bogus code to allow such attributes to be used. Doing so (and adding tests for attributes in such positions) shows up that the logic in the C front end for creating the c_declarator structures for such attributes put them in the wrong place relative to the structures for function and array types, and the logic for postfix attributes on a list of declaration specifiers failed to handle some cases, so those bugs are also fixed in this patch. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc: * attribs.c (decl_attributes): Do not ignore C++11 attributes on types. gcc/c: * c-tree.h (struct c_declarator): Use a structure for id member. * c-decl.c (grokdeclarator): Extract attributes from cdk_id declarators at the start, not when handling individual declarators later. Use u.id.id instead of u.id. (grokfield): Use u.id.id instead of u.id. (build_id_declarator): Set u.id.id and u.id.attrs. (finish_declspecs): Handle postfix attributes in case of typedef name or typeof used. * c-parser.c (c_parser_direct_declarator) (c_parser_direct_declarator_inner): Place declarator for attributes inside that for function or array, not outside. Set u.id.attrs for identifiers. (c_parser_parameter_declaration): Use u.id.id instead of u.id. * gimple-parser.c (c_parser_gimple_declaration): Use u.id.id instead of u.id. gcc/testsuite: * gcc.dg/gnu2x-attrs-1.c: Do not expect message about attributes appertaining to types. * gcc.dg/gnu2x-attrs-2.c: New test. * g++.dg/cpp0x/gen-attrs-1.C, g++.dg/cpp0x/gen-attrs-22.C, g++.dg/cpp0x/gen-attrs-4.C, g++.dg/cpp0x/lambda/lambda-attr1.C: Update expected diagnostics. From-SVN: r278683
2019-11-22re PR c/90677 (gcc-9.1.0 fails to build __gcc_diag__ souce: error: ↵Jakub Jelinek2-0/+19
'cgraph_node' is not defined as a type) PR c/90677 * c-common.h (identifier_global_tag): Declare. * c-format.c (get_pointer_to_named_type): Renamed to ... (get_named_type): ... this. Use identifier_global_tag instead of identifier_global_value, handle the return value being a TYPE_P. (init_dynamic_diag_info): Adjust get_pointer_to_named_type callers to call get_named_type instead. Formatting fixes. c/ * c-decl.c (identifier_global_tag): Define. cp/ * cp-objcp-common.c (identifier_global_tag): Define. testsuite/ * c-c++-common/pr90677.c: New test. From-SVN: r278634
2019-11-20re PR c/92088 (aggregates with VLAs and nested functions are broken)Richard Biener2-0/+23
2019-11-20 Richard Biener <rguenther@suse.de> PR c/92088 c/ * c-decl.c (grokdeclarator): Prevent inlining of nested function with VLA arguments. * builtins.c (compute_objsize): Deal with VLAs. * gcc.dg/torture/pr92088-1.c: New testcase. * gcc.dg/torture/pr92088-2.c: Likewise. From-SVN: r278477
2019-11-20Add more pedwarns for [[]] C attributes on types.Joseph Myers3-4/+37
The standard [[]] attributes currently defined in C2x are all not valid on types not being defined at the time. Use on such types results in a warning from attribs.c about attributes appertaining to types (the warning that I think is bogus in general for both C and C++, applying as it does to all [[]] attributes including gnu:: ones that are perfectly meaningful on types not being defined and work fine when __attribute__ syntax is used instead). If that warning is removed (as I intend to do in a subsequent patch), warnings may or may not result from the attribute handlers, depending on whether those particular attribute handlers consider the attributes meaningful in such a context. In C, however, the rules about where each [[]] attribute is valid are constraints, so a pedwarn, not a warning, is required. Because some handlers are shared between standard and gnu:: attributes, there can be cases that are valid for the GNU attribute variant but not for the standard one. So in general it is not correct to rely on the attribute handlers to give all required pedwarns (although in some cases, a pedwarn in the attribute handler is in appropriate way of diagnosing an invalid use); they not have the information about whether the attribute was a gnu:: one and can legitimately accept a wider range of uses for the gnu:: attributes. This patch ensures appropriate diagnostics for invalid uses of C2x standard attributes on types, and so helps pave the way for the subsequent removal of the bogus check in attribs.c, by adding a check run in the front end before calling decl_attributes; this check removes the attributes from the list after calling pedwarn to avoid subsequent duplicate warnings. Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c: * c-decl.c (c_warn_type_attributes): New function. (groktypename, grokdeclarator, finish_declspecs): Call c_warn_type_attributes before applying attributes to types. * c-tree.h (c_warn_type_attributes): Declare. gcc/testsuite: * gcc.dg/c2x-attr-deprecated-2.c, gcc.dg/c2x-attr-fallthrough-2.c, gcc.dg/c2x-attr-maybe_unused-2.c: Expect errors for invalid uses of standard attributes on types. Add more tests of invalid uses on types. From-SVN: r278471
2019-11-19Change some bad uses of C2x attributes into pedwarns.Joseph Myers3-34/+62
Certain bad uses of C2x standard attributes (that is, attributes inside [[]] with only a name but no namespace specified) are constraint violations, and so should be diagnosed with a pedwarn (or error) where GCC currently uses a warning. This patch implements this in some cases (not yet for attributes used on types, nor for some bad uses of fallthrough attributes). Specifically, this applies to unknown standard attributes (taking care not to pedwarn for nodiscard, which is known but not implemented for C), and to all currently implemented standard attributes in attribute declarations (including when mixed with fallthrough) and on statements. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-decl.c (c_warn_unused_attributes): Use pedwarn not warning for standard attributes. * c-parser.c (c_parser_std_attribute): Take argument for_tm. Use pedwarn for unknown standard attributes and return error_mark_node for them. gcc/c-family: * c-common.c (attribute_fallthrough_p): In C, use pedwarn not warning for standard attributes mixed with fallthrough attributes. gcc/testsuite: * gcc.dg/c2x-attr-fallthrough-5.c, gcc.dg/c2x-attr-syntax-5.c: New tests. * gcc.dg/c2x-attr-deprecated-2.c, gcc.dg/c2x-attr-deprecated-4.c, gcc.dg/c2x-attr-fallthrough-2.c, gcc.dg/c2x-attr-maybe_unused-2.c, gcc.dg/c2x-attr-maybe_unused-4.c: Expect errors in place of some warnings. From-SVN: r278428
2019-11-18[mid-end][__RTL] Clean state despite unspecified __RTL startwith passesMatthew Malcomson2-5/+8
Hi there, When compiling an __RTL function that has an unspecified "startwith" pass we currently don't run the cleanup pass, this means that we ICE on the next function (if it's a basic function). This change ensures that the clean_state pass is run even if the startwith pass is unspecified. We also ensure the name of the startwith pass is always freed correctly. As an example, before this change the following code would ICE when compiling the function `foo_a`. When compiled with ./aarch64-none-linux-gnu-gcc -O0 -S unspecified-pass-error.c -o test.s ``` int __RTL () badfoo () { (function "badfoo" (insn-chain (block 2 (edge-from entry (flags "FALLTHRU")) (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK) (cinsn 101 (set (reg:DI x19) (reg:DI x0))) (cinsn 10 (use (reg/i:SI x19))) (edge-to exit (flags "FALLTHRU")) ) ;; block 2 ) ;; insn-chain ) ;; function "foo2" } int foo_a () { return 200; } ``` Now it silently ignores the __RTL function and successfully compiles foo_a. regtest done on aarch64 regtest done on x86_64 OK for trunk? gcc/ChangeLog: 2019-11-18 Matthew Malcomson <matthew.malcomson@arm.com> * run-rtl-passes.c (run_rtl_passes): Accept and handle empty "initial_pass_name" argument -- by running "*clean_state" pass. Also free the "initial_pass_name" when done. gcc/c/ChangeLog: 2019-11-18 Matthew Malcomson <matthew.malcomson@arm.com> * c-parser.c (c_parser_parse_rtl_body): Always call run_rtl_passes, even if startwith pass is not provided. gcc/testsuite/ChangeLog: 2019-11-18 Matthew Malcomson <matthew.malcomson@arm.com> * gcc.dg/rtl/aarch64/unspecified-pass-error.c: New test. From-SVN: r278393
2019-11-15Diagnose duplicate C2x standard attributes.Joseph Myers2-2/+57
For each of the attributes currently included in C2x, it has a constraint that the attribute shall appear at most once in each attribute list (attribute-list being what appear between a single [[ and ]]). This patch implements that check. As the corresponding check in the C++ front end (cp_parser_check_std_attribute) makes violations into errors, I made them into errors, with the same wording, for C as well. There is an existing check in the case of the fallthrough attribute, with a warning rather than an error, in attribute_fallthrough_p. That is more general, as it also covers __attribute__ ((fallthrough)) and the case of [[fallthrough]] [[fallthrough]] (multiple attribute-lists in a single attribute-specifier-sequence), which is not a constraint violation. To avoid some [[fallthrough, fallthrough]] being diagnosed twice, the check I added avoids adding duplicate attributes to the list. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-parser.c (c_parser_std_attribute_specifier): Diagnose duplicate standard attributes. gcc/testsuite: * gcc.dg/c2x-attr-deprecated-4.c, gcc.dg/c2x-attr-fallthrough-4.c, gcc.dg/c2x-attr-maybe_unused-4.c: New tests. From-SVN: r278324
2019-11-15Support C2x [[maybe_unused]] attribute.Joseph Myers2-0/+6
This patch adds support for the C2x [[maybe_unused]] attribute, using the same handler as for GNU __attribute__ ((unused)). As with other such attribute support, I think turning certain warnings into pedwarns for usage in cases where that is a constraint violation can be addressed later as a bug fix, as can the C2x constraint for various standard attributes that they do not appear more than once inside a single [[]]. However, the warnings that appear in c2x-attr-maybe_unused-1.c (that the attribute is ignored on member declarations) need to remain as warnings not pedwarns, since C2x does permit the attribute there. (Or they could be silenced, on the basis that GCC doesn't have warnings for unused struct and union members so it's completely harmless that it's ignoring an attribute that might do something useful with another compiler that does have such warnings.) Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-decl.c (std_attribute_table): Add maybe_unused. gcc/testsuite: * gcc.dg/c2x-attr-maybe_unused-1.c, gcc.dg/c2x-attr-maybe_unused-2.c, gcc.dg/c2x-attr-maybe_unused-3.c: New tests. From-SVN: r278310
2019-11-15Improve checks on C2x fallthrough attribute.Joseph Myers3-3/+17
When adding C2x attribute support, some [[fallthrough]] support appeared as a side-effect because of code for that attribute going through separate paths from the normal attribute handling. However, going through those paths without the normal attribute handlers meant that certain checks, such as for the invalid usage [[fallthrough()]], did not operate. This patch improves checks by adding this attribute to the standard attribute table, so that the parser knows it expects no arguments, along with adding an explicit check for "[[fallthrough]];" attribute-declarations at top level. As with other attributes, there are still cases where warnings should be pedwarns because C2x constraints are violated, but this patch improves the attribute handling. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-decl.c (std_attribute_table): Add fallthrough. * c-parser.c (c_parser_declaration_or_fndef): Diagnose fallthrough attribute at top level. gcc/c-family: * c-attribs.c (handle_fallthrough_attribute): Remove static. * c-common.h (handle_fallthrough_attribute): Declare. gcc/testsuite: * gcc.dg/c2x-attr-fallthrough-2.c, gcc.dg/c2x-attr-fallthrough-3.c: New tests. From-SVN: r278273
2019-11-15Support C2x [[deprecated]] attribute.Joseph Myers3-4/+46
This patch adds support for the C2x [[deprecated]] attribute. All the actual logic for generating warnings can be identical to the GNU __attribute__ ((deprecated)), as can the attribute handler, so this is just a matter of wiring things up appropriately and adding the checks specified in the standard. Unlike for C++, this patch gives "deprecated" an entry in a table of standard attributes rather than remapping it internally to the GNU attribute, as that seems a cleaner approach to me. Specifically, the only form of arguments to the attribute permitted in the standard is (string-literal); empty parentheses are not permitted in the case of no arguments, and a string literal (which includes concatenated adjacent string literals, because concatenation is an earlier phase of translation) cannot have further redundant parentheses around it. For the case of empty parentheses, this patch makes the C parser disallow them for all known attributes using the [[]] syntax, as done for C++. For string literals (where the C++ front end is missing the check to avoid redundant parentheses, 92521 filed for that issue), a special case is inserted in the C parser. A known issue that I think can be addressed later as a bug fix is that the warnings for the attribute being ignored in certain cases (attribute declarations, statements, most uses on types) ought to be pedwarns, as those usages are constraint violations. Bad handling of wide string literals with this attribute is also a pre-existing bug (91182 - although that's filed as a C++ bug, the code in question is language-independent, in tree.c). Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-decl.c (std_attribute_table): New. (c_init_decl_processing): Register attributes from std_attribute_table. * c-parser.c (c_parser_attribute_arguments): Add arguments require_string and allow_empty_args. All callers changed. (c_parser_std_attribute): Set require_string argument for "deprecated" attribute. gcc/c-family: * c-attribs.c (handle_deprecated_attribute): Remove static. * c-common.h (handle_deprecated_attribute): Declare. gcc/testsuite: * gcc.dg/c2x-attr-deprecated-1.c, gcc.dg/c2x-attr-deprecated-2.c, gcc.dg/c2x-attr-deprecated-3.c: New tests. From-SVN: r278268
2019-11-14Support UTF-8 character constants for C2x.Joseph Myers3-0/+9
C2x adds u8'' character constants to C. This patch adds the corresponding GCC support. Most of the support was already present for C++ and just needed enabling for C2x. However, in C2x these constants have type unsigned char, which required corresponding adjustments in the compiler and the preprocessor to give them that type for C. For C, it seems clear to me that having type unsigned char means the constants are unsigned in the preprocessor (and thus treated as having type uintmax_t in #if conditionals), so this patch implements that. I included a conditional in the libcpp change to avoid affecting signedness for C++, but I'm not sure if in fact these constants should also be unsigned in the preprocessor for C++ in which case that !CPP_OPTION (pfile, cplusplus) conditional would not be needed. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-parser.c (c_parser_postfix_expression) (c_parser_check_literal_zero): Handle CPP_UTF8CHAR. * gimple-parser.c (c_parser_gimple_postfix_expression): Likewise. gcc/c-family: * c-lex.c (lex_charconst): Make CPP_UTF8CHAR constants unsigned char for C. gcc/testsuite: * gcc.dg/c11-utf8char-1.c, gcc.dg/c2x-utf8char-1.c, gcc.dg/c2x-utf8char-2.c, gcc.dg/c2x-utf8char-3.c, gcc.dg/gnu2x-utf8char-1.c: New tests. libcpp: * charset.c (narrow_str_to_charconst): Make CPP_UTF8CHAR constants unsigned for C. * init.c (lang_defaults): Set utf8_char_literals for GNUC2X and STDC2X. From-SVN: r278265
2019-11-14Remove build_{same_sized_,}truth_vector_typeRichard Sandiford2-2/+8
build_same_sized_truth_vector_type was confusingly named, since for SVE and AVX512 the returned vector isn't the same byte size (although it does have the same number of elements). What it really returns is the "truth" vector type for a given data vector type. The more general truth_type_for provides the same thing when passed a vector and IMO has a more descriptive name, so this patch replaces all uses of build_same_sized_truth_vector_type with that. It does the same for a call to build_truth_vector_type, leaving truth_type_for itself as the only remaining caller. It's then more natural to pass build_truth_vector_type the original vector type rather than its size and nunits, especially since the given size isn't the size of the returned vector. This in turn allows a future patch to simplify the interface of get_mask_mode. Doing this also fixes a bug in which truth_type_for would pass a size of zero for BLKmode vector types. 2019-11-14 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree.h (build_truth_vector_type): Delete. (build_same_sized_truth_vector_type): Likewise. * tree.c (build_truth_vector_type): Rename to... (build_truth_vector_type_for): ...this. Make static and take a vector type as argument. (truth_type_for): Update accordingly. (build_same_sized_truth_vector_type): Delete. * tree-vect-generic.c (expand_vector_divmod): Use truth_type_for instead of build_same_sized_truth_vector_type. * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise. (vect_record_loop_mask, vect_get_loop_mask): Likewise. * tree-vect-patterns.c (build_mask_conversion): Likeise. * tree-vect-slp.c (vect_get_constant_vectors): Likewise. * tree-vect-stmts.c (vect_get_vec_def_for_operand): Likewise. (vect_build_gather_load_calls, vectorizable_call): Likewise. (scan_store_can_perm_p, vectorizable_scan_store): Likewise. (vectorizable_store, vectorizable_condition): Likewise. (get_mask_type_for_scalar_type, get_same_sized_vectype): Likewise. (vect_get_mask_type_for_stmt): Use truth_type_for instead of build_truth_vector_type. * config/aarch64/aarch64-sve-builtins.cc (gimple_folder::convert_pred): Use truth_type_for instead of build_same_sized_truth_vector_type. * config/rs6000/rs6000-call.c (fold_build_vec_cmp): Likewise. gcc/c/ * c-typeck.c (build_conditional_expr): Use truth_type_for instead of build_same_sized_truth_vector_type. (build_vec_cmp): Likewise. gcc/cp/ * call.c (build_conditional_expr_1): Use truth_type_for instead of build_same_sized_truth_vector_type. * typeck.c (build_vec_cmp): Likewise. gcc/d/ * d-codegen.cc (build_boolop): Use truth_type_for instead of build_same_sized_truth_vector_type. From-SVN: r278232
2019-11-14c-parser.c (c_parser_omp_context_selector): Don't require score argument to ↵Jakub Jelinek2-1/+8
fit into shwi, just to be INTEGER_CST. * c-parser.c (c_parser_omp_context_selector): Don't require score argument to fit into shwi, just to be INTEGER_CST. Diagnose negative score. * parser.c (cp_parser_omp_context_selector): Don't require score argument to fit into shwi, just to be INTEGER_CST. Diagnose negative score. * pt.c (tsubst_attribute): Likewise. * c-c++-common/gomp/declare-variant-2.c: Add test for non-integral score and for negative score. * c-c++-common/gomp/declare-variant-3.c: Add test for zero score. * g++.dg/gomp/declare-variant-8.C: Add test for negative and zero scores. From-SVN: r278204
2019-11-14omp-general.c (omp_context_name_list_prop): New function.Jakub Jelinek2-12/+46
* omp-general.c (omp_context_name_list_prop): New function. (omp_context_selector_matches): Use it. Return 0 if it returns NULL. (omp_context_selector_props_compare): Allow equivalency of an identifier and a string literal containing no embedded zeros. c-family/ * c-omp.c (c_omp_check_context_selector): Handle name lists containing string literals. Don't diagnose atomic_default_mem_order with multiple props. c/ * c-parser.c (c_parser_omp_context_selector): Rename CTX_PROPERTY_IDLIST to CTX_PROPERTY_NAME_LIST, add CTX_PROPERTY_ID. Use CTX_PROPERTY_ID for atomic_default_mem_order, only allow a single identifier in that. For CTX_PROPERTY_NAME_LIST, allow identifiers and string literals. cp/ * parser.c (cp_parser_omp_context_selector): Rename CTX_PROPERTY_IDLIST to CTX_PROPERTY_NAME_LIST, add CTX_PROPERTY_ID. Use CTX_PROPERTY_ID for atomic_default_mem_order, only allow a single identifier in that. For CTX_PROPERTY_NAME_LIST, allow identifiers and string literals. * pt.c (tsubst_attribute): Fix up STRING_CST handling if allow_string. testsuite/ * c-c++-common/gomp/declare-variant-2.c: Adjust expected diagnostics, add a test for atomic_default_mem_order with a string literal. * c-c++-common/gomp/declare-variant-3.c: Use string literal props in a few random places, add a few string literal prop related tests. * c-c++-common/gomp/declare-variant-8.c: Likewise. * c-c++-common/gomp/declare-variant-9.c: Use string literal props in a few random places. * c-c++-common/gomp/declare-variant-10.c: Likewise. * c-c++-common/gomp/declare-variant-11.c: Likewise. * c-c++-common/gomp/declare-variant-12.c: Likewise. * g++.dg/gomp/declare-variant-7.C: Likewise. From-SVN: r278202
2019-11-14Support C2x [[]] attributes for C.Joseph Myers6-123/+489
This patch adds support for the C2x [[]] attribute syntax to the C front end. Support is only added for C at this point, not for Objective-C; I intend to add the unbounded lookahead required to support it for Objective-C in a followup patch, but maybe not in development stage 1. The syntax is supported in all relevant places where the standard says it is supported, but support is not added for the individual attributes specified in C2x (all of which are optional to support). I expect to add support for some of them in followup patches; all except nodiscard can be mapped directly to the semantics of an existing GNU attribute (subject to extra checks for invalid usages such as the same attribute being used more than once inside a single [[]]), and the fallthrough attribute already works after this patch because of existing special-case code handling it (but without some of the checks for invalid usage being present). Note that the four functions c_token_starts_declspecs, c_token_starts_declaration, c_parser_next_token_starts_declspecs and c_parser_next_tokens_start_declaration do *not* accept "[[". This is analogous with the handling of __extension__: both cases have the property that they can start either a declaration or some other statements and so need an unbounded number of tokens to be parsed in the caller before it can find out what kind of syntactic construct follows. Note also that, while I updated all places calling those functions for standard C syntax to handle attributes if applicable, I did not do anything regarding calls to such functions for OpenMP or OpenACC constructs. Thus, if there are such constructs using such functions where "[[" *should* be accepted as a possible start to a declaration, the code for parsing those constructs should be updated accordingly. Although all cases of the syntax are handled, and attributes applied to the constructs the standard says they should be (with less laxity than there is for GNU attributes to allow an attribute applied to one construct to be moved automatically to another one), there is a major limitation in the existing language-independent code in attribs.c preventing most cases of type attributes from working. The following code has been present with minor changes since the first support for [[]] attributes for C++ was added: if (TYPE_P (*node) && cxx11_attr_p && !(flags & ATTR_FLAG_TYPE_IN_PLACE)) { /* This is a c++11 attribute that appertains to a type-specifier, outside of the definition of, a class type. Ignore it. */ auto_diagnostic_group d; if (warning (OPT_Wattributes, "attribute ignored")) inform (input_location, "an attribute that appertains to a type-specifier " "is ignored"); continue; } I see no justification for this in general for either C or C++ and so propose to remove or restrict it in a followup bug-fix patch. Both C and C++ are clear about attributes in certain places (at the end of declaration specifiers, or after function or array declarators) appertaining to a specific type (and explicitly say, in the case of attributes at the end of declaration specifiers, that they only apply for that particular use of that type, not for subsequent uses of the same type without the attributes). Thus it seems clear to me that, for example, int [[gnu::mode(DI)]] x; ought to be accepted as an analogue in [[]] syntax for int __attribute__((mode(DI))) x; (or strictly as an analogue for a version of that with extra parentheses to make the GNU attribute bind properly to the type rather than being automatically moved from the declaration to the type). There are certain cases where an attribute *does* only make sense for the definition of a type (e.g. "packed" on structure types), but those should already be handled in the individual attribute handlers (such as handle_packed_attribute, which already has code to deal with that issue). So my inclination is that the above-quoted check in attribs.c should simply be removed, but failing that it should be restricted to structure and union types (and such a change would be a bug-fix). That would then allow various cases of [[]] attributes on types to work properly. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-tree.h (enum c_typespec_kind): Add ctsk_tagref_attrs and ctsk_tagfirstref_attrs. (struct c_declspecs): Update description of attrs. Add postfix_attrs and non_std_attrs_seen_p. Increase size of typespec_kind bit-field. (c_warn_unused_attributes): New declaration. (parser_xref_tag): Update prototype. * c-decl.c (c_warn_unused_attributes): New function. (shadow_tag_warned): Handle ctsk_tagfirstref_attrs and ctsk_tagref_attrs. Handle attribute declarations. (check_compound_literal_type): Handle ctsk_tagfirstref_attrs. (grokdeclarator): Handle standard attributes. (parser_xref_tag): Add arguments have_std_attrs and attrs. Apply attributes to incomplete type reference. (xref_tag): Update call to parser_xref_tag. (declspecs_add_addrspace, declspecs_add_type) (declspecs_add_scspec, declspecs_add_attrs): Set non_std_attrs_seen_p. (finish_declspecs): Apply postfix standard attributes to type. * c-parser.c (c_token_starts_declspecs) (c_token_starts_declaration, c_parser_next_token_starts_declspecs) (c_parser_next_tokens_start_declaration): Update comments. (c_parser_consume_token, c_parser_consume_pragma): Handle moving parser->tokens[2] to parser->tokens[1]. (c_parser_nth_token_starts_std_attributes) (c_parser_std_attribute_specifier_sequence): New functions. (c_parser_declaration_or_fndef): Add arguments have_attrs and attrs. All callers changed. Handle standard attributes. (c_parser_parms_declarator, c_parser_parms_list_declarator) (c_parser_parameter_declaration): Add argument have_gnu_attrs. All callers changed. (c_parser_declspecs): Add arguments start_std_attr_ok and end_std_attr_ok. All callers changed. Handle standard attributes. (c_parser_enum_specifier, c_parser_struct_or_union_specifier) (c_parser_direct_declarator, c_parser_direct_declarator_inner) (c_parser_compound_statement_nostart, c_parser_all_labels) (c_parser_label, c_parser_statement, c_parser_for_statement): Handle standard attributes. * c-parser.h (c_parser_declspecs): Update prototype. * gimple-parser.c (c_parser_gimple_declaration): Update call to c_parser_declspecs. gcc/testsuite: * gcc.dg/c2x-attr-fallthrough-1.c, gcc.dg/c2x-attr-syntax-1.c, gcc.dg/c2x-attr-syntax-2.c, gcc.dg/c2x-attr-syntax-3.c, gcc.dg/gnu2x-attr-syntax-1.c, gcc.dg/gnu2x-attr-syntax-2.c, gcc.dg/gnu2x-attrs-1.c: New tests. From-SVN: r278194
2019-11-12Remove gcc/params.* files.Martin Liska2-1/+4
2019-11-12 Martin Liska <mliska@suse.cz> * Makefile.in: Remove PARAMS_H and params.list and params.options. * params-enum.h: Remove. * params-list.h: Remove. * params-options.h: Remove. * params.c: Remove. * params.def: Remove. * params.h: Remove. * asan.c: Do not include params.h. * auto-profile.c: Likewise. * bb-reorder.c: Likewise. * builtins.c: Likewise. * cfgcleanup.c: Likewise. * cfgexpand.c: Likewise. * cfgloopanal.c: Likewise. * cgraph.c: Likewise. * combine.c: Likewise. * common/config/aarch64/aarch64-common.c: Likewise. * common/config/gcn/gcn-common.c: Likewise. * common/config/ia64/ia64-common.c: Likewise. * common/config/powerpcspe/powerpcspe-common.c: Likewise. * common/config/rs6000/rs6000-common.c: Likewise. * common/config/sh/sh-common.c: Likewise. * config/aarch64/aarch64.c: Likewise. * config/alpha/alpha.c: Likewise. * config/arm/arm.c: Likewise. * config/avr/avr.c: Likewise. * config/csky/csky.c: Likewise. * config/i386/i386-builtins.c: Likewise. * config/i386/i386-expand.c: Likewise. * config/i386/i386-features.c: Likewise. * config/i386/i386-options.c: Likewise. * config/i386/i386.c: Likewise. * config/ia64/ia64.c: Likewise. * config/rs6000/rs6000-logue.c: Likewise. * config/rs6000/rs6000.c: Likewise. * config/s390/s390.c: Likewise. * config/sparc/sparc.c: Likewise. * config/visium/visium.c: Likewise. * coverage.c: Likewise. * cprop.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * dse.c: Likewise. * emit-rtl.c: Likewise. * explow.c: Likewise. * final.c: Likewise. * fold-const.c: Likewise. * gcc.c: Likewise. * gcse.c: Likewise. * ggc-common.c: Likewise. * ggc-page.c: Likewise. * gimple-loop-interchange.cc: Likewise. * gimple-loop-jam.c: Likewise. * gimple-loop-versioning.cc: Likewise. * gimple-ssa-split-paths.c: Likewise. * gimple-ssa-sprintf.c: Likewise. * gimple-ssa-store-merging.c: Likewise. * gimple-ssa-strength-reduction.c: Likewise. * gimple-ssa-warn-alloca.c: Likewise. * gimple-ssa-warn-restrict.c: Likewise. * graphite-isl-ast-to-gimple.c: Likewise. * graphite-optimize-isl.c: Likewise. * graphite-scop-detection.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * haifa-sched.c: Likewise. * hsa-gen.c: Likewise. * ifcvt.c: Likewise. * ipa-cp.c: Likewise. * ipa-fnsummary.c: Likewise. * ipa-inline-analysis.c: Likewise. * ipa-inline.c: Likewise. * ipa-polymorphic-call.c: Likewise. * ipa-profile.c: Likewise. * ipa-prop.c: Likewise. * ipa-split.c: Likewise. * ipa-sra.c: Likewise. * ira-build.c: Likewise. * ira-conflicts.c: Likewise. * loop-doloop.c: Likewise. * loop-invariant.c: Likewise. * loop-unroll.c: Likewise. * lra-assigns.c: Likewise. * lra-constraints.c: Likewise. * modulo-sched.c: Likewise. * opt-suggestions.c: Likewise. * opts.c: Likewise. * postreload-gcse.c: Likewise. * predict.c: Likewise. * reload.c: Likewise. * reorg.c: Likewise. * resource.c: Likewise. * sanopt.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-rgn.c: Likewise. * sel-sched-ir.c: Likewise. * sel-sched.c: Likewise. * shrink-wrap.c: Likewise. * stmt.c: Likewise. * targhooks.c: Likewise. * toplev.c: Likewise. * tracer.c: Likewise. * trans-mem.c: Likewise. * tree-chrec.c: Likewise. * tree-data-ref.c: Likewise. * tree-if-conv.c: Likewise. * tree-inline.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-parloops.c: Likewise. * tree-predcom.c: Likewise. * tree-profile.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-dse.c: Likewise. * tree-ssa-ifcombine.c: Likewise. * tree-ssa-loop-ch.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-loop-unswitch.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-scopedtables.c: Likewise. * tree-ssa-sink.c: Likewise. * tree-ssa-strlen.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-tail-merge.c: Likewise. * tree-ssa-threadbackward.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-uninit.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * value-prof.c: Likewise. * var-tracking.c: Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * gimple-parser.c: Do not include params.h. 2019-11-12 Martin Liska <mliska@suse.cz> * name-lookup.c: Do not include params.h. * typeck.c: Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * lto-common.c: Do not include params.h. * lto-partition.c: Likewise. * lto.c: Likewise. From-SVN: r278086
2019-11-12Apply mechanical replacement (generated patch).Martin Liska2-1/+7
2019-11-12 Martin Liska <mliska@suse.cz> * asan.c (asan_sanitize_stack_p): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. (asan_sanitize_allocas_p): Likewise. (asan_emit_stack_protection): Likewise. (asan_protect_global): Likewise. (instrument_derefs): Likewise. (instrument_builtin_call): Likewise. (asan_expand_mark_ifn): Likewise. * auto-profile.c (auto_profile): Likewise. * bb-reorder.c (copy_bb_p): Likewise. (duplicate_computed_gotos): Likewise. * builtins.c (inline_expand_builtin_string_cmp): Likewise. * cfgcleanup.c (try_crossjump_to_edge): Likewise. (try_crossjump_bb): Likewise. * cfgexpand.c (defer_stack_allocation): Likewise. (stack_protect_classify_type): Likewise. (pass_expand::execute): Likewise. * cfgloopanal.c (expected_loop_iterations_unbounded): Likewise. (estimate_reg_pressure_cost): Likewise. * cgraph.c (cgraph_edge::maybe_hot_p): Likewise. * combine.c (combine_instructions): Likewise. (record_value_for_reg): Likewise. * common/config/aarch64/aarch64-common.c (aarch64_option_validate_param): Likewise. (aarch64_option_default_params): Likewise. * common/config/ia64/ia64-common.c (ia64_option_default_params): Likewise. * common/config/powerpcspe/powerpcspe-common.c (rs6000_option_default_params): Likewise. * common/config/rs6000/rs6000-common.c (rs6000_option_default_params): Likewise. * common/config/sh/sh-common.c (sh_option_default_params): Likewise. * config/aarch64/aarch64.c (aarch64_output_probe_stack_range): Likewise. (aarch64_allocate_and_probe_stack_space): Likewise. (aarch64_expand_epilogue): Likewise. (aarch64_override_options_internal): Likewise. * config/alpha/alpha.c (alpha_option_override): Likewise. * config/arm/arm.c (arm_option_override): Likewise. (arm_valid_target_attribute_p): Likewise. * config/i386/i386-options.c (ix86_option_override_internal): Likewise. * config/i386/i386.c (get_probe_interval): Likewise. (ix86_adjust_stack_and_probe_stack_clash): Likewise. (ix86_max_noce_ifcvt_seq_cost): Likewise. * config/ia64/ia64.c (ia64_adjust_cost): Likewise. * config/rs6000/rs6000-logue.c (get_stack_clash_protection_probe_interval): Likewise. (get_stack_clash_protection_guard_size): Likewise. * config/rs6000/rs6000.c (rs6000_option_override_internal): Likewise. * config/s390/s390.c (allocate_stack_space): Likewise. (s390_emit_prologue): Likewise. (s390_option_override_internal): Likewise. * config/sparc/sparc.c (sparc_option_override): Likewise. * config/visium/visium.c (visium_option_override): Likewise. * coverage.c (get_coverage_counts): Likewise. (coverage_compute_profile_id): Likewise. (coverage_begin_function): Likewise. (coverage_end_function): Likewise. * cse.c (cse_find_path): Likewise. (cse_extended_basic_block): Likewise. (cse_main): Likewise. * cselib.c (cselib_invalidate_mem): Likewise. * dse.c (dse_step1): Likewise. * emit-rtl.c (set_new_first_and_last_insn): Likewise. (get_max_insn_count): Likewise. (make_debug_insn_raw): Likewise. (init_emit): Likewise. * explow.c (compute_stack_clash_protection_loop_data): Likewise. * final.c (compute_alignments): Likewise. * fold-const.c (fold_range_test): Likewise. (fold_truth_andor): Likewise. (tree_single_nonnegative_warnv_p): Likewise. (integer_valued_real_single_p): Likewise. * gcse.c (want_to_gcse_p): Likewise. (prune_insertions_deletions): Likewise. (hoist_code): Likewise. (gcse_or_cprop_is_too_expensive): Likewise. * ggc-common.c: Likewise. * ggc-page.c (ggc_collect): Likewise. * gimple-loop-interchange.cc (MAX_NUM_STMT): Likewise. (MAX_DATAREFS): Likewise. (OUTER_STRIDE_RATIO): Likewise. * gimple-loop-jam.c (tree_loop_unroll_and_jam): Likewise. * gimple-loop-versioning.cc (loop_versioning::max_insns_for_loop): Likewise. * gimple-ssa-split-paths.c (is_feasible_trace): Likewise. * gimple-ssa-store-merging.c (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (imm_store_chain_info::output_merged_store): Likewise. (pass_store_merging::process_store): Likewise. * gimple-ssa-strength-reduction.c (find_basis_for_base_expr): Likewise. * graphite-isl-ast-to-gimple.c (class translate_isl_ast_to_gimple): Likewise. (scop_to_isl_ast): Likewise. * graphite-optimize-isl.c (get_schedule_for_node_st): Likewise. (optimize_isl): Likewise. * graphite-scop-detection.c (build_scops): Likewise. * haifa-sched.c (set_modulo_params): Likewise. (rank_for_schedule): Likewise. (model_add_to_worklist): Likewise. (model_promote_insn): Likewise. (model_choose_insn): Likewise. (queue_to_ready): Likewise. (autopref_multipass_dfa_lookahead_guard): Likewise. (schedule_block): Likewise. (sched_init): Likewise. * hsa-gen.c (init_prologue): Likewise. * ifcvt.c (bb_ok_for_noce_convert_multiple_sets): Likewise. (cond_move_process_if_block): Likewise. * ipa-cp.c (ipcp_lattice::add_value): Likewise. (merge_agg_lats_step): Likewise. (devirtualization_time_bonus): Likewise. (hint_time_bonus): Likewise. (incorporate_penalties): Likewise. (good_cloning_opportunity_p): Likewise. (ipcp_propagate_stage): Likewise. * ipa-fnsummary.c (decompose_param_expr): Likewise. (set_switch_stmt_execution_predicate): Likewise. (analyze_function_body): Likewise. (compute_fn_summary): Likewise. * ipa-inline-analysis.c (estimate_growth): Likewise. * ipa-inline.c (caller_growth_limits): Likewise. (inline_insns_single): Likewise. (inline_insns_auto): Likewise. (can_inline_edge_by_limits_p): Likewise. (want_early_inline_function_p): Likewise. (big_speedup_p): Likewise. (want_inline_small_function_p): Likewise. (want_inline_self_recursive_call_p): Likewise. (edge_badness): Likewise. (recursive_inlining): Likewise. (compute_max_insns): Likewise. (early_inliner): Likewise. * ipa-polymorphic-call.c (csftc_abort_walking_p): Likewise. * ipa-profile.c (ipa_profile): Likewise. * ipa-prop.c (determine_known_aggregate_parts): Likewise. (ipa_analyze_node): Likewise. (ipcp_transform_function): Likewise. * ipa-split.c (consider_split): Likewise. * ipa-sra.c (allocate_access): Likewise. (process_scan_results): Likewise. (ipa_sra_summarize_function): Likewise. (pull_accesses_from_callee): Likewise. * ira-build.c (loop_compare_func): Likewise. (mark_loops_for_removal): Likewise. * ira-conflicts.c (build_conflict_bit_table): Likewise. * loop-doloop.c (doloop_optimize): Likewise. * loop-invariant.c (gain_for_invariant): Likewise. (move_loop_invariants): Likewise. * loop-unroll.c (decide_unroll_constant_iterations): Likewise. (decide_unroll_runtime_iterations): Likewise. (decide_unroll_stupid): Likewise. (expand_var_during_unrolling): Likewise. * lra-assigns.c (spill_for): Likewise. * lra-constraints.c (EBB_PROBABILITY_CUTOFF): Likewise. * modulo-sched.c (sms_schedule): Likewise. (DFA_HISTORY): Likewise. * opts.c (default_options_optimization): Likewise. (finish_options): Likewise. (common_handle_option): Likewise. * postreload-gcse.c (eliminate_partially_redundant_load): Likewise. (if): Likewise. * predict.c (get_hot_bb_threshold): Likewise. (maybe_hot_count_p): Likewise. (probably_never_executed): Likewise. (predictable_edge_p): Likewise. (predict_loops): Likewise. (expr_expected_value_1): Likewise. (tree_predict_by_opcode): Likewise. (handle_missing_profiles): Likewise. * reload.c (find_equiv_reg): Likewise. * reorg.c (redundant_insn): Likewise. * resource.c (mark_target_live_regs): Likewise. (incr_ticks_for_insn): Likewise. * sanopt.c (pass_sanopt::execute): Likewise. * sched-deps.c (sched_analyze_1): Likewise. (sched_analyze_2): Likewise. (sched_analyze_insn): Likewise. (deps_analyze_insn): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (find_single_block_region): Likewise. (too_large): Likewise. (haifa_find_rgns): Likewise. (extend_rgns): Likewise. (new_ready): Likewise. (schedule_region): Likewise. (sched_rgn_init): Likewise. * sel-sched-ir.c (make_region_from_loop): Likewise. * sel-sched-ir.h (MAX_WS): Likewise. * sel-sched.c (process_pipelined_exprs): Likewise. (sel_setup_region_sched_flags): Likewise. * shrink-wrap.c (try_shrink_wrapping): Likewise. * targhooks.c (default_max_noce_ifcvt_seq_cost): Likewise. * toplev.c (print_version): Likewise. (process_options): Likewise. * tracer.c (tail_duplicate): Likewise. * trans-mem.c (tm_log_add): Likewise. * tree-chrec.c (chrec_fold_plus_1): Likewise. * tree-data-ref.c (split_constant_offset): Likewise. (compute_all_dependences): Likewise. * tree-if-conv.c (MAX_PHI_ARG_NUM): Likewise. * tree-inline.c (remap_gimple_stmt): Likewise. * tree-loop-distribution.c (MAX_DATAREFS_NUM): Likewise. * tree-parloops.c (MIN_PER_THREAD): Likewise. (create_parallel_loop): Likewise. * tree-predcom.c (determine_unroll_factor): Likewise. * tree-scalar-evolution.c (instantiate_scev_r): Likewise. * tree-sra.c (analyze_all_variable_accesses): Likewise. * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Likewise. * tree-ssa-dse.c (setup_live_bytes_from_ref): Likewise. (dse_optimize_redundant_stores): Likewise. (dse_classify_store): Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * tree-ssa-loop-ch.c (ch_base::copy_headers): Likewise. * tree-ssa-loop-im.c (LIM_EXPENSIVE): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): Likewise. (try_peel_loop): Likewise. (tree_unroll_loops_completely): Likewise. * tree-ssa-loop-ivopts.c (avg_loop_niter): Likewise. (CONSIDER_ALL_CANDIDATES_BOUND): Likewise. (MAX_CONSIDERED_GROUPS): Likewise. (ALWAYS_PRUNE_CAND_SET_BOUND): Likewise. * tree-ssa-loop-manip.c (can_unroll_loop_p): Likewise. * tree-ssa-loop-niter.c (MAX_ITERATIONS_TO_TRACK): Likewise. * tree-ssa-loop-prefetch.c (PREFETCH_BLOCK): Likewise. (L1_CACHE_SIZE_BYTES): Likewise. (L2_CACHE_SIZE_BYTES): Likewise. (should_issue_prefetch_p): Likewise. (schedule_prefetches): Likewise. (determine_unroll_factor): Likewise. (volume_of_references): Likewise. (add_subscript_strides): Likewise. (self_reuse_distance): Likewise. (mem_ref_count_reasonable_p): Likewise. (insn_to_prefetch_ratio_too_small_p): Likewise. (loop_prefetch_arrays): Likewise. (tree_ssa_prefetch_arrays): Likewise. * tree-ssa-loop-unswitch.c (tree_unswitch_single_loop): Likewise. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise. (convert_mult_to_fma): Likewise. (math_opts_dom_walker::after_dom_children): Likewise. * tree-ssa-phiopt.c (cond_if_else_store_replacement): Likewise. (hoist_adjacent_loads): Likewise. (gate_hoist_loads): Likewise. * tree-ssa-pre.c (translate_vuse_through_block): Likewise. (compute_partial_antic_aux): Likewise. * tree-ssa-reassoc.c (get_reassociation_width): Likewise. * tree-ssa-sccvn.c (vn_reference_lookup_pieces): Likewise. (vn_reference_lookup): Likewise. (do_rpo_vn): Likewise. * tree-ssa-scopedtables.c (avail_exprs_stack::lookup_avail_expr): Likewise. * tree-ssa-sink.c (select_best_block): Likewise. * tree-ssa-strlen.c (new_stridx): Likewise. (new_addr_stridx): Likewise. (get_range_strlen_dynamic): Likewise. (class ssa_name_limit_t): Likewise. * tree-ssa-structalias.c (push_fields_onto_fieldstack): Likewise. (create_variable_info_for_1): Likewise. (init_alias_vars): Likewise. * tree-ssa-tail-merge.c (find_clusters_1): Likewise. (tail_merge_optimize): Likewise. * tree-ssa-threadbackward.c (thread_jumps::profitable_jump_thread_path): Likewise. (thread_jumps::fsm_find_control_statement_thread_paths): Likewise. (thread_jumps::find_jump_threads_backwards): Likewise. * tree-ssa-threadedge.c (record_temporary_equivalences_from_stmts_at_dest): Likewise. * tree-ssa-uninit.c (compute_control_dep_chain): Likewise. * tree-switch-conversion.c (switch_conversion::check_range): Likewise. (jump_table_cluster::can_be_handled): Likewise. * tree-switch-conversion.h (jump_table_cluster::case_values_threshold): Likewise. (SWITCH_CONVERSION_BRANCH_RATIO): Likewise. (param_switch_conversion_branch_ratio): Likewise. * tree-vect-data-refs.c (vect_mark_for_runtime_alias_test): Likewise. (vect_enhance_data_refs_alignment): Likewise. (vect_prune_runtime_alias_test_list): Likewise. * tree-vect-loop.c (vect_analyze_loop_costing): Likewise. (vect_get_datarefs_in_loop): Likewise. (vect_analyze_loop): Likewise. * tree-vect-slp.c (vect_slp_bb): Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c (find_switch_asserts): Likewise. (vrp_prop::check_mem_ref): Likewise. * tree.c (wide_int_to_tree_1): Likewise. (cache_integer_cst): Likewise. * var-tracking.c (EXPR_USE_DEPTH): Likewise. (reverse_op): Likewise. (vt_find_locations): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * gimple-parser.c (c_parser_parse_gimple_body): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. 2019-11-12 Martin Liska <mliska@suse.cz> * name-lookup.c (namespace_hints::namespace_hints): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * typeck.c (comptypes): Likewise. 2019-11-12 Martin Liska <mliska@suse.cz> * lto-partition.c (lto_balanced_map): Replace old parameter syntax with the new one, include opts.h if needed. Use SET_OPTION_IF_UNSET macro. * lto.c (do_whole_program_analysis): Likewise. From-SVN: r278085
2019-11-12Add OpenACC 2.6 `serial' construct supportMaciej W. Rozycki2-5/+39
The `serial' construct (cf. section 2.5.3 of the OpenACC 2.6 standard) is equivalent to a `parallel' construct with clauses `num_gangs(1) num_workers(1) vector_length(1)' implied. These clauses are therefore not supported with the `serial' construct. All the remaining clauses accepted with `parallel' are also accepted with `serial'. The `serial' construct is implemented like `parallel', except for hardcoding dimensions rather than taking them from the relevant clauses, in `expand_omp_target'. Separate codes are used to denote the `serial' construct throughout the middle end, even though the mapping of `serial' to an equivalent `parallel' construct could have been done in the individual language frontends. In particular, this allows to distinguish between compute constructs in warnings, error messages, dumps etc. 2019-11-12 Maciej W. Rozycki <macro@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> Frederik Harwath <frederik@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> gcc/ * gimple.h (gf_mask): Add GF_OMP_TARGET_KIND_OACC_SERIAL enumeration constant. (is_gimple_omp_oacc): Handle GF_OMP_TARGET_KIND_OACC_SERIAL. (is_gimple_omp_offloaded): Likewise. * gimplify.c (omp_region_type): Add ORT_ACC_SERIAL enumeration constant. Adjust the value of ORT_NONE accordingly. (is_gimple_stmt): Handle OACC_SERIAL. (oacc_default_clause): Handle ORT_ACC_SERIAL. (gomp_needs_data_present): Likewise. (gimplify_adjust_omp_clauses): Likewise. (gimplify_omp_workshare): Handle OACC_SERIAL. (gimplify_expr): Likewise. * omp-expand.c (expand_omp_target): Handle GF_OMP_TARGET_KIND_OACC_SERIAL. (build_omp_regions_1, omp_make_gimple_edges): Likewise. * omp-low.c (is_oacc_parallel): Rename function to... (is_oacc_parallel_or_serial): ... this. Handle GF_OMP_TARGET_KIND_OACC_SERIAL. (scan_sharing_clauses): Adjust accordingly. (scan_omp_for): Likewise. (lower_oacc_head_mark): Likewise. (convert_from_firstprivate_int): Likewise. (lower_omp_target): Likewise. (check_omp_nesting_restrictions): Handle GF_OMP_TARGET_KIND_OACC_SERIAL. (lower_oacc_reductions): Likewise. (lower_omp_target): Likewise. * tree.def (OACC_SERIAL): New tree code. * tree-pretty-print.c (dump_generic_node): Handle OACC_SERIAL. * doc/generic.texi (OpenACC): Document OACC_SERIAL. gcc/c-family/ * c-pragma.h (pragma_kind): Add PRAGMA_OACC_SERIAL enumeration constant. * c-pragma.c (oacc_pragmas): Add "serial" entry. gcc/c/ * c-parser.c (OACC_SERIAL_CLAUSE_MASK): New macro. (c_parser_oacc_kernels_parallel): Rename function to... (c_parser_oacc_compute): ... this. Handle PRAGMA_OACC_SERIAL. (c_parser_omp_construct): Update accordingly. gcc/cp/ * constexpr.c (potential_constant_expression_1): Handle OACC_SERIAL. * parser.c (OACC_SERIAL_CLAUSE_MASK): New macro. (cp_parser_oacc_kernels_parallel): Rename function to... (cp_parser_oacc_compute): ... this. Handle PRAGMA_OACC_SERIAL. (cp_parser_omp_construct): Update accordingly. (cp_parser_pragma): Handle PRAGMA_OACC_SERIAL. Fix alphabetic order. * pt.c (tsubst_expr): Handle OACC_SERIAL. gcc/fortran/ * gfortran.h (gfc_statement): Add ST_OACC_SERIAL_LOOP, ST_OACC_END_SERIAL_LOOP, ST_OACC_SERIAL and ST_OACC_END_SERIAL enumeration constants. (gfc_exec_op): Add EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL enumeration constants. * match.h (gfc_match_oacc_serial): New prototype. (gfc_match_oacc_serial_loop): Likewise. * dump-parse-tree.c (show_omp_node, show_code_node): Handle EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL. * match.c (match_exit_cycle): Handle EXEC_OACC_SERIAL_LOOP. * openmp.c (OACC_SERIAL_CLAUSES): New macro. (gfc_match_oacc_serial_loop): New function. (gfc_match_oacc_serial): Likewise. (oacc_is_loop): Handle EXEC_OACC_SERIAL_LOOP. (resolve_omp_clauses): Handle EXEC_OACC_SERIAL. (oacc_code_to_statement): Handle EXEC_OACC_SERIAL and EXEC_OACC_SERIAL_LOOP. (gfc_resolve_oacc_directive): Likewise. * parse.c (decode_oacc_directive) <'s'>: Add case for "serial" and "serial loop". (next_statement): Handle ST_OACC_SERIAL_LOOP and ST_OACC_SERIAL. (gfc_ascii_statement): Likewise. Handle ST_OACC_END_SERIAL_LOOP and ST_OACC_END_SERIAL. (parse_oacc_structured_block): Handle ST_OACC_SERIAL. (parse_oacc_loop): Handle ST_OACC_SERIAL_LOOP and ST_OACC_END_SERIAL_LOOP. (parse_executable): Handle ST_OACC_SERIAL_LOOP and ST_OACC_SERIAL. (is_oacc): Handle EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL. * resolve.c (gfc_resolve_blocks, gfc_resolve_code): Likewise. * st.c (gfc_free_statement): Likewise. * trans-openmp.c (gfc_trans_oacc_construct): Handle EXEC_OACC_SERIAL. (gfc_trans_oacc_combined_directive): Handle EXEC_OACC_SERIAL_LOOP. (gfc_trans_oacc_directive): Handle EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL. * trans.c (trans_code): Likewise. gcc/testsuite/ * c-c++-common/goacc/parallel-dims.c: New test. * gfortran.dg/goacc/parallel-dims.f90: New test. libgomp/ * testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: New test. * testsuite/libgomp.oacc-fortran/parallel-dims-aux.c: New test. * testsuite/libgomp.oacc-fortran/parallel-dims.f89: New test. * testsuite/libgomp.oacc-fortran/parallel-dims-2.f90: New test. Reviewed-by: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Frederik Harwath <frederik@codesourcery.com> Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com> Co-Authored-By: Tobias Burnus <tobias@codesourcery.com> From-SVN: r278082
2019-11-11c-parser.c (c_parser_translation_unit): Diagnose declare target without ↵Jakub Jelinek2-0/+13
corresponding end declare target. * c-parser.c (c_parser_translation_unit): Diagnose declare target without corresponding end declare target. * semantics.c (finish_translation_unit): Diagnose declare target without corresponding end declare target. * c-c++-common/gomp/declare-target-5.c: New test. From-SVN: r278065
2019-11-08[C] Opt out of GNU vector extensions for built-in SVE typesRichard Sandiford3-31/+74
The AArch64 port defines built-in SVE types at start-up under names like __SVInt8_t. These types are represented in the front end and gimple as normal VECTOR_TYPEs and are code-generated as normal vectors. However, we'd like to stop the frontends from treating them in the same way as GNU-style ("vector_size") vectors, for several reasons: (1) We allowed the GNU vector extensions to be mixed with Advanced SIMD vector types and it ended up causing a lot of confusion on big-endian targets. Although SVE handles big-endian vectors differently from Advanced SIMD, there are still potential surprises; see the block comment near the head of aarch64-sve.md for details. (2) One of the SVE vectors is a packed one-bit-per-element boolean vector. That isn't a combination the GNU vector extensions have supported before. E.g. it means that vectors can no longer decompose to arrays for indexing, and that not all elements are individually addressable. It also makes it less clear which order the initialiser should be in (lsb first, or bitfield ordering?). We could define all that of course, but it seems a bit weird to go to the effort for this case when, given all the other reasons, we don't want the extensions anyway. (3) The GNU vector extensions only provide full-vector operations, which is a very artifical limitation on a predicated architecture like SVE. (4) The set of operations provided by the GNU vector extensions is relatively small, whereas the SVE intrinsics provide many more. (5) It makes it easier to ensure that (with default options) code is portable between compilers without the GNU vector extensions having to become an official part of the SVE intrinsics spec. (6) The length of the SVE types is usually not fixed at compile time, whereas the GNU vector extension is geared around fixed-length vectors. It's possible to specify the length of an SVE vector using the command-line option -msve-vector-bits=N, but in principle it should be possible to have functions compiled for different N in the same translation unit. This isn't supported yet but would be very useful for implementing ifuncs. Once mixing lengths in a translation unit is supported, the SVE types should represent the same type throughout the translation unit, just as GNU vector types do. However, when -msve-vector-bits=N is in effect, we do allow conversions between explicit GNU vector types of N bits and the corresponding SVE types. This doesn't undermine the intent of (5) because in this case the use of GNU vector types is explicit and intentional. It also doesn't undermine the intent of (6) because converting between the types is just a conditionally-supported operation. In other words, the types still represent the same types throughout the translation unit, it's just that conversions between them are valid in cases where a certain precondition is known to hold. It's similar to the way that the SVE vector types are defined throughout the translation unit but can only be used in functions for which SVE is enabled. The patch adds a new flag to tree_type_common to select this behaviour. (We currently have 17 bits free.) To avoid making the flag too specific to vectors, I called it TYPE_INDIVISIBLE_P, to mean that the frontend should not allow the components of the type to be accessed directly. This could perhaps be useful in future for hiding the fact that a type is an array, or for hiding the fields of a record or union. The actual frontend changes are very simple, mostly just replacing VECTOR_TYPE_P with gnu_vector_type_p in selected places. One interesting case is: /* Need to convert condition operand into a vector mask. */ if (VECTOR_TYPE_P (TREE_TYPE (ifexp))) { tree vectype = TREE_TYPE (ifexp); tree elem_type = TREE_TYPE (vectype); tree zero = build_int_cst (elem_type, 0); tree zero_vec = build_vector_from_val (vectype, zero); tree cmp_type = build_same_sized_truth_vector_type (vectype); ifexp = build2 (NE_EXPR, cmp_type, ifexp, zero_vec); } in build_conditional_expr. This appears to be trying to support elementwise conditions like "vec1 ? vec2 : vec3", which is something the C++ frontend supports. However, this code can never trigger AFAICT, because "vec1" does not survive c_objc_common_truthvalue_conversion: case VECTOR_TYPE: error_at (location, "used vector type where scalar is required"); return error_mark_node; Even if it did, the operation should be a VEC_COND_EXPR rather than a COND_EXPR. I've therefore left that condition as-is, but added tests for the "vec1 ? vec2 : vec3" case to make sure that we don't accidentally allow it for SVE vectors in future. 2019-11-08 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-core.h (tree_type_common::indivisible_p): New member variable. * tree.h (TYPE_INDIVISIBLE_P): New macro. * config/aarch64/aarch64-sve-builtins.cc (register_builtin_types): Treat the vector types as indivisible. gcc/c-family/ * c-common.h (gnu_vector_type_p): New function. * c-common.c (c_build_vec_perm_expr): Require __builtin_shuffle vectors to satisfy gnu_vector_type_p. (c_build_vec_convert): Likewise __builtin_convertvector. (convert_vector_to_array_for_subscript): Likewise when applying implicit vector to array conversion. (scalar_to_vector): Likewise when converting vector-scalar operations to vector-vector operations. gcc/c/ * c-convert.c (convert): Only handle vector conversions if one of the types satisfies gnu_vector_type_p or if -flax-vector-conversions allows it. * c-typeck.c (build_array_ref): Only allow vector indexing if the vectors satisfy gnu_vector_type_p. (build_unary_op): Only allow unary operators to be applied to vectors if they satisfy gnu_vector_type_p. (digest_init): Only allow by-element initialization of vectors if they satisfy gnu_vector_type_p. (really_start_incremental_init): Likewise. (push_init_level): Likewise. (pop_init_level): Likewise. (process_init_element): Likewise. (build_binary_op): Only allow binary operators to be applied to vectors if they satisfy gnu_vector_type_p. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general-c/gnu_vectors_1.c: New test. * gcc.target/aarch64/sve/acle/general-c/gnu_vectors_2.c: Likewise. From-SVN: r277950
2019-11-08Handle removal of old-style function definitions in C2x.Joseph Myers2-7/+28
C2x removes support for old-style function definitions with identifier lists, changing () in function definitions to be equivalent to (void) (while () in declarations that are not definitions still gives an unprototyped type). This patch updates GCC accordingly. The new semantics for () are implemented for C2x mode (meaning () in function definitions isn't diagnosed by -Wold-style-definition in that mode). -Wold-style-definition is enabled by default, and turned into a pedwarn, for C2x. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc: * doc/invoke.texi (-Wold-style-definition): Document () not being considered an old-style definition for C2x. gcc/c: * c-decl.c (grokparms): Convert () in a function definition to (void) for C2x. (store_parm_decls_oldstyle): Pedwarn for C2x. (store_parm_decls): Update comment about () not generating a prototype. gcc/c-family: * c.opt (Wold-style-definition): Initialize to -1. * c-opts.c (c_common_post_options): Set warn_old_style_definition to flag_isoc2x if not set explicitly. gcc/testsuite: * gcc.dg/c11-old-style-definition-1.c, gcc.dg/c11-old-style-definition-2.c, gcc.dg/c2x-old-style-definition-1.c, gcc.dg/c2x-old-style-definition-2.c, gcc.dg/c2x-old-style-definition-3.c, gcc.dg/c2x-old-style-definition-4.c, gcc.dg/c2x-old-style-definition-5.c, gcc.dg/c2x-old-style-definition-6.c: New tests. From-SVN: r277945
2019-11-07Expand C2x attribute parsing support and factor out from TM attributes.Joseph Myers2-78/+279
There is one place in the C parser that already handles a subset of the C2x [[]] attribute syntax: c_parser_transaction_attributes. This patch factors C2x attribute parsing out of there, extending it to cover the full C2x attribute syntax (although currently only called from that one place in the parser - so this is another piece of preparation for supporting C2x attributes in the places where C2x says they are valid, not the patch that actually enables such support). The new C2X attribute parsing code uses the same representation for scoped attributes as C++ does, so requiring parse_tm_stmt_attr to handle the scoped attributes representation (C++ currently special-cases TM attributes "to avoid the pedwarn in C++98 mode"; in C I'm using an argument to c_parser_std_attribute_specifier to disable the pedwarn_c11 call in the TM case). Parsing of arguments to known attributes is shared by GNU and C2x attributes. C2x specifies that unknown attributes are ignored (GCC practice in such a case is to warn along with ignoring the attribute) and gives a very general balanced-token-sequence syntax for arguments to unknown attributes (known ones each have their own syntax which is a subset of balanced-token-sequence), so support is added for parsing and ignoring such balanced-token-sequences as arguments of unknown attributes. Some limited tests are added of different attribute usages in the TM attribute case. The cases that become valid in the TM case include extra commas inside [[]], and an explicit "gnu" namespace, as the extra commas have no semantic effect for C2x attributes, while accepting the "gnu" namespace seems appropriate because the attribute in question is accepted inside __attribute__ (()), which is considered equivalent to the "gnu" namespace inside [[]]. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-parser.c (c_parser_attribute_arguments): New function. Factored out of c_parser_gnu_attribute. (c_parser_gnu_attribute): Use c_parser_attribute_arguments. (c_parser_balanced_token_sequence, c_parser_std_attribute) (c_parser_std_attribute_specifier): New functions. (c_parser_transaction_attributes): Use c_parser_std_attribute_specifier. gcc/c-family: * c-attribs.c (parse_tm_stmt_attr): Handle scoped attributes. gcc/testsuite: * gcc.dg/tm/attrs-1.c: New test. * gcc.dg/tm/props-5.c: New test. Based on props-4.c. From-SVN: r277935
2019-11-07Move string concatenation for C into the parser.Joseph Myers4-69/+240
This patch is another piece of preparation for C2x attributes support. C2x attributes require unbounded lookahead in the parser, because the token sequence '[[' that starts a C2x attribute is also valid in Objective-C in some of the same contexts, so it is necessary to see whether the matching ']]' are consecutive tokens or not to determine whether those tokens start an attribute. Unbounded lookahead means lexing an unbounded number of tokens before they are parsed. c_lex_one_token does various context-sensitive processing of tokens that cannot be done at that lookahead time, because it depends on information (such as whether particular identifiers are typedefs) that may be different at the time it is relevant than at the time the lookahead is needed (recall that more or less arbitrary C code, including declarations and statements, can appear inside expressions in GNU C). Most of that context-sensitive processing is not a problem, simply because it is not needed for lookahead purposes so can be deferred until the tokens lexed during lookahead are parsed. However, the earliest piece of context-sensitive processing is the handling of string literals based on flags passed to c_lex_with_flags, which determine whether adjacent literals are concatenated and whether translation to the execution character set occurs. Because the choice of whether to translate to the execution character set is context-sensitive, this means that unbounded lookahead requires the C parser to move to the approach used by the C++ parser, where string literals are generally not translated or concatenated from within c_lex_with_flags, but only later in the parser once it knows whether translation is needed. (Translation requires the tokens in their form before concatenation.) Thus, this patch makes that change to the C parser. Flags in the parser are still used for two special cases similar to C++: the handling of an initial #pragma pch_preprocess, and arranging for strings inside attributes not to be translated (the latter is made more logically correct by saving and restoring the flags, as in the C++ parser, rather than assuming that the state outside the attribute was always to translate string literals, which might not be the case in corner cases involving declarations and attributes inside attributes). The consequent change to pragma_lex to use c_parser_string_literal makes it disallow wide strings and disable translation in that context, which also follows C++ and is more logically correct than the previous state without special handling in that regard. Translation to the execution character set is always disabled when string constants are handled in the GIMPLE parser. Although the handling of strings is now a lot closer to that in C++, there are still some differences, in particular regarding the handling of locations. See c-c++-common/Wformat-pr88257.c, which has different expected multiline diagnostic output for C and C++, for example; I'm not sure whether the C or C++ output is better there (C++ has a more complete range than C, C mentions a macro definition location that C++ doesn't), but I tried to keep the locations the same as those previously used by the C front end, as far as possible, to minimize the testsuite changes needed, rather than possibly making them closer to those used with C++. The only changes needed for tests of user-visible diagnostics were for the wording of one diagnostic changing to match C++ (as a consequence of having a check for wide strings based on a flag in a general string-handling function rather than in a function specific to asm). However, although locations are extremely similar to what they were before, I couldn't make them completely identical in all cases. (My understanding of the implementation reason for the differences is as follows: lex_string uses src_loc from each cpp_token; the C parser is using the virtual location from cpp_get_token_with_location as called by c_lex_with_flags, and while passing that through linemap_resolve_location with LRK_MACRO_DEFINITION_LOCATION, as this patch does, produces something very close to what lex_string uses, it's not completely identical in some cases.) This results in changes being needed to two of the gcc.dg/plugin tests that use a plugin to test details of how string locations are handled. Because the tests being changed are for ICEs and the only change is to the details of the particular non-user-visible error that code gives in cases it can't handle (one involving __FILE__, one involving a string literal from stringizing), I think it's OK to change that non-user-visible error and that the new errors are no worse than the old ones. So these particular errors are now different for C and C++ (some other messages in those tests already had differences between C and C++). Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-parser.c (c_parser): Remove lex_untranslated_string. Add lex_joined_string and translate_strings_p. (c_lex_one_token): Pass 0 or C_LEX_STRING_NO_JOIN to c_lex_with_flags. (c_parser_string_literal): New function. (c_parser_static_assert_declaration_no_semi): Use c_parser_string_literal. Do not set lex_untranslated_string. (c_parser_asm_string_literal): Use c_parser_string_literal. (c_parser_simple_asm_expr): Do not set lex_untranslated_string. (c_parser_gnu_attributes): Set and restore translate_strings_p instead of lex_untranslated_string. (c_parser_asm_statement): Do not set lex_untranslated_string. (c_parser_asm_operands): Likewise. (c_parser_has_attribute_expression): Set and restore translate_strings_p instead of lex_untranslated_string. (c_parser_postfix_expression): Use c_parser_string_literal. (pragma_lex): Likewise. (c_parser_pragma_pch_preprocess): Set lex_joined_string. (c_parse_file): Set translate_strings_p. * gimple-parser.c (c_parser_gimple_postfix_expression) (c_parser_gimple_or_rtl_pass_list): Use c_parser_string_literal. * c-parser.c (c_parser_string_literal): Declare function. gcc/testsuite: * gcc.dg/asm-wide-1.c, gcc.dg/diagnostic-token-ranges.c, gcc.dg/plugin/diagnostic-test-string-literals-1.c, gcc.dg/plugin/diagnostic-test-string-literals-2.c: Update expected diagnostics. From-SVN: r277903
2019-11-02gimplify.h (omp_construct_selector_matches): Change return type to int, add ↵Jakub Jelinek2-3/+7
a new SCORES argument. * gimplify.h (omp_construct_selector_matches): Change return type to int, add a new SCORES argument. * gimplify.c (omp_construct_selector_matches): Likewise. If SCORES is non-NULL, compute scores of each construct. * omp-general.h (omp_get_context_selector): Declare. * omp-general.c (omp_maybe_offloaded, omp_context_selector_matches): Adjust omp_construct_selector_matches callers. (omp_get_context_selector): New function, moved from c-family/c-omp.c. (omp_context_compute_score): New function. (omp_resolve_declare_variant): Compute scores and decide based on that. c-family/ * c-common.h (c_omp_get_context_selector): Remove. * c-omp.c (c_omp_get_context_selector): Moved to omp-general.c and renamed to omp_get_context_selector. c/ * c-parser.c (c_finish_omp_declare_variant): Use omp_get_context_selector instead of c_omp_get_context_selector. cp/ * decl.c (omp_declare_variant_finalize_one): Use omp_get_context_selector instead of c_omp_get_context_selector. testsuite/ * c-c++-common/gomp/declare-variant-12.c: New test. From-SVN: r277742
2019-10-29Add a simulate_enum_decl langhookRichard Sandiford4-0/+40
Similarly to the simulate_builtin_function_decl patch, this one adds a hook for simulating an enum declaration in the source language. Again, the main SVE ACLE patch has tests for various error conditions. 2019-10-29 Richard Sandiford <richard.sandiford@arm.com> gcc/ * coretypes.h (string_int_pair): New typedef. * langhooks-def.h (LANG_HOOKS_SIMULATE_ENUM_DECL): Define. (LANG_HOOKS_FOR_TYPES_INITIALIZER): Include it. * langhooks.h (lang_hooks_for_types::simulate_enum_decl): New hook. gcc/c/ * c-tree.h (c_simulate_enum_decl): Declare. * c-decl.c (c_simulate_enum_decl): New function. * c-objc-common.h (LANG_HOOKS_SIMULATE_ENUM_DECL): Define to the above. gcc/cp/ * cp-objcp-common.h (cxx_simulate_enum_decl): Declare. (LANG_HOOKS_SIMULATE_ENUM_DECL): Define to the above. * decl.c (cxx_simulate_enum_decl): New function. From-SVN: r277555
2019-10-29Add a simulate_builin_function_decl langhookRichard Sandiford4-0/+21
Although it's possible to define the SVE intrinsics in a normal header file, it's much more convenient to define them directly in the compiler. This also speeds up compilation and gives better error messages. The idea is therefore for arm_sve.h (the main intrinsics header file) to have the pragma: #pragma GCC aarch64 "arm_sve.h" telling GCC to define (almost) everything arm_sve.h needs to define. The target then needs a way of injecting new built-in function declarations during compilation. The main hook for defining built-in functions is add_builtin_function. This is designed for use at start-up, and so has various features that are correct in that context but not for the pragma above: (1) the location is always BUILTINS_LOCATION, whereas for arm_sve.h it ought to be the location of the pragma. (2) the function is only immediately visible if it's in the implementation namespace, whereas the pragma is deliberately injecting functions into the general namespace. (3) there's no attempt to emulate a normal function declaration in C or C++, whereas functions declared by the pragma should be checked in the same way as an open-coded declaration would be. E.g. we should get an error if there was a previous incompatible declaration. (4) in C++, the function is treated as extern "C" and so can't be overloaded, whereas SVE intrinsics do use function overloading. This patch therefore adds a hook that targets can use to inject the equivalent of a source-level function declaration, but bound to a BUILT_IN_MD function. The main SVE intrinsic patch has tests to make sure that we report an error for conflicting definitions that appear either before or after including arm_sve.h. 2019-10-29 Richard Sandiford <richard.sandiford@arm.com> gcc/ * langhooks.h (lang_hooks::simulate_builtin_function_decl): New hook. (simulate_builtin_function_decl): Declare. * langhooks-def.h (LANG_HOOKS_SIMULATE_BUILTIN_FUNCTION_DECL): Define. (LANG_HOOKS_INITIALIZER): Include it. * langhooks.c (add_builtin_function_common): Rename to... (build_builtin_function): ...this. Add a location parameter and use it instead of BUILTINS_LOCATION. Remove the hook parameter and return the decl instead. (add_builtin_function): Update accordingly, passing the returned decl to the lang hook. (add_builtin_function_ext_scope): Likewise (simulate_builtin_function_decl): New function. gcc/c/ * c-tree.h (c_simulate_builtin_function_decl): Declare. * c-decl.c (c_simulate_builtin_function_decl): New function. * c-objc-common.h (LANG_HOOKS_SIMULATE_BUILTIN_FUNCTION_DECL): Define to the above. gcc/cp/ * cp-tree.h (cxx_simulate_builtin_function_decl): Declare. * decl.c (cxx_simulate_builtin_function_decl): New function. * cp-objcp-common.h (LANG_HOOKS_SIMULATE_BUILTIN_FUNCTION_DECL): Define to the above. From-SVN: r277554
2019-10-28PR c/66970 - Add __has_builtin() macroMartin Sebor2-0/+33
gcc/ChangeLog: PR c/66970 * doc/cpp.texi (__has_builtin): Document. * doc/extend.texi (__builtin_frob_return_addr): Correct spelling. gcc/c/ChangeLog: PR c/66970 * c-decl.c (names_builtin_p): Define a new function. gcc/c-family/ChangeLog: PR c/66970 * c-common.c (c_common_nodes_and_builtins): Call c_define_builtins even when only preprocessing. * c-common.h (names_builtin_p): Declare new function. * c-lex.c (init_c_lex): Set has_builtin. (c_common_has_builtin): Define a new function. * c-ppoutput.c (init_pp_output): Set has_builtin. gcc/cp/ChangeLog: PR c/66970 * cp-objcp-common.c (names_builtin_p): Define new function. gcc/testsuite/ChangeLog: PR c/66970 * c-c++-common/cpp/has-builtin-2.c: New test. * c-c++-common/cpp/has-builtin-3.c: New test. * c-c++-common/cpp/has-builtin.c: New test. From-SVN: r277544
2019-10-28re PR c/92249 (ICE in c_parser_gimple_compound_statement w/ GIMPLE testcases)Richard Biener2-1/+10
2019-10-28 Richard Biener <rguenther@suse.de> PR c/92249 * gimple-parser.c (c_parser_parse_gimple_body): Make current_bb the entry block initially to easier recover from errors. (c_parser_gimple_compound_statement): Adjust. From-SVN: r277512
2019-10-25gimplify.h (omp_construct_selector_matches): Declare.Jakub Jelinek3-3/+16
* gimplify.h (omp_construct_selector_matches): Declare. * gimplify.c (struct gimplify_omp_ctx): Add code member. (gimplify_call_expr): Call omp_resolve_declare_variant and remap called function if needed for flag_openmp. (gimplify_scan_omp_clauses): Set ctx->code. (omp_construct_selector_matches): New function. * omp-general.h (omp_constructor_traits_to_codes, omp_context_selector_matches, omp_resolve_declare_variant): Declare. * omp-general.c (omp_constructor_traits_to_codes, omp_context_selector_matches, omp_resolve_declare_variant): New functions. c-family/ * c-common.h (c_omp_context_selector_matches): Remove. * c-omp.c (c_omp_context_selector_matches): Remove. * c-attribs.c (c_common_attribute_table): Add "omp declare target {host,nohost,block}" attributes. c/ * c-parser.c (c_finish_omp_declare_variant): Use omp_context_selector_matches instead of c_omp_context_selector_matches. * c-decl.c (c_decl_attributes): Add "omp declare target block" attribute in between declare target and end declare target pragmas. cp/ * decl2.c (cplus_decl_attributes): Add "omp declare target block" attribute in between declare target and end declare target pragmas. testsuite/ * c-c++-common/gomp/declare-variant-8.c: New test. From-SVN: r277427
2019-10-15Rename attribute-related functions and productions in C parser.Joseph Myers2-77/+95
The C2x attribute syntax, [[ ]], appears in different places in the syntax from GNU __attribute__, and, where they can appear in the same place in the syntax, they do not always appertain to the same entity. (For example, in "int func(void) ATTRS;", GNU attributes appertain to the declaration but C2x attributes appertain to the function type.) Thus, the C parser needs to handle the two kinds of attributes separately, with each place in the syntax accepting whatever kinds of attributes are appropriate there and applying them to the relevant entities. This patch prepares for this by renaming parser functions relating to attributes to make clear they are specifically about GNU attributes and renaming syntax productions likewise to avoid confusing with the C2x attributes syntax productions. Where comments refer to attributes, this has only be changed where it is clear that in the context they are referring specifically to the gnu-attributes syntax. There may be other places that also end up changing to refer to gnu-attributes as part of the C2x attributes implementation, if more detailed examination of those places shows they are also specific to gnu-attributes. (I do not expect code dealing with semantics of attributes outside of the parser to need to change; as for C++, it will be possible to use existing attributes inside [[]] with the gnu:: form of the attribute name.) Bootstrapped with no regressions on x86_64-pc-linux-gnu. * c-parser.c (c_parser_attribute_any_word): Rename to c_parser_gnu_attribute_any_word. All callers changed. (c_parser_attribute): Rename to c_parser_gnu_attribute. All callers changed. (c_parser_attributes): Rename to c_parser_gnu_attributes. All callers changed. (c_parser_declaration_or_fndef, c_parser_declspecs) (c_parser_enum_specifier, c_parser_struct_or_union_specifier) (c_parser_struct_declaration, c_parser_declarator) (c_parser_gnu_attribute, c_parser_compound_statement) (c_parser_label, c_parser_statement, c_parser_objc_method_decl) (c_parser_transaction_attributes): Add "gnu-" prefix to names of attribute-related syntax productions. From-SVN: r276978
2019-10-14[C] Avoid exposing internal details in aka typesRichard Sandiford2-39/+99
The current aka diagnostics can sometimes leak internal details that seem more likely to be distracting than useful. E.g. on aarch64: void f (va_list *va) { *va = 1; } gives: incompatible types when assigning to type ‘va_list’ {aka ‘__va_list’} from type ‘int’ where __va_list isn't something the user is expected to know about. A similar thing happens for C++ on the arm_neon.h-based: float x; int8x8_t y = x; which gives: cannot convert ‘float’ to ‘int8x8_t’ {aka ‘__Int8x8_t’} in initialization This is accurate -- and __Int8x8_t is defined by the AArch64 PCS -- but it's not going to be meaningful to most users. This patch stops the aka code looking through typedefs if all of the following are true: (1) the typedef is built into the compiler or comes from a system header (2) the target of the typedef is anonymous or has a name in the implementation namespace (3) the target type is a tag type or vector type, which have in common that: (a) we print their type names if they have one (b) what we print for anonymous types isn't all that useful ("struct <anonymous>" etc. for tag types, pseudo-C "__vector(N) T" for vector types) The patch does this by recursively looking for the aka type, like the C++ frontend already does. This in turn makes "aka" work for distinct type copies like __Int8x8_t on aarch64, fixing the ??? in aarch64/diag_aka_1.c. 2019-10-14 Richard Sandiford <richard.sandiford@arm.com> gcc/c-family/ * c-common.h (user_facing_original_type_p): Declare. * c-common.c: Include c-spellcheck.h. (user_facing_original_type_p): New function. gcc/c/ * c-objc-common.c (useful_aka_type_p): Replace with... (get_aka_type): ...this new function. Given the original type, decide which aka type to print (if any). Only look through typedefs if user_facing_original_type_p. (print_type): Update accordingly. gcc/testsuite/ * gcc.dg/diag-aka-5.h: New test. * gcc.dg/diag-aka-5a.c: Likewise. * gcc.dg/diag-aka-5b.c: Likewise. * gcc.target/aarch64/diag_aka_1.c (f): Expect an aka to be printed for myvec. From-SVN: r276951
2019-10-14c-parser.c (c_parser_omp_all_clauses): Change bool NESTED_P argument into ↵Jakub Jelinek2-8/+24
int NESTED... c/ * c-parser.c (c_parser_omp_all_clauses): Change bool NESTED_P argument into int NESTED, if it is 2, diagnose missing commas in between clauses. (c_parser_omp_context_selector): Pass 2 as last argument to c_parser_omp_all_clauses. cp/ * parser.c (cp_parser_omp_all_clauses): Change bool NESTED_P argument into int NESTED, if it is 2, diagnose missing commas in between clauses. (cp_parser_omp_context_selector): Pass 2 as last argument to cp_parser_omp_all_clauses. testsuite/ * c-c++-common/gomp/declare-variant-7.c: Add tests for clauses not separated by commas in simd selector trait properties. From-SVN: r276950
2019-10-12c-common.h (c_omp_mark_declare_variant, [...]): Declare.Jakub Jelinek2-7/+26
c-family/ * c-common.h (c_omp_mark_declare_variant, c_omp_context_selector_matches): Declare. * c-omp.c: Include attribs.h, gimplify.h, cgraph.h, symbol-summary.h and hsa-common.h. (c_omp_get_context_selector): Support second argument NULL. (c_omp_mark_declare_variant, c_omp_context_selector_matches): New functions. * c-attribs.c (c_common_attribute_table): Remove "omp declare variant" attribute, add "omp declare variant base" and "omp declare variant variant" attributes. c/ * c-parser.c (c_parser_omp_context_selector): Improve error recovery. For simd properties, put them directly into TREE_VALUE. (c_finish_omp_declare_variant): Call c_omp_mark_declare_variant. If c_omp_context_selector_matches is 0, don't add attribute, otherwise add "omp declare variant base" attribute rather than "omp declare variant". cp/ * parser.c (cp_parser_omp_context_selector): Improve error recovery. For simd properties, put them directly into TREE_VALUE. (cp_finish_omp_declare_variant): Add "omp declare variant base" attribute rather than "omp declare variant". testsuite/ * c-c++-common/gomp/declare-variant-2.c: Adjust for error recovery improvements. Add new tests. * c-c++-common/gomp/declare-variant-4.c: New test. * c-c++-common/gomp/declare-variant-5.c: New test. * c-c++-common/gomp/declare-variant-6.c: New test. * c-c++-common/gomp/declare-variant-7.c: New test. From-SVN: r276914
2019-10-11Support _Decimal* keywords for C2x.Joseph Myers2-2/+7
ISO C2x adds decimal floating point as an optional standard feature. This patch accordingly makes GCC accept the _Decimal* keywords in strict C2x mode, using pedwarn_c11 to get a warning for -Wc11-c2x-compat. (Constants, where the pedwarn is in libcpp, will be dealt with separately.) The _Decimal* keywords are marked with D_EXT, meaning they are not considered keywords at all in strict conformance modes. This is contrary to the normal practice for most implementation-namespace keywords, which are accepted in all standards modes but with appropriate pedwarns for older standards. This patch removes D_EXT from those keywords so they are accepted as keywords for all standards, consequently removing the gcc.dg/dfp/keywords-ignored-c99.c test that is no longer valid. (A new D_C2X for keywords will still be needed if any new keywords get added that aren't in the implementation namespace for older standards; there are proposals for such keywords, albeit as predefined macros that might not actually need new keywords in the compiler in all cases. If the DFP keywords end up as decimal32 etc., of course appropriate compiler and testcase changes will be needed, and a version of keywords-ignored-c99.c would make sense again with such spellings.) Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-decl.c (declspecs_add_type): Use pedwarn_c11 for DFP types. gcc/c-family: * c-common.c (c_common_reswords): Do not use D_EXT for _Decimal32, _Decimal64 and _Decimal128. gcc/testsuite: * gcc.dg/dfp/c11-keywords-1.c, gcc.dg/dfp/c11-keywords-2.c, gcc.dg/dfp/c2x-keywords-1.c, gcc.dg/dfp/c2x-keywords-2.c: New tests. * gcc.dg/dfp/keywords-ignored-c99.c: Remove test. * gcc.dg/dfp/constants-c99.c, gcc.dg/dfp/keywords-c89.c, gcc.dg/dfp/keywords-c99.c: Use -pedantic-errors. From-SVN: r276896
2019-10-10c-common.h (c_omp_check_context_selector, [...]): Declare.Jakub Jelinek2-40/+520
c-family/ * c-common.h (c_omp_check_context_selector, c_omp_get_context_selector): Declare. * c-omp.c (c_omp_declare_simd_clauses_to_numbers): Fix spelling in diagnostic message. (c_omp_check_context_selector, c_omp_get_context_selector): New functions. * c-attribs.c (c_common_attribute_table): Add "omp declare variant" attribute. (handle_omp_declare_variant_attribute): New function. c/ * c-parser.c (c_parser_omp_all_clauses): Add NESTED_P argument, if true, terminate processing on closing paren and don't skip to end of pragma line. (c_parser_omp_declare_simd): Handle also declare variant. (omp_construct_selectors, omp_device_selectors, omp_implementation_selectors, omp_user_selectors): New variables. (c_parser_omp_context_selector, c_parser_omp_context_selector_specification, c_finish_omp_declare_variant): New functions. (c_finish_omp_declare_simd): Handle both declare simd and declare variant. (c_parser_omp_declare): Handle declare variant. cp/ * parser.h (struct cp_omp_declare_simd_data): Add variant_p member. * parser.c (cp_ensure_no_omp_declare_simd): Handle both declare simd and declare variant. (cp_parser_oacc_all_clauses): Formatting fix. (cp_parser_omp_all_clauses): Add NESTED_P argument, if true, terminate processing on closing paren and don't skip to end of pragma line. (cp_parser_omp_declare_simd): Add VARIANT_P argument. Handle also declare variant. (omp_construct_selectors, omp_device_selectors, omp_implementation_selectors, omp_user_selectors): New variables. (cp_parser_omp_context_selector, cp_parser_omp_context_selector_specification, cp_finish_omp_declare_variant): New functions. (cp_parser_late_parsing_omp_declare_simd): Handle also declare variant. (cp_parser_omp_declare): Handle declare variant. testsuite/ * c-c++-common/gomp/declare-variant-1.c: New test. * c-c++-common/gomp/declare-variant-2.c: New test. * c-c++-common/gomp/declare-variant-3.c: New test. * g++.dg/gomp/this-1.C: Adjust for diagnostic message spelling fix. * gcc.dg/gomp/declare-variant-1.c: New test. * gcc.dg/gomp/declare-variant-2.c: New test. From-SVN: r276789
2019-10-02Handle :: tokens in C for C2x.Joseph Myers2-6/+24
As part of adding [[]]-style attributes, C2x adds the token :: for use in scoped attribute names. This patch adds corresponding support for that token in C to GCC. The token is supported both for C2x and for older gnu* standards (on the basis that extensions are normally supported in older gnu* versions; people will expect to be able to use [[]] attributes, before C2x is the default, without needing to use -std=gnu2x). There are no cases in older C standards where the token : can be followed by a token starting with : in syntactically valid sources; the only cases the :: token could break in older standard C thus are ones involving concatenation of pp-tokens where the result does not end up as tokens (e.g., gets stringized). In GNU C extensions, the main case where :: might appear in existing sources is in asm statements, and the C parser is thus made to handle it like two consecutive : tokens, which the C++ parser already does. A limited test of various positionings of :: in asm statements is added to the testsuite (in particular, to cover the syntax error when :: means too many colons but a single : would be OK), but existing tests cover a variety of styles there anyway. Technically there are cases in Objective-C and OpenMP for which this also changes how previously valid code is lexed: the objc-selector-arg syntax allows multiple consecutive : tokens (although I don't think they are particularly useful there), while OpenMP syntax includes array section syntax such as [:] which, before :: was a token, could also be written as [::> (there might be other OpenMP cases potentially affected, I didn't check all the OpenMP syntax in detail). I don't think either of those cases affects the basis for supporting the :: token in all -std=gnu* modes, or that there is any obvious need to special-case handling of CPP_SCOPE tokens for those constructs the way there is for asm statements. cpp_avoid_paste, which determines when spaces need adding between tokens in preprocessed output where there wouldn't otherwise be whitespace between them (e.g. if stringized), already inserts space between : and : unconditionally, rather than only for C++, so no change is needed there (but a C2x test is added that such space is indeed inserted). Bootstrapped with no regressions on x86-64-pc-linux-gnu. gcc/c: * c-parser.c (c_parser_asm_statement): Handle CPP_SCOPE like two CPP_COLON tokens. gcc/testsuite: * gcc.dg/asm-scope-1.c, gcc.dg/cpp/c11-scope-1.c, gcc.dg/cpp/c17-scope-1.c, gcc.dg/cpp/c2x-scope-1.c, gcc.dg/cpp/c2x-scope-2.c, gcc.dg/cpp/c90-scope-1.c, gcc.dg/cpp/c94-scope-1.c, gcc.dg/cpp/c99-scope-1.c, gcc.dg/cpp/gnu11-scope-1.c, gcc.dg/cpp/gnu17-scope-1.c, gcc.dg/cpp/gnu89-scope-1.c, gcc.dg/cpp/gnu99-scope-1.c: New tests. libcpp: * include/cpplib.h (struct cpp_options): Add member scope. * init.c (struct lang_flags, lang_defaults): Likewise. (cpp_set_lang): Set scope member of pfile. * lex.c (_cpp_lex_direct): Test CPP_OPTION (pfile, scope) not CPP_OPTION (pfile, cplusplus) for creating CPP_SCOPE tokens. From-SVN: r276434
2019-10-01[C] Avoid aka types that just add tagsRichard Sandiford2-1/+73
diag-aka-1.c tests that: struct T { int i; } T; void *a; T *t = a; produces: request for implicit conversion from 'void *' to 'T *' {aka 'struct T *'} ... But printing an aka for the tag seems a bit redundant when the tag name is the same as the typedef name. It's probably not going to be telling the user anything they don't already know, and can be distracting if "T" rather than "struct T" is the preferred choice for an exported interface. This is even more true if the tag is anonymous; e.g.: struct { int i; } T; void *a; T *t = a; gives: request for implicit conversion from 'void *' to 'T *' {aka 'struct <anonymous> *'} Rather than just drop the test above, the patch instead tests for: struct T { int i; } *T; where seeing the tag definitely helps. 2019-10-01 Richard Sandiford <richard.sandiford@arm.com> gcc/c/ * c-objc-common.c (useful_aka_type_p): New function. (print_type): Use it to decide whether an aka type is worth printing. gcc/testsuite/ * gcc.dg/diag-aka-1.c (T): Turn into a pointer typedef. (foo): Update accordingly. * gcc.dg/diag-aka-4.c: New test. From-SVN: r276395
2019-09-27re PR c++/88203 (assert does not compile with OpenMP's pragma omp parallel ↵Jakub Jelinek3-38/+83
for default(none)) PR c++/88203 c-family/ * c-common.h (c_omp_predefined_variable): Declare. * c-omp.c (c_omp_predefined_variable): New function. (c_omp_predetermined_sharing): Return OMP_CLAUSE_DEFAULT_SHARED for predefined variables. c/ * c-parser.c (c_parser_predefined_identifier): New function. (c_parser_postfix_expression): Use it. (c_parser_omp_variable_list): Parse predefined identifiers. * c-typeck.c (c_finish_omp_clauses): Allow predefined variables in shared and firstprivate clauses, even when they are predetermined shared. cp/ * parser.c (cp_parser_omp_var_list_no_open): Parse predefined variables. * semantics.c (finish_omp_clauses): Allow predefined variables in shared and firstprivate clauses, even when they are predetermined shared. * cp-gimplify.c (cxx_omp_predetermined_sharing_1): Return OMP_CLAUSE_DEFAULT_SHARED for predefined variables. testsuite/ * c-c++-common/gomp/pr88203-1.c: New test. * c-c++-common/gomp/pr88203-2.c: New test. * c-c++-common/gomp/pr88203-3.c: New test. From-SVN: r276212
2019-09-27[C][C++] Allow targets to check calls to BUILT_IN_MD functionsRichard Sandiford2-4/+15
For SVE, we'd like the frontends to check calls to target-specific built-in functions in the same way that they already do for "normal" builtins. This patch adds a target hook for that and extends check_builtin_function_arguments accordingly. A slight complication is that when TARGET_RESOLVE_OVERLOADED_BUILTIN has resolved an overload, it can use build_function_call_vec to build the call to the underlying non-overloaded function decl. This in turn coerces the arguments to the function type and then calls check_builtin_function_arguments to check the final call. If the target does find a problem in this final call, it can be useful to refer to the original overloaded function decl in diagnostics, since that's what the user wrote. The patch therefore passes the original decl as a final optional parameter to build_function_call_vec. 2019-09-27 Richard Sandiford <richard.sandiford@arm.com> gcc/ * target.def (check_builtin_call): New target hook. * doc/tm.texi.in (TARGET_CHECK_BUILTIN_CALL): New @hook. * doc/tm.texi: Regenerate. gcc/c-family/ * c-common.h (build_function_call_vec): Take the original function decl as an optional final parameter. (check_builtin_function_arguments): Take the original function decl. * c-common.c (check_builtin_function_arguments): Likewise. Handle all built-in functions, not just BUILT_IN_NORMAL ones. Use targetm.check_builtin_call to check BUILT_IN_MD functions. gcc/c/ * c-typeck.c (build_function_call_vec): Take the original function decl as an optional final parameter. Pass all built-in calls to check_builtin_function_arguments. gcc/cp/ * cp-tree.h (build_cxx_call): Take the original function decl as an optional final parameter. (cp_build_function_call_vec): Likewise. * call.c (build_cxx_call): Likewise. Pass all built-in calls to check_builtin_function_arguments. * typeck.c (build_function_call_vec): Take the original function decl as an optional final parameter and pass it to cp_build_function_call_vec. (cp_build_function_call_vec): Take the original function decl as an optional final parameter and pass it to build_cxx_call. From-SVN: r276176
2019-09-20re PR c/91815 (questionable error on type definition at file scope)Eric Botcazou2-2/+11
PR c/91815 * c-decl.c (pushdecl): In C detect duplicate declarations across scopes of identifiers in the external scope only for variables and functions. From-SVN: r275992
2019-09-04Add warning Wenum-conversion for C and ObjC.Prathamesh Kulkarni2-0/+20
The patch enables warning with Wextra due to PR91593 and warnings with allmodconfig kernel build. Once these issues are resolved, we could consider promoting it to Wall. 2019-09-04 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR c/78736 * doc/invoke.texi: Document -Wenum-conversion. c-family * c.opt (Wenum-conversion): New option. c/ * c-typeck.c (convert_for_assignment): Handle Wenum-conversion. testsuite/ * gcc.dg/Wenum-conversion.c: New test-case. From-SVN: r275376
2019-08-23[PATCH, c-family] Fix a PCH thinko (and thus PR61250).Iain Sandoe2-0/+9
When we are parsing a source file, the very first token might be a PRAGMA_GCC_PCH_PREPROCESS. This indicates that we are going read in a PCH file (named as the value of the pragma). If we don't see this pragma, then we know that it's OK to release any resources that the host might have set aside for the PCH file. This fixes a thinko in the current implementation, in that the decision to release resources was happening unconditionally right after the first token is extracted but before it's been checked or acted upon. This leads to the pch bug (seen on Darwin), because we actually do release resources - which are subsequently (reasonably) assumed to be available when reading a PCH file. We then get random crashes or hangs depending on the interaction between unmmap and malloc. The bug is present everywhere but doesn't show on (say) Linux, since the release of PCH resources is a NOP there. This effects all the c-family front ends, because they all use c_lex_with_flags () to implement this. The solution is to check for the PRAGMA_GCC_PCH_PREPROCESS and only call c_common_no_more_pch () when that is not the first token. A secondary effect of the collection is that the name of the PCH file can be collected during the ggc_pch_read() reset of state. Therefore we should issue any diagnostic that might name the file before the collections are triggered. gcc/c-family/ 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> PR pch/61250 * c-lex.c (c_lex_with_flags): Don't call c_common_no_more_pch () from here. gcc/c/ 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> PR pch/61250 * c-parser.c (c_parse_file): Call c_common_no_more_pch () after determining that the first token is not PRAGMA_GCC_PCH_PREPROCESS. gcc/cp/ 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> PR pch/61250 * parser.c (cp_parser_initial_pragma): Call c_common_no_more_pch () after determining that the first token is not PRAGMA_GCC_PCH_PREPROCESS. gcc/ 2019-08-23 Iain Sandoe <iain@sandoe.co.uk> PR pch/61250 * ggc-page.c (ggc_pch_read): Read the ggc_pch_ondisk structure and issue any diagnostics needed before collecting the pre-PCH state. From-SVN: r274856
2019-08-22c-parser.c (c_parser_declaration_or_fndef): Set DECL_ARGUMENTS of a ↵Eric Botcazou2-2/+38
FUNCTION_DECL to the right value in the presence of... * c-parser.c (c_parser_declaration_or_fndef): Set DECL_ARGUMENTS of a FUNCTION_DECL to the right value in the presence of nested declarators. From-SVN: r274828