diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-25 18:46:03 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-25 18:46:03 +0000 |
commit | 9c6183ddd1c8f33f9994bfc954c0ecc1e638b5cc (patch) | |
tree | a0a78183eae0cbfd3a9ea596201c0a1fd30642d9 /libcpp | |
parent | 927a6b6b50770a413d2540c4957f5a422bb98c2d (diff) | |
download | gcc-9c6183ddd1c8f33f9994bfc954c0ecc1e638b5cc.tar.gz |
libcpp:
PR preprocessor/39559
* expr.c (cpp_interpret_integer): Use a pedwarn for decimal
constants larger than intmax_t in C99 mode.
gcc/testsuite:
* gcc.dg/c99-intconst-2.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146777 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 6 | ||||
-rw-r--r-- | libcpp/expr.c | 21 |
2 files changed, 26 insertions, 1 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index a9ccc59717b..24f3f8debcf 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,9 @@ +2009-04-25 Joseph Myers <joseph@codesourcery.com> + + PR preprocessor/39559 + * expr.c (cpp_interpret_integer): Use a pedwarn for decimal + constants larger than intmax_t in C99 mode. + 2009-04-21 Taras Glek <tglek@mozilla.com> * include/cpp-id-data.h: Update GTY annotations to new syntax. diff --git a/libcpp/expr.c b/libcpp/expr.c index b9a17db9361..f65fae02431 100644 --- a/libcpp/expr.c +++ b/libcpp/expr.c @@ -538,8 +538,27 @@ cpp_interpret_integer (cpp_reader *pfile, const cpp_token *token, && pfile->state.in_directive) && !num_positive (result, precision)) { + /* This is for constants within the range of uintmax_t but + not that or intmax_t. For such decimal constants, a + diagnostic is required for C99 as the selected type must + be signed and not having a type is a constraint violation + (DR#298, TC3), so this must be a pedwarn. For C90, + unsigned long is specified to be used for a constant that + does not fit in signed long; if uintmax_t has the same + range as unsigned long this means only a warning is + appropriate here. C90 permits the preprocessor to use a + wider range than unsigned long in the compiler, so if + uintmax_t is wider than unsigned long no diagnostic is + required for such constants in preprocessor #if + expressions and the compiler will pedwarn for such + constants outside the range of unsigned long that reach + the compiler so a diagnostic is not required there + either; thus, pedwarn for C99 but use a plain warning for + C90. */ if (base == 10) - cpp_error (pfile, CPP_DL_WARNING, + cpp_error (pfile, (CPP_OPTION (pfile, c99) + ? CPP_DL_PEDWARN + : CPP_DL_WARNING), "integer constant is so large that it is unsigned"); result.unsignedp = true; } |