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 9int f3(int param [[carries_dependency]]); // ok 10[[carries_dependency]] int (*f4)(); // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}} 11int (*f5 [[carries_dependency]])(); // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}} 12int (*f6)() [[carries_dependency]]; // expected-error {{'carries_dependency' attribute cannot be applied to types}} 13int (*f7)(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} 14int (((f8)))(int n [[carries_dependency]]); // ok 15int (*f9(int n))(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} 16int typedef f10(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} 17using T = int(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} 18struct 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}; 22void 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 28auto 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. 32auto l2 = []() [[carries_dependency]] {}; // expected-error {{'carries_dependency' attribute cannot be applied to types}} 33