Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-absolute-value.c
|
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s -Wabsolute-value
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only %s -Wabsolute-value -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
int abs(int);
long int labs(long int);
long long int llabs(long long int);
float fabsf(float);
double fabs(double);
long double fabsl(long double);
float cabsf(float _Complex);
double cabs(double _Complex);
long double cabsl(long double _Complex);
void test_int(int x) {
(void)abs(x);
(void)labs(x);
(void)llabs(x);
(void)fabsf(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
// expected-note@-2 {{use function 'abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"
(void)fabs(x);
// expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
// expected-note@-2 {{use function 'abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"abs"
(void)fabsl(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
// expected-note@-2 {{use function 'abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"
(void)cabsf(x);
// expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
// expected-note@-2 {{use function 'abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"
(void)cabs(x);
// expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
// expected-note@-2 {{use function 'abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"abs"
(void)cabsl(x);
// expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
// expected-note@-2 {{use function 'abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"abs"
(void)__builtin_abs(x);
(void)__builtin_labs(x);
(void)__builtin_llabs(x);
(void)__builtin_fabsf(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"
(void)__builtin_fabs(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_abs"
(void)__builtin_fabsl(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"
(void)__builtin_cabsf(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"
(void)__builtin_cabs(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_abs"
(void)__builtin_cabsl(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_abs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_abs"
}
void test_long(long x) {
(void)abs(x); // no warning - int and long are same length for this target
(void)labs(x);
(void)llabs(x);
(void)fabsf(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
// expected-note@-2 {{use function 'labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
(void)fabs(x);
// expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
// expected-note@-2 {{use function 'labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs"
(void)fabsl(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
// expected-note@-2 {{use function 'labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
(void)cabsf(x);
// expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
// expected-note@-2 {{use function 'labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
(void)cabs(x);
// expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
// expected-note@-2 {{use function 'labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"labs"
(void)cabsl(x);
// expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
// expected-note@-2 {{use function 'labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"labs"
(void)__builtin_abs(x); // no warning - int and long are same length for
// this target
(void)__builtin_labs(x);
(void)__builtin_llabs(x);
(void)__builtin_fabsf(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
(void)__builtin_fabs(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs"
(void)__builtin_fabsl(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
(void)__builtin_cabsf(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
(void)__builtin_cabs(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_labs"
(void)__builtin_cabsl(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_labs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_labs"
}
void test_long_long(long long x) {
(void)abs(x);
// expected-warning@-1{{absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
// expected-note@-2{{use function 'llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"llabs"
(void)labs(x);
// expected-warning@-1{{absolute value function 'labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}}
// expected-note@-2{{use function 'llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
(void)llabs(x);
(void)fabsf(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of integer type}}
// expected-note@-2 {{use function 'llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
(void)fabs(x);
// expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of integer type}}
// expected-note@-2 {{use function 'llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
(void)fabsl(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of integer type}}
// expected-note@-2 {{use function 'llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
(void)cabsf(x);
// expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of integer type}}
// expected-note@-2 {{use function 'llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
(void)cabs(x);
// expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of integer type}}
// expected-note@-2 {{use function 'llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"llabs"
(void)cabsl(x);
// expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of integer type}}
// expected-note@-2 {{use function 'llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"llabs"
(void)__builtin_abs(x);
// expected-warning@-1{{absolute value function '__builtin_abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value}}
// expected-note@-2{{use function '__builtin_llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_llabs"
(void)__builtin_labs(x);
// expected-warning@-1{{absolute value function '__builtin_labs' given an argument of type 'long long' but has parameter of type 'long' which may cause truncation of value}}
// expected-note@-2{{use function '__builtin_llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
(void)__builtin_llabs(x);
(void)__builtin_fabsf(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
(void)__builtin_fabs(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
(void)__builtin_fabsl(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
(void)__builtin_cabsf(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
(void)__builtin_cabs(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_llabs"
(void)__builtin_cabsl(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of integer type}}
// expected-note@-2 {{use function '__builtin_llabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_llabs"
}
void test_float(float x) {
(void)abs(x);
// expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabsf"
(void)labs(x);
// expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsf"
(void)llabs(x);
// expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"
(void)fabsf(x);
(void)fabs(x);
(void)fabsl(x);
(void)cabsf(x);
// expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"
(void)cabs(x);
// expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsf"
(void)cabsl(x);
// expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsf"
(void)__builtin_abs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabsf"
(void)__builtin_labs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsf"
(void)__builtin_llabs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"
(void)__builtin_fabsf(x);
(void)__builtin_fabs(x);
(void)__builtin_fabsl(x);
(void)__builtin_cabsf(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"
(void)__builtin_cabs(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsf"
(void)__builtin_cabsl(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsf"
}
void test_double(double x) {
(void)abs(x);
// expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabs"
(void)labs(x);
// expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabs"
(void)llabs(x);
// expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"
(void)fabsf(x);
// expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
// expected-note@-2{{use function 'fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"
(void)fabs(x);
(void)fabsl(x);
(void)cabsf(x);
// expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"
(void)cabs(x);
// expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabs"
(void)cabsl(x);
// expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabs"
(void)__builtin_abs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabs"
(void)__builtin_labs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabs"
(void)__builtin_llabs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"
(void)__builtin_fabsf(x);
// expected-warning@-1{{absolute value function '__builtin_fabsf' given an argument of type 'double' but has parameter of type 'float' which may cause truncation of value}}
// expected-note@-2{{use function '__builtin_fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"
(void)__builtin_fabs(x);
(void)__builtin_fabsl(x);
(void)__builtin_cabsf(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"
(void)__builtin_cabs(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabs"
(void)__builtin_cabsl(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabs"
}
void test_long_double(long double x) {
(void)abs(x);
// expected-warning@-1 {{using integer absolute value function 'abs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"fabsl"
(void)labs(x);
// expected-warning@-1 {{using integer absolute value function 'labs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"
(void)llabs(x);
// expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"
(void)fabsf(x);
// expected-warning@-1{{absolute value function 'fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}}
// expected-note@-2{{use function 'fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"
(void)fabs(x);
// expected-warning@-1{{absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}}
// expected-note@-2{{use function 'fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"
(void)fabsl(x);
(void)cabsf(x);
// expected-warning@-1 {{using complex absolute value function 'cabsf' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"
(void)cabs(x);
// expected-warning@-1 {{using complex absolute value function 'cabs' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"fabsl"
(void)cabsl(x);
// expected-warning@-1 {{using complex absolute value function 'cabsl' when argument is of floating point type}}
// expected-note@-2 {{use function 'fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"fabsl"
(void)__builtin_abs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_fabsl"
(void)__builtin_labs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"
(void)__builtin_llabs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"
(void)__builtin_fabsf(x);
// expected-warning@-1{{absolute value function '__builtin_fabsf' given an argument of type 'long double' but has parameter of type 'float' which may cause truncation of value}}
// expected-note@-2{{use function '__builtin_fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"
(void)__builtin_fabs(x);
// expected-warning@-1{{absolute value function '__builtin_fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value}}
// expected-note@-2{{use function '__builtin_fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"
(void)__builtin_fabsl(x);
(void)__builtin_cabsf(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsf' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"
(void)__builtin_cabs(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabs' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_fabsl"
(void)__builtin_cabsl(x);
// expected-warning@-1 {{using complex absolute value function '__builtin_cabsl' when argument is of floating point type}}
// expected-note@-2 {{use function '__builtin_fabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_fabsl"
}
void test_complex_float(_Complex float x) {
(void)abs(x);
// expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsf"
(void)labs(x);
// expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
(void)llabs(x);
// expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
(void)fabsf(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
(void)fabs(x);
// expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsf"
(void)fabsl(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsf"
(void)cabsf(x);
(void)cabs(x);
(void)cabsl(x);
(void)__builtin_abs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsf"
(void)__builtin_labs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"
(void)__builtin_llabs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
(void)__builtin_fabsf(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
(void)__builtin_fabs(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsf"
(void)__builtin_fabsl(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsf' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsf"
(void)__builtin_cabsf(x);
(void)__builtin_cabs(x);
(void)__builtin_cabsl(x);
}
void test_complex_double(_Complex double x) {
(void)abs(x);
// expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabs"
(void)labs(x);
// expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"
(void)llabs(x);
// expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
(void)fabsf(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
// expected-note@-2 {{use function 'cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
(void)fabs(x);
// expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabs"
(void)fabsl(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
// expected-note@-2 {{use function 'cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
(void)cabsf(x);
// expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex double' but has parameter of type '_Complex float' which may cause truncation of value}}
// expected-note@-2 {{use function 'cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabs"
(void)cabs(x);
(void)cabsl(x);
(void)__builtin_abs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabs"
(void)__builtin_labs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs"
(void)__builtin_llabs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
(void)__builtin_fabsf(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
(void)__builtin_fabs(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabs"
(void)__builtin_fabsl(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
(void)__builtin_cabsf(x);
// expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex double' but has parameter of type '_Complex float' which may cause truncation of value}}
// expected-note@-2 {{use function '__builtin_cabs' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabs"
(void)__builtin_cabs(x);
(void)__builtin_cabsl(x);
}
void test_complex_long_double(_Complex long double x) {
(void)abs(x);
// expected-warning@-1 {{using integer absolute value function 'abs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:"cabsl"
(void)labs(x);
// expected-warning@-1 {{using integer absolute value function 'labs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
(void)llabs(x);
// expected-warning@-1 {{using integer absolute value function 'llabs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
(void)fabsf(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsf' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
(void)fabs(x);
// expected-warning@-1 {{using floating point absolute value function 'fabs' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
(void)fabsl(x);
// expected-warning@-1 {{using floating point absolute value function 'fabsl' when argument is of complex type}}
// expected-note@-2 {{use function 'cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
(void)cabsf(x);
// expected-warning@-1 {{absolute value function 'cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}}
// expected-note@-2 {{use function 'cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:"cabsl"
(void)cabs(x);
// expected-warning@-1 {{absolute value function 'cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}}
// expected-note@-2 {{use function 'cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:"cabsl"
(void)cabsl(x);
(void)__builtin_abs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_abs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:"__builtin_cabsl"
(void)__builtin_labs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_labs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
(void)__builtin_llabs(x);
// expected-warning@-1 {{using integer absolute value function '__builtin_llabs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
(void)__builtin_fabsf(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsf' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
(void)__builtin_fabs(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabs' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
(void)__builtin_fabsl(x);
// expected-warning@-1 {{using floating point absolute value function '__builtin_fabsl' when argument is of complex type}}
// expected-note@-2 {{use function '__builtin_cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
(void)__builtin_cabsf(x);
// expected-warning@-1 {{absolute value function '__builtin_cabsf' given an argument of type '_Complex long double' but has parameter of type '_Complex float' which may cause truncation of value}}
// expected-note@-2 {{use function '__builtin_cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:"__builtin_cabsl"
(void)__builtin_cabs(x);
// expected-warning@-1 {{absolute value function '__builtin_cabs' given an argument of type '_Complex long double' but has parameter of type '_Complex double' which may cause truncation of value}}
// expected-note@-2 {{use function '__builtin_cabsl' instead}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:"__builtin_cabsl"
(void)__builtin_cabsl(x);
}
void test_unsigned_int(unsigned int x) {
(void)abs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
(void)labs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
(void)llabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)fabsf(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)fabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
(void)fabsl(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)cabsf(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)cabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
(void)cabsl(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)__builtin_abs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""
(void)__builtin_labs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
(void)__builtin_llabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
(void)__builtin_fabsf(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
(void)__builtin_fabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
(void)__builtin_fabsl(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
(void)__builtin_cabsf(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
(void)__builtin_cabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
(void)__builtin_cabsl(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned int' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
}
void test_unsigned_long(unsigned long x) {
(void)abs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'abs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:12}:""
(void)labs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'labs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
(void)llabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'llabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)fabsf(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'fabsf' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)fabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'fabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
(void)fabsl(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'fabsl' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)cabsf(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'cabsf' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)cabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'cabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:13}:""
(void)cabsl(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to 'cabsl' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:14}:""
(void)__builtin_abs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_abs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:22}:""
(void)__builtin_labs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_labs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
(void)__builtin_llabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_llabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
(void)__builtin_fabsf(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_fabsf' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
(void)__builtin_fabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_fabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
(void)__builtin_fabsl(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_fabsl' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
(void)__builtin_cabsf(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_cabsf' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
(void)__builtin_cabs(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_cabs' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:23}:""
(void)__builtin_cabsl(x);
// expected-warning@-1 {{taking the absolute value of unsigned type 'unsigned long' has no effect}}
// expected-note@-2 {{remove the call to '__builtin_cabsl' since unsigned values cannot be negative}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:9-[[@LINE-3]]:24}:""
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ms_wide_predefined_expr.cpp
|
// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
// expected-no-diagnostics
// Wide character predefined identifiers
#define _STR2WSTR(str) L##str
#define STR2WSTR(str) _STR2WSTR(str)
void abcdefghi12(void) {
const wchar_t (*ss)[12] = &STR2WSTR(__FUNCTION__);
static int arr[sizeof(STR2WSTR(__FUNCTION__))==12*sizeof(wchar_t) ? 1 : -1];
}
namespace PR13206 {
void foo(const wchar_t *);
template<class T> class A {
public:
void method() {
foo(L__FUNCTION__);
}
};
void bar() {
A<int> x;
x.method();
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/implicit-int.c
|
// RUN: %clang_cc1 -fsyntax-only %s -verify -pedantic
foo() { // expected-warning {{type specifier missing, defaults to 'int'}}
return 0;
}
y; // expected-warning {{type specifier missing, defaults to 'int'}}
// rdar://6131634
void f((x)); // expected-warning {{type specifier missing, defaults to 'int'}}
// PR3702
#define PAD(ms10) { \
register i; \
}
#define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */
void
h19_insline(n) // expected-warning {{parameter 'n' was not declared, defaulting to type 'int'}}
{
ILPAD(); // expected-warning {{type specifier missing, defaults to 'int'}}
}
struct foo {
__extension__ __attribute__((packed)) x : 4; // expected-warning {{type specifier missing, defaults to 'int'}}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/inline-redef.c
|
// RUN: %clang_cc1 -std=gnu89 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify %s
#if __STDC_VERSION__ >= 199901
#define GNU_INLINE __attribute((__gnu_inline__))
#else
#define GNU_INLINE
#endif
// PR5253
// rdar://9559708 (same extension in C99 mode)
// GNU Extension: check that we can redefine an extern inline function
GNU_INLINE extern inline int f(int a) {return a;}
int f(int b) {return b;} // expected-note{{previous definition is here}}
// And now check that we can't redefine a normal function
int f(int c) {return c;} // expected-error{{redefinition of 'f'}}
// Check that we can redefine an extern inline function as a static function
GNU_INLINE extern inline int g(int a) {return a;}
static int g(int b) {return b;}
// Check that we ensure the types of the two definitions are the same
GNU_INLINE extern inline int h(int a) {return a;} // expected-note{{previous definition is here}}
int h(short b) {return b;} // expected-error{{conflicting types for 'h'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtin-prefetch.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void foo() {
int a;
__builtin_prefetch(&a);
__builtin_prefetch(&a, 1);
__builtin_prefetch(&a, 1, 2);
__builtin_prefetch(&a, 1, 9, 3); // expected-error{{too many arguments to function}}
__builtin_prefetch(&a, "hello", 2); // expected-error{{argument to '__builtin_prefetch' must be a constant integer}}
__builtin_prefetch(&a, a, 2); // expected-error{{argument to '__builtin_prefetch' must be a constant integer}}
__builtin_prefetch(&a, 2); // expected-error{{argument should be a value from 0 to 1}}
__builtin_prefetch(&a, 0, 4); // expected-error{{argument should be a value from 0 to 3}}
__builtin_prefetch(&a, -1, 4); // expected-error{{argument should be a value from 0 to 1}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-return-3.c
|
// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
void foo() {
^ int (void) { }(); // expected-error {{control reaches end of non-void block}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-storageclass.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
// expected-no-diagnostics
int printf(const char *, ...);
void _Block_byref_release(void*src){}
int main() {
__block int X = 1234;
__block const char * message = "HELLO";
X = X - 1234;
X += 1;
printf ("%s(%d)\n", message, X);
X -= 1;
return X;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/array-bounds-ptr-arith.c
|
// RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s
// Test case from PR10615
struct ext2_super_block{
unsigned char s_uuid[8]; // expected-note {{declared here}}
};
void* ext2_statfs (struct ext2_super_block *es,int a)
{
return (void *)es->s_uuid + sizeof(int); // no-warning
}
void* broken (struct ext2_super_block *es,int a)
{
return (void *)es->s_uuid + 80; // expected-warning {{refers past the end of the array}}
}
// Test case reduced from PR11594
struct S { int n; };
void pr11594(struct S *s) {
int a[10];
int *p = a - s->n;
}
// Test case reduced from <rdar://problem/11387038>. This resulted in
// an assertion failure because of the typedef instead of an explicit
// constant array type.
struct RDar11387038 {};
typedef struct RDar11387038 RDar11387038Array[1];
struct RDar11387038_Table {
RDar11387038Array z;
};
typedef struct RDar11387038_Table * TPtr;
typedef TPtr *TabHandle;
struct RDar11387038_B { TabHandle x; };
typedef struct RDar11387038_B RDar11387038_B;
void radar11387038() {
RDar11387038_B *pRDar11387038_B;
struct RDar11387038* y = &(*pRDar11387038_B->x)->z[4];
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-weak.c
|
// RUN: %clang_cc1 -verify -fsyntax-only %s
extern int g0 __attribute__((weak));
extern int g1 __attribute__((weak_import));
int g2 __attribute__((weak));
int g3 __attribute__((weak_import)); // expected-warning {{'weak_import' attribute cannot be specified on a definition}}
int __attribute__((weak_import)) g4(void);
void __attribute__((weak_import)) g5(void) {
}
struct __attribute__((weak)) s0 {}; // expected-warning {{'weak' attribute only applies to variables and functions}}
struct __attribute__((weak_import)) s1 {}; // expected-warning {{'weak_import' attribute only applies to variables and functions}}
static int x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
// rdar://9538608
int C; // expected-note {{previous definition is here}}
extern int C __attribute__((weak_import)); // expected-warning {{an already-declared variable is made a weak_import declaration}}
static int pr14946_x;
extern int pr14946_x __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
static void pr14946_f();
void pr14946_f() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-non-iso.c
|
// RUN: %clang_cc1 -triple i686-linux-gnu -fsyntax-only -verify -std=c99 -Wformat-non-iso %s
int printf(const char *restrict, ...);
int scanf(const char * restrict, ...);
void f(void) {
char *cp;
// The 'q' length modifier.
printf("%qd", (long long)42); // expected-warning{{'q' length modifier is not supported by ISO C}} expected-note{{did you mean to use 'll'?}}
scanf("%qd", (long long *)0); // expected-warning{{'q' length modifier is not supported by ISO C}} expected-note{{did you mean to use 'll'?}}
// The 'm' length modifier.
scanf("%ms", &cp); // expected-warning{{'m' length modifier is not supported by ISO C}}
// The 'S' and 'C' conversion specifiers.
printf("%S", L"foo"); // expected-warning{{'S' conversion specifier is not supported by ISO C}}
printf("%C", L'x'); // expected-warning{{'C' conversion specifier is not supported by ISO C}}
// Combining 'L' with an integer conversion specifier.
printf("%Li", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'i' is not supported by ISO C}} expected-note{{did you mean to use 'll'?}}
printf("%Lo", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'o' is not supported by ISO C}} expected-note{{did you mean to use 'll'?}}
printf("%Lu", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'u' is not supported by ISO C}} expected-note{{did you mean to use 'll'?}}
printf("%Lx", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'x' is not supported by ISO C}} expected-note{{did you mean to use 'll'?}}
printf("%LX", (long long)42); // expected-warning{{using length modifier 'L' with conversion specifier 'X' is not supported by ISO C}} expected-note{{did you mean to use 'll'?}}
// Positional arguments.
printf("%1$d", 42); // expected-warning{{positional arguments are not supported by ISO C}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/fn-ptr-as-fn-prototype.c
|
// RUN: %clang_cc1 -ast-print %s | FileCheck %s
// This testcase checks the functionality of
// Sema::ActOn{Start,End}FunctionDeclarator, specifically checking that
// ActOnEndFunctionDeclarator is called after the typedef so the enum
// is in the global scope, not the scope of f().
// CHECK: typedef void (*g)();
typedef void (*g) ();
// CHECK: enum {
enum {
k = -1
};
// CHECK: void f() {
void f() {}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-minsize.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
int foo() __attribute__((__minsize__));
int var1 __attribute__((__minsize__)); // expected-error{{'__minsize__' attribute only applies to functions and methods}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/callingconv.c
|
// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -verify
// RUN: %clang_cc1 %s -fsyntax-only -triple i386-unknown-unknown -fms-compatibility -DWIN -verify
void __attribute__((fastcall)) foo(float *a) {
}
void __attribute__((stdcall)) bar(float *a) {
}
void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
}
void __attribute__((fastcall)) test0() {
}
void __attribute__((fastcall)) test1(void) {
}
void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{fastcall calling convention ignored on variadic function}}
}
void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{stdcall calling convention ignored on variadic function}}
}
void __attribute__((thiscall)) test4(int a, ...) { // expected-error {{variadic function cannot use thiscall calling convention}}
}
void __attribute__((cdecl)) ctest0() {}
void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
void (__attribute__((fastcall)) *pfoo)(float*) = foo;
void (__attribute__((stdcall)) *pbar)(float*) = bar;
void (__attribute__((cdecl)) *ptest1)(void) = test1; // expected-warning {{incompatible pointer types}}
void (*pctest0)() = ctest0;
void ctest2() {}
void (__attribute__((cdecl)) *pctest2)() = ctest2;
typedef void (__attribute__((fastcall)) *Handler) (float *);
Handler H = foo;
int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
// expected-error {{invalid PCS type}}
int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
/* These are ignored because the target is i386 and not ARM */
int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
// PR6361
void ctest3();
void __attribute__((cdecl)) ctest3() {}
// PR6408
typedef __attribute__((stdcall)) void (*PROC)();
PROC __attribute__((cdecl)) ctest4(const char *x) {}
void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {}
typedef void typedef_fun_t(int);
typedef_fun_t typedef_fun; // expected-note {{previous declaration is here}}
void __attribute__((stdcall)) typedef_fun(int x) { } // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
struct type_test {} __attribute__((stdcall)); // expected-warning {{'stdcall' attribute only applies to functions and methods}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-missing-prototypes.c
|
// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wmissing-prototypes -verify %s
// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wmissing-prototypes -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
int f();
int f(int x) { return x; } // expected-warning{{no previous prototype for function 'f'}}
static int g(int x) { return x; }
int h(int x) { return x; } // expected-warning{{no previous prototype for function 'h'}}
static int g2();
int g2(int x) { return x; }
void test(void);
int h3();
int h4(int);
int h4();
void test(void) {
int h2(int x);
int h3(int x);
int h4();
}
int h2(int x) { return x; } // expected-warning{{no previous prototype for function 'h2'}}
int h3(int x) { return x; } // expected-warning{{no previous prototype for function 'h3'}}
int h4(int x) { return x; }
int f2(int);
int f2();
int f2(int x) { return x; }
// rdar://6759522
int main(void) { return 0; }
void not_a_prototype_test(); // expected-note{{this declaration is not a prototype; add 'void' to make it a prototype for a zero-parameter function}}
void not_a_prototype_test() { } // expected-warning{{no previous prototype for function 'not_a_prototype_test'}}
// CHECK: fix-it:"{{.*}}":{40:27-40:27}:"void"
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-return.c
|
// RUN: %clang_cc1 -Wno-int-to-pointer-cast -pedantic -fsyntax-only %s -verify -fblocks
typedef void (^CL)(void);
CL foo() {
short y;
short (^add1)(void) = ^{ return y+1; }; // expected-error {{incompatible block pointer types initializing 'short (^)(void)' with an expression of type 'int (^)(void)'}}
CL X = ^{
if (2)
return;
return 1; // expected-error {{return type 'int' must match previous return type 'void' when block literal has unspecified explicit return type}}
};
int (^Y) (void) = ^{
if (3)
return 1;
else
return; // expected-error {{return type 'void' must match previous return type 'int' when block literal has unspecified explicit return type}}
};
char *(^Z)(void) = ^{
if (3)
return "";
else
return (char*)0;
};
double (^A)(void) = ^ { // expected-error {{incompatible block pointer types initializing 'double (^)(void)' with an expression of type 'float (^)(void)'}}
if (1)
return (float)1.0;
else
if (2)
return (double)2.0; // expected-error {{return type 'double' must match previous return type 'float' when block literal has unspecified explicit return type}}
return 1; // expected-error {{return type 'int' must match previous return type 'float' when block literal has unspecified explicit return type}}
};
char *(^B)(void) = ^{
if (3)
return "";
else
return 2; // expected-error {{return type 'int' must match previous return type 'char *' when block literal has unspecified explicit return type}}
};
return ^{ return 1; }; // expected-error {{incompatible block pointer types returning 'int (^)(void)' from a function with result type 'CL' (aka 'void (^)(void)')}}
}
typedef int (^CL2)(void);
CL2 foo2() {
return ^{ return 1; };
}
typedef unsigned int * uintptr_t;
typedef char Boolean;
typedef int CFBasicHash;
#define INVOKE_CALLBACK2(P, A, B) (P)(A, B)
typedef struct {
Boolean (^isEqual)(const CFBasicHash *, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key);
} CFBasicHashCallbacks;
int foo3() {
CFBasicHashCallbacks cb;
Boolean (*value_equal)(uintptr_t, uintptr_t) = 0;
cb.isEqual = ^(const CFBasicHash *table, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key) {
return (Boolean)(uintptr_t)INVOKE_CALLBACK2(value_equal, (uintptr_t)stack_value_or_key1, (uintptr_t)stack_value_or_key2);
};
}
static int funk(char *s) {
if (^{} == ((void*)0))
return 1;
else
return 0;
}
void next();
void foo4() {
int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-error {{incompatible block pointer types initializing 'int (^)(const char *)' with an expression of type 'int (^)(char *)'}}
int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (*)(const char *)' with an expression of type 'int (char *)'}}
int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; }; // expected-warning{{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}} \
// expected-note{{include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
}
typedef void (^bptr)(void);
bptr foo5(int j) {
__block int i;
if (j)
return ^{ ^{ i=0; }(); }; // expected-error {{returning block that lives on the local stack}}
return ^{ i=0; }; // expected-error {{returning block that lives on the local stack}}
return (^{ i=0; }); // expected-error {{returning block that lives on the local stack}}
return (void*)(^{ i=0; }); // expected-error {{returning block that lives on the local stack}}
}
int (*funcptr3[5])(long);
int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block cannot return array type}} expected-warning {{incompatible pointer to integer conversion}}
int sz9 = sizeof(^int(*())()[3]{ }); // expected-error {{function cannot return array type}}
void foo6() {
int (^b)(int) __attribute__((noreturn));
b = ^ (int i) __attribute__((noreturn)) { return 1; }; // expected-error {{block declared 'noreturn' should not return}}
b(1);
int (^c)(void) __attribute__((noreturn)) = ^ __attribute__((noreturn)) { return 100; }; // expected-error {{block declared 'noreturn' should not return}}
}
void foo7()
{
const int (^BB) (void) = ^{ const int i = 1; return i; }; // OK - initializing 'const int (^)(void)' with an expression of type 'int (^)(void)'
const int (^CC) (void) = ^const int{ const int i = 1; return i; };
int i;
int (^FF) (void) = ^{ return i; }; // OK
int (^EE) (void) = ^{ return i+1; }; // OK
__block int j;
int (^JJ) (void) = ^{ return j; }; // OK
int (^KK) (void) = ^{ return j+1; }; // OK
__block const int k;
const int cint = 100;
int (^MM) (void) = ^{ return k; };
int (^NN) (void) = ^{ return cint; };
}
// rdar://11069896
void (^blk)(void) = ^{
return (void)0; // expected-warning {{void block literal should not return void expression}}
};
// rdar://13463504
enum Test8 { T8_a, T8_b, T8_c };
void test8(void) {
extern void test8_helper(int (^)(int));
test8_helper(^(int flag) { if (flag) return T8_a; return T8_b; });
}
void test8b(void) {
extern void test8_helper2(char (^)(int)); // expected-note {{here}}
test8_helper2(^(int flag) { if (flag) return T8_a; return T8_b; }); // expected-error {{passing 'enum Test8 (^)(int)' to parameter of type 'char (^)(int)'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/floating-point-compare.c
|
// RUN: %clang_cc1 -fsyntax-only -Wfloat-equal -verify %s
int f1(float x, float y) {
return x == y; // expected-warning {{comparing floating point with ==}}
}
int f2(float x, float y) {
return x != y; // expected-warning {{comparing floating point with ==}}
}
int f3(float x) {
return x == x; // no-warning
}
int f4(float x) {
return x == 0.0; // no-warning {{comparing}}
}
int f5(float x) {
return x == __builtin_inf(); // no-warning
}
int f7(float x) {
return x == 3.14159; // expected-warning {{comparing}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/PR2727.c
|
// RUN: %clang_cc1 -verify -fsyntax-only -std=c90 %s
// RUN: %clang_cc1 -verify -fsyntax-only -std=c99 %s
// expected-no-diagnostics
int f (int x)
{
// sizeof applied to a type should not delete the type.
return sizeof (int[x]);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-unused.c
|
// RUN: %clang_cc1 -verify -Wunused -Wused-but-marked-unused -Wunused-parameter -Wunused -fsyntax-only %s
static void (*fp0)(void) __attribute__((unused));
static void __attribute__((unused)) f0(void);
// On K&R
int f1() __attribute__((unused));
int g0 __attribute__((unused));
int f2() __attribute__((unused(1, 2))); // expected-error {{'unused' attribute takes no arguments}}
struct Test0_unused {} __attribute__((unused));
struct Test0_not_unused {};
typedef int Int_unused __attribute__((unused));
typedef int Int_not_unused;
void test0() {
int x; // expected-warning {{unused variable}}
Int_not_unused i0; // expected-warning {{unused variable}}
Int_unused i1; // expected-warning {{'Int_unused' was marked unused but was used}}
struct Test0_not_unused s0; // expected-warning {{unused variable}}
struct Test0_unused s1; // expected-warning {{'Test0_unused' was marked unused but was used}}
}
int f3(int x) { // expected-warning{{unused parameter 'x'}}
return 0;
}
int f4(int x) {
return x;
}
int f5(int x __attribute__((__unused__))) {
return 0;
}
int f6(int x __attribute__((__unused__))) {
return x; // expected-warning{{'x' was marked unused but was used}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/cast-to-union.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
union u { int i; unsigned : 3; };
void f(union u);
void test(int x) {
f((union u)x); // expected-warning {{cast to union type is a GNU extension}}
f((union u)&x); // expected-error {{cast to union type from type 'int *' not present in union}}
f((union u)2U); // expected-error {{cast to union type from type 'unsigned int' not present in union}}
}
union u w = (union u)2; // expected-warning {{cast to union type is a GNU extension}}
union u ww = (union u)1.0; // expected-error{{cast to union type from type 'double' not present in union}}
union u x = 7; // expected-error{{initializing 'union u' with an expression of incompatible type 'int'}}
int i;
union u zz = (union u)i; // expected-error{{initializer element is not a compile-time constant}} expected-warning {{cast to union type is a GNU extension}}
struct s {int a, b;};
struct s y = { 1, 5 };
struct s z = (struct s){ 1, 5 };
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/const-eval-64.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux %s
// expected-no-diagnostics
#define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];});
// <rdar://problem/10962435>
EVAL_EXPR(1, ((char*)-1LL) + 1 == 0 ? 1 : -1)
EVAL_EXPR(2, ((char*)-1LL) + 1 < (char*) -1 ? 1 : -1)
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ms_bitfield_layout.c
|
// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fms-extensions -fdump-record-layouts %s 2>/dev/null \
// RUN: | FileCheck %s
// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fms-extensions -fdump-record-layouts %s 2>/dev/null \
// RUN: | FileCheck %s
typedef struct A {
char x;
int a : 22;
int : 0;
int c : 10;
char b : 3;
char d: 4;
short y;
} A;
// CHECK: Type: struct A
// CHECK: Size:128
// CHECK: Alignment:32
// CHECK: FieldOffsets: [0, 32, 64, 64, 96, 99, 112]>
typedef struct B {
char x;
int : 0;
short a : 4;
char y;
} B;
// CHECK: Type: struct B
// CHECK: Size:48
// CHECK: Alignment:16
// CHECK: FieldOffsets: [0, 8, 16, 32]>
typedef struct C {
char x;
short a : 4;
int : 0;
char y;
} C;
// CHECK: Type: struct C
// CHECK: Size:64
// CHECK: Alignment:32
// CHECK: FieldOffsets: [0, 16, 32, 32]>
typedef struct D {
char x;
short : 0;
int : 0;
char y;
} D;
// CHECK: Type: struct D
// CHECK: Size:16
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 8, 8, 8]>
typedef union E {
char x;
long long a : 3;
int b : 3;
long long : 0;
short y;
} E;
// CHECK: Type: union E
// CHECK: Size:64
// CHECK: Alignment:16
// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
typedef struct F {
char x;
char a : 3;
char b : 3;
char c : 3;
short d : 6;
short e : 6;
short f : 6;
short g : 11;
short h : 11;
short i : 11;
short y;
} F;
// CHECK: Type: struct F
// CHECK: Size:128
// CHECK: Alignment:16
// CHECK: FieldOffsets: [0, 8, 11, 16, 32, 38, 48, 64, 80, 96, 112]>
typedef union G {
char x;
int a : 3;
int : 0;
long long : 0;
short y;
} G;
// CHECK: Type: union G
// CHECK: Size:32
// CHECK: Alignment:16
// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
typedef struct H {
unsigned short a : 1;
unsigned char : 0;
unsigned long : 0;
unsigned short c : 1;
} H;
// CHECK: Type: struct H
// CHECK: Size:32
// CHECK: Alignment:16
// CHECK: FieldOffsets: [0, 16, 16, 16]>
typedef struct I {
short : 8;
__declspec(align(16)) short : 8;
} I;
// CHECK: Type: struct I
// CHECK: Size:16
// CHECK: Alignment:16
// CHECK: FieldOffsets: [0, 8]
#pragma pack(push, 1)
typedef struct A1 {
char x;
int a : 22;
int : 0;
int c : 10;
char b : 3;
char d: 4;
short y;
} A1;
// CHECK: Type: struct A1
// CHECK: Size:96
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 8, 40, 40, 72, 75, 80]>
typedef struct B1 {
char x;
int : 0;
short a : 4;
char y;
} B1;
// CHECK: Type: struct B1
// CHECK: Size:32
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 8, 8, 24]>
typedef struct C1 {
char x;
short a : 4;
int : 0;
char y;
} C1;
// CHECK: Type: struct C1
// CHECK: Size:32
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 8, 24, 24]>
typedef struct D1 {
char x;
short : 0;
int : 0;
char y;
} D1;
// CHECK: Type: struct D1
// CHECK: Size:16
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 8, 8, 8]>
typedef union E1 {
char x;
long long a : 3;
int b : 3;
long long : 0;
short y;
} E1;
// CHECK: Type: union E1
// CHECK: Size:64
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
typedef struct F1 {
char x;
char a : 3;
char b : 3;
char c : 3;
short d : 6;
short e : 6;
short f : 6;
short g : 11;
short h : 11;
short i : 11;
short y;
} F1;
// CHECK: Type: struct F1
// CHECK: Size:120
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 8, 11, 16, 24, 30, 40, 56, 72, 88, 104]>
typedef union G1 {
char x;
int a : 3;
int : 0;
long long : 0;
short y;
} G1;
// CHECK: Type: union G1
// CHECK: Size:32
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 0, 0, 0, 0]>
typedef struct H1 {
unsigned long a : 1;
unsigned char : 0;
unsigned long : 0;
unsigned long c : 1;
} H1;
// CHECK: Type: struct H1
// CHECK: Size:64
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 32, 32, 32]>
typedef struct I1 {
short : 8;
__declspec(align(16)) short : 8;
} I1;
// CHECK: Type: struct I1
// CHECK: Size:16
// CHECK: Alignment:8
// CHECK: FieldOffsets: [0, 8]
#pragma pack(pop)
int x[
sizeof(A ) +
sizeof(B ) +
sizeof(C ) +
sizeof(D ) +
sizeof(E ) +
sizeof(F ) +
sizeof(G ) +
sizeof(H ) +
sizeof(I ) +
sizeof(A1) +
sizeof(B1) +
sizeof(C1) +
sizeof(D1) +
sizeof(E1) +
sizeof(F1) +
sizeof(G1) +
sizeof(H1) +
sizeof(I1) +
0];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/vla-2.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
// Check that we don't crash trying to emit warnings in a potentially-evaluated
// sizeof or typeof. (This test needs to be in a separate file because we use
// a different codepath when we have already emitted an error.)
int PotentiallyEvaluatedSizeofWarn(int n) {
return (int)sizeof *(0 << 32,(int(*)[n])0); // expected-warning {{expression result unused}} expected-warning {{shift count >= width of type}}
}
void PotentiallyEvaluatedTypeofWarn(int n) {
__typeof(*(0 << 32,(int(*)[n])0)) x; // expected-warning {{expression result unused}} expected-warning {{shift count >= width of type}}
(void)x;
}
void PotentiallyEvaluatedArrayBoundWarn(int n) {
(void)*(int(*)[(0 << 32,n)])0; // FIXME: We should warn here.
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/integer-overflow.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
typedef unsigned long long uint64_t;
typedef unsigned long long uint32_t;
uint64_t f0(uint64_t);
uint64_t f1(uint64_t, uint32_t);
uint64_t f2(uint64_t, ...);
static const uint64_t overflow = 1 * 4608 * 1024 * 1024; // expected-warning {{overflow in expression; result is 536870912 with type 'int'}}
uint64_t check_integer_overflows(int i) {
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
uint64_t overflow = 4608 * 1024 * 1024,
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
overflow2 = (uint64_t)(4608 * 1024 * 1024),
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
overflow3 = (uint64_t)(4608 * 1024 * 1024 * i),
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
overflow4 = (1ULL * ((4608) * ((1024) * (1024))) + 2ULL),
// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
multi_overflow = (uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
overflow += overflow2 = overflow3 = (uint64_t)(4608 * 1024 * 1024);
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
overflow += overflow2 = overflow3 = 4608 * 1024 * 1024;
uint64_t not_overflow = 4608 * 1024 * 1024ULL;
uint64_t not_overflow2 = (1ULL * ((uint64_t)(4608) * (1024 * 1024)) + 2ULL);
// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
overflow = 4608 * 1024 * 1024 ? 4608 * 1024 * 1024 : 0;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
overflow = 0 ? 0 : 4608 * 1024 * 1024;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
if (4608 * 1024 * 1024)
return 0;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
if ((uint64_t)(4608 * 1024 * 1024))
return 1;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
if ((uint64_t)(4608 * 1024 * 1024))
return 2;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
if ((uint64_t)(4608 * 1024 * 1024 * i))
return 3;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
if ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL))
return 4;
// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
if ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)))
return 5;
switch (i) {
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
case 4608 * 1024 * 1024:
return 6;
// expected-warning@+1 {{overflow in expression; result is 537919488 with type 'int'}}
case (uint64_t)(4609 * 1024 * 1024):
return 7;
// expected-error@+1 {{expression is not an integer constant expression}}
case ((uint64_t)(4608 * 1024 * 1024 * i)):
return 8;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
case ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL)):
return 9;
// expected-warning@+2 2{{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@+1 {{overflow converting case value to switch condition type (288230376151711744 to 0)}}
case ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024))):
return 10;
}
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
while (4608 * 1024 * 1024);
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
while ((uint64_t)(4608 * 1024 * 1024));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
while ((uint64_t)(4608 * 1024 * 1024));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
while ((uint64_t)(4608 * 1024 * 1024 * i));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
while ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL));
// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
while ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
do { } while (4608 * 1024 * 1024);
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
do { } while ((uint64_t)(4608 * 1024 * 1024));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
do { } while ((uint64_t)(4608 * 1024 * 1024));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
do { } while ((uint64_t)(4608 * 1024 * 1024 * i));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
do { } while ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL));
// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
do { } while ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));
// expected-warning@+3 {{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@+3 {{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@+3 {{overflow in expression; result is 536870912 with type 'int'}}
for (uint64_t i = 4608 * 1024 * 1024;
(uint64_t)(4608 * 1024 * 1024);
i += (uint64_t)(4608 * 1024 * 1024 * i));
// expected-warning@+3 {{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@+3 2{{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@+3 2{{overflow in expression; result is 536870912 with type 'int'}}
for (uint64_t i = (1ULL * ((4608) * ((1024) * (1024))) + 2ULL);
((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));
i = ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024))));
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
_Complex long long x = 4608 * 1024 * 1024;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
(__real__ x) = 4608 * 1024 * 1024;
// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
(__imag__ x) = 4608 * 1024 * 1024;
// expected-warning@+4 {{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@+3 {{array index 536870912 is past the end of the array (which contains 10 elements)}}
// expected-note@+1 {{array 'a' declared here}}
uint64_t a[10];
a[4608 * 1024 * 1024] = 1i;
// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/align_value.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
typedef double * __attribute__((align_value(64))) aligned_double;
void foo(aligned_double x, double * y __attribute__((align_value(32)))) { };
// expected-error@+1 {{requested alignment is not a power of 2}}
typedef double * __attribute__((align_value(63))) aligned_double1;
// expected-error@+1 {{requested alignment is not a power of 2}}
typedef double * __attribute__((align_value(-2))) aligned_double2;
// expected-error@+1 {{attribute takes one argument}}
typedef double * __attribute__((align_value(63, 4))) aligned_double3;
// expected-error@+1 {{attribute takes one argument}}
typedef double * __attribute__((align_value())) aligned_double3a;
// expected-error@+1 {{attribute takes one argument}}
typedef double * __attribute__((align_value)) aligned_double3b;
// expected-error@+1 {{'align_value' attribute requires integer constant}}
typedef double * __attribute__((align_value(4.5))) aligned_double4;
// expected-warning@+1 {{'align_value' attribute only applies to a pointer or reference ('int' is invalid)}}
typedef int __attribute__((align_value(32))) aligned_int;
typedef double * __attribute__((align_value(32*2))) aligned_double5;
// expected-warning@+1 {{'align_value' attribute only applies to variables and typedefs}}
void foo() __attribute__((align_value(32)));
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/MicrosoftCompatibility.cpp
|
// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility
// PR15845
int foo(xxx); // expected-error{{unknown type name}}
struct cls {
char *m;
};
char * cls::* __uptr wrong2 = &cls::m; // expected-error {{'__uptr' attribute cannot be used with pointers to members}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/variadic-promotion.c
|
// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
void variadic(int, ...);
void test_floating_promotion(__fp16 *f16, float f32, double f64) {
variadic(3, *f16, f32, f64);
// CHECK: ImplicitCastExpr {{.*}} 'double' <FloatingCast>
// CHECK-NEXT: '__fp16'
// CHECK: ImplicitCastExpr {{.*}} 'double' <FloatingCast>
// CHECK-NEXT: 'float'
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/const-ptr-int-ptr-cast.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
// expected-no-diagnostics
#include <stdint.h>
char *a = (void*)(uintptr_t)(void*)&a;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/aarch64-neon-ranges.c
|
// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -ffreestanding -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -ffreestanding -fsyntax-only -verify %s
#include <arm_neon.h>
void test_vext_8bit(int8x8_t small, int8x16_t big) {
vext_s8(small, small, 7);
vext_u8(small, small, 7);
vext_p8(small, small, 7);
vextq_s8(big, big, 15);
vextq_u8(big, big, 15);
vextq_p8(big, big, 15);
vext_s8(small, small, 8); // expected-error {{argument should be a value from 0 to 7}}
vext_u8(small, small, 8); // expected-error {{argument should be a value from 0 to 7}}
vext_p8(small, small, 8); // expected-error {{argument should be a value from 0 to 7}}
vextq_s8(big, big, 16); // expected-error {{argument should be a value from 0 to 15}}
vextq_u8(big, big, 16); // expected-error {{argument should be a value from 0 to 15}}
vextq_p8(big, big, 16); // expected-error {{argument should be a value from 0 to 15}}
}
void test_mul_lane_f64(float64x1_t small, float64x2_t big, float64x2_t rhs) {
vmul_lane_f64(small, small, 0);
vmul_laneq_f64(small, big, 1);
vmulq_lane_f64(big, small, 0);
vmulq_laneq_f64(big, big, 1);
vfma_lane_f64(small, small, small, 0);
vfma_laneq_f64(small, small, big, 1);
vfmaq_lane_f64(big, big, small, 0);
vfmaq_laneq_f64(big, big, big, 1);
vmul_lane_f64(small, small, 1); // expected-error {{argument should be a value from 0 to 0}}
vmul_laneq_f64(small, big, 2); // expected-error {{argument should be a value from 0 to 1}}
vfma_lane_f64(small, small, small, 1); // expected-error {{argument should be a value from 0 to 0}}
vfma_laneq_f64(small, small, big, 2); // expected-error {{argument should be a value from 0 to 1}}
vfmaq_laneq_f64(big, big, big, 2); // expected-error {{argument should be a value from 0 to 1}}
}
void test_ld1st1(int8x8_t small, int8x16_t big, void *addr) {
vld1_lane_s8(addr, small, 7);
vld1_lane_s16(addr, small, 3);
vld1_lane_s32(addr, small, 1);
vld1_lane_s64(addr, small, 0);
vld1q_lane_s8(addr, big, 15);
vld1q_lane_s16(addr, big, 7);
vld1q_lane_s32(addr, big, 3);
vld1q_lane_s64(addr, big, 1);
vld1_lane_s8(addr, small, 8); // expected-error {{argument should be a value from 0 to 7}}
vld1_lane_s16(addr, small, 4); // expected-error {{argument should be a value from 0 to 3}}
vld1_lane_s32(addr, small, 2); // expected-error {{argument should be a value from 0 to 1}}
vld1_lane_s64(addr, small, 1); // expected-error {{argument should be a value from 0 to 0}}
vld1q_lane_s8(addr, big, 16); // expected-error {{argument should be a value from 0 to 15}}
vld1q_lane_s16(addr, big, 8); // expected-error {{argument should be a value from 0 to 7}}
vld1q_lane_s32(addr, big, 4); // expected-error {{argument should be a value from 0 to 3}}
vld1q_lane_s64(addr, big, 2); // expected-error {{argument should be a value from 0 to 1}}
vst1_lane_s8(addr, small, 7);
vst1_lane_s16(addr, small, 3);
vst1_lane_s32(addr, small, 1);
vst1_lane_s64(addr, small, 0);
vst1q_lane_s8(addr, big, 15);
vst1q_lane_s16(addr, big, 7);
vst1q_lane_s32(addr, big, 3);
vst1q_lane_s64(addr, big, 1);
vst1_lane_s8(addr, small, 8); // expected-error {{argument should be a value from 0 to 7}}
vst1_lane_s16(addr, small, 4); // expected-error {{argument should be a value from 0 to 3}}
vst1_lane_s32(addr, small, 2); // expected-error {{argument should be a value from 0 to 1}}
vst1_lane_s64(addr, small, 1); // expected-error {{argument should be a value from 0 to 0}}
vst1q_lane_s8(addr, big, 16); // expected-error {{argument should be a value from 0 to 15}}
vst1q_lane_s16(addr, big, 8); // expected-error {{argument should be a value from 0 to 7}}
vst1q_lane_s32(addr, big, 4); // expected-error {{argument should be a value from 0 to 3}}
vst1q_lane_s64(addr, big, 2); // expected-error {{argument should be a value from 0 to 1}}
}
void test_ld2st2(int8x8x2_t small8, int8x16x2_t big8,
int16x4x2_t small16, int16x8x2_t big16,
int32x2x2_t small32, int32x4x2_t big32,
int64x1x2_t small64, int64x2x2_t big64,
void *addr) {
vld2_lane_s8(addr, small8, 7);
vld2_lane_s16(addr, small16, 3);
vld2_lane_s32(addr, small32, 1);
vld2_lane_s64(addr, small64, 0);
vld2q_lane_s8(addr, big8, 15);
vld2q_lane_s16(addr, big16, 7);
vld2q_lane_s32(addr, big32, 3);
vld2q_lane_s64(addr, big64, 1);
vld2_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
vld2_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
vld2_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
vld2_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
vld2q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
vld2q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
vld2q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
vld2q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
vst2_lane_s8(addr, small8, 7);
vst2_lane_s16(addr, small16, 3);
vst2_lane_s32(addr, small32, 1);
vst2_lane_s64(addr, small64, 0);
vst2q_lane_s8(addr, big8, 15);
vst2q_lane_s16(addr, big16, 7);
vst2q_lane_s32(addr, big32, 3);
vst2q_lane_s64(addr, big64, 1);
vst2_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
vst2_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
vst2_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
vst2_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
vst2q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
vst2q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
vst2q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
vst2q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
}
void test_ld3st3(int8x8x3_t small8, int8x16x3_t big8,
int16x4x3_t small16, int16x8x3_t big16,
int32x2x3_t small32, int32x4x3_t big32,
int64x1x3_t small64, int64x2x3_t big64,
void *addr) {
vld3_lane_s8(addr, small8, 7);
vld3_lane_s16(addr, small16, 3);
vld3_lane_s32(addr, small32, 1);
vld3_lane_s64(addr, small64, 0);
vld3q_lane_s8(addr, big8, 15);
vld3q_lane_s16(addr, big16, 7);
vld3q_lane_s32(addr, big32, 3);
vld3q_lane_s64(addr, big64, 1);
vld3_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
vld3_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
vld3_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
vld3_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
vld3q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
vld3q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
vld3q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
vld3q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
vst3_lane_s8(addr, small8, 7);
vst3_lane_s16(addr, small16, 3);
vst3_lane_s32(addr, small32, 1);
vst3_lane_s64(addr, small64, 0);
vst3q_lane_s8(addr, big8, 15);
vst3q_lane_s16(addr, big16, 7);
vst3q_lane_s32(addr, big32, 3);
vst3q_lane_s64(addr, big64, 1);
vst3_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
vst3_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
vst3_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
vst3_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
vst3q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
vst3q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
vst3q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
vst3q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
}
void test_ld4st4(int8x8x4_t small8, int8x16x4_t big8,
int16x4x4_t small16, int16x8x4_t big16,
int32x2x4_t small32, int32x4x4_t big32,
int64x1x4_t small64, int64x2x4_t big64,
void *addr) {
vld4_lane_s8(addr, small8, 7);
vld4_lane_s16(addr, small16, 3);
vld4_lane_s32(addr, small32, 1);
vld4_lane_s64(addr, small64, 0);
vld4q_lane_s8(addr, big8, 15);
vld4q_lane_s16(addr, big16, 7);
vld4q_lane_s32(addr, big32, 3);
vld4q_lane_s64(addr, big64, 1);
vld4_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
vld4_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
vld4_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
vld4_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
vld4q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
vld4q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
vld4q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
vld4q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
vst4_lane_s8(addr, small8, 7);
vst4_lane_s16(addr, small16, 3);
vst4_lane_s32(addr, small32, 1);
vst4_lane_s64(addr, small64, 0);
vst4q_lane_s8(addr, big8, 15);
vst4q_lane_s16(addr, big16, 7);
vst4q_lane_s32(addr, big32, 3);
vst4q_lane_s64(addr, big64, 1);
vst4_lane_s8(addr, small8, 8); // expected-error {{argument should be a value from 0 to 7}}
vst4_lane_s16(addr, small16, 4); // expected-error {{argument should be a value from 0 to 3}}
vst4_lane_s32(addr, small32, 2); // expected-error {{argument should be a value from 0 to 1}}
vst4_lane_s64(addr, small64, 1); // expected-error {{argument should be a value from 0 to 0}}
vst4q_lane_s8(addr, big8, 16); // expected-error {{argument should be a value from 0 to 15}}
vst4q_lane_s16(addr, big16, 8); // expected-error {{argument should be a value from 0 to 7}}
vst4q_lane_s32(addr, big32, 4); // expected-error {{argument should be a value from 0 to 3}}
vst4q_lane_s64(addr, big64, 2); // expected-error {{argument should be a value from 0 to 1}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/struct-compat.c
|
/* RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify
*/
extern struct {int a;} x; // expected-note {{previous declaration is here}}
extern struct {int a;} x; // expected-error {{redeclaration of 'x'}}
struct x;
int a(struct x* b) {
// Per C99 6.7.2.3, since the outer and inner "struct x"es have different
// scopes, they don't refer to the same type, and are therefore incompatible
struct x {int a;} *c = b; // expected-warning {{incompatible pointer types}}
}
struct x {int a;} r;
int b() {
struct x {char x;} s = r; // expected-error {{initializing 'struct x' with an expression of incompatible type 'struct x'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/i386-linux-android.c
|
// RUN: %clang_cc1 -triple i386-linux-android -fsyntax-only -verify %s
// expected-no-diagnostics
extern int a1_0[sizeof(long double) == 8 ? 1 : -1];
extern int a1_i[__alignof(long double) == 4 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/varargs.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
class string;
void f(const string& s, ...) { // expected-note {{parameter of type 'const string &' is declared here}}
__builtin_va_list ap;
__builtin_va_start(ap, s); // expected-warning {{'va_start' has undefined behavior with reference types}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/wchar.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify
// RUN: %clang_cc1 %s -fsyntax-only -fshort-wchar -verify -DSHORT_WCHAR
typedef __WCHAR_TYPE__ wchar_t;
#if defined(_WIN32) || defined(_M_IX86) || defined(__CYGWIN__) \
|| defined(_M_X64) || defined(__PS4__) || defined(SHORT_WCHAR)
#define WCHAR_T_TYPE unsigned short
#elif defined(__arm) || defined(__aarch64__)
#define WCHAR_T_TYPE unsigned int
#elif defined(__sun)
#define WCHAR_T_TYPE long
#else /* Solaris. */
#define WCHAR_T_TYPE int
#endif
int check_wchar_size[sizeof(*L"") == sizeof(wchar_t) ? 1 : -1];
void foo() {
WCHAR_T_TYPE t1[] = L"x";
wchar_t tab[] = L"x";
WCHAR_T_TYPE t2[] = "x"; // expected-error {{initializing wide char array with non-wide string literal}}
char t3[] = L"x"; // expected-error {{initializing char array with wide string literal}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/init-struct-qualified.c
|
// RUN: %clang_cc1 -fsyntax-only -verify < %s
// expected-no-diagnostics
typedef float CGFloat;
typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint;
typedef struct _NSSize { CGFloat width; CGFloat height; } NSSize;
typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
extern const NSPoint NSZeroPoint;
extern NSSize canvasSize();
void func() {
const NSRect canvasRect = { NSZeroPoint, canvasSize() };
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pointer-subtract-compat.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
typedef const char rchar;
int a(char* a, rchar* b) {
return a-b;
}
// <rdar://problem/6520707>
void f0(void (*fp)(void)) {
int x = fp - fp; // expected-warning{{arithmetic on pointers to the function type 'void (void)' is a GNU extension}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/predefined-function.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
char *funk(int format);
enum Test {A=-1};
char *funk(enum Test x);
int eli(float b); // expected-note {{previous declaration is here}} \
// expected-note{{passing argument to parameter 'b' here}}
int b(int c) {return 1;}
int foo();
int foo() {
int eli(int (int)); // expected-error {{conflicting types for 'eli'}}
eli(b); // expected-error{{passing 'int (int)' to parameter of incompatible type 'float'}}
return 0;
}
int bar();
int bar(int i) // expected-note {{previous definition is here}}
{
return 0;
}
int bar() // expected-error {{redefinition of 'bar'}}
{
return 0;
}
int foobar(int); // note {{previous declaration is here}}
int foobar() // error {{conflicting types for 'foobar'}}
{
return 0;
}
int wibble(); // expected-note {{previous declaration is here}}
float wibble() // expected-error {{conflicting types for 'wibble'}}
{
return 0.0f;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/2007-10-01-BuildArrayRef.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR 1603
void func()
{
const int *arr;
arr[0] = 1; // expected-error {{read-only variable is not assignable}}
}
struct foo {
int bar;
};
struct foo sfoo = { 0 };
int func2()
{
const struct foo *fp;
fp = &sfoo;
fp[0].bar = 1; // expected-error {{read-only variable is not assignable}}
return sfoo.bar;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/sign-conversion.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wsign-conversion %s
// PR9345: make a subgroup of -Wconversion for signedness changes
void test(int x) {
unsigned t0 = x; // expected-warning {{implicit conversion changes signedness}}
unsigned t1 = (t0 == 5 ? x : 0); // expected-warning {{operand of ? changes signedness}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/arg-duplicate.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
int f3(y, x,
x) // expected-error {{redefinition of parameter}}
int y,
x, // expected-note {{previous declaration is here}}
x; // expected-error {{redefinition of parameter}}
{
return x + y;
}
void f4(void) {
f3 (1, 1, 2, 3, 4); // expected-warning{{too many arguments}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/variadic-block.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks
// expected-no-diagnostics
#include <stdarg.h>
int main(int argc, char *argv[]) {
long (^addthem)(const char *, ...) = ^long (const char *format, ...){
va_list argp;
const char *p;
int i;
char c;
double d;
long result = 0;
va_start(argp, format);
for (p = format; *p; p++) switch (*p) {
case 'i':
i = va_arg(argp, int);
result += i;
break;
case 'd':
d = va_arg(argp, double);
result += (int)d;
break;
case 'c':
c = va_arg(argp, int);
result += c;
break;
}
return result;
};
long testresult = addthem("ii", 10, 20);
if (testresult != 30) {
return 1;
}
testresult = addthem("idc", 30, 40.0, 'a');
if (testresult != (70+'a')) {
return 1;
}
return 0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-ms_struct.c
|
// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify -triple x86_64-apple-darwin9 %s
#pragma ms_struct on
#pragma ms_struct off
#pragma ms_struct reset
#pragma ms_struct // expected-warning {{incorrect use of '#pragma ms_struct on|off' - ignored}}
#pragma ms_struct on top of spaghetti // expected-warning {{extra tokens at end of '#pragma ms_struct' - ignored}}
struct foo
{
int a;
int b;
char c;
};
struct {
unsigned long bf_1 : 12;
unsigned long : 0;
unsigned long bf_2 : 12;
} __attribute__((__ms_struct__)) t1;
struct S {
double __attribute__((ms_struct)) d; // expected-warning {{'ms_struct' attribute only applies to struct or union}}
unsigned long bf_1 : 12;
unsigned long : 0;
unsigned long bf_2 : 12;
} __attribute__((ms_struct)) t2;
enum
{
A = 0,
B,
C
} __attribute__((ms_struct)) e1; // expected-warning {{'ms_struct' attribute only applies to struct or union}}
// rdar://10513599
#pragma ms_struct on
typedef struct
{
void *pv;
int l;
} Foo;
typedef struct
{
void *pv1;
Foo foo;
unsigned short fInited : 1;
void *pv2;
} PackOddity;
#pragma ms_struct off
static int arr[sizeof(PackOddity) == 40 ? 1 : -1];
struct __declspec(ms_struct) bad { // expected-warning {{__declspec attribute 'ms_struct' is not supported}}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/callingconv-ms_abi.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-win32 %s
void __attribute__((ms_abi)) foo(void);
void (*pfoo)(void) = foo;
void __attribute__((sysv_abi)) bar(void);
void (*pbar)(void) = bar; // expected-warning{{incompatible pointer types}}
void (__attribute__((sysv_abi)) *pfoo2)(void) = foo; // expected-warning{{incompatible pointer types}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtins-arm.c
|
// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple armv7 -target-abi apcs-gnu \
// RUN: -fsyntax-only -verify %s
void f(void *a, void *b) {
__clear_cache(); // expected-error {{too few arguments to function call, expected 2, have 0}} // expected-note {{'__clear_cache' is a builtin with type 'void (void *, void *)}}
__clear_cache(a); // expected-error {{too few arguments to function call, expected 2, have 1}}
__clear_cache(a, b);
}
void __clear_cache(char*, char*); // expected-error {{conflicting types for '__clear_cache'}}
void __clear_cache(void*, void*);
#if defined(__ARM_PCS) || defined(__ARM_EABI__)
// va_list on ARM AAPCS is struct { void* __ap }.
void test1() {
__builtin_va_list ptr;
ptr.__ap = "x";
*(ptr.__ap) = '0'; // expected-error {{incomplete type 'void' is not assignable}}
}
#else
// va_list on ARM apcs-gnu is void*.
void test1() {
__builtin_va_list ptr;
ptr.__ap = "x"; // expected-error {{member reference base type '__builtin_va_list' is not a structure or union}}
*(ptr.__ap) = '0';// expected-error {{member reference base type '__builtin_va_list' is not a structure or union}}
}
void test2() {
__builtin_va_list ptr = "x";
*ptr = '0'; // expected-error {{incomplete type 'void' is not assignable}}
}
#endif
void test3() {
__builtin_arm_dsb(16); // expected-error {{argument should be a value from 0 to 15}}
__builtin_arm_dmb(17); // expected-error {{argument should be a value from 0 to 15}}
__builtin_arm_isb(18); // expected-error {{argument should be a value from 0 to 15}}
}
void test4() {
__builtin_arm_prefetch(0, 2, 0); // expected-error {{argument should be a value from 0 to 1}}
__builtin_arm_prefetch(0, 0, 2); // expected-error {{argument should be a value from 0 to 1}}
}
void test5() {
__builtin_arm_dbg(16); // expected-error {{argument should be a value from 0 to 15}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/incomplete-call.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct foo; // expected-note 3 {{forward declaration of 'struct foo'}}
struct foo a(); // expected-note {{'a' declared here}}
void b(struct foo);
void c();
void func(void *p) {
a(); // expected-error{{calling 'a' with incomplete return type 'struct foo'}}
b(*(struct foo*)p); // expected-error{{argument type 'struct foo' is incomplete}}
c(*(struct foo*)p); // expected-error{{argument type 'struct foo' is incomplete}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/implicit-builtin-freestanding.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding %s
// expected-no-diagnostics
int malloc(int a) { return a; }
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtins-gnu-mode.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 %s
// PR16138
// expected-no-diagnostics
int alloca;
int stpcpy;
int stpncpy;
int strdup;
int strndup;
int index;
int rindex;
int bzero;
int strcasecmp;
int strncasecmp;
int _exit;
int _longjmp;
int siglongjmp;
int strlcpy;
int strlcat;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-format_arg.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
int printf(const char *, ...);
const char* f(const char *s) __attribute__((format_arg(1)));
void g(const char *s) {
printf("%d", 123);
printf("%d %d", 123); // expected-warning{{more '%' conversions than data arguments}}
printf(f("%d"), 123);
printf(f("%d %d"), 123); // expected-warning{{more '%' conversions than data arguments}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-shadow.c
|
// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -Wshadow %s
int i; // expected-note 3 {{previous declaration is here}}
void foo() {
int pass1;
int i; // expected-warning {{declaration shadows a variable in the global scope}} \
// expected-note {{previous declaration is here}}
{
int pass2;
int i; // expected-warning {{declaration shadows a local variable}} \
// expected-note {{previous declaration is here}}
{
int pass3;
int i; // expected-warning {{declaration shadows a local variable}}
}
}
int sin; // okay; 'sin' has not been declared, even though it's a builtin.
}
// <rdar://problem/7677531>
void (^test1)(int) = ^(int i) { // expected-warning {{declaration shadows a variable in the global scope}} \
// expected-note{{previous declaration is here}}
{
int i; // expected-warning {{declaration shadows a local variable}} \
// expected-note{{previous declaration is here}}
(^(int i) { return i; })(i); //expected-warning {{declaration shadows a local variable}}
}
};
struct test2 {
int i;
};
void test3(void) {
struct test4 {
int i;
};
}
void test4(int i) { // expected-warning {{declaration shadows a variable in the global scope}}
}
// Don't warn about shadowing for function declarations.
void test5(int i);
void test6(void (*f)(int i)) {}
void test7(void *context, void (*callback)(void *context)) {}
extern int bob; // expected-note {{previous declaration is here}}
// rdar://8883302
void rdar8883302() {
extern int bob; // don't warn for shadowing.
}
void test8() {
int bob; // expected-warning {{declaration shadows a variable in the global scope}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/complex-init-list.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
// This file tests the clang extension which allows initializing the components
// of a complex number individually using an initialization list. Basically,
// if you have an explicit init list for a complex number that contains two
// initializers, this extension kicks in to turn it into component-wise
// initialization.
//
// This extension is useful because there isn't any way to accurately build
// a complex number at the moment besides setting the components with
// __real__ and __imag__, which is inconvenient and not usable for constants.
// (Of course, there are other extensions we could implement that would
// allow this, like some sort of __builtin_build_complex.)
//
// FIXME: It would be a good idea to have a warnings for implicit
// real->complex and complex->real conversions; as-is, it's way too easy
// to get implicit conversions when they are not intended.
// Basic testcase
_Complex float valid1 = { 1.0f, 2.0f }; // expected-warning {{specifying real and imaginary components is an extension}}
// Struct for nesting tests
struct teststruct { _Complex float x; };
// Random other valid stuff
_Complex int valid2 = { 1, 2 }; // expected-warning {{complex integer}} expected-warning {{specifying real and imaginary components is an extension}}
struct teststruct valid3 = { { 1.0f, 2.0f} }; // expected-warning {{specifying real and imaginary components is an extension}}
_Complex float valid4[2] = { {1.0f, 1.0f}, {1.0f, 1.0f} }; // expected-warning 2 {{specifying real and imaginary components is an extension}}
// FIXME: We need some sort of warning for valid5
_Complex float valid5 = {1.0f, 1.0fi}; // expected-warning {{imaginary constants}} expected-warning {{specifying real and imaginary components is an extension}}
// Random invalid stuff
struct teststruct invalid1 = { 1, 2 }; // expected-warning {{excess elements}}
_Complex float invalid2 = { 1, 2, 3 }; // expected-warning {{excess elements}}
_Complex float invalid3 = {}; // expected-error {{scalar initializer cannot be empty}} expected-warning {{GNU empty initializer}}
// Check incomplete array sizing
_Complex float sizetest1[] = { {1.0f, 1.0f}, {1.0f, 1.0f} }; // expected-warning 2 {{specifying real and imaginary components is an extension}}
_Complex float sizecheck1[(sizeof(sizetest1) == sizeof(*sizetest1)*2) ? 1 : -1];
_Complex float sizetest2[] = { 1.0f, 1.0f, {1.0f, 1.0f} }; // expected-warning {{specifying real and imaginary components is an extension}}
_Complex float sizecheck2[(sizeof(sizetest2) == sizeof(*sizetest2)*3) ? 1 : -1];
// Constant-folding with init list.
_Complex float x = 2 + (_Complex float) { 1, 2 }; // expected-warning {{specifying real and imaginary components is an extension}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/predef.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void abcdefghi12(void) {
const char (*ss)[12] = &__func__;
static int arr[sizeof(__func__)==12 ? 1 : -1];
}
char *X = __func__; // expected-warning {{predefined identifier is only valid}} \
expected-warning {{initializing 'char *' with an expression of type 'const char [1]' discards qualifiers}}
void a() {
__func__[0] = 'a'; // expected-error {{variable is not assignable}}
}
// rdar://6097892 - GCC permits this insanity.
const char *b = __func__; // expected-warning {{predefined identifier is only valid}}
const char *c = __FUNCTION__; // expected-warning {{predefined identifier is only valid}}
const char *d = __PRETTY_FUNCTION__; // expected-warning {{predefined identifier is only valid}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/missing-field-initializers.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-field-initializers %s
// This was PR4808.
struct Foo { int a, b; };
struct Foo foo0 = { 1 }; // expected-warning {{missing field 'b' initializer}}
struct Foo foo1 = { .a = 1 }; // designator avoids MFI warning
struct Foo foo2 = { .b = 1 }; // designator avoids MFI warning
struct Foo bar0[] = {
{ 1,2 },
{ 1 }, // expected-warning {{missing field 'b' initializer}}
{ 1,2 }
};
struct Foo bar1[] = {
1, 2,
1, 2,
1
}; // expected-warning {{missing field 'b' initializer}}
struct Foo bar2[] = { {}, {}, {} };
struct One { int a; int b; };
struct Two { float c; float d; float e; };
struct Three {
union {
struct One one;
struct Two two;
} both;
};
struct Three t0 = {
{ .one = { 1, 2 } }
};
struct Three t1 = {
{ .two = { 1.0f, 2.0f, 3.0f } }
};
struct Three data[] = {
{ { .one = { 1, 2 } } },
{ { .one = { 1 } } }, // expected-warning {{missing field 'b' initializer}}
{ { .two = { 1.0f, 2.0f, 3.0f } } },
{ { .two = { 1.0f, 2.0f } } } // expected-warning {{missing field 'e' initializer}}
};
struct { int:5; int a; int:5; int b; int:5; } noNamedImplicit[] = {
{ 1, 2 },
{ 1 } // expected-warning {{missing field 'b' initializer}}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/x86_64-linux-android.c
|
// RUN: %clang_cc1 -triple x86_64-linux-android -emit-pch -o %t %s
// RUN: %clang_cc1 -x ast -ast-print %t | FileCheck %s
// REQUIRES: x86-registered-target
extern int a1_0[sizeof(long double) == 16 ? 1 : -1];
extern int a1_i[__alignof(long double) == 16 ? 1 : -1];
// Verify that long double is 128 bit IEEEquad
long double foo = 1.0E4000L;
// CHECK: long double foo = 1.00000000000000000000000000000000004E+4000L;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/memset-invalid-1.c
|
// RUN: %clang_cc1 -fsyntax-only %s -verify
// rdar://13081751
typedef __SIZE_TYPE__ size_t;
void *memset(void*, int, size_t);
typedef struct __incomplete *incomplete;
void mt_query_for_domain(const char *domain)
{
incomplete query = 0;
memset(query, 0, sizeof(query)); // expected-warning {{'memset' call operates on objects of type 'struct __incomplete' while the size is based on a different type 'incomplete'}} \
// expected-note {{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/big-endian-neon-initializers.c
|
// RUN: %clang_cc1 %s -triple aarch64_be -target-feature +neon -verify -fsyntax-only -ffreestanding
// RUN: %clang_cc1 %s -triple armebv7 -target-cpu cortex-a8 -verify -fsyntax-only -ffreestanding
#include <arm_neon.h>
int32x4_t x = {1, 2, 3, 4}; // expected-warning{{vector initializers are not compatible with NEON intrinsics}} expected-note{{consider using vld1q_s32() to initialize a vector from memory, or vcombine_s32(vcreate_s32(), vcreate_s32()) to initialize from integer constants}}
int16x4_t y = {1, 2, 3, 4}; // expected-warning{{vector initializers are not compatible with NEON intrinsics}} expected-note{{consider using vld1_s16() to initialize a vector from memory, or vcreate_s16() to initialize from an integer constant}}
int64x2_t z = {1, 2}; // expected-warning{{vector initializers are not compatible with NEON intrinsics}} expected-note{{consider using vld1q_s64() to initialize a vector from memory, or vcombine_s64(vcreate_s64(), vcreate_s64()) to initialize from integer constants}}
float32x2_t b = {1, 2}; // expected-warning{{vector initializers are not compatible with NEON intrinsics}} expected-note{{consider using vld1_f32() to initialize a vector from memory, or vcreate_f32() to initialize from an integer constant}}
// No warning expected here.
typedef int v4si __attribute__ ((vector_size (16)));
v4si c = {1, 2, 3, 4};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-unused-label.c
|
// RUN: %clang_cc1 -fsyntax-only -Wunused-label -verify %s
void f() {
a:
goto a;
b: // expected-warning{{unused}}
c: __attribute__((unused));
d: __attribute__((noreturn)); // expected-warning {{'noreturn' attribute only applies to functions}}
goto d;
return;
}
void PR8455() {
L: __attribute__((unused)) return; // ok, no semicolon required
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtins.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wstrlcpy-strlcat-size -Wno-string-plus-int -triple=i686-apple-darwin9
// This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si
int test1(float a, int b) {
return __builtin_isless(a, b); // expected-note {{declared here}}
}
int test2(int a, int b) {
return __builtin_islessequal(a, b); // expected-error {{floating point type}}
}
int test3(double a, float b) {
return __builtin_isless(a, b);
}
int test4(int* a, double b) {
return __builtin_islessequal(a, b); // expected-error {{floating point type}}
}
int test5(float a, long double b) {
return __builtin_isless(a, b, b); // expected-error {{too many arguments}}
}
int test6(float a, long double b) {
return __builtin_islessequal(a); // expected-error {{too few arguments}}
}
#define CFSTR __builtin___CFStringMakeConstantString
void test7() {
const void *X;
X = CFSTR("\242"); // expected-warning {{input conversion stopped}}
X = CFSTR("\0"); // no-warning
X = CFSTR(242); // expected-error {{CFString literal is not a string constant}} expected-warning {{incompatible integer to pointer conversion}}
X = CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
}
// atomics.
void test9(short v) {
unsigned i, old;
old = __sync_fetch_and_add(); // expected-error {{too few arguments to function call}}
old = __sync_fetch_and_add(&old); // expected-error {{too few arguments to function call}}
old = __sync_fetch_and_add((unsigned*)0, 42i); // expected-warning {{imaginary constants are a GNU extension}}
// PR7600: Pointers are implicitly casted to integers and back.
void *old_ptr = __sync_val_compare_and_swap((void**)0, 0, 0);
// Ensure the return type is correct even when implicit casts are stripped
// away. This triggers an assertion while checking the comparison otherwise.
if (__sync_fetch_and_add(&old, 1) == 1) {
}
}
// overloaded atomics should be declared only once.
void test9_1(volatile int* ptr, int val) {
__sync_fetch_and_add_4(ptr, val);
}
void test9_2(volatile int* ptr, int val) {
__sync_fetch_and_add(ptr, val);
}
void test9_3(volatile int* ptr, int val) {
__sync_fetch_and_add_4(ptr, val);
__sync_fetch_and_add(ptr, val);
__sync_fetch_and_add(ptr, val);
__sync_fetch_and_add_4(ptr, val);
__sync_fetch_and_add_4(ptr, val);
}
void test9_4(volatile int* ptr, int val) {
// expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}}
__sync_fetch_and_nand(ptr, val);
}
// rdar://7236819
void test10(void) __attribute__((noreturn));
void test10(void) {
__asm__("int3");
__builtin_unreachable();
// No warning about falling off the end of a noreturn function.
}
void test11(int X) {
switch (X) {
case __builtin_eh_return_data_regno(0): // constant foldable.
break;
}
__builtin_eh_return_data_regno(X); // expected-error {{argument to '__builtin_eh_return_data_regno' must be a constant integer}}
}
// PR5062
void test12(void) __attribute__((__noreturn__));
void test12(void) {
__builtin_trap(); // no warning because trap is noreturn.
}
void test_unknown_builtin(int a, int b) {
__builtin_isles(a, b); // expected-error{{use of unknown builtin}} \
// expected-note{{did you mean '__builtin_isless'?}}
}
int test13() {
__builtin_eh_return(0, 0); // no warning, eh_return never returns.
}
// <rdar://problem/8228293>
void test14() {
int old;
old = __sync_fetch_and_min((volatile int *)&old, 1);
}
// <rdar://problem/8336581>
void test15(const char *s) {
__builtin_printf("string is %s\n", s);
}
// PR7885
int test16() {
return __builtin_constant_p() + // expected-error{{too few arguments}}
__builtin_constant_p(1, 2); // expected-error {{too many arguments}}
}
const int test17_n = 0;
const char test17_c[] = {1, 2, 3, 0};
const char test17_d[] = {1, 2, 3, 4};
typedef int __attribute__((vector_size(16))) IntVector;
struct Aggregate { int n; char c; };
enum Enum { EnumValue1, EnumValue2 };
typedef __typeof(sizeof(int)) size_t;
size_t strlen(const char *);
void test17() {
#define ASSERT(...) { int arr[(__VA_ARGS__) ? 1 : -1]; }
#define T(...) ASSERT(__builtin_constant_p(__VA_ARGS__))
#define F(...) ASSERT(!__builtin_constant_p(__VA_ARGS__))
// __builtin_constant_p returns 1 if the argument folds to:
// - an arithmetic constant with value which is known at compile time
T(test17_n);
T(&test17_c[3] - test17_c);
T(3i + 5); // expected-warning {{imaginary constant}}
T(4.2 * 7.6);
T(EnumValue1);
T((enum Enum)(int)EnumValue2);
// - the address of the first character of a string literal, losslessly cast
// to any type
T("string literal");
T((double*)"string literal");
T("string literal" + 0);
T((long)"string literal");
// ... and otherwise returns 0.
F("string literal" + 1);
F(&test17_n);
F(test17_c);
F(&test17_c);
F(&test17_d);
F((struct Aggregate){0, 1});
F((IntVector){0, 1, 2, 3});
// Ensure that a technique used in glibc is handled correctly.
#define OPT(...) (__builtin_constant_p(__VA_ARGS__) && strlen(__VA_ARGS__) < 4)
// FIXME: These are incorrectly treated as ICEs because strlen is treated as
// a builtin.
ASSERT(OPT("abc"));
ASSERT(!OPT("abcd"));
// In these cases, the strlen is non-constant, but the __builtin_constant_p
// is 0: the array size is not an ICE but is foldable.
ASSERT(!OPT(test17_c)); // expected-warning {{folded}}
ASSERT(!OPT(&test17_c[0])); // expected-warning {{folded}}
ASSERT(!OPT((char*)test17_c)); // expected-warning {{folded}}
ASSERT(!OPT(test17_d)); // expected-warning {{folded}}
ASSERT(!OPT(&test17_d[0])); // expected-warning {{folded}}
ASSERT(!OPT((char*)test17_d)); // expected-warning {{folded}}
#undef OPT
#undef T
#undef F
}
void test18() {
char src[1024];
char dst[2048];
size_t result;
void *ptr;
ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src), sizeof(dst));
result = __builtin___strlcpy_chk(dst, src, sizeof(dst), sizeof(dst));
result = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst));
ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src)); // expected-error {{too few arguments to function call}}
ptr = __builtin___strlcpy_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
ptr = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-warning {{incompatible integer to pointer conversion}}
}
void no_ms_builtins() {
__assume(1); // expected-warning {{implicit declaration}}
__noop(1); // expected-warning {{implicit declaration}}
__debugbreak(); // expected-warning {{implicit declaration}}
}
void unavailable() {
__builtin_operator_new(0); // expected-error {{'__builtin_operator_new' is only available in C++}}
__builtin_operator_delete(0); // expected-error {{'__builtin_operator_delete' is only available in C++}}
}
// rdar://18259539
size_t strlcpy(char * restrict dst, const char * restrict src, size_t size);
size_t strlcat(char * restrict dst, const char * restrict src, size_t size);
void Test19(void)
{
static char b[40];
static char buf[20];
strlcpy(buf, b, sizeof(b)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} \\
// expected-note {{change size argument to be the size of the destination}}
__builtin___strlcpy_chk(buf, b, sizeof(b), __builtin_object_size(buf, 0)); // expected-warning {{size argument in '__builtin___strlcpy_chk' call appears to be size of the source; expected the size of the destination}} \
// expected-note {{change size argument to be the size of the destination}} \
// expected-warning {{'__builtin___strlcpy_chk' will always overflow destination buffer}}
strlcat(buf, b, sizeof(b)); // expected-warning {{size argument in 'strlcat' call appears to be size of the source; expected the size of the destination}} \
// expected-note {{change size argument to be the size of the destination}}
__builtin___strlcat_chk(buf, b, sizeof(b), __builtin_object_size(buf, 0)); // expected-warning {{size argument in '__builtin___strlcat_chk' call appears to be size of the source; expected the size of the destination}} \
// expected-note {{change size argument to be the size of the destination}} \
// expected-warning {{'__builtin___strlcat_chk' will always overflow destination buffer}}
}
// rdar://11076881
char * Test20(char *p, const char *in, unsigned n)
{
static char buf[10];
__builtin___memcpy_chk (&buf[6], in, 5, __builtin_object_size (&buf[6], 0)); // expected-warning {{'__builtin___memcpy_chk' will always overflow destination buffer}}
__builtin___memcpy_chk (p, "abcde", n, __builtin_object_size (p, 0));
__builtin___memcpy_chk (&buf[5], "abcde", 5, __builtin_object_size (&buf[5], 0));
__builtin___memcpy_chk (&buf[5], "abcde", n, __builtin_object_size (&buf[5], 0));
__builtin___memcpy_chk (&buf[6], "abcde", 5, __builtin_object_size (&buf[6], 0)); // expected-warning {{'__builtin___memcpy_chk' will always overflow destination buffer}}
return buf;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-documentation-unknown-command.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation-unknown-command -verify %s
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Werror -Wno-documentation-unknown-command %s
// expected-warning@+1 {{unknown command tag name}}
/// aaa \unknown
int test_unknown_comand_1;
// expected-warning@+1 {{unknown command tag name 'retur'; did you mean 'return'?}}
/// \retur aaa
int test_unknown_comand_2();
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtins-ppc.c
|
// REQUIRES: powerpc-registered-target
// RUN: %clang_cc1 -faltivec -target-feature +htm \
// RUN: -triple powerpc64-unknown-unknown -DTEST_HTM -fsyntax-only \
// RUN: -verify %s
// RUN: %clang_cc1 -faltivec -target-feature +crypto \
// RUN: -triple powerpc64le-unknown-unknown -DTEST_CRYPTO -fsyntax-only \
// RUN: -verify %s
#ifdef TEST_HTM
void test_htm() {
__builtin_tbegin(4); // expected-error {{argument should be a value from 0 to 1}}
__builtin_tend(-1); // expected-error {{argument should be a value from 0 to 1}}
__builtin_tsr(55); // expected-error {{argument should be a value from 0 to 7}}
__builtin_tabortwc(-5, 2, 3); // expected-error {{argument should be a value from 0 to 31}}
__builtin_tabortdc(55, 2, 3); // expected-error {{argument should be a value from 0 to 31}}
__builtin_tabortwci(-5, 2, 5); // expected-error {{argument should be a value from 0 to 31}}
__builtin_tabortwci(5, 2, 55); // expected-error {{argument should be a value from 0 to 31}}
__builtin_tabortdci(-5, 2, 5); // expected-error {{argument should be a value from 0 to 31}}
__builtin_tabortdci(5, 2, 55); // expected-error {{argument should be a value from 0 to 31}}
}
#endif
#ifdef TEST_CRYPTO
#include <altivec.h>
#define W_INIT { 0x01020304, 0x05060708, 0x090A0B0C, 0x0D0E0F10 };
#define D_INIT { 0x0102030405060708, 0x090A0B0C0D0E0F10 };
vector unsigned int test_vshasigmaw_or(void)
{
vector unsigned int a = W_INIT
vector unsigned int b = __builtin_crypto_vshasigmaw(a, 2, 15); // expected-error {{argument should be a value from 0 to 1}}
vector unsigned int c = __builtin_crypto_vshasigmaw(a, -1, 15); // expected-error {{argument should be a value from 0 to 1}}
vector unsigned int d = __builtin_crypto_vshasigmaw(a, 0, 85); // expected-error {{argument should be a value from 0 to 15}}
vector unsigned int e = __builtin_crypto_vshasigmaw(a, 1, -15); // expected-error {{argument should be a value from 0 to 15}}
return __builtin_crypto_vshasigmaw(a, 1, 15);
}
vector unsigned long long test_vshasigmad_or(void)
{
vector unsigned long long a = D_INIT
vector unsigned long long b = __builtin_crypto_vshasigmad(a, 2, 15); // expected-error {{argument should be a value from 0 to 1}}
vector unsigned long long c = __builtin_crypto_vshasigmad(a, -1, 15); // expected-error {{argument should be a value from 0 to 1}}
vector unsigned long long d = __builtin_crypto_vshasigmad(a, 0, 85); // expected-error {{argument should be a value from 0 to 1}}
vector unsigned long long e = __builtin_crypto_vshasigmad(a, 1, -15); // expected-error {{argument should be a value from 0 to 1}}
return __builtin_crypto_vshasigmad(a, 0, 15);
}
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/uninit-variables.c
|
// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -Wconditional-uninitialized -fsyntax-only -fblocks %s -verify
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
int test1() {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
return x; // expected-warning{{variable 'x' is uninitialized when used here}}
}
int test2() {
int x = 0;
return x; // no-warning
}
int test3() {
int x;
x = 0;
return x; // no-warning
}
int test4() {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
++x; // expected-warning{{variable 'x' is uninitialized when used here}}
return x;
}
int test5() {
int x, y; // expected-note{{initialize the variable 'y' to silence this warning}}
x = y; // expected-warning{{variable 'y' is uninitialized when used here}}
return x;
}
int test6() {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
x += 2; // expected-warning{{variable 'x' is uninitialized when used here}}
return x;
}
int test7(int y) {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
if (y) // expected-warning{{variable 'x' is used uninitialized whenever 'if' condition is false}} \
// expected-note{{remove the 'if' if its condition is always true}}
x = 1;
return x; // expected-note{{uninitialized use occurs here}}
}
int test7b(int y) {
int x = x; // expected-note{{variable 'x' is declared here}}
if (y)
x = 1;
// Warn with "may be uninitialized" here (not "is sometimes uninitialized"),
// since the self-initialization is intended to suppress a -Wuninitialized
// warning.
return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
}
int test8(int y) {
int x;
if (y)
x = 1;
else
x = 0;
return x;
}
int test9(int n) {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
for (unsigned i = 0 ; i < n; ++i) {
if (i == n - 1)
break;
x = 1;
}
return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
}
int test10(unsigned n) {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
for (unsigned i = 0 ; i < n; ++i) {
x = 1;
}
return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
}
int test11(unsigned n) {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
for (unsigned i = 0 ; i <= n; ++i) {
x = 1;
}
return x; // expected-warning{{variable 'x' may be uninitialized when used here}}
}
void test12(unsigned n) {
for (unsigned i ; n ; ++i) ; // expected-warning{{variable 'i' is uninitialized when used here}} expected-note{{initialize the variable 'i' to silence this warning}}
}
int test13() {
static int i;
return i; // no-warning
}
// Simply don't crash on this test case.
void test14() {
const char *p = 0;
for (;;) {}
}
void test15() {
int x = x; // no-warning: signals intended lack of initialization.
}
int test15b() {
// Warn here with the self-init, since it does result in a use of
// an unintialized variable and this is the root cause.
int x = x; // expected-warning {{variable 'x' is uninitialized when used within its own initialization}}
return x;
}
// Don't warn in the following example; shows dataflow confluence.
char *test16_aux();
void test16() {
char *p = test16_aux();
for (unsigned i = 0 ; i < 100 ; i++)
p[i] = 'a'; // no-warning
}
void test17() {
// Don't warn multiple times about the same uninitialized variable
// along the same path.
int *x; // expected-note{{initialize the variable 'x' to silence this warning}}
*x = 1; // expected-warning{{variable 'x' is uninitialized when used here}}
*x = 1; // no-warning
}
int test18(int x, int y) {
int z;
if (x && y && (z = 1)) {
return z; // no-warning
}
return 0;
}
int test19_aux1();
int test19_aux2();
int test19_aux3(int *x);
int test19() {
int z;
if (test19_aux1() + test19_aux2() && test19_aux1() && test19_aux3(&z))
return z; // no-warning
return 0;
}
int test20() {
int z; // expected-note{{initialize the variable 'z' to silence this warning}}
if ((test19_aux1() + test19_aux2() && test19_aux1()) || test19_aux3(&z)) // expected-warning {{variable 'z' is used uninitialized whenever '||' condition is true}} expected-note {{remove the '||' if its condition is always false}}
return z; // expected-note {{uninitialized use occurs here}}
return 0;
}
int test21(int x, int y) {
int z; // expected-note{{initialize the variable 'z' to silence this warning}}
if ((x && y) || test19_aux3(&z) || test19_aux2()) // expected-warning {{variable 'z' is used uninitialized whenever '||' condition is true}} expected-note {{remove the '||' if its condition is always false}}
return z; // expected-note {{uninitialized use occurs here}}
return 0;
}
int test22() {
int z;
while (test19_aux1() + test19_aux2() && test19_aux1() && test19_aux3(&z))
return z; // no-warning
return 0;
}
int test23() {
int z;
for ( ; test19_aux1() + test19_aux2() && test19_aux1() && test19_aux3(&z) ; )
return z; // no-warning
return 0;
}
// The basic uninitialized value analysis doesn't have enough path-sensitivity
// to catch initializations relying on control-dependencies spanning multiple
// conditionals. This possibly can be handled by making the CFG itself
// represent such control-dependencies, but it is a niche case.
int test24(int flag) {
unsigned val; // expected-note{{initialize the variable 'val' to silence this warning}}
if (flag)
val = 1;
if (!flag)
val = 1;
return val; // expected-warning{{variable 'val' may be uninitialized when used here}}
}
float test25() {
float x; // expected-note{{initialize the variable 'x' to silence this warning}}
return x; // expected-warning{{variable 'x' is uninitialized when used here}}
}
typedef int MyInt;
MyInt test26() {
MyInt x; // expected-note{{initialize the variable 'x' to silence this warning}}
return x; // expected-warning{{variable 'x' is uninitialized when used here}}
}
// Test handling of sizeof().
int test27() {
struct test_27 { int x; } *y;
return sizeof(y->x); // no-warning
}
int test28() {
int len; // expected-note{{initialize the variable 'len' to silence this warning}}
return sizeof(int[len]); // expected-warning{{variable 'len' is uninitialized when used here}}
}
void test29() {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
(void) ^{ (void) x; }; // expected-warning{{variable 'x' is uninitialized when captured by block}}
}
void test30() {
static int x; // no-warning
(void) ^{ (void) x; };
}
void test31() {
__block int x; // no-warning
(void) ^{ (void) x; };
}
int test32_x;
void test32() {
(void) ^{ (void) test32_x; }; // no-warning
}
void test_33() {
int x; // no-warning
(void) x;
}
int test_34() {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
(void) x;
return x; // expected-warning{{variable 'x' is uninitialized when used here}}
}
// Test that this case doesn't crash.
void test35(int x) {
__block int y = 0;
^{ y = (x == 0); }();
}
// Test handling of indirect goto.
void test36()
{
void **pc; // expected-note{{initialize the variable 'pc' to silence this warning}}
void *dummy[] = { &&L1, &&L2 };
L1:
goto *pc; // expected-warning{{variable 'pc' is uninitialized when used here}}
L2:
goto *pc;
}
// Test && nested in ||.
int test37_a();
int test37_b();
int test37()
{
int identifier;
if ((test37_a() && (identifier = 1)) ||
(test37_b() && (identifier = 2))) {
return identifier; // no-warning
}
return 0;
}
// Test merging of path-specific dataflow values (without asserting).
int test38(int r, int x, int y)
{
int z;
return ((r < 0) || ((r == 0) && (x < y)));
}
int test39(int x) {
int y; // expected-note{{initialize the variable 'y' to silence this warning}}
int z = x + y; // expected-warning {{variable 'y' is uninitialized when used here}}
return z;
}
int test40(int x) {
int y; // expected-note{{initialize the variable 'y' to silence this warning}}
return x ? 1 : y; // expected-warning {{variable 'y' is uninitialized when used here}}
}
int test41(int x) {
int y; // expected-note{{initialize the variable 'y' to silence this warning}}
if (x) y = 1; // expected-warning{{variable 'y' is used uninitialized whenever 'if' condition is false}} \
// expected-note{{remove the 'if' if its condition is always true}}
return y; // expected-note{{uninitialized use occurs here}}
}
void test42() {
int a;
a = 30; // no-warning
}
void test43_aux(int x);
void test43(int i) {
int x; // expected-note{{initialize the variable 'x' to silence this warning}}
for (i = 0 ; i < 10; i++)
test43_aux(x++); // expected-warning {{variable 'x' is uninitialized when used here}}
}
void test44(int i) {
int x = i;
int y; // expected-note{{initialize the variable 'y' to silence this warning}}
for (i = 0; i < 10; i++ ) {
test43_aux(x++); // no-warning
x += y; // expected-warning {{variable 'y' is uninitialized when used here}}
}
}
int test45(int j) {
int x = 1, y = x + 1;
if (y) // no-warning
return x;
return y;
}
void test46()
{
int i; // expected-note{{initialize the variable 'i' to silence this warning}}
int j = i ? : 1; // expected-warning {{variable 'i' is uninitialized when used here}}
}
void *test47(int *i)
{
return i ? : 0; // no-warning
}
void *test49(int *i)
{
int a;
return &a ? : i; // no-warning
}
void test50()
{
char c[1 ? : 2]; // no-warning
}
int test51(void)
{
__block int a;
^(void) {
a = 42;
}();
return a; // no-warning
}
// FIXME: This is a false positive, but it tests logical operations in switch statements.
int test52(int a, int b) {
int x; // expected-note {{initialize the variable 'x' to silence this warning}}
switch (a || b) { // expected-warning {{switch condition has boolean value}}
case 0:
x = 1;
break;
case 1:
x = 2;
break;
}
return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
}
void test53() {
int x; // expected-note {{initialize the variable 'x' to silence this warning}}
int y = (x); // expected-warning {{variable 'x' is uninitialized when used here}}
}
// This CFG caused the uninitialized values warning to inf-loop.
extern int PR10379_g();
void PR10379_f(int *len) {
int new_len; // expected-note{{initialize the variable 'new_len' to silence this warning}}
for (int i = 0; i < 42 && PR10379_g() == 0; i++) {
if (PR10379_g() == 1)
continue;
if (PR10379_g() == 2)
PR10379_f(&new_len);
else if (PR10379_g() == 3)
PR10379_f(&new_len);
*len += new_len; // expected-warning {{variable 'new_len' may be uninitialized when used here}}
}
}
// Test that sizeof(VLA) doesn't trigger a warning.
void test_vla_sizeof(int x) {
double (*memory)[2][x] = malloc(sizeof(*memory)); // no-warning
}
// Test absurd case of deadcode + use of blocks. This previously was a false positive
// due to an analysis bug.
int test_block_and_dead_code() {
__block int x;
^{ x = 1; }();
if (0)
return x;
return x; // no-warning
}
// This previously triggered an infinite loop in the analysis.
void PR11069(int a, int b) {
unsigned long flags;
for (;;) {
if (a && !b)
break;
}
for (;;) {
// This does not trigger a warning because it isn't a real use.
(void)(flags); // no-warning
}
}
// Test uninitialized value used in loop condition.
void rdar9432305(float *P) {
int i; // expected-note {{initialize the variable 'i' to silence this warning}}
for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}}
P[i] = 0.0f;
}
// Test that fixits are not emitted inside macros.
#define UNINIT(T, x, y) T x; T y = x;
#define ASSIGN(T, x, y) T y = x;
void test54() {
UNINIT(int, a, b); // expected-warning {{variable 'a' is uninitialized when used here}} \
// expected-note {{variable 'a' is declared here}}
int c; // expected-note {{initialize the variable 'c' to silence this warning}}
ASSIGN(int, c, d); // expected-warning {{variable 'c' is uninitialized when used here}}
}
// Taking the address is fine
struct { struct { void *p; } a; } test55 = { { &test55.a }}; // no-warning
struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning
void uninit_in_loop() {
int produce(void);
void consume(int);
for (int n = 0; n < 100; ++n) {
int k; // expected-note {{initialize}}
consume(k); // expected-warning {{variable 'k' is uninitialized}}
k = produce();
}
}
void uninit_in_loop_goto() {
int produce(void);
void consume(int);
for (int n = 0; n < 100; ++n) {
goto skip_decl;
int k; // expected-note {{initialize}}
skip_decl:
// FIXME: This should produce the 'is uninitialized' diagnostic, but we
// don't have enough information in the CFG to easily tell that the
// variable's scope has been left and re-entered.
consume(k); // expected-warning {{variable 'k' may be uninitialized}}
k = produce();
}
}
typedef char jmp_buf[256];
extern int setjmp(jmp_buf env); // implicitly returns_twice
void do_stuff_and_longjmp(jmp_buf env, int *result) __attribute__((noreturn));
int returns_twice() {
int a; // expected-note {{initialize}}
if (!a) { // expected-warning {{variable 'a' is uninitialized}}
jmp_buf env;
int b;
if (setjmp(env) == 0) {
do_stuff_and_longjmp(env, &b);
} else {
a = b; // no warning
}
}
return a;
}
int compound_assign(int *arr, int n) {
int sum; // expected-note {{initialize}}
for (int i = 0; i < n; ++i)
sum += arr[i]; // expected-warning {{variable 'sum' is uninitialized}}
return sum / n;
}
int compound_assign_2() {
int x; // expected-note {{initialize}}
return x += 1; // expected-warning {{variable 'x' is uninitialized}}
}
int compound_assign_3() {
int x; // expected-note {{initialize}}
x *= 0; // expected-warning {{variable 'x' is uninitialized}}
return x;
}
int self_init_in_cond(int *p) {
int n = ((p && (0 || 1)) && (n = *p)) ? n : -1; // ok
return n;
}
void test_analyzer_noreturn_aux() __attribute__((analyzer_noreturn));
void test_analyzer_noreturn(int y) {
int x; // expected-note {{initialize the variable 'x' to silence this warning}}
if (y) {
test_analyzer_noreturn_aux();
++x; // no-warning
}
else {
++x; // expected-warning {{variable 'x' is uninitialized when used here}}
}
}
void test_analyzer_noreturn_2(int y) {
int x;
if (y) {
test_analyzer_noreturn_aux();
}
else {
x = 1;
}
++x; // no-warning
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-tls_model.c
|
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -fsyntax-only %s
#if !__has_attribute(tls_model)
#error "Should support tls_model attribute"
#endif
int f() __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}}
int x __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}}
static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
static __thread int y __attribute((tls_model("local", "dynamic"))); // expected-error {{'tls_model' attribute takes one argument}}
static __thread int y __attribute((tls_model(123))); // expected-error {{'tls_model' attribute requires a string}}
static __thread int y __attribute((tls_model("foobar"))); // expected-error {{tls_model must be "global-dynamic", "local-dynamic", "initial-exec" or "local-exec"}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ms-inline-asm.c
|
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fms-extensions -fasm-blocks -Wno-microsoft -Wunused-label -verify -fsyntax-only
void t1(void) {
__asm __asm // expected-error {{__asm used with no assembly instructions}}
}
void f() {
int foo;
__asm {
mov eax, eax
.unknowndirective // expected-error {{unknown directive}}
}
f();
__asm {
mov eax, 1+=2 // expected-error {{unknown token in expression}}
}
f();
__asm {
mov eax, 1+++ // expected-error {{unknown token in expression}}
}
f();
__asm {
mov eax, LENGTH bar // expected-error {{unable to lookup expression}}
}
f();
__asm {
mov eax, SIZE bar // expected-error {{unable to lookup expression}}
}
f();
__asm {
mov eax, TYPE bar // expected-error {{unable to lookup expression}} expected-error {{use of undeclared label 'bar'}}
}
}
void rdar15318432(void) {
// We used to crash on this. When LLVM called back to Clang to parse a name
// and do name lookup, if parsing failed, we did not restore the lexer state
// properly.
__asm {
and ecx, ~15
}
int x = 0;
__asm {
and ecx, x
and ecx, ~15
}
}
static int global;
int t2(int *arr, int i) {
__asm {
mov eax, arr;
mov eax, arr[0];
mov eax, arr[1 + 2];
mov eax, arr[1 + (2 * 5) - 3 + 1<<1];
}
// expected-error@+1 {{cannot use base register with variable reference}}
__asm { mov eax, arr[ebp + 1 + (2 * 5) - 3 + 1<<1] }
// expected-error@+1 {{cannot use index register with variable reference}}
__asm { mov eax, arr[esi * 4] }
// expected-error@+1 {{cannot use more than one symbol in memory operand}}
__asm { mov eax, arr[i] }
// expected-error@+1 {{cannot use more than one symbol in memory operand}}
__asm { mov eax, global[i] }
// FIXME: Why don't we diagnose this?
// expected-Xerror@+1 {{cannot reference multiple local variables in assembly operand}}
//__asm mov eax, [arr + i];
return 0;
}
typedef struct {
int a;
int b;
} A;
void t3() {
__asm { mov eax, [eax] UndeclaredId } // expected-error {{unknown token in expression}} expected-error {{use of undeclared label 'UndeclaredId'}}
// FIXME: Only emit one diagnostic here.
// expected-error@+3 {{use of undeclared label 'A'}}
// expected-error@+2 {{unexpected type name 'A': expected expression}}
// expected-error@+1 {{unknown token in expression}}
__asm { mov eax, [eax] A }
}
void t4() {
// The dot in the "intel dot operator" is optional in MSVC. MSVC also does
// global field lookup, but we don't.
__asm { mov eax, [0] A.a }
__asm { mov eax, [0].A.a }
__asm { mov eax, [0].a } // expected-error {{Unable to lookup field reference!}}
__asm { mov eax, fs:[0] A.a }
__asm { mov eax, fs:[0].A.a }
__asm { mov eax, fs:[0].a } // expected-error {{Unable to lookup field reference!}}
__asm { mov eax, fs:[0]. A.a } // expected-error {{Unexpected token type!}}
}
void test_operand_size() {
__asm { call word t4 } // expected-error {{Expected 'PTR' or 'ptr' token!}}
}
__declspec(naked) int t5(int x) { // expected-note {{attribute is here}}
asm { movl eax, x } // expected-error {{parameter references not allowed in naked functions}} expected-error {{use of undeclared label 'x'}}
asm { retl }
}
int y;
__declspec(naked) int t6(int x) {
asm { mov eax, y } // No error.
asm { ret }
}
void t7() {
__asm {
foo: // expected-note {{inline assembly label 'foo' declared here}}
mov eax, 0
}
goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
}
void t8() {
__asm foo: // expected-note {{inline assembly label 'foo' declared here}}
__asm mov eax, 0
goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
}
void t9() {
goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
__asm {
foo: // expected-note {{inline assembly label 'foo' declared here}}
mov eax, 0
}
}
void t10() {
goto foo; // expected-error {{cannot jump from this goto statement to label 'foo' inside an inline assembly block}}
__asm foo: // expected-note {{inline assembly label 'foo' declared here}}
__asm mov eax, 0
}
void t11() {
foo:
__asm mov eax, foo // expected-error {{use of undeclared label 'foo'}} expected-warning {{unused label 'foo'}}
}
void t12() {
__asm foo:
__asm bar: // expected-warning {{unused label 'bar'}}
__asm jmp foo
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/PR16678.c
|
// RUN: %clang_cc1 -DX32TYPE=ULONG -triple powerpc-unknown-linux-gnu -std=c89 -x c %s -verify
// RUN: %clang_cc1 -DX32TYPE=ULONG -triple powerpc-unknown-linux-gnu -std=iso9899:199409 -x c %s -verify
// RUN: %clang_cc1 -DX32TYPE=ULONG -triple powerpc-unknown-linux-gnu -std=c++98 -x c++ %s -verify
// RUN: %clang_cc1 -DX32TYPE=LLONG -triple powerpc-unknown-linux-gnu -std=c99 -x c %s -verify
// RUN: %clang_cc1 -DX32TYPE=LLONG -triple powerpc-unknown-linux-gnu -std=c11 -x c %s -verify
// RUN: %clang_cc1 -DX32TYPE=LLONG -triple powerpc-unknown-linux-gnu -std=c++11 -x c++ %s -verify
// RUN: %clang_cc1 -DX32TYPE=LLONG -triple powerpc-unknown-linux-gnu -std=c++1y -x c++ %s -verify
// RUN: %clang_cc1 -DX32TYPE=LLONG -triple powerpc-unknown-linux-gnu -std=c++1z -x c++ %s -verify
// RUN: %clang_cc1 -DX64TYPE=ULONG -triple powerpc64-unknown-linux-gnu -std=c89 -x c %s -verify
// RUN: %clang_cc1 -DX64TYPE=ULONG -triple powerpc64-unknown-linux-gnu -std=iso9899:199409 -x c %s -verify
// RUN: %clang_cc1 -DX64TYPE=ULONG -triple powerpc64-unknown-linux-gnu -std=c++98 -x c++ %s -verify
// RUN: %clang_cc1 -DX64TYPE=ULLONG -triple powerpc64-unknown-linux-gnu -std=c99 -x c %s -verify
// RUN: %clang_cc1 -DX64TYPE=ULLONG -triple powerpc64-unknown-linux-gnu -std=c11 -x c %s -verify
// RUN: %clang_cc1 -DX64TYPE=ULLONG -triple powerpc64-unknown-linux-gnu -std=c++11 -x c++ %s -verify
// RUN: %clang_cc1 -DX64TYPE=ULLONG -triple powerpc64-unknown-linux-gnu -std=c++1y -x c++ %s -verify
// RUN: %clang_cc1 -DX64TYPE=ULLONG -triple powerpc64-unknown-linux-gnu -std=c++1z -x c++ %s -verify
#ifdef X64TYPE
#define X32TYPE long
#endif
#define IS_ULONG_ULONG 1
#define IS_ULONG2(X) IS_ULONG_##X
#define IS_ULONG(X) IS_ULONG2(X)
#if !defined(X64TYPE) && !IS_ULONG(X32TYPE)
// expected-no-diagnostics
#endif
typedef unsigned long ULONG;
typedef long long LLONG;
typedef unsigned long long ULLONG;
/******************************************************************************
* Test 2^31 as a decimal literal with no suffix and with the "l" and "L" cases.
******************************************************************************/
extern X32TYPE x32;
extern __typeof__(2147483648) x32;
extern __typeof__(2147483648l) x32;
extern __typeof__(2147483648L) x32;
#if IS_ULONG(X32TYPE)
#if !__cplusplus
/******************************************************************************
* Under pre-C99 ISO C, unsigned long is attempted for decimal integer literals
* that do not have a suffix containing "u" or "U" if the literal does not fit
* within the range of int or long. See 6.1.3.2 paragraph 5.
******************************************************************************/
// expected-warning@39 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C89; this literal will have type 'long long' in C99 onwards}}
// expected-warning@40 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C89; this literal will have type 'long long' in C99 onwards}}
// expected-warning@41 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C89; this literal will have type 'long long' in C99 onwards}}
#else
/******************************************************************************
* Under pre-C++11 ISO C++, the same holds if the literal contains an "l" or "L"
* in its suffix; otherwise, the behavior is undefined. See 2.13.1 [lex.icon]
* paragraph 2.
******************************************************************************/
// expected-warning@39 {{integer literal is too large to be represented in type 'long' and is subject to undefined behavior under C++98, interpreting as 'unsigned long'; this literal will have type 'long long' in C++11 onwards}}
// expected-warning@40 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C++98; this literal will have type 'long long' in C++11 onwards}}
// expected-warning@41 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C++98; this literal will have type 'long long' in C++11 onwards}}
#endif
#endif
#ifdef X64TYPE
/******************************************************************************
* Test 2^63 as a decimal literal with no suffix and with the "l" and "L" cases.
******************************************************************************/
extern X64TYPE x64;
extern __typeof__(9223372036854775808) x64;
extern __typeof__(9223372036854775808l) x64;
extern __typeof__(9223372036854775808L) x64;
#if IS_ULONG(X64TYPE)
#if !__cplusplus
/******************************************************************************
* Under pre-C99 ISO C, unsigned long is attempted for decimal integer literals
* that do not have a suffix containing "u" or "U" if the literal does not fit
* within the range of int or long. See 6.1.3.2 paragraph 5.
******************************************************************************/
// expected-warning@74 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C89; this literal will be ill-formed in C99 onwards}}
// expected-warning@75 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C89; this literal will be ill-formed in C99 onwards}}
// expected-warning@76 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C89; this literal will be ill-formed in C99 onwards}}
#else
/******************************************************************************
* Under pre-C++11 ISO C++, the same holds if the literal contains an "l" or "L"
* in its suffix; otherwise, the behavior is undefined. See 2.13.1 [lex.icon]
* paragraph 2.
******************************************************************************/
// expected-warning@74 {{integer literal is too large to be represented in type 'long' and is subject to undefined behavior under C++98, interpreting as 'unsigned long'; this literal will be ill-formed in C++11 onwards}}
// expected-warning@75 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C++98; this literal will be ill-formed in C++11 onwards}}
// expected-warning@76 {{integer literal is too large to be represented in type 'long', interpreting as 'unsigned long' per C++98; this literal will be ill-formed in C++11 onwards}}
#endif
#else
/******************************************************************************
* The status quo in C99/C++11-and-later modes for the literals in question is
* to interpret them as unsigned as an extension.
******************************************************************************/
// expected-warning@74 {{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}}
// expected-warning@75 {{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}}
// expected-warning@76 {{integer literal is too large to be represented in a signed integer type, interpreting as unsigned}}
#endif
#endif
/******************************************************************************
* Test preprocessor arithmetic with 2^31 as a decimal literal with no suffix
* and with the "l" and "L" cases.
******************************************************************************/
#if !IS_ULONG(X32TYPE)
/******************************************************************************
* If the literal is signed without need for the modified range of the signed
* integer types within the controlling constant expression for conditional
* inclusion, then it will also be signed with said modified range.
******************************************************************************/
#define EXPR(X) ((X - X) - 1 < 0)
#else
/******************************************************************************
* Strictly speaking, in pre-C99/C++11 ISO C/C++, the preprocessor arithmetic is
* evaluated with the range of long/unsigned long; however, both Clang and GCC
* evaluate using 64-bits even when long/unsigned long are 32-bits outside of
* preprocessing.
*
* If the range used becomes 32-bits, then this test will enforce the treatment
* as unsigned of the literals in question.
*
* Note:
* Under pre-C99/C++11 ISO C/C++, whether the interpretation of the literal is
* affected by the modified range of the signed and unsigned integer types
* within the controlling constant expression for conditional inclusion is
* unclear.
******************************************************************************/
#define PP_LONG_MAX ((0ul - 1ul) >> 1)
#define EXPR(X) \
(PP_LONG_MAX >= 0x80000000 || (X - X) - 1 > 0) // either 2^31 fits into a
// preprocessor "long" or the
// literals in question are
// unsigned
#endif
#if !(EXPR(2147483648) && EXPR(2147483648l) && EXPR(2147483648L))
#error Unexpected signedness or conversion behavior
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/PR2728.c
|
// RUN: %clang_cc1 -verify -fsyntax-only -std=c90 %s
// RUN: %clang_cc1 -verify -fsyntax-only -std=c99 %s
// expected-no-diagnostics
struct s
{
int a;
};
int a[__builtin_offsetof(struct s, a) == 0];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/function-redecl.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR3588
void g0(int, int);
void g0(); // expected-note{{previous declaration is here}} expected-note{{'g0' declared here}}
void f0() {
g0(1, 2, 3); // expected-error{{too many arguments to function call}}
}
void g0(int); // expected-error{{conflicting types for 'g0'}}
int g1(int, int);
typedef int INT;
INT g1(x, y)
int x;
int y;
{
return x + y;
}
int g2(int, int); // expected-note{{previous declaration is here}}
INT g2(x) // expected-error{{conflicting types for 'g2'}}
int x;
{
return x;
}
void test() {
int f1;
{
void f1(double);
{
void f1(double); // expected-note{{previous declaration is here}}
{
int f1(int); // expected-error{{conflicting types for 'f1'}}
}
}
}
}
extern void g3(int); // expected-note{{previous declaration is here}}
static void g3(int x) { } // expected-error{{static declaration of 'g3' follows non-static declaration}}
void test2() {
extern int f2; // expected-note 2 {{previous definition is here}}
{
void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
}
{
int f2;
{
void f2(int); // expected-error{{redefinition of 'f2' as different kind of symbol}}
}
}
}
// <rdar://problem/6127293>
int outer1(int); // expected-note{{previous declaration is here}}
struct outer3 { };
int outer4(int); // expected-note{{previous declaration is here}}
int outer5; // expected-note{{previous definition is here}}
int *outer7(int);
void outer_test() {
int outer1(float); // expected-error{{conflicting types for 'outer1'}}
int outer2(int); // expected-note{{previous declaration is here}}
int outer3(int); // expected-note{{previous declaration is here}}
int outer4(int);
int outer5(int); // expected-error{{redefinition of 'outer5' as different kind of symbol}}
int* outer6(int); // expected-note{{previous declaration is here}}
int *outer7(int);
int outer8(int);
int *ip7 = outer7(6);
}
int outer2(float); // expected-error{{conflicting types for 'outer2'}}
int outer3(float); // expected-error{{conflicting types for 'outer3'}}
int outer4(float); // expected-error{{conflicting types for 'outer4'}}
void outer_test2(int x) {
int* ip = outer6(x); // expected-warning{{use of out-of-scope declaration of 'outer6'}}
int *ip2 = outer7(x);
}
void outer_test3() {
int *(*fp)(int) = outer8; // expected-error{{use of undeclared identifier 'outer8'}}
}
enum e { e1, e2 };
// GNU extension: prototypes and K&R function definitions
int isroot(short x, // expected-note{{previous declaration is here}}
enum e);
int isroot(x, y)
short x; // expected-warning{{promoted type 'int' of K&R function parameter is not compatible with the parameter type 'short' declared in a previous prototype}}
unsigned int y;
{
return x == 1;
}
// PR3817
void *h0(unsigned a0, ...);
extern __typeof (h0) h1 __attribute__((__sentinel__));
extern __typeof (h1) h1 __attribute__((__sentinel__));
// PR3840
void i0 (unsigned short a0);
extern __typeof (i0) i1;
extern __typeof (i1) i1;
typedef int a();
typedef int a2(int*);
a x;
a2 x2; // expected-note{{passing argument to parameter here}}
void test_x() {
x(5);
x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int' to parameter of type 'int *'}}
}
enum e0 {one};
void f3();
void f3(enum e0 x) {}
enum incomplete_enum;
void f4(); // expected-note {{previous declaration is here}}
void f4(enum incomplete_enum); // expected-error {{conflicting types for 'f4'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/va_arg_x86_32.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple=i686-pc-linux-gnu %s
int a() {
__builtin_va_arg((char*)0, int); // expected-error {{expression is not assignable}}
__builtin_va_arg((void*){0}, int); // expected-error {{first argument to 'va_arg' is of type 'void *'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/no-format-y2k-turnsoff-format.c
|
// RUN: %clang_cc1 -verify -fsyntax-only -Wformat -Wno-format-y2k %s
// rdar://9504680
void foo(const char *, ...) __attribute__((__format__ (__printf__, 1, 2)));
void bar(unsigned int a) {
foo("%s", a); // expected-warning {{format specifies type 'char *' but the argument has type 'unsigned int'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-ms.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 %s
// RUN: %clang_cc1 -fsyntax-only -verify -fms-compatibility -triple=i386-pc-win32 -Wformat-non-iso -DNON_ISO_WARNING %s
int printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
int scanf(const char * restrict, ...) ;
typedef unsigned short wchar_t;
#ifdef NON_ISO_WARNING
// Split off this test to reduce the warning noise in the rest of the file.
void non_iso_warning_test(__int32 i32, __int64 i64, wchar_t c, void *p) {
printf("%Id", i32); // expected-warning{{'I' length modifier is not supported by ISO C}}
printf("%I32d", i32); // expected-warning{{'I32' length modifier is not supported by ISO C}}
printf("%I64d", i64); // expected-warning{{'I64' length modifier is not supported by ISO C}}
printf("%wc", c); // expected-warning{{'w' length modifier is not supported by ISO C}}
printf("%Z", p); // expected-warning{{'Z' conversion specifier is not supported by ISO C}}
}
#else
void signed_test() {
short val = 30;
printf("val = %I64d\n", val); // expected-warning{{format specifies type '__int64' (aka 'long long') but the argument has type 'short'}}
long long bigval = 30;
printf("val = %I32d\n", bigval); // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
printf("val = %Id\n", bigval); // expected-warning{{format specifies type '__int32' (aka 'int') but the argument has type 'long long'}}
}
void unsigned_test() {
unsigned short val = 30;
printf("val = %I64u\n", val); // expected-warning{{format specifies type 'unsigned __int64' (aka 'unsigned long long') but the argument has type 'unsigned short'}}
unsigned long long bigval = 30;
printf("val = %I32u\n", bigval); // expected-warning{{format specifies type 'unsigned __int32' (aka 'unsigned int') but the argument has type 'unsigned long long'}}
printf("val = %Iu\n", bigval); // expected-warning{{format specifies type 'unsigned __int32' (aka 'unsigned int') but the argument has type 'unsigned long long'}}
}
void w_test(wchar_t c, wchar_t *s) {
printf("%wc", c);
printf("%wC", c);
printf("%C", c);
printf("%ws", s);
printf("%wS", s);
printf("%S", s);
scanf("%wc", &c);
scanf("%wC", &c);
scanf("%C", &c);
scanf("%ws", s);
scanf("%wS", s);
scanf("%S", s);
double bad;
printf("%wc", bad); // expected-warning{{format specifies type 'wint_t' (aka 'int') but the argument has type 'double'}}
printf("%wC", bad); // expected-warning{{format specifies type 'wchar_t' (aka 'unsigned short') but the argument has type 'double'}}
printf("%C", bad); // expected-warning{{format specifies type 'wchar_t' (aka 'unsigned short') but the argument has type 'double'}}
printf("%ws", bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double'}}
printf("%wS", bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double'}}
printf("%S", bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double'}}
scanf("%wc", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
scanf("%wC", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
scanf("%C", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
scanf("%ws", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
scanf("%wS", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
scanf("%S", &bad); // expected-warning{{format specifies type 'wchar_t *' (aka 'unsigned short *') but the argument has type 'double *'}}
}
void h_test(char c, char* s) {
double bad;
printf("%hc", bad); // expected-warning{{format specifies type 'int' but the argument has type 'double'}}
printf("%hC", bad); // expected-warning{{format specifies type 'int' but the argument has type 'double'}}
printf("%hs", bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double'}}
printf("%hS", bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double'}}
scanf("%hc", &bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double *'}}
scanf("%hC", &bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double *'}}
scanf("%hs", &bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double *'}}
scanf("%hS", &bad); // expected-warning{{format specifies type 'char *' but the argument has type 'double *'}}
}
void z_test(void *p) {
printf("%Z", p);
printf("%hZ", p);
printf("%lZ", p);
printf("%wZ", p);
printf("%hhZ", p); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 'Z' conversion specifier}}
scanf("%Z", p); // expected-warning{{invalid conversion specifier 'Z'}}
}
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-flag-enum.c
|
// RUN: %clang_cc1 -verify -fsyntax-only -std=c11 -Wassign-enum %s
enum __attribute__((flag_enum)) flag {
ea = 0x1,
eb = 0x2,
ec = 0x8,
};
enum __attribute__((flag_enum)) flag2 {
ga = 0x1,
gb = 0x4,
gc = 0x5, // no-warning
gd = 0x7, // expected-warning {{enumeration value 'gd' is out of range}}
ge = ~0x2, // expected-warning {{enumeration value 'ge' is out of range}}
gf = ~0x4, // no-warning
gg = ~0x1, // no-warning
gh = ~0x5, // no-warning
gi = ~0x11, // expected-warning {{enumeration value 'gi' is out of range}}
};
enum __attribute__((flag_enum)) flag3 {
fa = 0x1,
fb = ~0x1u, // no-warning
};
// What happens here is that ~0x2 is negative, and so the enum must be signed.
// But ~0x1u is unsigned and has the high bit set, so the enum must be 64-bit.
// The result is that ~0x1u does not have high bits set, and so it is considered
// to be an invalid value. See Sema::IsValueInFlagEnum in SemaDecl.cpp for more
// discussion.
enum __attribute__((flag_enum)) flag4 {
ha = 0x1,
hb = 0x2,
hc = ~0x1u, // expected-warning {{enumeration value 'hc' is out of range}}
hd = ~0x2, // no-warning
};
void f(void) {
enum flag e = 0; // no-warning
e = 0x1; // no-warning
e = 0x3; // no-warning
e = 0xa; // no-warning
e = 0x4; // expected-warning {{integer constant not in range of enumerated type}}
e = 0xf; // expected-warning {{integer constant not in range of enumerated type}}
e = ~0; // no-warning
e = ~0x1; // no-warning
e = ~0x2; // no-warning
e = ~0x3; // no-warning
e = ~0x4; // expected-warning {{integer constant not in range of enumerated type}}
switch (e) {
case 0: break; // no-warning
case 0x1: break; // no-warning
case 0x3: break; // no-warning
case 0xa: break; // no-warning
case 0x4: break; // expected-warning {{case value not in enumerated type}}
case 0xf: break; // expected-warning {{case value not in enumerated type}}
case ~0: break; // expected-warning {{case value not in enumerated type}}
case ~0x1: break; // expected-warning {{case value not in enumerated type}}
case ~0x2: break; // expected-warning {{case value not in enumerated type}}
case ~0x3: break; // expected-warning {{case value not in enumerated type}}
case ~0x4: break; // expected-warning {{case value not in enumerated type}}
default: break;
}
enum flag2 f = ~0x1; // no-warning
f = ~0x1u; // no-warning
enum flag4 h = ~0x1; // no-warning
h = ~0x1u; // expected-warning {{integer constant not in range of enumerated type}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/array-size.c
|
// RUN: %clang_cc1 -triple i686-apple-darwin -verify %s
void f() {
int x0[1073741824]; // expected-error{{array is too large}}
int x1[1073741824 + 1]; // expected-error{{array is too large}}
int x2[(unsigned)1073741824]; // expected-error{{array is too large}}
int x3[(unsigned)1073741824 + 1]; // expected-error{{array is too large}}
int x4[1073741824 - 1];
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-unused-function.c
|
// RUN: %clang_cc1 -fsyntax-only -Wused-but-marked-unused -Wunused-function -Wunneeded-internal-declaration -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wall -Wno-infinite-recursion %s
void foo() {}
static void f2() {}
static void f1() {f2();} // expected-warning{{unused}}
static int f0() { return 17; } // expected-warning{{not needed and will not be emitted}}
int x = sizeof(f0());
static void f3();
extern void f3() { } // expected-warning{{unused}}
inline static void f4();
void f4() { } // expected-warning{{unused}}
static void __attribute__((used)) f5() {}
static void f6();
static void __attribute__((used)) f6();
static void f6() {};
static void f7(void);
void f8(void(*a0)(void));
void f9(void) { f8(f7); }
static void f7(void) {}
__attribute__((unused)) static void bar(void);
void bar(void) { }
__attribute__((constructor)) static void bar2(void);
void bar2(void) { }
__attribute__((destructor)) static void bar3(void);
void bar3(void) { }
static void f10(void); // expected-warning{{unused}}
static void f10(void);
static void f11(void);
static void f11(void) { } // expected-warning{{unused}}
static void f12(void) { } // expected-warning{{unused}}
static void f12(void);
// PR7923
static void unused(void) { unused(); } // expected-warning{{not needed and will not be emitted}}
// rdar://8728293
static void cleanupMalloc(char * const * const allocation) { }
void f13(void) {
char * const __attribute__((cleanup(cleanupMalloc))) a;
(void)a;
}
// rdar://12233989
extern void a(void) __attribute__((unused));
extern void b(void) __attribute__((unused));
void b(void)
{
}
void a(void)
{
b();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-enum.c
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -verify %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x c++ -verify %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x c++ -std=c++11 -verify %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -verify %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c++ -std=c++11 -verify %s
#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C extern
#endif
EXTERN_C int printf(const char *,...);
typedef enum { Constant = 0 } TestEnum;
// Note that in C, the type of 'Constant' is 'int'. In C++ it is 'TestEnum'.
// This is why we don't check for that in the expected output.
void test(TestEnum input) {
printf("%d", input); // no-warning
printf("%d", Constant); // no-warning
printf("%lld", input); // expected-warning-re{{format specifies type 'long long' but the argument has underlying type '{{(unsigned)?}} int'}}
printf("%lld", Constant); // expected-warning{{format specifies type 'long long'}}
}
typedef enum { LongConstant = ~0UL } LongEnum;
void testLong(LongEnum input) {
printf("%u", input); // expected-warning{{format specifies type 'unsigned int' but the argument has underlying type}}
printf("%u", LongConstant); // expected-warning{{format specifies type 'unsigned int'}}
printf("%lu", input);
printf("%lu", LongConstant);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/nested-redef.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct X { // expected-note{{previous definition is here}}
struct X { } x; // expected-error{{nested redefinition of 'X'}}
};
struct Y { };
void f(void) {
struct Y { }; // okay: this is a different Y
}
struct T;
struct Z {
struct T { int x; } t;
struct U { int x; } u;
};
void f2(void) {
struct T t;
struct U u;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/crash-invalid-array.c
|
// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
// PR6913
int main()
{
int x[10][10];
int (*p)[] = x;
int i;
for(i = 0; i < 10; ++i)
{
p[i][i] = i; // expected-error {{subscript of pointer to incomplete type 'int []'}}
}
}
// rdar://13705391
void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/bitfield-promote.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
struct {unsigned x : 2;} x;
__typeof__((x.x+=1)+1) y;
__typeof__(x.x<<1) y;
int y;
struct { int x : 8; } x1;
long long y1;
__typeof__(((long long)x1.x + 1)) y1;
// Check for extensions: variously sized unsigned bit-fields fitting
// into a signed int promote to signed int.
enum E { ec1, ec2, ec3 };
struct S {
enum E e : 2;
unsigned short us : 4;
unsigned long long ul1 : 8;
unsigned long long ul2 : 50;
} s;
__typeof(s.e + s.e) x_e;
int x_e;
__typeof(s.us + s.us) x_us;
int x_us;
__typeof(s.ul1 + s.ul1) x_ul1;
int x_ul1;
__typeof(s.ul2 + s.ul2) x_ul2;
unsigned long long x_ul2;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/inline-asm-validate-x86.c
|
// RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s
void I(int i, int j) {
static const int BelowMin = -1;
static const int AboveMax = 32;
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "I"(j)); // expected-error{{constraint 'I' expects an integer constant expression}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "I"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'I'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "I"(AboveMax)); // expected-error{{value '32' out of range for constraint 'I'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "I"(16)); // expected-no-error
}
void J(int i, int j) {
static const int BelowMin = -1;
static const int AboveMax = 64;
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "J"(j)); // expected-error{{constraint 'J' expects an integer constant expression}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "J"(AboveMax)); // expected-error{{value '64' out of range for constraint 'J'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "J"(32)); // expected-no-error
}
void K(int i, int j) {
static const int BelowMin = -129;
static const int AboveMax = 128;
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "K"(j)); // expected-error{{constraint 'K' expects an integer constant expression}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "K"(BelowMin)); // expected-error{{value '-129' out of range for constraint 'K'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "K"(AboveMax)); // expected-error{{value '128' out of range for constraint 'K'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "K"(96)); // expected-no-error
}
void M(int i, int j) {
static const int BelowMin = -1;
static const int AboveMax = 4;
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "M"(j)); // expected-error{{constraint 'M' expects an integer constant expression}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "M"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'M'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "M"(AboveMax)); // expected-error{{value '4' out of range for constraint 'M'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "M"(2)); // expected-no-error
}
void N(int i, int j) {
static const int BelowMin = -1;
static const int AboveMax = 256;
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "N"(j)); // expected-error{{constraint 'N' expects an integer constant expression}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "N"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'N'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "N"(AboveMax)); // expected-error{{value '256' out of range for constraint 'N'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "N"(128)); // expected-no-error
}
void O(int i, int j) {
static const int BelowMin = -1;
static const int AboveMax = 128;
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "O"(j)); // expected-error{{constraint 'O' expects an integer constant expression}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "O"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'O'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "O"(AboveMax)); // expected-error{{value '128' out of range for constraint 'O'}}
__asm__("xorl %0,%2"
: "=r"(i)
: "0"(i), "O"(64)); // expected-no-error
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/__try.c
|
// RUN: %clang_cc1 -triple x86_64-windows -fborland-extensions -DBORLAND -fsyntax-only -verify -fblocks %s
// RUN: %clang_cc1 -triple x86_64-windows -fms-extensions -fsyntax-only -verify -fblocks %s
#define JOIN2(x,y) x ## y
#define JOIN(x,y) JOIN2(x,y)
#define TEST2(name) JOIN(name,__LINE__)
#define TEST TEST2(test)
typedef int DWORD;
#pragma sysheader begin
struct EXCEPTION_INFO{};
unsigned long __exception_code();
#ifdef BORLAND
struct EXCEPTION_INFO* __exception_info();
#endif
int __abnormal_termination();
#define GetExceptionCode __exception_code
#define GetExceptionInformation __exception_info
#define AbnormalTermination __abnormal_termination
#pragma sysheader end
DWORD FilterExpression(int); // expected-note{{declared here}}
DWORD FilterExceptionInformation(struct EXCEPTION_INFO*);
const char * NotFilterExpression();
void TEST() {
__try {
__try {
__try {
}
__finally{
}
}
__finally{
}
}
__finally{
}
}
void TEST() {
__try {
}
} // expected-error{{expected '__except' or '__finally' block}}
void TEST() {
__except ( FilterExpression() ) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
// expected-error{{too few arguments to function call, expected 1, have 0}}
}
}
void TEST() {
__finally { } // expected-error{{}}
}
void TEST() {
__try{
int try_scope = 0;
} // TODO: expected expression is an extra error
__except( try_scope ? 1 : -1 ) // expected-error{{undeclared identifier 'try_scope'}} expected-error{{expected expression}}
{}
}
void TEST() {
__try {
}
// TODO: Why are there two errors?
__except( ) { // expected-error{{expected expression}} expected-error{{expected expression}}
}
}
void TEST() {
__try {
}
__except ( FilterExpression(GetExceptionCode()) ) {
}
__try {
}
__except( FilterExpression(__exception_code()) ) {
}
__try {
}
__except( FilterExceptionInformation(__exception_info()) ) {
}
__try {
}
__except(FilterExceptionInformation( GetExceptionInformation() ) ) {
}
}
void TEST() {
__try {
}
__except ( NotFilterExpression() ) { // expected-error{{filter expression type should be an integral value not 'const char *'}}
}
}
void TEST() {
int function_scope = 0;
__try {
int try_scope = 0;
}
__except ( FilterExpression(GetExceptionCode()) ) {
(void)function_scope;
(void)try_scope; // expected-error{{undeclared identifier}}
}
}
void TEST() {
int function_scope = 0;
__try {
int try_scope = 0;
}
__finally {
(void)function_scope;
(void)try_scope; // expected-error{{undeclared identifier}}
}
}
void TEST() {
int function_scope = 0;
__try {
}
__except( function_scope ? 1 : -1 ) {}
}
#ifdef BORLAND
void TEST() {
(void)__abnormal_termination(); // expected-error{{only allowed in __finally block}}
(void)AbnormalTermination(); // expected-error{{only allowed in __finally block}}
__try {
(void)AbnormalTermination; // expected-error{{only allowed in __finally block}}
(void)__abnormal_termination; // expected-error{{only allowed in __finally block}}
}
__except( 1 ) {
(void)AbnormalTermination; // expected-error{{only allowed in __finally block}}
(void)__abnormal_termination; // expected-error{{only allowed in __finally block}}
}
__try {
}
__finally {
AbnormalTermination();
__abnormal_termination();
}
}
#endif
void TEST() {
(void)__exception_info(); // expected-error{{only allowed in __except filter expression}}
(void)GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
}
void TEST() {
#ifndef BORLAND
(void)__exception_code; // expected-error{{builtin functions must be directly called}}
#endif
(void)__exception_code(); // expected-error{{only allowed in __except block or filter expression}}
(void)GetExceptionCode(); // expected-error{{only allowed in __except block or filter expression}}
}
void TEST() {
__try {
} __except(1) {
GetExceptionCode(); // valid
GetExceptionInformation(); // expected-error{{only allowed in __except filter expression}}
}
}
void test_seh_leave_stmt() {
__leave; // expected-error{{'__leave' statement not in __try block}}
__try {
__leave;
__leave 4; // expected-error{{expected ';' after __leave statement}}
} __except(1) {
__leave; // expected-error{{'__leave' statement not in __try block}}
}
__try {
__leave;
} __finally {
__leave; // expected-error{{'__leave' statement not in __try block}}
}
__leave; // expected-error{{'__leave' statement not in __try block}}
}
void test_jump_out_of___finally() {
while(1) {
__try {
} __finally {
continue; // expected-warning{{jump out of __finally block has undefined behavior}}
}
}
__try {
} __finally {
while (1) {
continue;
}
}
// Check that a deep __finally containing a block with a shallow continue
// doesn't trigger the warning.
while(1) {{{{
__try {
} __finally {
^{
while(1)
continue;
}();
}
}}}}
while(1) {
__try {
} __finally {
break; // expected-warning{{jump out of __finally block has undefined behavior}}
}
}
switch(1) {
case 1:
__try {
} __finally {
break; // expected-warning{{jump out of __finally block has undefined behavior}}
}
}
__try {
} __finally {
while (1) {
break;
}
}
__try {
__try {
} __finally {
__leave; // expected-warning{{jump out of __finally block has undefined behavior}}
}
} __finally {
}
__try {
} __finally {
__try {
__leave;
} __finally {
}
}
__try {
} __finally {
return; // expected-warning{{jump out of __finally block has undefined behavior}}
}
__try {
} __finally {
^{
return;
}();
}
}
void test_typo_in_except() {
__try {
} __except(undeclared_identifier) { // expected-error {{use of undeclared identifier 'undeclared_identifier'}} expected-error {{expected expression}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/memset-invalid.c
|
// RUN: %clang_cc1 -fsyntax-only %s -verify
char memset(); // expected-warning {{incompatible redeclaration of library function 'memset'}} expected-note{{'memset' is a builtin with type}}
char test() {
return memset();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/stmtexprs.c
|
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-gnu-statement-expression
int stmtexpr_fn();
void stmtexprs(int i) {
__builtin_assume( ({ 1; }) ); // no warning about "side effects"
__builtin_assume( ({ if (i) { (void)0; }; 42; }) ); // no warning about "side effects"
// expected-warning@+1 {{the argument to '__builtin_assume' has side effects that will be discarded}}
__builtin_assume( ({ if (i) ({ stmtexpr_fn(); }); 1; }) );
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/array-size-64.c
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin -verify %s
void f() {
int a[2147483647U][2147483647U]; // expected-error{{array is too large}}
int b[1073741825U - 1U][2147483647U]; // expected-error{{array is too large}}
}
void pr8256 () {
typedef char a[1LL<<61]; // expected-error {{array is too large}}
typedef char b[(long long)sizeof(a)-1];
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtins-arm-exclusive.c
|
// RUN: %clang_cc1 -triple armv7 -fsyntax-only -verify %s
struct Simple {
char a, b;
};
int test_ldrex(char *addr) {
int sum = 0;
sum += __builtin_arm_ldrex(addr);
sum += __builtin_arm_ldrex((short *)addr);
sum += __builtin_arm_ldrex((int *)addr);
sum += __builtin_arm_ldrex((long long *)addr);
sum += __builtin_arm_ldrex((float *)addr);
sum += __builtin_arm_ldrex((double *)addr);
sum += *__builtin_arm_ldrex((int **)addr);
sum += __builtin_arm_ldrex((struct Simple **)addr)->a;
sum += __builtin_arm_ldrex((volatile char *)addr);
sum += __builtin_arm_ldrex((const volatile char *)addr);
// In principle this might be valid, but stick to ints and floats for scalar
// types at the moment.
sum += __builtin_arm_ldrex((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}}
sum += __builtin_arm_ldrex((__int128 *)addr); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
__builtin_arm_ldrex(); // expected-error {{too few arguments to function call}}
__builtin_arm_ldrex(1, 2); // expected-error {{too many arguments to function call}}
return sum;
}
int test_strex(char *addr) {
int res = 0;
struct Simple var = {0};
res |= __builtin_arm_strex(4, addr);
res |= __builtin_arm_strex(42, (short *)addr);
res |= __builtin_arm_strex(42, (int *)addr);
res |= __builtin_arm_strex(42, (long long *)addr);
res |= __builtin_arm_strex(2.71828f, (float *)addr);
res |= __builtin_arm_strex(3.14159, (double *)addr);
res |= __builtin_arm_strex(&var, (struct Simple **)addr);
res |= __builtin_arm_strex(42, (volatile char *)addr);
res |= __builtin_arm_strex(42, (char *const)addr);
res |= __builtin_arm_strex(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}}
res |= __builtin_arm_strex(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}}
res |= __builtin_arm_strex(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}}
res |= __builtin_arm_strex(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}}
res |= __builtin_arm_strex(1, (__int128 *)addr); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
__builtin_arm_strex(1); // expected-error {{too few arguments to function call}}
__builtin_arm_strex(1, 2, 3); // expected-error {{too many arguments to function call}}
return res;
}
int test_ldaex(char *addr) {
int sum = 0;
sum += __builtin_arm_ldaex(addr);
sum += __builtin_arm_ldaex((short *)addr);
sum += __builtin_arm_ldaex((int *)addr);
sum += __builtin_arm_ldaex((long long *)addr);
sum += __builtin_arm_ldaex((float *)addr);
sum += __builtin_arm_ldaex((double *)addr);
sum += *__builtin_arm_ldaex((int **)addr);
sum += __builtin_arm_ldaex((struct Simple **)addr)->a;
sum += __builtin_arm_ldaex((volatile char *)addr);
sum += __builtin_arm_ldaex((const volatile char *)addr);
// In principle this might be valid, but stick to ints and floats for scalar
// types at the moment.
sum += __builtin_arm_ldaex((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}}
sum += __builtin_arm_ldaex((__int128 *)addr); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
__builtin_arm_ldaex(); // expected-error {{too few arguments to function call}}
__builtin_arm_ldaex(1, 2); // expected-error {{too many arguments to function call}}
return sum;
}
int test_stlex(char *addr) {
int res = 0;
struct Simple var = {0};
res |= __builtin_arm_stlex(4, addr);
res |= __builtin_arm_stlex(42, (short *)addr);
res |= __builtin_arm_stlex(42, (int *)addr);
res |= __builtin_arm_stlex(42, (long long *)addr);
res |= __builtin_arm_stlex(2.71828f, (float *)addr);
res |= __builtin_arm_stlex(3.14159, (double *)addr);
res |= __builtin_arm_stlex(&var, (struct Simple **)addr);
res |= __builtin_arm_stlex(42, (volatile char *)addr);
res |= __builtin_arm_stlex(42, (char *const)addr);
res |= __builtin_arm_stlex(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}}
res |= __builtin_arm_stlex(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}}
res |= __builtin_arm_stlex(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}}
res |= __builtin_arm_stlex(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}}
res |= __builtin_arm_stlex(1, (__int128 *)addr); // expected-error {{__int128 is not supported on this target}} expected-error {{address argument to load or store exclusive builtin must be a pointer to 1,2,4 or 8 byte type}}
__builtin_arm_stlex(1); // expected-error {{too few arguments to function call}}
__builtin_arm_stlex(1, 2, 3); // expected-error {{too many arguments to function call}}
return res;
}
void test_clrex() {
__builtin_arm_clrex();
__builtin_arm_clrex(1); // expected-error {{too many arguments to function call}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-section-invalid.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-apple-darwin
// expected-error@+1 {{argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment and section separated by a comma}}
#pragma data_seg(".my_const")
int a = 1;
#pragma data_seg("__THINGY,thingy")
int b = 1;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-printf-attribute-1.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
#include <stdarg.h>
int main() {
void (^b) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 1, 3))) = // expected-error {{format argument not a string type}}
^ __attribute__ ((__format__ (__printf__, 1, 3))) (int arg, const char * format, ...) {}; // expected-error {{format argument not a string type}}
void (^z) (int arg, const char * format, ...) __attribute__ ((__format__ (__printf__, 2, 3))) = ^ __attribute__ ((__format__ (__printf__, 2, 3))) (int arg, const char * format, ...) {};
z(1, "%s", 1); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
z(1, "%s", "HELLO"); // no-warning
}
void multi_attr(va_list ap, int *x, long *y) {
// Handle block with multiple format attributes.
void (^vprintf_scanf) (const char *, va_list, const char *, ...) __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) =
^ __attribute__((__format__(__printf__, 1, 0))) __attribute__((__format__(__scanf__, 3, 4))) (const char *str, va_list args, const char *fmt, ...) {};
vprintf_scanf("%", ap, "%d"); // expected-warning {{incomplete format specifier}}, expected-warning {{more '%' conversions than data arguments}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-cleanup.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
void c1(int *a);
extern int g1 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}}
int g2 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}}
static int g3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}}
void t1()
{
int v1 __attribute((cleanup)); // expected-error {{'cleanup' attribute takes one argument}}
int v2 __attribute((cleanup(1, 2))); // expected-error {{'cleanup' attribute takes one argument}}
static int v3 __attribute((cleanup(c1))); // expected-warning {{'cleanup' attribute ignored}}
int v4 __attribute((cleanup(h))); // expected-error {{use of undeclared identifier 'h'}}
int v5 __attribute((cleanup(c1)));
int v6 __attribute((cleanup(v3))); // expected-error {{'cleanup' argument 'v3' is not a function}}
}
struct s {
int a, b;
};
void c2();
void c3(struct s a);
void t2()
{
int v1 __attribute__((cleanup(c2))); // expected-error {{'cleanup' function 'c2' must take 1 parameter}}
int v2 __attribute__((cleanup(c3))); // expected-error {{'cleanup' function 'c3' parameter has type 'struct s' which is incompatible with type 'int *'}}
}
// This is a manufactured testcase, but gcc accepts it...
void c4(_Bool a);
void t4() {
__attribute((cleanup(c4))) void* g;
}
void c5(void*) __attribute__((deprecated)); // expected-note{{'c5' has been explicitly marked deprecated here}}
void t5() {
int i __attribute__((cleanup(c5))); // expected-warning {{'c5' is deprecated}}
}
void t6(void) {
int i __attribute__((cleanup((void *)0))); // expected-error {{'cleanup' argument is not a function}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/var-redecl.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
int outer1; // expected-note{{previous definition is here}}
extern int outer2; // expected-note{{previous declaration is here}}
int outer4;
int outer4; // expected-note{{previous definition is here}}
int outer5;
int outer6(float); // expected-note{{previous definition is here}}
int outer7(float);
void outer_test() {
extern float outer1; // expected-error{{redeclaration of 'outer1' with a different type}}
extern float outer2; // expected-error{{redeclaration of 'outer2' with a different type}}
extern float outer3; // expected-note{{previous declaration is here}}
double outer4;
extern int outer5; // expected-note{{previous declaration is here}}
extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}}
int outer7;
extern int outer8; // expected-note{{previous definition is here}}
extern int outer9;
{
extern int outer9; // expected-note{{previous declaration is here}}
}
}
int outer3; // expected-error{{redefinition of 'outer3' with a different type}}
float outer4; // expected-error{{redefinition of 'outer4' with a different type}}
float outer5; // expected-error{{redefinition of 'outer5' with a different type}}
int outer8(int); // expected-error{{redefinition of 'outer8' as different kind of symbol}}
float outer9; // expected-error{{redefinition of 'outer9' with a different type}}
extern int outer13; // expected-note{{previous declaration is here}}
void outer_shadowing_test() {
extern int outer10;
extern int outer11; // expected-note{{previous declaration is here}}
extern int outer12; // expected-note{{previous declaration is here}}
{
float outer10;
float outer11;
float outer12;
{
extern int outer10; // okay
extern float outer11; // expected-error{{redeclaration of 'outer11' with a different type}}
static double outer12;
{
extern float outer12; // expected-error{{redeclaration of 'outer12' with a different type}}
extern float outer13; // expected-error{{redeclaration of 'outer13' with a different type}}
}
}
}
}
void g18(void) { // expected-note{{'g18' declared here}}
extern int g19;
}
int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \
// expected-warning{{incompatible pointer types}}
// PR3645
static int a;
extern int a; // expected-note {{previous declaration is here}}
int a; // expected-error {{non-static declaration of 'a' follows static declaration}}
void f(int x) { // expected-note {{previous definition is here}}
extern int x; // expected-error {{extern declaration of 'x' follows non-extern declaration}}
}
extern int b[];
void g20() { extern int b[3]; } // expected-note{{previous declaration is here}}
void g21() { extern int b[4]; } // expected-error{{redeclaration of 'b' with a different type: 'int [4]' vs 'int [3]'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/2009-07-17-VoidParameter.c
|
// RUN: %clang_cc1 -verify -fsyntax-only %s
// PR4214
typedef void vt;
void (*func_ptr)(vt my_vt); // expected-error {{argument may not have 'void' type}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-fixit.c
|
// RUN: cp %s %t
// RUN: %clang_cc1 -pedantic -Wall -fixit %t
// RUN: %clang_cc1 -fsyntax-only -pedantic -Wall -Werror %t
// RUN: %clang_cc1 -E -o - %t | FileCheck %s
/* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
warnings will be fixed by -fixit, and the resulting file should
compile cleanly with -Werror -pedantic. */
int printf(char const *, ...);
typedef __SIZE_TYPE__ size_t;
typedef __INTMAX_TYPE__ intmax_t;
typedef __UINTMAX_TYPE__ uintmax_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __WCHAR_TYPE__ wchar_t;
void test() {
// Basic types
printf("%s", (int) 123);
printf("abc%0f", "testing testing 123");
printf("%u", (long) -12);
printf("%p", 123);
printf("%c\n", "x");
printf("%c\n", 1.23);
// Larger types
printf("%+.2d", (unsigned long long) 123456);
printf("%1d", (long double) 1.23);
// Flag handling
printf("%0+s", (unsigned) 31337); // 0 flag should stay
printf("%#p", (void *) 0);
printf("% +f", 1.23); // + flag should stay
printf("%0-f", 1.23); // - flag should stay
// Positional arguments
#pragma clang diagnostic push // Don't warn about using positional arguments.
#pragma clang diagnostic ignored "-Wformat-non-iso"
printf("%1$f:%2$.*3$f:%4$.*3$f\n", 1, 2, 3, 4);
#pragma clang diagnostic pop
// Precision
printf("%10.5d", 1l); // (bug 7394)
printf("%.2c", 'a');
// Ignored flags
printf("%0-f", 1.23);
// Bad length modifiers
printf("%hhs", "foo");
#pragma clang diagnostic push // Don't warn about using positional arguments.
#pragma clang diagnostic ignored "-Wformat-non-iso"
printf("%1$zp", (void *)0);
#pragma clang diagnostic pop
// Preserve the original formatting for unsigned integers.
unsigned long val = 42;
printf("%X", val);
// size_t, etc.
printf("%f", (size_t) 42);
printf("%f", (intmax_t) 42);
printf("%f", (uintmax_t) 42);
printf("%f", (ptrdiff_t) 42);
// Look beyond the first typedef.
typedef size_t my_size_type;
typedef intmax_t my_intmax_type;
typedef uintmax_t my_uintmax_type;
typedef ptrdiff_t my_ptrdiff_type;
typedef int my_int_type;
printf("%f", (my_size_type) 42);
printf("%f", (my_intmax_type) 42);
printf("%f", (my_uintmax_type) 42);
printf("%f", (my_ptrdiff_type) 42);
printf("%f", (my_int_type) 42);
// string
printf("%ld", "foo");
// Preserve the original choice of conversion specifier.
printf("%o", (long) 42);
printf("%u", (long) 42);
printf("%x", (long) 42);
printf("%X", (long) 42);
printf("%i", (unsigned long) 42);
printf("%d", (unsigned long) 42);
printf("%F", (long double) 42);
printf("%e", (long double) 42);
printf("%E", (long double) 42);
printf("%g", (long double) 42);
printf("%G", (long double) 42);
printf("%a", (long double) 42);
printf("%A", (long double) 42);
}
int scanf(char const *, ...);
void test2(int intSAParm[static 2]) {
char str[100];
char *vstr = "abc";
short shortVar;
unsigned short uShortVar;
int intVar;
int intAVar[2];
unsigned uIntVar;
float floatVar;
double doubleVar;
long double longDoubleVar;
long longVar;
unsigned long uLongVar;
long long longLongVar;
unsigned long long uLongLongVar;
size_t sizeVar;
intmax_t intmaxVar;
uintmax_t uIntmaxVar;
ptrdiff_t ptrdiffVar;
enum {A, B, C} enumVar;
// Some string types.
scanf("%lf", str);
scanf("%lf", vstr);
scanf("%ls", str);
scanf("%ls", str);
// Some integer types.
scanf("%f", &shortVar);
scanf("%f", &uShortVar);
scanf("%p", &intVar);
scanf("%f", intAVar);
scanf("%f", intSAParm);
scanf("%Lf", &uIntVar);
scanf("%ld", &floatVar);
scanf("%f", &doubleVar);
scanf("%d", &longDoubleVar);
scanf("%f", &longVar);
scanf("%f", &uLongVar);
scanf("%f", &longLongVar);
scanf("%f", &uLongLongVar);
scanf("%d", &enumVar); // FIXME: We ought to fix specifiers for enums.
// Some named ints.
scanf("%f", &sizeVar);
scanf("%f", &intmaxVar);
scanf("%f", &uIntmaxVar);
scanf("%f", &ptrdiffVar);
// Look beyond the first typedef for named integer types.
typedef size_t my_size_type;
typedef intmax_t my_intmax_type;
typedef uintmax_t my_uintmax_type;
typedef ptrdiff_t my_ptrdiff_type;
typedef int my_int_type;
scanf("%f", (my_size_type*)&sizeVar);
scanf("%f", (my_intmax_type*)&intmaxVar);
scanf("%f", (my_uintmax_type*)&uIntmaxVar);
scanf("%f", (my_ptrdiff_type*)&ptrdiffVar);
scanf("%f", (my_int_type*)&intVar);
// Preserve the original formatting.
scanf("%o", &longVar);
scanf("%u", &longVar);
scanf("%x", &longVar);
scanf("%X", &longVar);
scanf("%i", &uLongVar);
scanf("%d", &uLongVar);
scanf("%F", &longDoubleVar);
scanf("%e", &longDoubleVar);
scanf("%E", &longDoubleVar);
scanf("%g", &longDoubleVar);
scanf("%G", &longDoubleVar);
scanf("%a", &longDoubleVar);
scanf("%A", &longDoubleVar);
}
// Validate the fixes.
// CHECK: printf("%d", (int) 123);
// CHECK: printf("abc%s", "testing testing 123");
// CHECK: printf("%ld", (long) -12);
// CHECK: printf("%d", 123);
// CHECK: printf("%s\n", "x");
// CHECK: printf("%f\n", 1.23);
// CHECK: printf("%+.2lld", (unsigned long long) 123456);
// CHECK: printf("%1Lf", (long double) 1.23);
// CHECK: printf("%0u", (unsigned) 31337);
// CHECK: printf("%p", (void *) 0);
// CHECK: printf("%+f", 1.23);
// CHECK: printf("%-f", 1.23);
// CHECK: printf("%1$d:%2$.*3$d:%4$.*3$d\n", 1, 2, 3, 4);
// CHECK: printf("%10.5ld", 1l);
// CHECK: printf("%c", 'a');
// CHECK: printf("%-f", 1.23);
// CHECK: printf("%s", "foo");
// CHECK: printf("%1$p", (void *)0);
// CHECK: printf("%lX", val);
// CHECK: printf("%zu", (size_t) 42);
// CHECK: printf("%jd", (intmax_t) 42);
// CHECK: printf("%ju", (uintmax_t) 42);
// CHECK: printf("%td", (ptrdiff_t) 42);
// CHECK: printf("%zu", (my_size_type) 42);
// CHECK: printf("%jd", (my_intmax_type) 42);
// CHECK: printf("%ju", (my_uintmax_type) 42);
// CHECK: printf("%td", (my_ptrdiff_type) 42);
// CHECK: printf("%d", (my_int_type) 42);
// CHECK: printf("%s", "foo");
// CHECK: printf("%lo", (long) 42);
// CHECK: printf("%ld", (long) 42);
// CHECK: printf("%lx", (long) 42);
// CHECK: printf("%lX", (long) 42);
// CHECK: printf("%lu", (unsigned long) 42);
// CHECK: printf("%lu", (unsigned long) 42);
// CHECK: printf("%LF", (long double) 42);
// CHECK: printf("%Le", (long double) 42);
// CHECK: printf("%LE", (long double) 42);
// CHECK: printf("%Lg", (long double) 42);
// CHECK: printf("%LG", (long double) 42);
// CHECK: printf("%La", (long double) 42);
// CHECK: printf("%LA", (long double) 42);
// CHECK: scanf("%99s", str);
// CHECK: scanf("%s", vstr);
// CHECK: scanf("%99s", str);
// CHECK: scanf("%99s", str);
// CHECK: scanf("%hd", &shortVar);
// CHECK: scanf("%hu", &uShortVar);
// CHECK: scanf("%d", &intVar);
// CHECK: scanf("%d", intAVar);
// CHECK: scanf("%d", intSAParm);
// CHECK: scanf("%u", &uIntVar);
// CHECK: scanf("%f", &floatVar);
// CHECK: scanf("%lf", &doubleVar);
// CHECK: scanf("%Lf", &longDoubleVar);
// CHECK: scanf("%ld", &longVar);
// CHECK: scanf("%lu", &uLongVar);
// CHECK: scanf("%lld", &longLongVar);
// CHECK: scanf("%llu", &uLongLongVar);
// CHECK: scanf("%d", &enumVar);
// CHECK: scanf("%zu", &sizeVar);
// CHECK: scanf("%jd", &intmaxVar);
// CHECK: scanf("%ju", &uIntmaxVar);
// CHECK: scanf("%td", &ptrdiffVar);
// CHECK: scanf("%zu", (my_size_type*)&sizeVar);
// CHECK: scanf("%jd", (my_intmax_type*)&intmaxVar);
// CHECK: scanf("%ju", (my_uintmax_type*)&uIntmaxVar);
// CHECK: scanf("%td", (my_ptrdiff_type*)&ptrdiffVar);
// CHECK: scanf("%d", (my_int_type*)&intVar);
// CHECK: scanf("%lo", &longVar);
// CHECK: scanf("%lu", &longVar);
// CHECK: scanf("%lx", &longVar);
// CHECK: scanf("%lX", &longVar);
// CHECK: scanf("%li", &uLongVar);
// CHECK: scanf("%ld", &uLongVar);
// CHECK: scanf("%LF", &longDoubleVar);
// CHECK: scanf("%Le", &longDoubleVar);
// CHECK: scanf("%LE", &longDoubleVar);
// CHECK: scanf("%Lg", &longDoubleVar);
// CHECK: scanf("%LG", &longDoubleVar);
// CHECK: scanf("%La", &longDoubleVar);
// CHECK: scanf("%LA", &longDoubleVar);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ast-print.c
|
// RUN: %clang_cc1 %s -ast-print | FileCheck %s
typedef void func_typedef();
func_typedef xxx;
typedef void func_t(int x);
func_t a;
struct blah {
struct {
struct {
int b;
};
};
};
int foo(const struct blah *b) {
// CHECK: return b->b;
return b->b;
}
int arr(int a[static 3]) {
// CHECK: int a[static 3]
return a[2];
}
int rarr(int a[restrict static 3]) {
// CHECK: int a[restrict static 3]
return a[2];
}
int varr(int n, int a[static n]) {
// CHECK: int a[static n]
return a[2];
}
int rvarr(int n, int a[restrict static n]) {
// CHECK: int a[restrict static n]
return a[2];
}
typedef struct {
int f;
} T __attribute__ ((__aligned__));
// CHECK: struct __attribute__((visibility("default"))) S;
struct __attribute__((visibility("default"))) S;
struct pair_t {
int a;
int b;
};
// CHECK: struct pair_t p = {a: 3, .b = 4};
struct pair_t p = {a: 3, .b = 4};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-return-1.c
|
// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
int j;
void foo() {
^ (void) { if (j) return 1; }(); // expected-error {{control may reach end of non-void block}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/128bitint.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 -fms-extensions %s -DHAVE
// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -fms-extensions %s -DHAVE_NOT
#ifdef HAVE
typedef int i128 __attribute__((__mode__(TI)));
typedef unsigned u128 __attribute__((__mode__(TI)));
int a[((i128)-1 ^ (i128)-2) == 1 ? 1 : -1];
int a[(u128)-1 > 1LL ? 1 : -1];
int a[__SIZEOF_INT128__ == 16 ? 1 : -1];
// PR5435
__uint128_t b = (__uint128_t)-1;
// PR11916: Support for libstdc++ 4.7
__int128 i = (__int128)0;
unsigned __int128 u = (unsigned __int128)-1;
long long SignedTooBig = 123456789012345678901234567890; // expected-error {{integer literal is too large to be represented in any integer type}}
__int128_t Signed128 = 123456789012345678901234567890i128;
long long Signed64 = 123456789012345678901234567890i128; // expected-warning {{implicit conversion from '__int128' to 'long long' changes value from 123456789012345678901234567890 to -4362896299872285998}}
unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-error {{integer literal is too large to be represented in any integer type}}
__uint128_t Unsigned128 = 123456789012345678901234567890Ui128;
unsigned long long Unsigned64 = 123456789012345678901234567890Ui128; // expected-warning {{implicit conversion from 'unsigned __int128' to 'unsigned long long' changes value from 123456789012345678901234567890 to 14083847773837265618}}
// Ensure we don't crash when user passes 128-bit values to type safety
// attributes.
void pointer_with_type_tag_arg_num_1(void *buf, int datatype)
__attribute__(( pointer_with_type_tag(mpi,0x10000000000000001i128,1) )); // expected-error {{attribute parameter 2 is out of bounds}}
void pointer_with_type_tag_arg_num_2(void *buf, int datatype)
__attribute__(( pointer_with_type_tag(mpi,1,0x10000000000000001i128) )); // expected-error {{attribute parameter 3 is out of bounds}}
void MPI_Send(void *buf, int datatype) __attribute__(( pointer_with_type_tag(mpi,1,2) ));
static const __uint128_t mpi_int_wrong __attribute__(( type_tag_for_datatype(mpi,int) )) = 0x10000000000000001i128; // expected-error {{'type_tag_for_datatype' attribute requires the initializer to be an integer constant expression that can be represented by a 64 bit integer}}
static const int mpi_int __attribute__(( type_tag_for_datatype(mpi,int) )) = 10;
void test(int *buf)
{
MPI_Send(buf, 0x10000000000000001i128); // expected-warning {{implicit conversion from '__int128' to 'int' changes value}}
}
#else
__int128 n; // expected-error {{__int128 is not supported on this target}}
#if defined(__SIZEOF_INT128__)
#error __SIZEOF_INT128__ should not be defined
#endif
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-documentation-fixits.cpp
|
// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s
// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
// expected-warning@+1 {{parameter 'ZZZZZZZZZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
/// \param ZZZZZZZZZZ Blah blah.
int test1(int a);
// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
/// \param aab Blah blah.
int test2(int aaa, int bbb);
// expected-warning@+1 {{template parameter 'ZZZZZZZZZZ' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
/// \tparam ZZZZZZZZZZ Aaa
template<typename T>
void test3(T aaa);
// expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
/// \tparam SomTy Aaa
/// \tparam OtherTy Bbb
template<typename SomeTy, typename OtherTy>
void test4(SomeTy aaa, OtherTy bbb);
// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
/// \deprecated
void test_deprecated_1();
// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
/// \deprecated
void test_deprecated_2(int a);
struct test_deprecated_3 {
// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
/// \deprecated
void test_deprecated_4();
// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
/// \deprecated
void test_deprecated_5() {
}
};
template<typename T>
struct test_deprecated_6 {
// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
/// \deprecated
void test_deprecated_7();
// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
/// \deprecated
void test_deprecated_8() {
}
};
#define MY_ATTR_DEPRECATED __attribute__((deprecated))
// expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
/// \deprecated
void test_deprecated_9(int a);
// rdar://12381408
// expected-warning@+2 {{unknown command tag name 'retur'; did you mean 'return'?}}
/// \brief testing fixit
/// \retur int in FooBar
int FooBar();
// expected-warning@+1 {{unknown command tag name 'fooba'; did you mean 'foobar'?}}
/// \fooba bbb IS_DOXYGEN_END
int gorf();
// expected-warning@+1 {{unknown command tag name}}
/// \t bbb IS_DOXYGEN_END
int Bar();
// expected-warning@+2 {{unknown command tag name 'encode'; did you mean 'endcode'?}}
// expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
/// \encode PR18051
int PR18051();
// CHECK: fix-it:"{{.*}}":{5:12-5:22}:"a"
// CHECK: fix-it:"{{.*}}":{9:12-9:15}:"aaa"
// CHECK: fix-it:"{{.*}}":{13:13-13:23}:"T"
// CHECK: fix-it:"{{.*}}":{18:13-18:18}:"SomeTy"
// CHECK: fix-it:"{{.*}}":{25:25-25:25}:" __attribute__((deprecated))"
// CHECK: fix-it:"{{.*}}":{29:30-29:30}:" __attribute__((deprecated))"
// CHECK: fix-it:"{{.*}}":{34:27-34:27}:" __attribute__((deprecated))"
// CHECK: fix-it:"{{.*}}":{38:27-38:27}:" __attribute__((deprecated))"
// CHECK: fix-it:"{{.*}}":{46:27-46:27}:" __attribute__((deprecated))"
// CHECK: fix-it:"{{.*}}":{50:27-50:27}:" __attribute__((deprecated))"
// CHECK: fix-it:"{{.*}}":{58:30-58:30}:" MY_ATTR_DEPRECATED"
// CHECK: fix-it:"{{.*}}":{63:6-63:11}:"return"
// CHECK: fix-it:"{{.*}}":{67:6-67:11}:"foobar"
// CHECK: fix-it:"{{.*}}":{76:6-76:12}:"endcode"
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtins-arm64-exclusive.c
|
// RUN: %clang_cc1 -triple arm64-apple-ios7.0 -fsyntax-only -verify %s
struct Simple {
char a, b;
};
int test_ldrex(char *addr) {
int sum = 0;
sum += __builtin_arm_ldrex(addr);
sum += __builtin_arm_ldrex((short *)addr);
sum += __builtin_arm_ldrex((int *)addr);
sum += __builtin_arm_ldrex((long long *)addr);
sum += __builtin_arm_ldrex((__int128 *)addr);
sum += __builtin_arm_ldrex((float *)addr);
sum += __builtin_arm_ldrex((double *)addr);
sum += *__builtin_arm_ldrex((int **)addr);
sum += __builtin_arm_ldrex((struct Simple **)addr)->a;
sum += __builtin_arm_ldrex((volatile char *)addr);
sum += __builtin_arm_ldrex((const volatile char *)addr);
// In principle this might be valid, but stick to ints and floats for scalar
// types at the moment.
sum += __builtin_arm_ldrex((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}}
__builtin_arm_ldrex(); // expected-error {{too few arguments to function call}}
__builtin_arm_ldrex(1, 2); // expected-error {{too many arguments to function call}}
return sum;
}
int test_strex(char *addr) {
int res = 0;
struct Simple var = {0};
res |= __builtin_arm_strex(4, addr);
res |= __builtin_arm_strex(42, (short *)addr);
res |= __builtin_arm_strex(42, (int *)addr);
res |= __builtin_arm_strex(42, (long long *)addr);
res |= __builtin_arm_strex(42, (__int128 *)addr);
res |= __builtin_arm_strex(2.71828f, (float *)addr);
res |= __builtin_arm_strex(3.14159, (double *)addr);
res |= __builtin_arm_strex(&var, (struct Simple **)addr);
res |= __builtin_arm_strex(42, (volatile char *)addr);
res |= __builtin_arm_strex(42, (char *const)addr);
res |= __builtin_arm_strex(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}}
res |= __builtin_arm_strex(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}}
res |= __builtin_arm_strex(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}}
res |= __builtin_arm_strex(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}}
__builtin_arm_strex(1); // expected-error {{too few arguments to function call}}
__builtin_arm_strex(1, 2, 3); // expected-error {{too many arguments to function call}}
return res;
}
int test_ldaex(char *addr) {
int sum = 0;
sum += __builtin_arm_ldaex(addr);
sum += __builtin_arm_ldaex((short *)addr);
sum += __builtin_arm_ldaex((int *)addr);
sum += __builtin_arm_ldaex((long long *)addr);
sum += __builtin_arm_ldaex((__int128 *)addr);
sum += __builtin_arm_ldaex((float *)addr);
sum += __builtin_arm_ldaex((double *)addr);
sum += *__builtin_arm_ldaex((int **)addr);
sum += __builtin_arm_ldaex((struct Simple **)addr)->a;
sum += __builtin_arm_ldaex((volatile char *)addr);
sum += __builtin_arm_ldaex((const volatile char *)addr);
// In principle this might be valid, but stick to ints and floats for scalar
// types at the moment.
sum += __builtin_arm_ldaex((struct Simple *)addr).a; // expected-error {{address argument to atomic builtin must be a pointer to}}
__builtin_arm_ldaex(); // expected-error {{too few arguments to function call}}
__builtin_arm_ldaex(1, 2); // expected-error {{too many arguments to function call}}
return sum;
}
int test_stlex(char *addr) {
int res = 0;
struct Simple var = {0};
res |= __builtin_arm_stlex(4, addr);
res |= __builtin_arm_stlex(42, (short *)addr);
res |= __builtin_arm_stlex(42, (int *)addr);
res |= __builtin_arm_stlex(42, (long long *)addr);
res |= __builtin_arm_stlex(42, (__int128 *)addr);
res |= __builtin_arm_stlex(2.71828f, (float *)addr);
res |= __builtin_arm_stlex(3.14159, (double *)addr);
res |= __builtin_arm_stlex(&var, (struct Simple **)addr);
res |= __builtin_arm_stlex(42, (volatile char *)addr);
res |= __builtin_arm_stlex(42, (char *const)addr);
res |= __builtin_arm_stlex(42, (const char *)addr); // expected-warning {{passing 'const char *' to parameter of type 'volatile char *' discards qualifiers}}
res |= __builtin_arm_stlex(var, (struct Simple *)addr); // expected-error {{address argument to atomic builtin must be a pointer to}}
res |= __builtin_arm_stlex(var, (struct Simple **)addr); // expected-error {{passing 'struct Simple' to parameter of incompatible type 'struct Simple *'}}
res |= __builtin_arm_stlex(&var, (struct Simple **)addr).a; // expected-error {{is not a structure or union}}
__builtin_arm_stlex(1); // expected-error {{too few arguments to function call}}
__builtin_arm_stlex(1, 2, 3); // expected-error {{too many arguments to function call}}
return res;
}
void test_clrex() {
__builtin_arm_clrex();
__builtin_arm_clrex(1); // expected-error {{too many arguments to function call}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/self-comparison.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
int foo(int x) {
return x == x; // expected-warning {{self-comparison always evaluates to true}}
}
int foo2(int x) {
return (x) != (((x))); // expected-warning {{self-comparison always evaluates to false}}
}
void foo3(short s, short t) {
if (s == s) {} // expected-warning {{self-comparison always evaluates to true}}
if (s == t) {} // no-warning
}
void foo4(void* v, void* w) {
if (v == v) {} // expected-warning {{self-comparison always evaluates to true}}
if (v == w) {} // no-warning
}
int qux(int x) {
return x < x; // expected-warning {{self-comparison}}
}
int qux2(int x) {
return x > x; // expected-warning {{self-comparison}}
}
int bar(float x) {
return x == x; // no-warning
}
int bar2(float x) {
return x != x; // no-warning
}
#define IS_THE_ANSWER(x) (x == 42)
int macro_comparison() {
return IS_THE_ANSWER(42);
}
// Don't complain in unevaluated contexts.
int compare_sizeof(int x) {
return sizeof(x == x); // no-warning
}
int array_comparisons() {
int array1[2];
int array2[2];
//
// compare same array
//
return array1 == array1; // expected-warning{{self-comparison always evaluates to true}}
return array1 != array1; // expected-warning{{self-comparison always evaluates to false}}
return array1 < array1; // expected-warning{{self-comparison always evaluates to false}}
return array1 <= array1; // expected-warning{{self-comparison always evaluates to true}}
return array1 > array1; // expected-warning{{self-comparison always evaluates to false}}
return array1 >= array1; // expected-warning{{self-comparison always evaluates to true}}
//
// compare differrent arrays
//
return array1 == array2; // expected-warning{{array comparison always evaluates to false}}
return array1 != array2; // expected-warning{{array comparison always evaluates to true}}
//
// we don't know what these are going to be
//
return array1 < array2; // expected-warning{{array comparison always evaluates to a constant}}
return array1 <= array2; // expected-warning{{array comparison always evaluates to a constant}}
return array1 > array2; // expected-warning{{array comparison always evaluates to a constant}}
return array1 >= array2; // expected-warning{{array comparison always evaluates to a constant}}
}
// Don't issue a warning when either the left or right side of the comparison
// results from a macro expansion. <rdar://problem/8435950>
#define R8435950_A i
#define R8435950_B i
int R8435950(int i) {
if (R8435950_A == R8435950_B) // no-warning
return 0;
return 1;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-alias-elf.c
|
// RUN: %clang_cc1 -triple x86_64-pc-linux -fsyntax-only -verify -emit-llvm-only %s
void f1(void) __attribute__((alias("g1")));
void g1(void) {
}
void f2(void) __attribute__((alias("g2"))); // expected-error {{alias must point to a defined variable or function}}
void f3(void) __attribute__((alias("g3"))); // expected-error {{alias must point to a defined variable or function}}
void g3(void);
void f4() __attribute__((alias("g4")));
void g4() {}
void h4() __attribute__((alias("f4")));
void f5() __attribute__((alias("g5")));
void h5() __attribute__((alias("f5")));
void g5() {}
void g6() {}
void f6() __attribute__((alias("g6")));
void h6() __attribute__((alias("f6")));
void g7() {}
void h7() __attribute__((alias("f7")));
void f7() __attribute__((alias("g7")));
void h8() __attribute__((alias("f8")));
void g8() {}
void f8() __attribute__((alias("g8")));
void h9() __attribute__((alias("f9")));
void f9() __attribute__((alias("g9")));
void g9() {}
void f10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}}
void g10() __attribute__((alias("f10"))); // expected-error {{alias definition is part of a cycle}}
// FIXME: This could be a bit better, h10 is not part of the cycle, it points
// to it.
void h10() __attribute__((alias("g10"))); // expected-error {{alias definition is part of a cycle}}
extern int a1 __attribute__((alias("b1")));
int b1 = 42;
extern int a2 __attribute__((alias("b2"))); // expected-error {{alias must point to a defined variable or function}}
extern int a3 __attribute__((alias("b3"))); // expected-error {{alias must point to a defined variable or function}}
extern int b3;
extern int a4 __attribute__((alias("b4"))); // expected-error {{alias must point to a defined variable or function}}
typedef int b4;
void test2_bar() {}
void test2_foo() __attribute__((weak, alias("test2_bar")));
void test2_zed() __attribute__((alias("test2_foo"))); // expected-warning {{alias will always resolve to test2_bar even if weak definition of alias test2_foo is overridden}}
void test3_bar() { }
void test3_foo() __attribute__((section("test"))); // expected-warning {{alias will not be in section 'test' but in the same section as the aliasee}}
void test3_foo() __attribute__((alias("test3_bar")));
__attribute__((section("test"))) void test4_bar() { }
void test4_foo() __attribute__((section("test")));
void test4_foo() __attribute__((alias("test4_bar")));
int test5_bar = 0;
extern struct incomplete_type test5_foo __attribute__((alias("test5_bar")));
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/callingconv-sysv_abi.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-linux-gnu %s
void __attribute__((ms_abi)) foo(void);
void (*pfoo)(void) = foo; // expected-warning{{incompatible pointer types}}
void __attribute__((sysv_abi)) bar(void);
void (*pbar)(void) = bar;
void (__attribute__((ms_abi)) *pbar2)(void) = bar; // expected-warning{{incompatible pointer types}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/generic-selection.c
|
// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s
void foo(int n) {
(void) _Generic(0,
struct A: 0, // expected-error {{type 'struct A' in generic association incomplete}}
void(): 0, // expected-error {{type 'void ()' in generic association not an object type}}
int[n]: 0); // expected-error {{type 'int [n]' in generic association is a variably modified type}}
(void) _Generic(0,
void (*)(): 0, // expected-note {{compatible type 'void (*)()' specified here}}
void (*)(void): 0); // expected-error {{type 'void (*)(void)' in generic association compatible with previously specified type 'void (*)()'}}
(void) _Generic((void (*)()) 0, // expected-error {{controlling expression type 'void (*)()' compatible with 2 generic association types}}
void (*)(int): 0, // expected-note {{compatible type 'void (*)(int)' specified here}}
void (*)(void): 0); // expected-note {{compatible type 'void (*)(void)' specified here}}
(void) _Generic(0, // expected-error {{controlling expression type 'int' not compatible with any generic association type}}
char: 0, short: 0, long: 0);
int a1[_Generic(0, int: 1, short: 2, float: 3, default: 4) == 1 ? 1 : -1];
int a2[_Generic(0, default: 1, short: 2, float: 3, int: 4) == 4 ? 1 : -1];
int a3[_Generic(0L, int: 1, short: 2, float: 3, default: 4) == 4 ? 1 : -1];
int a4[_Generic(0L, default: 1, short: 2, float: 3, int: 4) == 1 ? 1 : -1];
int a5[_Generic(0, int: 1, short: 2, float: 3) == 1 ? 1 : -1];
int a6[_Generic(0, short: 1, float: 2, int: 3) == 3 ? 1 : -1];
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-arc-cf-code-audited.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
#pragma clang arc_cf_code_audited foo // expected-error {{expected 'begin' or 'end'}}
#pragma clang arc_cf_code_audited begin foo // expected-warning {{extra tokens at end of #pragma directive}}
#pragma clang arc_cf_code_audited end
#pragma clang arc_cf_code_audited end // expected-error {{not currently inside '#pragma clang arc_cf_code_audited'}}
#pragma clang arc_cf_code_audited begin // expected-note {{#pragma entered here}}
#pragma clang arc_cf_code_audited begin // expected-error {{already inside '#pragma clang arc_cf_code_audited'}} expected-note {{#pragma entered here}}
#include "Inputs/pragma-arc-cf-code-audited.h" // expected-error {{cannot #include files inside '#pragma clang arc_cf_code_audited'}}
// This is actually on the #pragma line in the header.
// expected-error@Inputs/pragma-arc-cf-code-audited.h:16 {{'#pragma clang arc_cf_code_audited' was not ended within this file}}
#pragma clang arc_cf_code_audited begin // expected-error {{'#pragma clang arc_cf_code_audited' was not ended within this file}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/constructor-attribute.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
int x __attribute__((constructor)); // expected-warning {{'constructor' attribute only applies to functions}}
int f() __attribute__((constructor));
int f() __attribute__((constructor(1)));
int f() __attribute__((constructor(1,2))); // expected-error {{'constructor' attribute takes no more than 1 argument}}
int f() __attribute__((constructor(1.0))); // expected-error {{'constructor' attribute requires an integer constant}}
int f() __attribute__((constructor(0x100000000))); // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
int x __attribute__((destructor)); // expected-warning {{'destructor' attribute only applies to functions}}
int f() __attribute__((destructor));
int f() __attribute__((destructor(1)));
int f() __attribute__((destructor(1,2))); // expected-error {{'destructor' attribute takes no more than 1 argument}}
int f() __attribute__((destructor(1.0))); // expected-error {{'destructor' attribute requires an integer constant}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-availability-app-extensions.c
|
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9.0 -fsyntax-only -fapplication-extension %s -verify
// RUN: %clang_cc1 -triple armv7-apple-ios9.0 -fsyntax-only -fapplication-extension %s -verify
#if __has_feature(attribute_availability_app_extension)
__attribute__((availability(macosx_app_extension,unavailable)))
__attribute__((availability(ios_app_extension,unavailable)))
#endif
void f0(int); // expected-note {{'f0' has been explicitly marked unavailable here}}
__attribute__((availability(macosx,unavailable)))
__attribute__((availability(ios,unavailable)))
void f1(int); // expected-note {{'f1' has been explicitly marked unavailable here}}
void test() {
f0(1); // expected-error {{'f0' is unavailable: not available on}}
f1(1); // expected-error {{'f1' is unavailable}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/invalid-cast.cpp
|
// RUN: %clang_cc1 -verify -fsyntax-only %s
// expected-no-diagnostics
// <rdar://problem/13153516> - This previously triggered an assertion failure.
template<class T>
struct X {
T array;
};
int foo(X<int[1]> x0) {
return x0.array[17];
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/heinous-extensions-off.c
|
// RUN: %clang_cc1 %s -verify
int foo() {
int a;
// PR3788
asm("nop" : : "m"((int)(a))); // expected-error {{cast in a inline asm context requiring an l-value}}
// PR3794
asm("nop" : "=r"((unsigned)a)); // expected-error {{cast in a inline asm context requiring an l-value}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ms_abi-sysv_abi.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-pc-linux-gnu %s
// CC qualifier can be applied only to functions
int __attribute__((ms_abi)) var1; // expected-warning{{'ms_abi' only applies to function types; type here is 'int'}}
int __attribute__((sysv_abi)) var2; // expected-warning{{'sysv_abi' only applies to function types; type here is 'int'}}
// Different CC qualifiers are not compatible
// FIXME: Should say 'sysv_abi' instead of 'cdecl'
void __attribute__((ms_abi, sysv_abi)) foo3(void); // expected-error{{cdecl and ms_abi attributes are not compatible}}
void __attribute__((ms_abi)) foo4(); // expected-note{{previous declaration is here}}
void __attribute__((sysv_abi)) foo4(void); // expected-error{{function declared 'cdecl' here was previously declared 'ms_abi'}}
void bar(int i, int j) __attribute__((ms_abi, cdecl)); // expected-error{{cdecl and ms_abi attributes are not compatible}}
void bar2(int i, int j) __attribute__((sysv_abi, cdecl)); // no-error
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.