aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
AgeCommit message (Collapse)AuthorFilesLines
2016-06-08re PR c++/70507 (integer overflow builtins not constant expressions)Martin Sebor2-3/+22
PR c++/70507 PR c/68120 * builtins.def (BUILT_IN_ADD_OVERFLOW_P, BUILT_IN_SUB_OVERFLOW_P, BUILT_IN_MUL_OVERFLOW_P): New builtins. * builtins.c: Include gimple-fold.h. (fold_builtin_arith_overflow): Handle BUILT_IN_{ADD,SUB,MUL}_OVERFLOW_P. (fold_builtin_3): Likewise. * doc/extend.texi (Integer Overflow Builtins): Document __builtin_{add,sub,mul}_overflow_p. gcc/c/ * c-typeck.c (convert_arguments): Don't promote last argument of BUILT_IN_{ADD,SUB,MUL}_OVERFLOW_P. gcc/cp/ * constexpr.c: Include gimple-fold.h. (cxx_eval_internal_function): New function. (cxx_eval_call_expression): Call it. (potential_constant_expression_1): Handle integer arithmetic overflow built-ins. * tree.c (builtin_valid_in_constant_expr_p): Handle BUILT_IN_{ADD,SUB,MUL}_OVERFLOW_P. gcc/c-family/ * c-common.c (check_builtin_function_arguments): Handle BUILT_IN_{ADD,SUB,MUL}_OVERFLOW_P. gcc/testsuite/ * c-c++-common/builtin-arith-overflow-1.c: Add test cases. * c-c++-common/builtin-arith-overflow-2.c: New test. * g++.dg/ext/builtin-arith-overflow-1.C: New test. * g++.dg/cpp0x/constexpr-arith-overflow.C: New test. * g++.dg/cpp1y/constexpr-arith-overflow.C: New test. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r237238
2016-06-08re PR c/71426 (gcc ICE on x86_64-linux-gnu in get_parm_info, at c/c-decl.c:7059)Marek Polacek2-3/+7
PR c/71426 * c-decl.c (get_parm_info): Don't crash on an assert on invalid code. * gcc.dg/noncompile/pr71426.c: New test. From-SVN: r237196
2016-06-08re PR c/71418 (gcc ICE on x86_64-linux-gnu in min_align_of_type, at ↵Marek Polacek2-1/+6
stor-layout.c:2402) PR c/71418 * c-decl.c (grokdeclarator): Check TYPE_P. * gcc.dg/noncompile/pr71418.c: New test. From-SVN: r237195
2016-06-07C: add fixit hint to misspelled field namesDavid Malcolm4-15/+61
gcc/c/ChangeLog: * c-parser.c (c_parser_postfix_expression): In __builtin_offsetof and structure element reference, capture the location of the element name token and pass it to build_component_ref. (c_parser_postfix_expression_after_primary): Likewise for structure element dereference. (c_parser_omp_variable_list): Likewise for OMP_CLAUSE_{_CACHE, MAP, FROM, TO}, * c-tree.h (build_component_ref): Add location_t param. * c-typeck.c (build_component_ref): Add location_t param COMPONENT_LOC. Use it, if available, when issuing hints about mispelled member names to provide a fixit replacement hint. gcc/objc/ChangeLog: * objc-act.c (objc_build_component_ref): Update call to build_component_ref for added param, passing UNKNOWN_LOCATION. gcc/testsuite/ChangeLog: * gcc.dg/spellcheck-fields-2.c: New test case. From-SVN: r237176
2016-06-06re PR c/71362 (Wrong position for "error: size of unnamed array is negative")Marek Polacek2-0/+6
PR c/71362 * c-parser.c (c_parser_direct_declarator): Set location. * gcc.dg/pr71362.c: New test. From-SVN: r237155
2016-06-06c-typeck.c (comptypes_internal): Handle comparisons of INTEGER_TYPE, ↵Marek Polacek2-3/+27
FIXED_POINT_TYPE, and REAL_TYPE nodes. * c-typeck.c (comptypes_internal): Handle comparisons of INTEGER_TYPE, FIXED_POINT_TYPE, and REAL_TYPE nodes. Don't check TYPE_REF_CAN_ALIAS_ALL. * c-c++-common/attr-may-alias-1.c: New test. * c-c++-common/attr-may-alias-2.c: New test. * gcc.dg/pr39464.c: Turn dg-warning into dg-bogus. From-SVN: r237137
2016-06-03c-typeck.c (c_finish_omp_clauses): Mark OpenACC reduction arguments as ↵Chung-Lin Tang2-0/+16
addressable when async clause exists. 2016-06-03 Chung-Lin Tang <cltang@codesourcery.com> c/ * c-typeck.c (c_finish_omp_clauses): Mark OpenACC reduction arguments as addressable when async clause exists. cp/ * semantics.c (finish_omp_clauses): Mark OpenACC reduction arguments as addressable when async clause exists. fortran/ * trans-openmp.c (gfc_trans_omp_reduction_list): Add mark_addressable bool parameter, set reduction clause DECLs as addressable when true. (gfc_trans_omp_clauses): Pass clauses->async to gfc_trans_omp_reduction_list, add comment describing OpenACC situation. libgomp/ * testsuite/libgomp.oacc-fortran/reduction-8.f90: New testcase. * testsuite/libgomp.oacc-c-c++-common/reduction-8.c: New testcase. From-SVN: r237070
2016-05-30re PR c++/71349 (Combined async target clause parsing issues)Jakub Jelinek2-1/+9
PR c++/71349 * c-parser.c (c_parser_omp_for): Don't disallow nowait clause when combined with target construct. * parser.c (cp_parser_omp_for): Don't disallow nowait clause when combined with target construct. (cp_parser_omp_parallel): Pass cclauses == NULL as last argument to cp_parser_omp_all_clauses. * c-omp.c (c_omp_split_clauses): Put OMP_CLAUSE_DEPEND to C_OMP_CLAUSE_SPLIT_TARGET. Put OMP_CLAUSE_NOWAIT to C_OMP_CLAUSE_SPLIT_TARGET if combined with target construct, instead of C_OMP_CLAUSE_SPLIT_FOR. * c-c++-common/gomp/clauses-1.c (bar): Add dd argument. Add nowait depend(inout: dd[0]) clauses where permitted. From-SVN: r236900
2016-05-26c-parser.c (c_parser_omp_clause_schedule): Warn if ↵Jakub Jelinek2-1/+19
OMP_CLAUSE_SCHEDULE_CHUNK_EXPR is known not to be positive. * c-parser.c (c_parser_omp_clause_schedule): Warn if OMP_CLAUSE_SCHEDULE_CHUNK_EXPR is known not to be positive. * semantics.c (finish_omp_clauses) <case OMP_CLAUSE_SCHEDULE>: Warn if OMP_CLAUSE_SCHEDULE_CHUNK_EXPR is known not to be positive. * openmp.c (resolve_omp_clauses): Warn if chunk_size is known not to be positive. * c-c++-common/gomp/schedule-1.c: New test. * gfortran.dg/gomp/schedule-1.f90: New test. * testsuite/libgomp.c/doacross-1.c (main): Use schedule(static) instead of invalid schedule(static, 0). * testsuite/libgomp.c/doacross-2.c (main): Likewise. From-SVN: r236793
2016-05-25re PR c/71266 (gcc ICE on x86_64-linux-gnu in "store_parm_decls_oldstyle")Marek Polacek2-2/+8
PR c/71266 * c-decl.c (store_parm_decls_oldstyle): Skip non-PARM_DECLs. * gcc.dg/noncompile/old-style-parm-3.c: New test. From-SVN: r236708
2016-05-25re PR c/71265 (gcc ICE on x86_64-linux-gnu with “seg fault”)Marek Polacek2-1/+6
PR c/71265 * c-decl.c (c_make_fname_decl): Don't check seen_error. * gcc.dg/noncompile/pr71265.c: New test. From-SVN: r236707
2016-05-24c-parser.c (c_parser_oacc_declare): Add support for ↵Cesar Philippidis3-15/+57
GOMP_MAP_FIRSTPRIVATE_POINTER. gcc/c/ * c-parser.c (c_parser_oacc_declare): Add support for GOMP_MAP_FIRSTPRIVATE_POINTER. * c-typeck.c (handle_omp_array_sections_1): Replace bool is_omp argument with enum c_omp_region_type ort. (handle_omp_array_sections): Likewise. Update call to handle_omp_array_sections_1. (c_finish_omp_clauses): Add specific errors and warning messages for OpenACC. Use firsrtprivate pointers for OpenACC subarrays. Update call to handle_omp_array_sections. gcc/cp/ * parser.c (cp_parser_oacc_declare): Add support for GOMP_MAP_FIRSTPRIVATE_POINTER. * semantics.c (handle_omp_array_sections_1): Replace bool is_omp argument with enum c_omp_region_type ort. Don't privatize OpenACC non-static members. (handle_omp_array_sections): Replace bool is_omp argument with enum c_omp_region_type ort. Update call to handle_omp_array_sections_1. (finish_omp_clauses): Add specific errors and warning messages for OpenACC. Use firsrtprivate pointers for OpenACC subarrays. Update call to handle_omp_array_sections. gcc/ * gimplify.c (omp_notice_variable): Use zero-length arrays for data pointers inside OACC_DATA regions. (gimplify_scan_omp_clauses): Prune firstprivate clause associated with OACC_DATA, OACC_ENTER_DATA and OACC_EXIT data regions. (gimplify_adjust_omp_clauses): Fix typo in comment. gcc/testsuite/ * c-c++-common/goacc/data-clause-duplicate-1.c: Adjust test. * c-c++-common/goacc/deviceptr-1.c: Likewise. * c-c++-common/goacc/kernels-alias-3.c: Likewise. * c-c++-common/goacc/kernels-alias-4.c: Likewise. * c-c++-common/goacc/kernels-alias-5.c: Likewise. * c-c++-common/goacc/kernels-alias-8.c: Likewise. * c-c++-common/goacc/kernels-alias-ipa-pta-3.c: Likewise. * c-c++-common/goacc/pcopy.c: Likewise. * c-c++-common/goacc/pcopyin.c: Likewise. * c-c++-common/goacc/pcopyout.c: Likewise. * c-c++-common/goacc/pcreate.c: Likewise. * c-c++-common/goacc/pr70688.c: New test. * c-c++-common/goacc/present-1.c: Adjust test. * c-c++-common/goacc/reduction-5.c: Likewise. * g++.dg/goacc/data-1.C: New test. libgomp/ * oacc-mem.c (acc_malloc): Update handling of shared-memory targets. (acc_free): Likewise. (acc_memcpy_to_device): Likewise. (acc_memcpy_from_device): Likewise. (acc_deviceptr): Likewise. (acc_hostptr): Likewise. (acc_is_present): Likewise. (acc_map_data): Likewise. (acc_unmap_data): Likewise. (present_create_copy): Likewise. (delete_copyout): Likewise. (update_dev_host): Likewise. * testsuite/libgomp.oacc-c-c++-common/asyncwait-1.c: Remove xfail. * testsuite/libgomp.oacc-c-c++-common/data-2-lib.c: New test. * testsuite/libgomp.oacc-c-c++-common/data-2.c: Adjust test. * testsuite/libgomp.oacc-c-c++-common/data-3.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/enter_exit-lib.c: New test. * testsuite/libgomp.oacc-c-c++-common/lib-13.c: Adjust test so that it only runs on nvptx targets. * testsuite/libgomp.oacc-c-c++-common/lib-14.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-15.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-16.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-17.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-18.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-20.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-21.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-22.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-23.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-24.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-25.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-28.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-29.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-30.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-34.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-42.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-43.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-44.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-47.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-48.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-52.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-53.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-54.c: Likewise. From-SVN: r236678
2016-05-24Tighten syntax checking for OpenACC routine construct in CThomas Schwinge2-10/+13
gcc/c/ * c-parser.c (c_parser_oacc_routine): Tighten syntax checks. gcc/testsuite/ * c-c++-common/goacc/routine-5.c: Add tests. * g++.dg/goacc/routine-2.C: Remove duplicate tests. * gfortran.dg/goacc/routine-6.f90: Add tests. From-SVN: r236639
2016-05-24re PR middle-end/70434 (adding an extraneous cast to vector type results in ↵Richard Biener2-3/+11
inferior code) 2016-05-24 Richard Biener <rguenther@suse.de> PR middle-end/70434 PR c/69504 c-family/ * c-common.h (convert_vector_to_pointer_for_subscript): Rename to ... (convert_vector_to_array_for_subscript): ... this. * c-common.c (convert_vector_to_pointer_for_subscript): Use a VIEW_CONVERT_EXPR to an array type. Rename to ... (convert_vector_to_array_for_subscript): ... this. cp/ * expr.c (mark_exp_read): Handle VIEW_CONVERT_EXPR. * constexpr.c (cxx_eval_array_reference): Handle indexed vectors. * typeck.c (cp_build_array_ref): Adjust. c/ * c-typeck.c (build_array_ref): Do not complain about indexing non-lvalue vectors. Adjust for function name change. * tree-ssa.c (non_rewritable_mem_ref_base): Make sure to mark bases which are accessed with non-invariant indices. * gimple-fold.c (maybe_canonicalize_mem_ref_addr): Re-write constant index ARRAY_REFs of vectors into BIT_FIELD_REFs. * c-c++-common/vector-subscript-4.c: New testcase. * c-c++-common/vector-subscript-5.c: Likewise. From-SVN: r236630
2016-05-20PR c/71115 - [4.9/5/6/7 Regression] Missing warning: excess elementsMartin Sebor2-5/+22
PR c/71115 - [4.9/5/6/7 Regression] Missing warning: excess elements in struct initializer gcc/c/ChangeLog: 2016-05-20 Martin Sebor <msebor@redhat.com> PR c/71115 * c-typeck.c (error_init): Use expansion_point_location_if_in_system_header. (warning_init): Same. gcc/testsuite/ChangeLog: 2016-05-20 Martin Sebor <msebor@redhat.com> PR c/71115 * gcc.dg/init-excess-2.c: New test. From-SVN: r236549
2016-05-19PR c/71171: Fix uninitialized source_range in c_parser_postfix_expressionDavid Malcolm4-37/+61
A common way for a c_expr to have an uninitialized src_range is in error-handling, where the "value" field is set to error_mark_node without touching the src_range, leading to complaints from valgrind. This patch introduces a new method c_expr::set_error which sets the value to error_mark_node whilst initializing the src_range to UNKNOWN_LOCATION. This fixes the valgrind issue seen in PR c/71171, along with various other related issues seen when running the testsuite using the checker patch I posted here: https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00887.html (this checker still doesn't fully work yet, but it seems to be good for easily detecting these issues without needing Valgrind). gcc/c/ChangeLog: PR c/71171 * c-parser.c (c_parser_generic_selection): Use c_expr::set_error in error-handling. (c_parser_postfix_expression): Likewise. * c-tree.h (c_expr::set_error): New method. * c-typeck.c (parser_build_binary_op): In error-handling, ensure that result's range is initialized. From-SVN: r236488
2016-05-17[Patch onbious] Fix indentation in c-typeck.c parser_build_unary_opJames Greenhalgh2-2/+6
gcc/c/ * c-typeck.c (parser_build_unary_op): Fix formatting. From-SVN: r236313
2016-05-16Remove TARGET_INVALID_PARAMETER_TYPE and TARGET_INVALID_RETURN_TYPE hooks.Matthew Wahab2-17/+7
c/ 2016-05-16 Matthew Wahab <matthew.wahab@arm.com> * c-decl.c (grokdeclarator): Remove errmsg and use of targetm.invalid_return_type. (grokparms): Remove errmsg and use of targetm.invalid_parameter_type. cp/ 2016-05-16 Matthew Wahab <matthew.wahab@arm.com> * decl.c (grokdeclarator): Remove errmsg and use of targetm.invalid_return_type. (grokparms): Remove errmsg and use of targetm.invalid_parameter_type. gcc/ 2016-05-16 Matthew Wahab <matthew.wahab@arm.com> * doc/tm.texi: Regenerate. * doc/tm.texi.in (TARGET_INVALID_PARAMETER_TYPE): Remove. (TARGET_INVALID_RETURN_TYPE): Remove. * system.h: Poison TARGET_INVALID_PARAMETER_TYPE and TARGET_INVALID_RETURN_TYPE. * target.def (invalid_parameter_type): Remove. (invalid_return_type): Remove. From-SVN: r236276
2016-05-13Implement C11 DR#423 resolution (ignore function return type qualifiers).Joseph Myers2-3/+23
The resolution of C11 DR#423, apart from doing things with the types of expressions cast to qualified types which are only in standard terms observable with _Generic and which agree with how GCC has implemented _Generic all along, also specifies that qualifiers are discarded from function return types: "derived-declarator-type-list function returning T" becomes "derived-declarator-type-list function returning the unqualified version of T" in the rules giving types for function declarators. This means that declarations of a function with both qualified and unqualified return types are now compatible, similar to how different declarations can vary in whether a function argument is declared with a qualifier or unqualified type. This patch implements this resolution. Since the motivation for the change was _Generic, the resolution is restricted to C11 mode; there's no reason to consider there to be a defect in this regard in older standard versions. Some less-obvious issues are handled as follows: * As usual, and as with function arguments, _Atomic is not considered a qualifier for this purpose; that is, function declarations must agree regarding whether the return type is atomic. * By 6.9.1#2, a function definition cannot return qualified void. But with this change, specifying "const void" in the declaration produces the type "function returning void", which is perfectly valid, so "const void f (void) {}" is no longer an error. * The application to restrict is less clear. The way I am interpreting it in this patch is that "unqualified version of T" is not valid if T is not valid, as in the case where T is a restrict-qualified version of a type that cannot be restrict qualified (non-pointer, or pointer-to-function). But it's possible to argue the other way from the wording. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: * c-decl.c (grokdeclarator): For C11, discard qualifiers on function return type. gcc/testsuite: * gcc.dg/qual-return-5.c, gcc.dg/qual-return-6.c: New tests. * gcc.dg/call-diag-2.c, gcc.dg/qual-return-2.c , gcc.dg/qual-return-3.c, gcc.dg/qual-return-4.c: Use -std=gnu99. From-SVN: r236231
2016-05-12re PR c/70756 (Wrong column number shown for "error: invalid use of flexible ↵Marek Polacek4-26/+50
array member") PR c/70756 * c-common.c (pointer_int_sum): Call size_in_bytes_loc instead of size_in_bytes and pass LOC to it. * c-decl.c (build_compound_literal): Pass LOC down to c_incomplete_type_error. * c-tree.h (require_complete_type): Adjust declaration. (c_incomplete_type_error): Likewise. * c-typeck.c (require_complete_type): Add location parameter, pass it down to c_incomplete_type_error. (c_incomplete_type_error): Add location parameter, pass it down to error_at. (build_component_ref): Pass location down to c_incomplete_type_error. (default_conversion): Pass location down to require_complete_type. (build_array_ref): Likewise. (build_function_call_vec): Likewise. (convert_arguments): Likewise. (build_unary_op): Likewise. (build_c_cast): Likewise. (build_modify_expr): Likewise. (convert_for_assignment): Likewise. (c_finish_omp_clauses): Likewise. * call.c (build_new_op_1): Pass LOC to cp_build_modify_expr. * cp-tree.h (cp_build_modify_expr): Update declaration. (cxx_incomplete_type_error, cxx_incomplete_type_diagnostic): New inline overloads. * cp-ubsan.c (cp_ubsan_dfs_initialize_vtbl_ptrs): Pass INPUT_LOCATION to cp_build_modify_expr. * decl2.c (set_guard): Likewise. (handle_tls_init): Likewise. * init.c (perform_member_init): Likewise. (expand_virtual_init): Likewise. (build_new_1): Likewise. (build_vec_delete_1): Likewise. (get_temp_regvar): Likewise. (build_vec_init): Likewise. * method.c (do_build_copy_assign): Likewise. (assignable_expr): Likewise. * semantics.c (finish_omp_for): Likewise. * typeck.c (cp_build_binary_op): Pass LOCATION to pointer_diff and cp_pointer_int_sum. (cp_pointer_int_sum): Add location parameter. Pass it down to pointer_int_sum. (pointer_diff): Add location parameter. Use it. (build_modify_expr): Pass location down to cp_build_modify_expr. (cp_build_modify_expr): Add location parameter. Use it. (build_x_modify_expr): Pass location down to cp_build_modify_expr. * typeck2.c (cxx_incomplete_type_diagnostic, cxx_incomplete_type_error): Add location parameter. * langhooks-def.h (lhd_incomplete_type_error): Adjust declaration. * langhooks.c (lhd_incomplete_type_error): Add location parameter. * langhooks.h (incomplete_type_error): Likewise. * tree.c (size_in_bytes_loc): Renamed from size_in_bytes. Add location parameter, pass it down to incomplete_type_error. * tree.h (size_in_bytes): New inline overload. (size_in_bytes_loc): Renamed from size_in_bytes. * c-c++-common/pr70756-2.c: New test. * c-c++-common/pr70756.c: New test. From-SVN: r236180
2016-05-11PR43651: add warning for duplicate qualifierMikhail Maltsev4-3/+33
gcc/c/ PR c/43651 * c-decl.c (declspecs_add_qual): Warn when -Wduplicate-decl-specifier is enabled. * c-errors.c (pedwarn_c90): Return true if warned. * c-tree.h (pedwarn_c90): Change return type to bool. (enum c_declspec_word): Add new enumerator cdw_atomic. gcc/ PR c/43651 * doc/invoke.texi (Wduplicate-decl-specifier): Document new option. gcc/testsuite/ PR c/43651 * gcc.dg/Wduplicate-decl-specifier-c11.c: New test. * gcc.dg/Wduplicate-decl-specifier.c: Likewise. gcc/c-family/ PR c/43651 * c.opt (Wduplicate-decl-specifier): New option. From-SVN: r236142
2016-05-11re PR c++/71024 (Missing warning for contradictory attributes)Marek Polacek2-49/+7
PR c++/71024 * c-common.c (diagnose_mismatched_attributes): New function. * c-common.h (diagnose_mismatched_attributes): Declare. * c-decl.c (diagnose_mismatched_decls): Factor out code to diagnose_mismatched_attributes and call it. * decl.c (duplicate_decls): Call diagnose_mismatched_decls. * c-c++-common/attributes-3.c: New test. From-SVN: r236129
2016-05-10re PR c/70255 (change of the order of summation of floating point numbers ↵Marek Polacek2-0/+18
despite no-associative-math) PR c/70255 * c-decl.c (diagnose_mismatched_decls): Warn for optimize attribute on a declaration following the definition. * gcc.dg/attr-opt-1.c: New test. From-SVN: r236071
2016-05-05c-parser.c (c_parser_switch_statement): Add IF_P argument, parse it through ↵Jakub Jelinek2-4/+11
to c_parser_c99_block_statement. * c-parser.c (c_parser_switch_statement): Add IF_P argument, parse it through to c_parser_c99_block_statement. (c_parser_statement_after_labels): Adjust c_parser_switch_statement caller. * parser.c (cp_parser_selection_statement): For RID_SWITCH, pass if_p instead of NULL to cp_parser_implicitly_scoped_statement. * c-c++-common/Wdangling-else-4.c: New test. From-SVN: r235920
2016-05-04c.opt (Wdangling-else): New option.Marek Polacek2-1/+6
* c.opt (Wdangling-else): New option. * c-parser.c (c_parser_if_statement): Replace OPT_Wparentheses with OPT_Wdangling_else. * parser.c (cp_parser_selection_statement): Replace OPT_Wparentheses with OPT_Wdangling_else. * doc/invoke.texi: Document -Wdangling-else. * c-c++-common/Wdangling-else-1.c: New test. * c-c++-common/Wdangling-else-2.c: New test. * c-c++-common/Wdangling-else-3.c: New test. From-SVN: r235885
2016-05-04re PR c/48778 (gcc 4.6 -Waddress adds unhelpful new warning case when using ↵Marek Polacek2-2/+10
from a macro) PR c/48778 * c-typeck.c (build_binary_op): Don't issue -Waddress warnings for macro expansions. * gcc.dg/Waddress-2.c: New test. From-SVN: r235878
2016-05-03re PR c/70859 (Bad column number in type-generic function errors)Marek Polacek2-1/+8
PR c/70859 * input.c (expansion_point_location): New function. * input.h (expansion_point_location): Declare. * c-common.c (builtin_function_validate_nargs): Add location parameter. Use it. (check_builtin_function_arguments): Add location and arguments parameters. Use them. * c-common.h (check_builtin_function_arguments): Update declaration. * c-typeck.c (build_function_call_vec): Pass LOC and ARG_LOC down to check_builtin_function_arguments. * call.c (build_cxx_call): Pass location and vNULL down to check_builtin_function_arguments. * gcc.dg/pr70859.c: New test. * gcc.dg/pr70859-2.c: New test. From-SVN: r235832
2016-05-03Make-lang.in (cc1-checksum.c): For stage-final re-use the checksum from the ↵Richard Biener2-2/+14
previous stage. 2016-05-03 Richard Biener <rguenther@suse.de> c/ * Make-lang.in (cc1-checksum.c): For stage-final re-use the checksum from the previous stage. cp/ * Make-lang.in (cc1plus-checksum.c): For stage-final re-use the checksum from the previous stage. From-SVN: r235804
2016-05-02c-common.h (enum c_omp_region_type): Define.Cesar Philippidis4-22/+35
gcc/c-family/ * c-common.h (enum c_omp_region_type): Define. gcc/c/ * c-parser.c (c_parser_oacc_all_clauses): Update call to c_finish_omp_clauses. (c_parser_omp_all_clauses): Likewise. (c_parser_oacc_cache): Likewise. (c_parser_oacc_loop): Likewise. (omp_split_clauses): Likewise. (c_parser_omp_declare_target): Likewise. (c_parser_cilk_all_clauses): Likewise. (c_parser_cilk_for): Likewise. * c-typeck.c (c_finish_omp_clauses): Replace bool arguments is_omp, declare_simd, and is_cilk with enum c_omp_region_type ort. gcc/cp/ * cp-tree.h (finish_omp_clauses): Update prototype. * parser.c (cp_parser_oacc_all_clauses): Update call to finish_omp_clauses. (cp_parser_omp_all_clauses): Likewise. (cp_parser_omp_for_loop): Likewise. (cp_omp_split_clauses): Likewise. (cp_parser_oacc_cache): Likewise. (cp_parser_oacc_loop): Likewise. (cp_parser_omp_declare_target): (cp_parser_cilk_simd_all_clauses): Likewise. (cp_parser_cilk_for): Likewise. * pt.c (tsubst_omp_clauses): Replace allow_fields and declare_simd arguments with enum c_omp_region_type ort. (tsubst_omp_clauses): Update calls to finish_omp_clauses. (tsubst_omp_attribute): Update calls to tsubst_omp_clauses. (tsubst_omp_for_iterator): Update calls to finish_omp_clauses. (tsubst_expr): Update calls to tsubst_omp_clauses. * semantics.c (finish_omp_clauses): Replace bool arguments allow_fields, declare_simd, and is_cilk with bitmask ort. (finish_omp_for): Update call to finish_omp_clauses. From-SVN: r235780
2016-05-02re PR c/70851 (internal compiler error: in create_tmp_var, at gimple-expr.c:473)Marek Polacek2-2/+19
PR c/70851 * c-decl.c (grokdeclarator): Diagnose when array's size has an incomplete type. * gcc.dg/enum-incomplete-3.c: New test. From-SVN: r235750
2016-04-29re PR middle-end/70626 (bogus results in 'acc parallel loop' reductions)Cesar Philippidis2-3/+11
gcc/c-family/ PR middle-end/70626 * c-common.h (c_oacc_split_loop_clauses): Add boolean argument. * c-omp.c (c_oacc_split_loop_clauses): Use it to duplicate reduction clauses in acc parallel loops. gcc/c/ PR middle-end/70626 * c-parser.c (c_parser_oacc_loop): Don't augment mask with OACC_LOOP_CLAUSE_MASK. (c_parser_oacc_kernels_parallel): Update call to c_oacc_split_loop_clauses. gcc/cp/ PR middle-end/70626 * parser.c (cp_parser_oacc_loop): Don't augment mask with OACC_LOOP_CLAUSE_MASK. (cp_parser_oacc_kernels_parallel): Update call to c_oacc_split_loop_clauses. gcc/fortran/ PR middle-end/70626 * trans-openmp.c (gfc_trans_oacc_combined_directive): Duplicate the reduction clause in both parallel and loop directives. gcc/testsuite/ PR middle-end/70626 * c-c++-common/goacc/combined-reduction.c: New test. * gfortran.dg/goacc/reduction-2.f95: Add check for kernels reductions. libgomp/ PR middle-end/70626 * testsuite/libgomp.oacc-c++/template-reduction.C: Adjust test. * testsuite/libgomp.oacc-c-c++-common/combined-reduction.c: New test. * testsuite/libgomp.oacc-fortran/combined-reduction.f90: New test. From-SVN: r235651
2016-04-28c-array-notation.c (fix_builtin_array_notation_fn): Fix final argument to ↵Andrew MacLeod2-2/+7
build_modify_expr in two cases. 2016-04-28 Andrew MacLeod <amacleod@redhat.com> * c-array-notation.c (fix_builtin_array_notation_fn): Fix final argument to build_modify_expr in two cases. From-SVN: r235614
2016-04-27invoke.texi (Warning Options): Add -Wmemset-elt-size.Bernd Schmidt2-10/+12
* doc/invoke.texi (Warning Options): Add -Wmemset-elt-size. (-Wmemset-elt-size): New item. c-family/ * c.opt (Wmemset-elt-size): New option. * c-common.c (warn_for_memset): New function. * c-common.h (warn_for_memset): Declare. c/ * c-parser.c (c_parser_postfix_expression_after_primary): Call warn_for_memset instead of warning directly here. cp/ * parser.c (cp_parser_postfix_expression): Call warn_for_memset instead of warning directly here. testsuite/ * c-c++-common/memset-array.c: New test. From-SVN: r235475
2016-04-26re PR c/70791 (-Wnested-externs prints inconsistent column number)Marek Polacek2-1/+5
PR c/70791 * c-decl.c (pushdecl): Pass LOCUS down to warning. * gcc.dg/Wnested-externs-2.c: New test. From-SVN: r235447
2016-04-26re PR c/67784 (Incorrect parsing when using declarations in for loops and ↵Marek Polacek2-32/+51
typedefs) PR c/67784 * c-parser.c (c_parser_maybe_reclassify_token): New function factored out of ... (c_parser_for_statement): ... here. (c_parser_if_statement): Use it. (c_parser_switch_statement): Use it. (c_parser_while_statement): Use it. * gcc.dg/pr67784-3.c: New test. * gcc.dg/pr67784-4.c: New test. * gcc.dg/pr67784-5.c: New test. From-SVN: r235446
2016-04-22[PATCH 1/2] (header usage fix) remove unused system header includesSzabolcs Nagy1-2/+0
2016-04-22 Szabolcs Nagy <szabolcs.nagy@arm.com> * auto-profile.c: Remove <string.h> include. * ipa-icf-gimple.c: Remove <list> include. * diagnostic.c: Remove <new> include. * genmatch.c: Likewise. * pretty-print.c: Likewise. * toplev.c: Likewise * c/c-objc-common.c: Likewise. * cp/error.c: Likewise. * fortran/error.c: Likewise. From-SVN: r235361
2016-04-20re PR c++/69363 (ICE when doing a pragma simd reduction with max)Ilya Verbin4-10/+37
Fix PR c++/69363 gcc/c-family/ PR c++/69363 * c-cilkplus.c (c_finish_cilk_clauses): Remove function. * c-common.h (c_finish_cilk_clauses): Remove declaration. gcc/c/ PR c++/69363 * c-parser.c (c_parser_cilk_all_clauses): Use c_finish_omp_clauses instead of c_finish_cilk_clauses. * c-tree.h (c_finish_omp_clauses): Add new default argument. * c-typeck.c (c_finish_omp_clauses): Add new argument. Allow floating-point variables in the linear clause for Cilk Plus. gcc/cp/ PR c++/69363 * cp-tree.h (finish_omp_clauses): Add new default argument. * parser.c (cp_parser_cilk_simd_all_clauses): Use finish_omp_clauses instead of c_finish_cilk_clauses. * semantics.c (finish_omp_clauses): Add new argument. Allow floating-point variables in the linear clause for Cilk Plus. gcc/testsuite/ PR c++/69363 * c-c++-common/cilk-plus/PS/clauses3.c: Adjust dg-error string. * c-c++-common/cilk-plus/PS/clauses4.c: New test. * c-c++-common/cilk-plus/PS/pr69363.c: New test. From-SVN: r235290
2016-04-18tree.h (TYPE_ALIGN, DECL_ALIGN): Return shifted amount.Michael Matz2-6/+11
* tree.h (TYPE_ALIGN, DECL_ALIGN): Return shifted amount. (SET_TYPE_ALIGN, SET_DECL_ALIGN): New. * tree-core.h (tree_type_common.align): Use bit-field. (tree_type_common.spare): New. (tree_decl_common.off_align): Make smaller. (tree_decl_common.align): Use bit-field. * expr.c (expand_expr_addr_expr_1): Use SET_TYPE_ALIGN. * omp-low.c (install_var_field): Use SET_DECL_ALIGN. (scan_sharing_clauses): Ditto. (finish_taskreg_scan): Use SET_DECL_ALIGN and SET_TYPE_ALIGN. (omp_finish_file): Ditto. * stor-layout.c (do_type_align): Use SET_DECL_ALIGN. (layout_decl): Ditto. (relayout_decl): Ditto. (finalize_record_size): Use SET_TYPE_ALIGN. (finalize_type_size): Ditto. (finish_builtin_struct): Ditto. (layout_type): Ditto. (initialize_sizetypes): Ditto. * targhooks.c (std_gimplify_va_arg_expr): Use SET_TYPE_ALIGN. * tree-nested.c (insert_field_into_struct): Use SET_TYPE_ALIGN. (lookup_field_for_decl): Use SET_DECL_ALIGN. (get_chain_field): Ditto. (get_trampoline_type): Ditto. (get_nl_goto_field): Ditto. * tree-streamer-in.c (unpack_ts_decl_common_value_fields): Use SET_DECL_ALIGN. (unpack_ts_type_common_value_fields): Use SET_TYPE_ALIGN. * gimple-expr.c (copy_var_decl): Use SET_DECL_ALIGN. * tree.c (make_node_stat): Use SET_DECL_ALIGN and SET_TYPE_ALIGN. (build_qualified_type): Use SET_TYPE_ALIGN. (build_aligned_type, build_range_type_1): Ditto. (build_atomic_base): Ditto. (build_common_tree_nodes): Ditto. * cfgexpand.c (align_local_variable): Use SET_DECL_ALIGN. (expand_one_stack_var_at): Ditto. * coverage.c (build_var): Use SET_DECL_ALIGN. * except.c (init_eh): Ditto. * function.c (assign_parm_setup_block): Ditto. * symtab.c (increase_alignment_1): Ditto. * tree-ssa-ccp.c (fold_builtin_alloca_with_align): Ditto. * tree-vect-stmts.c (ensure_base_align): Ditto. * varasm.c (align_variable): Ditto. (assemble_variable): Ditto. (build_constant_desc): Ditto. (output_constant_def_contents): Ditto. * config/arm/arm.c (arm_relayout_function): Use SET_DECL_ALIGN. * config/avr/avr.c (avr_adjust_type_node): Use SET_TYPE_ALIGN. * config/mips/mips.c (mips_std_gimplify_va_arg_expr): Ditto. * config/msp430/msp430.c (msp430_gimplify_va_arg_expr): Ditto. * config/spu/spu.c (spu_build_builtin_va_list): Use SET_DECL_ALIGN. ada/ * gcc-interface/decl.c (gnat_to_gnu_entity): Use SET_TYPE_ALIGN. (gnat_to_gnu_field): Ditto. (components_to_record): Ditto. (create_variant_part_from): Ditto. (copy_and_substitute_in_size): Ditto. (substitute_in_type): Ditto. * gcc-interface/utils.c (make_aligning_type): Use SET_TYPE_ALIGN. (make_packable_type): Ditto. (maybe_pad_type): Ditto. (finish_fat_pointer_type): Ditto. (finish_record_type): Ditto and use SET_DECL_ALIGN. (rest_of_record_type_compilation): Use SET_TYPE_ALIGN. (create_field_decl): Use SET_DECL_ALIGN. c-family/ * c-common.c (handle_aligned_attribute): Use SET_TYPE_ALIGN and SET_DECL_ALIGN. c/ * c-decl.c (merge_decls): Use SET_DECL_ALIGN and SET_TYPE_ALIGN. (grokdeclarator, parser_xref_tag, finish_enum): Use SET_TYPE_ALIGN. cp/ * class.c (build_vtable): Use SET_DECL_ALIGN and SET_TYPE_ALIGN. (layout_class_type): Ditto. (build_base_field): Use SET_DECL_ALIGN. (fixup_attribute_variants): Use SET_TYPE_ALIGN. * decl.c (duplicate_decls): Use SET_DECL_ALIGN. (record_unknown_type): Use SET_TYPE_ALIGN. (cxx_init_decl_processing): Ditto. (copy_type_enum): Ditto. (grokfndecl): Use SET_DECL_ALIGN. (copy_type_enum): Use SET_TYPE_ALIGN. * pt.c (instantiate_class_template_1): Use SET_TYPE_ALIGN. (tsubst): Ditto. * tree.c (cp_build_qualified_type_real): Use SET_TYPE_ALIGN. * lambda.c (maybe_add_lambda_conv_op): Use SET_DECL_ALIGN. * method.c (implicitly_declare_fn): Use SET_DECL_ALIGN. * rtti.c (emit_tinfo_decl): Ditto. fortran/ * trans-io.c (gfc_build_io_library_fndecls): Use SET_TYPE_ALIGN. * trans-common.c (build_common_decl): Use SET_DECL_ALIGN. * trans-types.c (gfc_add_field_to_struct): Use SET_DECL_ALIGN. go/ * go-gcc.cc (Gcc_backend::implicit_variable): Use SET_DECL_ALIGN. java/ * class.c (add_method_1): Use SET_DECL_ALIGN. (make_class_data): Ditto. (emit_register_classes_in_jcr_section): Ditto. * typeck.c (build_java_array_type): Ditto. objc/ * objc-act.c (objc_build_struct): Use SET_DECL_ALIGN. libcc1/ * plugin.cc (plugin_finish_record_or_union): Use SET_TYPE_ALIGN. From-SVN: r235172
2016-04-15re PR c/70671 (Wrong column number shown for "error: cannot take address of ↵Marek Polacek2-6/+13
bit-field") PR c/70671 * c-typeck.c (build_unary_op): Pass location down to error and warning call. * gcc.dg/bitfld-22.c: New test. From-SVN: r235032
2016-04-15re PR c/70436 (-Wparentheses missing ambiguous else warning)Jakub Jelinek2-108/+162
PR c/70436 c/ * c-parser.c (c_parser_pragma): Add IF_P argument, pass it down where needed. (c_parser_external_declaration, c_parser_struct_or_union_specifier, c_parser_parameter_declaration, c_parser_compound_statement_nostart, c_parser_objc_class_instance_variables, c_parser_objc_methodprotolist): Adjust c_parser_pragma callers. (c_parser_statement_after_labels): Likewise. Adjust c_parser_cilk_for caller. (c_parser_omp_structured_block): Add IF_P argument, pass it down to c_parser_statement. (c_parser_oacc_data, c_parser_oacc_host_data, c_parser_oacc_loop, c_parser_oacc_kernels_parallel, c_parser_omp_critical, c_parser_omp_simd, c_parser_omp_for, c_parser_omp_master, c_parser_omp_ordered, c_parser_omp_parallel, c_parser_omp_single, c_parser_omp_task, c_parser_omp_taskgroup, c_parser_omp_distribute, c_parser_omp_teams, c_parser_omp_target_data, c_parser_omp_target, c_parser_omp_taskloop, c_parser_omp_construct, c_parser_cilk_grainsize, c_parser_cilk_simd, c_parser_cilk_for): Add IF_P argument, pass it down where needed. (c_parser_omp_for_loop): Likewise. Clear IF_P if nbraces. (c_parser_omp_sections_scope): Adjust c_parser_omp_structured_block calls. cp/ * parser.c (cp_parser_pragma): Add IF_P argument, pass it down where needed. (cp_parser_declaration_seq_opt, cp_parser_member_specification_opt, cp_parser_objc_interstitial_code, cp_parser_omp_declare_simd, cp_parser_oacc_routine): Adjust cp_parser_pragma callers. (cp_parser_statement): Likewise. Adjust cp_parser_cilk_for caller. (cp_parser_omp_structured_block): Add IF_P argument, pass it down to cp_parser_statement. (cp_parser_oacc_data, cp_parser_oacc_host_data, cp_parser_oacc_loop, cp_parser_oacc_kernels_parallel, cp_parser_omp_critical, cp_parser_omp_simd, cp_parser_omp_for, cp_parser_omp_master, cp_parser_omp_ordered, cp_parser_omp_parallel, cp_parser_omp_single, cp_parser_omp_task, cp_parser_omp_taskgroup, cp_parser_omp_distribute, cp_parser_omp_teams, cp_parser_omp_target_data, cp_parser_omp_target, cp_parser_omp_taskloop, cp_parser_omp_construct, cp_parser_cilk_grainsize, cp_parser_cilk_simd, cp_parser_cilk_for): Add IF_P argument, pass it down where needed. (cp_parser_omp_for_loop): Likewise. Clear IF_P if nbraces. (cp_parser_omp_sections_scope): Adjust cp_parser_omp_structured_block calls. testsuite/ * c-c++-common/Wparentheses-1.c: New test. * c-c++-common/gomp/Wparentheses-1.c: New test. * c-c++-common/gomp/Wparentheses-2.c: New test. * c-c++-common/gomp/Wparentheses-3.c: New test. * c-c++-common/gomp/Wparentheses-4.c: New test. * c-c++-common/cilk-plus/PS/Wparentheses-1.c: New test. * c-c++-common/cilk-plus/CK/Wparentheses-1.c: New test. * c-c++-common/goacc/Wparentheses-1.c: New test. From-SVN: r235020
2016-04-13re PR c/70436 (-Wparentheses missing ambiguous else warning)Marek Polacek4-77/+98
PR c/70436 * c-parser.c (c_parser_statement_after_labels): Add IF_P argument and adjust callers. (c_parser_statement): Likewise. (c_parser_c99_block_statement): Likewise. (c_parser_while_statement): Likewise. (c_parser_for_statement): Likewise. (c_parser_if_body): Don't set IF_P here. (c_parser_if_statement): Add IF_P argument. Set IF_P here. Warn about dangling else here. * c-tree.h (c_finish_if_stmt): Adjust declaration. * c-typeck.c (c_finish_if_stmt): Remove NESTED_IF parameter. Don't warn about dangling else here. * testsuite/gcc.dg/Wparentheses-12.c: New test. * testsuite/gcc.dg/Wparentheses-13.c: New test. From-SVN: r234949
2016-04-04re PR middle-end/70307 (ICE: in gimplify_expr, at gimplify.c:10915 on valid ↵Marek Polacek2-0/+25
code) PR c/70307 * c-fold.c (c_fully_fold_internal): Handle VEC_COND_EXPR. * gcc.dg/torture/pr70307.c: New test. From-SVN: r234706
2016-03-31re PR c/70297 (GCC Segfaults when using -g3)Marek Polacek2-0/+34
PR c/70297 * c-decl.c (merge_decls): Also set TYPE_ALIGN and TYPE_USER_ALIGN. * decl.c (duplicate_decls): Also set TYPE_ALIGN and TYPE_USER_ALIGN. * c-c++-common/pr70297.c: New test. * g++.dg/cpp0x/typedef-redecl.C: New test. * gcc.dg/typedef-redecl2.c: New test. From-SVN: r234626
2016-03-18PR c/70281: C FE: fix uninitialized range for __builtin_types_compatible_pDavid Malcolm2-2/+10
gcc/c/ChangeLog: PR c/70281 * c-parser.c (c_parser_postfix_expression): Set the source range for uses of "__builtin_types_compatible_p". gcc/testsuite/ChangeLog: PR c/70281 * gcc.dg/plugin/diagnostic-test-expressions-1.c (test_builtin_types_compatible_p): New test function. * gcc.dg/pr70281.c: New test case. From-SVN: r234340
2016-03-18re PR middle-end/70280 (-fcompare-debug failure (length) with ↵Jakub Jelinek2-3/+13
--param=integer-share-limit=4016 -mavx512bw) PR c/70280 * c-typeck.c (composite_type): Don't count void_list_node into len, if the list is terminated by void_list_node, start with void_list_node instead of NULL for newargs. Stop at void_list_node. From-SVN: r234312
2016-03-17Rename GOMP_MAP_FORCE_DEALLOC to GOMP_MAP_DELETEThomas Schwinge1-1/+1
Also rename the Fortran OMP_MAP_FORCE_DEALLOC to OMP_MAP_DELETE. include/ * gomp-constants.h (enum gomp_map_kind): Rename GOMP_MAP_FORCE_DEALLOC to GOMP_MAP_DELETE. Adjust all users. gcc/fortran/ * gfortran.h (enum gfc_omp_map_op): Rename OMP_MAP_FORCE_DEALLOC to OMP_MAP_DELETE. Adjust all users. From-SVN: r234294
2016-03-16re PR c/70093 (Instancing function with VM return type cases internal ↵Marek Polacek2-0/+16
compiler error in 'assign_stack_temp_for_type'.) PR c/70093 * c-typeck.c (build_function_call_vec): Create a TARGET_EXPR for nested functions returning VM types. * cgraphunit.c (cgraph_node::expand_thunk): Also build call to the function being thunked if the result type doesn't have fixed size. * gimplify.c (gimplify_modify_expr): Also set LHS if the result type doesn't have fixed size. * gcc.dg/nested-func-10.c: New test. * gcc.dg/nested-func-9.c: New test. From-SVN: r234259
2016-03-09c-parser.c (c_parser_oacc_loop): Update cclauses and clauses when calling ↵Cesar Philippidis2-2/+7
c_finish_omp_clauses. gcc/c/ * c-parser.c (c_parser_oacc_loop): Update cclauses and clauses when calling c_finish_omp_clauses. gcc/cp/ * parser.c (cp_parser_oacc_loop): Update cclauses and clauses when calling c_finish_omp_clauses. gcc/testsuite/ * c-c++-common/goacc/combined-directives-2.c: New test. From-SVN: r234089
2016-03-04re PR c/69824 (internal compiler error in unshare_body)Bernd Schmidt2-6/+15
PR c/69824 * c-decl.c (get_parm_info): Don't queue implicit function declarations for later. PR c/69824 * gcc.dg/pr69824.c: New test. From-SVN: r234000
2016-03-04re PR c/69798 (ICE on invalid code on x86_64-linux-gnu in ↵Marek Polacek2-5/+11
c_parser_braced_init, at c/c-parser.c:4338) PR c/69798 * c-parser.c (c_parser_postfix_expression): Call c_parser_cast_expression rather than c_parser_postfix_expression. * gcc.dg/cilk-plus/pr69798-1.c: New test. * gcc.dg/cilk-plus/pr69798-2.c: New test. From-SVN: r233965