forked from OSchip/llvm-project
When we're performing an explicit cast of some sort, don't complain
about deprecated Objective-C pointer conversions. Plus, make sure to actually set an appropriate AssignmentAction when performing an implicit conversion from an InitializationSequence. Fixes regressions in the GCC DejaGNU testsuite. llvm-svn: 120744
This commit is contained in:
parent
8cabd938ed
commit
6dd3a6a181
|
@ -1732,7 +1732,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
|
|||
}
|
||||
else
|
||||
assert(0 && "Unknown conversion function kind!");
|
||||
// Whatch out for elipsis conversion.
|
||||
// Watch out for elipsis conversion.
|
||||
if (!ICS.UserDefined.EllipsisConversion) {
|
||||
if (PerformImplicitConversion(From, BeforeToType,
|
||||
ICS.UserDefined.Before, AA_Converting,
|
||||
|
@ -1925,7 +1925,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
|
|||
break;
|
||||
|
||||
case ICK_Pointer_Conversion: {
|
||||
if (SCS.IncompatibleObjC) {
|
||||
if (SCS.IncompatibleObjC && Action != AA_Casting) {
|
||||
// Diagnose incompatible Objective-C conversions
|
||||
Diag(From->getSourceRange().getBegin(),
|
||||
diag::ext_typecheck_convert_incompatible_pointer)
|
||||
|
|
|
@ -3233,6 +3233,8 @@ getAssignmentAction(const InitializedEntity &Entity) {
|
|||
switch(Entity.getKind()) {
|
||||
case InitializedEntity::EK_Variable:
|
||||
case InitializedEntity::EK_New:
|
||||
case InitializedEntity::EK_Exception:
|
||||
case InitializedEntity::EK_Base:
|
||||
return Sema::AA_Initializing;
|
||||
|
||||
case InitializedEntity::EK_Parameter:
|
||||
|
@ -3245,11 +3247,6 @@ getAssignmentAction(const InitializedEntity &Entity) {
|
|||
case InitializedEntity::EK_Result:
|
||||
return Sema::AA_Returning;
|
||||
|
||||
case InitializedEntity::EK_Exception:
|
||||
case InitializedEntity::EK_Base:
|
||||
llvm_unreachable("No assignment action for C++-specific initialization");
|
||||
break;
|
||||
|
||||
case InitializedEntity::EK_Temporary:
|
||||
// FIXME: Can we tell apart casting vs. converting?
|
||||
return Sema::AA_Casting;
|
||||
|
@ -3868,7 +3865,8 @@ InitializationSequence::Perform(Sema &S,
|
|||
bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast();
|
||||
|
||||
if (S.PerformImplicitConversion(CurInitExpr, Step->Type, *Step->ICS,
|
||||
Sema::AA_Converting, IgnoreBaseAccess))
|
||||
getAssignmentAction(Entity),
|
||||
IgnoreBaseAccess))
|
||||
return ExprError();
|
||||
|
||||
CurInit.release();
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
void bar(id(^)(void));
|
||||
void foo(id <NSObject>(^objectCreationBlock)(void)) {
|
||||
return bar(objectCreationBlock); // expected-warning{{incompatible pointer types converting 'id<NSObject> (^)()' to type 'id (^)()'}}
|
||||
return bar(objectCreationBlock); // expected-warning{{incompatible pointer types passing 'id<NSObject> (^)()' to parameter of type 'id (^)()'}}
|
||||
}
|
||||
|
||||
void bar2(id(*)(void));
|
||||
void foo2(id <NSObject>(*objectCreationBlock)(void)) {
|
||||
return bar2(objectCreationBlock); // expected-warning{{incompatible pointer types converting 'id<NSObject> (*)()' to type 'id (*)()'}}
|
||||
return bar2(objectCreationBlock); // expected-warning{{incompatible pointer types passing 'id<NSObject> (*)()' to parameter of type 'id (*)()'}}
|
||||
}
|
||||
|
||||
void bar3(id(*)()); // expected-note{{candidate function}}
|
||||
|
|
|
@ -42,5 +42,7 @@ void foo(const I *p, I* sel) {
|
|||
void accept_derived(DerivedFromI*);
|
||||
|
||||
void test_base_to_derived(I* i) {
|
||||
accept_derived(i); // expected-warning{{incompatible pointer types converting 'I *' to type 'DerivedFromI *'}}
|
||||
accept_derived(i); // expected-warning{{incompatible pointer types passing 'I *' to parameter of type 'DerivedFromI *'}}
|
||||
DerivedFromI *di = i; // expected-warning{{incompatible pointer types initializing 'I *' with an expression of type 'DerivedFromI *'}}
|
||||
DerivedFromI *di2 = (DerivedFromI *)i;
|
||||
}
|
||||
|
|
|
@ -52,12 +52,12 @@ void test0(A* a, B* b, id val) {
|
|||
}
|
||||
|
||||
void test1(A* a) {
|
||||
B* b = a; // expected-warning{{incompatible pointer types converting 'A *' to type 'B *'}}
|
||||
B* b = a; // expected-warning{{incompatible pointer types initializing 'A *' with an expression of type 'B *'}}
|
||||
B *c; c = a; // expected-warning{{incompatible pointer types assigning to 'A *' from 'B *'}}
|
||||
}
|
||||
|
||||
void test2(A** ap) {
|
||||
B** bp = ap; // expected-warning{{incompatible pointer types converting 'A **' to type 'B **'}}
|
||||
B** bp = ap; // expected-warning{{incompatible pointer types initializing 'A **' with an expression of type 'B **'}}
|
||||
bp = ap; // expected-warning{{incompatible pointer types assigning to 'A **' from 'B **'}}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ objc_exception_functions_t;
|
|||
|
||||
void (*_NSExceptionRaiser(void))(NSException *) {
|
||||
objc_exception_functions_t exc_funcs;
|
||||
return exc_funcs.throw_exc; // expected-warning{{incompatible pointer types converting 'void (*)(id)' to type 'void (*)(NSException *)'}}
|
||||
return exc_funcs.throw_exc; // expected-warning{{incompatible pointer types returning 'void (*)(id)' from a function with result type 'void (*)(NSException *)'}}
|
||||
}
|
||||
|
||||
namespace test5 {
|
||||
|
|
Loading…
Reference in New Issue