aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExprCXX.cpp4
-rw-r--r--lib/Sema/SemaInit.cpp10
-rw-r--r--test/SemaObjCXX/blocks.mm4
-rw-r--r--test/SemaObjCXX/objc-pointer-conv.mm4
-rw-r--r--test/SemaObjCXX/overload.mm6
5 files changed, 14 insertions, 14 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index f6bfee91ee..fceb542c79 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -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)
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 455f7bbba7..26826aa87b 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -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();
diff --git a/test/SemaObjCXX/blocks.mm b/test/SemaObjCXX/blocks.mm
index 559739a48d..f595863815 100644
--- a/test/SemaObjCXX/blocks.mm
+++ b/test/SemaObjCXX/blocks.mm
@@ -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}}
diff --git a/test/SemaObjCXX/objc-pointer-conv.mm b/test/SemaObjCXX/objc-pointer-conv.mm
index e40dab749c..209dcfdfd7 100644
--- a/test/SemaObjCXX/objc-pointer-conv.mm
+++ b/test/SemaObjCXX/objc-pointer-conv.mm
@@ -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;
}
diff --git a/test/SemaObjCXX/overload.mm b/test/SemaObjCXX/overload.mm
index 84aedf6b69..7000e54cfe 100644
--- a/test/SemaObjCXX/overload.mm
+++ b/test/SemaObjCXX/overload.mm
@@ -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 {