Commit 21a71295 authored by Bill Wendling's avatar Bill Wendling
Browse files

Merging r195135:

------------------------------------------------------------------------
r195135 | fjahanian | 2013-11-19 09:42:25 -0800 (Tue, 19 Nov 2013) | 3 lines

bjectiveC. Use a uniform diagnostic for
'objc_bridge' attribute. // rdar://15454846.

------------------------------------------------------------------------

llvm-svn: 195141
parent 1de95ce8
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -2051,7 +2051,7 @@ def err_attribute_wrong_decl_type : Error<
  "variables, functions and tag types|thread-local variables|"
  "variables and fields|variables, data members and tag types|"
  "types and namespaces|Objective-C interfaces|"
  "methods and properties}1">;
  "methods and properties|struct or union|struct, union or class}1">;
def warn_type_attribute_wrong_type : Warning<
  "'%0' only applies to %select{function|pointer|"
  "Objective-C object or block pointer}1 types; type here is %2">,
@@ -2441,8 +2441,6 @@ def err_ns_bridged_not_interface : Error<
// objc_bridge attribute diagnostics.
def err_objc_bridge_not_id : Error<
  "parameter of 'objc_bridge' attribute must be a single name of an Objective-C class">;
def err_objc_bridge_attribute : Error<
  "'objc_bridge' attribute must be applied to a struct%select{|, C++ class}0 or union">;
def err_objc_cf_bridged_not_interface : Error<
  "CF object of type %0 is bridged to '%1', which is not an Objective-C class">;
def err_objc_ns_bridged_invalid_cfobject : Error<
+7 −3
Original line number Diff line number Diff line
@@ -55,7 +55,9 @@ enum AttributeDeclKind {
  ExpectedVariableFieldOrTag,
  ExpectedTypeOrNamespace,
  ExpectedObjectiveCInterface,
  ExpectedMethodOrProperty
  ExpectedMethodOrProperty,
  ExpectedStructOrUnion,
  ExpectedStructOrUnionOrClass
};

//===----------------------------------------------------------------------===//
@@ -4392,8 +4394,10 @@ static void handleNSBridgedAttr(Sema &S, Scope *Sc, Decl *D,
static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D,
                                const AttributeList &Attr) {
  if (!isa<RecordDecl>(D)) {
    S.Diag(D->getLocStart(), diag::err_objc_bridge_attribute)
      << S.getLangOpts().CPlusPlus;
    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
    << Attr.getName()
    << (S.getLangOpts().CPlusPlus ? ExpectedStructOrUnionOrClass
                                  : ExpectedStructOrUnion);
    return;
  }
  
+7 −7
Original line number Diff line number Diff line
@@ -7,28 +7,28 @@ typedef struct __attribute__((objc_bridge(12))) __CFMyColor *CFMyColorRef; // e

typedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}}

typedef void *  __attribute__ ((objc_bridge(NSURL))) CFURLRef;  // expected-error {{'objc_bridge' attribute must be applied to a struct or union}}
typedef void *  __attribute__ ((objc_bridge(NSURL))) CFURLRef;  // expected-error {{'objc_bridge' attribute only applies to struct or union}}

typedef void * CFStringRef __attribute__ ((objc_bridge(NSString))); // expected-error {{'objc_bridge' attribute must be applied to a struct or union}}
typedef void * CFStringRef __attribute__ ((objc_bridge(NSString))); // expected-error {{'objc_bridge' attribute only applies to struct or union}}

typedef struct __attribute__((objc_bridge(NSLocale, NSError))) __CFLocale *CFLocaleRef;// expected-error {{use of undeclared identifier 'NSError'}}

typedef struct __CFData __attribute__((objc_bridge(NSData))) CFDataRef; // expected-error {{'objc_bridge' attribute must be applied to a struct or union}}
typedef struct __CFData __attribute__((objc_bridge(NSData))) CFDataRef; // expected-error {{'objc_bridge' attribute only applies to struct or union}}

typedef struct __attribute__((objc_bridge(NSDictionary))) __CFDictionary * CFDictionaryRef;

typedef struct __CFSetRef * CFSetRef __attribute__((objc_bridge(NSSet))); // expected-error {{'objc_bridge' attribute must be applied to a struct or union}};
typedef struct __CFSetRef * CFSetRef __attribute__((objc_bridge(NSSet))); // expected-error {{'objc_bridge' attribute only applies to struct or union}};

typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{'objc_bridge' attribute must be applied to a struct or union}};
typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{'objc_bridge' attribute only applies to struct or union}};

typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) *CFUColor1Ref; // expected-error {{'objc_bridge' attribute must be applied to a struct or union}};
typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) *CFUColor1Ref; // expected-error {{'objc_bridge' attribute only applies to struct or union}};

typedef union __attribute__((objc_bridge(NSUColor))) __CFUPrimeColor XXX;
typedef XXX *CFUColor2Ref;

@interface I
{
   __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute must be applied to a struct or union}};
   __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute only applies to struct or union}};
}
@end