| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| // RUN: %clang_cc1 %s -triple powerpc-ibm-aix-xcoff -S -mtocdata=f,g,h,i,j,k,l,m,n,o,p -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=COMMON,CHECK32 --match-full-lines | ||
| // RUN: %clang_cc1 %s -triple powerpc-ibm-aix-xcoff -S -mtocdata -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=COMMON,CHECK32 --match-full-lines | ||
|
|
||
| // RUN: %clang_cc1 %s -triple powerpc64-ibm-aix-xcoff -S -mtocdata=f,g,h,i,j,k,l,m,n,o,p -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=COMMON,CHECK64 --match-full-lines | ||
| // RUN: %clang_cc1 %s -triple powerpc64-ibm-aix-xcoff -S -mtocdata -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=COMMON,CHECK64 --match-full-lines | ||
|
|
||
| extern int f; | ||
| long long g = 5; | ||
| const char *h = "h"; | ||
| int *i; | ||
| int __attribute__((aligned(128))) j = 0; | ||
| float k = 100.00; | ||
| double l = 2.5; | ||
| int m __attribute__((section("foo"))) = 10; | ||
| __thread int n; | ||
|
|
||
| extern int p[]; | ||
|
|
||
| struct SomeStruct; | ||
| extern struct SomeStruct o; | ||
|
|
||
| static int func_a() { | ||
| return g+(int)h[0]+*i+j+k+l+m+n+p[0]; | ||
| } | ||
|
|
||
| int func_b() { | ||
| f = 1; | ||
| return func_a(); | ||
| } | ||
|
|
||
| struct SomeStruct* getAddress(void) { | ||
| return &o; | ||
| } | ||
|
|
||
| // CHECK32: @g = global i64 5, align 8 | ||
| // CHECK64: @g = global i64 5, align 8 #0 | ||
| // COMMON: {{.*}} = private unnamed_addr constant [2 x i8] c"h\00", align 1 | ||
| // COMMON: @h = global {{...*}} #0 | ||
| // COMMON: @j = global i32 0, align 128 | ||
| // COMMON: @k = global float 1.000000e+02, align 4 #0 | ||
| // CHECK32: @l = global double 2.500000e+00, align 8 | ||
| // CHECK64: @l = global double 2.500000e+00, align 8 #0 | ||
| // COMMON: @m = global i32 10, section "foo", align 4 | ||
| // COMMON: @f = external global i32, align 4 #0 | ||
| // COMMON: @o = external global %struct.SomeStruct, align 1 | ||
| // CHECK32: @i = global ptr null, align 4 #0 | ||
| // CHECK64: @i = global ptr null, align 8 #0 | ||
| // COMMON: @n = thread_local global i32 0, align 4 | ||
| // COMMON: @p = external global [0 x i32], align 4 | ||
| // COMMON: attributes #0 = { "toc-data" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // RUN: %clang_cc1 %s -triple powerpc-ibm-aix-xcoff -S -mtocdata -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=COMMON,ALLTOC | ||
| // RUN: %clang_cc1 %s -triple powerpc-ibm-aix-xcoff -S -mtocdata=n,_ZN11MyNamespace10myVariableE,_ZL1s,_ZZ4testvE7counter -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=COMMON,TOCLIST | ||
| // RUN: %clang_cc1 %s -triple powerpc64-ibm-aix-xcoff -S -mtocdata -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=COMMON,ALLTOC | ||
| // RUN: %clang_cc1 %s -triple powerpc64-ibm-aix-xcoff -S -mtocdata=n,_ZN11MyNamespace10myVariableE,_ZL1s,_ZZ4testvE7counter -emit-llvm -o - 2>&1 | FileCheck %s -check-prefixes=COMMON,TOCLIST | ||
|
|
||
| extern int n; | ||
| static int s = 100; | ||
|
|
||
| inline int test() { | ||
| static int counter = 0; | ||
| counter++; | ||
| return counter; | ||
| } | ||
|
|
||
| int a () { | ||
| n = test(); | ||
| return 0; | ||
| } | ||
|
|
||
| namespace MyNamespace { | ||
| int myVariable = 10; | ||
| } | ||
|
|
||
| int b(int x) { | ||
| using namespace MyNamespace; | ||
| return x + myVariable; | ||
| } | ||
|
|
||
| int c(int x) { | ||
| s += x; | ||
| return s; | ||
| } | ||
|
|
||
| // COMMON: @n = external global i32, align 4 #0 | ||
| // COMMON: @_ZN11MyNamespace10myVariableE = global i32 10, align 4 #0 | ||
| // COMMON-NOT: @_ZL1s = internal global i32 100, align 4 #0 | ||
| // ALLTOC: @_ZZ4testvE7counter = linkonce_odr global i32 0, align 4 #0 | ||
| // TOCLIST-NOT: @_ZZ4testvE7counter = linkonce_odr global i32 0, align 4 #0 | ||
| // COMMON: attributes #0 = { "toc-data" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // RUN: %clang_cc1 %s -triple=powerpc-ibm-aix-xcoff -S -mtocdata=h,g,f,e,d,c,b,a,globalOneWithAlias,globalTwoWithAlias,ll,t3 -verify -emit-llvm -o - | FileCheck %s -check-prefix=CHECK --match-full-lines | ||
| // RUN: %clang_cc1 %s -triple=powerpc-ibm-aix-xcoff -S -mtocdata -verify=none -emit-llvm -o - | FileCheck %s -check-prefix=CHECK --match-full-lines | ||
|
|
||
| // none-no-diagnostics | ||
|
|
||
| struct large_struct { | ||
| int x; | ||
| short y; | ||
| short z; | ||
| char c; | ||
| }; | ||
|
|
||
| struct large_struct a; // expected-warning {{-mtocdata option is ignored for a because variable is larger than a pointer}} | ||
| long long b = 5; // expected-warning {{-mtocdata option is ignored for b because variable is larger than a pointer}} | ||
| int __attribute__((aligned(128))) c = 0; // expected-warning {{-mtocdata option is ignored for c because variable is aligned wider than a pointer}} | ||
| double d = 2.5; // expected-warning {{-mtocdata option is ignored for d because variable is larger than a pointer}} | ||
| int e __attribute__((section("foo"))) = 10; // expected-warning {{-mtocdata option is ignored for e because variable has a section attribute}} | ||
| __thread int f; // expected-warning {{-mtocdata option is ignored for f because of thread local storage}} | ||
|
|
||
| struct SomeStruct; | ||
| extern struct SomeStruct g; // expected-warning {{-mtocdata option is ignored for g because of incomplete type}} | ||
|
|
||
| extern int h[]; // expected-warning {{-mtocdata option is ignored for h because of incomplete type}} | ||
|
|
||
| struct ty3 { | ||
| int A; | ||
| char C[]; | ||
| }; | ||
| struct ty3 t3 = { 4, "fo" }; // expected-warning {{-mtocdata option is ignored for t3 because it contains a flexible array member}} | ||
|
|
||
| int globalOneWithAlias = 10; | ||
| __attribute__((__alias__("globalOneWithAlias"))) extern int aliasOne; // expected-warning {{-mtocdata option is ignored for globalOneWithAlias because the variable has an alias}} | ||
| __attribute__((__alias__("globalTwoWithAlias"))) extern int aliasTwo; // expected-warning {{-mtocdata option is ignored for globalTwoWithAlias because the variable has an alias}} | ||
| int globalTwoWithAlias = 20; | ||
|
|
||
|
|
||
| int func() { | ||
| return a.x+b+c+d+e+f+h[0]; | ||
| } | ||
|
|
||
| struct SomeStruct* getAddress(void) { | ||
| return &g; | ||
| } | ||
|
|
||
| int test() { | ||
| return globalOneWithAlias + globalTwoWithAlias + aliasOne + aliasTwo; | ||
| } | ||
|
|
||
| long long test2() { | ||
| static long long ll = 5; | ||
| ll++; | ||
| return ll; | ||
| } | ||
|
|
||
| // CHECK: @b = global i64 5, align 8 | ||
| // CHECK: @c = global i32 0, align 128 | ||
| // CHECK: @d = global double 2.500000e+00, align 8 | ||
| // CHECK: @e = global i32 10, section "foo", align 4 | ||
| // CHECK: @globalOneWithAlias = global i32 10, align 4 | ||
| // CHECK: @globalTwoWithAlias = global i32 20, align 4 | ||
| // CHECK: @a = global %struct.large_struct zeroinitializer, align 4 | ||
| // CHECK: @f = thread_local global i32 0, align 4 | ||
| // CHECK: @h = external global [0 x i32], align 4 | ||
| // CHECK: @g = external global %struct.SomeStruct, align 1 | ||
| // CHECK: @test2.ll = internal global i64 5, align 8 | ||
| // CHECK: @aliasOne = alias i32, ptr @globalOneWithAlias | ||
| // CHECK: @aliasTwo = alias i32, ptr @globalTwoWithAlias | ||
| // CHECK-NOT: attributes #0 = { "toc-data" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // RUN: %clang_cc1 %s -triple powerpc-ibm-aix-xcoff -S -mtocdata=a4,a5,a8,a9,b,c,d,e,v -emit-llvm -o - 2>&1 \ | ||
| // RUN: | FileCheck %s -check-prefixes=CHECK32 --match-full-lines | ||
| // RUN: %clang_cc1 %s -triple powerpc-ibm-aix-xcoff -S -mtocdata -emit-llvm -o - 2>&1 \ | ||
| // RUN: | FileCheck %s -check-prefixes=CHECK32 --match-full-lines | ||
|
|
||
| // RUN: %clang_cc1 %s -triple powerpc64-ibm-aix-xcoff -S -mtocdata=a4,a5,a8,a9,b,c,d,e,v -emit-llvm -o - 2>&1 \ | ||
| // RUN: | FileCheck %s -check-prefixes=CHECK64 --match-full-lines | ||
| // RUN: %clang_cc1 %s -triple powerpc64-ibm-aix-xcoff -S -mtocdata -emit-llvm -o - 2>&1 \ | ||
| // RUN: | FileCheck %s -check-prefixes=CHECK64 --match-full-lines | ||
|
|
||
| struct size4_struct { | ||
| int x; | ||
| }; | ||
|
|
||
| struct size5_struct { | ||
| int x; | ||
| char c; | ||
| }; | ||
|
|
||
| struct size8_struct { | ||
| int x; | ||
| short y; | ||
| short z; | ||
| }; | ||
|
|
||
| struct size9_struct { | ||
| int x; | ||
| short y; | ||
| short z; | ||
| char c; | ||
| }; | ||
|
|
||
| struct size4_struct a4; | ||
| struct size5_struct a5; | ||
| struct size8_struct a8; | ||
| struct size9_struct a9; | ||
|
|
||
| short b[2]; | ||
| short c[3]; | ||
| short d[4]; | ||
| short e[5]; | ||
|
|
||
| int func_a() { | ||
| return a4.x+a5.x+a8.x+a9.x+b[0]+c[0]+d[0]+e[0]; | ||
| } | ||
|
|
||
| // CHECK32: @a4 = global %struct.size4_struct zeroinitializer, align 4 #0 | ||
| // CHECK32: @a5 = global %struct.size5_struct zeroinitializer, align 4 | ||
| // CHECK32: @a8 = global %struct.size8_struct zeroinitializer, align 4 | ||
| // CHECK32: @a9 = global %struct.size9_struct zeroinitializer, align 4 | ||
| // CHECK32: @b = global [2 x i16] zeroinitializer, align 2 #0 | ||
| // CHECK32: @c = global [3 x i16] zeroinitializer, align 2 | ||
| // CHECK32: @d = global [4 x i16] zeroinitializer, align 2 | ||
| // CHECK32: @e = global [5 x i16] zeroinitializer, align 2 | ||
| // CHECK32: attributes #0 = { "toc-data" } | ||
|
|
||
| // CHECK64: @a4 = global %struct.size4_struct zeroinitializer, align 4 #0 | ||
| // CHECK64: @a5 = global %struct.size5_struct zeroinitializer, align 4 #0 | ||
| // CHECK64: @a8 = global %struct.size8_struct zeroinitializer, align 4 #0 | ||
| // CHECK64: @a9 = global %struct.size9_struct zeroinitializer, align 4 | ||
| // CHECK64: @b = global [2 x i16] zeroinitializer, align 2 #0 | ||
| // CHECK64: @c = global [3 x i16] zeroinitializer, align 2 #0 | ||
| // CHECK64: @d = global [4 x i16] zeroinitializer, align 2 #0 | ||
| // CHECK64: @e = global [5 x i16] zeroinitializer, align 2 | ||
| // CHECK64: attributes #0 = { "toc-data" } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| // RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86 | ||
| // RUN: %clang_cc1 %s -O0 -triple x86_64-unknown-unknown -fsyntax-only -ast-dump | FileCheck %s --check-prefix=AST | ||
|
|
||
| // Check that for 'F _Complex + int' (F = real floating-point type), we emit an | ||
| // implicit cast from 'int' to 'F', but NOT to 'F _Complex' (i.e. that we do | ||
| // 'F _Complex + F', NOT 'F _Complex + F _Complex'), and likewise for -/*. | ||
|
|
||
| // AST-NOT: FloatingRealToComplex | ||
|
|
||
| float _Complex add_float_ci(float _Complex a, int b) { | ||
| // X86-LABEL: @add_float_ci | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float | ||
| // X86: fadd float {{.*}}, [[I]] | ||
| // X86-NOT: fadd | ||
| return a + b; | ||
| } | ||
|
|
||
| float _Complex add_float_ic(int a, float _Complex b) { | ||
| // X86-LABEL: @add_float_ic | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float | ||
| // X86: fadd float [[I]] | ||
| // X86-NOT: fadd | ||
| return a + b; | ||
| } | ||
|
|
||
| float _Complex sub_float_ci(float _Complex a, int b) { | ||
| // X86-LABEL: @sub_float_ci | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float | ||
| // X86: fsub float {{.*}}, [[I]] | ||
| // X86-NOT: fsub | ||
| return a - b; | ||
| } | ||
|
|
||
| float _Complex sub_float_ic(int a, float _Complex b) { | ||
| // X86-LABEL: @sub_float_ic | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float | ||
| // X86: fsub float [[I]] | ||
| // X86: fneg | ||
| // X86-NOT: fsub | ||
| return a - b; | ||
| } | ||
|
|
||
| float _Complex mul_float_ci(float _Complex a, int b) { | ||
| // X86-LABEL: @mul_float_ci | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float | ||
| // X86: fmul float {{.*}}, [[I]] | ||
| // X86: fmul float {{.*}}, [[I]] | ||
| // X86-NOT: fmul | ||
| return a * b; | ||
| } | ||
|
|
||
| float _Complex mul_float_ic(int a, float _Complex b) { | ||
| // X86-LABEL: @mul_float_ic | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float | ||
| // X86: fmul float [[I]] | ||
| // X86: fmul float [[I]] | ||
| // X86-NOT: fmul | ||
| return a * b; | ||
| } | ||
|
|
||
| float _Complex div_float_ci(float _Complex a, int b) { | ||
| // X86-LABEL: @div_float_ci | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float | ||
| // X86: fdiv float {{.*}}, [[I]] | ||
| // X86: fdiv float {{.*}}, [[I]] | ||
| // X86-NOT: @__divsc3 | ||
| return a / b; | ||
| } | ||
|
|
||
| // There is no good way of doing this w/o converting the 'int' to a complex | ||
| // number, so we expect complex division here. | ||
| float _Complex div_float_ic(int a, float _Complex b) { | ||
| // X86-LABEL: @div_float_ic | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to float | ||
| // X86: call {{.*}} @__divsc3(float {{.*}} [[I]], float noundef 0.{{0+}}e+00, float {{.*}}, float {{.*}}) | ||
| return a / b; | ||
| } | ||
|
|
||
| double _Complex add_double_ci(double _Complex a, int b) { | ||
| // X86-LABEL: @add_double_ci | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double | ||
| // X86: fadd double {{.*}}, [[I]] | ||
| // X86-NOT: fadd | ||
| return a + b; | ||
| } | ||
|
|
||
| double _Complex add_double_ic(int a, double _Complex b) { | ||
| // X86-LABEL: @add_double_ic | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double | ||
| // X86: fadd double [[I]] | ||
| // X86-NOT: fadd | ||
| return a + b; | ||
| } | ||
|
|
||
| double _Complex sub_double_ci(double _Complex a, int b) { | ||
| // X86-LABEL: @sub_double_ci | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double | ||
| // X86: fsub double {{.*}}, [[I]] | ||
| // X86-NOT: fsub | ||
| return a - b; | ||
| } | ||
|
|
||
| double _Complex sub_double_ic(int a, double _Complex b) { | ||
| // X86-LABEL: @sub_double_ic | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double | ||
| // X86: fsub double [[I]] | ||
| // X86: fneg | ||
| // X86-NOT: fsub | ||
| return a - b; | ||
| } | ||
|
|
||
| double _Complex mul_double_ci(double _Complex a, int b) { | ||
| // X86-LABEL: @mul_double_ci | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double | ||
| // X86: fmul double {{.*}}, [[I]] | ||
| // X86: fmul double {{.*}}, [[I]] | ||
| // X86-NOT: fmul | ||
| return a * b; | ||
| } | ||
|
|
||
| double _Complex mul_double_ic(int a, double _Complex b) { | ||
| // X86-LABEL: @mul_double_ic | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double | ||
| // X86: fmul double [[I]] | ||
| // X86: fmul double [[I]] | ||
| // X86-NOT: fmul | ||
| return a * b; | ||
| } | ||
|
|
||
| double _Complex div_double_ci(double _Complex a, int b) { | ||
| // X86-LABEL: @div_double_ci | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double | ||
| // X86: fdiv double {{.*}}, [[I]] | ||
| // X86: fdiv double {{.*}}, [[I]] | ||
| // X86-NOT: @__divdc3 | ||
| return a / b; | ||
| } | ||
|
|
||
| // There is no good way of doing this w/o converting the 'int' to a complex | ||
| // number, so we expect complex division here. | ||
| double _Complex div_double_ic(int a, double _Complex b) { | ||
| // X86-LABEL: @div_double_ic | ||
| // X86: [[I:%.*]] = sitofp i32 {{%.*}} to double | ||
| // X86: call {{.*}} @__divdc3(double {{.*}} [[I]], double noundef 0.{{0+}}e+00, double {{.*}}, double {{.*}}) | ||
| return a / b; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // RUN: %clang %s --target=powerpc-unknown-aix -mno-tocdata -mtocdata -mno-tocdata -### 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG1 | ||
| // RUN: %clang %s --target=powerpc-unknown-aix -mno-tocdata -mtocdata -mno-tocdata -mtocdata -### 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG2 | ||
| // RUN: %clang %s --target=powerpc-unknown-aix -mtocdata=g1,g2 -mno-tocdata=g2 -mtocdata=g3,g4 -mno-tocdata=g5,g1 -### 2>&1 | FileCheck %s -check-prefix=CHECK-EQCONF | ||
| // RUN: %clang %s --target=powerpc-unknown-aix -mtocdata=g1 -mtocdata -mno-tocdata -mtocdata=g2,g3 -mno-tocdata=g4,g5,g3 -### 2>&1 | FileCheck %s -check-prefix=CHECK-CONF1 | ||
| // RUN: %clang %s --target=powerpc-unknown-aix -mno-tocdata=g1 -mno-tocdata -mtocdata -### 2>&1 | FileCheck %s -check-prefix=CHECK-CONF2 | ||
|
|
||
| int g1, g4, g5; | ||
| extern int g2; | ||
| int g3 = 0; | ||
| void func() { | ||
| g2 = 0; | ||
| } | ||
|
|
||
| // CHECK-FLAG1-NOT: warning: | ||
| // CHECK-FLAG1: "-cc1"{{.*}}" "-mno-tocdata" | ||
|
|
||
| // CHECK-FLAG2-NOT: warning: | ||
| // CHECK-FLAG2: "-cc1"{{.*}}" "-mtocdata" | ||
|
|
||
| // CHECK-EQCONF-NOT: warning: | ||
| // CHECK-EQCONF: "-cc1"{{.*}}" "-mno-tocdata" | ||
| // CHECK-EQCONF: "-mtocdata=g3,g4" | ||
|
|
||
| // CHECK-CONF1-NOT: warning: | ||
| // CHECK-CONF1: "-cc1"{{.*}}" "-mno-tocdata" | ||
| // CHECK-CONF1: "-mtocdata=g2,g1" | ||
|
|
||
| // CHECK-CONF2-NOT: warning: | ||
| // CHECK-CONF2: "-cc1"{{.*}}" "-mtocdata" | ||
| // CHECK-CONF2: "-mno-tocdata=g1" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mcmodel=medium -mtocdata %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHECK-NOTOC %s | ||
| // RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mcmodel=large -mtocdata %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHECK-NOTOC %s | ||
| // RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mtocdata %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHECK-TOC %s | ||
| // RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mcmodel=medium -mtocdata %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHECK-NOTOC %s | ||
| // RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mcmodel=large -mtocdata %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHECK-NOTOC %s | ||
| // RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mtocdata %s 2>&1 \ | ||
| // RUN: | FileCheck -check-prefix=CHECK-TOC %s | ||
| // CHECK-NOTOC: warning: ignoring '-mtocdata' as it is only supported for -mcmodel=small | ||
| // CHECK-NOTOC-NOT: "-cc1"{{.*}}" "-mtocdata" | ||
| // CHECK-TOC: "-cc1"{{.*}}" "-mtocdata" | ||
| // CHECK-TOC-NOT: warning: ignoring '-mtocdata' as it is only supported for -mcmodel=small |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,33 @@ | ||
| // RUN: rm -rf %t | ||
| // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify=builtin-headers-in-system-modules -fno-modules-error-recovery | ||
| // RUN: rm -rf %t | ||
| // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/StdDef %s -verify=no-builtin-headers-in-system-modules -fno-modules-error-recovery | ||
|
|
||
| #include "ptrdiff_t.h" | ||
|
|
||
| ptrdiff_t pdt; | ||
|
|
||
| // size_t is declared in both size_t.h and __stddef_size_t.h. If | ||
| // -fbuiltin-headers-in-system-modules is set, then __stddef_size_t.h is a | ||
| // non-modular header that will be transitively pulled in the StdDef test module | ||
| // by include_again.h. Otherwise it will be in the _Builtin_stddef module. In | ||
| // any case it's not defined which module will win as the expected provider of | ||
| // size_t. For the purposes of this test it doesn't matter which of the two | ||
| // providing headers get reported. | ||
| size_t st; // builtin-headers-in-system-modules-error-re {{missing '#include "{{size_t|include_again}}.h"'; 'size_t' must be declared before it is used}} \ | ||
| no-builtin-headers-in-system-modules-error-re {{missing '#include "{{size_t|__stddef_size_t}}.h"'; 'size_t' must be declared before it is used}} | ||
| // builtin-headers-in-system-modules-note@size_t.h:* 0+ {{here}} \ | ||
| no-builtin-headers-in-system-modules-note@size_t.h:* 0+ {{here}} | ||
| // builtin-headers-in-system-modules-note@__stddef_size_t.h:* 0+ {{here}} \ | ||
| no-builtin-headers-in-system-modules-note@__stddef_size_t.h:* 0+ {{here}} | ||
|
|
||
| #include "include_again.h" | ||
| // Includes <stddef.h> which includes <__stddef_size_t.h>. | ||
|
|
||
| size_t st2; | ||
|
|
||
| #include "size_t.h" | ||
| // Redeclares size_t when -fbuiltin-headers-in-system-modules is not passed, but | ||
| // the type merger should figure it out. | ||
|
|
||
| size_t st3; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| // RUN: %clang_cc1 -verify %s | ||
| // expected-no-diagnostics | ||
|
|
||
| // This tests evaluation of _Complex arithmetic at compile time. | ||
|
|
||
| #define APPROX_EQ(a, b) ( \ | ||
| __builtin_fabs(__real (a) - __real (b)) < 0.0001 && \ | ||
| __builtin_fabs(__imag (a) - __imag (b)) < 0.0001 \ | ||
| ) | ||
|
|
||
| #define EVAL(a, b) _Static_assert(a == b, "") | ||
| #define EVALF(a, b) _Static_assert(APPROX_EQ(a, b), "") | ||
|
|
||
| // _Complex float + _Complex float | ||
| void a() { | ||
| EVALF((2.f + 3i) + (4.f + 5i), 6.f + 8i); | ||
| EVALF((2.f + 3i) - (4.f + 5i), -2.f - 2i); | ||
| EVALF((2.f + 3i) * (4.f + 5i), -7.f + 22i); | ||
| EVALF((2.f + 3i) / (4.f + 5i), 0.5609f + 0.0487i); | ||
|
|
||
| EVALF((2. + 3i) + (4. + 5i), 6. + 8i); | ||
| EVALF((2. + 3i) - (4. + 5i), -2. - 2i); | ||
| EVALF((2. + 3i) * (4. + 5i), -7. + 22i); | ||
| EVALF((2. + 3i) / (4. + 5i), .5609 + .0487i); | ||
| } | ||
|
|
||
| // _Complex int + _Complex int | ||
| void b() { | ||
| EVAL((2 + 3i) + (4 + 5i), 6 + 8i); | ||
| EVAL((2 + 3i) - (4 + 5i), -2 - 2i); | ||
| EVAL((2 + 3i) * (4 + 5i), -7 + 22i); | ||
| EVAL((8 + 30i) / (4 + 5i), 4 + 1i); | ||
| } | ||
|
|
||
| // _Complex float + float | ||
| void c() { | ||
| EVALF((2.f + 4i) + 3.f, 5.f + 4i); | ||
| EVALF((2.f + 4i) - 3.f, -1.f + 4i); | ||
| EVALF((2.f + 4i) * 3.f, 6.f + 12i); | ||
| EVALF((2.f + 4i) / 2.f, 1.f + 2i); | ||
|
|
||
| EVALF(3.f + (2.f + 4i), 5.f + 4i); | ||
| EVALF(3.f - (2.f + 4i), 1.f - 4i); | ||
| EVALF(3.f * (2.f + 4i), 6.f + 12i); | ||
| EVALF(3.f / (2.f + 4i), .3f - 0.6i); | ||
|
|
||
| EVALF((2. + 4i) + 3., 5. + 4i); | ||
| EVALF((2. + 4i) - 3., -1. + 4i); | ||
| EVALF((2. + 4i) * 3., 6. + 12i); | ||
| EVALF((2. + 4i) / 2., 1. + 2i); | ||
|
|
||
| EVALF(3. + (2. + 4i), 5. + 4i); | ||
| EVALF(3. - (2. + 4i), 1. - 4i); | ||
| EVALF(3. * (2. + 4i), 6. + 12i); | ||
| EVALF(3. / (2. + 4i), .3 - 0.6i); | ||
| } | ||
|
|
||
| // _Complex int + int | ||
| void d() { | ||
| EVAL((2 + 4i) + 3, 5 + 4i); | ||
| EVAL((2 + 4i) - 3, -1 + 4i); | ||
| EVAL((2 + 4i) * 3, 6 + 12i); | ||
| EVAL((2 + 4i) / 2, 1 + 2i); | ||
|
|
||
| EVAL(3 + (2 + 4i), 5 + 4i); | ||
| EVAL(3 - (2 + 4i), 1 - 4i); | ||
| EVAL(3 * (2 + 4i), 6 + 12i); | ||
| EVAL(20 / (2 + 4i), 2 - 4i); | ||
| } | ||
|
|
||
| // _Complex float + int | ||
| void e() { | ||
| EVALF((2.f + 4i) + 3, 5.f + 4i); | ||
| EVALF((2.f + 4i) - 3, -1.f + 4i); | ||
| EVALF((2.f + 4i) * 3, 6.f + 12i); | ||
| EVALF((2.f + 4i) / 2, 1.f + 2i); | ||
|
|
||
| EVALF(3 + (2.f + 4i), 5.f + 4i); | ||
| EVALF(3 - (2.f + 4i), 1.f - 4i); | ||
| EVALF(3 * (2.f + 4i), 6.f + 12i); | ||
| EVALF(3 / (2.f + 4i), .3f - 0.6i); | ||
|
|
||
| EVALF((2. + 4i) + 3, 5. + 4i); | ||
| EVALF((2. + 4i) - 3, -1. + 4i); | ||
| EVALF((2. + 4i) * 3, 6. + 12i); | ||
| EVALF((2. + 4i) / 2, 1. + 2i); | ||
|
|
||
| EVALF(3 + (2. + 4i), 5. + 4i); | ||
| EVALF(3 - (2. + 4i), 1. - 4i); | ||
| EVALF(3 * (2. + 4i), 6. + 12i); | ||
| EVALF(3 / (2. + 4i), .3 - 0.6i); | ||
| } | ||
|
|
||
| // _Complex int + float | ||
| void f() { | ||
| EVALF((2 + 4i) + 3.f, 5.f + 4i); | ||
| EVALF((2 + 4i) - 3.f, -1.f + 4i); | ||
| EVALF((2 + 4i) * 3.f, 6.f + 12i); | ||
| EVALF((2 + 4i) / 2.f, 1.f + 2i); | ||
|
|
||
| EVALF(3.f + (2 + 4i), 5.f + 4i); | ||
| EVALF(3.f - (2 + 4i), 1.f - 4i); | ||
| EVALF(3.f * (2 + 4i), 6.f + 12i); | ||
| EVALF(3.f / (2 + 4i), .3f - 0.6i); | ||
|
|
||
| EVALF((2 + 4i) + 3., 5. + 4i); | ||
| EVALF((2 + 4i) - 3., -1. + 4i); | ||
| EVALF((2 + 4i) * 3., 6. + 12i); | ||
| EVALF((2 + 4i) / 2., 1. + 2i); | ||
|
|
||
| EVALF(3. + (2 + 4i), 5. + 4i); | ||
| EVALF(3. - (2 + 4i), 1. - 4i); | ||
| EVALF(3. * (2 + 4i), 6. + 12i); | ||
| EVALF(3. / (2 + 4i), .3 - 0.6i); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| // RUN: %clang_cc1 -fsyntax-only -verify -std=c23 %s | ||
|
|
||
| // Division by 0 here is an error iff the variable is 'constexpr'. | ||
| const _Bool inf1 = (1.0/0.0 == __builtin_inf()); | ||
| constexpr _Bool inf2 = (1.0/0.0 == __builtin_inf()); // expected-error {{must be initialized by a constant expression}} expected-note {{division by zero}} | ||
| constexpr _Bool inf3 = __builtin_inf() == __builtin_inf(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // RUN: %clang_cc1 -std=c++23 -verify %s | ||
| // expected-no-diagnostics | ||
|
|
||
| struct S { | ||
| int i = 42; | ||
| constexpr auto f1() { | ||
| return [this](this auto) { | ||
| return this->i; | ||
| }(); | ||
| }; | ||
|
|
||
| constexpr auto f2() { | ||
| return [this](this auto&&) { | ||
| return this->i; | ||
| }(); | ||
| }; | ||
|
|
||
| constexpr auto f3() { | ||
| return [i = this->i](this auto) { | ||
| return i; | ||
| }(); | ||
| }; | ||
|
|
||
| constexpr auto f4() { | ||
| return [i = this->i](this auto&&) { | ||
| return i; | ||
| }(); | ||
| }; | ||
| }; | ||
|
|
||
| static_assert(S().f1() == 42); | ||
| static_assert(S().f2() == 42); | ||
| static_assert(S().f3() == 42); | ||
| static_assert(S().f4() == 42); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // UNSUPPORTED: hwasan, ubsan | ||
| // RUN: not %clangxx -static %s -o /dev/null |