1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-extension.m
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-extension.m \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-ivars-number.m
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-ivars-number.m \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-methods-protocols.m
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-methods-protocols.m \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-subclass.m
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-subclass.m \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-implementation.m
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-implementation.m \
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
// Same class extensions with the same ivars but from different modules aren't considered
// an error and they are merged together. Test that differences in extensions and/or ivars
// are still reported as errors.
//--- include/Interfaces.h
@interface NSObject @end
@interface ObjCInterface : NSObject
@end
@interface ObjCInterfaceLevel2 : ObjCInterface
@end
@protocol Protocol1 @end
@protocol Protocol2 @end
//--- include/IvarsInExtensions.h
#import <Interfaces.h>
@interface ObjCInterface() {
int ivarName;
}
@end
@interface ObjCInterfaceLevel2() {
int bitfieldIvarName: 3;
}
@end
//--- include/IvarsInExtensionsWithMethodsProtocols.h
#import <Interfaces.h>
@interface ObjCInterface() {
int methodRelatedIvar;
}
- (void)test;
@end
@interface ObjCInterfaceLevel2() <Protocol1> {
int protocolRelatedIvar;
}
@end
//--- include/IvarInImplementation.h
#import <Interfaces.h>
@implementation ObjCInterface {
int ivarName;
}
@end
//--- include/module.modulemap
module Interfaces {
header "Interfaces.h"
export *
}
module IvarsInExtensions {
header "IvarsInExtensions.h"
export *
}
module IvarsInExtensionsWithMethodsProtocols {
header "IvarsInExtensionsWithMethodsProtocols.h"
export *
}
module IvarInImplementation {
header "IvarInImplementation.h"
export *
}
//--- test-mismatch-in-extension.m
// Different ivars with the same name aren't mergeable and constitute an error.
#import <Interfaces.h>
@interface ObjCInterface() {
float ivarName; // expected-note {{previous definition is here}}
}
@end
@interface ObjCInterfaceLevel2() {
int bitfieldIvarName: 5; // expected-note {{previous definition is here}}
}
@end
#import <IvarsInExtensions.h>
// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}
// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}
@implementation ObjCInterfaceLevel2
@end
//--- test-mismatch-in-ivars-number.m
// Extensions with different amount of ivars aren't considered to be the same.
#import <Interfaces.h>
@interface ObjCInterface() {
int ivarName; // expected-note {{previous definition is here}}
float anotherIvar;
}
@end
#import <IvarsInExtensions.h>
// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}
@implementation ObjCInterface
@end
//--- test-mismatch-in-methods-protocols.m
// Extensions with different methods or protocols aren't considered to be the same.
#import <Interfaces.h>
@interface ObjCInterface() {
int methodRelatedIvar; // expected-note {{previous definition is here}}
}
- (void)differentTest;
@end
@interface ObjCInterfaceLevel2() <Protocol2> {
int protocolRelatedIvar; // expected-note {{previous definition is here}}
}
@end
#import <IvarsInExtensionsWithMethodsProtocols.h>
// expected-error@IvarsInExtensionsWithMethodsProtocols.h:* {{instance variable is already declared}}
// expected-error@IvarsInExtensionsWithMethodsProtocols.h:* {{instance variable is already declared}}
@implementation ObjCInterfaceLevel2
@end
//--- test-redecl-in-subclass.m
// Ivar in superclass extension is not added to a subclass, so the ivar with
// the same name in subclass extension is not considered a redeclaration.
// expected-no-diagnostics
#import <Interfaces.h>
@interface ObjCInterfaceLevel2() {
float ivarName;
}
@end
#import <IvarsInExtensions.h>
@implementation ObjCInterfaceLevel2
@end
//--- test-redecl-in-implementation.m
// Ivar redeclaration in `@implementation` is always an error and never mergeable.
#import <IvarsInExtensions.h>
@interface ObjCInterface() {
int triggerExtensionIvarDeserialization;
}
@end
#import <IvarInImplementation.h>
#if __has_feature(modules)
// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}
// expected-note@IvarInImplementation.h:* {{previous definition is here}}
#else
// expected-error@IvarInImplementation.h:* {{instance variable is already declared}}
// expected-note@IvarsInExtensions.h:* {{previous definition is here}}
#endif
|