aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
AgeCommit message (Collapse)AuthorFilesLines
2023-07-07Update ChangeLog and version files for releasereleases/gcc-10.5.0releases/gcc-10Richard Biener1-0/+4
2023-05-04Daily bump.GCC Administrator1-0/+19
2023-05-03c, c++: Fix up excess precision handling of scalar_to_vector conversion ↵Jakub Jelinek1-2/+2
[PR107358] As mentioned earlier in the C++ excess precision support mail, the following testcase is broken with excess precision both in C and C++ (though just in C++ it was triggered in real-world code). scalar_to_vector is called in both FEs after the excess precision promotions (or stripping of EXCESS_PRECISION_EXPR), so we can then get invalid diagnostics that say float vector + float involves truncation (on ia32 from long double to float). The following patch fixes that by calling scalar_to_vector on the operands before the excess precision promotions, let scalar_to_vector just do the diagnostics (it does e.g. fold_for_warn so it will fold EXCESS_PRECISION_EXPR around REAL_CST to constants etc.) but will then do the actual conversions using the excess precision promoted operands (so say if we have vector double + (float + float) we don't actually do vector double + (float) ((long double) float + (long double) float) but vector double + (double) ((long double) float + (long double) float) 2022-10-24 Jakub Jelinek <jakub@redhat.com> PR c++/107358 gcc/c/ * c-typeck.c (build_binary_op): Pass operands before excess precision promotions to scalar_to_vector call. gcc/testsuite/ * c-c++-common/pr107358.c: New test. (cherry picked from commit 65e3274e363cb2c6bfe6b5e648916eb7696f7e2f)
2023-05-03openmp, c: Tighten up c_tree_equal [PR106981]Jakub Jelinek1-6/+10
This patch changes c_tree_equal to work more like cp_tree_equal, be more strict in what it accepts. The ICE on the first testcase was due to INTEGER_CST wi::wide (t1) == wi::wide (t2) comparison which ICEs if the two constants have different precision, but as the second testcase shows, being too lenient in it can also lead to miscompilation of valid OpenMP programs where we think certain expression is the same even when it isn't and can be guaranteed at runtime to represent different memory location. So, the patch looks through only NON_LVALUE_EXPRs and for constants as well as casts requires that the types match before actually comparing the constant values or recursing on the cast operands. 2022-09-24 Jakub Jelinek <jakub@redhat.com> PR c/106981 gcc/c/ * c-typeck.c (c_tree_equal): Only strip NON_LVALUE_EXPRs at the start. For CONSTANT_CLASS_P or CASE_CONVERT: return false if t1 and t2 have different types. gcc/testsuite/ * c-c++-common/gomp/pr106981.c: New test. libgomp/ * testsuite/libgomp.c-c++-common/pr106981.c: New test. (cherry picked from commit 3c5bccb608c665ac3f62adb1817c42c845812428)
2022-08-03Daily bump.GCC Administrator1-0/+9
2022-08-02c: Fix location for _Pragma tokens [PR97498]Lewis Hyatt1-0/+1
The handling of #pragma GCC diagnostic uses input_location, which is not always as precise as needed; in particular the relative location of some tokens and a _Pragma directive will crucially determine whether a given diagnostic is enabled or suppressed in the desired way. PR97498 shows how the C frontend ends up with input_location pointing to the beginning of the line containing a _Pragma() directive, resulting in the wrong behavior if the diagnostic to be modified pertains to some tokens found earlier on the same line. This patch fixes that by addressing two issues: a) libcpp was not assigning a valid location to the CPP_PRAGMA token generated by the _Pragma directive. b) C frontend was not setting input_location to something reasonable. With this change, the C frontend is able to change input_location to point to the _Pragma token as needed. This is just a two-line fix (one for each of a) and b)), the testsuite changes were needed only because the location on the tested warnings has been somewhat improved, so the tests need to look for the new locations. gcc/c/ChangeLog: PR preprocessor/97498 * c-parser.c (c_parser_pragma): Set input_location to the location of the pragma, rather than the start of the line. libcpp/ChangeLog: PR preprocessor/97498 * directives.c (destringize_and_run): Override the location of the CPP_PRAGMA token from a _Pragma directive to the location of the expansion point, as is done for the tokens lexed from it. gcc/testsuite/ChangeLog: PR preprocessor/97498 * c-c++-common/pr97498.c: New test. * gcc.dg/pragma-message.c: Adapt for improved warning locations. (cherry picked from commit 0587cef3d7962a8b0f44779589ba2920dd3d71e5)
2022-06-28Update ChangeLog and version files for releasereleases/gcc-10.4.0Jakub Jelinek1-0/+4
2022-05-11Daily bump.GCC Administrator1-0/+54
2022-05-10c, c++, c-family: -Wshift-negative-value and -Wshift-overflow* tweaks for ↵Jakub Jelinek2-1/+3
-fwrapv and C++20+ [PR104711] As mentioned in the PR, different standards have different definition on what is an UB left shift. They all agree on out of bounds (including negative) shift count. The rules used by ubsan are: C99-C2x ((unsigned) x >> (uprecm1 - y)) != 0 then UB C++11-C++17 x < 0 || ((unsigned) x >> (uprecm1 - y)) > 1 then UB C++20 and later everything is well defined Now, for C++20, I've in the P1236R1 implementation added an early exit for -Wshift-overflow* warning so that it never warns, but apparently -Wshift-negative-value remained as is. As it is well defined in C++20, the following patch doesn't enable -Wshift-negative-value from -Wextra anymore for C++20 and later, if users want for compatibility with C++17 and earlier get the warning, they still can by using -Wshift-negative-value explicitly. Another thing is -fwrapv, that is an extension to the standards, so it is up to us how exactly we define that case. Our ubsan code treats TYPE_OVERFLOW_WRAPS (type0) and cxx_dialect >= cxx20 the same as only diagnosing out of bounds shift count and nothing else and IMHO it is most sensical to treat -fwrapv signed left shifts the same as C++20 treats them, https://eel.is/c++draft/expr.shift#2 "The value of E1 << E2 is the unique value congruent to E1×2^E2 modulo 2^N, where N is the width of the type of the result. [Note 1: E1 is left-shifted E2 bit positions; vacated bits are zero-filled. — end note]" with no UB dependent on the E1 values. The UB is only "The behavior is undefined if the right operand is negative, or greater than or equal to the width of the promoted left operand." Under the hood (except for FEs and ubsan from FEs) GCC middle-end doesn't consider UB in left shifts dependent on the first operand's value, only the out of bounds shifts. While this change isn't a regression, I'd think it is useful for GCC 12, it doesn't add new warnings, but just removes warnings that aren't appropriate. 2022-03-09 Jakub Jelinek <jakub@redhat.com> PR c/104711 gcc/ * doc/invoke.texi (-Wextra): Document that -Wshift-negative-value is enabled by it only for C++11 to C++17 rather than for C++03 or later. (-Wshift-negative-value): Similarly (except here we stated that it is enabled for C++11 or later). gcc/c-family/ * c-opts.c (c_common_post_options): Don't enable -Wshift-negative-value from -Wextra for C++20 or later. * c-ubsan.c (ubsan_instrument_shift): Adjust comments. * c-warn.c (maybe_warn_shift_overflow): Use TYPE_OVERFLOW_WRAPS instead of TYPE_UNSIGNED. gcc/c/ * c-fold.c (c_fully_fold_internal): Don't emit -Wshift-negative-value warning if TYPE_OVERFLOW_WRAPS. * c-typeck.c (build_binary_op): Likewise. gcc/cp/ * constexpr.c (cxx_eval_check_shift_p): Use TYPE_OVERFLOW_WRAPS instead of TYPE_UNSIGNED. * typeck.c (cp_build_binary_op): Don't emit -Wshift-negative-value warning if TYPE_OVERFLOW_WRAPS. gcc/testsuite/ * c-c++-common/Wshift-negative-value-1.c: Remove dg-additional-options, instead in target selectors of each diagnostic check for exact C++ versions where it should be diagnosed. * c-c++-common/Wshift-negative-value-2.c: Likewise. * c-c++-common/Wshift-negative-value-3.c: Likewise. * c-c++-common/Wshift-negative-value-4.c: Likewise. * c-c++-common/Wshift-negative-value-7.c: New test. * c-c++-common/Wshift-negative-value-8.c: New test. * c-c++-common/Wshift-negative-value-9.c: New test. * c-c++-common/Wshift-negative-value-10.c: New test. * c-c++-common/Wshift-overflow-1.c: Remove dg-additional-options, instead in target selectors of each diagnostic check for exact C++ versions where it should be diagnosed. * c-c++-common/Wshift-overflow-2.c: Likewise. * c-c++-common/Wshift-overflow-5.c: Likewise. * c-c++-common/Wshift-overflow-6.c: Likewise. * c-c++-common/Wshift-overflow-7.c: Likewise. * c-c++-common/Wshift-overflow-8.c: New test. * c-c++-common/Wshift-overflow-9.c: New test. * c-c++-common/Wshift-overflow-10.c: New test. * c-c++-common/Wshift-overflow-11.c: New test. * c-c++-common/Wshift-overflow-12.c: New test. (cherry picked from commit d76511138dc816ef66fd16f71531f48c37dac3b4)
2022-05-10c: Fix ICE on deferred pragma in unknown attribute arguments [PR103587]Jakub Jelinek1-0/+5
We ICE on the following testcase, because c_parser_balanced_token_sequence when encountering a deferred pragma will just use c_parser_consume_token which the FE doesn't allow for CPP_PRAGMA tokens (and if that wasn't the case, it could ICE on CPP_PRAGMA_EOL similarly). We don't know in what exact context the pragma appears when we don't know what those arguments semantically mean, so I think we should just skip over them, like e.g. the C++ FE does. And, I think (/[/{ vs. )/]/} from outside of the pragma shouldn't be paired with those inside of the pragma and it doesn't seem to be necessary to check that inside of the pragma line itself all the paren kinds are balanced. 2021-12-14 Jakub Jelinek <jakub@redhat.com> PR c/103587 * c-parser.c (c_parser_balanced_token_sequence): For CPP_PRAGMA, consume the pragma and silently skip to the pragma eol. * gcc.dg/pr103587.c: New test. (cherry picked from commit e163dbbc4433e598cad7e6011b255d1d6ad93a3b)
2022-05-10OpenMP: Support complex/float in && and || reductionTobias Burnus1-8/+2
C/C++ permit logical AND and logical OR also with floating-point or complex arguments by doing an unequal zero comparison; the result is an 'int' with value one or zero. Hence, those are also permitted as reduction variable, even though it is not the most sensible thing to do. gcc/c/ChangeLog: * c-typeck.c (c_finish_omp_clauses): Accept float + complex for || and && reductions. gcc/cp/ChangeLog: * semantics.c (finish_omp_reduction_clause): Accept float + complex for || and && reductions. gcc/ChangeLog: * omp-low.c (lower_rec_input_clauses, lower_reduction_clauses): Handle && and || with floating-point and complex arguments. gcc/testsuite/ChangeLog: * gcc.dg/gomp/clause-1.c: Use 'reduction(&:..)' instead of '...(&&:..)'. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/reduction-1.c: New test. * testsuite/libgomp.c-c++-common/reduction-2.c: New test. * testsuite/libgomp.c-c++-common/reduction-3.c: New test. (cherry picked from commit 1580fc764423bf89e9b853aaa8c65999e37ccb8b)
2022-05-10c: Fix up c_parser_has_attribute_expression [PR101176]Jakub Jelinek1-0/+3
This function keeps src_range member of the result uninitialized, which at least under valgrind can show up later when those uninitialized location_t's can make it into the IL or location_t hash tables. 2021-06-24 Jakub Jelinek <jakub@redhat.com> PR c/101176 * c-parser.c (c_parser_has_attribute_expression): Set source range for the result. (cherry picked from commit 178fb8df9315f2f8f45b7fe5faf11a9c2912cc28)
2022-05-10c: Fix C cast error-recovery [PR101171]Jakub Jelinek1-0/+1
The following testcase ICEs during error-recovery, as build_c_cast calls note_integer_operands on error_mark_node and that wraps it into C_MAYBE_CONST_EXPR which is unexpected and causes ICE later on. Seems most other callers of note_integer_operands check early if something is error_mark_node and return before calling note_integer_operands on it. The following patch fixes it by not calling on error_mark_node, another possibility would be to handle error_mark_node in note_integer_operands and just return it. 2021-06-24 Jakub Jelinek <jakub@redhat.com> PR c/101171 * c-typeck.c (build_c_cast): Don't call note_integer_operands on error_mark_node. * gcc.dg/pr101171.c: New test. (cherry picked from commit fdc5522fb04b4a820b28c4d1f16f54897f5978de)
2022-05-10inline-asm: Fix ICE with bitfields in "m" operands [PR100785]Jakub Jelinek1-1/+10
Bitfields, while they live in memory, aren't something inline-asm can easily operate on. For C and "=m" or "+m", we were diagnosing bitfields in the past in the FE, where c_mark_addressable had: case COMPONENT_REF: if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1))) { error ("cannot take address of bit-field %qD", TREE_OPERAND (x, 1)); return false; } but that check got moved in GCC 6 to build_unary_op instead and now we emit an error during expansion and ICE afterwards (i.e. error-recovery). For "m" it used to be diagnosed in c_mark_addressable too, but since GCC 6 it is ice-on-invalid. For C++, this was never diagnosed in the FE, but used to be diagnosed in the gimplifier and/or during expansion before 4.8. The following patch does multiple things: 1) diagnoses it in the FEs 2) simplifies during expansion the inline asm if any errors have been reported (similarly how e.g. vregs pass if it detects errors on inline-asm either deletes them or simplifies to bare minimum - just labels), so that we don't have error-recovery ICEs there 2021-06-11 Jakub Jelinek <jakub@redhat.com> PR inline-asm/100785 gcc/ * cfgexpand.c (expand_asm_stmt): If errors are emitted, remove all inputs, outputs and clobbers from the asm and set template to "". gcc/c/ * c-typeck.c (c_mark_addressable): Diagnose trying to make bit-fields addressable. gcc/cp/ * typeck.c (cxx_mark_addressable): Diagnose trying to make bit-fields addressable. gcc/testsuite/ * c-c++-common/pr100785.c: New test. (cherry picked from commit 644c2cc5f2c09506a7bfef293a7f90efa8d7e5fa)
2021-04-21Daily bump.GCC Administrator1-0/+9
2021-04-20c: Avoid clobbering TREE_TYPE (error_mark_node) [PR99990]Jakub Jelinek1-1/+1
The following testcase ICEs during error recovery, because finish_decl overwrites TREE_TYPE (error_mark_node), which better should stay always to be error_mark_node. 2021-04-10 Jakub Jelinek <jakub@redhat.com> PR c/99990 * c-decl.c (finish_decl): Don't overwrite TREE_TYPE of error_mark_node. * gcc.dg/pr99990.c: New test. (cherry picked from commit 9f7d77bd6d65aa1cf2e195d3776052705c6e636b)
2021-04-08Update ChangeLog and version files for releasereleases/gcc-10.3.0Richard Biener1-0/+4
2021-03-31Daily bump.GCC Administrator1-0/+10
2021-03-30c: Fix up -Wunused-but-set-* warnings for _Atomics [PR99588]Jakub Jelinek1-6/+60
As the following testcases show, compared to -D_Atomic= case we have many -Wunused-but-set-* warning false positives. When an _Atomic variable/parameter is read, we call mark_exp_read on it in convert_lvalue_to_rvalue, but build_atomic_assign does not. For consistency with the non-_Atomic case where we mark_exp_read the lhs for lhs op= ... but not for lhs = ..., this patch does that too. But furthermore we need to pattern match the trees emitted by _Atomic store, so that _Atomic store itself is not marked as being a variable read, but when the result of the store is used, we mark it. 2021-03-19 Jakub Jelinek <jakub@redhat.com> PR c/99588 * c-typeck.c (mark_exp_read): Recognize what build_atomic_assign with modifycode NOP_EXPR produces and mark the _Atomic var as read if found. (build_atomic_assign): For modifycode of NOP_EXPR, use COMPOUND_EXPRs rather than STATEMENT_LIST. Otherwise call mark_exp_read on lhs. Set TREE_SIDE_EFFECTS on the TARGET_EXPR. * gcc.dg/Wunused-var-5.c: New test. * gcc.dg/Wunused-var-6.c: New test.
2021-03-25Daily bump.GCC Administrator1-0/+7
2021-03-24Objective-C/C++ : Fix rejects valid fails for properties.Iain Sandoe1-121/+159
This amends the property handling to fix missing cases and improve diagnostics. 1. Address a FIXME. We can avoid the spurious additional complaint about a closing ')' by short-circuiting the test in the case we know there's a syntax error already reported. 2. Improve '@' keyword locations. When we are lexing tokens for Objective-C, we combine '@' tokens with a following keyword (when that keyword is a valid Objective-C one or, for Objective-C, one of the C++ keywords that can appear in this position). The responsibility is passed on to the parser to validate the resulting combination. The combination of tokens was being done without applying the rule to their locations - so that we get: @property ^ instead of what the user might expect: @property ^~~~~~~~~ This patch combines the source range of the keyword with that of the '@' sign - which improves diagnostics. 3. Update @property attribute parsing At present, we are missing parsing and checking for around half of the property attributes in use. The existing ad hoc scheme for the parser's communication with the Objective C validation is not suitable for extending to cover all the missing cases. We are not adding the new cases in the backport, but covering the missing 'atomic' one. 4. Add missing 'atomic' property attribute. This is the default, but it is still legal in user code and therefore we should handle it in parsing. Fix whitespace issues in the lines affected. Backported from e344ea07e4024316e1bc01f18bf7f187ad3aef89, 7a2cc1e8438ee853900f20880ca8858c17486b10, 9a34a5cce6b50fc3527e7c7ab356808ed435883c and 6f762481a21f211c03b6eda416b5d5737c3ed4b7 gcc/cp/ChangeLog: * parser.c (cp_parser_objc_at_property_declaration): Use any exisiting syntax error to suppress complaints about a missing closing parenthesis in parsing property attributes. gcc/testsuite/ChangeLog: * obj-c++.dg/property/at-property-1.mm: Adjust test after fixing spurious error output. gcc/c-family/ChangeLog: * c-lex.c (c_lex_with_flags): When combining '@' with a keyword for Objective-C, combine the location ranges too. gcc/c-family/ChangeLog: * c-objc.h (enum objc_property_attribute_group): New (enum objc_property_attribute_kind): New. (OBJC_PROPATTR_GROUP_MASK): New. (struct property_attribute_info): Small class encapsulating parser output from property attributes. (objc_prop_attr_kind_for_rid): New (objc_add_property_declaration): Simplify interface. * stub-objc.c (enum rid): Dummy type. (objc_add_property_declaration): Simplify interface. (objc_prop_attr_kind_for_rid): New. gcc/c/ChangeLog: * c-parser.c (c_parser_objc_at_property_declaration): Improve parsing fidelity. Associate better location info with @property attributes. Clean up the interface to objc_add_property_declaration (). gcc/cp/ChangeLog: * parser.c (cp_parser_objc_at_property_declaration): Improve parsing fidelity. Associate better location info with @property attributes. Clean up the interface to objc_add_property_declaration (). gcc/objc/ChangeLog: * objc-act.c (objc_prop_attr_kind_for_rid): New. (objc_add_property_declaration): Adjust to consume the parser output using a vector of parsed attributes. gcc/testsuite/ChangeLog: * obj-c++.dg/property/at-property-1.mm: Adjust expected diagnostics. * obj-c++.dg/property/at-property-29.mm: Likewise. * obj-c++.dg/property/at-property-4.mm: Likewise. * obj-c++.dg/property/property-neg-2.mm: Likewise. * objc.dg/property/at-property-1.m: Likewise. * objc.dg/property/at-property-29.m: Likewise. * objc.dg/property/at-property-4.m: Likewise. * objc.dg/property/at-property-5.m: Likewise. * objc.dg/property/property-neg-2.m: Likewise. gcc/c-family/ChangeLog: * c-common.c (c_common_reswords): Add 'atomic' property attribute. * c-common.h (enum rid): Add RID_PROPATOMIC for atomic property attributes. gcc/objc/ChangeLog: * objc-act.c (objc_prop_attr_kind_for_rid): Handle RID_PROPATOMIC. gcc/testsuite/ChangeLog: * obj-c++.dg/property/at-property-4.mm: Test atomic property attribute. * objc.dg/property/at-property-4.m: Likewise.
2021-03-20Daily bump.GCC Administrator1-0/+9
2021-03-20c: Fix ICE with -fexcess-precision=standard [PR99136]Jakub Jelinek1-1/+3
The following testcase ICEs on i686-linux, because c_finish_return wraps c_fully_folded retval back into EXCESS_PRECISION_EXPR, but when the function return type is void, we don't call convert_for_assignment on it that would then be fully folded again, but just put the retval into RETURN_EXPR's operand, so nothing removes it anymore and during gimplification we ICE as EXCESS_PRECISION_EXPR is not handled. This patch fixes it by not adding that EXCESS_PRECISION_EXPR in functions returning void, the return value is ignored and all we need is evaluate any side-effects of the expression. 2021-02-18 Jakub Jelinek <jakub@redhat.com> PR c/99136 * c-typeck.c (c_finish_return): Don't wrap retval into EXCESS_PRECISION_EXPR in functions that return void. * gcc.dg/pr99136.c: New test. (cherry picked from commit d82f829905cfe6cb47d073825f680900274ce764)
2021-03-07Daily bump.GCC Administrator1-0/+8
2021-03-06OpenACC: C/C++ - fix async parsing [PR99137]Tobias Burnus1-1/+1
gcc/c/ChangeLog: PR c/99137 * c-parser.c (c_parser_oacc_clause_async): Reject comma expressions. gcc/cp/ChangeLog: PR c/99137 * parser.c (cp_parser_oacc_clause_async): Reject comma expressions. gcc/testsuite/ChangeLog: PR c/99137 * c-c++-common/goacc/asyncwait-1.c: Update dg-error; add additional test. (cherry picked from commit 6ddedd3efa3fe482f76a4037521a06b3ac9f2a8b)
2020-11-26Daily bump.GCC Administrator1-0/+10
2020-11-25openmp: Fix C ICE on OpenMP atomicsJakub Jelinek1-3/+7
c_parser_binary_expression was using build2 to create a temporary holder for binary expression that c_parser_atomic and c_finish_omp_atomic can then handle. The latter performs then all the needed checking. Unfortunately, build2 performs some checking too, e.g. PLUS_EXPR vs. POINTER_PLUS_EXPR or matching types of the arguments, nothing we can guarantee at the parsing time. So we need something like C++ build_min_nt*. This patch implements that inline. 2020-11-24 Jakub Jelinek <jakub@redhat.com> PR c/97958 * c-parser.c (c_parser_binary_expression): For omp atomic binary expressions, use make_node instead of build2 to avoid checking build2 performs. * c-c++-common/gomp/pr97958.c: New test. (cherry picked from commit 2aaf44a90283156ec0e70ad4d9030f3ba5054c6f)
2020-08-26Daily bump.GCC Administrator1-0/+10
2020-08-25c: Fix -Wunused-but-set-* warning with _Generic [PR96571]Jakub Jelinek1-6/+13
The following testcase shows various problems with -Wunused-but-set* warnings and _Generic construct. I think it is best to treat the selector and the ignored expressions as (potentially) read, because when they are parsed, the vars in there are already marked as TREE_USED. 2020-08-18 Jakub Jelinek <jakub@redhat.com> PR c/96571 * c-parser.c (c_parser_generic_selection): Change match_found from bool to int, holding index of the match. Call mark_exp_read on the selector expression and on expressions other than the selected one. * gcc.dg/Wunused-var-4.c: New test. (cherry picked from commit 6d42cbe5ad7a7b46437f2576c9920e44dc14b386)
2020-08-04Daily bump.GCC Administrator1-0/+11
2020-08-03c: Fix bogus vector initialisation error [PR96377]Richard Sandiford1-15/+44
One of the problems in this PR was that if we had: vector_type1 array[] = { vector_value1 }; process_init_element would only treat vector_value1 as initialising a vector_type1 if they had the same TYPE_MAIN_VARIANT. This has several problems: (1) It gives confusing error messages if the vector types are incompatible. (Tested by gcc.dg/pr96377-1.c.) (2) It means that we reject code that should be valid with -flax-vector-conversions. (Tested by gcc.dg/pr96377-2.c.) (3) On arm and aarch64 targets, it means that we reject some initializers that mix Advanced SIMD and standard GNU vectors. These vectors have traditionally had different TYPE_MAIN_VARIANTs because they have different mangling schemes. (Tested by gcc.dg/pr96377-[3-6].c.) (4) It means that we reject SVE initializers that should be valid. (Tested by gcc.target/aarch64/sve/gnu_vectors_[34].c.) (5) After r11-1741-g:31427b974ed7b7dd54e2 we reject: arm_neon_type1 array[] = { k ^ arm_neon_value1 }; because applying the binary operator to arm_neon_value1 strips the "Advanced SIMD type" attributes that were added in that patch. Stripping the attributes is problematic for other reasons though, so that still needs to be fixed separately. g++.target/aarch64/sve/gnu_vectors_[34].C already pass. gcc/c/ PR c/96377 * c-typeck.c (process_init_element): Split test for whether to recurse into a record, union or array into... (initialize_elementwise_p): ...this new function. Don't recurse into a vector type if the initialization value is also a vector. gcc/testsuite/ PR c/96377 * gcc.dg/pr96377-1.c: New test. * gcc.dg/pr96377-2.c: Likewise. * gcc.dg/pr96377-3.c: Likewise. * gcc.dg/pr96377-4.c: Likewise. * gcc.dg/pr96377-5.c: Likewise. * gcc.dg/pr96377-6.c: Likewise. * gcc.target/aarch64/pr96377-1.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/gnu_vectors_3.c: Likewise. * gcc.target/aarch64/sve/acle/general-c/gnu_vectors_4.c: Likewise. * g++.target/aarch64/sve/acle/general-c++/gnu_vectors_3.C: Likewise. * g++.target/aarch64/sve/acle/general-c++/gnu_vectors_4.C: Likewise. (cherry picked from commit 7d599ad27b9bcf5165f87710f1abc64bbabd06ae)
2020-07-23Update ChangeLog and version files for releasereleases/gcc-10.2.0Richard Biener1-0/+4
2020-07-14Daily bump.GCC Administrator1-0/+10
2020-07-13openacc: Set bias to zero for explicit attach/detach clauses in C and C++Julian Brown1-0/+16
This is a fix for the pointer (or array) size inadvertently being used for the bias with attach and detach mapping kinds, for both C and C++. 2020-07-09 Julian Brown <julian@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> gcc/c/ PR middle-end/95270 * c-typeck.c (c_finish_omp_clauses): Set OMP_CLAUSE_SIZE (bias) to zero for standalone attach/detach clauses. gcc/cp/ PR middle-end/95270 * semantics.c (finish_omp_clauses): Likewise. include/ PR middle-end/95270 * gomp-constants.h (gomp_map_kind): Expand comment for attach/detach mapping kinds. gcc/testsuite/ PR middle-end/95270 * c-c++-common/goacc/mdc-1.c: Update expected dump output for zero bias. libgomp/ PR middle-end/95270 * testsuite/libgomp.oacc-c-c++-common/pr95270-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/pr95270-2.c: New test. (cherry picked from commit 0d00fe404c162ad0cf922ca8455aa23a74042b63)
2020-06-24Daily bump.GCC Administrator1-0/+6
2020-06-23c/95141 - fix bogus integer overflow warningRichard Biener1-0/+1
This fixes an integer overflow warning that ultimatively happens because of TREE_OVERFLOW propagating through transforms and the existing guard against this, 375 if (TREE_OVERFLOW_P (ret) 376 && !TREE_OVERFLOW_P (op0) 377 && !TREE_OVERFLOW_P (op1)) 378 overflow_warning (EXPR_LOC_OR_LOC (expr, input_location, being insufficient. Rather than trying to use sth like walk_tree to exhaustively walk operands (with the possibility of introducing quadraticness when folding larger expressions recursively) the following amends the above with an ad-hoc test for a binary op0 with a possibly constant op1. 2020-05-30 Richard Biener <rguenther@suse.de> PR c/95141 gcc/c * c-fold.c (c_fully_fold_internal): Enhance guard on overflow_warning. gcc/testsuite * gcc.dg/pr95141.c: New testcase.
2020-05-07testsuite: Improve g++.dg/ext/attr-parm-1.C testcase [PR94946]Jakub Jelinek1-1/+4
The testcase in the current form doesn't FAIL without the patch on x86_64-linux unless also testing with -m32; as that the 64-bit testing on that target is probably way more common, and we can use also attributes that FAIL without the patch with -m64, the following patch adjusts the test, so that it FAILs without the patch for both -m64 and -m32 (but not -mx32) and PASSes with the patch. 2020-05-07 Jakub Jelinek <jakub@redhat.com> PR c++/94946 * g++.dg/ext/attr-parm-1.C: Enable the test also for lp64 x86, use sysv_abi and ms_abi attributes in that case instead of fastcall and no attribute.
2020-05-07c: Fix ICE with _Atomic side-effect in nested fn param decls [PR94842]Jakub Jelinek2-4/+19
If there are _Atomic side-effects in the parameter declarations of non-nested function, when they are parsed, current_function_decl is NULL, the create_artificial_label created labels during build_atomic* are then adjusted by store_parm_decls through set_labels_context_r callback. Unfortunately, if such thing happens in nested function parameter declarations, while those decls are parsed current_function_decl is the parent function (and am not sure it is a good idea to temporarily clear it, some code perhaps should be aware it is in a nested function, or it can refer to variables from the parent function etc.) and that means store_param_decls through set_labels_context_r doesn't adjust anything. As those labels are emitted in the nested function body rather than in the parent, I think it is ok to override the context in those cases. 2020-04-30 Jakub Jelinek <jakub@redhat.com> PR c/94842 * c-decl.c (set_labels_context_r): In addition to context-less LABEL_DECLs adjust also LABEL_DECLs with context equal to parent function if any. (store_parm_decls): Adjust comment. * gcc.dg/pr94842.c: New test.
2020-05-07Update ChangeLog and version files for releasereleases/gcc-10.1.0Jakub Jelinek1-0/+4
2020-04-19c, objc: Fix up c_parser_objc_selector_arg after CPP_SCOPE changes [PR94637]Jakub Jelinek2-5/+24
Similarly to inline asm, :: (or any other number of consecutive colons) can appear in ObjC @selector argument and with the introduction of CPP_SCOPE into the C FE, we need to trat CPP_SCOPE as two CPP_COLON tokens. The C++ FE does that already that way. 2020-04-19 Jakub Jelinek <jakub@redhat.com> PR objc/94637 * c-parser.c (c_parser_objc_selector_arg): Handle CPP_SCOPE like two CPP_COLON tokens. * objc.dg/pr94637.m: New test.
2020-04-17c, c++: Fix two redundantAssignment warnings [PR94629]Jakub Jelinek2-1/+6
This change fixes two obvious redundant assignments reported by cppcheck: trunk.git/gcc/c/c-parser.c:16969:2: style: Variable 'data.clauses' is reassigned a value before the old one has been used. [redundantAssignment] trunk.git/gcc/cp/call.c:5116:9: style: Variable 'arg2' is reassigned a value before the old one has been used. [redundantAssignment] 2020-04-17 Jakub Jelinek <jakub@redhat.com> PR other/94629 * c-parser.c (c_parser_oacc_routine): Remove redundant assignment to data.clauses. * call.c (build_conditional_expr_1): Remove redundant assignment to arg2.
2020-04-15openmp: Reject requires directives not at file or namespace scope [PR94593]Jakub Jelinek2-0/+13
This change started with a bugreport about a typo in one requires testcase (diagnosed with -Wunknown-pragmas only), but following discussion lead to noting that we do not diagnose restriction that requires directives in C/C++ may only appear at file or namespace scope; and several our tests violated that. 2020-04-15 Jakub Jelinek <jakub@redhat.com> PR c/94593 * c-parser.c (c_parser_pragma) <case PRAGMA_OMP_REQUIRES>: Reject requires directive when not at file scope. * parser.c (cp_parser_pragma) <case PRAGMA_OMP_REQUIRES>: Reject requires directive when not at file or namespace scope. * c-c++-common/gomp/requires-1.c: Fix a typo, requries -> requires. Move directives to file scope. (i): Remove. * c-c++-common/gomp/requires-2.c: Move directives to file scope. (i, foo): Remove. * c-c++-common/gomp/requires-4.c: Move directives to file scope. * c-c++-common/gomp/atomic-19.c: Move requires directive to file scope. * c-c++-common/gomp/atomic-20.c: Likewise. * c-c++-common/gomp/atomic-21.c: Likewise. * c-c++-common/gomp/atomic-22.c: Likewise. * gcc.dg/gomp/requires-1.c: New test. * g++.dg/gomp/requires-1.C: New test. * g++.dg/gomp/requires-2.C: New test. * g++.dg/gomp/atomic-18.C: Move requires directive to file scope.
2020-04-08[C/C++, OpenACC] Reject vars of different scope in acc declare (PR94120)Tobias Burnus4-0/+27
gcc/c/ PR middle-end/94120 * c-decl.c (c_check_in_current_scope): New function. * c-tree.h (c_check_in_current_scope): Declare it. * c-parser.c (c_parser_oacc_declare): Add check that variables are declared in the same scope as the directive. Fix handling of namespace vars. gcc/cp/ PR middle-end/94120 * paser.c (cp_parser_oacc_declare): Add check that variables are declared in the same scope as the directive. gcc/testsuite/ PR middle-end/94120 * c-c++-common/goacc/declare-pr94120.c: New. * g++.dg/declare-pr94120.C: New. libgomp/testsuite/ PR middle-end/94120 * libgomp.oacc-c++/declare-pr94120.C: New.
2020-04-07openmp: Fix parallel master error recovery [PR94512]Jakub Jelinek2-1/+7
We need to set OMP_PARALLEL_COMBINED only if the parsing of omp_master succeeded, because otherwise there is no nested master construct in the parallel. 2020-04-07 Jakub Jelinek <jakub@redhat.com> PR c++/94512 * c-parser.c (c_parser_omp_parallel): Set OMP_PARALLEL_COMBINED if c_parser_omp_master succeeded. * parser.c (cp_parser_omp_parallel): Set OMP_PARALLEL_COMBINED if cp_parser_omp_master succeeded. * g++.dg/gomp/pr94512.C: New test.
2020-03-28c: After issuing errors about array size, for error-recovery don't make the ↵Jakub Jelinek1-0/+3
array VLA [PR93573] After we report various errors about array size, we set for error-recovery the size to be 1, but because size_int_const is false, it still means we pretend the array is a VLA, can emit a second diagnostics in that case etc. E.g. $ ./cc1.unpatched -quiet a.c a.c:1:5: error: size of array ‘f’ has non-integer type 1 | int f[100.0]; | ^ a.c:1:1: warning: variably modified ‘f’ at file scope 1 | int f[100.0]; | ^~~ $ ./cc1 -quiet a.c a.c:1:5: error: size of array ‘f’ has non-integer type 1 | int f[100.0]; | ^ 2020-03-28 Jakub Jelinek <jakub@redhat.com> PR c/93573 * c-decl.c (grokdeclarator): After issuing errors, set size_int_const to true after setting size to integer_one_node. * gcc.dg/pr93573-1.c: New test. * gcc.dg/pr93573-2.c: New test.
2020-03-23c: Fix up cfun->function_end_locus on invalid function bodies [PR94239]Jakub Jelinek2-4/+11
Unfortunately the patch broke +FAIL: gcc.dg/pr20245-1.c (internal compiler error) +FAIL: gcc.dg/pr20245-1.c (test for excess errors) +FAIL: gcc.dg/pr28419.c (internal compiler error) +FAIL: gcc.dg/pr28419.c (test for excess errors) on some targets (and under valgrind on the rest of them). Those functions don't have the opening { and so c_parser_compound_statement returned error_mark_node before initializing *endlocp. So, either we can initialize it in that case too: --- gcc/c/c-parser.c 2020-03-20 22:09:39.659411721 +0100 +++ gcc/c/c-parser.c 2020-03-21 09:36:44.455705261 +0100 @@ -5611,6 +5611,8 @@ c_parser_compound_statement (c_parser *p if we have just prepared to enter a function body. */ stmt = c_begin_compound_stmt (true); c_end_compound_stmt (brace_loc, stmt, true); + if (endlocp) + *endlocp = brace_loc; return error_mark_node; } stmt = c_begin_compound_stmt (true); or perhaps simpler initialize it to the function_start_locus at the beginning and have those functions without { have function_start_locus == function_end_locus like the __GIMPLE functions (where propagating the closing } seemed too difficult). 2020-03-23 Jakub Jelinek <jakub@redhat.com> PR gcov-profile/94029 PR c/94239 * c-parser.c (c_parser_declaration_or_fndef): Initialize endloc to the function_start_locus location. Don't do that afterwards for the __GIMPLE body parsing.
2020-03-19c: Fix up cfun->function_end_locus from the C FE [PR94029]Jakub Jelinek4-24/+47
On the following testcase we ICE because while DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus = c_parser_peek_token (parser)->location; and similarly DECL_SOURCE_LOCATION (fndecl) is set from some token's location, the end is set as: /* Store the end of the function, so that we get good line number info for the epilogue. */ cfun->function_end_locus = input_location; and the thing is that input_location is only very rarely set in the C FE (the primary spot that changes it is the cb_line_change/fe_file_change). Which means, e.g. for pretty much all C functions that are on a single line, function_start_locus column is > than function_end_locus column, and the testcase even has smaller line in function_end_locus because cb_line_change isn't performed while parsing multi-line arguments of a function-like macro. Attached are two possible fixes to achieve what the C++ FE does, in particular that cfun->function_end_locus is the locus of the closing } of the function. The first one updates input_location when we see a closing } of a compound statement (though any, not just the function body) and thus input_location in the finish_function call is what we need. The second instead propagates the location_t from the parsing of the outermost compound statement (the function body) to finish_function. The second one is this version. 2020-03-19 Jakub Jelinek <jakub@redhat.com> PR gcov-profile/94029 * c-tree.h (finish_function): Add location_t argument defaulted to input_location. * c-parser.c (c_parser_compound_statement): Add endlocp argument and set it to the locus of closing } if non-NULL. (c_parser_compound_statement_nostart): Return locus of closing }. (c_parser_parse_rtl_body): Likewise. (c_parser_declaration_or_fndef): Propagate locus of closing } to finish_function. * c-decl.c (finish_function): Add end_loc argument, use it instead of input_location to set function_end_locus. * gcc.misc-tests/gcov-pr94029.c: New test.
2020-03-17c: Handle C_TYPE_INCOMPLETE_VARS even for ENUMERAL_TYPEs [PR94172]Jakub Jelinek4-28/+54
The following testcases ICE, because they contain extern variable declarations with incomplete enum types that is later completed and after that those variables are accessed. The ICEs are because the vars then may have incorrect DECL_MODE etc., e.g. in the first case the var has SImode DECL_MODE (the guessed mode for the enum), but the enum then actually has DImode because its enumerators don't fit into unsigned int. The following patch fixes it by using C_TYPE_INCOMPLETE_VARS not just on incomplete struct/union types, but also incomplete enum types. TYPE_VFIELD can't be used as it is TYPE_MIN_VALUE on ENUMERAL_TYPE, thankfully TYPE_LANG_SLOT_1 has been used in the C FE only on FUNCTION_TYPEs. 2020-03-17 Jakub Jelinek <jakub@redhat.com> PR c/94172 * c-tree.h (C_TYPE_INCOMPLETE_VARS): Define to TYPE_LANG_SLOT_1 instead of TYPE_VFIELD, and support it on {RECORD,UNION,ENUMERAL}_TYPE. (TYPE_ACTUAL_ARG_TYPES): Check that it is only used on FUNCTION_TYPEs. * c-decl.c (pushdecl): Push C_TYPE_INCOMPLETE_VARS also to ENUMERAL_TYPEs. (finish_incomplete_vars): New function, moved from finish_struct. Use relayout_decl instead of layout_decl. (finish_struct): Remove obsolete comment about C_TYPE_INCOMPLETE_VARS being TYPE_VFIELD. Use finish_incomplete_vars. (finish_enum): Clear C_TYPE_INCOMPLETE_VARS. Call finish_incomplete_vars. * c-typeck.c (c_build_qualified_type): Clear C_TYPE_INCOMPLETE_VARS also on ENUMERAL_TYPEs. * gcc.dg/pr94172-1.c: New test. * gcc.dg/pr94172-2.c: New test.
2020-03-17c: ignore initializers for elements of variable-size types [PR93577]Christophe Lyon1-1/+1
2020-03-17 Christophe Lyon <christophe.lyon@linaro.org> gcc/ * c-typeck.c (process_init_element): Handle constructor_type with type size represented by POLY_INT_CST. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general-c/sizeless-1.c: Remove superfluous dg-error. * gcc.target/aarch64/sve/acle/general-c/sizeless-2.c: Likewise.
2020-03-16c: Handle MEM_REF in c_fully_fold* [PR94179]Jakub Jelinek2-0/+14
The recent match.pd changes can generate a MEM_REF which can be seen by the C FE folding routines. Unlike the C++ FE, they weren't expected in the C FE yet. MEM_REF should be handled like INDIRECT_REF, except that it has two operands rather than just one and that we should preserve the type of the second operand. Given that it already has to be an INTEGER_CST with pointer type, I think we are fine, the recursive call should return the INTEGER_CST unmodified and STRIP_TYPE_NOPS will not strip anything. 2020-03-16 Jakub Jelinek <jakub@redhat.com> PR c/94179 * c-fold.c (c_fully_fold_internal): Handle MEM_REF. * gcc.c-torture/compile/pr94179.c: New test.