aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
AgeCommit message (Collapse)AuthorFilesLines
31 hoursDaily bump.GCC Administrator1-0/+14
35 hoursExtend "counted_by" attribute to pointer fields of structures. Convert a ↵Qing Zhao2-58/+93
pointer reference with counted_by attribute to .ACCESS_WITH_SIZE. For example: struct PP { size_t count2; char other1; char *array2 __attribute__ ((counted_by (count2))); int other2; } *pp; specifies that the "array2" is an array that is pointed by the pointer field, and its number of elements is given by the field "count2" in the same structure. gcc/c-family/ChangeLog: * c-attribs.cc (handle_counted_by_attribute): Accept counted_by attribute for pointer fields. gcc/c/ChangeLog: * c-decl.cc (verify_counted_by_attribute): Change the 2nd argument to a vector of fields with counted_by attribute. Verify all fields in this vector. (finish_struct): Collect all the fields with counted_by attribute to a vector and pass this vector to verify_counted_by_attribute. * c-typeck.cc (build_counted_by_ref): Handle pointers with counted_by. Add one more argument, issue error when the pointee type is a structure or union including a flexible array member. (build_access_with_size_for_counted_by): Handle pointers with counted_by. (handle_counted_by_for_component_ref): Call build_counted_by_ref with the new prototype. gcc/ChangeLog: * doc/extend.texi: Extend counted_by attribute to pointer fields in structures. Add one more requirement to pointers with counted_by attribute. gcc/testsuite/ChangeLog: * gcc.dg/flex-array-counted-by.c: Update test. * gcc.dg/pointer-counted-by-1.c: New test. * gcc.dg/pointer-counted-by-2.c: New test. * gcc.dg/pointer-counted-by-3.c: New test. * gcc.dg/pointer-counted-by.c: New test.
9 daysDaily bump.GCC Administrator1-0/+4
9 daysOpenACC: Add 'if' clause to 'acc wait' directiveTobias Burnus1-1/+2
OpenACC 3.0 added the 'if' clause to four directives; this patch only adds it to 'acc wait'. gcc/c-family/ChangeLog: * c-omp.cc (c_finish_oacc_wait): Handle if clause. gcc/c/ChangeLog: * c-parser.cc (OACC_WAIT_CLAUSE_MASK): Add if clause. gcc/cp/ChangeLog: * parser.cc (OACC_WAIT_CLAUSE_MASK): Ass if clause. gcc/fortran/ChangeLog: * openmp.cc (OACC_WAIT_CLAUSES): Add if clause. * trans-openmp.cc (gfc_trans_oacc_wait_directive): Handle it. gcc/testsuite/ChangeLog: * c-c++-common/goacc/acc-wait-1.c: New test. * gfortran.dg/goacc/acc-wait-1.f90: New test.
2025-06-12Daily bump.GCC Administrator1-0/+31
2025-06-12c, c++: Save 8 bytes of memory in lang_type for non-ObjC*Jakub Jelinek2-11/+23
For C++26 P2786R13 I'm afraid I'll need 4-6 new flags on class types in struct lang_type (1 bit for trivially_relocatable_if_eligible, 1 for replaceable_if_eligible, 1 for not_trivially_relocatable and 1 for not_replaceable and perhaps 2 bits whether the last 2 have been computed already) and there are just 2 bits left. The following patch is an attempt to save 8 bytes of memory in those structures when not compiling ObjC or ObjC++ (I think those are used fairly rarely and the patch keeps the sizes unmodified for those 2). The old allocations were 32 bytes for C and 120 bytes for C++. The patch moves the objc_info member last in the C++ case (it was already last in the C case), arranges for GC to skip it for C and C++ but walk for ObjC and ObjC++ and allocates or copies over just offsetof bytes instead of sizeof. 2025-06-12 Jakub Jelinek <jakub@redhat.com> gcc/c/ * c-lang.h (union lang_type::maybe_objc_info): New type. (struct lang_type): Use union maybe_objc_info info member instead of tree objc_info. * c-decl.cc (finish_struct): Allocate struct lang_type using ggc_internal_cleared_alloc instead of ggc_cleared_alloc, and use sizeof (struct lang_type) for ObjC and otherwise offsetof (struct lang_type, info) as size. (finish_enum): Likewise. gcc/cp/ * cp-tree.h (union lang_type::maybe_objc_info): New type. (struct lang_type): Use union maybe_objc_info info member instead of tree objc_info. * lex.cc (copy_lang_type): Use sizeof (struct lang_type) just for ObjC++ and otherwise offsetof (struct lang_type, info). (maybe_add_lang_type_raw): Likewise. (cxx_make_type): Formatting fix. gcc/objc/ * objc-act.h (TYPE_OBJC_INFO): Define to info.objc_info instead of objc_info. gcc/objcp/ * objcp-decl.h (TYPE_OBJC_INFO): Define to info.objc_info instead of objc_info.
2025-06-11c: remaining fix for the composite type inconsistency [PR120510]Martin Uecker1-9/+42
There is an old GNU extension which allows overriding the promoted old-style arguments when there is an earlier prototype An example (from a test added for PR16666) is the following. float dremf (float, float); float dremf (x, y) float x, y; { return x + y; } The types of the two declarations are not compatible, because the arguments are not self-promoting. Add a special case to function_types_compatible_p that can be toggled via a flag for comptypes_internal and add a helper function to be able to add the checking assertions to composite_type. PR c/120510 gcc/c/ChangeLog: * c-typeck.cc (composite_type_internal): Activate checking assertions for all types and also inputs. (comptypes_for_composite_check): New helper function. (function_types_compatible_p): Add exception. gcc/testsuite/ChangeLog: * gcc.dg/old-style-prom-4.c: New test.
2025-06-11c: clean up some functions in c-typeck.ccMartin Uecker1-39/+24
This removes two unnecessary variables and replaces 1/0 with true/false for two functions with boolean return type. gcc/c/ChangeLog: * c-typeck.cc (function_types_compatible_p): Remove unused variables and return true/false instead of 1/0. (type_lists_compatible_p): Return false instead of 0.
2025-06-11c: fix ICE for invalid code in generic selection [PR120303]Martin Uecker1-1/+7
Fix an error recovery ICE that occurs when a typename can not be parsed correctly in the controlling expression of a generic selection. PR c/120303 gcc/c/ChangeLog: * c-parser.cc (c_parser_generic_selection): Handle error condition. gcc/testsuite/ChangeLog: * gcc.dg/pr120303.c: New test.
2025-06-10Daily bump.GCC Administrator1-0/+24
2025-06-10c: Add remove_qualifier helper function [PR120510]Martin Uecker1-71/+28
Add a helper function to replace repeated code for removing qualifiers but not atomic. Make sure to also remove qualifiers but not atomic from the element type of arrays. PR c/120510 gcc/c/ChangeLog: * c-typeck.cc (remove_qualifiers): New function. (composite_type_internal): Use it. (comp_target_types): Use it. (type_lists_compatible_p): Use it. (find_anonymous_field_with_type): Use it. (convert_to_anonymous_field): Use it. (convert_for_assignment): Use it.
2025-06-10c: partial fix for qualifier inconsistency II [PR120510]Martin Uecker1-14/+7
This fixes a case where we invoke composite_type with types that do not have matching qualifiers. With this change, we can activate the checking assertion that makes sure the composite type is compatible with the two original types also for arrays. PR c/120510 gcc/c/ChangeLog: * c-typeck.cc (composite_type_internal): Activate checking assertion for arrays. (common_pointer_type): Remove qualifiers also from arrays.
2025-06-10c: partial fix for qualifier inconsistency [PR120510]Martin Uecker1-6/+8
Checking assertions revealed that we sometimes produce composite types with incorrect qualifiers, e.g. the example int f(int [_Atomic]); int f(int [_Atomic]); int f(int [_Atomic]); was rejected because atomic was lost in the second declaration. PR c/120510 gcc/c/ChangeLog: * c-typeck.cc (composite_types_internal): Handle arrays declared with atomic for function arguments. gcc/testsuite/ChangeLog: * gcc.dg/pr120510.c
2025-06-04Daily bump.GCC Administrator1-0/+10
2025-06-03c: Move checking assertions from recursion when forming composite types to ↵Martin Uecker1-7/+10
avoid ICE. The checking assertion in composite_type_internal for structures and unions may fail if there are self-referential types. To avoid this, we move them out of the recursion. This should also be more efficient and covers other types. We have to ignore some cases where we form composite types with qualifiers not matching (PR120510). gcc/c/ChangeLog: * c-typeck.cc (composite_type_internal,composite_type): Move checking assertions. gcc/testsuite/ChangeLog: * gcc.dg/gnu23-tag-composite-6.c: Update.
2025-06-03c: fix ICE with enum completed with packed attribute after forward decl ↵Martin Uecker1-0/+1
[PR116892] After forward declaration of an enum and when completing it with the attribute packed, we need to propagate TYPE_PACKED to all main variants. PR c/116892 gcc/c/ChangeLog: * c-decl.cc (finish_enum): Propagate TYPE_PACKED. gcc/testsuite/ChangeLog: * gcc.dg/pr116892.c: New test.
2025-06-03Daily bump.GCC Administrator1-0/+6
2025-06-02OpenMP: Handle more cases in user/condition selectorSandra Loosemore1-3/+16
Tobias had noted that the C front end was not treating C23 constexprs as constant in the user/condition selector property, which led to missed opportunities to resolve metadirectives at parse time. Additionally neither C nor C++ was permitting the expression to have pointer or floating-point type -- the former being a common idiom in other C/C++ conditional expressions. By using the existing front-end hooks for the implicit conversion to bool in conditional expressions, we also get free support for using a C++ class object that has a bool conversion operator in the user/condition selector. gcc/c/ChangeLog * c-parser.cc (c_parser_omp_context_selector): Call convert_lvalue_to_rvalue and c_objc_common_truthvalue_conversion on the expression for OMP_TRAIT_PROPERTY_BOOL_EXPR. gcc/cp/ChangeLog * cp-tree.h (maybe_convert_cond): Declare. * parser.cc (cp_parser_omp_context_selector): Call maybe_convert_cond and fold_build_cleanup_point_expr on the expression for OMP_TRAIT_PROPERTY_BOOL_EXPR. * pt.cc (tsubst_omp_context_selector): Likewise. * semantics.cc (maybe_convert_cond): Remove static declaration. gcc/testsuite/ChangeLog * c-c++-common/gomp/declare-variant-2.c: Update expected output. * c-c++-common/gomp/metadirective-condition-constexpr.c: New. * c-c++-common/gomp/metadirective-condition.c: New. * c-c++-common/gomp/metadirective-error-recovery.c: Update expected output. * g++.dg/gomp/metadirective-condition-class.C: New. * g++.dg/gomp/metadirective-condition-template.C: New.
2025-06-02Daily bump.GCC Administrator1-0/+5
2025-06-01c: fix ICE related to tagged types with attributes in diagnostics [PR120380]Martin Uecker1-0/+5
get_aka_type will create a new type for diagnostics, but for tagged types attributes will then be ignored with a warning. This can lead to reentering warning code which leads to an ICE. Fix this by ignoring the attributes for tagged types. PR c/120380 gcc/c/ChangeLog: * c-objc-common.cc (get_aka_type): Ignore attributes for tagged types. gcc/testsuite/ChangeLog: * gcc.dg/pr120380.c: New test.
2025-05-31Daily bump.GCC Administrator1-0/+42
2025-05-30C: Flex array in union followed by a structure field is not reported [PR120354]Qing Zhao1-3/+6
There is only one last_field for a structure type, but there might be multiple last_fields for a union type, therefore we should ORed the result of TYPE_INCLUDES_FLEXARRAY for multiple last_fields of a union type. PR c/120354 gcc/c/ChangeLog: * c-decl.cc (finish_struct): Or the results for TYPE_INCLUDES_FLEXARRAY. gcc/testsuite/ChangeLog: * gcc.dg/pr120354.c: New test.
2025-05-30C: Flex array in the middle via type alias is not reported [PR120353]Qing Zhao1-0/+1
The root cause of the bug is: the TYPE_INCLUDES_FLEXARRAY marking of the structure type is not copied to its aliased type. The fix is to copy this marking to all the variant types of the current structure type. PR c/120353 gcc/c/ChangeLog: * c-decl.cc (finish_struct): Copy TYPE_INCLUDES_FLEXARRAY marking to all the variant types of the current structure type. gcc/testsuite/ChangeLog: * gcc.dg/pr120353.c: New test.
2025-05-30OpenMP: Support OpenMP 5.0 "declare mapper" directives for CJulian Brown5-19/+474
This patch adds support for "declare mapper" directives (and the "mapper" modifier on "map" clauses) for C. gcc/c/ChangeLog: * c-decl.cc (c_omp_mapper_id, c_omp_mapper_decl, c_omp_mapper_lookup, c_omp_extract_mapper_directive, c_omp_map_array_section, c_omp_scan_mapper_bindings_r, c_omp_scan_mapper_bindings): New functions. * c-objc-common.h (LANG_HOOKS_OMP_FINISH_MAPPER_CLAUSES, LANG_HOOKS_OMP_MAPPER_LOOKUP, LANG_HOOKS_OMP_EXTRACT_MAPPER_DIRECTIVE, LANG_HOOKS_OMP_MAP_ARRAY_SECTION): Define langhooks for C. * c-parser.cc (c_parser_omp_clause_map): Add declare_mapper_p parameter; handle mapper modifier. (c_parser_omp_all_clauses): Update call to c_parser_omp_clause_map. (c_parser_omp_target): Instantiate explicit mappers and record bindings for implicit mappers. (c_parser_omp_declare_mapper): Parse "declare mapper" directives. (c_parser_omp_declare): Support "declare mapper". (c_parser_omp_declare_reduction): Use inform not error_at. * c-tree.h (c_omp_finish_mapper_clauses, c_omp_mapper_lookup, c_omp_extract_mapper_directive, c_omp_map_array_section, c_omp_mapper_id, c_omp_mapper_decl, c_omp_scan_mapper_bindings, c_omp_instantiate_mappers): Add prototypes. * c-typeck.cc (c_finish_omp_clauses): Handle GOMP_MAP_PUSH_MAPPER_NAME and GOMP_MAP_POP_MAPPER_NAME. (c_omp_finish_mapper_clauses): New function (langhook). libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/declare-mapper-9.c: Enable for C. * testsuite/libgomp.c-c++-common/declare-mapper-10.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-11.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-12.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-13.c: Likewise. * testsuite/libgomp.c-c++-common/declare-mapper-14.c: Likewise. gcc/testsuite/ChangeLog: * c-c++-common/gomp/declare-mapper-3.c: Enable for C. * c-c++-common/gomp/declare-mapper-4.c: Likewise. * c-c++-common/gomp/declare-mapper-5.c: Likewise. * c-c++-common/gomp/declare-mapper-6.c: Likewise. * c-c++-common/gomp/declare-mapper-7.c: Likewise. * c-c++-common/gomp/declare-mapper-8.c: Likewise. * c-c++-common/gomp/declare-mapper-9.c: Likewise. * c-c++-common/gomp/declare-mapper-10.c: Likewise. * c-c++-common/gomp/declare-mapper-12.c: Likewise. * c-c++-common/gomp/map-6.c: Update dg-error. * gcc.dg/gomp/udr-3.c: Update for change to dg-note. * c-c++-common/gomp/declare-mapper-11.c: New. * gcc.dg/gomp/declare-mapper-10.c: New test. * gcc.dg/gomp/declare-mapper-11.c: New test. * gcc.dg/gomp/declare-mapper-13.c: New test.
2025-05-30c: fix ICE for mutually recursive structures [PR120381]Martin Uecker1-1/+1
For invalid nesting of a structure definition in a definition of itself or when using a rather obscure construction using statement expressions, we can create mutually recursive pairs of non-identical but compatible structure types. This can lead to invalid composite types and an ICE. If we detect recursion even for swapped pairs when forming composite types, this is avoided. PR c/120381 gcc/c/ChangeLog: * c-typeck.cc (composite_type_internal): Stop recursion for swapped pairs. gcc/testsuite/ChangeLog: * gcc.dg/pr120381.c: New test. * gcc.dg/gnu23-tag-composite-6.c: New test.
2025-05-30Daily bump.GCC Administrator1-0/+20
2025-05-29OpenMP: Fix ICE and other issues in C/C++ metadirective error recovery.Sandra Loosemore1-20/+62
The new testcase included in this patch used to ICE in gcc after diagnosing the first error, and in g++ it only diagnosed the error in the first metadirective, ignoring the second one. The solution is to make error recovery in the C front end more like that in the C++ front end, and remove the code in both front ends that previously tried to skip all the way over the following statement (instead of just to the end of the metadirective pragma) after an error. gcc/c/ChangeLog * c-parser.cc (c_parser_skip_to_closing_brace): New, copied from the equivalent function in the C++ front end. (c_parser_skip_to_end_of_block_or_statement): Pass false to the error flag. (c_parser_omp_context_selector): Immediately return error_mark_node after giving an error that the integer trait property is invalid, similarly to C++ front end. (c_parser_omp_context_selector_specification): Likewise handle error return from c_parser_omp_context_selector similarly to C++. (c_parser_omp_metadirective): Do not call c_parser_skip_to_end_of_block_or_statement after an error. gcc/cp/ChangeLog * parser.cc (cp_parser_omp_metadirective): Do not call cp_parser_skip_to_end_of_block_or_statement after an error. gcc/testsuite/ChangeLog * c-c++-common/gomp/declare-variant-2.c: Adjust patterns now that C and C++ now behave similarly. * c-c++-common/gomp/metadirective-error-recovery.c: New.
2025-05-29OpenMP: Fix ICE in metadirective recovery after error [PR120180]Sandra Loosemore1-3/+4
It's not clear whether a metadirective in a loop nest is supposed to be valid, but GCC certainly shouldn't be ICE'ing after diagnosing it as an error. gcc/c/ChangeLog PR c/120180 * c-parser.cc (c_parser_omp_metadirective): Only consume the token if it is the expected close paren. gcc/cp/ChangeLog PR c/120180 * parser.cc (cp_parser_omp_metadirective): Only consume the token if it is the expected close paren. gcc/testsuite/ChangeLog PR c/120180 * c-c++-common/gomp/pr120180.c: New.
2025-05-28Daily bump.GCC Administrator1-0/+34
2025-05-27c: Fix up a pasto in countof diagnostics [PR117025]Jakub Jelinek1-1/+1
The C23 in there looks like pasto, should be C2Y. 2025-05-27 Jakub Jelinek <jakub@redhat.com> PR c/117025 * c-parser.cc (c_parser_sizeof_or_countof_expression): Use C2Y rather than C23 in pedwarn_c23.
2025-05-27c: Add -Wpedantic diagnostic for _Countof [PR117025]Alejandro Colomar1-0/+4
It has been standardized in C2y. PR c/117025 gcc/c/ChangeLog: * c-parser.cc (c_parser_sizeof_or_countof_expression): Add -Wpedantic diagnostic for _Countof in <= C23 mode. gcc/testsuite/ChangeLog: * gcc.dg/countof-compat.c: New test. * gcc.dg/countof-no-compat.c: New test. * gcc.dg/countof-pedantic.c: New test. * gcc.dg/countof-pedantic-errors.c: New test. Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-05-27c: Add _Countof operator [PR117025]Alejandro Colomar4-29/+187
This operator is similar to sizeof but can only be applied to an array, and returns its number of elements. FUTURE DIRECTIONS: - We should make it work with array parameters to functions, and somehow magically return the number of elements of the array, regardless of it being really a pointer. Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3550.pdf> Link: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117025> Link: <https://inbox.sourceware.org/gcc/M8S4oQy--3-2@tutanota.com/T/> Link: <https://inbox.sourceware.org/gcc-patches/20240728141547.302478-1-alx@kernel.org/T/#t> Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3313.pdf> Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3325.pdf> Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3369.pdf> Link: <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3469.htm> Link: <https://github.com/llvm/llvm-project/issues/102836> Link: <https://thephd.dev/the-big-array-size-survey-for-c> Link: <https://thephd.dev/the-big-array-size-survey-for-c-results> Link: <https://stackoverflow.com/questions/37538/#57537491> PR c/117025 gcc/ChangeLog: * doc/extend.texi: Document _Countof operator. gcc/c-family/ChangeLog: * c-common.h (enum rid): Add RID_COUNTOF. (c_countof_type): New function prototype. * c-common.def (COUNTOF_EXPR): New tree. * c-common.cc (c_common_reswords): Add RID_COUNTOF entry. (c_countof_type): New function. gcc/c/ChangeLog: * c-tree.h (in_countof): Add global variable declaration. (c_expr_countof_expr): Add function prototype. (c_expr_countof_type): Add function prototype. * c-decl.cc (start_struct, finish_struct): Add support for _Countof. (start_enum, finish_enum): Add support for _Countof. * c-parser.cc (c_parser_sizeof_expression): New macro. (c_parser_countof_expression): New macro. (c_parser_sizeof_or_countof_expression): Rename function and add support for _Countof. (c_parser_unary_expression): Add RID_COUNTOF entry. * c-typeck.cc (in_countof): Add global variable. (build_external_ref): Add support for _Countof. (record_maybe_used_decl): Add support for _Countof. (pop_maybe_used): Add support for _Countof. (is_top_array_vla): New function. (c_expr_countof_expr, c_expr_countof_type): New functions. gcc/testsuite/ChangeLog: * gcc.dg/countof-compile.c: New test. * gcc.dg/countof-vla.c: New test. * gcc.dg/countof-vmt.c: New test. * gcc.dg/countof-zero-compile.c: New test. * gcc.dg/countof-zero.c: New test. * gcc.dg/countof.c: New test. Suggested-by: Xavier Del Campo Romero <xavi.dcr@tutanota.com> Co-authored-by: Martin Uecker <uecker@tugraz.at> Acked-by: "James K. Lowden" <jklowden@schemamania.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
2025-05-03Daily bump.GCC Administrator1-0/+11
2025-05-02c: Fix up RAW_DATA_CST handling in check_constexpr_init [PR120057]Jakub Jelinek1-2/+18
The pr120057-1.c testcase is incorrectly rejected since r15-4377 (and for a while it also ICEd after the error), i.e. the optimization of large C initializers using RAW_DATA_CST. Similarly, the embed-18.c testcase is incorrectly rejected since the embed support has been introduced and RAW_DATA_CST used for that. The callers of check_constexpr_init (store_init_value and output_init_element) compute int_const_expr as int_const_expr = (TREE_CODE (init) == INTEGER_CST && !TREE_OVERFLOW (init) && INTEGRAL_TYPE_P (TREE_TYPE (init))); but that is only passed through down to check_constexpr_init. I think tweaking those 2 callers to also allow RAW_DATA_CST for int_const_expr when check_constexpr_init needs top special case it no matter what would be larger, so the patch just changes check_constexpr_init to deal with RAW_DATA_CST in the initializers. For TYPE_UNSIGNED char precision integral types RAW_DATA_CST is always valid, for !TYPE_UNSIGNED we need to check for 128-255 values being turned into negative ones. 2025-05-02 Jakub Jelinek <jakub@redhat.com> PR c/120057 * c-typeck.cc (check_constexpr_init): Handle RAW_DATA_CST. * gcc.dg/cpp/embed-18.c: New test. * gcc.dg/pr120057-1.c: New test. * gcc.dg/pr120057-2.c: New test.
2025-05-02c: Fix crash in c-typeck.cc convert_arguments with indirect callsFlorian Weimer1-1/+1
gcc/c/ PR c/120055 * c-typeck.cc (convert_arguments): Check if fundecl is null before checking for builtin function declaration. gcc/testsuite/ * gcc.dg/Wdeprecated-non-prototype-6.c: New test.
2025-05-02Daily bump.GCC Administrator1-0/+14
2025-05-01Fix BZ 119317: named loops (C2y) with debug infoChristopher Bazley1-1/+2
Named loops (C2y) could not previously be compiled with -O1 and -ggdb2 or higher because the label preceding a loop (or switch) could not be found when using such command lines. This could be observed by compiling gcc/gcc/testsuite/gcc.dg/c2y-named-loops-1.c with the provoking command line (or any minimal example such as that cited in the bug report). The fix was simply to ignore the tree nodes inserted for debugging information. Base commit is 79aa2a283a8d3327ff4d6dca77e81d5b1ac3a01e PR c/119317 gcc/c/ChangeLog: * c-decl.cc (c_get_loop_names): Do not prematurely end the search for a label that names a loop or switch statement upon encountering a DEBUG_BEGIN_STMT. Instead, ignore any instances of DEBUG_BEGIN_STMT. gcc/testsuite/ChangeLog: * gcc.dg/c2y-named-loops-8.c: New test.
2025-05-01c: Suppress -Wdeprecated-non-prototype warnings for builtinsFlorian Weimer1-1/+2
Builtins defined with BT_FN_INT_VAR etc. show as functions without a prototype and trigger the warning. gcc/c/ PR c/119950 * c-typeck.cc (convert_arguments): Check for built-in function declaration before warning. gcc/testsuite/ * gcc.dg/Wdeprecated-non-prototype-5.c: New test.
2025-04-29Daily bump.GCC Administrator1-0/+28
2025-04-28Eliminate make-unique.h and ::make_uniqueDavid Malcolm3-13/+11
C++11 does not provide a std::make_unique so in r13-3627-g00d7c8ff16e683 I added a make-unique.h declaring a ::make_unique. As of r15-4719-ga9ec1bc06bd3cc we can use C++14, so make-unique.h is no longer needed: we can use simply use std::make_unique instead. This patch removes make-unique.h and updates every place using it to use std::make_unique. No functional change intended. gcc/analyzer/ChangeLog: * access-diagram.cc: Replace uses of ::make_unique with std::make_unique. * analyzer.cc: Likewise. * bounds-checking.cc: Likewise. * call-details.cc: Likewise. * call-info.cc: Likewise. * call-string.cc: Likewise. * checker-path.cc: Likewise. * common.h: Drop include of "make-unique.h". * constraint-manager.cc: Replace uses of ::make_unique with std::make_unique. * diagnostic-manager.cc: Likewise. * engine.cc: Likewise. * infinite-loop.cc: Likewise. * infinite-recursion.cc: Likewise. * kf-analyzer.cc: Likewise. * kf-lang-cp.cc: Likewise. * kf.cc: Likewise. * pending-diagnostic.cc: Likewise. * program-point.cc: Likewise; drop #include. * program-state.cc: Likewise. * ranges.cc: Likewise. * region-model.cc: Likewise. * region.cc: Likewise; drop #include. * sm-fd.cc: Likewise. * sm-file.cc: Likewise. * sm-malloc.cc: Likewise. * sm-pattern-test.cc: Likewise. * sm-sensitive.cc: Likewise. * sm-signal.cc: Likewise. * sm-taint.cc: Likewise. * sm.cc: Likewise. * store.cc: Likewise. * supergraph.cc: Likewise. * svalue.cc: Likewise; drop #include. * varargs.cc: Likewise. gcc/c-family/ChangeLog: * c-pretty-print.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. gcc/c/ChangeLog: * c-decl.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * c-objc-common.cc: Likewise. * c-parser.cc: Likewise. gcc/cp/ChangeLog: * cxx-pretty-print.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * error.cc: Likewise. * name-lookup.cc: Likewise. * parser.cc: Likewise. gcc/ChangeLog: * diagnostic-format-json.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * diagnostic-format-sarif.cc: Likewise. * diagnostic-format-text.cc: Likewise. * diagnostic.cc: Likewise. * dumpfile.cc: Likewise. * gcc-attribute-urlifier.cc: Likewise. * gcc-urlifier.cc: Likewise. * json-parsing.cc: Likewise. * json.cc: Likewise. * lazy-diagnostic-path.cc: Likewise. * libgdiagnostics.cc: Likewise. * libsarifreplay.cc: Likewise. * lto-wrapper.cc: Likewise. * make-unique.h: Delete. * opts-diagnostic.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * pretty-print.cc: Likewise. * text-art/style.cc: Likewise. * text-art/styled-string.cc: Likewise. * text-art/table.cc: Likewise. * text-art/tree-widget.cc: Likewise. * text-art/widget.cc: Likewise. * timevar.cc: Likewise. * toplev.cc: Likewise. * tree-diagnostic-client-data-hooks.cc: Likewise. gcc/jit/ChangeLog: * dummy-frontend.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. gcc/testsuite/ChangeLog: * gcc.dg/plugin/analyzer_cpython_plugin.cc: Drop include of "make-unique.h". Replace uses of ::make_unique with std::make_unique. * gcc.dg/plugin/analyzer_gil_plugin.cc: Likewise. * gcc.dg/plugin/analyzer_kernel_plugin.cc: Likewise. * gcc.dg/plugin/analyzer_known_fns_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_group_plugin.cc: Likewise. * gcc.dg/plugin/diagnostic_plugin_xhtml_format.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-04-28c,c++: use unique_ptr in name_hint to reduce naked 'new'David Malcolm2-11/+16
gcc/c-family/ChangeLog: * name-hint.h (name_hint::name_hint): Use std::unique_ptr for param. gcc/c/ChangeLog: * c-decl.cc: Include "make-unique.h". (lookup_name_fuzzy): Use ::make_unique rather than "new" when making suggest_missing_header and suggest_missing_option. * c-parser.cc: Include "make-unique.h" (c_parser_error_richloc): Use ::make_unique rather than "new" when making suggest_missing_header. gcc/cp/ChangeLog: * name-lookup.cc: Include "make-unique.h". (namespace_hints::convert_candidates_to_name_hint): Use ::make_unique rather than "new" when making show_candidate_location and suggest_alternatives. (namespace_hints::maybe_decorate_with_limit): Likewise when making namespace_limit_reached. (suggest_alternatives_for_1): Likewise when making suggest_missing_option. (maybe_suggest_missing_std_header): Likewise when making missing_std_header. (macro_use_before_def::maybe_make): Use std::unique_ptr. (macro_use_before_def::macro_use_before_def): Make public. (lookup_name_fuzzy): Use ::make_unique rather than "new" when making suggest_missing_header. * parser.cc: Include "make-unique.h". (cp_parser_error_1): Use ::make_unique rather than "new" when making suggest_missing_header. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2025-04-28gimplefe: Round trip of rotates [PR119432]Andrew Pinski1-0/+2
This adds support for rotate left/right to the GIMPLE front-end via __ROTATE_LEFT/__ROTATE_RIGHT oeprators. PR c/119432 gcc/c/ChangeLog: * gimple-parser.cc (gimple_binary_identifier_code): Add __ROTATE_LEFT and __ROTATE_RIGHT. gcc/ChangeLog: * tree-pretty-print.cc (op_symbol_code): For LROTATE_EXPR, output __ROTATE_LEFT for gimple. For RROTATE_EXPR output __ROTATE_RIGHT for gimple. gcc/testsuite/ChangeLog: * gcc.dg/gimplefe-57.c: New test. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-28gimplefe: Simplify handling of identifier based binary operationsAndrew Pinski1-78/+29
While looking into adding __ROTATE_LEFT and __ROTATE_RIGHT, I noticed this code is just a bunch of if statments repeated. Instead we could just use a simple lookup array to do the same thinga and it would be easier to add to the array instead of duplicating the if sequence again. Bootstrapped and tested on x86_64-linux-gnu. gcc/c/ChangeLog: * gimple-parser.cc (gimple_binary_identifier_code): New variable. (c_parser_gimple_binary_expression): Use gimple_binary_identifier_code instead of doing if statements on the strings. Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-04-28Daily bump.GCC Administrator1-0/+12
2025-04-27Drop targetm.promote_prototypes from C, C++ and Ada frontendsH.J. Lu2-55/+4
Remove the targetm.calls.promote_prototypes call from C, C++ and Ada frontends. gcc/ PR c/48274 PR middle-end/112877 PR middle-end/118288 * gimple.cc (gimple_builtin_call_types_compatible_p): Remove the targetm.calls.promote_prototypes call. * tree.cc (tree_builtin_call_types_compatible_p): Likewise. gcc/ada/ PR middle-end/112877 * gcc-interface/utils.cc (create_param_decl): Remove the targetm.calls.promote_prototypes call. gcc/c/ PR c/48274 PR middle-end/112877 PR middle-end/118288 * c-decl.cc (start_decl): Remove the targetm.calls.promote_prototypes call. (store_parm_decls_oldstyle): Likewise. (finish_function): Likewise. * c-typeck.cc (convert_argument): Likewise. (c_safe_arg_type_equiv_p): Likewise. gcc/cp/ PR middle-end/112877 * call.cc (type_passed_as): Remove the targetm.calls.promote_prototypes call. (convert_for_arg_passing): Likewise. * typeck.cc (cxx_safe_arg_type_equiv_p): Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-04-16Daily bump.GCC Administrator1-0/+6
2025-04-15c: Fully fold each parameter for call to .ACCESS_WITH_SIZE [PR119717]Qing Zhao1-2/+6
C_MAYBE_CONST_EXPR is a C FE operator that will be removed by c_fully_fold. In c_fully_fold, it assumes that operands of function calls have already been folded. However, when we build call to .ACCESS_WITH_SIZE, all its operands are not fully folded. therefore the C FE specific operator is passed to middle-end. In order to fix this issue, fully fold the parameters before building the call to .ACCESS_WITH_SIZE. PR c/119717 gcc/c/ChangeLog: * c-typeck.cc (build_access_with_size_for_counted_by): Fully fold the parameters for call to .ACCESS_WITH_SIZE. gcc/testsuite/ChangeLog: * gcc.dg/pr119717.c: New test.
2025-04-09Daily bump.GCC Administrator1-0/+9
2025-04-08c: fix checking for a tag for variably modified tagged types [PR119612]Martin Uecker3-16/+28
The checking assertion added for PR118765 did not take into account that add_decl_expr can change TYPE_NAME to a TYPE_DECL with no name for certain cases of variably modified types. This also implies that we might sometimes not reliably detect the absence of a tag when only considering TYPE_NAME. This patch introduces a new helper function c_type_tag to reliable compute the tag for a tagged types and uses it for code where the switch to C23 may cause regressions. PR c/119612 gcc/c/ChangeLog: * c-tree.h (c_type_tag): Add prototype. * c-typeck.cc (c_type_tag): New function. (tagged_types_tu_compatible_p, composite_type_internal): Use c_type_tag. * c-decl.cc (c_struct_hasher::hash, previous_tag): Use c_type_tag. gcc/testsuite/ChangeLog: * gcc.dg/gnu23-tag-6.c: New test. * gcc.dg/pr119612.c: New test.
2025-04-03Daily bump.GCC Administrator1-0/+16