test case for annotate attribute
[oota-llvm.git] / test / CFrontend / 2007-06-15-AnnotateAttribute.c
1 // RUN: %llvmgxx -c -emit-llvm %s -o - | llvm-dis | grep llvm.global.annotations | grep foo \ 
2 // RUN: | grep @X | grep @a
3 // RUN: %llvmgxx -c -emit-llvm %s -o - | llvm-dis | grep -c llvm.var.annotation | grep 3 
4
5 #include <stdio.h>
6
7 /* Global variable with attribute */
8 int X __attribute__((annotate("GlobalValAnnotation")));
9
10 /* Function with attribute */
11 int foo(int y) __attribute__((annotate("GlobalValAnnotation"))) 
12                __attribute__((noinline));
13
14 int foo(int y __attribute__((annotate("LocalValAnnotation")))) {
15   int x __attribute__((annotate("LocalValAnnotation")));
16   x = 34;
17   return y + x;
18
19
20 int main() {
21   static int a __attribute__((annotate("GlobalValAnnotation")));
22   a = foo(2);
23   printf("hello world%d\n", a);
24   return 0;
25 }