[cfe-commits] r154619 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/SemaObjC/objc-literal-nsnumber.m

David Blaikie dblaikie at gmail.com
Thu Apr 12 14:42:26 PDT 2012


On Thu, Apr 12, 2012 at 2:37 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Thu, Apr 12, 2012 at 2:24 PM, Fariborz Jahanian <fjahanian at apple.com> wrote:
>> Author: fjahanian
>> Date: Thu Apr 12 16:24:56 2012
>> New Revision: 154619
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=154619&view=rev
>> Log:
>> objective-c literals: Issue warning and ignore
>> when BOOL is not of an intergal type when
>> boolean literals are used. // rdar://11231426
>>
>> Modified:
>>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>    cfe/trunk/lib/Sema/SemaExpr.cpp
>>    cfe/trunk/test/SemaObjC/objc-literal-nsnumber.m
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=154619&r1=154618&r2=154619&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Apr 12 16:24:56 2012
>> @@ -1547,6 +1547,9 @@
>>   "using %0 with a literal is redundant">, InGroup<ObjCRedundantLiteralUse>;
>>  }
>>
>> +def warn_bool_for_boolean_literal : Warning<
>> +  "BOOL of type %0 is non-intergal and unsuitable for a "
>> +  "boolean literal - ignored">, InGroup<DiagGroup<"numeric-literals">>;
>
> "intergal"?
>
> In any case, is it really worth warning here?  If we really want to
> warn about constructs like this, we should warn about the typedef
> itself, not the bool literal.

For what it's worth - we have precedent for just assuming certain
macros are the 'right' ones. NULL for example (we suggest "T* i =
NULL;" to initialize a pointer in C++98 in the presence of any macro
definition for NULL). I'm not sure if BOOL is similarly universal.

(& agreed - if we were wanting to test for sanity here, it seems
reasonable to catch the macro definition)

- David




More information about the cfe-commits mailing list