summaryrefslogtreecommitdiff
path: root/clang/test/Parser/attributes.c
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/Parser/attributes.c
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/Parser/attributes.c')
-rw-r--r--clang/test/Parser/attributes.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/clang/test/Parser/attributes.c b/clang/test/Parser/attributes.c
new file mode 100644
index 0000000..347cb9c
--- /dev/null
+++ b/clang/test/Parser/attributes.c
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic -std=c99
+
+int __attribute__(()) x;
+
+__inline void __attribute__((__always_inline__, __nodebug__))
+foo(void) {
+}
+
+
+__attribute__(()) y; // expected-warning {{defaults to 'int'}}
+
+// PR2796
+int (__attribute__(()) *z)(long y);
+
+
+void f1(__attribute__(()) int x);
+
+int f2(y, __attribute__(()) x); // expected-error {{expected identifier}}
+
+// This is parsed as a normal argument list (with two args that are implicit
+// int) because the __attribute__ is a declspec.
+void f3(__attribute__(()) x, // expected-warning {{defaults to 'int'}}
+ y); // expected-warning {{defaults to 'int'}}
+
+void f4(__attribute__(())); // expected-error {{expected parameter declarator}}
+
+
+// This is ok, the __attribute__ applies to the pointer.
+int baz(int (__attribute__(()) *x)(long y));
+
+void g1(void (*f1)(__attribute__(()) int x));
+void g2(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
+void g3(void (*f3)(__attribute__(()) x, int y)); // expected-warning {{defaults to 'int'}}
+void g4(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
+
+
+void (*h1)(void (*f1)(__attribute__(()) int x));
+void (*h2)(int (*f2)(y, __attribute__(()) x)); // expected-error {{expected identifier}}
+
+void (*h3)(void (*f3)(__attribute__(()) x)); // expected-warning {{defaults to 'int'}}
+void (*h4)(void (*f4)(__attribute__(()))); // expected-error {{expected parameter declarator}}
+
+
+
+// rdar://6131260
+int foo42(void) {
+ int x, __attribute__((unused)) y, z;
+ return 0;
+}
+
+// rdar://6096491
+void __attribute__((noreturn)) d0(void), __attribute__((noreturn)) d1(void);
+
+void d2(void) __attribute__((noreturn)), d3(void) __attribute__((noreturn));
+
+
+// PR6287
+void __attribute__((returns_twice)) returns_twice_test();
+
+int aligned(int);
+int __attribute__((vec_type_hint(char, aligned(16) )) missing_rparen_1; // expected-error {{expected ')'}}
+int __attribute__((mode(x aligned(16) )) missing_rparen_2; // expected-error {{expected ')'}}
+int __attribute__((format(printf, 0 aligned(16) )) missing_rparen_3; // expected-error {{expected ')'}}
+
+
+
+int testFundef1(int *a) __attribute__((nonnull(1))) { // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ return *a;
+}
+
+// noreturn is lifted to type qualifier
+void testFundef2() __attribute__((noreturn)) { // \
+ // expected-warning {{GCC does not allow noreturn attribute in this position on a function definition}}
+ testFundef2();
+}
+
+int testFundef3(int *a) __attribute__((nonnull(1), // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ pure)) { // \
+ // expected-warning {{GCC does not allow pure attribute in this position on a function definition}}
+ return *a;
+}
+
+int testFundef4(int *a) __attribute__((nonnull(1))) // \
+ // expected-warning {{GCC does not allow nonnull attribute in this position on a function definition}}
+ __attribute((pure)) { // \
+ // expected-warning {{GCC does not allow pure attribute in this position on a function definition}}
+ return *a;
+}
+
+// GCC allows these
+void testFundef5() __attribute__(()) { }
+
+__attribute__((pure)) int testFundef6(int a) { return a; }
+
+
+