Clang Project

clang_source_code/test/Sema/attr-mig.cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3typedef int kern_return_t;
4typedef kern_return_t IOReturn;
5#define KERN_SUCCESS 0
6#define kIOReturnSuccess KERN_SUCCESS
7
8class MyServer {
9public:
10  virtual __attribute__((mig_server_routine)) IOReturn externalMethod();
11  virtual __attribute__((mig_server_routine)) void anotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
12  virtual __attribute__((mig_server_routine)) int yetAnotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
13  [[clang::mig_server_routine]] virtual IOReturn cppAnnotatedMethod();
14  [[clang::mig_server_routine("arg")]] virtual IOReturn cppAnnotatedMethodWithInvalidArgs(); // expected-error{{'mig_server_routine' attribute takes no arguments}}
15  [[clang::mig_server_routine]] virtual int cppInvalidAnnotatedMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
16};
17
18IOReturn MyServer::externalMethod() {
19  return kIOReturnSuccess;
20}
21