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