From 6ab3df0892f2a095793a9f2c29bca75a48eae9ec Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Fri, 3 Aug 2018 14:31:44 +0100 Subject: [PATCH] Improve the forward declare protocols test. Make it not fail to build with older compilers and make it test the thing that should be true with the new ABI. --- Test/ForwardDeclareProtocol.m | 7 +++++++ Test/ForwardDeclareProtocolAccess.m | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Test/ForwardDeclareProtocol.m b/Test/ForwardDeclareProtocol.m index 32ebc41..61fdd88 100644 --- a/Test/ForwardDeclareProtocol.m +++ b/Test/ForwardDeclareProtocol.m @@ -3,5 +3,12 @@ Protocol *getProtocol(void) { +// Don't try to compile this on known-broken compilers. +#if !defined(__clang__) return @protocol(P); +#elif __clang_major__ > 6 + return @protocol(P); +#else + return 0; +#endif } diff --git a/Test/ForwardDeclareProtocolAccess.m b/Test/ForwardDeclareProtocolAccess.m index f8da5e5..5e36399 100644 --- a/Test/ForwardDeclareProtocolAccess.m +++ b/Test/ForwardDeclareProtocolAccess.m @@ -9,9 +9,12 @@ Protocol *getProtocol(void); int main(void) { - //Protocol *p1 = @protocol(P); + Protocol *p1 = @protocol(P); Protocol *p2 = getProtocol(); - //assert(protocol_isEqual(p1, p2)); - //assert(p1 == p2); + assert(protocol_isEqual(p1, p2)); +#ifdef GS_RUNTIME_V2 + // With the new ABI, these should be precisely the same object. + assert(p1 == p2); +#endif return 0; }