[PATCH] Consider unsigned long for non-u/U decimal literals (C90/C++03)

Hubert Tong hubert.reinterpretcast at gmail.com
Fri May 15 07:31:19 PDT 2015


Hi rsmith, fraggamuffin,

This modifies Clang to reflect that under pre-C99 ISO C, decimal
constants may have type `unsigned long` even if they do not contain `u`
or `U` in their suffix (C90 subclause 6.1.3.2 paragraph 5). The same is
done for C++ without C++11 which--because of undefined behaviour--allows
for behaviour compatible with ISO C90 in the case of an unsuffixed
decimal literal and is otherwise identical to C90 in its treatment of
integer literals (C++03 subclause 2.13.1 [lex.icon] paragraph 2).

A message is added alongside `ext_integer_literal_too_large_for_signed`
to the `implicitly-unsigned-literal` group to warn on this additional
cause of implicitly unsigned literals.

Fixes PR 16678.

http://reviews.llvm.org/D9794

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticGroups.td
  lib/Sema/SemaExpr.cpp
  test/Sema/PR16678new32.c
  test/Sema/PR16678new32.cpp
  test/Sema/PR16678new64.c
  test/Sema/PR16678new64.cpp
  test/Sema/PR16678old32.c
  test/Sema/PR16678old32.cpp
  test/Sema/PR16678old64.c
  test/Sema/PR16678old64.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9794.25868.patch
Type: text/x-patch
Size: 17719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150515/da07e1a4/attachment.bin>


More information about the cfe-commits mailing list