summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorjanis <janis@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-01 17:31:26 +0000
committerjanis <janis@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-01 17:31:26 +0000
commitf8ed6d41439b594e4be05b47b2999a45b0c4fecb (patch)
tree6d2eb69c07acf9dfdd9f7f3af93d923a035bc1f3 /libcpp
parent098581e0aac4ee21dcaf02bb2bcb509cd10f655a (diff)
downloadgcc-f8ed6d41439b594e4be05b47b2999a45b0c4fecb.tar.gz
gcc/
PR c/29027 * c-lex.c (interpret_float): Default (no suffix) is double. libcpp/ PR c/29027 * include/cpplib.h (CPP_N_DEFAULT): Define. * expr.c (interpret_float_suffix): Recognize d or D for double, return new value for default. (cpp_classify_number): Issue pedwarn for use of d or D in suffix. gcc/testsuite/ PR c/29027 * gcc.dg/fltconst-1.c: Don't error for use of d or D in suffix. * gcc.dg/fltconst-2.c: New test. * gcc.dg/fltconst-double-pedantic-1.c: New test. * gcc.dg/fltconst-double-pedantic-2.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145422 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/expr.c21
-rw-r--r--libcpp/include/cpplib.h1
3 files changed, 23 insertions, 5 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index c7c723995c8..1ca914db97e 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,5 +1,11 @@
2009-04-01 Janis Johnson <janis187@us.ibm.com>
+ PR c/39027
+ * include/cpplib.h (CPP_N_DEFAULT): Define.
+ * expr.c (interpret_float_suffix): Recognize d or D for double,
+ return new value for default.
+ (cpp_classify_number): Issue pedwarn for use of d or D in suffix.
+
PR c/33466
* expr.c (interpret_float_suffix): Reject invalid suffix that uses
letters from decimal float and fixed-point suffixes.
diff --git a/libcpp/expr.c b/libcpp/expr.c
index dbbb05a60bb..688439799f9 100644
--- a/libcpp/expr.c
+++ b/libcpp/expr.c
@@ -84,10 +84,10 @@ static unsigned int
interpret_float_suffix (const uchar *s, size_t len)
{
size_t flags;
- size_t f, l, w, q, i;
+ size_t f, d, l, w, q, i;
flags = 0;
- f = l = w = q = i = 0;
+ f = d = l = w = q = i = 0;
/* Process decimal float suffixes, which are two letters starting
with d or D. Order and case are significant. */
@@ -103,7 +103,9 @@ interpret_float_suffix (const uchar *s, size_t len)
case 'l': return (!uppercase ? (CPP_N_DFLOAT | CPP_N_LARGE) : 0); break;
case 'L': return (uppercase ? (CPP_N_DFLOAT | CPP_N_LARGE) : 0); break;
default:
- return 0;
+ /* Additional two-character suffixes beginning with D are not
+ for decimal float constants. */
+ break;
}
}
@@ -162,6 +164,7 @@ interpret_float_suffix (const uchar *s, size_t len)
switch (s[len])
{
case 'f': case 'F': f++; break;
+ case 'd': case 'D': d++; break;
case 'l': case 'L': l++; break;
case 'w': case 'W': w++; break;
case 'q': case 'Q': q++; break;
@@ -171,14 +174,15 @@ interpret_float_suffix (const uchar *s, size_t len)
return 0;
}
- if (f + l + w + q > 1 || i > 1)
+ if (f + d + l + w + q > 1 || i > 1)
return 0;
return ((i ? CPP_N_IMAGINARY : 0)
| (f ? CPP_N_SMALL :
+ d ? CPP_N_MEDIUM :
l ? CPP_N_LARGE :
w ? CPP_N_MD_W :
- q ? CPP_N_MD_Q : CPP_N_MEDIUM));
+ q ? CPP_N_MD_Q : CPP_N_DEFAULT));
}
/* Subroutine of cpp_classify_number. S points to an integer suffix
@@ -365,6 +369,13 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token)
"traditional C rejects the \"%.*s\" suffix",
(int) (limit - str), str);
+ /* A suffix for double is a GCC extension via decimal float support.
+ If the suffix also specifies an imaginary value we'll catch that
+ later. */
+ if ((result == CPP_N_MEDIUM) && CPP_PEDANTIC (pfile))
+ cpp_error (pfile, CPP_DL_PEDWARN,
+ "suffix for double constant is a GCC extension");
+
/* Radix must be 10 for decimal floats. */
if ((result & CPP_N_DFLOAT) && radix != 10)
{
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index adc6cf13ede..469aaedff60 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -780,6 +780,7 @@ struct cpp_num
#define CPP_N_UNSIGNED 0x1000 /* Properties. */
#define CPP_N_IMAGINARY 0x2000
#define CPP_N_DFLOAT 0x4000
+#define CPP_N_DEFAULT 0x8000
#define CPP_N_FRACT 0x100000 /* Fract types. */
#define CPP_N_ACCUM 0x200000 /* Accum types. */