diff options
author | Joseph Myers <joseph@codesourcery.com> | 2020-11-13 22:45:22 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2020-11-13 22:45:22 +0000 |
commit | e400a64936efdc2424044aa74c0424df16242d2d (patch) | |
tree | 5306e5a590540d75f925bd5f41600102ed65039c /libcpp | |
parent | f3dc991fba095b38b15cd667e5cd15b1c418e809 (diff) | |
download | gcc-e400a64936efdc2424044aa74c0424df16242d2d.zip gcc-e400a64936efdc2424044aa74c0424df16242d2d.tar.gz gcc-e400a64936efdc2424044aa74c0424df16242d2d.tar.bz2 |
c: C2x binary constants
C2x adds binary integer constants (approved at the last WG14 meeting,
though not yet added to the working draft in git). Configure libcpp
to consider these a standard feature in C2x mode, with appropriate
updates to diagnostics including support for diagnosing them with
-std=c2x -Wc11-c2x-compat.
Bootstrapped with no regressions for x86_64-pc-linux-gnu.
gcc/testsuite/
2020-11-13 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/binary-constants-2.c, gcc.dg/binary-constants-3.c,
gcc.dg/system-binary-constants-1.c: Update expected diagnostics.
* gcc.dg/c11-binary-constants-1.c,
gcc.dg/c11-binary-constants-2.c, gcc.dg/c2x-binary-constants-1.c,
gcc.dg/c2x-binary-constants-2.c, gcc.dg/c2x-binary-constants-3.c:
New tests.
libcpp/
2020-11-13 Joseph Myers <joseph@codesourcery.com>
* expr.c (cpp_classify_number): Update diagnostic for binary
constants for C. Also diagnose binary constants for
-Wc11-c2x-compat.
* init.c (lang_defaults): Enable binary constants for GNUC2X and
STDC2X.
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/expr.c | 23 | ||||
-rw-r--r-- | libcpp/init.c | 4 |
2 files changed, 17 insertions, 10 deletions
diff --git a/libcpp/expr.c b/libcpp/expr.c index e01a47a..b98c038 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -812,14 +812,21 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token, if ((result & CPP_N_IMAGINARY) && CPP_PEDANTIC (pfile)) cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, "imaginary constants are a GCC extension"); - if (radix == 2 - && !CPP_OPTION (pfile, binary_constants) - && CPP_PEDANTIC (pfile)) - cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, - CPP_OPTION (pfile, cplusplus) - ? N_("binary constants are a C++14 feature " - "or GCC extension") - : N_("binary constants are a GCC extension")); + if (radix == 2) + { + if (!CPP_OPTION (pfile, binary_constants) + && CPP_PEDANTIC (pfile)) + cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0, + CPP_OPTION (pfile, cplusplus) + ? N_("binary constants are a C++14 feature " + "or GCC extension") + : N_("binary constants are a C2X feature " + "or GCC extension")); + else if (CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) > 0) + cpp_warning_with_line (pfile, CPP_W_C11_C2X_COMPAT, + virtual_location, 0, + "binary constants are a C2X feature"); + } if (radix == 10) result |= CPP_N_DECIMAL; diff --git a/libcpp/init.c b/libcpp/init.c index 1b43802..76882bc 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -102,13 +102,13 @@ static const struct lang_flags lang_defaults[] = /* GNUC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0 }, /* GNUC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0 }, /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0 }, - /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1 }, + /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1 }, /* STDC89 */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, /* STDC94 */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, /* STDC99 */ { 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, /* STDC11 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, /* STDC17 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, - /* STDC2X */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1 }, + /* STDC2X */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 }, /* GNUCXX */ { 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }, /* CXX98 */ { 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0 }, /* GNUCXX11 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0 }, |