aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorJanis Johnson <janis187@us.ibm.com>2009-05-07 22:34:08 +0000
committerJanis Johnson <janis@gcc.gnu.org>2009-05-07 22:34:08 +0000
commit6ec637a4b85abeee6570e4cb7786df53eadbaa40 (patch)
tree478b0f3a70632c6c119442bb4244b21106b8a03a /gcc/c-lex.c
parent2995ed9a270259c4fbaa457913860bfab76565c0 (diff)
downloadgcc-6ec637a4b85abeee6570e4cb7786df53eadbaa40.zip
gcc-6ec637a4b85abeee6570e4cb7786df53eadbaa40.tar.gz
gcc-6ec637a4b85abeee6570e4cb7786df53eadbaa40.tar.bz2
re PR c/39037 (FLOAT_CONST_DECIMAL64 pragma not supported)
gcc/ PR c/39037 * c-common.h (mark_valid_location_for_stdc_pragma, valid_location_for_stdc_pragma_p, set_float_const_decimal64, clear_float_const_decimal64, float_const_decimal64_p): New. * c.opt (Wunsuffixed-float-constants): New. * c-lex.c (interpret_float): Use pragma FLOAT_CONST_DECIMAL64 for unsuffixed float constant, handle new warning. * c-cppbuiltin.c (c_cpp_builtins): Use cast for double constants. * c-decl.c (c_scope): New flag float_const_decimal64. (set_float_const_decimal64, clear_float_const_decimal64, float_const_decimal64_p): New. (push_scope): Set new flag. * c-parser.c (c_parser_translation_unit): Mark when it's valid to use STDC pragmas. (c_parser_external_declaration): Ditto. (c_parser_compound_statement_nostart): Ditto. * c-pragma.c (valid_location_for_stdc_pragma, mark_valid_location_for_stdc_pragma, valid_location_for_stdc_pragma_p, handle_stdc_pragma, handle_pragma_float_const_decimal64): New. (init_pragma): Register new pragma FLOAT_CONST_DECIMAL64. * cp/semantics.c (valid_location_for_stdc_pragma_p, set_float_const_decimal64, clear_float_const_decimal64, float_const_decimal64_p): New dummy functions. * doc/extend.texi (Decimal Float): Remove statement that the pragma, and suffix for double constants, are not supported. * doc/invoke.texi (Warning Options): List new option. (-Wunsuffixed-float-constants): New. gcc/testsuite PR c/39037 * gcc.dg/Wunsuffixed-float-constants-1.c: New test. * gcc.dg/cpp/pragma-float-const-decimal64-1.c: New test. * gcc.dg/dfp/float-constant-double.c: New test. * gcc.dg/dfp/pragma-float-const-decimal64-1.c: New test. * gcc.dg/dfp/pragma-float-const-decimal64-2.c: New test. * gcc.dg/dfp/pragma-float-const-decimal64-3.c: New test. * gcc.dg/dfp/pragma-float-const-decimal64-4.c: New test. * gcc.dg/dfp/pragma-float-const-decimal64-5.c: New test. * gcc.dg/dfp/pragma-float-const-decimal64-6.c: New test. * gcc.dg/dfp/pragma-float-const-decimal64-7.c: New test. * gcc.dg/dfp/pragma-float-const-decimal64-8.c: New test. * g++.dg/cpp/pragma-float-const-decimal64-1.C: New test. From-SVN: r147259
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index df63548..fc89279 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -617,11 +617,21 @@ interpret_float (const cpp_token *token, unsigned int flags)
char *copy;
size_t copylen;
- /* Default (no suffix) is double. */
+ /* Default (no suffix) depends on whether the FLOAT_CONST_DECIMAL64
+ pragma has been used and is either double or _Decimal64. Types
+ that are not allowed with decimal float default to double. */
if (flags & CPP_N_DEFAULT)
{
flags ^= CPP_N_DEFAULT;
flags |= CPP_N_MEDIUM;
+
+ if (((flags & CPP_N_HEX) == 0) && ((flags & CPP_N_IMAGINARY) == 0))
+ {
+ warning (OPT_Wunsuffixed_float_constants,
+ "unsuffixed float constant");
+ if (float_const_decimal64_p ())
+ flags |= CPP_N_DFLOAT;
+ }
}
/* Decode _Fract and _Accum. */