diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-10-04 23:47:28 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-10-04 23:47:28 +0000 |
commit | 417dd179b2e92dcad3adb817b311e6297321a583 (patch) | |
tree | 6e44af8a3fc18e643ff4f70b5b6e185d6efadadb | |
parent | b0adbba45c3537cba66abd788eff884ed621a7d2 (diff) | |
download | clang-417dd179b2e92dcad3adb817b311e6297321a583.tar.gz |
Add coverage tests of C and Obj-C language features.
- AST printing, dumping, serialization, codegen.
- HTML printing.
- Parser callbacks.
Several of these are XFAIL because they trigger unimplemented code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57081 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Coverage/ast-printing.c | 5 | ||||
-rw-r--r-- | test/Coverage/ast-printing.m | 5 | ||||
-rw-r--r-- | test/Coverage/c-language-features.inc | 104 | ||||
-rw-r--r-- | test/Coverage/codegen.c | 4 | ||||
-rw-r--r-- | test/Coverage/codegen.m | 5 | ||||
-rw-r--r-- | test/Coverage/html-print.c | 3 | ||||
-rw-r--r-- | test/Coverage/objc-language-features.inc | 69 | ||||
-rw-r--r-- | test/Coverage/parse-callbacks.c | 4 | ||||
-rw-r--r-- | test/Coverage/parse-callbacks.m | 4 | ||||
-rw-r--r-- | test/Coverage/serialize.c | 4 | ||||
-rw-r--r-- | test/Coverage/serialize.m | 4 |
11 files changed, 211 insertions, 0 deletions
diff --git a/test/Coverage/ast-printing.c b/test/Coverage/ast-printing.c new file mode 100644 index 0000000000..0fc8b9f833 --- /dev/null +++ b/test/Coverage/ast-printing.c @@ -0,0 +1,5 @@ +// RUN: clang --fsyntax-only %s && +// RUN: clang --ast-print %s && +// RUN: clang --ast-dump %s + +#include "c-language-features.inc" diff --git a/test/Coverage/ast-printing.m b/test/Coverage/ast-printing.m new file mode 100644 index 0000000000..c53efac0d7 --- /dev/null +++ b/test/Coverage/ast-printing.m @@ -0,0 +1,5 @@ +// RUN: clang --fsyntax-only %s && +// RUN: clang --ast-print %s && +// RUN: clang --ast-dump %s + +#include "objc-language-features.inc" diff --git a/test/Coverage/c-language-features.inc b/test/Coverage/c-language-features.inc new file mode 100644 index 0000000000..a2dcb28e94 --- /dev/null +++ b/test/Coverage/c-language-features.inc @@ -0,0 +1,104 @@ +//-*- C -*- + +/* This is a + multiline comment */ + +// Intended to exercise all syntactic parts of the C language. + +int g0; +int g1, g2; + +struct s0; + +struct s0 { + int x; +}; + +int g3 = 10; + +__asm(""); + +typedef int td0; + +td0 g4; + +enum e0 { + ec0 +}; + +static void f0(int x) { +} + +inline void f0_0(int x) { + ; +} + +extern void f0_1(int x) { +} + +void f1(int, ...); + +// Statements. +void f2() { + for (;;) { + break; + continue; + } + + while (0) { + } + + do { + } while (0); + + void *label = &&theif; + goto *label; + + goto theif; +theif: + if (0) { + ; + } else if (0) { + } else { + } + + switch(0) { + case 0: + case 1 ... 2: + break; + default: + break; + } + + asm ("nop"); + + return; +} + +// Expressions. + +#include <stdarg.h> + +typedef struct ipair { + int first, second; +} ipair; + +void f4(int a0, int a1, int a2, va_list ap) { + int t0 = a0 ? a1 : a2; + float t1 = (float) a0; + ipair t2 = {1, 2}; + int t3 = sizeof(ipair); + ipair t4; + t4 = (ipair) {1, 2}; + extern int g(int); + int t5 = g(a0); + int t6 = t4.first; + int t7[10]; + int t8 = t7[a0]; + t8++; + const char *t9 = __FUNCTION__; + char t10 = 'x'; + int t11 = __builtin_offsetof(ipair, first); + int t12 = __builtin_types_compatible_p(ipair, int); + int t13 = va_arg(ap, int); +} diff --git a/test/Coverage/codegen.c b/test/Coverage/codegen.c new file mode 100644 index 0000000000..eb2873c783 --- /dev/null +++ b/test/Coverage/codegen.c @@ -0,0 +1,4 @@ +// RUN: clang -emit-llvm -o %t %s +// RUN: clang -emit-llvm-bc -o %t %s + +#include "c-language-features.inc" diff --git a/test/Coverage/codegen.m b/test/Coverage/codegen.m new file mode 100644 index 0000000000..9bfdb68d27 --- /dev/null +++ b/test/Coverage/codegen.m @@ -0,0 +1,5 @@ +// RUN: clang -fnext-runtime -emit-llvm -o %t %s +// RUN: clang -fnext-runtime -emit-llvm-bc -o %t %s +// XFAIL + +#include "objc-language-features.inc" diff --git a/test/Coverage/html-print.c b/test/Coverage/html-print.c new file mode 100644 index 0000000000..7ade9c6237 --- /dev/null +++ b/test/Coverage/html-print.c @@ -0,0 +1,3 @@ +// RUN: clang -emit-html -o %t %s + +#include "c-language-features.inc" diff --git a/test/Coverage/objc-language-features.inc b/test/Coverage/objc-language-features.inc new file mode 100644 index 0000000000..d341032b82 --- /dev/null +++ b/test/Coverage/objc-language-features.inc @@ -0,0 +1,69 @@ +//-*- ObjC -*- + +@protocol P0; + +@protocol P1 +-(void) fm0; +@end + +@class B; + +@interface Root +@end + +@interface A : Root <P1> { + int iv0; + B *iv1; +} + +@property(assign,readonly) int p0; +@property(assign,nonatomic,readwrite) int p1; +@property(copy) id p2; +@property(retain) id p3; +@property(assign, getter=getme, setter=setme:) id p4; +@end + +@implementation A +@dynamic p0; +@synthesize p1 = iv0; ++(void) fm0 { + [super fm0]; +} +-(void) im0 { + [super im0]; +} +-(void) im1: (int) x, ... { +} +@end + +@implementation C : A +@end + +#if 0 +@interface A (Cat) +@end + +@implementation A (Cat) +@end +#endif + +int f0(id x) { + @synchronized(x) { + } + + @try { + @throw x; + } @catch(A *e) { + @throw; + } @finally { + ; + } + + for (id y in x) { + break; + } +} + +struct s0 { + @defs(A); +}; diff --git a/test/Coverage/parse-callbacks.c b/test/Coverage/parse-callbacks.c new file mode 100644 index 0000000000..f65d9513d4 --- /dev/null +++ b/test/Coverage/parse-callbacks.c @@ -0,0 +1,4 @@ +// RUN: clang --parse-noop %s && +// RUN: clang --parse-print-callbacks %s + +#include "c-language-features.inc" diff --git a/test/Coverage/parse-callbacks.m b/test/Coverage/parse-callbacks.m new file mode 100644 index 0000000000..efce13e958 --- /dev/null +++ b/test/Coverage/parse-callbacks.m @@ -0,0 +1,4 @@ +// RUN: clang --parse-noop %s && +// RUN: clang --parse-print-callbacks %s + +#include "objc-language-features.inc" diff --git a/test/Coverage/serialize.c b/test/Coverage/serialize.c new file mode 100644 index 0000000000..5c81f31f5d --- /dev/null +++ b/test/Coverage/serialize.c @@ -0,0 +1,4 @@ +// RUN: clang -fsyntax-only --serialize %s +// XFAIL + +#include "c-language-features.inc" diff --git a/test/Coverage/serialize.m b/test/Coverage/serialize.m new file mode 100644 index 0000000000..8ad330a71d --- /dev/null +++ b/test/Coverage/serialize.m @@ -0,0 +1,4 @@ +// RUN: clang -fsyntax-only --serialize %s +// XFAIL + +#include "objc-language-features.inc" |