55// --- good_attr.cpp
66// expected-no-diagnostics
77void fn1a () __attribute__((example)) {
8- __attribute__ ((example)) for (int i = 0 ; i < 10 ; ++i) {}
8+ __attribute__ ((example)) for (int i = 0 ; i < 9 ; ++i) {}
99}
1010[[example]] void fn1b () {
11- [[example]] for (int i = 0 ; i < 10 ; ++i) {}
11+ [[example]] for (int i = 0 ; i < 9 ; ++i) {}
1212}
1313[[plugin::example]] void fn1c () {
14- [[plugin::example]] for (int i = 0 ; i < 10 ; ++i) {}
14+ [[plugin::example]] for (int i = 0 ; i < 9 ; ++i) {}
1515}
1616void fn2 () __attribute__((example(" somestring" , 1 , 2.0 ))) {
17- __attribute__ ((example (" abc" , 3 , 4.0 ))) for (int i = 0 ; i < 10 ; ++i) {}
17+ __attribute__ ((example (" abc" , 3 , 4.0 ))) for (int i = 0 ; i < 9 ; ++i) {}
1818}
19+ template <int N> void template_fn () __attribute__((example(" template" , N))) {
20+ __attribute__ ((example (" def" , N + 1 ))) for (int i = 0 ; i < 9 ; ++i) {}
21+ }
22+ void fn3 () { template_fn<5 >(); }
1923// CHECK: -AttributedStmt 0x{{[0-9a-z]+}} {{<line:[0-9]+:[0-9]+(, col:[0-9]+)?>}}
2024// CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} "example"
2125// CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{<line:[0-9]+:[0-9]+(, col:[0-9]+)?>}} "example"
@@ -34,6 +38,14 @@ void fn2() __attribute__((example("somestring", 1, 2.0))) {
3438// CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'const char[{{[0-9]+}}]' lvalue "somestring"
3539// CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'int' 1
3640// CHECK: -FloatingLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'double' 2.000000e+00
41+ // CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} Implicit "example"
42+ // CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'const char[{{[0-9]+}}]' lvalue "def"
43+ // CHECK: -BinaryOperator 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'int' '+'
44+ // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{<line:[0-9]+:[0-9]+(, col:[0-9]+)?>}} 'int' 5
45+ // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'int' 1
46+ // CHECK: -AnnotateAttr 0x{{[0-9a-z]+}} {{<line:[0-9]+:[0-9]+(, col:[0-9]+)?>}} "example"
47+ // CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'const char[{{[0-9]+}}]' lvalue "template"
48+ // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'int' 5
3749
3850// --- bad_attr.cpp
3951int var1 __attribute__ ((example(" otherstring" ))) = 1; // expected-warning {{'example' attribute only applies to functions}}
0 commit comments