diff options
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/builtin-types.def | 24 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 9 | ||||
-rw-r--r-- | gcc/c-family/c-format.c | 2 | ||||
-rw-r--r-- | gcc/c-family/c-lex.c | 7 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 4 | ||||
-rw-r--r-- | gcc/lto/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/lto/lto-lang.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c2x-no-dfp-1.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/gnu2x-builtins-no-dfp-1.c | 18 | ||||
-rw-r--r-- | gcc/tree.c | 37 |
15 files changed, 134 insertions, 32 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 58be9e9..2b63623 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,15 @@ 2019-11-25 Joseph Myers <joseph@codesourcery.com> + PR c/91985 + * builtin-types.def (BT_DFLOAT32, BT_DFLOAT64, BT_DFLOAT128) + (BT_DFLOAT32_PTR, BT_DFLOAT64_PTR, BT_DFLOAT128_PTR): Define to + error_mark_node if corresponding global tree node is NULL. + * tree.c (build_common_tree_nodes): Do not initialize + dfloat32_type_node, dfloat64_type_node or dfloat128_type_node if + decimal floating-point not supported. + +2019-11-25 Joseph Myers <joseph@codesourcery.com> + * attribs.c (decl_attributes): Do not ignore C++11 attributes on types. diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def index e5c9e06..800b751 100644 --- a/gcc/builtin-types.def +++ b/gcc/builtin-types.def @@ -136,12 +136,24 @@ DEF_PRIMITIVE_TYPE (BT_WINT, wint_type_node) DEF_PRIMITIVE_TYPE (BT_STRING, string_type_node) DEF_PRIMITIVE_TYPE (BT_CONST_STRING, const_string_type_node) -DEF_PRIMITIVE_TYPE (BT_DFLOAT32, dfloat32_type_node) -DEF_PRIMITIVE_TYPE (BT_DFLOAT64, dfloat64_type_node) -DEF_PRIMITIVE_TYPE (BT_DFLOAT128, dfloat128_type_node) -DEF_PRIMITIVE_TYPE (BT_DFLOAT32_PTR, dfloat32_ptr_type_node) -DEF_PRIMITIVE_TYPE (BT_DFLOAT64_PTR, dfloat64_ptr_type_node) -DEF_PRIMITIVE_TYPE (BT_DFLOAT128_PTR, dfloat128_ptr_type_node) +DEF_PRIMITIVE_TYPE (BT_DFLOAT32, (dfloat32_type_node + ? dfloat32_type_node + : error_mark_node)) +DEF_PRIMITIVE_TYPE (BT_DFLOAT64, (dfloat64_type_node + ? dfloat64_type_node + : error_mark_node)) +DEF_PRIMITIVE_TYPE (BT_DFLOAT128, (dfloat128_type_node + ? dfloat128_type_node + : error_mark_node)) +DEF_PRIMITIVE_TYPE (BT_DFLOAT32_PTR, (dfloat32_ptr_type_node + ? dfloat32_ptr_type_node + : error_mark_node)) +DEF_PRIMITIVE_TYPE (BT_DFLOAT64_PTR, (dfloat64_ptr_type_node + ? dfloat64_ptr_type_node + : error_mark_node)) +DEF_PRIMITIVE_TYPE (BT_DFLOAT128_PTR, (dfloat128_ptr_type_node + ? dfloat128_ptr_type_node + : error_mark_node)) DEF_PRIMITIVE_TYPE (BT_VALIST_REF, va_list_ref_type_node) DEF_PRIMITIVE_TYPE (BT_VALIST_ARG, va_list_arg_type_node) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 281d7f4..30b5b6a 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,14 @@ +2019-11-25 Joseph Myers <joseph@codesourcery.com> + + PR c/91985 + * c-common.c (c_common_type_for_mode): Handle decimal + floating-point types being NULL_TREE. + * c-format.c (get_format_for_type_1): Handle specified types being + NULL_TREE. + * c-lex.c (interpret_float): Give an error for decimal + floating-point constants when decimal floating-point not + supported. + 2019-11-23 Jakub Jelinek <jakub@redhat.com> PR middle-end/83859 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 3e70b6d..5b9af1a 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -2321,11 +2321,14 @@ c_common_type_for_mode (machine_mode mode, int unsignedp) return build_vector_type_for_mode (inner_type, mode); } - if (mode == TYPE_MODE (dfloat32_type_node)) + if (dfloat32_type_node != NULL_TREE + && mode == TYPE_MODE (dfloat32_type_node)) return dfloat32_type_node; - if (mode == TYPE_MODE (dfloat64_type_node)) + if (dfloat64_type_node != NULL_TREE + && mode == TYPE_MODE (dfloat64_type_node)) return dfloat64_type_node; - if (mode == TYPE_MODE (dfloat128_type_node)) + if (dfloat128_type_node != NULL_TREE + && mode == TYPE_MODE (dfloat128_type_node)) return dfloat128_type_node; if (ALL_SCALAR_FIXED_POINT_MODE_P (mode)) diff --git a/gcc/c-family/c-format.c b/gcc/c-family/c-format.c index d70d1e0..519bc8f 100644 --- a/gcc/c-family/c-format.c +++ b/gcc/c-family/c-format.c @@ -4390,7 +4390,7 @@ get_format_for_type_1 (const format_kind_info *fki, tree arg_type, for (int i = 0; i < FMT_LEN_MAX; i++) { const format_type_detail *ftd = &spec->types[i]; - if (!ftd->type) + if (!ftd->type || *ftd->type == NULL_TREE) continue; if (matching_type_p (*ftd->type, effective_arg_type)) { diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c index d446633f..107c4c3 100644 --- a/gcc/c-family/c-lex.c +++ b/gcc/c-family/c-lex.c @@ -877,7 +877,12 @@ interpret_float (const cpp_token *token, unsigned int flags, /* Decode type based on width and properties. */ if (flags & CPP_N_DFLOAT) - if ((flags & CPP_N_WIDTH) == CPP_N_LARGE) + if (!targetm.decimal_float_supported_p ()) + { + error ("decimal floating-point not supported for this target"); + return error_mark_node; + } + else if ((flags & CPP_N_WIDTH) == CPP_N_LARGE) type = dfloat128_type_node; else if ((flags & CPP_N_WIDTH) == CPP_N_SMALL) type = dfloat32_type_node; diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 9f0b8ce..b9ec977 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,11 @@ 2019-11-25 Joseph Myers <joseph@codesourcery.com> + PR c/91985 + * c-decl.c (finish_declspecs): Use int instead of decimal + floating-point types if decimal floating-point not supported. + +2019-11-25 Joseph Myers <joseph@codesourcery.com> + * c-tree.h (struct c_declarator): Use a structure for id member. * c-decl.c (grokdeclarator): Extract attributes from cdk_id declarators at the start, not when handling individual declarators diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index a14f782..292a4cc 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -11633,7 +11633,9 @@ finish_declspecs (struct c_declspecs *specs) case cts_dfloat128: gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p && !specs->signed_p && !specs->unsigned_p && !specs->complex_p); - if (specs->typespec_word == cts_dfloat32) + if (!targetm.decimal_float_supported_p ()) + specs->type = integer_type_node; + else if (specs->typespec_word == cts_dfloat32) specs->type = dfloat32_type_node; else if (specs->typespec_word == cts_dfloat64) specs->type = dfloat64_type_node; diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index cdf6964..df9ddfa 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,9 @@ +2019-11-25 Joseph Myers <joseph@codesourcery.com> + + PR c/91985 + * lto-lang.c (lto_type_for_mode): Handle decimal floating-point + types being NULL_TREE. + 2019-11-22 Jan Hubicka <jh@suse.cz> * lto.c (lto_wpa_write_files): Call memory_block_pool::trim. diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index 3e37c37..f827867 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -1051,11 +1051,14 @@ lto_type_for_mode (machine_mode mode, int unsigned_p) return build_vector_type_for_mode (inner_type, mode); } - if (mode == TYPE_MODE (dfloat32_type_node)) + if (dfloat32_type_node != NULL_TREE + && mode == TYPE_MODE (dfloat32_type_node)) return dfloat32_type_node; - if (mode == TYPE_MODE (dfloat64_type_node)) + if (dfloat64_type_node != NULL_TREE + && mode == TYPE_MODE (dfloat64_type_node)) return dfloat64_type_node; - if (mode == TYPE_MODE (dfloat128_type_node)) + if (dfloat128_type_node != NULL_TREE + && mode == TYPE_MODE (dfloat128_type_node)) return dfloat128_type_node; if (ALL_SCALAR_FIXED_POINT_MODE_P (mode)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5ded904..6431a09 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,13 @@ 2019-11-25 Joseph Myers <joseph@codesourcery.com> + PR c/91985 + * gcc.dg/c2x-no-dfp-1.c, gcc.dg/gnu2x-builtins-no-dfp-1.c: New + tests. + * gcc.dg/fltconst-pedantic-dfp.c: Expect errors when decimal + floating-point not supported. + +2019-11-25 Joseph Myers <joseph@codesourcery.com> + * gcc.dg/gnu2x-attrs-1.c: Do not expect message about attributes appertaining to types. * gcc.dg/gnu2x-attrs-2.c: New test. diff --git a/gcc/testsuite/gcc.dg/c2x-no-dfp-1.c b/gcc/testsuite/gcc.dg/c2x-no-dfp-1.c new file mode 100644 index 0000000..2cfbb6c --- /dev/null +++ b/gcc/testsuite/gcc.dg/c2x-no-dfp-1.c @@ -0,0 +1,12 @@ +/* Test DFP types and constants rejected if no DFP support. Bug + 91985. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=c2x" } */ + +_Decimal32 d32a; /* { dg-error "not supported" } */ +_Decimal64 d64a; /* { dg-error "not supported" } */ +_Decimal128 d128a; /* { dg-error "not supported" } */ + +_Bool d32b = 1.0DF; /* { dg-error "not supported" } */ +_Bool d64b = 1.0DD; /* { dg-error "not supported" } */ +_Bool d128b = 1.0DL; /* { dg-error "not supported" } */ diff --git a/gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c b/gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c index d0d1c4c..6ff3091 100644 --- a/gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c +++ b/gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c @@ -2,5 +2,8 @@ /* { dg-options "-pedantic" } */ double a = 1.dl; /* { dg-warning "decimal float" } */ +/* { dg-error "not supported for this target" "not supported" { target { ! dfp } } .-1 } */ double b = 1.df; /* { dg-warning "decimal float" } */ +/* { dg-error "not supported for this target" "not supported" { target { ! dfp } } .-1 } */ double c = 1.dd; /* { dg-warning "decimal float" } */ +/* { dg-error "not supported for this target" "not supported" { target { ! dfp } } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/gnu2x-builtins-no-dfp-1.c b/gcc/testsuite/gcc.dg/gnu2x-builtins-no-dfp-1.c new file mode 100644 index 0000000..853a56e --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu2x-builtins-no-dfp-1.c @@ -0,0 +1,18 @@ +/* Test C2x built-in functions: test DFP built-in functions are not + available when no DFP support. Bug 91985. */ +/* { dg-do compile { target { ! dfp } } } */ +/* { dg-options "-std=gnu2x" } */ + +int fabsd32 (void); +int fabsd64 (void); +int fabsd128 (void); +int nand32 (void); +int nand64 (void); +int nand128 (void); + +__typeof__ (__builtin_fabsd32 (0)) d32; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_fabsd64 (0)) d64; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_fabsd128 (0)) d128; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_nand32 (0)) d32n; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_nand64 (0)) d64n; /* { dg-warning "implicit" } */ +__typeof__ (__builtin_nand128 (0)) d128n; /* { dg-warning "implicit" } */ @@ -10334,23 +10334,26 @@ build_common_tree_nodes (bool signed_char) uint64_type_node = make_or_reuse_type (64, 1); /* Decimal float types. */ - dfloat32_type_node = make_node (REAL_TYPE); - TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE; - SET_TYPE_MODE (dfloat32_type_node, SDmode); - layout_type (dfloat32_type_node); - dfloat32_ptr_type_node = build_pointer_type (dfloat32_type_node); - - dfloat64_type_node = make_node (REAL_TYPE); - TYPE_PRECISION (dfloat64_type_node) = DECIMAL64_TYPE_SIZE; - SET_TYPE_MODE (dfloat64_type_node, DDmode); - layout_type (dfloat64_type_node); - dfloat64_ptr_type_node = build_pointer_type (dfloat64_type_node); - - dfloat128_type_node = make_node (REAL_TYPE); - TYPE_PRECISION (dfloat128_type_node) = DECIMAL128_TYPE_SIZE; - SET_TYPE_MODE (dfloat128_type_node, TDmode); - layout_type (dfloat128_type_node); - dfloat128_ptr_type_node = build_pointer_type (dfloat128_type_node); + if (targetm.decimal_float_supported_p ()) + { + dfloat32_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE; + SET_TYPE_MODE (dfloat32_type_node, SDmode); + layout_type (dfloat32_type_node); + dfloat32_ptr_type_node = build_pointer_type (dfloat32_type_node); + + dfloat64_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (dfloat64_type_node) = DECIMAL64_TYPE_SIZE; + SET_TYPE_MODE (dfloat64_type_node, DDmode); + layout_type (dfloat64_type_node); + dfloat64_ptr_type_node = build_pointer_type (dfloat64_type_node); + + dfloat128_type_node = make_node (REAL_TYPE); + TYPE_PRECISION (dfloat128_type_node) = DECIMAL128_TYPE_SIZE; + SET_TYPE_MODE (dfloat128_type_node, TDmode); + layout_type (dfloat128_type_node); + dfloat128_ptr_type_node = build_pointer_type (dfloat128_type_node); + } complex_integer_type_node = build_complex_type (integer_type_node, true); complex_float_type_node = build_complex_type (float_type_node, true); |