[all-commits] [llvm/llvm-project] ccc4d8: [ObjC] Diagnose implicit type coercion from ObjC '...
jyknight via All-commits
all-commits at lists.llvm.org
Thu Oct 17 08:25:53 PDT 2019
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: ccc4d83cda16bea1d9dfd0967dc7d2cfb24b8e75
https://github.com/llvm/llvm-project/commit/ccc4d83cda16bea1d9dfd0967dc7d2cfb24b8e75
Author: James Y Knight <jyknight at google.com>
Date: 2019-10-17 (Thu, 17 Oct 2019)
Changed paths:
M clang/lib/AST/ASTContext.cpp
M clang/lib/Sema/SemaExpr.cpp
M clang/test/SemaObjC/comptypes-1.m
M clang/test/SemaObjCXX/class-method-self.mm
M clang/test/SemaObjCXX/comptypes-1.mm
M clang/test/SemaObjCXX/comptypes-7.mm
M clang/test/SemaObjCXX/instancetype.mm
Log Message:
-----------
[ObjC] Diagnose implicit type coercion from ObjC 'Class' to object
pointer types.
For example, in Objective-C mode, the initialization of 'x' in:
```
@implementation MyType
+ (void)someClassMethod {
MyType *x = self;
}
@end
```
is correctly diagnosed with an incompatible-pointer-types warning, but
in Objective-C++ mode, it is not diagnosed at all -- even though
incompatible pointer conversions generally become an error in C++.
This patch fixes that oversight, allowing implicit conversions
involving Class only to/from unqualified-id, and between qualified and
unqualified Class, where the protocols are compatible.
Note that this does change some behaviors in Objective-C, as well, as
shown by the modified tests.
Of particular note is that assignment from from 'Class<MyProtocol>' to
'id<MyProtocol>' now warns. (Despite appearances, those are not
compatible types. 'Class<MyProtocol>' is not expected to have instance
methods defined by 'MyProtocol', while 'id<MyProtocol>' is.)
Differential Revision: https://reviews.llvm.org/D67983
llvm-svn: 375125
More information about the All-commits
mailing list