aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
AgeCommit message (Collapse)AuthorFilesLines
2016-03-01re PR c/69796 (ICE on invalid code in useless_type_conversion_p, at ↵Jakub Jelinek2-4/+8
gimple-expr.c:83) PR c/69796 PR c/69974 * c-parser.c (c_parser_translation_unit): Don't change TREE_TYPE of incomplete decls to error_mark_node. * gcc.dg/pr69796.c: New test. * gcc.dg/pr69974.c: New test. From-SVN: r233861
2016-02-24re PR c/69819 (ICE on invalid code on x86_64-linux-gnu in tree check: ↵Marek Polacek2-1/+7
expected function_type or method_type, have array_type in function_args_iter_init, at tree.h:4536) PR c/69819 * c-decl.c (finish_decl): Don't update the copy of the type of a different decl type. * gcc.dg/pr69819.c: New test. From-SVN: r233683
2016-02-23re PR objc/69844 (Possibly bogus error: unknown type name in ObjC code)Jakub Jelinek2-7/+30
PR objc/69844 * c-parser.c (c_parser_for_statement): Properly handle ObjC classes in id_kind reclassification. * objc.dg/pr69844.m: New test. From-SVN: r233643
2016-02-16re PR c/69835 (-Wnonnull diagnoses parameter comparisons with NULL even when ↵Jakub Jelinek2-10/+5
those could have changed) PR c/69835 * common.opt (Wnonnull-compare): New warning. * doc/invoke.texi (-Wnonnull): Remove text about comparison of arguments against NULL. (-Wnonnull-compare): Document. * Makefile.in (OBJS): Add gimple-ssa-nonnull-compare.o. * tree-pass.h (make_pass_warn_nonnull_compare): Declare. * passes.def (pass_warn_nonnull_compare): Add. * gimple-ssa-nonnull-compare.c: New file. c-family/ * c.opt (Wnonnull-compare): Enable for -Wall. c/ * c-typeck.c (build_binary_op): Revert 2015-09-09 change. cp/ * typeck.c (cp_build_binary_op): Revert 2015-09-09 change. testsuite/ * c-c++-common/nonnull-1.c: Use -Wnonnull-compare instead of -Wnonnull in dg-options. * c-c++-common/nonnull-2.c: New test. From-SVN: r233472
2016-02-16re PR c/64748 (OpenACC: "is not a variable" error with deviceptr())James Norris2-1/+6
PR c/64748 gcc/c/ * c-parser.c (c_parser_oacc_data_clause_deviceptr): Allow parms. gcc/cp/ * parser.c (cp_parser_oacc_data_clause_deviceptr): Remove checking. * semantics.c (finish_omp_clauses): Add deviceptr checking. gcc/testsuite/ * c-c++-common/goacc/deviceptr-1.c: Add tests. * g++.dg/goacc/deviceptr-1.c: New file. From-SVN: r233458
2016-02-12Fix incomplete initialization of the declspec struct.Bernd Schmidt2-27/+3
* c-decl.c (build_null_declspecs): Zero the entire struct. From-SVN: r233367
2016-02-12Fix obstack use-after-free problems in C frontend, PR69522Bernd Schmidt4-33/+51
c/ PR c/69522 * c-parser.c (c_parser_braced_init): New arg outer_obstack. All callers changed. If nested_p is true, use it to call finish_implicit_inits. * c-tree.h (finish_implicit_inits): Declare. * c-typeck.c (finish_implicit_inits): New function. Move code from ... (push_init_level): ... here. (set_designator, process_init_element): Call finish_implicit_inits. testsuite/ PR c/69522 gcc.dg/pr69522.c: New test. From-SVN: r233366
2016-02-11re PR c/69768 (Bogus -Waddress warning)Jakub Jelinek2-2/+10
PR c/69768 * c-typeck.c (parser_build_binary_op): Strip nops from integer_zerop arguments for -Waddress warning. * typeck.c (cp_build_binary_op): cp_fully_fold integer_zerop arguments for -Waddress warning. Fix up formatting. * c-c++-common/Waddress-1.c: New test. From-SVN: r233357
2016-02-04re PR c/69669 (ICE with enum __attribute__((mode(QI))))Jakub Jelinek2-12/+25
PR c/69669 * c-decl.c (finish_enum): When honoring mode attribute, make sure to use proper TYPE_MIN_VALUE and TYPE_MAX_VALUE. * c-c++-common/pr69669.c: New test. From-SVN: r233154
2016-01-29re PR debug/69518 (Flag -g causes "error: type variant has different ↵Jakub Jelinek2-11/+16
TYPE_VFIELD") PR debug/69518 * c-decl.c (finish_struct): Clear C_TYPE_INCOMPLETE_VARS in all type variants, not just TYPE_MAIN_VARIANT. * gcc.dg/torture/pr69518.c: New test. From-SVN: r232998
2016-01-27re PR debug/66869 (-Wunused-function no longer warns for static declarations ↵Jakub Jelinek2-4/+22
without definition) PR debug/66869 * c-decl.c (c_write_global_declarations_1): Warn with warn_unused_function if static prototype without definition is not C_DECL_USED. * gcc.dg/pr66869.c: New test. From-SVN: r232899
2016-01-27re PR c/68062 (ICE when comparing vectors)Marek Polacek2-0/+34
PR c/68062 * c-typeck.c (build_binary_op) [EQ_EXPR, GE_EXPR]: Promote operand to unsigned, if needed. Add -Wsign-compare warning. * typeck.c (cp_build_binary_op): Promote operand to unsigned, if needed. Add -Wsign-compare warning. * c-c++-common/vector-compare-4.c: New test. From-SVN: r232894
2016-01-26re PR tree-optimization/69483 (gcc ICE on x86_64-linux-gnu with "expected ↵Jakub Jelinek2-9/+13
class 'type', have 'exceptional' (error_mark) in useless_type_conversion_p") PR tree-optimization/69483 * gimple-fold.c (canonicalize_constructor_val): Return NULL if base has error_mark_node type. * c-parser.c (c_parser_translation_unit): Use FOR_EACH_VEC_ELT. * gcc.dg/pr69483.c: New test. * g++.dg/opt/pr69483.C: New test. From-SVN: r232833
2016-01-20Correct date in ChangeLog entry for r232622Prathamesh Kulkarni1-1/+1
From-SVN: r232626
2016-01-20re PR c/24293 (Undefined behaviour not diagnosed with -fsyntax-only)Prathamesh Kulkarni4-0/+37
2016-01-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> PR c/24293 * c-tree.h (incomplete_record_decls): Declare. * c-parser.c (incomplete_record_decls): Define. (c_parser_translation_unit): Iterate through incomplete_record_decls and report error if any decl has zero size. * c-decl.c (finish_decl): Append static decl with incomplete struct/union or enum type to incomplete_record_decls. testsuite/ * gcc.dg/pr24293.c: New test. * gcc.dg/Wcxx-compat-8.c: Adjust to accept error due to incomplete struct type. * gcc.dg/declspec-1.c: Likewise. * gcc.dg/pr63549.c: Likewise. From-SVN: r232622
2016-01-14Mark symbols in offload tables with force_output in read_offload_tablesTom de Vries2-8/+8
2016-01-14 Tom de Vries <tom@codesourcery.com> PR tree-optimization/68773 * c-parser.c (c_parser_oacc_declare, c_parser_omp_declare_target): Don't set force_output. * parser.c (cp_parser_oacc_declare, cp_parser_omp_declare_target): Don't set force_output. * omp-low.c (expand_omp_target): Don't set force_output. * varpool.c (varpool_node::get_create): Same. * lto-cgraph.c (input_offload_tables): Mark entries in offload_vars and offload_funcs with force_output. From-SVN: r232384
2016-01-14re PR c/69262 (Request for better array bounds warning)Marek Polacek2-0/+18
PR c/69262 * c-decl.c (grokdeclarator): Provide more information for invalid array declarations. * gcc.dg/array-15.c: New test. From-SVN: r232376
2016-01-13Improve warning locations (PR66208)Bernd Schmidt1-1/+1
PR c/66208 * c-common.c (check_function_nonnull): Remove unnecessary declaration. Add new arg loc and pass it down as context. (check_nonnull_arg): Don't mark ctx arg as unused. Use it as a pointer to the location to use for the warning. (check_function_arguments): New arg loc. All callers changed. Pass it to check_function_nonnull. * c-common.h (check_function_arguments): Adjust declaration. testsuite/ PR c/66208 * c-c++-common/pr66208.c: New file. From-SVN: r232345
2016-01-06C: fix reported range of invalid unary dereference.David Malcolm2-8/+19
gcc/c/ChangeLog: * c-parser.c (c_parser_unary_expression): For dereferences, build a combined location before calling build_indirect_ref, so that error reports cover the full range, manually updating the c_expr src_range. gcc/testsuite/ChangeLog: * gcc.dg/bad-dereference.c: New test case. From-SVN: r232110
2016-01-06re PR sanitizer/69099 (ICE when compiling gcc.dg/atomic/c11-atomic-exec-2.c ↵Marek Polacek2-8/+11
with -fsanitize=float-cast-overflow) PR sanitizer/69099 * c-convert.c (convert) [INTEGER_TYPE]: Drop ARG. Don't pass ARG to ubsan_instrument_float_cast. Fold EXPR. Use NULL_TREE instead of NULL. * convert.c (convert_to_integer_1): Adjust call to ubsan_instrument_float_cast. Use NULL_TREE instead of NULL. * ubsan.c (ubsan_instrument_float_cast): Drop the ARG parameter. Use EXPR instead of ARG. * ubsan.h (ubsan_instrument_float_cast): Adjust declaration. * gcc.dg/ubsan/float-cast-overflow-atomic.c: New test. From-SVN: r232099
2016-01-04Update copyright years.Jakub Jelinek17-17/+21
From-SVN: r232055
2016-01-04re PR c/68908 (inefficient code for _Atomic operations)Marek Polacek2-15/+107
PR c/68908 * c-typeck.c (build_atomic_assign): Improve commentary. Add optimization to use __atomic_fetch_* built-in if possible. * gcc.dg/atomic/c11-atomic-exec-6.c: New test. * gcc.dg/atomic/c11-atomic-exec-7.c: New test. * gcc.dg/atomic/stdatomic-op-5.c: New test. From-SVN: r232052
2015-12-23Merge OMP_CLAUSE_USE_DEVICE into OMP_CLAUSE_USE_DEVICE_PTRThomas Schwinge3-12/+12
gcc/c/ * c-parser.c (c_parser_oacc_clause_use_device): Merge function into... (c_parser_omp_clause_use_device_ptr): ... this function. Adjust all users. gcc/ * tree-core.h (enum omp_clause_code): Merge OMP_CLAUSE_USE_DEVICE into OMP_CLAUSE_USE_DEVICE_PTR. Adjust all users. From-SVN: r231926
2015-12-22re PR c/69002 (C front end should warn about undefined access to atomic ↵Marek Polacek2-0/+18
structure or union) PR c/69002 * c-typeck.c (build_component_ref): Warn when acessing elements of atomic structures or unions. * gcc.dg/c11-atomic-1.c: Add dg-warnings. * gcc.dg/c11-atomic-4.c: New test. From-SVN: r231902
2015-12-21C and C++ FE: fix source ranges for binary opsDavid Malcolm2-2/+16
gcc/c-family/ChangeLog: * c-common.c (binary_op_error): Convert first param from location_t to rich_location * and use it when emitting an error. * c-common.h (binary_op_error): Convert first param from location_t to rich_location *. gcc/c/ChangeLog: * c-typeck.c: Include "gcc-rich-location.h". (build_binary_op): In the two places that call binary_op_error, create a gcc_rich_location and populate it with the location of the binary op and its two operands. gcc/cp/ChangeLog: * typeck.c (cp_build_binary_op): Update for change in signature of build_binary_op. Use error_at to replace an implicit use of input_location with param "location" in "invalid operands" error. (cp_build_binary_op): Replace an error with an error_at, using "location", rather than implicitly using input_location. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/bad-binary-ops.C: New test case. * gcc.dg/bad-binary-ops.c: New test case. gcc.dg/plugin/diagnostic_plugin_show_trees.c (get_range_for_expr): Remove material copied from gcc-rich-location.c (gcc_rich_location::add_expr): Likewise. From-SVN: r231884
2015-12-17C FE: improvements to ranges of bad return valuesDavid Malcolm3-9/+31
gcc/c/ChangeLog: * c-parser.c (c_parser_statement_after_labels): When calling c_finish_return, Use the return expression's location if it has one, falling back to the location of the first token within it. * c-typeck.c (c_finish_return): When issuing warnings about the incorrect presence/absence of a return value, issue a note showing the declaration of the function. gcc/testsuite/ChangeLog: * gcc.dg/diagnostic-range-bad-return.c: New test case. From-SVN: r231786
2015-12-16Better error recovery for merge-conflict markersDavid Malcolm2-2/+81
gcc/c-family/ChangeLog: * c-common.h (conflict_marker_get_final_tok_kind): New prototype. * c-lex.c (conflict_marker_get_final_tok_kind): New function. gcc/c/ChangeLog: * c-parser.c (struct c_parser): Expand array "tokens_buf" from 2 to 4. (c_parser_peek_nth_token): New function. (c_parser_peek_conflict_marker): New function. (c_parser_error): Detect conflict markers and report them as such. gcc/cp/ChangeLog: * parser.c (cp_lexer_peek_conflict_marker): New function. (cp_parser_error): Detect conflict markers and report them as such. gcc/testsuite/ChangeLog: * c-c++-common/conflict-markers-1.c: New testcase. * c-c++-common/conflict-markers-2.c: Likewise. * c-c++-common/conflict-markers-3.c: Likewise. * c-c++-common/conflict-markers-4.c: Likewise. * c-c++-common/conflict-markers-5.c: Likewise. * c-c++-common/conflict-markers-6.c: Likewise. * c-c++-common/conflict-markers-7.c: Likewise. * c-c++-common/conflict-markers-8.c: Likewise. * c-c++-common/conflict-markers-9.c: Likewise. * c-c++-common/conflict-markers-10.c: Likewise. * c-c++-common/conflict-markers-11.c: Likewise. * g++.dg/conflict-markers-1.C: Likewise. From-SVN: r231712
2015-12-16C FE: fix range of primary-expression in c_parser_postfix_expressionDavid Malcolm2-1/+8
gcc/c/ChangeLog: * c-parser.c (c_parser_postfix_expression): Use EXPR_LOC_OR_LOC to preserve range information for the primary expression in the call to c_parser_postfix_expression_after_primary. gcc/testsuite/ChangeLog: * gcc.dg/cast-function-1.c (bar): Update column numbers. * gcc.dg/diagnostic-range-bad-called-object.c: New test case. From-SVN: r231709
2015-12-16C FE: use correct location range for static assertionsDavid Malcolm2-1/+8
gcc/c/ChangeLog: * c-parser.c (c_parser_static_assert_declaration_no_semi): Use the expression location, falling back on the first token location, rather than always using the latter. gcc/testsuite/ChangeLog: * gcc.dg/diagnostic-range-static-assert.c: New test case. From-SVN: r231704
2015-12-16re PR c/64637 (Incorrect location for -Wunused-value warnings in for-loop)Marek Polacek2-1/+7
PR c/64637 * c-typeck.c (c_process_expr_stmt): Use location of the expression if available. * gcc.dg/pr64637.c: New test. From-SVN: r231700
2015-12-15re PR c/68907 (bogus warning: right-hand operand of comma expression has no ↵Marek Polacek2-0/+7
effect on an atomic_int preincrement) PR c/68907 * c-typeck.c (build_atomic_assign): Set TREE_NO_WARNING on an artificial decl. * gcc.dg/pr68907.c: New test. From-SVN: r231656
2015-12-09c-omp.c (c_finish_oacc_wait): Remove add_stmt() call.Chung-Lin Tang1-0/+1
2015-12-09 Chung-Lin Tang <cltang@codesourcery.com> * c-family/c-omp.c (c_finish_oacc_wait): Remove add_stmt() call. * c/c-parser.c (c_parser_oacc_wait): Add add_stmt() call. * cp/parser.c (cp_parser_oacc_wait): Add finish_expr_stmt() call. From-SVN: r231441
2015-12-08C: fix uninitialized ranges for __alignof__David Malcolm2-5/+17
gcc/c/ChangeLog: * c-parser.c (c_parser_alignof_expression): Capture location of closing parenthesis (if any), or of end of unary expression, and use it to build a src_range for the expression. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-expressions-1.c (test_alignof): New test function. From-SVN: r231415
2015-12-08PR c/68757: fix uninitialized src_range for various builtinsDavid Malcolm2-11/+40
gcc/c/ChangeLog: PR c/68757 * c-parser.c (c_parser_get_builtin_args): Add "out_close_paren_loc" param, and write back to it. (c_parser_postfix_expression): Capture the closing parenthesis location for RID_CHOOSE_EXPR, RID_BUILTIN_CALL_WITH_STATIC_CHAIN, RID_BUILTIN_COMPLEX, RID_BUILTIN_SHUFFLE and use it to set the source range for such expressions; within RID_BUILTIN_COMPLEX set the underlying location. gcc/testsuite/ChangeLog: PR c/68757 * gcc.dg/plugin/diagnostic-test-expressions-1.c (test_builtin_choose_expr): New test function. (test_builtin_call_with_static_chain): Likewise. (test_builtin_complex): Likewise. (test_builtin_shuffle): Likewise. From-SVN: r231414
2015-12-07re PR c/68668 (bogus error: invalid use of array with unspecified bounds)Marek Polacek2-0/+13
PR c/68668 * c-decl.c (grokdeclarator): If ORIG_QUAL_INDIRECT is indirect, use TREE_TYPE of ORIG_QUAL_TYPE, otherwise decrement ORIG_QUAL_INDIRECT. * gcc.dg/pr68668.c: New test. From-SVN: r231374
2015-12-04c-tree.h (c_build_va_arg): Adjust prototype.Eric Botcazou4-6/+22
* c-tree.h (c_build_va_arg): Adjust prototype. * c-parser.c (c_parser_postfix_expression): Adjust call to above. * c-typeck.c (c_build_va_arg): Rename LOC parameter to LOC2, add LOC1 parameter, adjust throughout and issue an error if EXPR is a component with reverse storage order. From-SVN: r231250
2015-12-02Define c_fully_fold separately for C and C++.Jason Merrill4-1/+601
gcc/c-family/ * c-common.c (c_disable_warnings, c_enable_warnings, c_fully_fold) (c_fully_fold_internal, decl_constant_value_for_optimization): Move to c/c-fold.c. * c-common.h: Don't declare decl_constant_value_for_optimization. gcc/c/ * c-fold.c (c_disable_warnings, c_enable_warnings, c_fully_fold) (c_fully_fold_internal, decl_constant_value_for_optimization): Move from c-common.c. * c-tree.h: Declare decl_constant_value_for_optimization. * Make-lang.in (C_AND_OBJC_OBJS): Add c-fold.o. gcc/cp/ * cp-gimplify.c (c_fully_fold): Define. From-SVN: r231196
2015-12-02Fix TYPE_MAIN_VARIANT construction for arrays of qualified typedefs (PR ↵Joseph Myers3-21/+57
c/68162). PR c/68162 reports a spurious warning about incompatible types involving arrays of const double, constructed in one place using a typedef for const double and in another place literally using const double. The problem is that the array of the typedef was incorrectly constructed without a TYPE_MAIN_VARIANT being an array of unqualified elements as it should be (though it seems some more recent change resulted in this producing incorrect diagnostics, likely the support for C++-style handling of arrays of qualified type). This patch fixes the logic in grokdeclarator to determine first_non_attr_kind, which is used to determine whether it is necessary to use the TYPE_MAIN_VARIANT of the type in the declaration specifiers. However, fixing that logic introduces a failure of gcc.dg/debug/dwarf2/pr47939-4.c, a test introduced along with first_non_attr_kind. Thus, it is necessary to track the original qualified typedef when qualifying an array type, to use it rather than a newly-constructed type, to avoid regressing regarding typedef names in debug info. This is done along lines I suggested in <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47939#c6>: track the original type and the number of levels of array indirection at which it appears, and, in possibly affected cases, pass extra arguments to c_build_qualified_type (with default arguments to avoid needing to pass those extra arguments explicitly everywhere). Given Richard's recent fix to dwarf2out.c, this allows the C bug to be fixed without causing debug information regressions. Bootstrapped with no regressions on x86_64-pc-linux-gnu. gcc/c: PR c/68162 * c-decl.c (grokdeclarator): Set first_non_attr_kind before following link from declarator to next declarator. Track original qualified type and pass it to c_build_qualified_type. * c-typeck.c (c_build_qualified_type): Add arguments orig_qual_type and orig_qual_indirect. gcc/c-family: PR c/68162 * c-common.h (c_build_qualified_type): Add extra default arguments. gcc/cp: PR c/68162 * tree.c (c_build_qualified_type): Add extra arguments. gcc/testsuite: PR c/68162 * gcc.dg/pr68162-1.c: New test. From-SVN: r231194
2015-12-02Some OpenACC host_data cleanupThomas Schwinge2-6/+11
gcc/c/ * c-parser.c (c_parser_omp_clause_name) (c_parser_oacc_all_clauses): Alphabetical sorting. gcc/cp/ * parser.c (cp_parser_omp_clause_name) (cp_parser_oacc_all_clauses): Alphabetical sorting. * pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_USE_DEVICE. gcc/testsuite/ * c-c++-common/goacc/host_data-5.c: New file. * c-c++-common/goacc/host_data-6.c: Likewise. * gfortran.dg/goacc/coarray.f95: XFAIL. * gfortran.dg/goacc/coarray_2.f90: Adjust dg-excess-errors directive. * gfortran.dg/goacc/host_data-tree.f95: Remove dg-prune-output directive. libgomp/ * testsuite/libgomp.oacc-c-c++-common/host_data-2.c: Restrict to target openacc_nvidia_accel_selected. * testsuite/libgomp.oacc-c-c++-common/host_data-4.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/host_data-5.c: Likewise. * testsuite/libgomp.oacc-c-c++-common/host_data-3.c: Remove file. * testsuite/libgomp.oacc-c-c++-common/host_data-6.c: Remove file. Co-Authored-By: James Norris <James_Norris@mentor.com> Co-Authored-By: Julian Brown <julian@codesourcery.com> From-SVN: r231184
2015-12-02re PR c/68533 (bogus location for "warning: ‘struct s3’ declared inside ↵Jakub Jelinek2-6/+13
parameter list will not be visible outside of this definition or declaration") PR c/68533 * c-decl.c (get_parm_info): Use b->locus instead of input_location for diagnostics. * gcc.dg/pr68533.c: New test. From-SVN: r231147
2015-12-01OpenACC host_data support.Julian Brown4-0/+76
gcc/ * gimple-pretty-print.c (dump_gimple_omp_target): Add host_data support. * gimple.h (gf_mask): Add GF_OMP_TARGET_KIND_OACC_HOST_DATA. (is_gimple_omp_oacc): Add support for above. * gimplify.c (omp_region_type): Add ORT_ACC_HOST_DATA. (omp_notice_variable): Diagnose undefined implicit uses of use_device variables in offloaded regions. (gimplify_scan_omp_clauses): Add host_data, use_device support. Diagnose undefined mapping of use_device variables in OpenACC clauses. (gimplify_omp_workshare): Add host_data support. (gimplify_expr): Likewise. * omp-builtins.def (BUILT_IN_GOACC_HOST_DATA): New. * omp-low.c (lookup_decl_in_outer_ctx) (maybe_lookup_decl_in_outer_ctx): Add optional argument to skip host_data regions. (scan_sharing_clauses): Support use_device. (check_omp_nesting_restrictions): Support host_data. (expand_omp_target): Support host_data. (lower_omp_target): Skip over outer host_data regions when looking up decls. Support use_device. (make_gimple_omp_edges): Support host_data. * tree-nested.c (convert_nonlocal_omp_clauses): Add use_device clause. gcc/c/ * c-parser.c (c_parser_omp_clause_name): Add use_device support. (c_parser_oacc_clause_use_device): New function. (c_parser_oacc_all_clauses): Add use_device support. (OACC_HOST_DATA_CLAUSE_MASK): New macro. (c_parser_oacc_host_data): New function. (c_parser_omp_construct): Add host_data support. * c-tree.h (c_finish_oacc_host_data): Add prototype. * c-typeck.c (c_finish_oacc_host_data): New function. (c_finish_omp_clauses): Add use_device support. gcc/cp/ * cp-tree.h (finish_oacc_host_data): Add prototype. * parser.c (cp_parser_omp_clause_name): Add use_device support. (cp_parser_oacc_all_clauses): Add use_device support. (OACC_HOST_DATA_CLAUSE_MASK): New macro. (cp_parser_oacc_host_data): New function. (cp_parser_omp_construct): Add host_data support. (cp_parser_pragma): Add host_data support. * semantics.c (finish_omp_clauses): Add use_device support. (finish_oacc_host_data): New function. gcc/c-family/ * c-pragma.c (oacc_pragmas): Add PRAGMA_OACC_HOST_DATA. * c-pragma.h (pragma_kind): Add PRAGMA_OACC_HOST_DATA. (pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_USE_DEVICE. libgomp/ * oacc-parallel.c (GOACC_host_data): New function. * libgomp.map (GOACC_host_data): Add to GOACC_2.0.1. * testsuite/libgomp.oacc-c-c++-common/host_data-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/host_data-2.c: New test. * testsuite/libgomp.oacc-c-c++-common/host_data-3.c: New test. * testsuite/libgomp.oacc-c-c++-common/host_data-4.c: New test. * testsuite/libgomp.oacc-c-c++-common/host_data-5.c: New test. * testsuite/libgomp.oacc-c-c++-common/host_data-6.c: New test. Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com> Co-Authored-By: James Norris <James_Norris@mentor.com> From-SVN: r231118
2015-11-29re PR c/67106 (ICE: verify_type failed: type variant differs by ↵Jan Hubicka2-1/+7
TYPE_PACKED. with -g -fpack-struct) PR c/67106 * gcc.c-torture/compile/pr67106.c: New testcase. * c-decl.c: Set TYPE_PACKED in variants. From-SVN: r231049
2015-11-27Fix memory leak in cilkMartin Liska2-27/+32
PR c++/68312 * c-array-notation.c (fix_builtin_array_notation_fn): Use release_vec_vec instead of vec::release. (build_array_notation_expr): Likewise. (fix_conditional_array_notations_1): Likewise. (fix_array_notation_expr): Likewise. (fix_array_notation_call_expr): Likewise. PR c++/68312 * cp-array-notation.c (expand_sec_reduce_builtin): Likewise. (create_array_refs): Replace argument with const reference. (expand_an_in_modify_expr): Likewise. (cp_expand_cond_array_notations): Likewise. (expand_unary_array_notation_exprs): Likewise. PR c++/68312 * array-notation-common.c (cilkplus_extract_an_triplets): Release vector of vectors. * cilk.c (gimplify_cilk_spawn): Free allocated memory. PR c++/68312 * vec.h (release_vec_vec): New function. From-SVN: r231001
2015-11-27re PR c/63326 (whether a #pragma is a statement depends on the type of pragma)Jakub Jelinek2-5/+17
PR c/63326 * c-parser.c (c_parser_compound_statement_nostart): If last_label is true, use pragma_stmt instead of pragma_compound as second c_parser_pragma argument. (c_parser_omp_ordered, c_parser_omp_target_update, c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Pass false as second argument to c_parser_skip_to_pragma_eol after diagnosing standalone directives used in pragma_stmt context. * parser.c (cp_parser_statement): Clear in_compound after labels. * gcc.dg/gomp/barrier-2.c (f2): Expect another error after label. * c-c++-common/gomp/pr63326.c: New test. * testsuite/libgomp.c/cancel-parallel-2.c (foo): Add semicolon in between case label and OpenMP standalone directives. * testsuite/libgomp.c++/cancel-parallel-2.C (foo): Likewise. From-SVN: r230999
2015-11-24c-parser.c (c_parser_oacc_declare): Replace "ifdef ENABLE_OFFLOADING" with ↵Ilya Verbin2-6/+12
"if (ENABLE_OFFLOADING)". gcc/c/ * c-parser.c (c_parser_oacc_declare): Replace "ifdef ENABLE_OFFLOADING" with "if (ENABLE_OFFLOADING)". gcc/cp/ * parser.c (cp_parser_oacc_declare): replace "ifdef enable_offloading" with "if (enable_offloading)". From-SVN: r230842
2015-11-23Fix PR objc/68438 (uninitialized source ranges)David Malcolm2-3/+21
gcc/c/ChangeLog: PR objc/68438 * c-parser.c (c_parser_postfix_expression): Set up source ranges for various Objective-C constructs: Class.name syntax, @selector(), @protocol(), @encode(), and [] message syntax. gcc/testsuite/ChangeLog: PR objc/68438 * objc.dg/plugin: New subdirectory. * objc.dg/plugin/diagnostic-test-expressions-1.m: New test file. * objc.dg/plugin/plugin.exp: New file, based on gcc.dg/plugin/plugin.exp. From-SVN: r230775
2015-11-20PR 62314: add ability to add fixit-hints to a diagnosticDavid Malcolm2-0/+47
This is the combination of two patches: [PATCH 01/02] PR/62314: add ability to add fixit-hints [PATCH 02/02] C FE: add fix-it hint for . vs -> gcc/ChangeLog: PR 62314 * diagnostic-show-locus.c (colorizer::set_fixit_hint): New. (class layout): Update comment (layout::print_any_fixits): New method. (layout::move_to_column): New method. (diagnostic_show_locus): Add call to layout.print_any_fixits. gcc/c/ChangeLog: PR 62314 * c-typeck.c (should_suggest_deref_p): New function. (build_component_ref): Special-case POINTER_TYPE when generating a "not a structure of union" error message, and suggest a "->" rather than a ".", providing a fix-it hint. gcc/testsuite/ChangeLog: PR 62314 * gcc.dg/fixits.c: New file. * gcc.dg/plugin/diagnostic-test-show-locus-ascii-bw.c (test_fixit_insert): New. (test_fixit_remove): New. (test_fixit_replace): New. * gcc.dg/plugin/diagnostic-test-show-locus-ascii-color.c (test_fixit_insert): New. (test_fixit_remove): New. (test_fixit_replace): New. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (test_show_locus): Add tests of rendering fixit hints. libcpp/ChangeLog: PR 62314 * include/line-map.h (source_range::intersects_line_p): New method. (rich_location::~rich_location): New. (rich_location::add_fixit_insert): New method. (rich_location::add_fixit_remove): New method. (rich_location::add_fixit_replace): New method. (rich_location::get_num_fixit_hints): New accessor. (rich_location::get_fixit_hint): New accessor. (rich_location::MAX_FIXIT_HINTS): New constant. (rich_location::m_num_fixit_hints): New field. (rich_location::m_fixit_hints): New field. (class fixit_hint): New class. (class fixit_insert): New class. (class fixit_remove): New class. (class fixit_replace): New class. * line-map.c (source_range::intersects_line_p): New method. (rich_location::rich_location): Add initialization of m_num_fixit_hints to both ctors. (rich_location::~rich_location): New. (rich_location::add_fixit_insert): New method. (rich_location::add_fixit_remove): New method. (rich_location::add_fixit_replace): New method. (fixit_insert::fixit_insert): New. (fixit_insert::~fixit_insert): New. (fixit_insert::affects_line_p): New. (fixit_remove::fixit_remove): New. (fixit_remove::affects_line_p): New. (fixit_replace::fixit_replace): New. (fixit_replace::~fixit_replace): New. (fixit_replace::affects_line_p): New. From-SVN: r230674
2015-11-20C++ FE: offer suggestions for misspelled field namesDavid Malcolm2-27/+6
gcc/c/ChangeLog: * c-typeck.c (lookup_field_fuzzy): Move determination of closest candidate into a new function, find_closest_identifier. gcc/cp/ChangeLog: * cp-tree.h (lookup_member_fuzzy): New decl. * search.c: Include spellcheck.h. (class lookup_field_fuzzy_info): New class. (lookup_field_fuzzy_info::fuzzy_lookup_fnfields): New. (lookup_field_fuzzy_info::fuzzy_lookup_field): New. (lookup_field_fuzzy_r): New. (lookup_member_fuzzy): New. * typeck.c (finish_class_member_access_expr): When issuing a "has no member named" error, call lookup_member_fuzzy, and offer any result as a suggestion. gcc/ChangeLog: * spellcheck-tree.c (find_closest_identifier): New function, taken from c/c-typeck.c:lookup_field_fuzzy, with NULL corrected to NULL_TREE in two places. * spellcheck.h (find_closest_identifier): New decl. gcc/testsuite/ChangeLog: * g++.dg/spellcheck-fields.C: New file. From-SVN: r230638
2015-11-19re PR c/68412 (ICE with -Wall -Wextra in fold_binary_loc())Marek Polacek2-1/+28
PR c/68412 * c-typeck.c (parser_build_binary_op): Properly handle C_MAYBE_CONST_EXPR before calling warn_tautological_cmp. * gcc.dg/pr68412-2.c: New test. * gcc.dg/pr68412.c: New test. From-SVN: r230627
2015-11-17Fix uninitialized src_range values for c_exprDavid Malcolm2-39/+77
gcc/c/ChangeLog: * c-parser.c (set_c_expr_source_range): Bulletproof both overloaded implementations against NULL expr->value. (c_parser_braced_init): Set src_range for "ret" to a sane pair of values. (c_parser_unary_expression): Likewise when handling addresses of labels. (c_parser_postfix_expression): Likewise for statement expressions, for __FUNCTION__, __PRETTY_FUNCTION_ and __func__ keywords, for __builtin_va_arg, and for __builtin_offset_of. (c_parser_postfix_expression_after_paren_type): Initialize expr's src_range using the range of the braced initializer. (c_parser_transaction_expression): Set src_range for "ret" to a sane pair of values. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic-test-expressions-1.c (vector): New macro. (test_braced_init): New function. (test_statement_expression): New function. (test_address_of_label): New function. (test_transaction_expressions): New function. (test_keywords): New function. (test_builtin_va_arg): New function. (test_builtin_offsetof): New function. * lib/multiline.exp (_build_multiline_regex): Escape braces. From-SVN: r230497