llvm-capstone/clang/test/SemaObjC/attr-called-once.m
Aaron Ballman 1c2558021c Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the final batch of tests being updated to add prototypes,
hopefully.
2022-02-24 15:30:13 -05:00

21 lines
982 B
Objective-C

// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc -fblocks %s
#define CALLED_ONCE __attribute__((called_once))
void test1(int x CALLED_ONCE); // expected-error{{'called_once' attribute only applies to function-like parameters}}
void test2(double x CALLED_ONCE); // expected-error{{'called_once' attribute only applies to function-like parameters}}
void test3(void (*foo)(void) CALLED_ONCE); // no-error
void test4(int (^foo)(int) CALLED_ONCE); // no-error
void test5(void (*foo)(void) __attribute__((called_once(1))));
// expected-error@-1{{'called_once' attribute takes no arguments}}
void test6(void (*foo)(void) __attribute__((called_once("str1", "str2"))));
// expected-error@-1{{'called_once' attribute takes no arguments}}
CALLED_ONCE void test7(void); // expected-warning{{'called_once' attribute only applies to parameters}}
void test8(void) {
void (*foo)(void) CALLED_ONCE; // expected-warning{{'called_once' attribute only applies to parameters}}
foo();
}