diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-14 21:18:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-14 21:18:50 +0000 |
commit | 0b7489194f9f89fac39d57211c1e7953ae50251f (patch) | |
tree | ca09eb36de431daa65f27488790d747ea49a7b7d /test | |
parent | b6645dd9ca7a44e9b5f657e14820d5edcc511ee5 (diff) |
PCH support for a few very, very simple kinds of expressions. Hook up
expression (de-)serialization for VLAs, variable initializers,
enum constant initializers, and bitfield widths.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/PCH/enum.h | 4 | ||||
-rw-r--r-- | test/PCH/exprs.c | 19 | ||||
-rw-r--r-- | test/PCH/exprs.h | 14 | ||||
-rw-r--r-- | test/PCH/external-defs.c | 3 | ||||
-rw-r--r-- | test/PCH/external-defs.h | 2 | ||||
-rw-r--r-- | test/PCH/struct.c | 2 | ||||
-rw-r--r-- | test/PCH/struct.h | 2 | ||||
-rw-r--r-- | test/PCH/types.c | 5 | ||||
-rw-r--r-- | test/PCH/types.h | 3 | ||||
-rw-r--r-- | test/PCH/variables.c | 3 | ||||
-rw-r--r-- | test/PCH/variables.h | 2 |
11 files changed, 49 insertions, 10 deletions
diff --git a/test/PCH/enum.h b/test/PCH/enum.h index cfa8d6f3d8..c94e314eb0 100644 --- a/test/PCH/enum.h +++ b/test/PCH/enum.h @@ -8,9 +8,9 @@ enum Color { enum Shape { Square, - Triangle, + Triangle = 17, Rhombus, Circle }; -enum Shape aRoundShape = Circle; +enum Shape aRoundShape;// FIXME: = Circle; diff --git a/test/PCH/exprs.c b/test/PCH/exprs.c new file mode 100644 index 0000000000..d1cd5636b8 --- /dev/null +++ b/test/PCH/exprs.c @@ -0,0 +1,19 @@ +// Test this without pch. +// RUN: clang-cc -fblocks -include %S/exprs.h -fsyntax-only -verify %s + +// Test with pch. +// RUN: clang-cc -emit-pch -fblocks -o %t %S/exprs.h && +// RUN: clang-cc -fblocks -include-pch %t -fsyntax-only -verify %s + +int integer; +long long_integer; + +// DeclRefExpr +int_decl_ref *int_ptr1 = &integer; +enum_decl_ref *enum_ptr1 = &integer; +// IntegerLiteralExpr +integer_literal *int_ptr2 = &integer; +long_literal *long_ptr1 = &long_integer; + +// CharacterLiteralExpr +char_literal *int_ptr3 = &integer; diff --git a/test/PCH/exprs.h b/test/PCH/exprs.h new file mode 100644 index 0000000000..db6513c35b --- /dev/null +++ b/test/PCH/exprs.h @@ -0,0 +1,14 @@ +// Header for PCH test exprs.c + +// DeclRefExpr +int i = 17; +enum Enum { Enumerator = 18 }; +typedef typeof(i) int_decl_ref; +typedef typeof(Enumerator) enum_decl_ref; + +// IntegerLiteralExpr +typedef typeof(17) integer_literal; +typedef typeof(17l) long_literal; + +// CharacterLiteralExpr +typedef typeof('a') char_literal; diff --git a/test/PCH/external-defs.c b/test/PCH/external-defs.c index fd14c4fa8b..5af21af517 100644 --- a/test/PCH/external-defs.c +++ b/test/PCH/external-defs.c @@ -3,8 +3,7 @@ // RUN: clang-cc -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s && // RUN: grep "@x = common global i32 0" %t | count 1 && -// FIXME below: should be i32 17, but we don't serialize y's value yet -// RUN: grep "@y = common global i32 0" %t | count 1 && +// RUN: grep "@y = global i32 17" %t | count 1 && // RUN: grep "@z" %t | count 0 && // RUN: grep "@x2 = global i32 19" %t | count 1 && diff --git a/test/PCH/external-defs.h b/test/PCH/external-defs.h index 4ac9077d12..06c4601ccb 100644 --- a/test/PCH/external-defs.h +++ b/test/PCH/external-defs.h @@ -4,7 +4,7 @@ int x; int x2; -// FIXME: check this, once we actually serialize it +// Definitions int y = 17; // Should not show up diff --git a/test/PCH/struct.c b/test/PCH/struct.c index 220f079465..5ea9fe2757 100644 --- a/test/PCH/struct.c +++ b/test/PCH/struct.c @@ -23,6 +23,8 @@ int get_very_fun() { return fun2->very_fun; } +int *int_ptr_fail = &fun->is_ptr; // expected-error{{address of bit-field requested}} + /* FIXME: DeclContexts aren't yet able to find "struct Nested" nested within "struct S", so causing the following to fail. When not using PCH, this works because Sema puts the nested struct onto the diff --git a/test/PCH/struct.h b/test/PCH/struct.h index 6c256221fa..2ffdd4aea5 100644 --- a/test/PCH/struct.h +++ b/test/PCH/struct.h @@ -13,7 +13,7 @@ struct Fun; struct Fun *fun; struct Fun { - int is_ptr; + int is_ptr : 1; union { void *ptr; diff --git a/test/PCH/types.c b/test/PCH/types.c index e62a4bbe3b..425305c584 100644 --- a/test/PCH/types.c +++ b/test/PCH/types.c @@ -56,7 +56,10 @@ proto *p2 = p1; // TYPE_TYPEDEF int_ptr_ptr ipp = &int_value_ptr; -// FIXME: TYPE_TYPEOF_EXPR +// TYPE_TYPEOF_EXPR +typeof_17 *t17 = &int_value; +struct S { int x, y; }; +typeof_17 t17_2 = (struct S){1, 2}; // expected-error{{incompatible type initializing}} // TYPE_TYPEOF int_ptr_ptr2 ipp2 = &int_value_ptr; diff --git a/test/PCH/types.h b/test/PCH/types.h index 3713e0b690..54ab2152d7 100644 --- a/test/PCH/types.h +++ b/test/PCH/types.h @@ -35,7 +35,8 @@ typedef float proto(float, float, ...); // TYPE_TYPEDEF typedef int_ptr * int_ptr_ptr; -// FIXME: TYPE_TYPEOF_EXPR +// TYPE_TYPEOF_EXPR +typedef typeof(17) typeof_17; // TYPE_TYPEOF typedef typeof(int_ptr *) int_ptr_ptr2; diff --git a/test/PCH/variables.c b/test/PCH/variables.c index 4f42e50481..afd45461d0 100644 --- a/test/PCH/variables.c +++ b/test/PCH/variables.c @@ -9,7 +9,8 @@ int *ip2 = &x; float *fp = &ip; // expected-warning{{incompatible pointer types}} // FIXME:variables.h expected-note{{previous}} double z; // expected-error{{redefinition}} - +// FIXME:variables.h expected-note{{previous}} +int z2 = 18; // expected-error{{redefinition}} //double VeryHappy; // FIXME: xpected-error{{redefinition}} diff --git a/test/PCH/variables.h b/test/PCH/variables.h index 82e87aaf4b..70aec65180 100644 --- a/test/PCH/variables.h +++ b/test/PCH/variables.h @@ -9,7 +9,7 @@ extern int *ip, x; float z; - +int z2 = 17; #define MAKE_HAPPY(X) X##Happy int MAKE_HAPPY(Very); |