- 21 Nov, 2017 2 commits
-
-
This patch extends the C frontend's "knowledge" of the C stdlib within get_c_name_hint to cover some more macros and functions, covering a case reported in PR c/81404 ("INT_MAX"), so that rather than printing: t.c:5:12: error: 'INT_MAX' undeclared here (not in a function); did you mean '__INT_MAX__'? int test = INT_MAX; ^~~~~~~ __INT_MAX__ we instead print: t.c:5:12: error: 'INT_MAX' undeclared here (not in a function) int test = INT_MAX; ^~~~~~~ t.c:5:12: note: 'INT_MAX' is defined in header '<limits.h>'; did you forget to '#include <limits.h>'? t.c:1:1: +#include <limits.h> t.c:5:12: int test = INT_MAX; ^~~~~~~ It also adds generalizes some of the code for this (and for the "std::" namespace hints in the C++ frontend), moving it to a new c-family/known-headers.cc and .h, and introducing a class known_headers. This currently just works by scanning a hardcoded array of known name/header associations, but perhaps in the future could be turned into some kind of symbol database so that the compiler could record API uses and use that to offer suggestions e.g. foo.cc: error: 'myapi::foo' was not declared in this scope foo.cc: note: 'myapi::foo" was declared in header 'myapi/private.h' (included via 'myapi/public.h') when compiling 'bar.cc'; did you forget to '#include "myapi/public.h"'? or somesuch. In any case, moving this to a class gives an easier way to locate the hardcoded knowledge about the stdlib. The patch also adds similar code to the C++ frontend covering unqualified names in the standard library, so that rather than just e.g.: t.cc:19:13: error: 'NULL' was not declared in this scope void *ptr = NULL; ^~~~ we can emit: t.cc:19:13: error: 'NULL' was not declared in this scope void *ptr = NULL; ^~~~ t.cc:19:13: note: 'NULL' is defined in header '<cstddef>'; did you forget to '#include <cstddef>'? t.cc:1:1: +#include <cstddef> t.cc:19:13: void *ptr = NULL; ^~~~ (Also XFAIL for PR c++/80567 added for the C++ testcase; this is a separate pre-existing bug exposed by the testcase for PR 81404). gcc/ChangeLog: PR c/81404 * Makefile.in (C_COMMON_OBJS): Add c-family/known-headers.o. gcc/c-family/ChangeLog: PR c/81404 * known-headers.cc: New file, based on material from c/c-decl.c. (suggest_missing_header): Copied as-is. (get_stdlib_header_for_name): New, based on get_c_name_hint but heavily edited to add C++ support. Add some knowledge about <limits.h>, <stdint.h>, and <wchar.h>. * known-headers.h: Likewise. gcc/c/ChangeLog: PR c/81404 * c-decl.c: Include "c-family/known-headers.h". (get_c_name_hint): Rename to get_stdlib_header_for_name and move to known-headers.cc. (class suggest_missing_header): Move to known-header.h. (lookup_name_fuzzy): Call get_c_stdlib_header_for_name rather than get_c_name_hint. gcc/cp/ChangeLog: PR c/81404 * name-lookup.c: Include "c-family/known-headers.h" (lookup_name_fuzzy): Call get_cp_stdlib_header_for_name and potentially return a new suggest_missing_header hint. gcc/testsuite/ChangeLog: PR c/81404 * g++.dg/spellcheck-stdlib.C: New. * gcc.dg/spellcheck-stdlib.c (test_INT_MAX): New. From-SVN: r254980
David Malcolm committed -
The C frontend already "knows" about many common functions in the C standard library: test.c: In function 'test': test.c:3:3: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] printf ("hello world\n"); ^~~~~~ test.c:3:3: warning: incompatible implicit declaration of built-in function 'printf' test.c:3:3: note: include '<stdio.h>' or provide a declaration of 'printf' and which header file they are in. However it doesn't know about various types and macros: test.c:1:13: error: 'NULL' undeclared here (not in a function) void *ptr = NULL; ^~~~ This patch uses the name_hint/deferred_diagnostic machinery to add hints for missing C standard library headers for some of the most common type and macro names. For example, the above becomes: test.c:1:13: error: 'NULL' undeclared here (not in a function) void *ptr = NULL; ^~~~ test.c:1:13: note: 'NULL' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'? gcc/c/ChangeLog: * c-decl.c (get_c_name_hint): New function. (class suggest_missing_header): New class. (lookup_name_fuzzy): Call get_c_name_hint and use it to suggest missing headers to the user. gcc/testsuite/ChangeLog: * gcc.dg/spellcheck-stdlib.c: New test case. From-SVN: r254979
David Malcolm committed
-
- 20 Nov, 2017 1 commit
-
-
In various places we use lookup_name_fuzzy to provide a hint, and can report messages of the form: error: unknown foo named 'bar' or: error: unknown foo named 'bar'; did you mean 'SUGGESTION? This patch provides a way for lookup_name_fuzzy to provide both the suggestion above, and (optionally) additional hints that can be printed e.g. note: did you forget to include <SOME_HEADER.h>? This patch provides the mechanism and ports existing users of lookup_name_fuzzy to the new return type. There are no uses of such hints in this patch, but followup patches provide various front-end specific uses of this. gcc/c-family/ChangeLog: * c-common.h (enum lookup_name_fuzzy_kind): Move to name-hint.h. (lookup_name_fuzzy): Likewise. Convert return type from const char * to name_hint. Add location_t param. * name-hint.h: New header. gcc/c/ChangeLog: * c-decl.c: Define INCLUDE_UNIQUE_PTR before including system.h. Include "c-family/name-hint.h" (implicit_decl_warning): Convert "hint" from const char * to name_hint. Pass location to lookup_name_fuzzy. Suppress any deferred diagnostic if the warning was not printed. (undeclared_variable): Likewise for "guessed_id". (lookup_name_fuzzy): Convert return type from const char * to name_hint. Add location_t param. * c-parser.c: Define INCLUDE_UNIQUE_PTR before including system.h. Include "c-family/name-hint.h" (c_parser_declaration_or_fndef): Convert "hint" from const char * to name_hint. Pass location to lookup_name_fuzzy. (c_parser_parameter_declaration): Likewise. gcc/cp/ChangeLog: * name-lookup.c: Define INCLUDE_UNIQUE_PTR before including system.h. Include "c-family/name-hint.h" (suggest_alternatives_for): Convert "fuzzy_name" from const char * to name_hint, and rename to "hint". Pass location to lookup_name_fuzzy. (lookup_name_fuzzy): Convert return type from const char * to name_hint. Add location_t param. * parser.c: Define INCLUDE_UNIQUE_PTR before including system.h. Include "c-family/name-hint.h" (cp_parser_diagnose_invalid_type_name): Convert "suggestion" from const char * to name_hint, and rename to "hint". Pass location to lookup_name_fuzzy. From-SVN: r254963
David Malcolm committed
-
- 19 Nov, 2017 1 commit
-
-
PR c/66618 PR c/69960 c-family/ * c-common.h (c_fully_fold): Add LVAL argument defaulted to false. c/ * c-parser.c (c_parser_omp_atomic): Pass true as LVAL to c_fully_fold where needed. * c-typeck.c (build_unary_op, build_modify_expr, build_asm_expr, handle_omp_array_sections): Likewise. (digest_init): Don't call decl_constant_value_for_optimization. * c-tree.h (decl_constant_value_for_optimization): Removed. * c-fold.c (c_fold_array_ref): New function. (c_fully_fold_internal): Add LVAL argument, propagate it through recursive calls. For VAR_P call decl_constant_value and unshare if not LVAL and either optimizing or IN_INIT. Remove decl_constant_value_for_optimization calls. If IN_INIT and not LVAL, fold ARRAY_REF with STRING_CST and INTEGER_CST operands. (c_fully_fold): Add LVAL argument, pass it through to c_fully_fold_internal. (decl_constant_value_for_optimization): Removed. cp/ * cp-gimplify.c (c_fully_fold): Add LVAL argument, call cp_fold_maybe_rvalue instead of cp_fold_rvalue and pass it !LVAL. testsuite/ * gcc.dg/pr69960.c: New test. * gcc.dg/pr66618.c: New test. * gcc.dg/pr66618-2.c: New test. From-SVN: r254930
Jakub Jelinek committed
-
- 15 Nov, 2017 1 commit
-
-
Various implementations of C99/C11 <tgmath.h> have the property that their macro expansions contain many copies of the macro arguments, so resulting in exponential blowup of the size of macro expansions where a call to such a macro contains other such calls in the macro arguments. This patch adds a (C-only) language feature __builtin_tgmath designed to avoid this problem by implementing the <tgmath.h> function selection rules directly in the compiler. The effect is that type-generic macros can be defined simply as #define pow(a, b) __builtin_tgmath (powf, pow, powl, \ cpowf, cpow, cpowl, a, b) as in the example added to the manual, with each macro argument expanded exactly once. The details of __builtin_tgmath are as described in the manual. This is C-only since C++ uses function overloading and just defines <ctgmath> to include <ccomplex> and <cmath>. __builtin_tgmath handles C99/C11 type-generic macros, and _FloatN, _FloatNx and decimal floating-point types (following the proposed resolution to the floating-point TS DR#9 that makes the rules for finding a common type from arguments to a type-generic macro follow the usual arithmetic conversions after adjustment of integer arguments to _Decimal64 or double - or to _Complex double in the case of GNU complex integer arguments). Type-generic macros for functions from TS 18661 that round their results to a narrower type are handled, but there are still some unresolved questions regarding such macros so further changes in that regard may be needed in future. The current implementation follows an older version of the DR#13 resolution (allowing a function for a wide-enough argument type to be selected if no exactly-matching function is available), but with appropriate calls to __builtin_tgmath is still fully compatible with the latest version of the resolution (not yet in the DR log), and allowing such not-exactly-matching argument types to be chosen in that case avoids needing another special case to treat integers as _Float64 instead of double in certain cases. Regarding other possible language/library features, not currently implemented in GCC: * Imaginary types could be naturally supported by allowing cases where the type-generic type is an imaginary type T and arguments or return types may be T (as at present), or the corresponding real type to T (as at present), or (new) the corresponding real type if T is real or imaginary but T if T is complex. (tgmath.h would need a series of functions such as static inline _Imaginary double __sin_imag (_Imaginary double __x) { return _Imaginary_I * sinh (__imag__ __x); } to be used in __builtin_tgmath calls.) * __builtin_tgmath would use the constant rounding direction in the presence of support for the FENV_ROUND / FENV_DEC_ROUND pragmas. Support for those would also require a new __builtin_<something> to cause a non-type-generic call to use the constant rounding direction (it seems cleaner to add a new __builtin_<something> when required than to make __builtin_tgmath handle a non-type-generic case with only one function argument). * TS 18661-5 __STDC_TGMATH_OPERATOR_EVALUATION__ would require new __builtin_<something> that evaluates with excess range and precision like arithmetic operators do. * The proposed C bindings for IEEE 754-2018 augmented arithmetic operations involve struct return types. As currently implemented __builtin_tgmath does not handle those, but support could be added. There are many error cases that the implementation diagnoses. I've tried to ensure reasonable error messages for erroneous uses of __builtin_tgmath, but the errors for erroneous uses of the resulting type-generic macros (that is, when the non-function arguments have inappropriate types) are more important as they are more likely to be seen by users. GCC's own tgmath.h, as used for some targets, is updated in this patch. I've tested those changes minimally, via adjusting gcc.dg/c99-tgmath-* locally to use that tgmath.h version. I've also run the glibc testsuite (which has much more thorough tests of correctness of tgmath.h function selection) with a glibc patch to use __builtin_tgmath in glibc's tgmath.h. Bootstrapped with no regressions on x86_64-pc-linux-gnu. PR c/81156 gcc: * doc/extend.texi (Other Builtins): Document __builtin_tgmath. * ginclude/tgmath.h (__tg_cplx, __tg_ldbl, __tg_dbl, __tg_choose) (__tg_choose_2, __tg_choose_3, __TGMATH_REAL_1_2) (__TGMATH_REAL_2_3): Remove macros. (__TGMATH_CPLX, __TGMATH_CPLX_2, __TGMATH_REAL, __TGMATH_REAL_2) (__TGMATH_REAL_3, __TGMATH_CPLX_ONLY): Define using __builtin_tgmath. (frexp, ldexp, nexttoward, scalbn, scalbln): Define using __TGMATH_REAL_2. (remquo): Define using __TGMATH_REAL_3. gcc/c: * c-parser.c (check_tgmath_function): New function. (enum tgmath_parm_kind): New enum. (c_parser_postfix_expression): Handle __builtin_tgmath. gcc/c-family: * c-common.c (c_common_reswords): Add __builtin_tgmath. * c-common.h (enum rid): Add RID_BUILTIN_TGMATH. gcc/testsuite: * gcc.dg/builtin-tgmath-1.c, gcc.dg/builtin-tgmath-2.c, gcc.dg/builtin-tgmath-err-1.c, gcc.dg/builtin-tgmath-err-2.c, gcc.dg/dfp/builtin-tgmath-dfp-err.c, gcc.dg/dfp/builtin-tgmath-dfp.c: New tests. From-SVN: r254749
Joseph Myers committed
-
- 31 Oct, 2017 1 commit
-
-
Adding a fix-it hint currently involves changing e.g.: error_at (token->location, "unknown type name %qE; did you mean %qs?", token->value, hint); to: gcc_rich_location richloc (token->location); richloc.add_fixit_replace (hint); error_at_rich_loc (&richloc, "unknown type name %qE; did you mean %qs?", token->value, hint); to make the change from taking a location_t to a rich_location *. This patch renames the "*_at_rich_loc" diagnostic entrypoints to use the same function names for rich_location * as for location_t, via overloading, to simplify the above change to just changing from: error_at (token->location, "unknown type name %qE; did you mean %qs?", token->value, hint); to: gcc_rich_location richloc (token->location); richloc.add_fixit_replace (hint); error_at (&richloc, "unknown type name %qE; did you mean %qs?", token->value, hint); thus saving space (and typing) and usually avoiding the need to reindent the "error_at" invocation. With this change, 0 is no longer acceptable as a location_t to these entrypoints, as e.g.: ../../src/gcc/auto-profile.c:855:37: error: call of overloaded 'inform(int, const char [18])' is ambiguous inform (0, "Not expected TAG."); ^ In file included from ../../src/gcc/auto-profile.c:35:0: ../../src/gcc/diagnostic-core.h:88:13: note: candidate: 'void inform(location_t, const char*, ...)' extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); ^~~~~~ ../../src/gcc/diagnostic-core.h:89:13: note: candidate: 'void inform(rich_location*, const char*, ...)' extern void inform (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); ^~~~~~ Such locations now need to be spelled out as UNKNOWN_LOCATION, rather than 0. I considered making the API take a rich_location & rather than a rich_location *, but doing so would mean replacing diagnostic_set_info and diagnostic_set_info_translated with a constructor for diagnostic_info, which was a more invasive change. Maybe in the future. gcc/ChangeLog: * auto-profile.c (autofdo_source_profile::read): Use UNKNOWN_LOCATION rather than 0. * diagnostic-core.h (warning_at_rich_loc): Rename to... (warning_at): ...this overload. (warning_at_rich_loc_n): Rename to... (warning_n): ...this overload. (error_at_rich_loc): Rename to... (error_at): ...this overload. (pedwarn_at_rich_loc): Rename to... (pedwarn): ...this overload. (permerror_at_rich_loc): Rename to... (permerror): ...this overload. (inform_at_rich_loc): Rename to... (inform): ...this overload. * diagnostic.c: (diagnostic_n_impl): Delete location_t-based decl. (diagnostic_n_impl_richloc): Rename to... (diagnostic_n_impl): ...this rich_location *-based decl. (inform_at_rich_loc): Rename to... (inform): ...this, and add an assertion. (inform_n): Update for removal of location_t-based diagnostic_n_impl. (warning_at_rich_loc): Rename to... (warning_at): ...this, and add an assertion. (warning_at_rich_loc_n): Rename to... (warning_n): ...this, and add an assertion. (warning_n): Update location_t-based implementation for removal of location_t-based diagnostic_n_impl. (pedwarn_at_rich_loc): Rename to... (pedwarn): ...this, and add an assertion. (permerror_at_rich_loc): Rename to... (permerror): ...this, and add an assertion. (error_n): Update for removal of location_t-based diagnostic_n_impl. (error_at_rich_loc): Rename to... (error_at): ...this, and add an assertion. * gcc.c (do_spec_1): Use UNKNOWN_LOCATION rather than 0. (driver::do_spec_on_infiles): Likewise. * substring-locations.c (format_warning_va): Update for renaming of inform_at_rich_loc. gcc/c-family/ChangeLog: * c-common.c (binary_op_error): Update for renaming of error_at_rich_loc. (c_parse_error): Likewise. * c-warn.c (warn_logical_not_parentheses): Likewise for renaming of inform_at_rich_loc. (warn_for_restrict): Likewise for renaming of warning_at_rich_loc_n. gcc/c/ChangeLog: * c-decl.c (implicit_decl_warning): Update for renaming of pedwarn_at_rich_loc and warning_at_rich_loc. (implicitly_declare): Likewise for renaming of inform_at_rich_loc. (undeclared_variable): Likewise for renaming of error_at_rich_loc. * c-parser.c (c_parser_declaration_or_fndef): Likewise. (c_parser_struct_or_union_specifier): Likewise for renaming of pedwarn_at_rich_loc. (c_parser_parameter_declaration): Likewise for renaming of error_at_rich_loc. * c-typeck.c (build_component_ref): Likewise. (build_unary_op): Likewise for renaming of inform_at_rich_loc. (pop_init_level): Likewise for renaming of warning_at_rich_loc. (set_init_label): Likewise for renaming of error_at_rich_loc. gcc/cp/ChangeLog: * class.c (explain_non_literal_class): Use UNKNOWN_LOCATION rather than 0. * name-lookup.c (suggest_alternatives_for): Update for renaming of inform_at_rich_loc. (maybe_suggest_missing_header): Likewise. (suggest_alternative_in_explicit_scope): Likewise. * parser.c (cp_parser_diagnose_invalid_type_name): Likewise for renaming of error_at_rich_loc. (cp_parser_string_literal): Likewise. (cp_parser_nested_name_specifier_opt): Likewise. (cp_parser_cast_expression): Likewise for renaming of warning_at_rich_loc. (cp_parser_decl_specifier_seq): Likewise for renaming of error_at_rich_loc and warning_at_rich_loc. (cp_parser_elaborated_type_specifier): Likewise for renaming of pedwarn_at_rich_loc. (cp_parser_cv_qualifier_seq_opt): Likewise for renaming of error_at_rich_loc. (cp_parser_virt_specifier_seq_opt): Likewise. (cp_parser_class_specifier_1): Likewise. (cp_parser_class_head): Likewise. (cp_parser_member_declaration): Likewise for renaming of pedwarn_at_rich_loc, warning_at_rich_loc, and error_at_rich_loc. (cp_parser_enclosed_template_argument_list): Likewise for renaming of error_at_rich_loc. (set_and_check_decl_spec_loc): Likewise. * pt.c (listify): Likewise. * rtti.c (typeid_ok_p): Likewise. * semantics.c (process_outer_var_ref): Use UNKNOWN_LOCATION rather than 0. * typeck.c (access_failure_info::maybe_suggest_accessor): Update for renaming of inform_at_rich_loc. (finish_class_member_access_expr): Likewise for renaming of error_at_rich_loc. gcc/objc/ChangeLog: * objc-gnu-runtime-abi-01.c (objc_gnu_runtime_abi_01_init): Use UNKNOWN_LOCATION rather than 0. gcc/testsuite/ChangeLog: * gcc.dg/plugin/diagnostic_plugin_show_trees.c (show_tree): Update for renaming of error_at_rich_loc and inform_at_rich_loc. * gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (test_show_locus): Likewise for renaming of warning_at_rich_loc. libcpp/ChangeLog: * directives.c (_cpp_handle_directive): Update for renaming of cpp_error_at_richloc to cpp_error_at. * errors.c (cpp_diagnostic_at_richloc): Rename to... (cpp_diagnostic_at): ...this, dropping the location_t-based implementation. (cpp_diagnostic): Update for removal of location_t-based cpp_diagnostic_at. (cpp_error_at): Likewise. (cpp_error_at_richloc): Rename to... (cpp_error_at): ...this, and update for renaming of cpp_diagnostic_at_richloc. * include/cpplib.h (cpp_error_at_richloc): Rename to... (cpp_error_at): ...this. From-SVN: r254280
David Malcolm committed
-
- 30 Oct, 2017 1 commit
-
-
2017-10-30 Richard Biener <rguenther@suse.de> c/ * gimple-parser.c (c_parser_gimple_statement): Parse conditional stmts. * gcc.dg/gimplefe-27.c: New testcase. From-SVN: r254217
Richard Biener committed
-
- 27 Oct, 2017 1 commit
-
-
builtins.c (CASE_MATHFN_FLOATN): New helper macro to add cases for math functions that have _Float<N> and... [gcc] 2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com> * builtins.c (CASE_MATHFN_FLOATN): New helper macro to add cases for math functions that have _Float<N> and _Float<N>X variants. (mathfn_built_in_2): Add support for math functions that have _Float<N> and _Float<N>X variants. (DEF_INTERNAL_FLT_FLOATN_FN): New helper macro. (expand_builtin_mathfn_ternary): Add support for fma with _Float<N> and _Float<N>X variants. (expand_builtin): Likewise. (fold_builtin_3): Likewise. * builtins.def (DEF_EXT_LIB_FLOATN_NX_BUILTINS): New macro to create math function _Float<N> and _Float<N>X variants as external library builtins. (BUILT_IN_COPYSIGN _Float<N> and _Float<N>X variants) Use DEF_EXT_LIB_FLOATN_NX_BUILTINS to make built-in functions using the __builtin_ prefix and if not strict ansi, without the prefix. (BUILT_IN_FABS _Float<N> and _Float<N>X variants): Likewise. (BUILT_IN_FMA _Float<N> and _Float<N>X variants): Likewise. (BUILT_IN_FMAX _Float<N> and _Float<N>X variants): Likewise. (BUILT_IN_FMIN _Float<N> and _Float<N>X variants): Likewise. (BUILT_IN_NAN _Float<N> and _Float<N>X variants): Likewise. (BUILT_IN_SQRT _Float<N> and _Float<N>X variants): Likewise. * builtin-types.def (BT_FN_FLOAT16_FLOAT16_FLOAT16_FLOAT16): New function signatures for fma _Float<N> and _Float<N>X variants. (BT_FN_FLOAT32_FLOAT32_FLOAT32_FLOAT32): Likewise. (BT_FN_FLOAT64_FLOAT64_FLOAT64_FLOAT64): Likewise. (BT_FN_FLOAT128_FLOAT128_FLOAT128_FLOAT128): Likewise. (BT_FN_FLOAT32X_FLOAT32X_FLOAT32X_FLOAT32X): Likewise. (BT_FN_FLOAT64X_FLOAT64X_FLOAT64X_FLOAT64X): Likewise. (BT_FN_FLOAT128X_FLOAT128X_FLOAT128X_FLOAT128X): Likewise. * gencfn-macros.c (print_case_cfn): Add support for math functions that have _Float<N> and _Float<N>X variants. (print_define_operator_list): Likewise. (fltfn_suffixes): Likewise. (main): Likewise. * internal-fn.def (DEF_INTERNAL_FLT_FLOATN_FN): New helper macro for math functions that have _Float<N> and _Float<N>X variants. (SQRT): Add support for sqrt, copysign, fmin and fmax _Float<N> and _Float<N>X variants. (COPYSIGN): Likewise. (FMIN): Likewise. (FMAX): Likewise. * fold-const.c (tree_call_nonnegative_warnv_p): Add support for copysign, fma, fmax, fmin, and sqrt _Float<N> and _Float<N>X variants. (integer_valued_read_call_p): Likewise. * fold-const-call.c (fold_const_call_ss): Likewise. (fold_const_call_sss): Add support for copysign, fmin, and fmax _Float<N> and _Float<N>X variants. (fold_const_call_ssss): Add support for fma _Float<N> and _Float<N>X variants. * gimple-ssa-backprop.c (backprop::process_builtin_call_use): Add support for copysign and fma _Float<N> and _Float<N>X variants. (backprop::process_builtin_call_use): Likewise. * tree-call-cdce.c (can_test_argument_range); Add support for sqrt _Float<N> and _Float<N>X variants. (edom_only_function): Likewise. (get_no_error_domain): Likewise. * tree-ssa-math-opts.c (internal_fn_reciprocal): Likewise. * tree-ssa-reassoc.c (attempt_builtin_copysign): Add support for copysign _Float<N> and _Float<N>X variants. * config/rs6000/rs6000-builtin.def (SQRTF128): Delete, this is now handled by machine independent code. (FMAF128): Likewise. * doc/cpp.texi (Common Predefined Macros): Document defining __FP_FAST_FMAF<N> and __FP_FAST_FMAF<N>X if the backend supports fma _Float<N> and _Float<N>X variants. [gcc/c] 2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com> * c-decl.c (header_for_builtin_fn): Add support for copysign, fma, fmax, fmin, and sqrt _Float<N> and _Float<N>X variants. [gcc/c-family] 2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com> * c-cppbuiltin.c (mode_has_fma): Add support for PowerPC KFmode. (c_cpp_builtins): If a machine has a fast fma _Float<N> and _Float<N>X variant, define __FP_FAST_FMA<N> and/or __FP_FAST_FMA<N>X. [gcc/testsuite] 2017-10-27 Michael Meissner <meissner@linux.vnet.ibm.com> * gcc.target/powerpc/float128-hw.c: Add support for all 4 FMA variants. Check various conversions to/from float128. Check negation. Use {\m...\M} in the tests. * gcc.target/powerpc/float128-hw2.c: New test for implicit _Float128 math functions. * gcc.target/powerpc/float128-hw3.c: New test for strict ansi mode not implicitly adding the _Float128 math functions. * gcc.target/powerpc/float128-fma2.c: Delete, test is no longer valid. * gcc.target/powerpc/float128-sqrt2.c: Likewise. From-SVN: r254168
Michael Meissner committed
-
- 25 Oct, 2017 2 commits
-
-
c_parser_declaration_or_fndef has logic for parsing what might be either a declaration or a function definition. This patch adds a test to detect cases where a semicolon would have terminated the decls as a declaration, where the token that follows would start a new declaration specifier, and updates the error message accordingly, with a fix-it hint. This addresses PR c/7356, fixing the case of a stray token before a #include that previously gave inscrutable output, and improving e.g.: int i int j; from: t.c:2:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int' int j; ^~~ to: t.c:1:6: error: expected ';' before 'int' int i ^ ; int j; ~~~ gcc.dg/noncompile/920923-1.c needs a slight update, as the output for the first line changes from: 920923-1.c:2:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'unsigned' typedef BYTE unsigned char; /* { dg-error "expected" } */ ^~~~~~~~ to: 920923-1.c:2:13: error: expected ';' before 'unsigned' typedef BYTE unsigned char; /* { dg-error "expected" } */ ^~~~~~~~~ ; 920923-1.c:2:1: warning: useless type name in empty declaration typedef BYTE unsigned char; /* { dg-error "expected" } */ ^~~~~~~ The patch also adds a test for PR c/44515 as a baseline. gcc/c/ChangeLog: PR c/7356 * c-parser.c (c_parser_declaration_or_fndef): Detect missing semicolons. gcc/testsuite/ChangeLog: PR c/7356 PR c/44515 * c-c++-common/pr44515.c: New test case. * gcc.dg/pr7356-2.c: New test case. * gcc.dg/pr7356.c: New test case. * gcc.dg/spellcheck-typenames.c: Update the "singed" char "TODO" case to reflect changes to output. * gcc.dg/noncompile/920923-1.c: Add dg-warning to reflect changes to output. From-SVN: r254093
David Malcolm committed -
PR libstdc++/81706 * attribs.c (attribute_value_equal): Use omp_declare_simd_clauses_equal for comparison of OMP_CLAUSEs regardless of flag_openmp{,_simd}. (duplicate_one_attribute, copy_attributes_to_builtin): New functions. * attribs.h (duplicate_one_attribute, copy_attributes_to_builtin): New declarations. * c-decl.c (merge_decls): Copy "omp declare simd" attributes from newdecl to corresponding __builtin_ if any. * decl.c (duplicate_decls): Copy "omp declare simd" attributes from newdecl to corresponding __builtin_ if any. * gcc.target/i386/pr81706.c: New test. * g++.dg/ext/pr81706.C: New test. From-SVN: r254069
Jakub Jelinek committed
-
- 24 Oct, 2017 1 commit
-
-
2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> PR c++/82466 * doc/invoke.texi ([Wbuiltin-declaration-mismatch]): Extend description. /cp 2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> PR c++/82466 * decl.c (duplicate_decls): Warn for built-in functions declared as non-function, use OPT_Wbuiltin_declaration_mismatch. * decl.c (duplicate_decls): Avoid redundant '+' in warning_at. /c 2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> PR c++/82466 * c-decl.c (diagnose_mismatched_decls): Use OPT_Wbuiltin_declaration_mismatch. /testsuite 2017-10-24 Paolo Carlini <paolo.carlini@oracle.com> PR c++/82466 * c-c++-common/Wbuiltin-declaration-mismatch-1.c: New. * c-c++-common/Wno-builtin-declaration-mismatch-1.c: Likewise. * g++.dg/warn/Wbuiltin_declaration_mismatch-1.C: Likewise. * g++.dg/parse/builtin2.C: Adjust. * g++.old-deja/g++.mike/p811.C: Likewise. From-SVN: r254057
Paolo Carlini committed
-
- 20 Oct, 2017 1 commit
-
-
https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf A proposal is to introduce a target independent flag -fcf-protection=[none|branch|return|full] with a semantic to instrument a code to control validness or integrity of control-flow transfers using jump and call instructions. The main goal is to detect and block a possible malware execution through transfer the execution to unknown target address. Implementation could be either software or target based. Any target platforms can provide their implementation for instrumentation under this option. The compiler should instrument any control-flow transfer points in a program (ex. call/jmp/ret) as well as any landing pads, which are targets of control-flow transfers. A new 'nocf_check' attribute is introduced to provide hand tuning support. The attribute directs the compiler to skip a call to a function and a function's landing pad from instrumentation. The attribute can be used for function and pointer to function types, otherwise it will be ignored. Currently all platforms except i386 will report the error and do no instrumentation. i386 will provide the implementation based on a specification published by Intel for a new technology called Control-flow Enforcement Technology (CET). gcc/c-family/ * c-attribs.c (handle_nocf_check_attribute): New function. (c_common_attribute_table): Add 'nocf_check' handling. gcc/c/ * gimple-parser.c: Add second argument NULL to gimple_build_call_from_tree. gcc/ * attrib.c (comp_type_attributes): Check nocf_check attribute. * cfgexpand.c (expand_call_stmt): Set REG_CALL_NOCF_CHECK for call insn. * combine.c (distribute_notes): Add REG_CALL_NOCF_CHECK handling. * common.opt: Add fcf-protection flag. * emit-rtl.c (try_split): Add REG_CALL_NOCF_CHECK handling. * flag-types.h: Add enum cf_protection_level. * gimple.c (gimple_build_call_from_tree): Add second parameter. Add 'nocf_check' attribute propagation to gimple call. * gimple.h (gf_mask): Add GF_CALL_NOCF_CHECK. (gimple_build_call_from_tree): Update prototype. (gimple_call_nocf_check_p): New function. (gimple_call_set_nocf_check): Likewise. * gimplify.c: Add second argument to gimple_build_call_from_tree. * ipa-icf.c: Add nocf_check attribute in statement hash. * recog.c (peep2_attempt): Add REG_CALL_NOCF_CHECK handling. * reg-notes.def: Add REG_NOTE (CALL_NOCF_CHECK). * toplev.c (process_options): Add flag_cf_protection handling. From-SVN: r253936
Igor Tsimbalist committed
-
- 12 Oct, 2017 1 commit
-
-
The patch improves our C/C++ frontends' handling of missing symbols, by making c_parser_require and cp_parser_require use "better" locations for the diagnostic, and insert fix-it hints, under certain circumstances (see the comments in the patch for full details). For example, for this code with a missing semicolon: $ cat test.c int missing_semicolon (void) { return 42 } trunk currently emits: test.c:4:1: error: expected ';' before '}' token } ^ This patch adds a fix-it hint for the missing semicolon, and puts the error at the location of the missing semicolon, printing the followup token as a secondary location: test.c:3:12: error: expected ';' before '}' token return 42 ^ ; } ~ More examples can be seen in the test cases. gcc/c-family/ChangeLog: * c-common.c (enum missing_token_insertion_kind): New enum. (get_missing_token_insertion_kind): New function. (maybe_suggest_missing_token_insertion): New function. * c-common.h (maybe_suggest_missing_token_insertion): New decl. gcc/c/ChangeLog: * c-parser.c (c_parser_require): Add "type_is_unique" param and use it to guard calls to maybe_suggest_missing_token_insertion. (c_parser_parms_list_declarator): Override default value of new "type_is_unique" param to c_parser_require. (c_parser_asm_statement): Likewise. * c-parser.h (c_parser_require): Add "type_is_unique" param, defaulting to true. gcc/cp/ChangeLog: * parser.c (get_required_cpp_ttype): New function. (cp_parser_error_1): Call it, using the result to call maybe_suggest_missing_token_insertion. gcc/testsuite/ChangeLog: * c-c++-common/cilk-plus/AN/parser_errors.c: Update expected output to reflect changes to reported locations of missing symbols. * c-c++-common/cilk-plus/AN/parser_errors2.c: Likewise. * c-c++-common/cilk-plus/AN/parser_errors3.c: Likewise. * c-c++-common/cilk-plus/AN/pr61191.c: Likewise. * c-c++-common/gomp/pr63326.c: Likewise. * c-c++-common/missing-close-symbol.c: Likewise, also update for new fix-it hints. * c-c++-common/missing-symbol.c: Likewise, also add test coverage for missing colon in ternary operator. * g++.dg/cpp1y/digit-sep-neg.C: Likewise. * g++.dg/cpp1y/pr65202.C: Likewise. * g++.dg/missing-symbol-2.C: New test case. * g++.dg/other/do1.C: Update expected output to reflect changes to reported locations of missing symbols. * g++.dg/parse/error11.C: Likewise. * g++.dg/template/error11.C: Likewise. * gcc.dg/missing-symbol-2.c: New test case. * gcc.dg/missing-symbol-3.c: New test case. * gcc.dg/noncompile/940112-1.c: Update expected output to reflect changes to reported locations of missing symbols. * gcc.dg/noncompile/971104-1.c: Likewise. * obj-c++.dg/exceptions-6.mm: Likewise. * obj-c++.dg/pr48187.mm: Likewise. * objc.dg/exceptions-6.m: Likewise. From-SVN: r253690
David Malcolm committed
-
- 11 Oct, 2017 1 commit
-
-
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00582.html * tree.h (DECL_ASSEMBLER_NAME_SET_P): Don't check HAS_DECL_ASSEMBLER_NAME_P. * gimple-expr.c (gimple_decl_printable_name: Check HAS_DECL_ASSEMBLER_NAME_P too. * ipa-utils.h (type_in_anonymous_namespace_p): Check DECL_ASSEMBLER_NAME_SET_P of TYPE_NAME. (odr_type_p): No need to assert TYPE_NAME is a TYPE_DECL. * passes.c (rest_of_decl_compilation): Check HAS_DECL_ASSEMBLER_NAME_P too. * recog.c (verify_changes): Likewise. * tree-pretty-print.c (dump_decl_name): Likewise. * tree-ssa-structalias.c (alias_get_name): Likewise. Reimplement. c/ * c-decl.c (grokdeclarator): Check HAS_DECL_ASSEMBLER_NAME_P too. From-SVN: r253649
Nathan Sidwell committed
-
- 10 Oct, 2017 1 commit
-
-
The wide_int routines allow things like: wi::add (t, 1) to add 1 to an INTEGER_CST T in its native precision. But we also have: wi::to_offset (t) // Treat T as an offset_int wi::to_widest (t) // Treat T as a widest_int Recently we also gained: wi::to_wide (t, prec) // Treat T as a wide_int in preccision PREC This patch therefore requires: wi::to_wide (t) when operating on INTEGER_CSTs in their native precision. This is just as efficient, and makes it clearer that a deliberate choice is being made to treat the tree as a wide_int in its native precision. This also removes the inconsistency that a) INTEGER_CSTs in their native precision can be used without an accessor but must use wi:: functions instead of C++ operators b) the other forms need an explicit accessor but the result can be used with C++ operators. It also helps with SVE, where there's the additional possibility that the tree could be a runtime value. 2017-10-10 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * wide-int.h (wide_int_ref_storage): Make host_dependent_precision a template parameter. (WIDE_INT_REF_FOR): Update accordingly. * tree.h (wi::int_traits <const_tree>): Delete. (wi::tree_to_widest_ref, wi::tree_to_offset_ref): New typedefs. (wi::to_widest, wi::to_offset): Use them. Expand commentary. (wi::tree_to_wide_ref): New typedef. (wi::to_wide): New function. * calls.c (get_size_range): Use wi::to_wide when operating on trees as wide_ints. * cgraph.c (cgraph_node::create_thunk): Likewise. * config/i386/i386.c (ix86_data_alignment): Likewise. (ix86_local_alignment): Likewise. * dbxout.c (stabstr_O): Likewise. * dwarf2out.c (add_scalar_info, gen_enumeration_type_die): Likewise. * expr.c (const_vector_from_tree): Likewise. * fold-const-call.c (host_size_t_cst_p, fold_const_call_1): Likewise. * fold-const.c (may_negate_without_overflow_p, negate_expr_p) (fold_negate_expr_1, int_const_binop_1, const_binop) (fold_convert_const_int_from_real, optimize_bit_field_compare) (all_ones_mask_p, sign_bit_p, unextend, extract_muldiv_1) (fold_div_compare, fold_single_bit_test, fold_plusminus_mult_expr) (pointer_may_wrap_p, expr_not_equal_to, fold_binary_loc) (fold_ternary_loc, multiple_of_p, fold_negate_const, fold_abs_const) (fold_not_const, round_up_loc): Likewise. * gimple-fold.c (gimple_fold_indirect_ref): Likewise. * gimple-ssa-warn-alloca.c (alloca_call_type_by_arg): Likewise. (alloca_call_type): Likewise. * gimple.c (preprocess_case_label_vec_for_gimple): Likewise. * godump.c (go_output_typedef): Likewise. * graphite-sese-to-poly.c (tree_int_to_gmp): Likewise. * internal-fn.c (get_min_precision): Likewise. * ipa-cp.c (ipcp_store_vr_results): Likewise. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Likewise. * ipa-prop.c (ipa_print_node_jump_functions_for_edge): Likewise. (ipa_modify_call_arguments): Likewise. * match.pd: Likewise. * omp-low.c (scan_omp_1_op, lower_omp_ordered_clauses): Likewise. * print-tree.c (print_node_brief, print_node): Likewise. * stmt.c (expand_case): Likewise. * stor-layout.c (layout_type): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. * tree-cfg.c (group_case_labels_stmt): Likewise. * tree-data-ref.c (dr_analyze_indices): Likewise. (prune_runtime_alias_test_list): Likewise. * tree-dump.c (dequeue_and_dump): Likewise. * tree-inline.c (remap_gimple_op_r, copy_tree_body_r): Likewise. * tree-predcom.c (is_inv_store_elimination_chain): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * tree-scalar-evolution.c (iv_can_overflow_p): Likewise. (simple_iv_with_niters): Likewise. * tree-ssa-address.c (addr_for_mem_ref): Likewise. * tree-ssa-ccp.c (ccp_finalize, evaluate_stmt): Likewise. * tree-ssa-loop-ivopts.c (constant_multiple_of): Likewise. * tree-ssa-loop-niter.c (split_to_var_and_offset) (refine_value_range_using_guard, number_of_iterations_ne_max) (number_of_iterations_lt_to_ne, number_of_iterations_lt) (get_cst_init_from_scev, record_nonwrapping_iv) (scev_var_range_cant_overflow): Likewise. * tree-ssa-phiopt.c (minmax_replacement): Likewise. * tree-ssa-pre.c (compute_avail): Likewise. * tree-ssa-sccvn.c (vn_reference_fold_indirect): Likewise. (vn_reference_maybe_forwprop_address, valueized_wider_op): Likewise. * tree-ssa-structalias.c (get_constraint_for_ptr_offset): Likewise. * tree-ssa-uninit.c (is_pred_expr_subset_of): Likewise. * tree-ssanames.c (set_nonzero_bits, get_nonzero_bits): Likewise. * tree-switch-conversion.c (collect_switch_conv_info, array_value_type) (dump_case_nodes, try_switch_expansion): Likewise. * tree-vect-loop-manip.c (vect_gen_vector_loop_niters): Likewise. (vect_do_peeling): Likewise. * tree-vect-patterns.c (vect_recog_bool_pattern): Likewise. * tree-vect-stmts.c (vectorizable_load): Likewise. * tree-vrp.c (compare_values_warnv, vrp_int_const_binop): Likewise. (zero_nonzero_bits_from_vr, ranges_from_anti_range): Likewise. (extract_range_from_binary_expr_1, adjust_range_with_scev): Likewise. (overflow_comparison_p_1, register_edge_assert_for_2): Likewise. (is_masked_range_test, find_switch_asserts, maybe_set_nonzero_bits) (vrp_evaluate_conditional_warnv_with_ops, intersect_ranges): Likewise. (range_fits_type_p, two_valued_val_range_p, vrp_finalize): Likewise. (evrp_dom_walker::before_dom_children): Likewise. * tree.c (cache_integer_cst, real_value_from_int_cst, integer_zerop) (integer_all_onesp, integer_pow2p, integer_nonzerop, tree_log2) (tree_floor_log2, tree_ctz, mem_ref_offset, tree_int_cst_sign_bit) (tree_int_cst_sgn, get_unwidened, int_fits_type_p): Likewise. (get_type_static_bounds, num_ending_zeros, drop_tree_overflow) (get_range_pos_neg): Likewise. * ubsan.c (ubsan_expand_ptr_ifn): Likewise. * config/darwin.c (darwin_mergeable_constant_section): Likewise. * config/aarch64/aarch64.c (aapcs_vfp_sub_candidate): Likewise. * config/arm/arm.c (aapcs_vfp_sub_candidate): Likewise. * config/avr/avr.c (avr_fold_builtin): Likewise. * config/bfin/bfin.c (bfin_local_alignment): Likewise. * config/msp430/msp430.c (msp430_attr): Likewise. * config/nds32/nds32.c (nds32_insert_attributes): Likewise. * config/powerpcspe/powerpcspe-c.c (altivec_resolve_overloaded_builtin): Likewise. * config/powerpcspe/powerpcspe.c (rs6000_aggregate_candidate) (rs6000_expand_ternop_builtin): Likewise. * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): Likewise. * config/rs6000/rs6000.c (rs6000_aggregate_candidate): Likewise. (rs6000_expand_ternop_builtin): Likewise. * config/s390/s390.c (s390_handle_hotpatch_attribute): Likewise. gcc/ada/ * gcc-interface/decl.c (annotate_value): Use wi::to_wide when operating on trees as wide_ints. gcc/c/ * c-parser.c (c_parser_cilk_clause_vectorlength): Use wi::to_wide when operating on trees as wide_ints. * c-typeck.c (build_c_cast, c_finish_omp_clauses): Likewise. (c_tree_equal): Likewise. gcc/c-family/ * c-ada-spec.c (dump_generic_ada_node): Use wi::to_wide when operating on trees as wide_ints. * c-common.c (pointer_int_sum): Likewise. * c-pretty-print.c (pp_c_integer_constant): Likewise. * c-warn.c (match_case_to_enum_1): Likewise. (c_do_switch_warnings): Likewise. (maybe_warn_shift_overflow): Likewise. gcc/cp/ * cvt.c (ignore_overflows): Use wi::to_wide when operating on trees as wide_ints. * decl.c (check_array_designated_initializer): Likewise. * mangle.c (write_integer_cst): Likewise. * semantics.c (cp_finish_omp_clause_depend_sink): Likewise. gcc/fortran/ * target-memory.c (gfc_interpret_logical): Use wi::to_wide when operating on trees as wide_ints. * trans-const.c (gfc_conv_tree_to_mpz): Likewise. * trans-expr.c (gfc_conv_cst_int_power): Likewise. * trans-intrinsic.c (trans_this_image): Likewise. (gfc_conv_intrinsic_bound): Likewise. (conv_intrinsic_cobound): Likewise. gcc/lto/ * lto.c (compare_tree_sccs_1): Use wi::to_wide when operating on trees as wide_ints. gcc/objc/ * objc-act.c (objc_decl_method_attributes): Use wi::to_wide when operating on trees as wide_ints. From-SVN: r253595
Richard Sandiford committed
-
- 04 Oct, 2017 1 commit
-
-
In r253096 ("C++: underline parameters in mismatching function calls" aka 5d78d423a5f7a1d135c7bb678e82007678d1313c https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01546.html ) I updated the C++ FE's handling of mismatched types in function calls so that it underlines the pertinent param of the callee, rather than just the function name. The following patch does the same for the C frontend. Given e.g. this type mismatch: extern int callee (int one, const char *two, float three); int caller (int first, int second, float third) { return callee (first, second, third); } the C FE currently emits (trunk): test.c: In function 'caller': test.c:5:25: warning: passing argument 2 of 'callee' makes pointer from integer without a cast [-Wint-conversion] return callee (first, second, third); ^~~~~~ test.c:1:12: note: expected 'const char *' but argument is of type 'int' extern int callee (int one, const char *two, float three); ^~~~~~ whereas with this patch the note underlines the pertinent param of the callee: test.c: In function 'caller': test.c:5:25: warning: passing argument 2 of 'callee' makes pointer from integer without a cast [-Wint-conversion] return callee (first, second, third); ^~~~~~ test.c:1:41: note: expected 'const char *' but argument is of type 'int' extern int callee (int one, const char *two, float three); ~~~~~~~~~~~~^~~ making the problem more obvious to the user. As with the C++ patch, the patch: (a) updates the locations of the params to cover the range of all of their tokens, putting the caret on the first character of the param name (if present), otherwise at the start of the first token (doing so requires adding a last_token_location to the c_parser, so we can determine the location of the last consumed token). (b) updates the "note" to use the param location, rather than the fndecl location gcc/c/ChangeLog: * c-decl.c (push_parm_decl): Store c_parm's location into the PARAM_DECL. (build_c_parm): Add "loc" param and store it within the c_parm. * c-parser.c (struct c_parser): Add "last_token_location" field. (c_parser_consume_token): Store location of the token into the new field. (c_parser_declaration_or_fndef): Store params into DECL_ARGUMENTS when handling a FUNCTION_DECL, if it doesn't already have them. (c_parser_parameter_declaration): Generate a location for the parameter, and pass it to the call to build_c_parm. * c-tree.h (struct c_parm): Add field "loc". (build_c_parm): Add location_t param. * c-typeck.c (get_fndecl_argument_location): New function. (inform_for_arg): New function. (convert_for_assignment): Use inform_for_arg when dealing with ic_argpass. gcc/testsuite/ChangeLog: * gcc.dg/diagnostic-range-bad-called-object.c: Update expected underlining for param. * gcc.dg/param-type-mismatch.c: Update expected results to reflect highlighting of parameters; add test coverage for trivial parameter decls, and for callback parameters. * gcc.dg/pr68533.c: Update location of two errors to reflect location of params. From-SVN: r253411
David Malcolm committed
-
- 29 Sep, 2017 2 commits
-
-
c-family/ * c-attribs.c (handle_packed_attribute): Test DECL_C_BIT_FIELD rather than DECL_INITIAL. (common_handle_aligned_attribute): Likewise. c/ * c-decl.c (grokfield): Use SET_DECL_C_BIT_FIELD here if width is non-NULL. (finish_struct): Test DECL_C_BIT_FIELD instead of DECL_INITIAL, don't SET_DECL_C_BIT_FIELD here. cp/ * class.c (check_bitfield_decl): Retrieve and clear width from DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL. (check_field_decls): Test DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL. (remove_zero_width_bit_fields): Adjust comment. * decl2.c (grokbitfield): Stash width into DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL. * pt.c (tsubst_decl): For DECL_C_BIT_FIELD, tsubst_expr DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL for width. objc/ * objc-act.c (check_ivars, gen_declaration): For OBJCPLUS look at DECL_BIT_FIELD_REPRESENTATIVE rather than DECL_INITIAL. From-SVN: r253301
Jakub Jelinek committed -
PR c/82340 * c-decl.c (build_compound_literal): Use c_apply_type_quals_to_decl instead of trying to set just TREE_READONLY manually. * gcc.dg/tree-ssa/pr82340.c: New test. From-SVN: r253280
Jakub Jelinek committed
-
- 16 Sep, 2017 1 commit
-
-
2017-09-16 Tom de Vries <tom@codesourcery.com> PR c/81875 * c-parser.c (c_parser_omp_for_loop): Fold only operands of cond, not cond itself. * testsuite/libgomp.c-c++-common/pr81875.c: New test. From-SVN: r252873
Tom de Vries committed
-
- 15 Sep, 2017 2 commits
-
-
C11 semantics for excess precision (from N1531) are that an implicit conversion (from the usual arithmetic conversions, not by assignment) from integer to floating point has a result in the corresponding evaluation format of that floating-point type, so possibly with excess precision (whereas a cast or conversion by assignment from integer to floating point must produce a value without excess range or precision, as always). This patch makes GCC support those semantics if flag_isoc11 (which in turn means that conditional expressions need to support generating a result with excess precision even if neither operand had excess precision). C99 is less than entirely clear in this regard, but my reading as outlined at <https://gcc.gnu.org/ml/gcc-patches/2008-11/msg00105.html> is that the results of conversions from integer to floating-point types are always expected to be representable in the target type without excess precision, and this patch conservatively keeps these semantics for pre-C11 (i.e. if an older standard is explicitly selected). Bootstrapped with no regressions on x86_64-pc-linux-gnu. PR c/82071 gcc/c: * c-typeck.c (ep_convert_and_check): Just call convert_and_check for C11. (build_conditional_expr): For C11, generate result with excess precision when one argument is an integer and the other is of a type using excess precision. gcc/testsuite: * gcc.target/i386/excess-precision-8.c: New test. From-SVN: r252847
Joseph Myers committed -
2017-09-15 Bernd Edlinger <bernd.edlinger@hotmail.de> * common.opt (Wcast-align=strict): New warning option. * doc/invoke.texi: Document -Wcast-align=strict. c: 2017-09-15 Bernd Edlinger <bernd.edlinger@hotmail.de> * c-typeck.c (build_c_cast): Implement -Wcast-align=strict. cp: 2017-09-15 Bernd Edlinger <bernd.edlinger@hotmail.de> * typeck.c (build_reinterpret_cast_1, build_const_cast_1): Implement -Wcast-align=strict. testsuite: 2017-09-15 Bernd Edlinger <bernd.edlinger@hotmail.de> * c-c++-common/Wcast-align.c: New test. From-SVN: r252832
Bernd Edlinger committed
-
- 13 Sep, 2017 1 commit
-
-
PR c/82167 * c-typeck.c (c_expr_sizeof_expr): Use the type of expr.value rather than expr.original_type. * gcc.dg/pr82167.c: New test. From-SVN: r252372
Marek Polacek committed
-
- 12 Sep, 2017 1 commit
-
-
c-family/ * c-common.c (field_decl_cmp, resort_data, resort_field_decl_cmp, resort_sorted_fields): Move to c/c-decl.c. * c-common.h (field_decl_cmp, resort_sorted_fields): Delete. (struct sorted_fields_type): Move to c/c-lang.h. c/ * c-decl.c (field_decl_cmp, resort_data, resort_field_decl_cmp, resort_sorted_fields): Moved from c-family/c-common.c. * c-lang.h (struct sorted_fields_type): Moved from c-family/c-common.h. From-SVN: r252023
Nathan Sidwell committed
-
- 01 Sep, 2017 2 commits
-
-
PR c/82071 reports how compound assignment operators such as += handle excess precision inconsistently with the same operation done with a plain assignment and binary operator. There were (at least) two problems with how compound assignments handled excess precision. The EXCESS_PRECISION_EXPR for an argument with excess precision was removed too early, resulting in build_binary_op being called with an rhs operand whose type reflected the evaluation format, so not having sufficient information to achieve the intended semantics in all cases, and then the code called c_fully_fold on the results of build_binary_op without allowing for the possibility of an EXCESS_PRECISION_EXPR as the result, so leading to double rounding of the result (first to its semantic type, then to the type of the LHS of the assignment) instead of the intended single rounding. This patch fixes those problems by keeping EXCESS_PRECISION_EXPRs further through build_modify_expr (and build_atomic_assign which it calls) and only removing them locally where appropriate. Note that while this patch should achieve *consistency*, that's consistency with the understanding of C99 semantics that I originally intended to implement. For the particular case in the testcase, C11 semantics (from N1531) differ from that understanding of C99 semantics, in that an implicit conversion of an integer to floating point can have excess precision. I intend to implement those C11 semantics separately (conditional on flag_isoc11) (which will also mean that building conditional expressions can produce a result with excess precision even when the arguments lack excess precision, where previously it could not), and not to close the bug until that is also done. Tested for x86_64-pc-linux-gnu. PR c/82071 gcc/c: * c-typeck.c (build_atomic_assign): Handle argument with excess precision. Ensure any EXCESS_PRECISION_EXPR is present in argument passed to build_binary_op and convert_for_assignment but not for call to c_fully_fold. (build_modify_expr): Do not remove EXCESS_PRECISION_EXPR early. Ensure build_binary_op is called with argument with original semantic type. Avoid calling c_fully_fold with an EXCESS_PRECISION_EXPR from build_binary_op. gcc/testsuite: * gcc.target/i386/excess-precision-7.c: New test. From-SVN: r251603
Joseph Myers committed -
PR c/81887 c-family/ * c-pragma.c (omp_pragmas): Move "ordered" entry from here to ... (omp_pragmas_simd): ... here. * c-omp.c (c_finish_omp_ordered): If clauses isn't simd clause alone, create new clauses list containing just simd clause. c/ * c-parser.c (c_parser_omp_ordered): Handle -fopenmp-simd. cp/ * parser.c (cp_parser_omp_ordered): Handle -fopenmp-simd. fortran/ * parse.c (decode_omp_directive): Use matchs instead of matcho for end ordered and ordered directives, except for ordered depend. For -fopenmp-simd and ordered depend, reject the stmt. * trans-openmp.c (gfc_trans_omp_ordered): For -fopenmp-simd ignore threads clause and if simd clause isn't present, just translate the body. testsuite/ * c-c++-common/gomp/pr81887.c: New test. * gfortran.dg/gomp/pr81887.f90: New test. From-SVN: r251585
Jakub Jelinek committed
-
- 30 Aug, 2017 1 commit
-
-
This patch adds a SCALAR_TYPE_MODE macro, along the same lines as SCALAR_INT_TYPE_MODE and SCALAR_FLOAT_TYPE_MODE. It also adds two instances of as_a <scalar_mode> to c_common_type, when converting an unsigned fixed-point SCALAR_TYPE_MODE to the equivalent signed mode. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * tree.h (SCALAR_TYPE_MODE): New macro. * expr.c (expand_expr_addr_expr_1): Use it. (expand_expr_real_2): Likewise. * fold-const.c (fold_convert_const_fixed_from_fixed): Likeise. (fold_convert_const_fixed_from_int): Likewise. (fold_convert_const_fixed_from_real): Likewise. (native_encode_fixed): Likewise (native_encode_complex): Likewise (native_encode_vector): Likewise. (native_interpret_fixed): Likewise. (native_interpret_real): Likewise. (native_interpret_complex): Likewise. (native_interpret_vector): Likewise. * omp-simd-clone.c (simd_clone_adjust_return_type): Likewise. (simd_clone_adjust_argument_types): Likewise. (simd_clone_init_simd_arrays): Likewise. (simd_clone_adjust): Likewise. * stor-layout.c (layout_type): Likewise. * tree.c (build_minus_one_cst): Likewise. * tree-cfg.c (verify_gimple_assign_ternary): Likewise. * tree-inline.c (estimate_move_cost): Likewise. * tree-ssa-math-opts.c (convert_plusminus_to_widen): Likewise. * tree-vect-loop.c (vect_create_epilog_for_reduction): Likewise. (vectorizable_reduction): Likewise. * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Likewise. (vect_recog_mixed_size_cond_pattern): Likewise. (check_bool_pattern): Likewise. (adjust_bool_pattern): Likewise. (search_type_for_mask_1): Likewise. * tree-vect-slp.c (vect_schedule_slp_instance): Likewise. * tree-vect-stmts.c (vectorizable_conversion): Likewise. (vectorizable_load): Likewise. (vectorizable_store): Likewise. * ubsan.c (ubsan_encode_value): Likewise. * varasm.c (output_constant): Likewise. gcc/c-family/ * c-lex.c (interpret_fixed): Use SCALAR_TYPE_MODE. * c-common.c (c_build_vec_perm_expr): Likewise. gcc/c/ * c-typeck.c (build_binary_op): Use SCALAR_TYPE_MODE. (c_common_type): Likewise. Use as_a <scalar_mode> when setting m1 and m2 to the signed equivalent of a fixed-point SCALAR_TYPE_MODE. gcc/cp/ * typeck.c (cp_build_binary_op): Use SCALAR_TYPE_MODE. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251516
Richard Sandiford committed
-
- 24 Aug, 2017 1 commit
-
-
In r251239 I added a c_expr::get_location method for use by c_parser_expr_list for building the vec<location_t> for an expression list, rather than using the location of the first token. When determining whether to use the location within the tree node, or fall back to the range in the c_expr, I used EXPR_CAN_HAVE_LOCATION, rather than EXPR_HAS_LOCATION. This meant that any tree nodes of kinds that *can* have a location but which erroneously had EXPR_LOCATION (value) == UNKNOWN_LOCATION had that value added to the vec<location_t>, leading to missing location information when reporting on the issue (seen with gcc.dg/Wtraditional-conversion-2.c for m68k). This patch addresses this in two ways: (a) it fixes the specific issue in this failing test case, by setting up the location properly on the EXCESS_PRECISION_EXPR. (b) updating c_expr::get_location by only using the EXPR_LOCATION if it's sane. Arguably this is papering over bugs, but they are pre-existing ones exposed by r251239, and I'd rather have this fix in place than play whack-a-mole on any other such "missing location" bugs that are lurking in the codebase. gcc/c/ChangeLog: * c-tree.h (c_expr::get_location) Use EXPR_HAS_LOCATION rather than CAN_HAVE_LOCATION_P when determining whether to use the location_t value within "value". gcc/c-family/ChangeLog: * c-lex.c (interpret_float): Use token location when building an EXCESS_PRECISION_EXPR. From-SVN: r251335
David Malcolm committed
-
- 21 Aug, 2017 2 commits
-
-
The previous patch uncovered a bug in how c_parser_expr_list builds the vec<location_t>: it was only using the location of the first token within each assignment-expression in the expr-list. This shows up in e.g. this -Wformat warning, where only part of the 2nd param is underlined: printf("hello %i", (long)0); ~^ ~ %li This patch fixes c_parser_expr_list to use the full range of each assignment-expression in the list for the vec<location_t>, so that for the above we print: printf("hello %i", (long)0); ~^ ~~~~~~~ %li gcc/c/ChangeLog: * c-parser.c (c_parser_expr_list): Use c_expr::get_location () rather than peeking the location of the first token. * c-tree.h (c_expr::get_location): New method. gcc/testsuite/ChangeLog: * gcc.dg/format/diagnostic-ranges.c (test_mismatching_types): Update expected result to show all of "(long)0" being underlined. * gcc.dg/plugin/diagnostic-test-string-literals-1.c (test_multitoken_macro): Update expected underlining. From-SVN: r251239
David Malcolm committed -
This patch passes along the vec<location_t> of argument locations at a callsite from the C frontend to check_function_arguments and from there to c-format.c, so that we can underline the pertinent argument to mismatched format codes even for tree codes like decls and constants which lack a location_t for their usage sites. This takes e.g.: printf("hello %i %i %i ", foo, bar, baz); ~^ %s to: printf("hello %i %i %i ", foo, bar, baz); ~^ ~~~ %s which is useful for cases where there's more than one variadic argument. gcc/c-family/ChangeLog: * c-common.c (check_function_arguments): Add "arglogs" param; pass it to check_function_format. * c-common.h (check_function_arguments): Add vec<location_t> * param. (check_function_format): Likewise. * c-format.c (struct format_check_context): Add field "arglocs". (check_function_format): Add param "arglocs"; pass it to check_format_info. (check_format_info): Add param "arglocs"; use it to initialize new field of format_ctx. (check_format_arg): Pass format_ctx->arglocs to new param of check_format_info_main. (class argument_parser): New field "arglocs". (argument_parser::argument_parser): Add "arglocs_" param and use it to initialize new field. (argument_parser::check_argument_type): Pass new arglocs field to check_format_types. (check_format_info_main): Add param "arglocs", and use it when constructing arg_parser. (check_format_types): Add param "arglocs"; use it if non-NULL when !EXPR_HAS_LOCATION (cur_param) to get at location information. gcc/c/ChangeLog: * c-typeck.c (build_function_call_vec): Pass arg_loc to call to check_function_arguments. gcc/cp/ChangeLog: * call.c (build_over_call): Pass NULL for new parameter to check_function_arguments. * typeck.c (cp_build_function_call_vec): Likewise. gcc/testsuite/ChangeLog: * gcc.dg/format/diagnostic-ranges.c: Update expected results to show underlining of all pertinent params. * gcc.dg/format/pr72858.c: Likewise. From-SVN: r251238
David Malcolm committed
-
- 18 Aug, 2017 2 commits
-
-
* c-parser.c (c_parser_postfix_expression): Remove unused code. Update commentary. From-SVN: r251181
Marek Polacek committed -
Add warn_if_not_aligned attribute as well as command line options: -Wif-not-aligned and -Wpacked-not-aligned. __attribute__((warn_if_not_aligned(N))) causes compiler to issue a warning if the field in a struct or union is not aligned to N: typedef unsigned long long __u64 __attribute__((aligned(4),warn_if_not_aligned(8))); struct foo { int i1; int i2; __u64 x; }; __u64 is aligned to 4 bytes. But inside struct foo, __u64 should be aligned at 8 bytes. It is used to define struct foo in such a way that struct foo has the same layout and x has the same alignment when __u64 is aligned at either 4 or 8 bytes. Since struct foo is normally aligned to 4 bytes, a warning will be issued: warning: alignment 4 of 'struct foo' is less than 8 Align struct foo to 8 bytes: struct foo { int i1; int i2; __u64 x; } __attribute__((aligned(8))); silences the warning. It also warns the field with misaligned offset: struct foo { int i1; int i2; int i3; __u64 x; } __attribute__((aligned(8))); warning: 'x' offset 12 in 'struct foo' isn't aligned to 8 This warning is controlled by -Wif-not-aligned and is enabled by default. When -Wpacked-not-aligned is used, the same warning is also issued for the field with explicitly specified alignment in a packed struct or union: struct __attribute__ ((aligned (8))) S8 { char a[8]; }; struct __attribute__ ((packed)) S { struct S8 s8; }; warning: alignment 1 of 'struct S' is less than 8 This warning is disabled by default and enabled by -Wall. gcc/ PR c/53037 * print-tree.c (print_node): Support DECL_WARN_IF_NOT_ALIGN and TYPE_WARN_IF_NOT_ALIGN. * stor-layout.c (do_type_align): Merge DECL_WARN_IF_NOT_ALIGN. (handle_warn_if_not_align): New. (place_union_field): Call handle_warn_if_not_align. (place_field): Call handle_warn_if_not_align. Copy TYPE_WARN_IF_NOT_ALIGN. (finish_builtin_struct): Copy TYPE_WARN_IF_NOT_ALIGN. (layout_type): Likewise. * tree-core.h (tree_type_common): Add warn_if_not_align. Set spare to 18. (tree_decl_common): Add warn_if_not_align. * tree.c (build_range_type_1): Copy TYPE_WARN_IF_NOT_ALIGN. * tree.h (TYPE_WARN_IF_NOT_ALIGN): New. (SET_TYPE_WARN_IF_NOT_ALIGN): Likewise. (DECL_WARN_IF_NOT_ALIGN): Likewise. (SET_DECL_WARN_IF_NOT_ALIGN): Likewise. * doc/extend.texi: Document warn_if_not_aligned attribute. * doc/invoke.texi: Document -Wif-not-aligned and -Wpacked-not-aligned. gcc/c-family/ PR c/53037 * c-attribs.c (handle_warn_if_not_aligned_attribute): New. (c_common_attribute_table): Add warn_if_not_aligned. (handle_aligned_attribute): Renamed to ... (common_handle_aligned_attribute): Remove argument, name, and add argument, warn_if_not_aligned. Handle warn_if_not_aligned. (handle_aligned_attribute): New. * c.opt: Add -Wif-not-aligned and -Wpacked-not-aligned. gcc/c/ PR c/53037 * c-decl.c (merge_decls): Also merge DECL_WARN_IF_NOT_ALIGN. (check_bitfield_type_and_width): Don't allow bit-field with warn_if_not_aligned type. gcc/cp/ PR c/53037 * decl.c (duplicate_decls): Also merge DECL_WARN_IF_NOT_ALIGN. * decl2.c (grokbitfield): Don't allow bit-field with warn_if_not_aligned type. gcc/testsuite/ PR c/53037 * c-c++-common/pr53037-5.c: New test. * g++.dg/pr53037-1.C: Likewise. * g++.dg/pr53037-2.C: Likewise. * g++.dg/pr53037-3.C: Likewise. * g++.dg/pr53037-4.C: Likewise. * gcc.dg/pr53037-1.c: Likewise. * gcc.dg/pr53037-2.c: Likewise. * gcc.dg/pr53037-3.c: Likewise. * gcc.dg/pr53037-4.c: Likewise. From-SVN: r251180
H.J. Lu committed
-
- 14 Aug, 2017 1 commit
-
-
gcc/ChangeLog: PR c/81117 * tree-diagnostic.c (default_tree_printer): Handle %G. * gimple-pretty-print.h (percent_G_format): Declare new function. * gimple-pretty-print.c (percent_G_format): Define. * tree-pretty-print.c (percent_K_format): Add argument. gcc/c/ChangeLog: PR c/81117 * c-objc-common.c (c_objc_common_init): Handle 'G'. gcc/c-family/ChangeLog: PR c/81117 * c-format.h (T89_G): New macro. * c-format.c (local_gcall_ptr_node): New variable. (init_dynamic_diag_info): Initialize it. gcc/cp/ChangeLog: PR c/81117 * error.c (cp_printer): Handle 'G'. gcc/testsuite/ChangeLog: PR c/81117 * gcc.dg/format/gcc_diag-10.c: Exercise %G. From-SVN: r251098
Martin Sebor committed
-
- 11 Aug, 2017 1 commit
-
-
re PR c/81795 (Stray "originally defined here" when using -Wc++-compat with #pragma GCC diagnostic push/pop) PR c/81795 * c-decl.c (pushtag): Only print inform if the warning was printed. (grokdeclarator): Likewise. * gcc.dg/pr81795.c: New test. From-SVN: r251056
Marek Polacek committed
-
- 10 Aug, 2017 1 commit
-
-
gcc/c/ChangeLog: * c-parser.c (c_parser_error): Rename to... (c_parser_error_richloc): ...this, making static, and adding "richloc" parameter, passing it to the c_parse_error call, rather than calling c_parser_set_source_position_from_token. (c_parser_error): Reintroduce, reimplementing in terms of the above, converting return type from void to bool. (class token_pair): New class. (struct matching_paren_traits): New struct. (matching_parens): New typedef. (struct matching_brace_traits): New struct. (matching_braces): New typedef. (get_matching_symbol): New function. (c_parser_require): Add param MATCHING_LOCATION, using it to highlight matching "opening" tokens for missing "closing" tokens. (c_parser_skip_until_found): Likewise. (c_parser_static_assert_declaration_no_semi): Convert explicit parsing of CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use of class matching_parens, so that the pertinent open parenthesis is highlighted when there are problems locating the close parenthesis. (c_parser_struct_or_union_specifier): Likewise. (c_parser_typeof_specifier): Likewise. (c_parser_alignas_specifier): Likewise. (c_parser_simple_asm_expr): Likewise. (c_parser_braced_init): Likewise, for matching_braces. (c_parser_paren_condition): Likewise, for matching_parens. (c_parser_switch_statement): Likewise. (c_parser_for_statement): Likewise. (c_parser_asm_statement): Likewise. (c_parser_asm_operands): Likewise. (c_parser_cast_expression): Likewise. (c_parser_sizeof_expression): Likewise. (c_parser_alignof_expression): Likewise. (c_parser_generic_selection): Likewise. (c_parser_postfix_expression): Likewise for cases RID_VA_ARG, RID_OFFSETOF, RID_TYPES_COMPATIBLE_P, RID_AT_SELECTOR, RID_AT_PROTOCOL, RID_AT_ENCODE, reindenting as necessary. In case CPP_OPEN_PAREN, pass loc_open_paren to the c_parser_skip_until_found call. (c_parser_objc_class_definition): Use class matching_parens as above. (c_parser_objc_method_decl): Likewise. (c_parser_objc_try_catch_finally_statement): Likewise. (c_parser_objc_synchronized_statement): Likewise. (c_parser_objc_at_property_declaration): Likewise. (c_parser_oacc_wait_list): Likewise. (c_parser_omp_var_list_parens): Likewise. (c_parser_omp_clause_collapse): Likewise. (c_parser_omp_clause_default): Likewise. (c_parser_omp_clause_if): Likewise. (c_parser_omp_clause_num_threads): Likewise. (c_parser_omp_clause_num_tasks): Likewise. (c_parser_omp_clause_grainsize): Likewise. (c_parser_omp_clause_priority): Likewise. (c_parser_omp_clause_hint): Likewise. (c_parser_omp_clause_defaultmap): Likewise. (c_parser_oacc_single_int_clause): Likewise. (c_parser_omp_clause_ordered): Likewise. (c_parser_omp_clause_reduction): Likewise. (c_parser_omp_clause_schedule): Likewise. (c_parser_omp_clause_num_teams): Likewise. (c_parser_omp_clause_thread_limit): Likewise. (c_parser_omp_clause_aligned): Likewise. (c_parser_omp_clause_linear): Likewise. (c_parser_omp_clause_safelen): Likewise. (c_parser_omp_clause_simdlen): Likewise. (c_parser_omp_clause_depend): Likewise. (c_parser_omp_clause_map): Likewise. (c_parser_omp_clause_device): Likewise. (c_parser_omp_clause_dist_schedule): Likewise. (c_parser_omp_clause_proc_bind): Likewise. (c_parser_omp_clause_uniform): Likewise. (c_parser_omp_for_loop): Likewise. (c_parser_cilk_clause_vectorlength): Likewise. (c_parser_cilk_clause_linear): Likewise. (c_parser_transaction_expression): Likewise. * c-parser.h (c_parser_require): Add param matching_location with default UNKNOWN_LOCATION. (c_parser_error): Convert return type from void to bool. (c_parser_skip_until_found): Add param matching_location with default UNKNOWN_LOCATION. gcc/c-family/ChangeLog: * c-common.c (c_parse_error): Add rich_location * param, using it rather implicitly using input_location. * c-common.h (c_parse_error): Add rich_location * param. gcc/cp/ChangeLog: * parser.c (cp_parser_error): Update for new param to c_parse_error. (class token_pair): New class. (struct matching_paren_traits): New struct. (matching_parens): New typedef. (struct matching_brace_traits): New struct. (matching_braces): New typedef. (cp_parser_statement_expr): Convert explicit parsing of CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use of class matching_parens, so that the pertinent open parenthesis is highlighted when there are problems locating the close parenthesis. (cp_parser_primary_expression): Likewise. (cp_parser_compound_literal_p): Remove consumption of opening paren. (cp_parser_postfix_expression): Convert explicit parsing of CPP_OPEN_PAREN and CPP_CLOSE_PAREN to use matching parens, as above. Use it to consume the opening paren previously consumed by cp_parser_compound_literal_p. (cp_parser_parenthesized_expression_list): Likewise. (cp_parser_unary_expression): Likewise. (cp_parser_new_expression): Likewise. (cp_parser_cast_expression): Likewise. (cp_parser_builtin_offsetof): Likewise. (cp_parser_trait_expr): Likewise. (cp_parser_lambda_declarator_opt): Likewise. (cp_parser_lambda_body): Likewise, for matching_braces. (cp_parser_compound_statement): Likewise. (cp_parser_selection_statement): Likewise, for matching_parens. (cp_parser_iteration_statement): Likewise. (cp_parser_already_scoped_statement): Likewise, for matching_braces. (cp_parser_linkage_specification): Likewise. (cp_parser_static_assert): Likewise, for matching_parens. (cp_parser_decltype): Likewise. (cp_parser_operator): Likewise. (cp_parser_enum_specifier): Likewise. (cp_parser_namespace_definition): Likewise. (cp_parser_direct_declarator): Likewise. (cp_parser_braced_list): Likewise. (cp_parser_class_specifier_1): Likewise, for matching_braces. (cp_parser_constant_initializer): Likewise. (cp_parser_noexcept_specification_opt): Likewise, for matching_parens. (cp_parser_exception_specification_opt): Likewise. (cp_parser_handler): Likewise. (cp_parser_asm_specification_opt): Likewise. (cp_parser_asm_operand_list): Likewise. (cp_parser_gnu_attributes_opt): Likewise. (cp_parser_std_attribute_spec): Likewise. (cp_parser_requirement_parameter_list): Likewise. (cp_parser_requirement_body): Likewise, for matching_braces. (cp_parser_compound_requirement): Likewise. (cp_parser_template_introduction): Likewise. (cp_parser_sizeof_pack): Likewise, for matching_parens. (cp_parser_sizeof_operand): Likewise; use it to consume the opening paren previously consumed by cp_parser_compound_literal_p. (get_matching_symbol): New function. (cp_parser_required_error): Add param "matching_location". Remove calls to cp_parser_error, instead setting a non-NULL gmsgid, and handling it if set by calling c_parse_error, potentially with a secondary location if matching_location was set. (cp_parser_require): Add param "matching_location", with a default value of UNKNOWN_LOCATION. (cp_parser_require_keyword): Update for new param of cp_parser_required_error. (cp_parser_objc_encode_expression): Update to class matching_parens as above. (cp_parser_objc_defs_expression): Likewise. (cp_parser_objc_protocol_expression): Likewise. (cp_parser_objc_selector_expression): Likewise. (cp_parser_objc_typename): Likewise. (cp_parser_objc_superclass_or_category): Likewise. (cp_parser_objc_try_catch_finally_statement): Likewise. (cp_parser_objc_synchronized_statement): Likewise. (cp_parser_objc_at_property_declaration): Likewise. (cp_parser_oacc_single_int_clause): Likewise. (cp_parser_oacc_shape_clause): Likewise. (cp_parser_omp_clause_collapse): Likewise. (cp_parser_omp_clause_default): Likewise. (cp_parser_omp_clause_final): Likewise. (cp_parser_omp_clause_if): Likewise. (cp_parser_omp_clause_num_threads): Likewise. (cp_parser_omp_clause_num_tasks): Likewise. (cp_parser_omp_clause_grainsize): Likewise. (cp_parser_omp_clause_priority): Likewise. (cp_parser_omp_clause_hint): Likewise. (cp_parser_omp_clause_defaultmap): Likewise. (cp_parser_omp_clause_ordered): Likewise. (cp_parser_omp_clause_schedule): Likewise. (cp_parser_omp_clause_num_teams): Likewise. (cp_parser_omp_clause_thread_limit): Likewise. (cp_parser_omp_clause_aligned): Likewise. (cp_parser_omp_clause_linear): Likewise. (cp_parser_omp_clause_safelen): Likewise. (cp_parser_omp_clause_simdlen): Likewise. (cp_parser_omp_clause_depend): Likewise. (cp_parser_omp_clause_device): Likewise. (cp_parser_omp_clause_dist_schedule): Likewise. (cp_parser_oacc_clause_async): Likewise. (cp_parser_omp_critical): Likewise. (cp_parser_omp_for_loop): Likewise. (cp_parser_omp_sections_scope): Likewise. (cp_parser_omp_declare_reduction_exprs): Likewise. Update for new param to cp_parser_required_error. (cp_parser_oacc_routine): Likewise. (cp_parser_transaction_expression): Likewise. (cp_parser_cilk_simd_vectorlength): Likewise. gcc/testsuite/ChangeLog: * c-c++-common/missing-close-symbol.c: New test case. * c-c++-common/missing-symbol.c: New test case. * gcc.dg/unclosed-init.c: New test case. * g++.dg/diagnostic/unclosed-extern-c.C: New test case. * g++.dg/diagnostic/unclosed-function.C: New test case. * g++.dg/diagnostic/unclosed-namespace.C: New test case. * g++.dg/diagnostic/unclosed-struct.C: New test case. * g++.dg/parse/pragma2.C: Update to reflect movement of the "expected identifier" error. From-SVN: r251026
David Malcolm committed
-
- 09 Aug, 2017 3 commits
-
-
From-SVN: r250986
Marek Polacek committed -
PR c/81233 * c-typeck.c (pedwarn_init): Make the function take a variable list. Call emit_diagnostic_valist instead of pedwarn. (convert_for_assignment): Unroll the PEDWARN_FOR_ASSIGNMENT macro. Print the relevant types in diagnostics. * diagnostic-core.h (emit_diagnostic_valist): Add declaration. * diagnostic.c (emit_diagnostic): Add a comment. (emit_diagnostic_valist): New function. * gcc.dg/diagnostic-types-1.c: New test. * gcc.dg/assign-warn-1.c: Update warning messages. * gcc.dg/assign-warn-2.c: Likewise. * gcc.dg/c90-const-expr-5.c: Likewise. * gcc.dg/c99-const-expr-5.c: Likewise. * gcc.dg/conv-2.c: Likewise. * gcc.dg/init-bad-7.c: Likewise. * gcc.dg/overflow-warn-1.c: Likewise. * gcc.dg/overflow-warn-2.c: Likewise. * gcc.dg/overflow-warn-3.c: Likewise. * gcc.dg/overflow-warn-4.c: Likewise. * gcc.dg/pointer-array-atomic.c: Likewise. * gcc.dg/pr26865.c: Likewise. * gcc.dg/pr61162-2.c: Likewise. * gcc.dg/pr61162.c: Likewise. * gcc.dg/pr67730-2.c: Likewise. * gcc.dg/pr69156.c: Likewise. * gcc.dg/pr70174.c: Likewise. * objc.dg/proto-lossage-4.m: Likewise. From-SVN: r250985
Marek Polacek committed -
PR c/81417 * c-array-notation.c (fix_builtin_array_notation_fn): Update calls to build_conditional_expr. * c-parser.c (c_parser_conditional_expression): Create locations for EXP1 and EXP2 from their source ranges. Pass the locations down to build_conditional_expr. * c-tree.h (build_conditional_expr): Update declaration. * c-typeck.c (build_conditional_expr): Add location_t parameters. For -Wsign-compare, also print the types. * input.c (make_location): New overload. * input.h (make_location): Declare. * objc-next-runtime-abi-02.c (build_v2_build_objc_method_call): Update a call to build_conditional_expr. * Wsign-compare-1.c: New test. * gcc.dg/compare1.c: Adjust dg-bogus. * gcc.dg/compare2.c: Likewise. * gcc.dg/compare3.c: Likewise. * gcc.dg/compare7.c: Likewise. * gcc.dg/compare8.c: Likewise. * gcc.dg/compare9.c: Likewise. * gcc.dg/pr11492.c: Likewise. From-SVN: r250984
Marek Polacek committed
-
- 08 Aug, 2017 1 commit
-
-
. 2017-08-08 Martin Liska <mliska@suse.cz> * gcc-interface/trans.c: Include header files. 2017-08-08 Martin Liska <mliska@suse.cz> * objc-gnu-runtime-abi-01.c: Include header files. * objc-next-runtime-abi-01.c: Likewise. * objc-next-runtime-abi-02.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * asan.c: Include header files. * attribs.c (build_decl_attribute_variant): New function moved from tree.[ch]. (build_type_attribute_qual_variant): Likewise. (cmp_attrib_identifiers): Likewise. (simple_cst_list_equal): Likewise. (omp_declare_simd_clauses_equal): Likewise. (attribute_value_equal): Likewise. (comp_type_attributes): Likewise. (build_type_attribute_variant): Likewise. (lookup_ident_attribute): Likewise. (remove_attribute): Likewise. (merge_attributes): Likewise. (merge_type_attributes): Likewise. (merge_decl_attributes): Likewise. (merge_dllimport_decl_attributes): Likewise. (handle_dll_attribute): Likewise. (attribute_list_equal): Likewise. (attribute_list_contained): Likewise. * attribs.h (lookup_attribute): New function moved from tree.[ch]. (lookup_attribute_by_prefix): Likewise. * bb-reorder.c: Include header files. * builtins.c: Likewise. * calls.c: Likewise. * cfgexpand.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * convert.c: Likewise. * dwarf2out.c: Likewise. * final.c: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * gimple-expr.c: Likewise. * gimple-fold.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple.c: Likewise. * gimplify.c: Likewise. * hsa-common.c: Likewise. * hsa-gen.c: Likewise. * internal-fn.c: Likewise. * ipa-chkp.c: Likewise. * ipa-cp.c: Likewise. * ipa-devirt.c: Likewise. * ipa-fnsummary.c: Likewise. * ipa-inline.c: Likewise. * ipa-visibility.c: Likewise. * ipa.c: Likewise. * lto-cgraph.c: Likewise. * omp-expand.c: Likewise. * omp-general.c: Likewise. * omp-low.c: Likewise. * omp-offload.c: Likewise. * omp-simd-clone.c: Likewise. * opts-global.c: Likewise. * passes.c: Likewise. * predict.c: Likewise. * sancov.c: Likewise. * sanopt.c: Likewise. * symtab.c: Likewise. * toplev.c: Likewise. * trans-mem.c: Likewise. * tree-chkp.c: Likewise. * tree-eh.c: Likewise. * tree-into-ssa.c: Likewise. * tree-object-size.c: Likewise. * tree-parloops.c: Likewise. * tree-profile.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-streamer-in.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vrp.c: Likewise. * tsan.c: Likewise. * ubsan.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * tree.c: Remove functions moved to attribs.[ch]. * tree.h: Likewise. * config/aarch64/aarch64.c: Add attrs.h header file. * config/alpha/alpha.c: Likewise. * config/arc/arc.c: Likewise. * config/arm/arm.c: Likewise. * config/avr/avr.c: Likewise. * config/bfin/bfin.c: Likewise. * config/c6x/c6x.c: Likewise. * config/cr16/cr16.c: Likewise. * config/cris/cris.c: Likewise. * config/darwin.c: Likewise. * config/epiphany/epiphany.c: Likewise. * config/fr30/fr30.c: Likewise. * config/frv/frv.c: Likewise. * config/ft32/ft32.c: Likewise. * config/h8300/h8300.c: Likewise. * config/i386/winnt.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/lm32/lm32.c: Likewise. * config/m32c/m32c.c: Likewise. * config/m32r/m32r.c: Likewise. * config/m68k/m68k.c: Likewise. * config/mcore/mcore.c: Likewise. * config/microblaze/microblaze.c: Likewise. * config/mips/mips.c: Likewise. * config/mmix/mmix.c: Likewise. * config/mn10300/mn10300.c: Likewise. * config/moxie/moxie.c: Likewise. * config/msp430/msp430.c: Likewise. * config/nds32/nds32-isr.c: Likewise. * config/nds32/nds32.c: Likewise. * config/nios2/nios2.c: Likewise. * config/nvptx/nvptx.c: Likewise. * config/pa/pa.c: Likewise. * config/pdp11/pdp11.c: Likewise. * config/powerpcspe/powerpcspe.c: Likewise. * config/riscv/riscv.c: Likewise. * config/rl78/rl78.c: Likewise. * config/rx/rx.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sol2.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/tilegx/tilegx.c: Likewise. * config/tilepro/tilepro.c: Likewise. * config/v850/v850.c: Likewise. * config/vax/vax.c: Likewise. * config/visium/visium.c: Likewise. * config/xtensa/xtensa.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * call.c: Include header files. * cp-gimplify.c: Likewise. * cp-ubsan.c: Likewise. * cvt.c: Likewise. * init.c: Likewise. * search.c: Likewise. * semantics.c: Likewise. * typeck.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * lto-lang.c: Include header files. * lto-symtab.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * c-convert.c: Include header files. * c-typeck.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * c-ada-spec.c: Include header files. * c-ubsan.c: Likewise. * c-warn.c: Likewise. 2017-08-08 Martin Liska <mliska@suse.cz> * trans-types.c: Include header files. From-SVN: r250946
Martin Liska committed
-
- 07 Aug, 2017 1 commit
-
-
2017-08-07 Martin Liska <mliska@suse.cz> * attribs.h (canonicalize_attr_name): New function. (cmp_attribs): Move from c-format.c and adjusted. (is_attribute_p): Moved from tree.h. * tree-inline.c: Add new includes. * tree.c (cmp_attrib_identifiers): Use cmp_attribs. (private_is_attribute_p): Remove. (private_lookup_attribute): Likewise. (private_lookup_attribute_by_prefix): Simplify. (remove_attribute): Use is_attribute_p. * tree.h: Remove removed declarations. 2017-08-07 Martin Liska <mliska@suse.cz> * array-notation-common.c: Add new includes. * c-format.c( handle_format_attribute): Canonicalize a format function name. * c-lex.c (c_common_has_attribute): Canonicalize name of an attribute. * c-pretty-print.c: Add new include. 2017-08-07 Martin Liska <mliska@suse.cz> * parser.c (cp_parser_gnu_attribute_list): Canonicalize name of an attribute. (cp_parser_std_attribute): Likewise. * tree.c: Add new include. 2017-08-07 Martin Liska <mliska@suse.cz> * c-parser.c (c_parser_attributes): Canonicalize name of an attribute. 2017-08-07 Martin Liska <mliska@suse.cz> * go-gcc.cc (Gcc_backend::function): Look up for no_split_stack and not __no_split_stack__. 2017-08-07 Martin Liska <mliska@suse.cz> * g++.dg/cpp0x/pr65558.C: Update scanned pattern. * gcc.dg/parm-impl-decl-1.c: Likewise. * gcc.dg/parm-impl-decl-3.c: Likewise. * gcc.dg/Wattributes-5.c: New test. From-SVN: r250911
Martin Liska committed
-
- 02 Aug, 2017 1 commit
-
-
PR c/81448 PR c/81306 * c-warn.c (warn_for_multistatement_macros): Prevent bogus warnings. Avoid walking MACRO_MAP_LOCATIONS. * c-c++-common/Wmultistatement-macros-13.c: New test. From-SVN: r250822
Marek Polacek committed
-