diff options
author | Martin Liska <mliska@suse.cz> | 2022-10-15 15:32:39 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-10-15 15:32:39 +0200 |
commit | 2c92cfe87d2bb8aa0eb78f3932fca16699cb35c9 (patch) | |
tree | b118381a0a883a762ddd56c0e91608d937ee8bdf /gcc/c-family | |
parent | bd21c04269deded2c7476ceca1100a26f28ea526 (diff) | |
parent | baeec7cc83b19b46d1c73523f06efa7ea2b30390 (diff) | |
download | gcc-2c92cfe87d2bb8aa0eb78f3932fca16699cb35c9.zip gcc-2c92cfe87d2bb8aa0eb78f3932fca16699cb35c9.tar.gz gcc-2c92cfe87d2bb8aa0eb78f3932fca16699cb35c9.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 24 | ||||
-rw-r--r-- | gcc/c-family/c-common.def | 7 | ||||
-rw-r--r-- | gcc/c-family/c-cppbuiltin.cc | 21 | ||||
-rw-r--r-- | gcc/c-family/c-lex.cc | 21 | ||||
-rw-r--r-- | gcc/c-family/c-opts.cc | 12 |
5 files changed, 66 insertions, 19 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 1fade0a..2047e2e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,27 @@ +2022-10-14 Jakub Jelinek <jakub@redhat.com> + + * c-cppbuiltin.cc (c_cpp_builtins): If bfloat16_type_node, + predefine __BFLT16_*__ macros and for C++23 also + __STDCPP_BFLOAT16_T__. Predefine bfloat16_type_node related + macros for -fbuilding-libgcc. + * c-lex.cc (interpret_float): Handle CPP_N_BFLOAT16. + +2022-10-14 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/323 + PR c++/107097 + * c-common.def (EXCESS_PRECISION_EXPR): Remove comment part about + the tree being specific to C/ObjC. + * c-opts.cc (c_common_post_options): Handle flag_excess_precision + in C++ the same as in C. + * c-lex.cc (interpret_float): Set const_type to excess_precision () + even for C++. + +2022-10-13 Joseph Myers <joseph@codesourcery.com> + + * c-cppbuiltin.cc (builtin_define_float_constants): Do not use + value 2 for *_IS_IEC_60559. + 2022-10-12 Lewis Hyatt <lhyatt@gmail.com> PR preprocessor/60014 diff --git a/gcc/c-family/c-common.def b/gcc/c-family/c-common.def index 0759ace..dd8be7f 100644 --- a/gcc/c-family/c-common.def +++ b/gcc/c-family/c-common.def @@ -38,10 +38,9 @@ along with GCC; see the file COPYING3. If not see not. */ DEFTREECODE (C_MAYBE_CONST_EXPR, "c_maybe_const_expr", tcc_expression, 2) -/* An EXCESS_PRECISION_EXPR, currently only used for C and Objective - C, represents an expression evaluated in greater range or precision - than its type. The type of the EXCESS_PRECISION_EXPR is the - semantic type while the operand represents what is actually being +/* An EXCESS_PRECISION_EXPR represents an expression evaluated in greater + range or precision than its type. The type of the EXCESS_PRECISION_EXPR + is the semantic type while the operand represents what is actually being evaluated. */ DEFTREECODE (EXCESS_PRECISION_EXPR, "excess_precision_expr", tcc_expression, 1) diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc index 2e39acb..cdb658f 100644 --- a/gcc/c-family/c-cppbuiltin.cc +++ b/gcc/c-family/c-cppbuiltin.cc @@ -1260,6 +1260,13 @@ c_cpp_builtins (cpp_reader *pfile) builtin_define_float_constants (prefix, ggc_strdup (csuffix), "%s", csuffix, FLOATN_NX_TYPE_NODE (i)); } + if (bfloat16_type_node) + { + if (c_dialect_cxx () && cxx_dialect > cxx20) + cpp_define (pfile, "__STDCPP_BFLOAT16_T__=1"); + builtin_define_float_constants ("BFLT16", "BF16", "%s", + "BF16", bfloat16_type_node); + } /* For float.h. */ if (targetm.decimal_float_supported_p ()) @@ -1370,6 +1377,12 @@ c_cpp_builtins (cpp_reader *pfile) suffix[0] = 'l'; memcpy (float_h_prefix, "LDBL", 5); } + else if (bfloat16_type_node + && mode == TYPE_MODE (bfloat16_type_node)) + { + memcpy (suffix, "bf16", 5); + memcpy (float_h_prefix, "BFLT16", 7); + } else { bool found_suffix = false; @@ -1396,22 +1409,28 @@ c_cpp_builtins (cpp_reader *pfile) machine_mode float16_type_mode = (float16_type_node ? TYPE_MODE (float16_type_node) : VOIDmode); + machine_mode bfloat16_type_mode = (bfloat16_type_node + ? TYPE_MODE (bfloat16_type_node) + : VOIDmode); switch (targetm.c.excess_precision (EXCESS_PRECISION_TYPE_IMPLICIT)) { case FLT_EVAL_METHOD_UNPREDICTABLE: case FLT_EVAL_METHOD_PROMOTE_TO_LONG_DOUBLE: excess_precision = (mode == float16_type_mode + || mode == bfloat16_type_mode || mode == TYPE_MODE (float_type_node) || mode == TYPE_MODE (double_type_node)); break; case FLT_EVAL_METHOD_PROMOTE_TO_DOUBLE: excess_precision = (mode == float16_type_mode + || mode == bfloat16_type_mode || mode == TYPE_MODE (float_type_node)); break; case FLT_EVAL_METHOD_PROMOTE_TO_FLOAT: - excess_precision = mode == float16_type_mode; + excess_precision = (mode == float16_type_mode + || mode == bfloat16_type_mode); break; case FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16: excess_precision = false; diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc index 050fa77..89c65ac 100644 --- a/gcc/c-family/c-lex.cc +++ b/gcc/c-family/c-lex.cc @@ -1000,6 +1000,22 @@ interpret_float (const cpp_token *token, unsigned int flags, pedwarn (input_location, OPT_Wpedantic, "non-standard suffix on floating constant"); } + else if ((flags & CPP_N_BFLOAT16) != 0) + { + type = bfloat16_type_node; + if (type == NULL_TREE) + { + error ("unsupported non-standard suffix on floating constant"); + return error_mark_node; + } + if (!c_dialect_cxx ()) + pedwarn (input_location, OPT_Wpedantic, + "non-standard suffix on floating constant"); + else if (cxx_dialect < cxx23) + pedwarn (input_location, OPT_Wpedantic, + "%<bf16%> or %<BF16%> suffix on floating constant only " + "available with %<-std=c++2b%> or %<-std=gnu++2b%>"); + } else if ((flags & CPP_N_WIDTH) == CPP_N_LARGE) type = long_double_type_node; else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL @@ -1008,10 +1024,7 @@ interpret_float (const cpp_token *token, unsigned int flags, else type = double_type_node; - if (c_dialect_cxx ()) - const_type = NULL_TREE; - else - const_type = excess_precision_type (type); + const_type = excess_precision_type (type); if (!const_type) const_type = type; diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc index 55cebf6..32b929e 100644 --- a/gcc/c-family/c-opts.cc +++ b/gcc/c-family/c-opts.cc @@ -812,17 +812,9 @@ c_common_post_options (const char **pfilename) C_COMMON_OVERRIDE_OPTIONS; #endif - /* Excess precision other than "fast" requires front-end - support. */ - if (c_dialect_cxx ()) - { - if (flag_excess_precision == EXCESS_PRECISION_STANDARD) - sorry ("%<-fexcess-precision=standard%> for C++"); - flag_excess_precision = EXCESS_PRECISION_FAST; - } - else if (flag_excess_precision == EXCESS_PRECISION_DEFAULT) + if (flag_excess_precision == EXCESS_PRECISION_DEFAULT) flag_excess_precision = (flag_iso ? EXCESS_PRECISION_STANDARD - : EXCESS_PRECISION_FAST); + : EXCESS_PRECISION_FAST); /* ISO C restricts floating-point expression contraction to within source-language expressions (-ffp-contract=on, currently an alias |