diff options
Diffstat (limited to 'test')
104 files changed, 1220 insertions, 0 deletions
diff --git a/test/Lexer/badstring_in_if0.c b/test/Lexer/badstring_in_if0.c new file mode 100644 index 0000000000..714f89b386 --- /dev/null +++ b/test/Lexer/badstring_in_if0.c @@ -0,0 +1,8 @@ +// RUN: clang -E %s 2>&1 | not grep error +#if 0 + + " + + ' + +#endif diff --git a/test/Lexer/block_cmt_end.c b/test/Lexer/block_cmt_end.c new file mode 100644 index 0000000000..b111b2a23e --- /dev/null +++ b/test/Lexer/block_cmt_end.c @@ -0,0 +1,27 @@ +/* + RUN: clang -E %s | grep bar && + RUN: clang -E %s | grep foo && + RUN: clang -E %s | not grep abc && + RUN: clang -E %s | not grep xyz && + RUN: clang -parse-ast-check %s + */ + +/* abc + +next comment ends with normal escaped newline: +*/ + +/* expected-warning {{escaped newline}} expected-warning {{backslash and newline}} *\ +/ + +bar + +/* xyz + +next comment ends with a trigraph escaped newline: */ + +/* expected-warning {{escaped newline between}} expected-warning {{backslash and newline separated by space}} expected-warning {{trigraph ends block comment}} *??/ +/ + +foo /* expected-error {{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}} */ + diff --git a/test/Lexer/escape_newline.c b/test/Lexer/escape_newline.c new file mode 100644 index 0000000000..235ee51ef0 --- /dev/null +++ b/test/Lexer/escape_newline.c @@ -0,0 +1,7 @@ +// RUN: clang -E %s | grep -- ' ->' && +// RUN: clang -E %s 2>&1 | grep 'backslash and newline separated by space' && +// RUN: clang -E %s 2>&1 | grep 'trigraph converted' + +// This is an ugly way to spell a -> token. + -??/ +> diff --git a/test/Lexer/number.c b/test/Lexer/number.c new file mode 100644 index 0000000000..4e12cc7edc --- /dev/null +++ b/test/Lexer/number.c @@ -0,0 +1,4 @@ +// RUN: clang %s -fsyntax-only + +float X = 1.17549435e-38F; + diff --git a/test/Lexer/unknown-char.c b/test/Lexer/unknown-char.c new file mode 100644 index 0000000000..8bdfe60553 --- /dev/null +++ b/test/Lexer/unknown-char.c @@ -0,0 +1,2 @@ +// RUN: clang -E %s 2>&1 | not grep error + ` ` ` ` diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000000..2c35b4421e --- /dev/null +++ b/test/Makefile @@ -0,0 +1,3 @@ + +all: + find Lexer Preprocessor Parser -name '*.c*' -print -exec ./TestRunner.sh {} \; diff --git a/test/Parser/CompoundStmtScope.c b/test/Parser/CompoundStmtScope.c new file mode 100644 index 0000000000..d6a4730632 --- /dev/null +++ b/test/Parser/CompoundStmtScope.c @@ -0,0 +1,8 @@ +// RUN: clang -parse-ast-check %s + +int foo() { + { + typedef float X; + } + X Y; // expected-error {{use of undeclared identifier}} +} diff --git a/test/Parser/argument_qualified.c b/test/Parser/argument_qualified.c new file mode 100644 index 0000000000..cd92c3258c --- /dev/null +++ b/test/Parser/argument_qualified.c @@ -0,0 +1,5 @@ +// RUN: clang %s +int abc (const float x) { + return 1; +} + diff --git a/test/Parser/argument_redef.c b/test/Parser/argument_redef.c new file mode 100644 index 0000000000..c3dae512a3 --- /dev/null +++ b/test/Parser/argument_redef.c @@ -0,0 +1,6 @@ +/* RUN: clang -parse-ast-check %s +*/ + +int foo(int A) { /* expected-error {{previous definition is here}} */ + int A; /* expected-error {{redefinition of 'A'}} */ +} diff --git a/test/Parser/argument_scope.c b/test/Parser/argument_scope.c new file mode 100644 index 0000000000..8b9f065c82 --- /dev/null +++ b/test/Parser/argument_scope.c @@ -0,0 +1,6 @@ +// RUN: clang -fsyntax-only %s +typedef struct foo foo; + +void blah(int foo) { + foo = 1; +} diff --git a/test/Parser/attributes.c b/test/Parser/attributes.c new file mode 100644 index 0000000000..29e8c81f3b --- /dev/null +++ b/test/Parser/attributes.c @@ -0,0 +1,6 @@ +// RUN: clang -parse-ast-check %s + +static __inline void __attribute__((__always_inline__, __nodebug__)) // expected-warning {{extension used}} +foo (void) +{ +} diff --git a/test/Parser/bad-control.c b/test/Parser/bad-control.c new file mode 100644 index 0000000000..914393461a --- /dev/null +++ b/test/Parser/bad-control.c @@ -0,0 +1,9 @@ +/* RUN: clang -parse-ast-check %s +*/ +int foo() { + break; /* expected-error {{'break' statement not in loop or switch statement}} */ +} + +int foo2() { + continue; /* expected-error {{'continue' statement not in loop statement}} */ +} diff --git a/test/Parser/c-namespace.c b/test/Parser/c-namespace.c new file mode 100644 index 0000000000..2b380503ac --- /dev/null +++ b/test/Parser/c-namespace.c @@ -0,0 +1,6 @@ +// RUN: clang -fsyntax-only %s +void bla1() { + struct XXX; + int XXX; +} + diff --git a/test/Parser/cxx-bool.cpp b/test/Parser/cxx-bool.cpp new file mode 100644 index 0000000000..623dcb2887 --- /dev/null +++ b/test/Parser/cxx-bool.cpp @@ -0,0 +1,4 @@ +// RUN: clang -fsyntax-only %s + +bool a = true; +bool b = false; diff --git a/test/Parser/cxx-casting.cpp b/test/Parser/cxx-casting.cpp new file mode 100644 index 0000000000..638985faf7 --- /dev/null +++ b/test/Parser/cxx-casting.cpp @@ -0,0 +1,32 @@ +// RUN: clang -fsyntax-only %s +// XFAIL: * + +char *const_cast_test(const char *var) +{ + return const_cast<char*>(var); +} + +#if 0 +// FIXME: Uncomment when C++ is supported more. +struct A { + virtual ~A() {} +}; + +struct B : public A { +}; + +struct B *dynamic_cast_test(struct A *a) +{ + return dynamic_cast<struct B*>(a); +} +#endif + +char *reinterpret_cast_test() +{ + return reinterpret_cast<char*>(0xdeadbeef); +} + +double static_cast_test(int i) +{ + return static_cast<double>(i); +} diff --git a/test/Parser/cxx-reference.cpp b/test/Parser/cxx-reference.cpp new file mode 100644 index 0000000000..44a2a03c9c --- /dev/null +++ b/test/Parser/cxx-reference.cpp @@ -0,0 +1,17 @@ +// RUN: clang -parse-ast-check %s + +extern char *bork; +char *& bar = bork; + +void foo(int &a) { +} + +typedef int & A; + +void g(const A aref) { +} + +int & const X; // expected-error {{'const' qualifier may not be applied to a reference}} +int & volatile Y; // expected-error {{'volatile' qualifier may not be applied to a reference}} +int & const volatile Z; /* expected-error {{'const' qualifier may not be applied}} \ + expected-error {{'volatile' qualifier may not be applied}} */ diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c new file mode 100644 index 0000000000..af599f82fe --- /dev/null +++ b/test/Parser/declarators.c @@ -0,0 +1,28 @@ +// RUN: clang %s -fsyntax-only + +extern int a1[]; + +void f0(); +void f1(int [*]); +void f2(int [const *]); +void f3(int [volatile const*]); +int f4(*XX)(void); + +char ((((*X)))); + +void (*signal(int, void (*)(int)))(int); |