diff options
Diffstat (limited to 'clang/test/Frontend')
31 files changed, 225 insertions, 0 deletions
diff --git a/clang/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h b/clang/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h new file mode 100644 index 0000000..49048ca --- /dev/null +++ b/clang/test/Frontend/Inputs/TestFramework.framework/Headers/TestFramework.h @@ -0,0 +1 @@ +static int f0(void) {} diff --git a/clang/test/Frontend/Inputs/lit.local.cfg b/clang/test/Frontend/Inputs/lit.local.cfg new file mode 100644 index 0000000..e6f55ee --- /dev/null +++ b/clang/test/Frontend/Inputs/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = [] diff --git a/clang/test/Frontend/Inputs/test.h b/clang/test/Frontend/Inputs/test.h new file mode 100644 index 0000000..98cc459 --- /dev/null +++ b/clang/test/Frontend/Inputs/test.h @@ -0,0 +1 @@ +#include "test2.h" diff --git a/clang/test/Frontend/Inputs/test2.h b/clang/test/Frontend/Inputs/test2.h new file mode 100644 index 0000000..6d1a0d4 --- /dev/null +++ b/clang/test/Frontend/Inputs/test2.h @@ -0,0 +1 @@ +int x; diff --git a/clang/test/Frontend/Inputs/test3.h b/clang/test/Frontend/Inputs/test3.h new file mode 100644 index 0000000..92ff4b8 --- /dev/null +++ b/clang/test/Frontend/Inputs/test3.h @@ -0,0 +1 @@ +int y; diff --git a/clang/test/Frontend/Weverything.c b/clang/test/Frontend/Weverything.c new file mode 100644 index 0000000..32f3147 --- /dev/null +++ b/clang/test/Frontend/Weverything.c @@ -0,0 +1,9 @@ +// Regression check that -pedantic-errors doesn't cause other diagnostics to +// become errors. +// +// RUN: %clang_cc1 -verify -Weverything -pedantic-errors %s + +int f0(int, unsigned); +int f0(int x, unsigned y) { + return x < y; // expected-warning {{comparison of integers}} +} diff --git a/clang/test/Frontend/Wno-everything.c b/clang/test/Frontend/Wno-everything.c new file mode 100644 index 0000000..ca70ca4 --- /dev/null +++ b/clang/test/Frontend/Wno-everything.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -verify -Wno-everything -Wsign-compare %s + +int f0(int, unsigned); +int f0(int x, unsigned y) { + if (x=3); + return x < y; // expected-warning {{comparison of integers}} +} diff --git a/clang/test/Frontend/ast-codegen.c b/clang/test/Frontend/ast-codegen.c new file mode 100644 index 0000000..b5b2157 --- /dev/null +++ b/clang/test/Frontend/ast-codegen.c @@ -0,0 +1,12 @@ +// RUN: %clang -emit-ast -o %t.ast %s +// RUN: %clang -emit-llvm -S -o - %t.ast | FileCheck %s + +// CHECK: module asm "foo" +__asm__("foo"); + +// CHECK: @g0 = common global i32 0, align 4 +int g0; + +// CHECK: define i32 @f0() +int f0() { +} diff --git a/clang/test/Frontend/ast-main.c b/clang/test/Frontend/ast-main.c new file mode 100644 index 0000000..43237a1 --- /dev/null +++ b/clang/test/Frontend/ast-main.c @@ -0,0 +1,8 @@ +// RUN: %clang -emit-llvm -S -o %t1.ll -x c - < %s +// RUN: %clang -emit-ast -o %t.ast %s +// RUN: %clang -emit-llvm -S -o %t2.ll -x ast - < %t.ast +// RUN: diff %t1.ll %t2.ll + +int main() { + return 0; +} diff --git a/clang/test/Frontend/cpp-output.c b/clang/test/Frontend/cpp-output.c new file mode 100644 index 0000000..e44095b --- /dev/null +++ b/clang/test/Frontend/cpp-output.c @@ -0,0 +1,14 @@ +// RUN: %clang -E -o %t -C %s +// RUN: grep '^int x; // comment' %t +// RUN: grep '^x x' %t +// RUN: %clang -E -o %t -CC %s +// RUN: grep '^int x; // comment' %t +// RUN: grep '^x /\* comment \*/ x /\* comment \*/' %t + +int x; // comment + +#define A(foo, bar) foo bar +#define B x // comment + +A(B, B) + diff --git a/clang/test/Frontend/darwin-version.c b/clang/test/Frontend/darwin-version.c new file mode 100644 index 0000000..f9ce54b --- /dev/null +++ b/clang/test/Frontend/darwin-version.c @@ -0,0 +1,25 @@ +// RUN: %clang -target armv6-apple-darwin9 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0 +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1 +// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=3.0 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '30000' | count 1 +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0 +// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=2.0 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20000' | count 1 +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | count 0 +// RUN: %clang -target armv6-apple-darwin9 -miphoneos-version-min=2.2 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | grep '20200' | count 1 +// RUN: %clang -target i686-apple-darwin8 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0 +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1 +// RUN: %clang -target i686-apple-darwin9 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1 +// RUN: %clang -target i686-apple-darwin10 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1 +// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__' %t | count 0 +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1040' | count 1 +// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.5 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1050' | count 1 +// RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -dM -E -o %t %s +// RUN: grep '__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__' %t | grep '1060' | count 1 diff --git a/clang/test/Frontend/dependency-gen.c b/clang/test/Frontend/dependency-gen.c new file mode 100644 index 0000000..5883ec5 --- /dev/null +++ b/clang/test/Frontend/dependency-gen.c @@ -0,0 +1,27 @@ +// REQUIRES: shell +// Basic test +// RUN: rm -rf %t.dir +// RUN: mkdir -p %t.dir/a/b +// RUN: echo > %t.dir/a/b/x.h +// RUN: cd %t.dir +// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b | FileCheck -check-prefix=CHECK-ONE %s +// CHECK-ONE: {{ }}a/b{{[/\\]}}x.h + +// PR8974 (-include flag) +// RUN: %clang -MD -MF - %s -fsyntax-only -include a/b/x.h -DINCLUDE_FLAG_TEST | FileCheck -check-prefix=CHECK-TWO %s +// CHECK-TWO: {{ }}a/b/x.h + +// rdar://problem/9734352 (paths involving ".") +// RUN: %clang -MD -MF - %s -fsyntax-only -I ./a/b | FileCheck -check-prefix=CHECK-THREE %s +// CHECK-THREE: {{ }}a/b{{[/\\]}}x.h +// RUN: %clang -MD -MF - %s -fsyntax-only -I .//./a/b/ | FileCheck -check-prefix=CHECK-FOUR %s +// CHECK-FOUR: {{ }}a/b{{[/\\]}}x.h +// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b/. | FileCheck -check-prefix=CHECK-FIVE %s +// CHECK-FIVE: {{ }}a/b/.{{[/\\]}}x.h +// RUN: cd a/b +// RUN: %clang -MD -MF - %s -fsyntax-only -I ./ | FileCheck -check-prefix=CHECK-SIX %s +// CHECK-SIX: {{ }}x.h + +#ifndef INCLUDE_FLAG_TEST +#include <x.h> +#endif diff --git a/clang/test/Frontend/dependency-generation-crash.c b/clang/test/Frontend/dependency-generation-crash.c new file mode 100644 index 0000000..181bb71 --- /dev/null +++ b/clang/test/Frontend/dependency-generation-crash.c @@ -0,0 +1,4 @@ +// RUN: touch %t +// RUN: chmod 0 %t +// %clang -E -dependency-file bla -MT %t -MP -o %t -x c /dev/null +// rdar://9286457 diff --git a/clang/test/Frontend/diagnostics-option-names.c b/clang/test/Frontend/diagnostics-option-names.c new file mode 100644 index 0000000..ed0d2ed --- /dev/null +++ b/clang/test/Frontend/diagnostics-option-names.c @@ -0,0 +1,8 @@ +// RUN: not %clang_cc1 -fdiagnostics-show-option -Werror -Weverything %s 2> %t +// RUN: FileCheck < %t %s + +int f0(int, unsigned); +int f0(int x, unsigned y) { +// CHECK: comparison of integers of different signs{{.*}} [-Werror,-Wsign-compare] + return x < y; // expected-error {{ : 'int' and 'unsigned int' }} +} diff --git a/clang/test/Frontend/iframework.c b/clang/test/Frontend/iframework.c new file mode 100644 index 0000000..0c241fd --- /dev/null +++ b/clang/test/Frontend/iframework.c @@ -0,0 +1,3 @@ +// RUN: %clang -fsyntax-only -iframework%S/Inputs %s -Xclang -verify + +#include <TestFramework/TestFramework.h> diff --git a/clang/test/Frontend/ir-support-codegen.ll b/clang/test/Frontend/ir-support-codegen.ll new file mode 100644 index 0000000..e5e5b62 --- /dev/null +++ b/clang/test/Frontend/ir-support-codegen.ll @@ -0,0 +1,9 @@ +; REQUIRES: x86-64-registered-target +; RUN: %clang_cc1 -S -o - %s | FileCheck %s + +target triple = "x86_64-apple-darwin10" + +; CHECK: .globl _f0 +define i32 @f0() nounwind ssp { + ret i32 0 +} diff --git a/clang/test/Frontend/ir-support-errors.ll b/clang/test/Frontend/ir-support-errors.ll new file mode 100644 index 0000000..cb5913c --- /dev/null +++ b/clang/test/Frontend/ir-support-errors.ll @@ -0,0 +1,8 @@ +; RUN: %clang_cc1 -S -o - %s 2>&1 | FileCheck %s + +target triple = "x86_64-apple-darwin10" + +define i32 @f0() nounwind ssp { +; CHECK: {{.*}}ir-support-errors.ll:7:16: error: use of undefined value '%x' + ret i32 %x +} diff --git a/clang/test/Frontend/lit.local.cfg b/clang/test/Frontend/lit.local.cfg new file mode 100644 index 0000000..4c13598 --- /dev/null +++ b/clang/test/Frontend/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.bc'] diff --git a/clang/test/Frontend/macros.c b/clang/test/Frontend/macros.c new file mode 100644 index 0000000..3170797 --- /dev/null +++ b/clang/test/Frontend/macros.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -DA= -DB=1 -verify -fsyntax-only %s + +int a[(B A) == 1 ? 1 : -1]; + diff --git a/clang/test/Frontend/output-failures.c b/clang/test/Frontend/output-failures.c new file mode 100644 index 0000000..e2af7c7 --- /dev/null +++ b/clang/test/Frontend/output-failures.c @@ -0,0 +1,4 @@ +// RUN: not %clang_cc1 -emit-llvm -o %S/doesnotexist/somename %s 2> %t +// RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s + +// OUTPUTFAIL: Error opening output file '{{.*}}doesnotexist{{.*}}' diff --git a/clang/test/Frontend/preprocessed-output-macro-first-token.c b/clang/test/Frontend/preprocessed-output-macro-first-token.c new file mode 100644 index 0000000..06b78c2 --- /dev/null +++ b/clang/test/Frontend/preprocessed-output-macro-first-token.c @@ -0,0 +1,5 @@ +// This is the first thing other than comments and preprocessor stuff in the +// file. +// +// RUN: %clang_cc1 -fms-extensions -E %s +#pragma comment(lib, "somelib") diff --git a/clang/test/Frontend/print-header-includes.c b/clang/test/Frontend/print-header-includes.c new file mode 100644 index 0000000..7773d20 --- /dev/null +++ b/clang/test/Frontend/print-header-includes.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -include Inputs/test3.h -E -H -o %t.out %s 2> %t.err +// RUN: FileCheck < %t.err %s + +// CHECK-NOT: test3.h +// CHECK: . {{.*test.h}} +// CHECK: .. {{.*test2.h}} + +#include "Inputs/test.h" diff --git a/clang/test/Frontend/rewrite-macros.c b/clang/test/Frontend/rewrite-macros.c new file mode 100644 index 0000000..bc74796 --- /dev/null +++ b/clang/test/Frontend/rewrite-macros.c @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -verify -rewrite-macros -o %t %s + +#define A(a,b) a ## b + +// RUN: grep '12 */\*A\*/ /\*(1,2)\*/' %t +A(1,2) + +// RUN: grep '/\*_Pragma("mark")\*/' %t +_Pragma("mark") + +// RUN: grep "//#warning eek" %t +/* expected-warning {{eek}} */ #warning eek + +// RUN: grep "//#pragma mark mark" %t +#pragma mark mark + + diff --git a/clang/test/Frontend/stdin.c b/clang/test/Frontend/stdin.c new file mode 100644 index 0000000..2d0a237 --- /dev/null +++ b/clang/test/Frontend/stdin.c @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -E - < /dev/null > %t +// RUN: grep '<built-in>' %t + diff --git a/clang/test/Frontend/undef.c b/clang/test/Frontend/undef.c new file mode 100644 index 0000000..f539cdc --- /dev/null +++ b/clang/test/Frontend/undef.c @@ -0,0 +1,4 @@ +// RUN: %clang -undef -x assembler-with-cpp -E %s +#ifndef __ASSEMBLER__ +#error "Must be preprocessed as assembler." +#endif diff --git a/clang/test/Frontend/unknown-pragmas.c b/clang/test/Frontend/unknown-pragmas.c new file mode 100644 index 0000000..53a5a45 --- /dev/null +++ b/clang/test/Frontend/unknown-pragmas.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -Eonly -Wall -verify %s +// RUN: %clang_cc1 -E -dM -Wall -verify %s + +#pragma adgohweopihweotnwet diff --git a/clang/test/Frontend/warning-mapping-1.c b/clang/test/Frontend/warning-mapping-1.c new file mode 100644 index 0000000..883dafb --- /dev/null +++ b/clang/test/Frontend/warning-mapping-1.c @@ -0,0 +1,6 @@ +// Check that -w has higher priority than -Werror. +// RUN: %clang_cc1 -verify -Wsign-compare -Werror -w %s + +int f0(int x, unsigned y) { + return x < y; +} diff --git a/clang/test/Frontend/warning-mapping-2.c b/clang/test/Frontend/warning-mapping-2.c new file mode 100644 index 0000000..39ba499 --- /dev/null +++ b/clang/test/Frontend/warning-mapping-2.c @@ -0,0 +1,5 @@ +// Check that -w has lower priority than -pedantic-errors. +// RUN: %clang_cc1 -verify -pedantic-errors -w %s + +void f0() { f1(); } // expected-error {{implicit declaration of function}} + diff --git a/clang/test/Frontend/warning-mapping-3.c b/clang/test/Frontend/warning-mapping-3.c new file mode 100644 index 0000000..8c70190 --- /dev/null +++ b/clang/test/Frontend/warning-mapping-3.c @@ -0,0 +1,10 @@ +// Check that -Werror and -Wfatal-error interact properly. +// +// Verify mode doesn't work with fatal errors, just use FileCheck here. +// +// RUN: not %clang_cc1 -Wunused-function -Werror -Wfatal-errors %s 2> %t.err +// RUN: FileCheck < %t.err %s +// CHECK: fatal error: unused function +// CHECK: 1 error generated + +static void f0(void) {} // expected-fatal {{unused function}} diff --git a/clang/test/Frontend/warning-mapping-4.c b/clang/test/Frontend/warning-mapping-4.c new file mode 100644 index 0000000..d8d2769 --- /dev/null +++ b/clang/test/Frontend/warning-mapping-4.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -verify -Wno-error=sign-compare %s +// RUN: %clang_cc1 -verify -Wsign-compare -w -Wno-error=sign-compare %s + +int f0(int x, unsigned y) { + return x < y; +} diff --git a/clang/test/Frontend/warning-mapping-5.c b/clang/test/Frontend/warning-mapping-5.c new file mode 100644 index 0000000..27d53dc --- /dev/null +++ b/clang/test/Frontend/warning-mapping-5.c @@ -0,0 +1,9 @@ +// Check that #pragma diagnostic warning overrides -Werror. This matches GCC's +// original documentation, but not its earlier implementations. +// +// RUN: %clang_cc1 -verify -Werror %s + +#pragma clang diagnostic warning "-Wsign-compare" +int f0(int x, unsigned y) { + return x < y; // expected-warning {{comparison of integers}} +} |