forked from llvm-mirror/clang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sema] Split of versions of -Wimplicit-{float,int}-conversion for Obj…
…ective-C BOOL Also, add a diagnostic group, -Wobjc-signed-char-bool, to control all these related diagnostics. rdar://51954400 Differential revision: https://reviews.llvm.org/D67559 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372183 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
6 changed files
with
156 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// RUN: %clang_cc1 %s -verify -Wobjc-signed-char-bool | ||
// RUN: %clang_cc1 -xobjective-c++ %s -verify -Wobjc-signed-char-bool | ||
|
||
typedef signed char BOOL; | ||
#define YES __objc_yes | ||
#define NO __objc_no | ||
|
||
typedef unsigned char Boolean; | ||
|
||
BOOL b; | ||
Boolean boolean; | ||
float fl; | ||
int i; | ||
int *ptr; | ||
|
||
void t1() { | ||
b = boolean; | ||
b = fl; // expected-warning {{implicit conversion from floating-point type 'float' to 'BOOL'}} | ||
b = i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}} | ||
|
||
b = 1.0; | ||
b = 0.0; | ||
b = 1.1; // expected-warning {{implicit conversion from 'double' to 'BOOL' (aka 'signed char') changes value from 1.1 to 1}} | ||
b = 2.1; // expected-warning {{implicit conversion from constant value 2.1 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}} | ||
|
||
b = YES; | ||
#ifndef __cplusplus | ||
b = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}} | ||
#endif | ||
} | ||
|
||
@interface BoolProp | ||
@property BOOL p; | ||
@end | ||
|
||
void t2(BoolProp *bp) { | ||
bp.p = YES; | ||
bp.p = NO; | ||
bp.p = boolean; | ||
bp.p = fl; // expected-warning {{implicit conversion from floating-point type 'float' to 'BOOL'}} | ||
bp.p = i; // expected-warning {{implicit conversion from integral type 'int' to 'BOOL'}} | ||
bp.p = b; | ||
bp.p = bp.p; | ||
#ifndef __cplusplus | ||
bp.p = ptr; // expected-warning {{incompatible pointer to integer conversion assigning to 'BOOL' (aka 'signed char') from 'int *'}} | ||
#endif | ||
bp.p = 1; | ||
bp.p = 2; // expected-warning {{implicit conversion from constant value 2 to 'BOOL'; the only well defined values for 'BOOL' are YES and NO}} | ||
} |