================
Comment at: include/clang/Basic/DiagnosticCommonKinds.td:119
@@ +118,3 @@
+  InGroup<ImplicitlyUnsignedLiteral>;
+def warn_old_implicitly_unsigned_long : Warning<
+  "integer literal is of type unsigned long only when %select{C99|C++11}0 "
----------------
rsmith wrote:
> In C++98, this should probably be an `ExtWarn` rather than a `Warning`, 
> because this case has undefined behavior. Splitting this into two warnings 
> would also allow you to put the warning into `-Wc99-compat` or 
> `-Wc++11-compat` as appropriate, and to indicate that the C++98 case has 
> undefined behavior.
In C++98, the undefined behaviour is only on the case of a decimal integer 
literal with none of `u`/`U`/`l`/`L`. If the `l`/`L` is present, the choice of 
`unsigned long` is required to be considered after `long`.

I agree that an `ExtWarn` is appropriate for the undefined behaviour case, but 
I do not think that the `-Wc99-compat`/`-Wc++11-compat` split still follows.

================
Comment at: include/clang/Basic/DiagnosticCommonKinds.td:120-121
@@ +119,4 @@
+def warn_old_implicitly_unsigned_long : Warning<
+  "integer literal is of type unsigned long only when %select{C99|C++11}0 "
+  "or higher is not enabled">,
+  InGroup<ImplicitlyUnsignedLiteral>;
----------------
rsmith wrote:
> It would be clearer and more useful to phrase this as:
> 
>   "integer literal is too large to be represented in type 'long', 
> interpreting as 'unsigned long'; this literal will have type '%select{long 
> long|unsigned long long}0' in C99 onwards"
> 
> (with s/C99/C++11/ for the C++98 warning.)
> 
> You can easily compute the signedness of the `long long` in SemaExpr by 
> checking if `LongLongSize > LongSize`.
The use of unsigned long long in C99/C++11 modes would also be an extension 
though. Saying "C99 onwards" implies the Standard, not the mode; so perhaps "in 
C99-and-later modes"?

http://reviews.llvm.org/D9794

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/



_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to