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