diff options
author | Joseph Myers <joseph@codesourcery.com> | 2019-10-11 18:32:48 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2019-10-11 18:32:48 +0100 |
commit | fe2bc27cdb6d572da0163d77e787ba644b400753 (patch) | |
tree | abec31c70851140a7af2d5ec10894a47c357ec8a | |
parent | 6334c1f49fe3e3b81dfe90f25fdf89a3ddb557b8 (diff) | |
download | gcc-fe2bc27cdb6d572da0163d77e787ba644b400753.zip gcc-fe2bc27cdb6d572da0163d77e787ba644b400753.tar.gz gcc-fe2bc27cdb6d572da0163d77e787ba644b400753.tar.bz2 |
Support _Decimal* keywords for C2x.
ISO C2x adds decimal floating point as an optional standard feature.
This patch accordingly makes GCC accept the _Decimal* keywords in
strict C2x mode, using pedwarn_c11 to get a warning for
-Wc11-c2x-compat. (Constants, where the pedwarn is in libcpp, will be
dealt with separately.)
The _Decimal* keywords are marked with D_EXT, meaning they are not
considered keywords at all in strict conformance modes. This is
contrary to the normal practice for most implementation-namespace
keywords, which are accepted in all standards modes but with
appropriate pedwarns for older standards. This patch removes D_EXT
from those keywords so they are accepted as keywords for all
standards, consequently removing the gcc.dg/dfp/keywords-ignored-c99.c
test that is no longer valid.
(A new D_C2X for keywords will still be needed if any new keywords get
added that aren't in the implementation namespace for older standards;
there are proposals for such keywords, albeit as predefined macros
that might not actually need new keywords in the compiler in all
cases. If the DFP keywords end up as decimal32 etc., of course
appropriate compiler and testcase changes will be needed, and a
version of keywords-ignored-c99.c would make sense again with such
spellings.)
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
gcc/c:
* c-decl.c (declspecs_add_type): Use pedwarn_c11 for DFP types.
gcc/c-family:
* c-common.c (c_common_reswords): Do not use D_EXT for _Decimal32,
_Decimal64 and _Decimal128.
gcc/testsuite:
* gcc.dg/dfp/c11-keywords-1.c, gcc.dg/dfp/c11-keywords-2.c,
gcc.dg/dfp/c2x-keywords-1.c, gcc.dg/dfp/c2x-keywords-2.c: New
tests.
* gcc.dg/dfp/keywords-ignored-c99.c: Remove test.
* gcc.dg/dfp/constants-c99.c, gcc.dg/dfp/keywords-c89.c,
gcc.dg/dfp/keywords-c99.c: Use -pedantic-errors.
From-SVN: r276896
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 6 | ||||
-rw-r--r-- | gcc/c/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/c11-keywords-1.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/c11-keywords-2.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/c2x-keywords-1.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/c2x-keywords-2.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/constants-c99.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/keywords-c89.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/keywords-c99.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/keywords-ignored-c99.c | 15 |
13 files changed, 57 insertions, 25 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index a41e910..a0ce54b 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2019-10-11 Joseph Myers <joseph@codesourcery.com> + + * c-common.c (c_common_reswords): Do not use D_EXT for _Decimal32, + _Decimal64 and _Decimal128. + 2019-10-10 Joseph Myers <joseph@codesourcery.com> * c-cppbuiltin.c (c_cpp_builtins): Do not define macros for DFP diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 7169813..909f52a 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -351,9 +351,9 @@ const struct c_common_resword c_common_reswords[] = { "_Float32x", RID_FLOAT32X, D_CONLY }, { "_Float64x", RID_FLOAT64X, D_CONLY }, { "_Float128x", RID_FLOAT128X, D_CONLY }, - { "_Decimal32", RID_DFLOAT32, D_CONLY | D_EXT }, - { "_Decimal64", RID_DFLOAT64, D_CONLY | D_EXT }, - { "_Decimal128", RID_DFLOAT128, D_CONLY | D_EXT }, + { "_Decimal32", RID_DFLOAT32, D_CONLY }, + { "_Decimal64", RID_DFLOAT64, D_CONLY }, + { "_Decimal128", RID_DFLOAT128, D_CONLY }, { "_Fract", RID_FRACT, D_CONLY | D_EXT }, { "_Accum", RID_ACCUM, D_CONLY | D_EXT }, { "_Sat", RID_SAT, D_CONLY | D_EXT }, diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index fa1001c..894f5e7 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,7 @@ +2019-10-11 Joseph Myers <joseph@codesourcery.com> + + * c-decl.c (declspecs_add_type): Use pedwarn_c11 for DFP types. + 2019-10-10 Jakub Jelinek <jakub@redhat.com> * c-parser.c (c_parser_omp_all_clauses): Add NESTED_P argument, if diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 132fa3e..f67033b 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -10959,8 +10959,9 @@ declspecs_add_type (location_t loc, struct c_declspecs *specs, error_at (loc, ("decimal floating-point not supported " "for this target")); - pedwarn (loc, OPT_Wpedantic, - "ISO C does not support decimal floating-point"); + pedwarn_c11 (loc, OPT_Wpedantic, + "ISO C does not support decimal floating-point " + "before C2X"); return specs; case RID_FRACT: case RID_ACCUM: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 488eba9..2459275 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2019-10-11 Joseph Myers <joseph@codesourcery.com> + + * gcc.dg/dfp/c11-keywords-1.c, gcc.dg/dfp/c11-keywords-2.c, + gcc.dg/dfp/c2x-keywords-1.c, gcc.dg/dfp/c2x-keywords-2.c: New + tests. + * gcc.dg/dfp/keywords-ignored-c99.c: Remove test. + * gcc.dg/dfp/constants-c99.c, gcc.dg/dfp/keywords-c89.c, + gcc.dg/dfp/keywords-c99.c: Use -pedantic-errors. + 2019-10-11 Tobias Burnus <tobias@codesourcery.com> PR fortran/92050 diff --git a/gcc/testsuite/gcc.dg/dfp/c11-keywords-1.c b/gcc/testsuite/gcc.dg/dfp/c11-keywords-1.c new file mode 100644 index 0000000..5a5c862 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/c11-keywords-1.c @@ -0,0 +1,7 @@ +/* Test that _Decimal* keywords diagnosed in C11 mode: -pedantic. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic" } */ + +_Decimal32 d32; /* { dg-warning "ISO C does not support" } */ +_Decimal64 d64; /* { dg-warning "ISO C does not support" } */ +_Decimal128 d128; /* { dg-warning "ISO C does not support" } */ diff --git a/gcc/testsuite/gcc.dg/dfp/c11-keywords-2.c b/gcc/testsuite/gcc.dg/dfp/c11-keywords-2.c new file mode 100644 index 0000000..7c7f3d9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/c11-keywords-2.c @@ -0,0 +1,7 @@ +/* Test that _Decimal* keywords diagnosed in C11 mode: -pedantic-errors. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +_Decimal32 d32; /* { dg-error "ISO C does not support" } */ +_Decimal64 d64; /* { dg-error "ISO C does not support" } */ +_Decimal128 d128; /* { dg-error "ISO C does not support" } */ diff --git a/gcc/testsuite/gcc.dg/dfp/c2x-keywords-1.c b/gcc/testsuite/gcc.dg/dfp/c2x-keywords-1.c new file mode 100644 index 0000000..a3a1da5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/c2x-keywords-1.c @@ -0,0 +1,7 @@ +/* Test that _Decimal* keywords are accepted in C2X mode. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +_Decimal32 d32; +_Decimal64 d64; +_Decimal128 d128; diff --git a/gcc/testsuite/gcc.dg/dfp/c2x-keywords-2.c b/gcc/testsuite/gcc.dg/dfp/c2x-keywords-2.c new file mode 100644 index 0000000..9655dd0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/c2x-keywords-2.c @@ -0,0 +1,7 @@ +/* Test that _Decimal* keywords are accepted in C2X mode: compat warnings. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -Wc11-c2x-compat" } */ + +_Decimal32 d32; /* { dg-warning "ISO C does not support" } */ +_Decimal64 d64; /* { dg-warning "ISO C does not support" } */ +_Decimal128 d128; /* { dg-warning "ISO C does not support" } */ diff --git a/gcc/testsuite/gcc.dg/dfp/constants-c99.c b/gcc/testsuite/gcc.dg/dfp/constants-c99.c index 6a48bf5..5a135c5 100644 --- a/gcc/testsuite/gcc.dg/dfp/constants-c99.c +++ b/gcc/testsuite/gcc.dg/dfp/constants-c99.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-std=c99 -Wno-overflow" } */ +/* { dg-options "-std=c99 -Wno-overflow -pedantic-errors" } */ /* N1150 6: Constants. C99 6.4.4.2: Floating constants. */ diff --git a/gcc/testsuite/gcc.dg/dfp/keywords-c89.c b/gcc/testsuite/gcc.dg/dfp/keywords-c89.c index 8c96d60..a67c3d6 100644 --- a/gcc/testsuite/gcc.dg/dfp/keywords-c89.c +++ b/gcc/testsuite/gcc.dg/dfp/keywords-c89.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-std=c89" } */ +/* { dg-options "-std=c89 -pedantic-errors" } */ -/* Decimal float keywords are not recognized in C89 mode. */ +/* Decimal float keywords are diagnosed in pedantic C89 mode. */ _Decimal32 x; /* { dg-error "" } */ _Decimal64 y; /* { dg-error "" } */ diff --git a/gcc/testsuite/gcc.dg/dfp/keywords-c99.c b/gcc/testsuite/gcc.dg/dfp/keywords-c99.c index 8a62fb9..f51900e 100644 --- a/gcc/testsuite/gcc.dg/dfp/keywords-c99.c +++ b/gcc/testsuite/gcc.dg/dfp/keywords-c99.c @@ -1,7 +1,7 @@ /* { dg-do compile } */ -/* { dg-options "-std=c99" } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ -/* Decimal float keywords are not recognized in C99 mode. */ +/* Decimal float keywords are diagnosed in pedantic C99 mode. */ _Decimal32 x; /* { dg-error "" } */ _Decimal64 y; /* { dg-error "" } */ diff --git a/gcc/testsuite/gcc.dg/dfp/keywords-ignored-c99.c b/gcc/testsuite/gcc.dg/dfp/keywords-ignored-c99.c deleted file mode 100644 index a4258aa..0000000 --- a/gcc/testsuite/gcc.dg/dfp/keywords-ignored-c99.c +++ /dev/null @@ -1,15 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-std=c99" } */ - -/* Decimal float keywords are not reserved for c99. */ - -int _Decimal32 (void) -{ - return 0; -} - -int foo (int i) -{ - int _Decimal64 = i * 2; - return _Decimal64; -} |