view clang/test/Sema/attr-musttail.m @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 79ff65ed7e25
children
line wrap: on
line source

// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class -verify %s

void TestObjcBlock(void) {
  void (^x)(void) = ^(void) {
    __attribute__((musttail)) return TestObjcBlock(); // expected-error{{'musttail' attribute cannot be used from a block}}
  };
  __attribute__((musttail)) return x();
}

void ReturnsVoid(void);
void TestObjcBlockVar(void) {
  __block int i = 0;                              // expected-note{{jump exits scope of __block variable}}
  __attribute__((musttail)) return ReturnsVoid(); // expected-error{{cannot perform a tail call from this return statement}}
}

__attribute__((objc_root_class))
@interface TestObjcClass
@end

@implementation TestObjcClass

- (void)testObjCMethod {
  __attribute__((musttail)) return ReturnsVoid(); // expected-error{{'musttail' attribute cannot be used from an Objective-C function}}
}

@end