[cfe-commits] r120744 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp lib/Sema/SemaInit.cpp test/SemaObjCXX/blocks.mm test/SemaObjCXX/objc-pointer-conv.mm test/SemaObjCXX/overload.mm
Douglas Gregor
dgregor at apple.com
Thu Dec 2 13:47:04 PST 2010
Author: dgregor
Date: Thu Dec 2 15:47:04 2010
New Revision: 120744
URL: http://llvm.org/viewvc/llvm-project?rev=120744&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaObjCXX/blocks.mm
cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm
cfe/trunk/test/SemaObjCXX/overload.mm
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=120744&r1=120743&r2=120744&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Dec 2 15:47:04 2010
@@ -1732,7 +1732,7 @@
}
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 @@
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)
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=120744&r1=120743&r2=120744&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Dec 2 15:47:04 2010
@@ -3233,6 +3233,8 @@
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 @@
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 @@
bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast();
if (S.PerformImplicitConversion(CurInitExpr, Step->Type, *Step->ICS,
- Sema::AA_Converting, IgnoreBaseAccess))
+ getAssignmentAction(Entity),
+ IgnoreBaseAccess))
return ExprError();
CurInit.release();
Modified: cfe/trunk/test/SemaObjCXX/blocks.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/blocks.mm?rev=120744&r1=120743&r2=120744&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/blocks.mm (original)
+++ cfe/trunk/test/SemaObjCXX/blocks.mm Thu Dec 2 15:47:04 2010
@@ -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}}
Modified: cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm?rev=120744&r1=120743&r2=120744&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm (original)
+++ cfe/trunk/test/SemaObjCXX/objc-pointer-conv.mm Thu Dec 2 15:47:04 2010
@@ -42,5 +42,7 @@
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;
}
Modified: cfe/trunk/test/SemaObjCXX/overload.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/overload.mm?rev=120744&r1=120743&r2=120744&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/overload.mm (original)
+++ cfe/trunk/test/SemaObjCXX/overload.mm Thu Dec 2 15:47:04 2010
@@ -52,12 +52,12 @@
}
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 @@
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 {
More information about the cfe-commits
mailing list