1 // RUN: split-file %s %t
2 // RUN: %clang_cc1 -load %llvmshlibdir/Attribute%pluginext -fsyntax-only -ast-dump -verify %t/good_attr.cpp | FileCheck %s
3 // RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -fsyntax-only -Xclang -verify %t/bad_attr.cpp
4 // REQUIRES: plugins, examples
6 // expected-no-diagnostics
7 void fn1a() __attribute__((example
)) {}
8 [[example
]] void fn1b() {}
9 [[plugin::example
]] void fn1c() {}
10 void fn2() __attribute__((example("somestring", 1, 2.0))) {}
11 // CHECK-COUNT-4: -AnnotateAttr 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} "example"
12 // CHECK: -StringLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'const char[{{[0-9]+}}]' lvalue "somestring"
13 // CHECK: -IntegerLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'int' 1
14 // CHECK: -FloatingLiteral 0x{{[0-9a-z]+}} {{<col:[0-9]+(, col:[0-9]+)?>}} 'double' 2.000000e+00
17 int var1
__attribute__((example("otherstring"))) = 1; // expected-warning {{'example' attribute only applies to functions}}
19 void __attribute__((example
)) fn3(); // expected-error {{'example' attribute only allowed at file scope}}
21 void fn4() __attribute__((example(123))) { } // expected-error {{first argument to the 'example' attribute must be a string literal}}
22 void fn5() __attribute__((example("a","b", 3, 4.0))) { } // expected-error {{'example' attribute only accepts at most three arguments}}