brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.6 KiB · 8afb00e Raw
167 lines · plain
1// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}2// RUN: rm -rf %t3// RUN: split-file %s %t4// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-extension.m5// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-extension.m \6// RUN:            -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache7 8// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-ivars-number.m9// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-ivars-number.m \10// RUN:            -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache11 12// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-methods-protocols.m13// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-mismatch-in-methods-protocols.m \14// RUN:            -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache15 16// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-subclass.m17// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-subclass.m \18// RUN:            -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache19 20// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-implementation.m21// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-10.9 -verify -I%t/include %t/test-redecl-in-implementation.m \22// RUN:            -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache23 24// Same class extensions with the same ivars but from different modules aren't considered25// an error and they are merged together. Test that differences in extensions and/or ivars26// are still reported as errors.27 28//--- include/Interfaces.h29@interface NSObject @end30@interface ObjCInterface : NSObject31@end32@interface ObjCInterfaceLevel2 : ObjCInterface33@end34 35@protocol Protocol1 @end36@protocol Protocol2 @end37 38//--- include/IvarsInExtensions.h39#import <Interfaces.h>40@interface ObjCInterface() {41  int ivarName;42}43@end44@interface ObjCInterfaceLevel2() {45  int bitfieldIvarName: 3;46}47@end48 49//--- include/IvarsInExtensionsWithMethodsProtocols.h50#import <Interfaces.h>51@interface ObjCInterface() {52  int methodRelatedIvar;53}54- (void)test;55@end56@interface ObjCInterfaceLevel2() <Protocol1> {57  int protocolRelatedIvar;58}59@end60 61//--- include/IvarInImplementation.h62#import <Interfaces.h>63@implementation ObjCInterface {64  int ivarName;65}66@end67 68//--- include/module.modulemap69module Interfaces {70  header "Interfaces.h"71  export *72}73module IvarsInExtensions {74  header "IvarsInExtensions.h"75  export *76}77module IvarsInExtensionsWithMethodsProtocols {78  header "IvarsInExtensionsWithMethodsProtocols.h"79  export *80}81module IvarInImplementation {82  header "IvarInImplementation.h"83  export *84}85 86 87//--- test-mismatch-in-extension.m88// Different ivars with the same name aren't mergeable and constitute an error.89#import <Interfaces.h>90@interface ObjCInterface() {91  float ivarName; // expected-note {{previous definition is here}}92}93@end94@interface ObjCInterfaceLevel2() {95  int bitfieldIvarName: 5; // expected-note {{previous definition is here}}96}97@end98#import <IvarsInExtensions.h>99// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}100// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}101@implementation ObjCInterfaceLevel2102@end103 104 105//--- test-mismatch-in-ivars-number.m106// Extensions with different amount of ivars aren't considered to be the same.107#import <Interfaces.h>108@interface ObjCInterface() {109  int ivarName; // expected-note {{previous definition is here}}110  float anotherIvar;111}112@end113#import <IvarsInExtensions.h>114// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}115@implementation ObjCInterface116@end117 118 119//--- test-mismatch-in-methods-protocols.m120// Extensions with different methods or protocols aren't considered to be the same.121#import <Interfaces.h>122@interface ObjCInterface() {123  int methodRelatedIvar; // expected-note {{previous definition is here}}124}125- (void)differentTest;126@end127@interface ObjCInterfaceLevel2() <Protocol2> {128  int protocolRelatedIvar; // expected-note {{previous definition is here}}129}130@end131#import <IvarsInExtensionsWithMethodsProtocols.h>132// expected-error@IvarsInExtensionsWithMethodsProtocols.h:* {{instance variable is already declared}}133// expected-error@IvarsInExtensionsWithMethodsProtocols.h:* {{instance variable is already declared}}134@implementation ObjCInterfaceLevel2135@end136 137 138//--- test-redecl-in-subclass.m139// Ivar in superclass extension is not added to a subclass, so the ivar with140// the same name in subclass extension is not considered a redeclaration.141// expected-no-diagnostics142#import <Interfaces.h>143@interface ObjCInterfaceLevel2() {144  float ivarName;145}146@end147#import <IvarsInExtensions.h>148@implementation ObjCInterfaceLevel2149@end150 151 152//--- test-redecl-in-implementation.m153// Ivar redeclaration in `@implementation` is always an error and never mergeable.154#import <IvarsInExtensions.h>155@interface ObjCInterface() {156  int triggerExtensionIvarDeserialization;157}158@end159#import <IvarInImplementation.h>160#if __has_feature(modules)161// expected-error@IvarsInExtensions.h:* {{instance variable is already declared}}162// expected-note@IvarInImplementation.h:* {{previous definition is here}}163#else164// expected-error@IvarInImplementation.h:* {{instance variable is already declared}}165// expected-note@IvarsInExtensions.h:* {{previous definition is here}}166#endif167