]> granicus.if.org Git - clang/commitdiff
Support extended vector types in chained PCH.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 28 Jul 2010 21:38:49 +0000 (21:38 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 28 Jul 2010 21:38:49 +0000 (21:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109675 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PCHReader.cpp
test/PCH/Inputs/chain-ext_vector1.h [new file with mode: 0644]
test/PCH/Inputs/chain-ext_vector2.h [new file with mode: 0644]
test/PCH/chain-ext_vector.c [new file with mode: 0644]

index bdc02020b406aa192cf5744bccf19f1f15064985..69922b0d0fad9919ee038fb58701e6402a4c16bf 100644 (file)
@@ -1685,11 +1685,12 @@ PCHReader::ReadPCHBlock(PerFileData &F) {
     }
 
     case pch::EXT_VECTOR_DECLS:
-      if (!ExtVectorDecls.empty()) {
-        Error("duplicate EXT_VECTOR_DECLS record in PCH file");
-        return Failure;
-      }
-      ExtVectorDecls.swap(Record);
+      // Optimization for the first block.
+      if (ExtVectorDecls.empty())
+        ExtVectorDecls.swap(Record);
+      else
+        ExtVectorDecls.insert(ExtVectorDecls.end(),
+                              Record.begin(), Record.end());
       break;
 
     case pch::VTABLE_USES:
diff --git a/test/PCH/Inputs/chain-ext_vector1.h b/test/PCH/Inputs/chain-ext_vector1.h
new file mode 100644 (file)
index 0000000..5109336
--- /dev/null
@@ -0,0 +1,3 @@
+// First header file for chain-ext_vector.c PCH test
+
+typedef __attribute__((ext_vector_type(2))) float float2;
diff --git a/test/PCH/Inputs/chain-ext_vector2.h b/test/PCH/Inputs/chain-ext_vector2.h
new file mode 100644 (file)
index 0000000..bdaeccc
--- /dev/null
@@ -0,0 +1,3 @@
+// Second header file for chain-ext_vector.c PCH test
+
+typedef __attribute__((ext_vector_type(4))) float float4;
diff --git a/test/PCH/chain-ext_vector.c b/test/PCH/chain-ext_vector.c
new file mode 100644 (file)
index 0000000..2635070
--- /dev/null
@@ -0,0 +1,11 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/chain-ext_vector1.h -include %S/Inputs/chain-ext_vector2.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-ext_vector1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-ext_vector2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+
+int test(float4 f4) {
+  return f4.xy; // expected-error{{float2}}
+}