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
diff --git a/test/PCH/enum.h b/test/PCH/enum.h
index cfa8d6f..c94e314 100644
--- a/test/PCH/enum.h
+++ b/test/PCH/enum.h
@@ -8,9 +8,9 @@
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 0000000..d1cd563
--- /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 0000000..db6513c
--- /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 fd14c4f..5af21af 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 4ac9077..06c4601 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 220f079..5ea9fe2 100644
--- a/test/PCH/struct.c
+++ b/test/PCH/struct.c
@@ -23,6 +23,8 @@
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 6c25622..2ffdd4a 100644
--- a/test/PCH/struct.h
+++ b/test/PCH/struct.h
@@ -13,7 +13,7 @@
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 e62a4bb..425305c 100644
--- a/test/PCH/types.c
+++ b/test/PCH/types.c
@@ -56,7 +56,10 @@
// 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 3713e0b..54ab215 100644
--- a/test/PCH/types.h
+++ b/test/PCH/types.h
@@ -35,7 +35,8 @@
// 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 4f42e50..afd4546 100644
--- a/test/PCH/variables.c
+++ b/test/PCH/variables.c
@@ -9,7 +9,8 @@
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 82e87aa..70aec65 100644
--- a/test/PCH/variables.h
+++ b/test/PCH/variables.h
@@ -9,7 +9,7 @@
float z;
-
+int z2 = 17;
#define MAKE_HAPPY(X) X##Happy
int MAKE_HAPPY(Very);