summaryrefslogtreecommitdiffstats
path: root/test/LLVMC
diff options
context:
space:
mode:
Diffstat (limited to 'test/LLVMC')
-rw-r--r--test/LLVMC/C++/dash-x.cpp9
-rw-r--r--test/LLVMC/C++/dg.exp5
-rw-r--r--test/LLVMC/C++/hello.cpp8
-rw-r--r--test/LLVMC/C++/together.cpp9
-rw-r--r--test/LLVMC/C/dg.exp5
-rw-r--r--test/LLVMC/C/emit-llvm.c4
-rw-r--r--test/LLVMC/C/hello.c12
-rw-r--r--test/LLVMC/C/include.c9
-rw-r--r--test/LLVMC/C/opt-test.c12
-rw-r--r--test/LLVMC/C/sink.c12
-rw-r--r--test/LLVMC/C/wall.c12
-rw-r--r--test/LLVMC/EmptyCompilationGraph.td2
-rw-r--r--test/LLVMC/EnvParentheses.td2
-rw-r--r--test/LLVMC/ExternOptions.td4
-rw-r--r--test/LLVMC/ForwardAs.td4
-rw-r--r--test/LLVMC/HookWithArguments.td2
-rw-r--r--test/LLVMC/MultiValuedOption.td4
-rw-r--r--test/LLVMC/MultipleCompilationGraphs.td2
-rw-r--r--test/LLVMC/NoActions.td4
-rw-r--r--test/LLVMC/NoCompilationGraph.td2
-rw-r--r--test/LLVMC/ObjC++/dg.exp5
-rw-r--r--test/LLVMC/ObjC++/hello.mm8
-rw-r--r--test/LLVMC/ObjC/dg.exp5
-rw-r--r--test/LLVMC/ObjC/hello.m12
-rw-r--r--test/LLVMC/OneOrMore.td4
-rw-r--r--test/LLVMC/TestWarnings.td2
-rw-r--r--test/LLVMC/dg.exp3
-rw-r--r--test/LLVMC/test_data/false.c10
28 files changed, 156 insertions, 16 deletions
diff --git a/test/LLVMC/C++/dash-x.cpp b/test/LLVMC/C++/dash-x.cpp
new file mode 100644
index 0000000..b32400e
--- /dev/null
+++ b/test/LLVMC/C++/dash-x.cpp
@@ -0,0 +1,9 @@
+// Test that we can compile .c files as C++ and vice versa
+// RUN: llvmc %s -x c++ %p/../test_data/false.c -x c %p/../test_data/false.cpp -x lisp -x whatnot -x none %p/../test_data/false2.cpp -o %t
+// RUN: %abs_tmp | grep hello
+
+extern int test_main();
+
+int main() {
+ test_main();
+}
diff --git a/test/LLVMC/C++/dg.exp b/test/LLVMC/C++/dg.exp
new file mode 100644
index 0000000..fc852e3
--- /dev/null
+++ b/test/LLVMC/C++/dg.exp
@@ -0,0 +1,5 @@
+load_lib llvm.exp
+
+if [ llvm_gcc_supports c++ ] then {
+ RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
+}
diff --git a/test/LLVMC/C++/hello.cpp b/test/LLVMC/C++/hello.cpp
new file mode 100644
index 0000000..b9c6399
--- /dev/null
+++ b/test/LLVMC/C++/hello.cpp
@@ -0,0 +1,8 @@
+// Test that we can compile C++ code.
+// RUN: llvmc %s -o %t
+// RUN: %abs_tmp | grep hello
+#include <iostream>
+
+int main() {
+ std::cout << "hello" << '\n';
+}
diff --git a/test/LLVMC/C++/together.cpp b/test/LLVMC/C++/together.cpp
new file mode 100644
index 0000000..e02f69a
--- /dev/null
+++ b/test/LLVMC/C++/together.cpp
@@ -0,0 +1,9 @@
+// Check that we can compile files of different types together.
+// RUN: llvmc %s %p/../test_data/together.c -o %t
+// RUN: %abs_tmp | grep hello
+
+extern "C" void test();
+
+int main() {
+ test();
+}
diff --git a/test/LLVMC/C/dg.exp b/test/LLVMC/C/dg.exp
new file mode 100644
index 0000000..a9be28a
--- /dev/null
+++ b/test/LLVMC/C/dg.exp
@@ -0,0 +1,5 @@
+load_lib llvm.exp
+
+if [ llvm_gcc_supports c ] then {
+ RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
+}
diff --git a/test/LLVMC/C/emit-llvm.c b/test/LLVMC/C/emit-llvm.c
new file mode 100644
index 0000000..38bbba6
--- /dev/null
+++ b/test/LLVMC/C/emit-llvm.c
@@ -0,0 +1,4 @@
+// RUN: llvmc -c -emit-llvm -o - %s | llvm-dis | grep "@f0()" | count 1
+
+int f0(void) {
+}
diff --git a/test/LLVMC/C/hello.c b/test/LLVMC/C/hello.c
new file mode 100644
index 0000000..b2d903f
--- /dev/null
+++ b/test/LLVMC/C/hello.c
@@ -0,0 +1,12 @@
+/*
+ * Check that we can compile helloworld
+ * RUN: llvmc %s -o %t
+ * RUN: %abs_tmp | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/C/include.c b/test/LLVMC/C/include.c
new file mode 100644
index 0000000..07ae761
--- /dev/null
+++ b/test/LLVMC/C/include.c
@@ -0,0 +1,9 @@
+/*
+ * Check that the 'include' options work.
+ * RUN: echo "int x;\n" > %t1.inc
+ * RUN: llvmc -include %t1.inc -fsyntax-only %s
+ */
+
+int f0(void) {
+ return x;
+}
diff --git a/test/LLVMC/C/opt-test.c b/test/LLVMC/C/opt-test.c
new file mode 100644
index 0000000..d69dc9b
--- /dev/null
+++ b/test/LLVMC/C/opt-test.c
@@ -0,0 +1,12 @@
+/*
+ * Check that the -opt switch works.
+ * RUN: llvmc %s -opt -o %t
+ * RUN: %abs_tmp | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/C/sink.c b/test/LLVMC/C/sink.c
new file mode 100644
index 0000000..bdff340
--- /dev/null
+++ b/test/LLVMC/C/sink.c
@@ -0,0 +1,12 @@
+/*
+ * Check that the 'sink' options work.
+ * RUN: llvmc -v -Wall %s -o %t |& grep "Wall"
+ * RUN: %abs_tmp | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/C/wall.c b/test/LLVMC/C/wall.c
new file mode 100644
index 0000000..f676099
--- /dev/null
+++ b/test/LLVMC/C/wall.c
@@ -0,0 +1,12 @@
+/*
+ * Check that -Wall works as intended
+ * RUN: llvmc -Wall %s -o %t
+ * RUN: %abs_tmp | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/EmptyCompilationGraph.td b/test/LLVMC/EmptyCompilationGraph.td
index f4a3047..b30f84c 100644
--- a/test/LLVMC/EmptyCompilationGraph.td
+++ b/test/LLVMC/EmptyCompilationGraph.td
@@ -1,5 +1,5 @@
// Check that the compilation graph can be empty.
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s
+// RUN: tblgen -I %p/../../include --gen-llvmc %s
include "llvm/CompilerDriver/Common.td"
diff --git a/test/LLVMC/EnvParentheses.td b/test/LLVMC/EnvParentheses.td
index cf2a0e3..694468f 100644
--- a/test/LLVMC/EnvParentheses.td
+++ b/test/LLVMC/EnvParentheses.td
@@ -1,6 +1,6 @@
// Check the fix for PR4157.
// http://llvm.org/bugs/show_bug.cgi?id=4157
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
// RUN: not grep {)));} %t
include "llvm/CompilerDriver/Common.td"
diff --git a/test/LLVMC/ExternOptions.td b/test/LLVMC/ExternOptions.td
index a04a88b..5c69af7 100644
--- a/test/LLVMC/ExternOptions.td
+++ b/test/LLVMC/ExternOptions.td
@@ -1,6 +1,6 @@
// Check that extern options work.
// The dummy tool and graph are required to silence warnings.
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
// RUN: grep {extern .* AutoGeneratedSwitch_Wall} %t
include "llvm/CompilerDriver/Common.td"
@@ -10,7 +10,7 @@ def OptList : OptionList<[(switch_option "Wall", (extern)),
(prefix_list_option "L", (extern))]>;
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy"),
(actions (case
diff --git a/test/LLVMC/ForwardAs.td b/test/LLVMC/ForwardAs.td
index 5e5a087..51bd494 100644
--- a/test/LLVMC/ForwardAs.td
+++ b/test/LLVMC/ForwardAs.td
@@ -1,6 +1,6 @@
// Check the fix for PR4159.
// http://llvm.org/bugs/show_bug.cgi?id=4159
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
// RUN: grep unique_name %t
include "llvm/CompilerDriver/Common.td"
@@ -8,7 +8,7 @@ include "llvm/CompilerDriver/Common.td"
def OptList : OptionList<[(parameter_option "dummy", (extern))]>;
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy"),
(actions (case
diff --git a/test/LLVMC/HookWithArguments.td b/test/LLVMC/HookWithArguments.td
index 0f7c379..3bdb3ee 100644
--- a/test/LLVMC/HookWithArguments.td
+++ b/test/LLVMC/HookWithArguments.td
@@ -1,5 +1,5 @@
// Check that hooks with arguments work.
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
// RUN: grep {Hook(const char\\* Arg0, const char\\* Arg1, const char\\* Arg2);} %t | count 1
// RUN: grep "/path" %t | count 1
// RUN: grep "VARIABLE" %t | count 1
diff --git a/test/LLVMC/MultiValuedOption.td b/test/LLVMC/MultiValuedOption.td
index d68a115..bd1e033 100644
--- a/test/LLVMC/MultiValuedOption.td
+++ b/test/LLVMC/MultiValuedOption.td
@@ -1,6 +1,6 @@
// Check that multivalued options work.
// The dummy tool and graph are required to silence warnings.
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
// RUN: grep cl::multi_val(2) %t | count 1
include "llvm/CompilerDriver/Common.td"
@@ -10,7 +10,7 @@ def OptList : OptionList<[
(parameter_list_option "baz", (multi_val 2), (extern))]>;
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy"),
(actions (case
diff --git a/test/LLVMC/MultipleCompilationGraphs.td b/test/LLVMC/MultipleCompilationGraphs.td
index 3305fc6..64dbc9b 100644
--- a/test/LLVMC/MultipleCompilationGraphs.td
+++ b/test/LLVMC/MultipleCompilationGraphs.td
@@ -1,5 +1,5 @@
// Check that multiple compilation graphs are allowed.
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s
+// RUN: tblgen -I %p/../../include --gen-llvmc %s
include "llvm/CompilerDriver/Common.td"
diff --git a/test/LLVMC/NoActions.td b/test/LLVMC/NoActions.td
index 43fd007..2a4a749 100644
--- a/test/LLVMC/NoActions.td
+++ b/test/LLVMC/NoActions.td
@@ -1,10 +1,10 @@
// Check that tools without associated actions are accepted.
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s | grep dummy_tool
+// RUN: tblgen -I %p/../../include --gen-llvmc %s | grep dummy_tool
include "llvm/CompilerDriver/Common.td"
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy")
]>;
diff --git a/test/LLVMC/NoCompilationGraph.td b/test/LLVMC/NoCompilationGraph.td
index 6476a37..2eea3e9 100644
--- a/test/LLVMC/NoCompilationGraph.td
+++ b/test/LLVMC/NoCompilationGraph.td
@@ -1,4 +1,4 @@
// Check that the compilation graph is not required.
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s
+// RUN: tblgen -I %p/../../include --gen-llvmc %s
include "llvm/CompilerDriver/Common.td"
diff --git a/test/LLVMC/ObjC++/dg.exp b/test/LLVMC/ObjC++/dg.exp
new file mode 100644
index 0000000..41c3db2
--- /dev/null
+++ b/test/LLVMC/ObjC++/dg.exp
@@ -0,0 +1,5 @@
+load_lib llvm.exp
+
+if [ llvm_gcc_supports obj-c++ ] then {
+ RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{mm}]]
+}
diff --git a/test/LLVMC/ObjC++/hello.mm b/test/LLVMC/ObjC++/hello.mm
new file mode 100644
index 0000000..2125dc7
--- /dev/null
+++ b/test/LLVMC/ObjC++/hello.mm
@@ -0,0 +1,8 @@
+// Test that we can compile Objective-C++ code.
+// RUN: llvmc %s -o %t
+// RUN: %abs_tmp | grep hello
+#include <iostream>
+
+int main() {
+ std::cout << "hello" << '\n';
+}
diff --git a/test/LLVMC/ObjC/dg.exp b/test/LLVMC/ObjC/dg.exp
new file mode 100644
index 0000000..18f73a7
--- /dev/null
+++ b/test/LLVMC/ObjC/dg.exp
@@ -0,0 +1,5 @@
+load_lib llvm.exp
+
+if [ llvm_gcc_supports objc ] then {
+ RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{m}]]
+}
diff --git a/test/LLVMC/ObjC/hello.m b/test/LLVMC/ObjC/hello.m
new file mode 100644
index 0000000..b2d903f
--- /dev/null
+++ b/test/LLVMC/ObjC/hello.m
@@ -0,0 +1,12 @@
+/*
+ * Check that we can compile helloworld
+ * RUN: llvmc %s -o %t
+ * RUN: %abs_tmp | grep hello
+ */
+
+#include <stdio.h>
+
+int main() {
+ printf("hello\n");
+ return 0;
+}
diff --git a/test/LLVMC/OneOrMore.td b/test/LLVMC/OneOrMore.td
index f27ae97..38b7eb7 100644
--- a/test/LLVMC/OneOrMore.td
+++ b/test/LLVMC/OneOrMore.td
@@ -1,6 +1,6 @@
// Check that (one_or_more) and (zero_or_one) properties work.
// The dummy tool and graph are required to silence warnings.
-// RUN: tblgen -I $srcroot/include --gen-llvmc %s -o %t
+// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t
// RUN: grep cl::ZeroOrOne %t | count 1
// RUN: grep cl::OneOrMore %t | count 1
@@ -11,7 +11,7 @@ def OptList : OptionList<[
(parameter_list_option "baz", (zero_or_one))]>;
def dummy_tool : Tool<[
-(cmd_line "dummy_cmd"),
+(cmd_line "dummy_cmd $INFILE"),
(in_language "dummy"),
(out_language "dummy"),
(actions (case
diff --git a/test/LLVMC/TestWarnings.td b/test/LLVMC/TestWarnings.td
index bf2173c..1a4064e 100644
--- a/test/LLVMC/TestWarnings.td
+++ b/test/LLVMC/TestWarnings.td
@@ -1,6 +1,6 @@
// Check that the compiler warns about unused options.
// This should fail because the output is printed on stderr.
-// RUN: ignore tblgen -I $srcroot/include --gen-llvmc %s |& grep "option '-Wall' has no effect!"
+// RUN: ignore tblgen -I %p/../../include --gen-llvmc %s |& grep "option '-Wall' has no effect!"
include "llvm/CompilerDriver/Common.td"
diff --git a/test/LLVMC/dg.exp b/test/LLVMC/dg.exp
new file mode 100644
index 0000000..f7d275a
--- /dev/null
+++ b/test/LLVMC/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{td}]]
diff --git a/test/LLVMC/test_data/false.c b/test/LLVMC/test_data/false.c
new file mode 100644
index 0000000..3e4e8a7
--- /dev/null
+++ b/test/LLVMC/test_data/false.c
@@ -0,0 +1,10 @@
+#include <iostream>
+
+extern "C" void test();
+extern std::string test2();
+
+int test_main() {
+ std::cout << "h";
+ test();
+ std::cout << test2() << '\n';
+}
OpenPOWER on IntegriCloud