[llvm-bugs] [Bug 40285] New: Objective C - compiler error using new within the implementation when init is marked with unavailable attribute

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 10 09:34:09 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40285

            Bug ID: 40285
           Summary: Objective C - compiler error using new within the
                    implementation when init is marked with unavailable
                    attribute
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jelin at microsoft.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Created attachment 21311
  --> https://bugs.llvm.org/attachment.cgi?id=21311&action=edit
Repro test code.

The regression was introduced sometime between 340925 and 342523.

The following code used to compile fine in 340925, but now generate the error:

#import <Foundation/Foundation.h>

@interface Test : NSObject

- (nullable instancetype)init __attribute__((unavailable("Use the
sharedInstance singleton method instead.")));

+ (nullable instancetype)sharedInstance;

@end

@implementation Test

+ (nullable instancetype)sharedInstance {
    return [Test new];
}

@end


Compiled with:
clang -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
-c test.m

Error message:
test.m:25:18: error: 'new' is unavailable: Use the sharedInstance
      singleton method instead.
    return [Test new];
                 ^
test.m:14:1: note: 'init' has been explicitly marked unavailable
      here
- (nullable instancetype)init __attribute__((unavailable("Use the shared...
^
1 error generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190110/4b1ecba5/attachment.html>


More information about the llvm-bugs mailing list