brintos

brintos / llvm-project-archived public Read only

0
0
Text · 789 B · 272c3be Raw
35 lines · plain
1// RUN: %clang_cc1 -triple x86_64-apple-macos11 -fsyntax-only -fobjc-arc -fblocks -verify -Wunused-but-set-variable -Wno-objc-root-class %s2 3typedef struct dispatch_queue_s *dispatch_queue_t;4 5typedef void (^dispatch_block_t)(void);6 7void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);8 9extern __attribute__((visibility("default"))) struct dispatch_queue_s _dispatch_main_q;10 11id getFoo(void);12 13@protocol P14 15@end16 17@interface I18 19@end20 21void test(void) {22  // no diagnostics23  __block id x = getFoo();24  __block id<P> y = x;25  __block I *z = (I *)x;26  // diagnose non-block variables27  id x2 = getFoo(); // expected-warning {{variable 'x2' set but not used}}28  dispatch_async(&_dispatch_main_q, ^{29    x = ((void *)0);30    y = x;31    z = ((void *)0);32  });33  x2 = getFoo();34}35