• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -std=c++11 %s
2 
3 [[carries_dependency, carries_dependency]] int m1(); // expected-error {{attribute 'carries_dependency' cannot appear multiple times in an attribute specifier}}
4 [[carries_dependency]] [[carries_dependency]] int m2(); // ok
5 [[carries_dependency()]] int m3(); // expected-error {{attribute 'carries_dependency' cannot have an argument list}}
6 
7 [[carries_dependency]] void f1(); // FIXME: warn here
8 [[carries_dependency]] int f2(); // ok
9 int f3(int param [[carries_dependency]]); // ok
10 [[carries_dependency]] int (*f4)(); // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}}
11 int (*f5 [[carries_dependency]])(); // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}}
12 int (*f6)() [[carries_dependency]]; // expected-error {{'carries_dependency' attribute cannot be applied to types}}
13 int (*f7)(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}}
14 int (((f8)))(int n [[carries_dependency]]); // ok
15 int (*f9(int n))(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}}
16 int typedef f10(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}}
17 using T = int(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}}
18 struct S {
19   [[carries_dependency]] int f(int n [[carries_dependency]]); // ok
20   int (*p)(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}}
21 };
f()22 void f() {
23   [[carries_dependency]] int f(int n [[carries_dependency]]); // ok
24   [[carries_dependency]] // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}}
25       int (*p)(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}}
26 }
27 
__anon16f8825e0102(int n ) 28 auto l1 = [](int n [[carries_dependency]]) {};
29 // There's no way to write a lambda such that the return value carries
30 // a dependency, because an attribute applied to the lambda appertains to
31 // the *type* of the operator() function, not to the function itself.
__anon16f8825e0202() 32 auto l2 = []() [[carries_dependency]] {}; // expected-error {{'carries_dependency' attribute cannot be applied to types}}
33