brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 424b159 Raw
33 lines · cpp
1// RUN: %clang_cc1 -verify -std=c++11 %s2 3[[carries_dependency, carries_dependency]] int m1(); // ok4[[carries_dependency]] [[carries_dependency]] int m2(); // ok5[[carries_dependency()]] int m3(); // expected-error {{attribute 'carries_dependency' cannot have an argument list}}6 7[[carries_dependency]] void f1(); // FIXME: warn here8[[carries_dependency]] int f2(); // ok9int f3(int param [[carries_dependency]]); // ok10[[carries_dependency]] int (*f4)(); // expected-error {{'carries_dependency' attribute only applies to parameters, Objective-C methods, and functions}}11int (*f5 [[carries_dependency]])(); // expected-error {{'carries_dependency' attribute only applies to}}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]]); // ok15int (*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]]); // ok20  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]]); // ok24  [[carries_dependency]] // expected-error {{'carries_dependency' attribute only applies to}}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 carries30// a dependency, because an attribute applied to the lambda appertains to31// 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