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/member-reference.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
struct simple { int i; };
void f(void) {
struct simple s[1];
s->i = 1;
}
typedef int x;
struct S {
int x;
x z;
};
void g(void) {
struct S s[1];
s->x = 1;
s->z = 2;
}
int PR17762(struct simple c) {
return c->i; // expected-error {{member reference type 'struct simple' is not a pointer; did you mean to use '.'?}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/invalid-init-diag.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
int a;
struct {int x;} x = a; // expected-error {{with an expression of incompatible type 'int'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/stdcall-fastcall.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-apple-darwin10 %s
// CC qualifier can be applied only to functions
int __attribute__((stdcall)) var1; // expected-warning{{'stdcall' only applies to function types; type here is 'int'}}
int __attribute__((fastcall)) var2; // expected-warning{{'fastcall' only applies to function types; type here is 'int'}}
// Different CC qualifiers are not compatible
void __attribute__((stdcall, fastcall)) foo3(void); // expected-error{{fastcall and stdcall attributes are not compatible}}
void __attribute__((stdcall)) foo4(); // expected-note{{previous declaration is here}} expected-warning{{function with no prototype cannot use the stdcall calling convention}}
void __attribute__((fastcall)) foo4(void); // expected-error{{function declared 'fastcall' here was previously declared 'stdcall'}}
// rdar://8876096
void rdar8876096foo1(int i, int j) __attribute__((fastcall, cdecl)); // expected-error {{not compatible}}
void rdar8876096foo2(int i, int j) __attribute__((fastcall, stdcall)); // expected-error {{not compatible}}
void rdar8876096foo3(int i, int j) __attribute__((fastcall, regparm(2))); // expected-error {{not compatible}}
void rdar8876096foo4(int i, int j) __attribute__((stdcall, cdecl)); // expected-error {{not compatible}}
void rdar8876096foo5(int i, int j) __attribute__((stdcall, fastcall)); // expected-error {{not compatible}}
void rdar8876096foo6(int i, int j) __attribute__((cdecl, fastcall)); // expected-error {{not compatible}}
void rdar8876096foo7(int i, int j) __attribute__((cdecl, stdcall)); // expected-error {{not compatible}}
void rdar8876096foo8(int i, int j) __attribute__((regparm(2), fastcall)); // expected-error {{not compatible}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/align-x86-64.c
|
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s
// expected-no-diagnostics
// PR5637
typedef __attribute__((aligned(16))) struct {
unsigned long long w[3];
} UINT192;
UINT192 ten2mk192M[] = {
{{0xcddd6e04c0592104ULL, 0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}},
{{0xcddd6e04c0592104ULL, 0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}},
{{0xcddd6e04c0592104ULL, 0x0fcf80dc33721d53ULL, 0xa7c5ac471b478423ULL}}
};
short chk1[sizeof(ten2mk192M) == 80 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtins-x86.c
|
// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
typedef long long __m128i __attribute__((__vector_size__(16)));
typedef float __m128 __attribute__((__vector_size__(16)));
typedef double __m128d __attribute__((__vector_size__(16)));
typedef float __m512 __attribute__((__vector_size__(64)));
typedef double __m512d __attribute__((__vector_size__(64)));
typedef unsigned char __mmask8;
typedef unsigned short __mmask16;
__m128 test__builtin_ia32_cmpps(__m128 __a, __m128 __b) {
__builtin_ia32_cmpps(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
}
__m128d test__builtin_ia32_cmppd(__m128d __a, __m128d __b) {
__builtin_ia32_cmppd(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
}
__m128 test__builtin_ia32_cmpss(__m128 __a, __m128 __b) {
__builtin_ia32_cmpss(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
}
__m128d test__builtin_ia32_cmpsd(__m128d __a, __m128d __b) {
__builtin_ia32_cmpsd(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}}
}
__mmask16 test__builtin_ia32_cmpps512_mask(__m512d __a, __m512d __b) {
__builtin_ia32_cmpps512_mask(__a, __b, 32, -1, 0); // expected-error {{argument should be a value from 0 to 31}}
}
__mmask8 test__builtin_ia32_cmppd512_mask(__m512d __a, __m512d __b) {
__builtin_ia32_cmppd512_mask(__a, __b, 32, -1, 0); // expected-error {{argument should be a value from 0 to 31}}
}
__m128i test__builtin_ia32_vpcomub(__m128i __a, __m128i __b) {
__builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
}
__m128i test__builtin_ia32_vpcomuw(__m128i __a, __m128i __b) {
__builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
}
__m128i test__builtin_ia32_vpcomud(__m128i __a, __m128i __b) {
__builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
}
__m128i test__builtin_ia32_vpcomuq(__m128i __a, __m128i __b) {
__builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
}
__m128i test__builtin_ia32_vpcomb(__m128i __a, __m128i __b) {
__builtin_ia32_vpcomub(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
}
__m128i test__builtin_ia32_vpcomw(__m128i __a, __m128i __b) {
__builtin_ia32_vpcomuw(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
}
__m128i test__builtin_ia32_vpcomd(__m128i __a, __m128i __b) {
__builtin_ia32_vpcomud(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
}
__m128i test__builtin_ia32_vpcomq(__m128i __a, __m128i __b) {
__builtin_ia32_vpcomuq(__a, __b, 8); // expected-error {{argument should be a value from 0 to 7}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/complex-int.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
void a() {
__complex__ int arr;
__complex__ short brr;
__complex__ unsigned xx;
__complex__ signed yy;
__complex__ int result;
int ii;
int aa = 1 + 1.0iF;
int bb = 0;
bb += 1i;
result = arr*ii;
result = ii*brr;
result = arr*brr;
result = xx*yy;
switch (arr) { // expected-error{{statement requires expression of integer type ('_Complex int' invalid)}}
case brr: ; // expected-error{{expression is not an integer constant expression}}
case xx: ; // expected-error{{expression is not an integer constant expression}}
}
}
void Tester() {
__complex short a1;
__complex int a2;
__complex float a3;
__complex double a4;
short a5;
int a6;
float a7;
double a8;
#define TestPair(m,n) int x##m##n = a##m+a##n;
#define TestPairs(m) TestPair(m,1) TestPair(m,2) \
TestPair(m,3) TestPair(m,4) \
TestPair(m,5) TestPair(m,6) \
TestPair(m,7) TestPair(m,8)
TestPairs(1); TestPairs(2);
TestPairs(3); TestPairs(4);
TestPairs(5); TestPairs(6);
TestPairs(7); TestPairs(8);
}
// rdar://6097730
void test3(_Complex int *x) {
*x = ~*x;
}
void test4(_Complex float *x) {
*x = ~*x;
}
void test5(_Complex int *x) {
(*x)++;
}
int i1[(2+3i)*(5+7i) == 29i-11 ? 1 : -1];
int i2[(29i-11)/(5+7i) == 2+3i ? 1 : -1];
int i3[-(2+3i) == +(-3i-2) ? 1 : -1];
int i4[~(2+3i) == 2-3i ? 1 : -1];
int i5[(3i == -(-3i) ? ((void)3, 1i - 1) : 0) == 1i - 1 ? 1 : -1];
int f1[(2.0+3.0i)*(5.0+7.0i) == 29.0i-11.0 ? 1 : -1];
int f2[(29.0i-11.0)/(5.0+7.0i) == 2.0+3.0i ? 1 : -1];
int f3[-(2.0+3.0i) == +(-3.0i-2.0) ? 1 : -1];
int f4[~(2.0+3.0i) == 2.0-3.0i ? 1 : -1];
int f5[(3.0i == -(-3.0i) ? ((void)3.0, __extension__ (1.0i - 1.0)) : 0) == 1.0i - 1.0 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-pack-2.c
|
// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
// expected-no-diagnostics
#include <stddef.h>
#pragma pack(4)
// Baseline
struct s0 {
char f0;
int f1;
};
extern int a0[offsetof(struct s0, f1) == 4 ? 1 : -1];
#pragma pack(push, 2)
struct s1 {
char f0;
int f1;
};
extern int a1[offsetof(struct s1, f1) == 2 ? 1 : -1];
#pragma pack(pop)
#pragma pack(1)
struct s3_0 {
char f0;
int f1;
};
#pragma pack()
struct s3_1 {
char f0;
int f1;
};
extern int a3_0[offsetof(struct s3_0, f1) == 1 ? 1 : -1];
extern int a3_1[offsetof(struct s3_1, f1) == 4 ? 1 : -1];
// pack(0) is like pack()
#pragma pack(1)
struct s4_0 {
char f0;
int f1;
};
#pragma pack(0)
struct s4_1 {
char f0;
int f1;
};
extern int a4_0[offsetof(struct s4_0, f1) == 1 ? 1 : -1];
extern int a4_1[offsetof(struct s4_1, f1) == 4 ? 1 : -1];
void f() {
#pragma pack(push, 2)
struct s5_0 {
char f0;
struct s2_4_0 {
int f0;
} f1;
};
#pragma pack(pop)
extern int s5_0[offsetof(struct s5_0, f1) == 2 ? 1 : -1];
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/implicit-cast.c
|
// RUN: %clang_cc1 -fsyntax-only %s
static char *test1(int cf) {
return cf ? "abc" : 0;
}
static char *test2(int cf) {
return cf ? 0 : "abc";
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/vector-ops.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
typedef unsigned int v2u __attribute__ ((vector_size (8)));
typedef int v2s __attribute__ ((vector_size (8)));
typedef float v2f __attribute__ ((vector_size(8)));
void test1(v2u v2ua, v2s v2sa, v2f v2fa) {
// Bitwise binary operators
(void)(v2ua & v2ua);
(void)(v2fa & v2fa); // expected-error{{invalid operands to binary expression}}
// Unary operators
(void)(~v2ua);
(void)(~v2fa); // expected-error{{invalid argument type 'v2f' (vector of 2 'float' values) to unary}}
// Comparison operators
v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'int __attribute__((ext_vector_type(2)))' (vector of 2 'int' values)}}
v2sa = (v2ua==v2sa);
// Arrays
int array1[v2ua]; // expected-error{{size of array has non-integer type 'v2u' (vector of 2 'unsigned int' values)}}
int array2[17];
// FIXME: error message below needs type!
(void)(array2[v2ua]); // expected-error{{array subscript is not an integer}}
v2u *v2u_ptr = 0;
v2s *v2s_ptr;
v2s_ptr = v2u_ptr; // expected-warning{{converts between pointers to integer types with different sign}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ext_vector_casts.c
|
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only -verify -fno-lax-vector-conversions -Wconversion %s
typedef __attribute__(( ext_vector_type(2) )) float float2;
typedef __attribute__(( ext_vector_type(3) )) float float3;
typedef __attribute__(( ext_vector_type(4) )) int int4;
typedef __attribute__(( ext_vector_type(8) )) short short8;
typedef __attribute__(( ext_vector_type(4) )) float float4;
typedef float t3 __attribute__ ((vector_size (16)));
typedef __typeof__(sizeof(int)) size_t;
typedef unsigned long ulong2 __attribute__ ((ext_vector_type(2)));
typedef size_t stride4 __attribute__((ext_vector_type(4)));
static void test() {
float2 vec2;
float3 vec3;
float4 vec4, vec4_2;
int4 ivec4;
short8 ish8;
t3 vec4_3;
int *ptr;
int i;
vec3 += vec2; // expected-error {{can't convert between vector values of different size}}
vec4 += vec3; // expected-error {{can't convert between vector values of different size}}
vec4 = 5.0f;
vec4 = (float4)5.0f;
vec4 = (float4)5;
vec4 = (float4)vec4_3;
ivec4 = (int4)5.0f;
ivec4 = (int4)5;
ivec4 = (int4)vec4_3;
i = (int)ivec4; // expected-error {{invalid conversion between vector type 'int4' (vector of 4 'int' values) and integer type 'int' of different size}}
i = ivec4; // expected-error {{assigning to 'int' from incompatible type 'int4' (vector of 4 'int' values)}}
ivec4 = (int4)ptr; // expected-error {{invalid conversion between vector type 'int4' (vector of 4 'int' values) and scalar type 'int *'}}
vec4 = (float4)vec2; // expected-error {{invalid conversion between ext-vector type 'float4' (vector of 4 'float' values) and 'float2' (vector of 2 'float' values)}}
ish8 += 5;
ivec4 *= 5;
vec4 /= 5.2f;
vec4 %= 4; // expected-error {{invalid operands to binary expression ('float4' (vector of 4 'float' values) and 'int')}}
ivec4 %= 4;
ivec4 += vec4; // expected-error {{can't convert between vector values of different size ('int4' (vector of 4 'int' values) and 'float4' (vector of 4 'float' values))}}
ivec4 += (int4)vec4;
ivec4 -= ivec4;
ivec4 |= ivec4;
ivec4 += ptr; // expected-error {{can't convert between vector and non-scalar values ('int4' (vector of 4 'int' values) and 'int *')}}
}
typedef __attribute__(( ext_vector_type(2) )) float2 vecfloat2; // expected-error{{invalid vector element type 'float2' (vector of 2 'float' values)}}
void inc(float2 f2) {
f2++; // expected-error{{cannot increment value of type 'float2' (vector of 2 'float' values)}}
__real f2; // expected-error{{invalid type 'float2' (vector of 2 'float' values) to __real operator}}
}
typedef enum
{
uchar_stride = 1,
uchar4_stride = 4,
ushort4_stride = 8,
short4_stride = 8,
uint4_stride = 16,
int4_stride = 16,
float4_stride = 16,
} PixelByteStride;
stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride);
stride4 RDar15091442_get_stride4(int4 x, PixelByteStride pixelByteStride)
{
stride4 stride;
// This previously caused an assertion failure.
stride.lo = ((ulong2) x) * pixelByteStride; // no-warning
return stride;
}
// rdar://16196902
typedef __attribute__((ext_vector_type(4))) float float32x4_t;
typedef float C3DVector3 __attribute__((ext_vector_type(3)));
extern float32x4_t vabsq_f32(float32x4_t __a);
C3DVector3 Func(const C3DVector3 a) {
return (C3DVector3)vabsq_f32((float32x4_t)a); // expected-error {{invalid conversion between ext-vector type 'float32x4_t' (vector of 4 'float' values) and 'C3DVector3' (vector of 3 'float' values)}}
}
// rdar://16350802
typedef double double2 __attribute__ ((ext_vector_type(2)));
static void splats(int i, long l, __uint128_t t, float f, double d) {
short8 vs = 0;
int4 vi = i;
ulong2 vl = (unsigned long)l;
float2 vf = f;
double2 vd = d;
vs = 65536 + vs; // expected-warning {{implicit conversion from 'int' to 'short8' (vector of 8 'short' values) changes value from 65536 to 0}}
vs = vs + i; // expected-warning {{implicit conversion loses integer precision}}
vs = vs + 1;
vs = vs + 1.f; // expected-error {{can't convert between vector values of different size}}
vi = l + vi; // expected-warning {{implicit conversion loses integer precision}}
vi = 1 + vi;
vi = vi + 2.0; // expected-error {{can't convert between vector values of different size}}
vi = vi + 0xffffffff; // expected-warning {{implicit conversion changes signedness}}
vl = l + vl; // expected-warning {{implicit conversion changes signedness}}
vl = vl + t; // expected-warning {{implicit conversion loses integer precision}}
vf = 1 + vf;
vf = l + vf;
vf = 2.0 + vf;
vf = d + vf; // expected-warning {{implicit conversion loses floating-point precision}}
vf = vf + 0xffffffff;
vf = vf + 2.1; // expected-warning {{implicit conversion loses floating-point precision}}
vd = l + vd;
vd = vd + t;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/atomic-type.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
// Basic parsing/Sema tests for _Atomic
// No operations are actually supported on objects of this type yet.
// The qualifier syntax is not supported yet.
_Atomic(int) t1;
_Atomic(int) *t2 = &t1;
void testf(void*);
void f(void) {
_Atomic(_Atomic(int)*) t3;
_Atomic(_Atomic(int)*) *t4[2] = { &t3, 0 };
testf(t4);
}
extern _Atomic(int (*)(int(*)[], int(*)[10])) mergetest;
extern _Atomic(int (*)(int(*)[10], int(*)[])) mergetest;
extern _Atomic(int (*)(int(*)[10], int(*)[10])) mergetest;
_Atomic(int()) error1; // expected-error {{_Atomic cannot be applied to function type}}
_Atomic(struct ErrorS) error2; // expected-error {{_Atomic cannot be applied to incomplete type}} expected-note {{forward declaration}}
_Atomic(int[10]) error3; // expected-error {{_Atomic cannot be applied to array type}}
_Atomic(const int) error4; // expected-error {{_Atomic cannot be applied to qualified type}}
_Atomic(_Atomic(int)) error5; // expected-error {{_Atomic cannot be applied to atomic type}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/varargs.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9
void f1(int a)
{
__builtin_va_list ap;
__builtin_va_start(ap, a, a); // expected-error {{too many arguments to function}}
__builtin_va_start(ap, a); // expected-error {{'va_start' used in function with fixed args}}
}
void f2(int a, int b, ...)
{
__builtin_va_list ap;
__builtin_va_start(ap, 10); // expected-warning {{second parameter of 'va_start' not last named argument}}
__builtin_va_start(ap, a); // expected-warning {{second parameter of 'va_start' not last named argument}}
__builtin_va_start(ap, b);
}
void f3(float a, ...)
{
__builtin_va_list ap;
__builtin_va_start(ap, a);
__builtin_va_start(ap, (a));
}
// stdarg: PR3075
void f4(const char *msg, ...) {
__builtin_va_list ap;
__builtin_stdarg_start((ap), (msg));
__builtin_va_end (ap);
}
void f5() {
__builtin_va_list ap;
__builtin_va_start(ap,ap); // expected-error {{'va_start' used in function with fixed args}}
}
void f6(int a, ...) {
__builtin_va_list ap;
__builtin_va_start(ap); // expected-error {{too few arguments to function}}
}
// PR3350
void
foo(__builtin_va_list authors, ...) {
__builtin_va_start (authors, authors);
(void)__builtin_va_arg(authors, int);
__builtin_va_end (authors);
}
void f7(int a, ...) {
__builtin_va_list ap;
__builtin_va_start(ap, a);
// FIXME: This error message is sub-par.
__builtin_va_arg(ap, int) = 1; // expected-error {{expression is not assignable}}
int *x = &__builtin_va_arg(ap, int); // expected-error {{cannot take the address of an rvalue}}
__builtin_va_end(ap);
}
void f8(int a, ...) {
__builtin_va_list ap;
__builtin_va_start(ap, a);
(void)__builtin_va_arg(ap, void); // expected-error {{second argument to 'va_arg' is of incomplete type 'void'}}
__builtin_va_end(ap);
}
enum E { x = -1, y = 2, z = 10000 };
void f9(__builtin_va_list args)
{
(void)__builtin_va_arg(args, float); // expected-warning {{second argument to 'va_arg' is of promotable type 'float'}}
(void)__builtin_va_arg(args, enum E); // Don't warn here in C
(void)__builtin_va_arg(args, short); // expected-warning {{second argument to 'va_arg' is of promotable type 'short'}}
(void)__builtin_va_arg(args, char); // expected-warning {{second argument to 'va_arg' is of promotable type 'char'}}
}
void f10(int a, ...) {
int i;
__builtin_va_list ap;
i = __builtin_va_start(ap, a); // expected-error {{assigning to 'int' from incompatible type 'void'}}
__builtin_va_end(ap);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/conversion.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wconversion \
// RUN: -nostdsysteminc -nobuiltininc -isystem %S/Inputs \
// RUN: -triple x86_64-apple-darwin %s -Wno-unreachable-code
#include <conversion.h>
#define BIG 0x7f7f7f7f7f7f7f7fL
void test0(char c, short s, int i, long l, long long ll) {
c = c;
c = s; // expected-warning {{implicit conversion loses integer precision}}
c = i; // expected-warning {{implicit conversion loses integer precision}}
c = l; // expected-warning {{implicit conversion loses integer precision}}
s = c;
s = s;
s = i; // expected-warning {{implicit conversion loses integer precision}}
s = l; // expected-warning {{implicit conversion loses integer precision}}
i = c;
i = s;
i = i;
i = l; // expected-warning {{implicit conversion loses integer precision}}
l = c;
l = s;
l = i;
l = l;
c = (char) 0;
c = (short) 0;
c = (int) 0;
c = (long) 0;
s = (char) 0;
s = (short) 0;
s = (int) 0;
s = (long) 0;
i = (char) 0;
i = (short) 0;
i = (int) 0;
i = (long) 0;
l = (char) 0;
l = (short) 0;
l = (int) 0;
l = (long) 0;
c = (char) BIG;
c = (short) BIG; // expected-warning {{implicit conversion from 'short' to 'char' changes value}}
c = (int) BIG; // expected-warning {{implicit conversion from 'int' to 'char' changes value}}
c = (long) BIG; // expected-warning {{implicit conversion from 'long' to 'char' changes value}}
s = (char) BIG;
s = (short) BIG;
s = (int) BIG; // expected-warning {{implicit conversion from 'int' to 'short' changes value}}
s = (long) BIG; // expected-warning {{implicit conversion from 'long' to 'short' changes value}}
i = (char) BIG;
i = (short) BIG;
i = (int) BIG;
i = (long) BIG; // expected-warning {{implicit conversion from 'long' to 'int' changes value}}
l = (char) BIG;
l = (short) BIG;
l = (int) BIG;
l = (long) BIG;
}
char test1(long long ll) {
return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
}
char test1_a(long long ll) {
return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
}
char test1_b(long long ll) {
return (int) ll; // expected-warning {{implicit conversion loses integer precision}}
}
char test1_c(long long ll) {
return (short) ll; // expected-warning {{implicit conversion loses integer precision}}
}
char test1_d(long long ll) {
return (char) ll;
}
char test1_e(long long ll) {
return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'char' changes value}}
}
char test1_f(long long ll) {
return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'char' changes value}}
}
char test1_g(long long ll) {
return (int) BIG; // expected-warning {{implicit conversion from 'int' to 'char' changes value}}
}
char test1_h(long long ll) {
return (short) BIG; // expected-warning {{implicit conversion from 'short' to 'char' changes value}}
}
char test1_i(long long ll) {
return (char) BIG;
}
short test2(long long ll) {
return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
}
short test2_a(long long ll) {
return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
}
short test2_b(long long ll) {
return (int) ll; // expected-warning {{implicit conversion loses integer precision}}
}
short test2_c(long long ll) {
return (short) ll;
}
short test2_d(long long ll) {
return (char) ll;
}
short test2_e(long long ll) {
return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'short' changes value}}
}
short test2_f(long long ll) {
return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'short' changes value}}
}
short test2_g(long long ll) {
return (int) BIG; // expected-warning {{implicit conversion from 'int' to 'short' changes value}}
}
short test2_h(long long ll) {
return (short) BIG;
}
short test2_i(long long ll) {
return (char) BIG;
}
int test3(long long ll) {
return (long long) ll; // expected-warning {{implicit conversion loses integer precision}}
}
int test3_b(long long ll) {
return (long) ll; // expected-warning {{implicit conversion loses integer precision}}
}
int test3_c(long long ll) {
return (int) ll;
}
int test3_d(long long ll) {
return (short) ll;
}
int test3_e(long long ll) {
return (char) ll;
}
int test3_f(long long ll) {
return (long long) BIG; // expected-warning {{implicit conversion from 'long long' to 'int' changes value}}
}
int test3_g(long long ll) {
return (long) BIG; // expected-warning {{implicit conversion from 'long' to 'int' changes value}}
}
int test3_h(long long ll) {
return (int) BIG;
}
int test3_i(long long ll) {
return (short) BIG;
}
int test3_j(long long ll) {
return (char) BIG;
}
long test4(long long ll) {
return (long long) ll;
}
long test4_a(long long ll) {
return (long) ll;
}
long test4_b(long long ll) {
return (int) ll;
}
long test4_c(long long ll) {
return (short) ll;
}
long test4_d(long long ll) {
return (char) ll;
}
long test4_e(long long ll) {
return (long long) BIG;
}
long test4_f(long long ll) {
return (long) BIG;
}
long test4_g(long long ll) {
return (int) BIG;
}
long test4_h(long long ll) {
return (short) BIG;
}
long test4_i(long long ll) {
return (char) BIG;
}
long long test5(long long ll) {
return (long long) ll;
return (long) ll;
return (int) ll;
return (short) ll;
return (char) ll;
return (long long) BIG;
return (long) BIG;
return (int) BIG;
return (short) BIG;
return (char) BIG;
}
void takes_char(char);
void takes_short(short);
void takes_int(int);
void takes_long(long);
void takes_longlong(long long);
void takes_float(float);
void takes_double(double);
void takes_longdouble(long double);
void test6(char v) {
takes_char(v);
takes_short(v);
takes_int(v);
takes_long(v);
takes_longlong(v);
takes_float(v);
takes_double(v);
takes_longdouble(v);
}
void test7(short v) {
takes_char(v); // expected-warning {{implicit conversion loses integer precision}}
takes_short(v);
takes_int(v);
takes_long(v);
takes_longlong(v);
takes_float(v);
takes_double(v);
takes_longdouble(v);
}
void test8(int v) {
takes_char(v); // expected-warning {{implicit conversion loses integer precision}}
takes_short(v); // expected-warning {{implicit conversion loses integer precision}}
takes_int(v);
takes_long(v);
takes_longlong(v);
takes_float(v);
takes_double(v);
takes_longdouble(v);
}
void test9(long v) {
takes_char(v); // expected-warning {{implicit conversion loses integer precision}}
takes_short(v); // expected-warning {{implicit conversion loses integer precision}}
takes_int(v); // expected-warning {{implicit conversion loses integer precision}}
takes_long(v);
takes_longlong(v);
takes_float(v);
takes_double(v);
takes_longdouble(v);
}
void test10(long long v) {
takes_char(v); // expected-warning {{implicit conversion loses integer precision}}
takes_short(v); // expected-warning {{implicit conversion loses integer precision}}
takes_int(v); // expected-warning {{implicit conversion loses integer precision}}
takes_long(v);
takes_longlong(v);
takes_float(v);
takes_double(v);
takes_longdouble(v);
}
void test11(float v) {
takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_float(v);
takes_double(v);
takes_longdouble(v);
}
void test12(double v) {
takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_float(v); // expected-warning {{implicit conversion loses floating-point precision}}
takes_double(v);
takes_longdouble(v);
}
void test13(long double v) {
takes_char(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_short(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_int(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_long(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_longlong(v); // expected-warning {{implicit conversion turns floating-point number into integer}}
takes_float(v); // expected-warning {{implicit conversion loses floating-point precision}}
takes_double(v); // expected-warning {{implicit conversion loses floating-point precision}}
takes_longdouble(v);
}
void test14(long l) {
// Fine because of the boolean whitelist.
char c;
c = (l == 4);
c = ((l <= 4) && (l >= 0));
c = ((l <= 4) && (l >= 0)) || (l > 20);
}
void test15(char c) {
c = c + 1 + c * 2;
c = (short) c + 1 + c * 2; // expected-warning {{implicit conversion loses integer precision}}
}
// PR 5422
extern void *test16_external;
void test16(void) {
int a = (unsigned long) &test16_external; // expected-warning {{implicit conversion loses integer precision}}
}
// PR 5938
void test17() {
union {
unsigned long long a : 8;
unsigned long long b : 32;
unsigned long long c;
} U;
unsigned int x;
x = U.a;
x = U.b;
x = U.c; // expected-warning {{implicit conversion loses integer precision}}
}
// PR 5939
void test18() {
union {
unsigned long long a : 1;
unsigned long long b;
} U;
int x;
x = (U.a ? 0 : 1);
x = (U.b ? 0 : 1);
}
// None of these should warn.
unsigned char test19(unsigned long u64) {
unsigned char x1 = u64 & 0xff;
unsigned char x2 = u64 >> 56;
unsigned char mask = 0xee;
unsigned char x3 = u64 & mask;
return x1 + x2 + x3;
}
// <rdar://problem/7631400>
void test_7631400(void) {
// This should show up despite the caret being inside a macro substitution
char s = LONG_MAX; // expected-warning {{implicit conversion from 'long' to 'char' changes value}}
}
// <rdar://problem/7676608>: assertion for compound operators with non-integral RHS
void f7676608(int);
void test_7676608(void) {
float q = 0.7f;
char c = 5;
f7676608(c *= q);
}
// <rdar://problem/7904686>
void test_7904686(void) {
const int i = -1;
unsigned u1 = i; // expected-warning {{implicit conversion changes signedness}}
u1 = i; // expected-warning {{implicit conversion changes signedness}}
unsigned u2 = -1; // expected-warning {{implicit conversion changes signedness}}
u2 = -1; // expected-warning {{implicit conversion changes signedness}}
}
// <rdar://problem/8232669>: don't warn about conversions required by
// contexts in system headers
void test_8232669(void) {
unsigned bitset[20];
SETBIT(bitset, 0);
unsigned y = 50;
SETBIT(bitset, y);
#define USER_SETBIT(set,bit) do { int i = bit; set[i/(8*sizeof(set[0]))] |= (1 << (i%(8*sizeof(set)))); } while(0)
USER_SETBIT(bitset, 0); // expected-warning 2 {{implicit conversion changes signedness}}
}
// <rdar://problem/8559831>
enum E8559831a { E8559831a_val };
enum E8559831b { E8559831b_val };
typedef enum { E8559831c_val } E8559831c;
enum { E8559831d_val } value_d;
void test_8559831_a(enum E8559831a value);
void test_8559831(enum E8559831b value_a, E8559831c value_c) {
test_8559831_a(value_a); // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
enum E8559831a a1 = value_a; // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
a1 = value_a; // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
test_8559831_a(E8559831b_val); // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
enum E8559831a a1a = E8559831b_val; // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
a1 = E8559831b_val; // expected-warning{{implicit conversion from enumeration type 'enum E8559831b' to different enumeration type 'enum E8559831a'}}
test_8559831_a(value_c); // expected-warning{{implicit conversion from enumeration type 'E8559831c' to different enumeration type 'enum E8559831a'}}
enum E8559831a a2 = value_c; // expected-warning{{implicit conversion from enumeration type 'E8559831c' to different enumeration type 'enum E8559831a'}}
a2 = value_c; // expected-warning{{implicit conversion from enumeration type 'E8559831c' to different enumeration type 'enum E8559831a'}}
test_8559831_a(value_d);
enum E8559831a a3 = value_d;
a3 = value_d;
}
void test26(int si, long sl) {
si = sl % sl; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
si = sl % si;
si = si % sl;
si = si / sl;
si = sl / si; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
}
// rdar://16502418
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef __attribute__ ((ext_vector_type(16),__aligned__(32))) uint16_t ushort16;
typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) uint32_t uint8;
void test27(ushort16 constants) {
uint8 pairedConstants = (uint8) constants;
ushort16 crCbScale = pairedConstants.s4; // expected-warning {{implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'ushort16'}}
ushort16 brBias = pairedConstants.s6; // expected-warning {{implicit conversion loses integer precision: 'uint32_t' (aka 'unsigned int') to 'ushort16'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-labels.c
|
// RUN: %clang_cc1 %s -verify -fblocks -fsyntax-only
void xx();
int a() {
A:
if (1) xx();
return ^{
A: return 1;
}();
}
int b() {
A: return ^{int a; A:return 1;}();
}
int d() {
A: return ^{int a; A: a = ^{int a; A:return 1;}() + ^{int b; A:return 2;}(); return a; }();
}
int c() {
goto A; // expected-error {{use of undeclared label 'A'}}
return ^{
A:
return 1;
}();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/struct-cast.c
|
// RUN: %clang_cc1 -fsyntax-only %s -verify
// expected-no-diagnostics
struct S {
int one;
int two;
};
struct S const foo(void);
struct S tmp;
void priv_sock_init() {
tmp = (struct S)foo();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtins-decl.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-mingw32
// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-mingw32
// expected-no-diagnostics
// mingw-w64's intrin.h has decls below.
// we should accept them.
extern unsigned int __builtin_ia32_crc32qi (unsigned int, unsigned char);
extern unsigned int __builtin_ia32_crc32hi (unsigned int, unsigned short);
extern unsigned int __builtin_ia32_crc32si (unsigned int, unsigned int);
// GCC documents these as unsigned, but they are defined with a signed argument.
extern int __builtin_ffs(int);
extern int __builtin_ffsl(long);
extern int __builtin_ffsll(long long);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-vla.c
|
// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -Wvla %s
// RUN: %clang_cc1 -std=c89 -fsyntax-only -verify -Wvla %s
void test1(int n) {
int v[n]; // expected-warning {{variable length array used}}
}
void test2(int n, int v[n]) { // expected-warning {{variable length array used}}
}
void test3(int n, int v[n]); // expected-warning {{variable length array used}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-int-typedefs.c
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
int printf(char const *, ...);
int scanf(char const *, ...);
void test(void) {
printf("%jd", 42.0); // expected-warning {{format specifies type 'intmax_t' (aka 'long long')}}
printf("%ju", 42.0); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long')}}
printf("%zu", 42.0); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long')}}
printf("%td", 42.0); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int')}}
printf("%lc", 42.0); // expected-warning {{format specifies type 'wint_t' (aka 'int')}}
printf("%ls", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
printf("%S", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
printf("%C", 42.0); // expected-warning {{format specifies type 'wchar_t' (aka 'int')}}
scanf("%jd", 0); // expected-warning {{format specifies type 'intmax_t *' (aka 'long long *')}}
scanf("%ju", 0); // expected-warning {{format specifies type 'uintmax_t *' (aka 'unsigned long long *')}}
scanf("%zu", 0); // expected-warning {{format specifies type 'size_t *' (aka 'unsigned long *')}}
scanf("%td", 0); // expected-warning {{format specifies type 'ptrdiff_t *' (aka 'int *')}}
scanf("%lc", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
scanf("%ls", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
scanf("%S", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
scanf("%C", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
// typedef size_t et al. to something crazy.
typedef void *size_t;
typedef void *intmax_t;
typedef void *uintmax_t;
typedef void *ptrdiff_t;
// The warning still fires, because it checks the underlying type.
printf("%jd", (intmax_t)42); // expected-warning {{format specifies type 'intmax_t' (aka 'long long') but the argument has type 'intmax_t' (aka 'void *')}}
printf("%ju", (uintmax_t)42); // expected-warning {{format specifies type 'uintmax_t' (aka 'unsigned long long') but the argument has type 'uintmax_t' (aka 'void *')}}
printf("%zu", (size_t)42); // expected-warning {{format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'size_t' (aka 'void *')}}
printf("%td", (ptrdiff_t)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int') but the argument has type 'ptrdiff_t' (aka 'void *')}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/extern-redecl.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar: // 8125274
static int a16[]; // expected-warning {{tentative array definition assumed to have one element}}
void f16(void) {
extern int a16[];
}
// PR10013: Scope of extern declarations extend past enclosing block
extern int PR10013_x;
int PR10013(void) {
int *PR10013_x = 0;
{
extern int PR10013_x;
extern int PR10013_x;
}
return PR10013_x; // expected-warning{{incompatible pointer to integer conversion}}
}
static int test1_a[]; // expected-warning {{tentative array definition assumed to have one element}}
extern int test1_a[];
// rdar://13535367
void test2declarer() { extern int test2_array[100]; }
extern int test2_array[];
int test2v = sizeof(test2_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
void test3declarer() {
{ extern int test3_array[100]; }
extern int test3_array[];
int x = sizeof(test3_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
}
void test4() {
extern int test4_array[];
{
extern int test4_array[100];
int x = sizeof(test4_array); // fine
}
int x = sizeof(test4_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
}
// Test that invalid local extern declarations of library
// builtins behave reasonably.
extern void abort(void); // expected-note 2 {{previous declaration is here}}
extern float *calloc(); // expected-warning {{incompatible redeclaration of library function}} expected-note {{is a builtin}} expected-note 2 {{previous declaration is here}}
void test5a() {
int abort(); // expected-error {{conflicting types}}
float *malloc(); // expected-warning {{incompatible redeclaration of library function}} expected-note 2 {{is a builtin}}
int *calloc(); // expected-error {{conflicting types}}
}
void test5b() {
int abort(); // expected-error {{conflicting types}}
float *malloc(); // expected-warning {{incompatible redeclaration of library function}}
int *calloc(); // expected-error {{conflicting types}}
}
void test5c() {
void (*_abort)(void) = &abort;
void *(*_malloc)() = &malloc;
float *(*_calloc)() = &calloc;
}
void test6() {
extern int test6_array1[100];
extern int test6_array2[100];
void test6_fn1(int*);
void test6_fn2(int*);
{
// Types are only merged from visible declarations.
char test6_array2;
char test6_fn2;
{
extern int test6_array1[];
extern int test6_array2[];
(void)sizeof(test6_array1); // ok
(void)sizeof(test6_array2); // expected-error {{incomplete type}}
void test6_fn1();
void test6_fn2();
test6_fn1(1.2); // expected-error {{passing 'double' to parameter of incompatible type 'int *'}}
// FIXME: This is valid, but we should warn on it.
test6_fn2(1.2);
}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/expr-comma.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c89 -Wno-sizeof-array-decay
// rdar://6095180
struct s { char c[17]; };
extern struct s foo(void);
struct s a, b, c;
int A[sizeof((foo().c)) == 17 ? 1 : -1];
int B[sizeof((a.c)) == 17 ? 1 : -1];
// comma does not promote array/function in c90 unless they are lvalues.
int W[sizeof(0, a.c) == sizeof(char*) ? 1 : -1];
int X[sizeof(0, (foo().c)) == 17 ? 1 : -1];
int Y[sizeof(0, (a,b).c) == 17 ? 1 : -1];
int Z[sizeof(0, (a=b).c) == 17 ? 1 : -1]; // expected-warning {{expression with side effects has no effect in an unevaluated context}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-missing-variable-declarations.c
|
// RUN: %clang_cc1 -Wmissing-variable-declarations -fsyntax-only -verify %s
int vbad1; // expected-warning{{no previous extern declaration for non-static variable 'vbad1'}}
int vbad2;
int vbad2 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad2'}}
struct {
int mgood1;
} vbad3; // expected-warning{{no previous extern declaration for non-static variable 'vbad3'}}
int vbad4;
int vbad4 = 10; // expected-warning{{no previous extern declaration for non-static variable 'vbad4'}}
extern int vbad4;
extern int vgood1;
int vgood1;
int vgood1 = 10;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/initialize-noreturn.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify
// rdar://10095762
typedef void (*Fn_noret)(void) __attribute__((noreturn));
typedef void (*Fn_ret)(void);
void foo(void);
void foo_noret(void) __attribute__((noreturn));
void test() {
Fn_noret fn2 = &foo; // expected-warning {{incompatible pointer types initializing 'Fn_noret'}}
Fn_noret fn3 = &foo_noret;
Fn_ret fn4 = &foo_noret;
Fn_ret fn5 = &foo;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/inline-asm-validate-aarch64.c
|
// RUN: %clang_cc1 -triple arm64-apple-darwin -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
typedef unsigned char uint8_t;
uint8_t constraint_r(uint8_t *addr) {
uint8_t byte;
__asm__ volatile("ldrb %0, [%1]" : "=r" (byte) : "r" (addr) : "memory");
// CHECK: warning: value size does not match register size specified by the constraint and modifier
// CHECK: note: use constraint modifier "w"
// CHECK: fix-it:{{.*}}:{8:26-8:28}:"%w0"
return byte;
}
uint8_t constraint_r_symbolic(uint8_t *addr) {
uint8_t byte;
__asm__ volatile("ldrb %[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
// CHECK: warning: value size does not match register size specified by the constraint and modifier
// CHECK: note: use constraint modifier "w"
// CHECK: fix-it:{{.*}}:{19:26-19:31}:"%w[s0]"
return byte;
}
#define PERCENT "%"
uint8_t constraint_r_symbolic_macro(uint8_t *addr) {
uint8_t byte;
__asm__ volatile("ldrb "PERCENT"[s0], [%[s1]]" : [s0] "=r" (byte) : [s1] "r" (addr) : "memory");
// CHECK: warning: value size does not match register size specified by the constraint and modifier
// CHECK: note: use constraint modifier "w"
// CHECK-NOT: fix-it
return byte;
}
// CHECK: warning: value size does not match register size specified by the constraint and modifier
// CHECK: asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
// CHECK: note: use constraint modifier "w"
// CHECK: fix-it:{{.*}}:{47:17-47:19}:"%w2"
void read_write_modifier0(int one, int two) {
long wide_two = two;
asm ("%w0 %w1 %2" : "+r" (one) : "r" (wide_two));
}
// CHECK-NOT: warning:
void read_write_modifier1(int one, int two) {
long wide_two = two;
asm ("%w0 %1" : "+r" (one), "+r" (wide_two));
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/complex-imag.c
|
// RUN: %clang_cc1 -verify %s
void f1() {
int a = 1;
int b = __imag a;
int *c = &__real a;
int *d = &__imag a; // expected-error {{cannot take the address of an rvalue of type 'int'}}
}
void f2() {
_Complex int a = 1;
int b = __imag a;
int *c = &__real a;
int *d = &__imag a;
}
void f3() {
double a = 1;
double b = __imag a;
double *c = &__real a;
double *d = &__imag a; // expected-error {{cannot take the address of an rvalue of type 'double'}}
}
void f4() {
_Complex double a = 1;
double b = __imag a;
double *c = &__real a;
double *d = &__imag a;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtin-unary-fp.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
void check(int);
void a() {
check(__builtin_isfinite(1.0f));
check(__builtin_isinf(1.0));
check(__builtin_isinf_sign(1.0L));
check(__builtin_isnan(1.0f));
check(__builtin_isnormal(1.0f));
check(__builtin_isfinite(1)); // expected-error{{requires argument of floating point type}}
check(__builtin_isinf()); // expected-error{{too few arguments}}
check(__builtin_isnan(1,2)); // expected-error{{too many arguments}}
check(__builtin_fpclassify(0, 0, 0, 0, 0, 1.0));
check(__builtin_fpclassify(0, 0, 0, 0, 0, 1)); // expected-error{{requires argument of floating point type}}
check(__builtin_fpclassify(0, 0, 0, 0, 1)); // expected-error{{too few arguments}}
check(__builtin_fpclassify(0, 0, 0, 0, 0, 1, 0)); // expected-error{{too many arguments}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/fpack-struct.c
|
// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=5 -fpack-struct=1 %s
// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=6 -fpack-struct=2 %s
struct s0 {
int x;
char c;
};
int t0[sizeof(struct s0) == EXPECTED_STRUCT_SIZE ?: -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-c90.c
|
/* RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -Wformat-non-iso -std=c89 %s
*/
int scanf(const char * restrict, ...);
int printf(const char *restrict, ...);
void foo(char **sp, float *fp, int *ip) {
scanf("%as", sp); /* expected-warning{{'a' length modifier is not supported by ISO C}} */
scanf("%a[abc]", sp); /* expected-warning{{'a' length modifier is not supported by ISO C}} */
/* TODO: Warn that the 'a' conversion specifier is a C99 feature. */
scanf("%a", fp);
scanf("%afoobar", fp);
printf("%a", 1.0);
printf("%as", 1.0);
printf("%aS", 1.0);
printf("%a[", 1.0);
printf("%afoo", 1.0);
scanf("%da", ip);
/* Test argument type check for the 'a' length modifier. */
scanf("%as", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
expected-warning{{'a' length modifier is not supported by ISO C}} */
scanf("%aS", fp); /* expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
expected-warning{{'a' length modifier is not supported by ISO C}}
expected-warning{{'S' conversion specifier is not supported by ISO C}} */
scanf("%a[abc]", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
expected-warning{{'a' length modifier is not supported by ISO C}} */
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/neon-vector-types.c
|
// RUN: %clang_cc1 %s -triple armv7 -target-feature +neon -fsyntax-only -verify
// RUN: %clang_cc1 %s -triple armv8 -target-feature +neon -fsyntax-only -verify
typedef float float32_t;
typedef signed char poly8_t;
typedef short poly16_t;
typedef unsigned __INT64_TYPE__ uint64_t;
// Define some valid Neon types.
typedef __attribute__((neon_vector_type(2))) int int32x2_t;
typedef __attribute__((neon_vector_type(4))) int int32x4_t;
typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t;
typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t;
// The attributes must have a single argument.
typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{'neon_vector_type' attribute takes one argument}}
// The number of elements must be an ICE.
typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{'neon_vector_type' attribute requires an integer constant}}
// Only certain element types are allowed.
typedef __attribute__((neon_vector_type(4))) void* ptr_elt; // expected-error{{invalid vector element type}}
typedef __attribute__((neon_polyvector_type(4))) float32_t bad_poly_elt; // expected-error{{invalid vector element type}}
struct aggr { signed char c; };
typedef __attribute__((neon_vector_type(8))) struct aggr aggregate_elt; // expected-error{{invalid vector element type}}
// The total vector size must be 64 or 128 bits.
typedef __attribute__((neon_vector_type(1))) int int32x1_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
typedef __attribute__((neon_vector_type(3))) int int32x3_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-nodebug.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
int a __attribute__((nodebug));
void b() {
int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies to variables with static storage duration and functions}}
}
void t1() __attribute__((nodebug));
void t2() __attribute__((nodebug(2))); // expected-error {{'nodebug' attribute takes no arguments}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/for.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// Check C99 6.8.5p3
void b1 (void) { for (void (*f) (void);;); }
void b2 (void) { for (void f (void);;); } // expected-error {{declaration of non-local variable}}
void b3 (void) { for (static int f;;); } // expected-error {{declaration of non-local variable}}
void b4 (void) { for (typedef int f;;); } // expected-error {{declaration of non-local variable}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-strncat-size.c
|
// RUN: %clang_cc1 -Wstrncat-size -verify -fsyntax-only %s
// RUN: %clang_cc1 -DUSE_BUILTINS -Wstrncat-size -verify -fsyntax-only %s
// RUN: %clang_cc1 -fsyntax-only -Wstrncat-size -fixit -x c %s
// RUN: %clang_cc1 -DUSE_BUILTINS -fsyntax-only -Wstrncat-size -fixit -x c %s
typedef __SIZE_TYPE__ size_t;
size_t strlen (const char *s);
#ifdef USE_BUILTINS
# define BUILTIN(f) __builtin_ ## f
#else
# define BUILTIN(f) f
#endif
#define strncat BUILTIN(strncat)
char *strncat(char *restrict s1, const char *restrict s2, size_t n);
struct {
char f1[100];
char f2[100][3];
} s4, **s5;
char s1[100];
char s2[200];
int x;
void test(char *src) {
char dest[10];
strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest) - 1); // no-warning
strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - 1); // no-warning - the code might assume that dest is empty
strncat(dest, src, sizeof(src)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat(dest, src, sizeof(src) - 1); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat(dest, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", sizeof(dest) - strlen(dest)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
strncat(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}}
strncat(s4.f1, s2, sizeof(s2)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
}
// Don't issue FIXIT for flexible arrays.
struct S {
int y;
char x[];
};
void flexible_arrays(struct S *s) {
char str[] = "hi";
strncat(s->x, str, sizeof(str)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}}
}
// Don't issue FIXIT for destinations of size 1.
void size_1() {
char z[1];
char str[] = "hi";
strncat(z, str, sizeof(z)); // expected-warning{{the value of the size argument to 'strncat' is wrong}}
}
// Support VLAs.
void vlas(int size) {
char z[size];
char str[] = "hi";
strncat(z, str, sizeof(str)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}}
}
// Non-array type gets a different error message.
void f(char* s, char* d) {
strncat(d, s, sizeof(d)); // expected-warning {{the value of the size argument to 'strncat' is wrong}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-sizeof-array-decay.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f(int x) {
char foo[10];
int bar[20];
char qux[30];
(void)sizeof(bar + 10); // expected-warning{{sizeof on pointer operation will return size of 'int *' instead of 'int [20]'}}
(void)sizeof(foo - 20); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char [10]'}}
(void)sizeof(bar - x); // expected-warning{{sizeof on pointer operation will return size of 'int *' instead of 'int [20]'}}
(void)sizeof(foo + x); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char [10]'}}
// This is ptrdiff_t.
(void)sizeof(foo - qux); // no-warning
(void)sizeof(foo, x); // no-warning
(void)sizeof(x, foo); // expected-warning{{sizeof on pointer operation will return size of 'char *' instead of 'char [10]'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/align-x86.c
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
// expected-no-diagnostics
// PR3433
double g1;
short chk1[__alignof__(g1) == 8 ? 1 : -1];
short chk2[__alignof__(double) == 8 ? 1 : -1];
long long g2;
short chk1[__alignof__(g2) == 8 ? 1 : -1];
short chk2[__alignof__(long long) == 8 ? 1 : -1];
unsigned long long g5;
short chk1[__alignof__(g5) == 8 ? 1 : -1];
short chk2[__alignof__(unsigned long long) == 8 ? 1 : -1];
_Complex double g3;
short chk1[__alignof__(g3) == 8 ? 1 : -1];
short chk2[__alignof__(_Complex double) == 8 ? 1 : -1];
// PR6362
struct __attribute__((packed)) {unsigned int a;} g4;
short chk1[__alignof__(g4) == 1 ? 1 : -1];
short chk2[__alignof__(g4.a) == 1 ? 1 : -1];
double g6[3];
short chk1[__alignof__(g6) == 8 ? 1 : -1];
short chk2[__alignof__(double[3]) == 8 ? 1 : -1];
enum { x = 18446744073709551615ULL } g7;
short chk1[__alignof__(g7) == 8 ? 1 : -1];
// PR5637
#define ALIGNED(x) __attribute__((aligned(x)))
typedef ALIGNED(2) struct {
char a[3];
} T;
short chk1[sizeof(T) == 3 ? 1 : -1];
short chk2[sizeof(T[1]) == 4 ? 1 : -1];
short chk3[sizeof(T[2]) == 6 ? 1 : -1];
short chk4[sizeof(T[2][1]) == 8 ? 1 : -1];
short chk5[sizeof(T[1][2]) == 6 ? 1 : -1];
typedef struct ALIGNED(2) {
char a[3];
} T2;
short chk1[sizeof(T2) == 4 ? 1 : -1];
short chk2[sizeof(T2[1]) == 4 ? 1 : -1];
short chk3[sizeof(T2[2]) == 8 ? 1 : -1];
short chk4[sizeof(T2[2][1]) == 8 ? 1 : -1];
short chk5[sizeof(T2[1][2]) == 8 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/transparent-union-pointer.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify
// expected-no-diagnostics
typedef union {
union wait *__uptr;
int *__iptr;
} __WAIT_STATUS __attribute__ ((__transparent_union__));
extern int wait (__WAIT_STATUS __stat_loc);
void fastcgi_cleanup() {
int status = 0;
wait(&status);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/vla.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
int test1() {
typedef int x[test1()]; // vla
static int y = sizeof(x); // expected-error {{not a compile-time constant}}
}
// PR2347
void f (unsigned int m)
{
int e[2][m];
e[0][0] = 0;
}
// PR3048
int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
// PR2352
void f2(unsigned int m)
{
extern int e1[2][m]; // expected-error {{variable length array declaration cannot have 'extern' linkage}}
e1[0][0] = 0;
}
// PR2361
int i;
int c[][i]; // expected-error {{variably modified type declaration not allowed at file scope}}
int d[i]; // expected-error {{variable length array declaration not allowed at file scope}}
int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}}
void f3()
{
static int a[i]; // expected-error {{variable length array declaration cannot have 'static' storage duration}}
extern int b[i]; // expected-error {{variable length array declaration cannot have 'extern' linkage}}
extern int (*c1)[i]; // expected-error {{variably modified type declaration cannot have 'extern' linkage}}
static int (*d)[i];
}
// PR3663
static const unsigned array[((2 * (int)((((4) / 2) + 1.0/3.0) * (4) - 1e-8)) + 1)]; // expected-warning {{variable length array folded to constant array as an extension}}
int a[*]; // expected-error {{star modifier used outside of function prototype}}
int f4(int a[*][*]);
// PR2044
int pr2044(int b) {int (*c(void))[b];**c() = 2;} // expected-error {{variably modified type}}
int pr2044b;
int (*pr2044c(void))[pr2044b]; // expected-error {{variably modified type}}
const int f5_ci = 1;
void f5() { char a[][f5_ci] = {""}; } // expected-warning {{variable length array folded to constant array as an extension}}
// PR5185
void pr5185(int a[*]);
void pr5185(int a[*]) // expected-error {{variable length array must be bound in function definition}}
{
}
void pr23151(int (*p1)[*]) // expected-error {{variable length array must be bound in function definition}}
{}
// Make sure this isn't treated as an error
int TransformBug(int a) {
return sizeof(*(int(*)[({ goto v; v: a;})]) 0); // expected-warning {{use of GNU statement expression extension}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/designated-initializers.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-unknown %s
int complete_array_from_init[] = { 1, 2, [10] = 5, 1, 2, [5] = 2, 6 };
int complete_array_from_init_check[((sizeof(complete_array_from_init) / sizeof(int)) == 13)? 1 : -1];
int iarray[10] = {
[0] = 1,
[1 ... 5] = 2,
[ 6 ... 6 ] = 3,
[ 8 ... 7 ] = 4, // expected-error{{array designator range [8, 7] is empty}}
[10] = 5,
[-1] = 6 // expected-error{{array designator value '-1' is negative}}
};
int iarray2[10] = {
[10] = 1, // expected-error{{array designator index (10) exceeds array bounds (10)}}
};
int iarray3[10] = {
[3] 2, // expected-warning{{use of GNU 'missing =' extension in designator}}
[5 ... 12] = 2 // expected-error{{array designator index (12) exceeds array bounds (10)}}
};
struct point {
double x;
double y;
};
struct point p1 = {
.y = 1.0,
x: 2.0, // expected-warning{{}}
.a = 4.0, // expected-error{{field designator 'a' does not refer to any field in type 'struct point'}}
};
struct point p2 = {
[1] = 1.0 // expected-error{{array designator cannot initialize non-array type}}
};
struct point array[10] = {
[0].x = 1.0,
[1].y = 2.0,
[2].z = 3.0, // expected-error{{field designator 'z' does not refer to any field in type 'struct point'}}
};
struct point array2[10] = {
[10].x = 2.0, // expected-error{{array designator index (10) exceeds array bounds (10)}}
[4 ... 5].y = 2.0, // expected-note 2 {{previous initialization is here}}
[4 ... 6] = { .x = 3, .y = 4.0 } // expected-warning 2 {{subobject initialization overrides initialization of other fields within its enclosing subobject}}
};
struct point array3[10] = {
.x = 5 // expected-error{{field designator cannot initialize a non-struct, non-union type}}
};
struct rect {
struct point top_left;
struct point bottom_right;
};
struct rect window = { .top_left.x = 1.0 };
struct rect windows[] = {
[2].top_left = { 1.0, 2.0 },
[4].bottom_right = { .y = 1.0 },
{ { .y = 7.0, .x = 8.0 }, { .x = 5.0 } },
[3] = { .top_left = { 1.1, 2.2 }, .bottom_right = { .y = 1.1 } }
};
int windows_size[((sizeof(windows) / sizeof(struct rect)) == 6)? 1 : -1];
struct rect windows_bad[3] = {
[2].top_left = { { .x = 1.1 } }, // expected-error{{designator in initializer for scalar type}}
[1].top_left = { .x = 1.1 }
};
struct gui {
struct rect windows[10];
};
struct gui gui[] = {
[5].windows[3].top_left.x = { 7.0 } // expected-warning{{braces around scalar initializer}}
};
struct translator {
struct wonky { int * ptr; } wonky ;
struct rect window;
struct point offset;
} tran = {
.window = { .top_left = { 1.0, 2.0 } },
{ .x = 5.0, .y = 6.0 },
.wonky = { 0 }
};
int anint;
struct {int x,*y;} z[] = {[0].x = 2, &z[0].x};
struct outer { struct inner { int x, *y; } in, *inp; } zz[] = {
[0].in.x = 2, &zz[0].in.x, &zz[0].in,
0, &anint, &zz[1].in,
[3].in = { .y = &anint, .x = 17 },
[7].in.y = &anint, &zz[0].in,
[4].in.y = &anint, [5].in.x = 12
};
int zz_sizecheck[sizeof(zz) / sizeof(struct outer) == 8? 1 : -1 ];
struct disklabel_ops {
struct {} type;
int labelsize;
};
struct disklabel_ops disklabel64_ops = {
.labelsize = sizeof(struct disklabel_ops)
};
// PR clang/3378
int bitwidth[] = { [(long long int)1] = 5, [(short int)2] = 2 };
int a[]= { [sizeof(int)] = 0 };
int a2[]= { [0 ... sizeof(int)] = 0 };
// Test warnings about initializers overriding previous initializers
struct X {
int a, b, c;
};
int counter = 0;
int get8() { ++counter; return 8; }
void test() {
struct X xs[] = {
[0] = (struct X){1, 2}, // expected-note 2 {{previous initialization is here}}
[0].c = 3, // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}}
(struct X) {4, 5, 6}, // expected-note{{previous initialization is here}}
[1].b = get8(), // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}}
[0].b = 8 // expected-warning{{subobject initialization overrides initialization of other fields within its enclosing subobject}}
};
}
union { char c; long l; } u1 = { .l = 0xFFFF };
extern float global_float;
struct XX { int a, *b; };
struct XY { int before; struct XX xx, *xp; float* after; } xy[] = {
0, 0, &xy[0].xx.a, &xy[0].xx, &global_float,
[1].xx = 0, &xy[1].xx.a, &xy[1].xx, &global_float,
0, // expected-note{{previous initialization is here}}
0, // expected-note{{previous initialization is here}}
[2].before = 0, // expected-warning{{initializer overrides prior initialization of this subobject}}
0, // expected-warning{{initializer overrides prior initialization of this subobject}}
&xy[2].xx.a, &xy[2].xx, &global_float
};
// PR3519
struct foo {
int arr[10];
};
struct foo Y[10] = {
[1] .arr [1] = 2,
[4] .arr [2] = 4
};
struct bar {
struct foo f;
float *arr[10];
};
extern float f;
struct bar saloon = {
.f.arr[3] = 1,
.arr = { &f }
};
typedef unsigned char u_char;
typedef unsigned short u_short;
union wibble {
u_char arr1[6];
u_short arr2[3];
};
const union wibble wobble = { .arr2[0] = 0xffff,
.arr2[1] = 0xffff,
.arr2[2] = 0xffff };
const union wibble wobble2 = { .arr2 = {4, 5, 6}, 7 }; // expected-warning{{excess elements in union initializer}}
// PR3778
struct s {
union { int i; };
};
struct s si = {
{ .i = 1 }
};
double d0;
char c0;
float f0;
int i0;
struct Enigma {
union {
struct {
struct {
double *double_ptr;
char *string;
};
float *float_ptr;
};
int *int_ptr;
};
char *string2;
};
struct Enigma enigma = {
.double_ptr = &d0, &c0,
&f0, // expected-note{{previous}}
&c0,
.float_ptr = &f0 // expected-warning{{overrides}}
};
/// PR16644
typedef union {
struct {
int zero;
int one;
int two;
int three;
} a;
int b[4];
} union_16644_t;
union_16644_t union_16644_instance_0 =
{
.b[0] = 0, // expected-note{{previous}}
.a.one = 1, // expected-warning{{overrides}} expected-note{{previous}}
.b[2] = 2, // expected-warning{{overrides}} expected-note{{previous}}
.a.three = 3, // expected-warning{{overrides}}
};
union_16644_t union_16644_instance_1 =
{
.a.three = 13, // expected-note{{previous}}
.b[2] = 12, // expected-warning{{overrides}} expected-note{{previous}}
.a.one = 11, // expected-warning{{overrides}} expected-note{{previous}}
.b[0] = 10, // expected-warning{{overrides}}
};
union_16644_t union_16644_instance_2 =
{
.a.one = 21, // expected-note{{previous}}
.b[1] = 20, // expected-warning{{overrides}}
};
union_16644_t union_16644_instance_3 =
{
.b[1] = 30, // expected-note{{previous}}
.a = { // expected-warning{{overrides}}
.one = 31
}
};
union_16644_t union_16644_instance_4[2] =
{
[0].a.one = 2,
[1].a.zero = 3,// expected-note{{previous}}
[0].a.zero = 5,
[1].b[1] = 4 // expected-warning{{overrides}}
};
/// PR4073
/// Should use evaluate to fold aggressively and emit a warning if not an ice.
extern int crazy_x;
int crazy_Y[] = {
[ 0 ? crazy_x : 4] = 1
};
// PR5843
struct expr {
int nargs;
union {
unsigned long int num;
struct expr *args[3];
} val;
};
struct expr expr0 = {
.nargs = 2,
.val = {
.args = {
[0] = (struct expr *)0,
[1] = (struct expr *)0
}
}
};
// PR6955
struct ds {
struct {
struct {
unsigned int a;
};
unsigned int b;
struct {
unsigned int c;
};
};
};
// C1X lookup-based anonymous member init cases
struct ds ds0 = {
{ {
.a = 1 // expected-note{{previous initialization is here}}
} },
.a = 2, // expected-warning{{initializer overrides prior initialization of this subobject}}
.b = 3
};
struct ds ds1 = { .c = 0 };
struct ds ds2 = { { {
.a = 0,
.b = 1 // expected-error{{field designator 'b' does not refer to any field}}
} } };
// Check initializer override warnings overriding a character in a string
struct overwrite_string_struct {
char L[6];
int M;
} overwrite_string[] = {
{ { "foo" }, 1 }, // expected-note {{previous initialization is here}}
[0].L[2] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}}
};
struct overwrite_string_struct2 {
char L[6];
int M;
} overwrite_string2[] = {
{ { "foo" }, 1 }, // expected-note{{previous initialization is here}}
[0].L[4] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}}
};
struct overwrite_string_struct
overwrite_string3[] = {
"foo", 1, // expected-note{{previous initialization is here}}
[0].L[4] = 'x' // expected-warning{{subobject initialization overrides initialization of other fields}}
};
struct overwrite_string_struct
overwrite_string4[] = {
{ { 'f', 'o', 'o' }, 1 },
[0].L[4] = 'x' // no-warning
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/void_arg.c
|
/* RUN: %clang_cc1 -fsyntax-only %s -verify
*/
typedef void Void;
void foo() {
int X;
X = sizeof(int (void a)); // expected-error {{argument may not have 'void' type}}
X = sizeof(int (int, void)); // expected-error {{must be the first and only parameter}}
X = sizeof(int (void, ...)); // expected-error {{must be the first and only parameter}}
X = sizeof(int (Void a)); // expected-error {{argument may not have 'void' type}}
X = sizeof(int (int, Void)); // expected-error {{must be the first and only parameter}}
X = sizeof(int (Void, ...)); // expected-error {{must be the first and only parameter}}
// Accept these.
X = sizeof(int (void));
X = sizeof(int (Void));
}
// this is ok.
void bar(Void) {
}
void f(const void); // expected-error {{parameter must not have type qualifiers}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/tls.c
|
// Test that TLS is correctly considered supported or unsupported for the
// different targets.
// Linux supports TLS.
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only %s
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only %s
// Darwin supports TLS since 10.7.
// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only %s
// RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only %s
// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only %s
// OpenBSD does not suppport TLS.
// RUN: not %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s
// RUN: not %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s
// Haiku does not suppport TLS.
// RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
// Bitrig suppports TLS.
// RUN: %clang_cc1 -triple x86_64-pc-bitrig -fsyntax-only %s
// RUN: %clang_cc1 -triple armv6-unknown-bitrig -fsyntax-only %s
__thread int x;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/dllexport.c
|
// RUN: %clang_cc1 -triple i686-win32 -fsyntax-only -fms-extensions -verify -std=c99 %s
// RUN: %clang_cc1 -triple x86_64-win32 -fsyntax-only -fms-extensions -verify -std=c11 %s
// RUN: %clang_cc1 -triple i686-mingw32 -fsyntax-only -fms-extensions -verify -std=c11 %s
// RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c99 %s
// Invalid usage.
__declspec(dllexport) typedef int typedef1; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
typedef __declspec(dllexport) int typedef2; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
typedef int __declspec(dllexport) typedef3; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
typedef __declspec(dllexport) void (*FunTy)(); // expected-warning{{'dllexport' attribute only applies to variables and functions}}
enum __declspec(dllexport) Enum { EnumVal }; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
struct __declspec(dllexport) Record {}; // expected-warning{{'dllexport' attribute only applies to variables and functions}}
//===----------------------------------------------------------------------===//
// Globals
//===----------------------------------------------------------------------===//
// Export declaration.
__declspec(dllexport) extern int ExternGlobalDecl;
// dllexport implies a definition.
__declspec(dllexport) int GlobalDef;
// Export definition.
__declspec(dllexport) int GlobalInit1 = 1;
int __declspec(dllexport) GlobalInit2 = 1;
// Declare, then export definition.
__declspec(dllexport) extern int GlobalDeclInit;
int GlobalDeclInit = 1;
// Redeclarations
__declspec(dllexport) extern int GlobalRedecl1;
__declspec(dllexport) int GlobalRedecl1;
__declspec(dllexport) extern int GlobalRedecl2;
int GlobalRedecl2;
extern int GlobalRedecl3; // expected-note{{previous declaration is here}}
int useGlobalRedecl3() { return GlobalRedecl3; }
__declspec(dllexport) extern int GlobalRedecl3; // expected-error{{redeclaration of 'GlobalRedecl3' cannot add 'dllexport' attribute}}
extern int GlobalRedecl4; // expected-note{{previous declaration is here}}
__declspec(dllexport) extern int GlobalRedecl4; // expected-warning{{redeclaration of 'GlobalRedecl4' should not add 'dllexport' attribute}}
// External linkage is required.
__declspec(dllexport) static int StaticGlobal; // expected-error{{'StaticGlobal' must have external linkage when declared 'dllexport'}}
// Thread local variables are invalid.
__declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}
// Export in local scope.
void functionScope() {
__declspec(dllexport) int LocalVarDecl; // expected-error{{'LocalVarDecl' must have external linkage when declared 'dllexport'}}
__declspec(dllexport) int LocalVarDef = 1; // expected-error{{'LocalVarDef' must have external linkage when declared 'dllexport'}}
__declspec(dllexport) extern int ExternLocalVarDecl;
__declspec(dllexport) static int StaticLocalVar; // expected-error{{'StaticLocalVar' must have external linkage when declared 'dllexport'}}
}
//===----------------------------------------------------------------------===//
// Functions
//===----------------------------------------------------------------------===//
// Export function declaration. Check different placements.
__attribute__((dllexport)) void decl1A(); // Sanity check with __attribute__
__declspec(dllexport) void decl1B();
void __attribute__((dllexport)) decl2A();
void __declspec(dllexport) decl2B();
// Export function definition.
__declspec(dllexport) void def() {}
// Export inline function.
__declspec(dllexport) inline void inlineFunc1() {}
extern void inlineFunc1();
inline void __attribute__((dllexport)) inlineFunc2() {}
extern void inlineFunc2();
// Redeclarations
__declspec(dllexport) void redecl1();
__declspec(dllexport) void redecl1();
__declspec(dllexport) void redecl2();
void redecl2();
__declspec(dllexport) void redecl3();
void redecl3() {}
void redecl4(); // expected-note{{previous declaration is here}}
void useRedecl4() { redecl4(); }
__declspec(dllexport) void redecl4(); // expected-error{{redeclaration of 'redecl4' cannot add 'dllexport' attribute}}
void redecl5(); // expected-note{{previous declaration is here}}
void useRedecl5() { redecl5(); }
__declspec(dllexport) inline void redecl5() {} // expected-error{{redeclaration of 'redecl5' cannot add 'dllexport' attribute}}
// Allow with a warning if the decl hasn't been used yet.
void redecl6(); // expected-note{{previous declaration is here}}
__declspec(dllexport) void redecl6(); // expected-warning{{redeclaration of 'redecl6' should not add 'dllexport' attribute}}
// External linkage is required.
__declspec(dllexport) static int staticFunc(); // expected-error{{'staticFunc' must have external linkage when declared 'dllexport'}}
//===----------------------------------------------------------------------===//
// Precedence
//===----------------------------------------------------------------------===//
// dllexport takes precedence over dllimport if both are specified.
__attribute__((dllimport, dllexport)) extern int PrecedenceExternGlobal1A; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllimport) __declspec(dllexport) extern int PrecedenceExternGlobal1B; // expected-warning{{'dllimport' attribute ignored}}
__attribute__((dllexport, dllimport)) extern int PrecedenceExternGlobal2A; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllexport) __declspec(dllimport) extern int PrecedenceExternGlobal2B; // expected-warning{{'dllimport' attribute ignored}}
__attribute__((dllimport, dllexport)) int PrecedenceGlobal1A; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B; // expected-warning{{'dllimport' attribute ignored}}
__attribute__((dllexport, dllimport)) int PrecedenceGlobal2A; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllexport) extern int PrecedenceExternGlobalRedecl1;
__declspec(dllimport) extern int PrecedenceExternGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllimport) extern int PrecedenceExternGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllexport) extern int PrecedenceExternGlobalRedecl2;
__declspec(dllexport) extern int PrecedenceGlobalRedecl1;
__declspec(dllimport) int PrecedenceGlobalRedecl1; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllimport) extern int PrecedenceGlobalRedecl2; // expected-warning{{'dllimport' attribute ignored}}
__declspec(dllexport) int PrecedenceGlobalRedecl2;
void __attribute__((dllimport, dllexport)) precedence1A() {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllimport) __declspec(dllexport) precedence1B() {} // expected-warning{{'dllimport' attribute ignored}}
void __attribute__((dllexport, dllimport)) precedence2A() {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllexport) __declspec(dllimport) precedence2B() {} // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllimport) precedenceRedecl1(); // expected-warning{{'dllimport' attribute ignored}}
void __declspec(dllexport) precedenceRedecl1() {}
void __declspec(dllexport) precedenceRedecl2();
void __declspec(dllimport) precedenceRedecl2() {} // expected-warning{{'dllimport' attribute ignored}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/parentheses.cpp
|
// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
bool someConditionFunc();
void conditional_op(int x, int y, bool b) {
(void)(x + someConditionFunc() ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} \
// expected-note {{place parentheses around the '+' expression to silence this warning}} \
// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:33-[[@LINE-4]]:33}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:41-[[@LINE-6]]:41}:")"
(void)(x - b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '-'}} \
// expected-note {{place parentheses around the '-' expression to silence this warning}} \
// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:15-[[@LINE-4]]:15}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:23-[[@LINE-6]]:23}:")"
(void)(x * (x == y) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '*'}} \
// expected-note {{place parentheses around the '*' expression to silence this warning}} \
// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:22-[[@LINE-4]]:22}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:30-[[@LINE-6]]:30}:")"
}
class Stream {
public:
operator int();
Stream &operator<<(int);
Stream &operator<<(const char*);
Stream &operator>>(int);
Stream &operator>>(const char*);
};
void f(Stream& s, bool b) {
(void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \
// expected-note {{place parentheses around the '<<' expression to silence this warning}} \
// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:32-[[@LINE-6]]:32}:")"
(void)(s << 5 == 1); // expected-warning {{overloaded operator << has higher precedence than comparison operator}} \
// expected-note {{place parentheses around the '<<' expression to silence this warning}} \
// expected-note {{place parentheses around comparison expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"
(void)(s >> 5 == 1); // expected-warning {{overloaded operator >> has higher precedence than comparison operator}} \
// expected-note {{place parentheses around the '>>' expression to silence this warning}} \
// expected-note {{place parentheses around comparison expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"
}
struct S {
operator int() { return 42; }
friend S operator+(const S &lhs, bool) { return S(); }
};
void test(S *s, bool (S::*m_ptr)()) {
(void)(*s + true ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '+'}} \
// expected-note {{place parentheses around the '+' expression to silence this warning}} \
// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:10-[[@LINE-3]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:19-[[@LINE-4]]:19}:")"
// CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:35-[[@LINE-6]]:35}:")"
(void)((*s + true) ? "foo" : "bar"); // No warning.
// Don't crash on unusual member call expressions.
(void)((s->*m_ptr)() ? "foo" : "bar");
}
void test(int a, int b, int c) {
(void)(a >> b + c); // expected-warning {{operator '>>' has lower precedence than '+'; '+' will be evaluated first}} \
expected-note {{place parentheses around the '+' expression to silence this warning}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")"
(void)(a - b << c); // expected-warning {{operator '<<' has lower precedence than '-'; '-' will be evaluated first}} \
expected-note {{place parentheses around the '-' expression to silence this warning}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:10-[[@LINE-2]]:10}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:15-[[@LINE-3]]:15}:")"
Stream() << b + c;
Stream() >> b + c; // expected-warning {{operator '>>' has lower precedence than '+'; '+' will be evaluated first}} \
expected-note {{place parentheses around the '+' expression to silence this warning}}
// CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:15-[[@LINE-2]]:15}:"("
// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:20-[[@LINE-3]]:20}:")"
}
namespace PR15628 {
struct BlockInputIter {
void* operator++(int);
void* operator--(int);
};
void test(BlockInputIter i) {
(void)(i++ ? true : false); // no-warning
(void)(i-- ? true : false); // no-warning
}
}
namespace PR20735 {
struct X {
static int state;
static int get();
int get_num();
int num;
};
namespace ns {
int num = 0;
int get();
}
void test(X x) {
if (5 & x.get_num() != 0) {}
// expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
// expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
// expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
// CHECK: place parentheses around the '!=' expression to silence this warning
// fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
// fix-it:"{{.*}}":{[[@LINE-6]]:29-[[@LINE-6]]:29}:")"
// CHECK: place parentheses around the & expression to evaluate it first
// fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
// fix-it:"{{.*}}":{[[@LINE-9]]:24-[[@LINE-9]]:24}:")"
if (5 & x.num != 0) {}
// expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
// expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
// expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
// CHECK: place parentheses around the '!=' expression to silence this warning
// fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
// fix-it:"{{.*}}":{[[@LINE-6]]:23-[[@LINE-6]]:23}:")"
// CHECK: place parentheses around the & expression to evaluate it first
// fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
// fix-it:"{{.*}}":{[[@LINE-9]]:18-[[@LINE-9]]:18}:")"
if (5 & x.state != 0) {}
// expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
// expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
// expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
// CHECK: place parentheses around the '!=' expression to silence this warning
// fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
// fix-it:"{{.*}}":{[[@LINE-6]]:25-[[@LINE-6]]:25}:")"
// CHECK: place parentheses around the & expression to evaluate it first
// fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
// fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")"
if (5 & x.get() != 0) {}
// expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
// expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
// expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
// CHECK: place parentheses around the '!=' expression to silence this warning
// fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
// fix-it:"{{.*}}":{[[@LINE-6]]:25-[[@LINE-6]]:25}:")"
// CHECK: place parentheses around the & expression to evaluate it first
// fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
// fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")"
if (5 & X::state != 0) {}
// expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
// expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
// expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
// CHECK: place parentheses around the '!=' expression to silence this warning
// fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
// fix-it:"{{.*}}":{[[@LINE-6]]:26-[[@LINE-6]]:26}:")"
// CHECK: place parentheses around the & expression to evaluate it first
// fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
// fix-it:"{{.*}}":{[[@LINE-9]]:21-[[@LINE-9]]:21}:")"
if (5 & X::get() != 0) {}
// expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
// expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
// expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
// CHECK: place parentheses around the '!=' expression to silence this warning
// fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
// fix-it:"{{.*}}":{[[@LINE-6]]:26-[[@LINE-6]]:26}:")"
// CHECK: place parentheses around the & expression to evaluate it first
// fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
// fix-it:"{{.*}}":{[[@LINE-9]]:21-[[@LINE-9]]:21}:")"
if (5 & ns::get() != 0) {}
// expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
// expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
// expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
// CHECK: place parentheses around the '!=' expression to silence this warning
// fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
// fix-it:"{{.*}}":{[[@LINE-6]]:27-[[@LINE-6]]:27}:")"
// CHECK: place parentheses around the & expression to evaluate it first
// fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
// fix-it:"{{.*}}":{[[@LINE-9]]:22-[[@LINE-9]]:22}:")"
if (5 & ns::num != 0) {}
// expected-warning@-1 {{& has lower precedence than !=; != will be evaluated first}}
// expected-note@-2 {{place parentheses around the '!=' expression to silence this warning}}
// expected-note@-3 {{place parentheses around the & expression to evaluate it first}}
// CHECK: place parentheses around the '!=' expression to silence this warning
// fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
// fix-it:"{{.*}}":{[[@LINE-6]]:25-[[@LINE-6]]:25}:")"
// CHECK: place parentheses around the & expression to evaluate it first
// fix-it:"{{.*}}":{[[@LINE-8]]:9-[[@LINE-8]]:9}:"("
// fix-it:"{{.*}}":{[[@LINE-9]]:20-[[@LINE-9]]:20}:")"
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/overloadable.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
int var __attribute__((overloadable)); // expected-error{{'overloadable' attribute only applies to functions}}
void params(void) __attribute__((overloadable(12))); // expected-error {{'overloadable' attribute takes no arguments}}
int *f(int) __attribute__((overloadable)); // expected-note 2{{previous overload of function is here}}
float *f(float); // expected-error{{overloaded function 'f' must have the 'overloadable' attribute}}
int *f(int); // expected-error{{redeclaration of 'f' must have the 'overloadable' attribute}} \
// expected-note{{previous declaration is here}}
double *f(double) __attribute__((overloadable)); // okay, new
void test_f(int iv, float fv, double dv) {
int *ip = f(iv);
float *fp = f(fv);
double *dp = f(dv);
}
int *accept_funcptr(int (*)()) __attribute__((overloadable)); // \
// expected-note{{candidate function}}
float *accept_funcptr(int (*)(int, double)) __attribute__((overloadable)); // \
// expected-note{{candidate function}}
void test_funcptr(int (*f1)(int, double),
int (*f2)(int, float)) {
float *fp = accept_funcptr(f1);
accept_funcptr(f2); // expected-error{{no matching function for call to 'accept_funcptr'}}
}
struct X { int x; float y; };
struct Y { int x; float y; };
int* accept_struct(struct X x) __attribute__((__overloadable__));
float* accept_struct(struct Y y) __attribute__((overloadable));
void test_struct(struct X x, struct Y y) {
int *ip = accept_struct(x);
float *fp = accept_struct(y);
}
double *f(int) __attribute__((overloadable)); // expected-error{{conflicting types for 'f'}}
double promote(float) __attribute__((__overloadable__)); // expected-note {{candidate}}
double promote(double) __attribute__((__overloadable__)); // expected-note {{candidate}}
long double promote(long double) __attribute__((__overloadable__)); // expected-note {{candidate}}
void promote(...) __attribute__((__overloadable__, __unavailable__)); // \
// expected-note{{candidate function}}
void test_promote(short* sp) {
promote(1.0);
promote(sp); // expected-error{{call to unavailable function 'promote'}}
}
// PR6600
typedef double Double;
typedef Double DoubleVec __attribute__((vector_size(16)));
typedef int Int;
typedef Int IntVec __attribute__((vector_size(16)));
double magnitude(DoubleVec) __attribute__((__overloadable__));
double magnitude(IntVec) __attribute__((__overloadable__));
double test_p6600(DoubleVec d) {
return magnitude(d) * magnitude(d);
}
// PR7738
extern int __attribute__((overloadable)) f0(); // expected-error{{'overloadable' function 'f0' must have a prototype}}
typedef int f1_type();
f1_type __attribute__((overloadable)) f1; // expected-error{{'overloadable' function 'f1' must have a prototype}}
void test() {
f0();
f1();
}
void before_local_1(int) __attribute__((overloadable)); // expected-note {{here}}
void before_local_2(int); // expected-note {{here}}
void before_local_3(int) __attribute__((overloadable));
void local() {
void before_local_1(char); // expected-error {{must have the 'overloadable' attribute}}
void before_local_2(char) __attribute__((overloadable)); // expected-error {{conflicting types}}
void before_local_3(char) __attribute__((overloadable));
void after_local_1(char); // expected-note {{here}}
void after_local_2(char) __attribute__((overloadable)); // expected-note {{here}}
void after_local_3(char) __attribute__((overloadable));
}
void after_local_1(int) __attribute__((overloadable)); // expected-error {{conflicting types}}
void after_local_2(int); // expected-error {{must have the 'overloadable' attribute}}
void after_local_3(int) __attribute__((overloadable));
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/neon-vector-types-support.c
|
// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported for this target}}
typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported for this target}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/loop-control.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -x c++ -Werror %s
int pr8880_1() {
int first = 1;
for ( ; ({ if (first) { first = 0; continue; } 0; }); )
return 0;
return 1;
}
void pr8880_2(int first) {
for ( ; ({ if (first) { first = 0; break; } 0; }); ) {}
}
void pr8880_3(int first) {
for ( ; ; (void)({ if (first) { first = 0; continue; } 0; })) {}
}
void pr8880_4(int first) {
for ( ; ; (void)({ if (first) { first = 0; break; } 0; })) {}
}
void pr8880_5 (int first) {
while(({ if (first) { first = 0; continue; } 0; })) {}
}
void pr8880_6 (int first) {
while(({ if (first) { first = 0; break; } 0; })) {}
}
void pr8880_7 (int first) {
do {} while(({ if (first) { first = 0; continue; } 0; }));
}
void pr8880_8 (int first) {
do {} while(({ if (first) { first = 0; break; } 0; }));
}
void pr8880_10(int i) {
for ( ; i != 10 ; i++ )
for ( ; ; (void)({ ++i; continue; i;})) {} // expected-warning{{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
}
void pr8880_11(int i) {
for ( ; i != 10 ; i++ )
for ( ; ; (void)({ ++i; break; i;})) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
}
void pr8880_12(int i, int j) {
for ( ; i != 10 ; i++ )
for ( ; ({if (i) continue; i;}); j++) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
}
void pr8880_13(int i, int j) {
for ( ; i != 10 ; i++ )
for ( ; ({if (i) break; i;}); j++) {} // expected-warning{{'break' is bound to current loop, GCC binds it to the enclosing loop}}
}
void pr8880_14(int i) {
for ( ; i != 10 ; i++ )
while(({if (i) break; i;})) {} // expected-warning {{'break' is bound to current loop, GCC binds it to the enclosing loop}}
}
void pr8880_15(int i) {
while (--i)
while(({if (i) continue; i;})) {} // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
}
void pr8880_16(int i) {
for ( ; i != 10 ; i++ )
do {} while(({if (i) break; i;})); // expected-warning {{'break' is bound to current loop, GCC binds it to the enclosing loop}}
}
void pr8880_17(int i) {
for ( ; i != 10 ; i++ )
do {} while(({if (i) continue; i;})); // expected-warning {{'continue' is bound to current loop, GCC binds it to the enclosing loop}}
}
void pr8880_18(int x, int y) {
while(x > 0)
switch(({if(y) break; y;})) {
case 2: x = 0;
}
}
void pr8880_19(int x, int y) {
switch(x) {
case 1:
switch(({if(y) break; y;})) {
case 2: x = 0;
}
}
}
void pr8880_20(int x, int y) {
switch(x) {
case 1:
while(({if (y) break; y;})) {} //expected-warning {{'break' is bound to loop, GCC binds it to switch}}
}
}
void pr8880_21(int x, int y) {
switch(x) {
case 1:
do {} while(({if (y) break; y;})); //expected-warning {{'break' is bound to loop, GCC binds it to switch}}
}
}
void pr8880_22(int x, int y) {
switch(x) {
case 1:
for ( ; ; (void)({ ++y; break; y;})) {} // expected-warning{{'break' is bound to loop, GCC binds it to switc}}
}
}
void pr8880_23(int x, int y) {
switch(x) {
case 1:
for ( ; ({ ++y; break; y;}); ++y) {} // expected-warning{{'break' is bound to loop, GCC binds it to switch}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/PR2919-builtin-types-compat-strips-crv.c
|
// RUN: %clang_cc1 -fsyntax-only %s
typedef struct foo T0;
typedef const struct foo T1;
int a0[__builtin_types_compatible_p(T0,
const T1) ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/unused-expr.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code
int foo(int X, int Y);
double sqrt(double X); // implicitly const because of no -fmath-errno!
void bar(volatile int *VP, int *P, int A,
_Complex double C, volatile _Complex double VC) {
VP < P; // expected-warning {{relational comparison result unused}}
(void)A;
(void)foo(1,2); // no warning.
A < foo(1, 2); // expected-warning {{relational comparison result unused}}
foo(1,2)+foo(4,3); // expected-warning {{expression result unused}}
*P; // expected-warning {{expression result unused}}
*VP; // no warning.
P[4]; // expected-warning {{expression result unused}}
VP[4]; // no warning.
__real__ C; // expected-warning {{expression result unused}}
__real__ VC;
// We know this can't change errno because of no -fmath-errno.
sqrt(A); // expected-warning {{ignoring return value of function declared with const attribute}}
}
extern void t1();
extern void t2();
void t3(int c) {
c ? t1() : t2();
}
// This shouldn't warn: the expr at the end of the stmtexpr really is used.
int stmt_expr(int x, int y) {
return ({int _a = x, _b = y; _a > _b ? _a : _b; });
}
void nowarn(unsigned char* a, unsigned char* b)
{
unsigned char c = 1;
*a |= c, *b += c;
// PR4633
int y, x;
((void)0), y = x;
}
void t4(int a) {
int b = 0;
if (a)
b < 1; // expected-warning{{relational comparison result unused}}
else
b < 2; // expected-warning{{relational comparison result unused}}
while (1)
b < 3; // expected-warning{{relational comparison result unused}}
do
b < 4; // expected-warning{{relational comparison result unused}}
while (1);
for (;;)
b < 5; // expected-warning{{relational comparison result unused}}
for (b < 1;;) {} // expected-warning{{relational comparison result unused}}
for (;b < 1;) {}
for (;;b < 1) {} // expected-warning{{relational comparison result unused}}
}
// rdar://7186119
int t5f(void) __attribute__((warn_unused_result));
void t5() {
t5f(); // expected-warning {{ignoring return value of function declared with warn_unused_result}}
}
int fn1() __attribute__ ((warn_unused_result));
int fn2() __attribute__ ((pure));
int fn3() __attribute__ ((__const));
// rdar://6587766
int t6() {
if (fn1() < 0 || fn2(2,1) < 0 || fn3(2) < 0) // no warnings
return -1;
fn1(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
fn2(92, 21); // expected-warning {{ignoring return value of function declared with pure attribute}}
fn3(42); // expected-warning {{ignoring return value of function declared with const attribute}}
__builtin_abs(0); // expected-warning {{ignoring return value of function declared with const attribute}}
(void)0, fn1(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
return 0;
}
int t7 __attribute__ ((warn_unused_result)); // expected-warning {{'warn_unused_result' attribute only applies to functions}}
// PR4010
int (*fn4)(void) __attribute__ ((warn_unused_result));
void t8() {
fn4(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
}
void t9() __attribute__((warn_unused_result)); // expected-warning {{attribute 'warn_unused_result' cannot be applied to functions without return value}}
// rdar://7410924
void *some_function(void);
void t10() {
(void*) some_function(); //expected-warning {{expression result unused; should this cast be to 'void'?}}
}
void f(int i, ...) {
__builtin_va_list ap;
__builtin_va_start(ap, i);
__builtin_va_arg(ap, int);
__builtin_va_end(ap);
}
// PR8371
int fn5() __attribute__ ((__const));
// Don't warn for unused expressions in macro bodies; however, do warn for
// unused expressions in macro arguments. Macros below are reduced from code
// found in the wild.
#define NOP(a) (a)
#define M1(a, b) (long)foo((a), (b))
#define M2 (long)0;
#define M3(a) (t3(a), fn2())
#define M4(a, b) (foo((a), (b)) ? 0 : t3(a), 1)
#define M5(a, b) (foo((a), (b)), 1)
#define M6() fn1()
#define M7() fn2()
void t11(int i, int j) {
M1(i, j); // no warning
NOP((long)foo(i, j)); // expected-warning {{expression result unused}}
M2; // no warning
NOP((long)0); // expected-warning {{expression result unused}}
M3(i); // no warning
NOP((t3(i), fn2())); // expected-warning {{ignoring return value}}
M4(i, j); // no warning
NOP((foo(i, j) ? 0 : t3(i), 1)); // expected-warning {{expression result unused}}
M5(i, j); // no warning
NOP((foo(i, j), 1)); // expected-warning {{expression result unused}}
M6(); // expected-warning {{ignoring return value}}
M7(); // no warning
}
#undef NOP
#undef M1
#undef M2
#undef M3
#undef M4
#undef M5
#undef M6
#undef M7
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ucn-identifiers.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
// RUN: %clang_cc1 %s -verify -fsyntax-only -x c++ -pedantic
// This file contains UTF-8; please do not fix!
extern void \u00FCber(int);
extern void \U000000FCber(int); // redeclaration, no warning
#ifdef __cplusplus
// expected-note@-2 + {{candidate function not viable}}
#else
// expected-note@-4 + {{declared here}}
#endif
void goodCalls() {
\u00FCber(0);
\u00fcber(1);
über(2);
\U000000FCber(3);
}
void badCalls() {
\u00FCber(0.5); // expected-warning{{implicit conversion from 'double' to 'int'}}
\u00fcber = 0; // expected-error{{non-object type 'void (int)' is not assignable}}
über(1, 2);
\U000000FCber();
#ifdef __cplusplus
// expected-error@-3 {{no matching function}}
// expected-error@-3 {{no matching function}}
#else
// expected-error@-6 {{too many arguments to function call, expected 1, have 2}}
// expected-error@-6 {{too few arguments to function call, expected 1, have 0}}
#endif
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/fp16-sema.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// Functions cannot have parameters of type __fp16.
extern void f (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}}
extern void g (__fp16 *);
extern void (*pf) (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}}
extern void (*pg) (__fp16*);
typedef void(*tf) (__fp16); // expected-error {{parameters cannot have __fp16 type; did you forget * ?}}
typedef void(*tg) (__fp16*);
void kf(a)
__fp16 a; { // expected-error {{parameters cannot have __fp16 type; did you forget * ?}}
}
void kg(a)
__fp16 *a; {
}
// Functions cannot return type __fp16.
extern __fp16 f1 (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}}
extern __fp16 *g1 (void);
extern __fp16 (*pf1) (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}}
extern __fp16 *(*gf1) (void);
typedef __fp16 (*tf1) (void); // expected-error {{function return value cannot have __fp16 type; did you forget * ?}}
typedef __fp16 *(*tg1) (void);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/align-arm-apcs.c
|
// RUN: %clang_cc1 -triple arm-unknown-unknown -target-abi apcs-gnu -fsyntax-only -verify %s
// expected-no-diagnostics
struct s0 { double f0; int f1; };
char chk0[__alignof__(struct s0) == 4 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/constant-builtins-2.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// Math stuff
double g0 = __builtin_huge_val();
float g1 = __builtin_huge_valf();
long double g2 = __builtin_huge_vall();
double g3 = __builtin_inf();
float g4 = __builtin_inff();
long double g5 = __builtin_infl();
double g6 = __builtin_nan("");
float g7 = __builtin_nanf("");
long double g8 = __builtin_nanl("");
// GCC constant folds these too (via native strtol):
//double g6_1 = __builtin_nan("1");
//float g7_1 = __builtin_nanf("1");
//long double g8_1 = __builtin_nanl("1");
// APFloat doesn't have signalling NaN functions.
//double g9 = __builtin_nans("");
//float g10 = __builtin_nansf("");
//long double g11 = __builtin_nansl("");
//int g12 = __builtin_abs(-12);
double g13 = __builtin_fabs(-12.);
double g13_0 = __builtin_fabs(-0.);
double g13_1 = __builtin_fabs(-__builtin_inf());
float g14 = __builtin_fabsf(-12.f);
// GCC doesn't eat this one.
//long double g15 = __builtin_fabsfl(-12.0L);
float g16 = __builtin_copysign(1.0, -1.0);
double g17 = __builtin_copysignf(1.0f, -1.0f);
long double g18 = __builtin_copysignl(1.0L, -1.0L);
char classify_nan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nan(""))];
char classify_snan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nans(""))];
char classify_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, __builtin_inf())];
char classify_neg_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, -__builtin_inf())];
char classify_normal [__builtin_fpclassify(-1, -1, +1, -1, -1, 1.539)];
char classify_normal2 [__builtin_fpclassify(-1, -1, +1, -1, -1, 1e-307)];
char classify_denorm [__builtin_fpclassify(-1, -1, -1, +1, -1, 1e-308)];
char classify_denorm2 [__builtin_fpclassify(-1, -1, -1, +1, -1, -1e-308)];
char classify_zero [__builtin_fpclassify(-1, -1, -1, -1, +1, 0.0)];
char classify_neg_zero[__builtin_fpclassify(-1, -1, -1, -1, +1, -0.0)];
char isinf_sign_noninf1[__builtin_isinf_sign(-0.0) == 0 ? 1 : -1];
char isinf_sign_noninf2[__builtin_isinf_sign(1e307) == 0 ? 1 : -1];
char isinf_sign_noninf3[__builtin_isinf_sign(__builtin_nan("")) == 0 ? 1 : -1];
char isinf_sign_noninf4[__builtin_isinf_sign(-436.) == 0 ? 1 : -1];
char isinf_sign_inf [__builtin_isinf_sign(__builtin_inf()) == 1 ? 1 : -1];
char isinf_sign_neg_inf[__builtin_isinf_sign(-__builtin_inf()) == -1 ? 1 : -1];
char isinf_inf_pos[__builtin_isinf(__builtin_inf()) ? 1 : -1];
char isinf_pos [!__builtin_isinf(1.0) ? 1 : -1];
char isinf_normf [!__builtin_isinf(1e-37f) ? 1 : -1];
char isinf_denormf[!__builtin_isinf(1e-38f) ? 1 : -1];
char isinf_norm [!__builtin_isinf(1e-307) ? 1 : -1];
char isinf_denorm [!__builtin_isinf(1e-308) ? 1 : -1];
char isinf_zero [!__builtin_isinf(0.0) ? 1 : -1];
char isinf_negzero[!__builtin_isinf(-0.0) ? 1 : -1];
char isinf_neg [!__builtin_isinf(-1.0) ? 1 : -1];
char isinf_inf_neg[__builtin_isinf(-__builtin_inf()) ? 1 : -1];
char isinf_nan [!__builtin_isinf(__builtin_nan("")) ? 1 : -1];
char isinf_snan [!__builtin_isinf(__builtin_nans("")) ? 1 : -1];
char isfinite_inf_pos[!__builtin_isfinite(__builtin_inf()) ? 1 : -1];
char isfinite_pos [__builtin_isfinite(1.0) ? 1 : -1];
char isfinite_normf [__builtin_isfinite(1e-37f) ? 1 : -1];
char isfinite_denormf[__builtin_isfinite(1e-38f) ? 1 : -1];
char isfinite_norm [__builtin_isfinite(1e-307) ? 1 : -1];
char isfinite_denorm [__builtin_isfinite(1e-308) ? 1 : -1];
char isfinite_zero [__builtin_isfinite(0.0) ? 1 : -1];
char isfinite_negzero[__builtin_isfinite(-0.0) ? 1 : -1];
char isfinite_neg [__builtin_isfinite(-1.0) ? 1 : -1];
char isfinite_inf_neg[!__builtin_isfinite(-__builtin_inf()) ? 1 : -1];
char isfinite_nan [!__builtin_isfinite(__builtin_nan("")) ? 1 : -1];
char isfinite_snan [!__builtin_isfinite(__builtin_nans("")) ? 1 : -1];
char isnan_inf_pos[!__builtin_isnan(__builtin_inf()) ? 1 : -1];
char isnan_pos [!__builtin_isnan(1.0) ? 1 : -1];
char isnan_normf [!__builtin_isnan(1e-37f) ? 1 : -1];
char isnan_denormf[!__builtin_isnan(1e-38f) ? 1 : -1];
char isnan_norm [!__builtin_isnan(1e-307) ? 1 : -1];
char isnan_denorm [!__builtin_isnan(1e-308) ? 1 : -1];
char isnan_zero [!__builtin_isnan(0.0) ? 1 : -1];
char isnan_negzero[!__builtin_isnan(-0.0) ? 1 : -1];
char isnan_neg [!__builtin_isnan(-1.0) ? 1 : -1];
char isnan_inf_neg[!__builtin_isnan(-__builtin_inf()) ? 1 : -1];
char isnan_nan [__builtin_isnan(__builtin_nan("")) ? 1 : -1];
char isnan_snan [__builtin_isnan(__builtin_nans("")) ? 1 : -1];
char isnormal_inf_pos[!__builtin_isnormal(__builtin_inf()) ? 1 : -1];
char isnormal_pos [__builtin_isnormal(1.0) ? 1 : -1];
char isnormal_normf [__builtin_isnormal(1e-37f) ? 1 : -1];
char isnormal_denormf[!__builtin_isnormal(1e-38f) ? 1 : -1];
char isnormal_norm [__builtin_isnormal(1e-307) ? 1 : -1];
char isnormal_denorm [!__builtin_isnormal(1e-308) ? 1 : -1];
char isnormal_zero [!__builtin_isnormal(0.0) ? 1 : -1];
char isnormal_negzero[!__builtin_isnormal(-0.0) ? 1 : -1];
char isnormal_neg [__builtin_isnormal(-1.0) ? 1 : -1];
char isnormal_inf_neg[!__builtin_isnormal(-__builtin_inf()) ? 1 : -1];
char isnormal_nan [!__builtin_isnormal(__builtin_nan("")) ? 1 : -1];
char isnormal_snan [!__builtin_isnormal(__builtin_nans("")) ? 1 : -1];
//double g19 = __builtin_powi(2.0, 4);
//float g20 = __builtin_powif(2.0f, 4);
//long double g21 = __builtin_powil(2.0L, 4);
#define BITSIZE(x) (sizeof(x) * 8)
char clz1[__builtin_clz(1) == BITSIZE(int) - 1 ? 1 : -1];
char clz2[__builtin_clz(7) == BITSIZE(int) - 3 ? 1 : -1];
char clz3[__builtin_clz(1 << (BITSIZE(int) - 1)) == 0 ? 1 : -1];
int clz4 = __builtin_clz(0); // expected-error {{not a compile-time constant}}
char clz5[__builtin_clzl(0xFL) == BITSIZE(long) - 4 ? 1 : -1];
char clz6[__builtin_clzll(0xFFLL) == BITSIZE(long long) - 8 ? 1 : -1];
char clz7[__builtin_clzs(0x1) == BITSIZE(short) - 1 ? 1 : -1];
char clz8[__builtin_clzs(0xf) == BITSIZE(short) - 4 ? 1 : -1];
char clz9[__builtin_clzs(0xfff) == BITSIZE(short) - 12 ? 1 : -1];
char ctz1[__builtin_ctz(1) == 0 ? 1 : -1];
char ctz2[__builtin_ctz(8) == 3 ? 1 : -1];
char ctz3[__builtin_ctz(1 << (BITSIZE(int) - 1)) == BITSIZE(int) - 1 ? 1 : -1];
int ctz4 = __builtin_ctz(0); // expected-error {{not a compile-time constant}}
char ctz5[__builtin_ctzl(0x10L) == 4 ? 1 : -1];
char ctz6[__builtin_ctzll(0x100LL) == 8 ? 1 : -1];
char ctz7[__builtin_ctzs(1 << (BITSIZE(short) - 1)) == BITSIZE(short) - 1 ? 1 : -1];
char popcount1[__builtin_popcount(0) == 0 ? 1 : -1];
char popcount2[__builtin_popcount(0xF0F0) == 8 ? 1 : -1];
char popcount3[__builtin_popcount(~0) == BITSIZE(int) ? 1 : -1];
char popcount4[__builtin_popcount(~0L) == BITSIZE(int) ? 1 : -1];
char popcount5[__builtin_popcountl(0L) == 0 ? 1 : -1];
char popcount6[__builtin_popcountl(0xF0F0L) == 8 ? 1 : -1];
char popcount7[__builtin_popcountl(~0L) == BITSIZE(long) ? 1 : -1];
char popcount8[__builtin_popcountll(0LL) == 0 ? 1 : -1];
char popcount9[__builtin_popcountll(0xF0F0LL) == 8 ? 1 : -1];
char popcount10[__builtin_popcountll(~0LL) == BITSIZE(long long) ? 1 : -1];
char parity1[__builtin_parity(0) == 0 ? 1 : -1];
char parity2[__builtin_parity(0xb821) == 0 ? 1 : -1];
char parity3[__builtin_parity(0xb822) == 0 ? 1 : -1];
char parity4[__builtin_parity(0xb823) == 1 ? 1 : -1];
char parity5[__builtin_parity(0xb824) == 0 ? 1 : -1];
char parity6[__builtin_parity(0xb825) == 1 ? 1 : -1];
char parity7[__builtin_parity(0xb826) == 1 ? 1 : -1];
char parity8[__builtin_parity(~0) == 0 ? 1 : -1];
char parity9[__builtin_parityl(1L << (BITSIZE(long) - 1)) == 1 ? 1 : -1];
char parity10[__builtin_parityll(1LL << (BITSIZE(long long) - 1)) == 1 ? 1 : -1];
char ffs1[__builtin_ffs(0) == 0 ? 1 : -1];
char ffs2[__builtin_ffs(1) == 1 ? 1 : -1];
char ffs3[__builtin_ffs(0xfbe71) == 1 ? 1 : -1];
char ffs4[__builtin_ffs(0xfbe70) == 5 ? 1 : -1];
char ffs5[__builtin_ffs(1U << (BITSIZE(int) - 1)) == BITSIZE(int) ? 1 : -1];
char ffs6[__builtin_ffsl(0x10L) == 5 ? 1 : -1];
char ffs7[__builtin_ffsll(0x100LL) == 9 ? 1 : -1];
#undef BITSIZE
// GCC misc stuff
extern int f();
int h0 = __builtin_types_compatible_p(int, float);
//int h1 = __builtin_choose_expr(1, 10, f());
//int h2 = __builtin_expect(0, 0);
int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f();
int h4 = __builtin_bswap32(0x1234) == 0x34120000 ? 1 : f();
int h5 = __builtin_bswap64(0x1234) == 0x3412000000000000 ? 1 : f();
extern long int bi0;
extern __typeof__(__builtin_expect(0, 0)) bi0;
// Strings
int array1[__builtin_strlen("ab\0cd")];
int array2[(sizeof(array1)/sizeof(int)) == 2? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/arm-asm.c
|
// RUN: %clang_cc1 %s -triple armv7-apple-darwin -verify -fsyntax-only
void f (void) {
int Val;
asm volatile ("lw (r1), %0[val]": "=&b"(Val)); // expected-error {{invalid output constraint '=&b' in asm}}
return;
}
void test_64bit_r(void) {
long long foo = 0, bar = 0;
asm volatile("INST %0, %1" : "=r"(foo) : "r"(bar));
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-capabilities.c
|
// RUN: %clang_cc1 -fsyntax-only -Wthread-safety -verify %s
typedef int __attribute__((capability("role"))) ThreadRole;
struct __attribute__((shared_capability("mutex"))) Mutex {};
struct NotACapability {};
// Test an invalid capability name
struct __attribute__((capability("wrong"))) IncorrectName {}; // expected-warning {{invalid capability name 'wrong'; capability name must be 'mutex' or 'role'}}
int Test1 __attribute__((capability("test1"))); // expected-error {{'capability' attribute only applies to structs and typedefs}}
int Test2 __attribute__((shared_capability("test2"))); // expected-error {{'shared_capability' attribute only applies to structs and typedefs}}
int Test3 __attribute__((acquire_capability("test3"))); // expected-warning {{'acquire_capability' attribute only applies to functions}}
int Test4 __attribute__((try_acquire_capability("test4"))); // expected-error {{'try_acquire_capability' attribute only applies to functions}}
int Test5 __attribute__((release_capability("test5"))); // expected-warning {{'release_capability' attribute only applies to functions}}
struct __attribute__((capability(12))) Test3 {}; // expected-error {{'capability' attribute requires a string}}
struct __attribute__((shared_capability(Test2))) Test4 {}; // expected-error {{'shared_capability' attribute requires a string}}
struct __attribute__((capability)) Test5 {}; // expected-error {{'capability' attribute takes one argument}}
struct __attribute__((shared_capability("test1", 12))) Test6 {}; // expected-error {{'shared_capability' attribute takes one argument}}
struct NotACapability BadCapability;
ThreadRole GUI, Worker;
void Func1(void) __attribute__((requires_capability(GUI))) {}
void Func2(void) __attribute__((requires_shared_capability(Worker))) {}
void Func3(void) __attribute__((requires_capability)) {} // expected-error {{'requires_capability' attribute takes at least 1 argument}}
void Func4(void) __attribute__((requires_shared_capability)) {} // expected-error {{'requires_shared_capability' attribute takes at least 1 argument}}
void Func5(void) __attribute__((requires_capability(1))) {} // expected-warning {{'requires_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'int'}}
void Func6(void) __attribute__((requires_shared_capability(BadCapability))) {} // expected-warning {{'requires_shared_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'struct NotACapability'}}
void Func7(void) __attribute__((assert_capability(GUI))) {}
void Func8(void) __attribute__((assert_shared_capability(GUI))) {}
void Func9(void) __attribute__((assert_capability())) {} // expected-error {{'assert_capability' attribute takes one argument}}
void Func10(void) __attribute__((assert_shared_capability())) {} // expected-error {{'assert_shared_capability' attribute takes one argument}}
void Func11(void) __attribute__((acquire_capability(GUI))) {}
void Func12(void) __attribute__((acquire_shared_capability(GUI))) {}
void Func15(void) __attribute__((release_capability(GUI))) {}
void Func16(void) __attribute__((release_shared_capability(GUI))) {}
void Func17(void) __attribute__((release_generic_capability(GUI))) {}
void Func21(void) __attribute__((try_acquire_capability(1))) {}
void Func22(void) __attribute__((try_acquire_shared_capability(1))) {}
void Func23(void) __attribute__((try_acquire_capability(1, GUI))) {}
void Func24(void) __attribute__((try_acquire_shared_capability(1, GUI))) {}
void Func25(void) __attribute__((try_acquire_capability())) {} // expected-error {{'try_acquire_capability' attribute takes at least 1 argument}}
void Func26(void) __attribute__((try_acquire_shared_capability())) {} // expected-error {{'try_acquire_shared_capability' attribute takes at least 1 argument}}
// Test that boolean logic works with capability attributes
void Func27(void) __attribute__((requires_capability(!GUI)));
void Func28(void) __attribute__((requires_capability(GUI && Worker)));
void Func29(void) __attribute__((requires_capability(GUI || Worker)));
void Func30(void) __attribute__((requires_capability((Worker || Worker) && !GUI)));
int AlsoNotACapability;
void Func31(void) __attribute__((requires_capability(GUI && AlsoNotACapability))); // expected-warning {{'requires_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'int'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/implicit-builtin-decl.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: not %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
void f() {
int *ptr = malloc(sizeof(int) * 10); // expected-warning{{implicitly declaring library function 'malloc' with type}} \
// expected-note{{include the header <stdlib.h> or explicitly provide a declaration for 'malloc'}} \
// expected-note{{'malloc' is a builtin with type 'void *}}
}
void *alloca(__SIZE_TYPE__); // redeclaration okay
int *calloc(__SIZE_TYPE__, __SIZE_TYPE__); // expected-warning{{incompatible redeclaration of library function 'calloc'}} \
// expected-note{{'calloc' is a builtin with type 'void *}}
void g(int malloc) { // okay: these aren't functions
int calloc = 1;
}
void h() {
int malloc(int); // expected-warning{{incompatible redeclaration of library function 'malloc'}}
int strcpy(int); // expected-warning{{incompatible redeclaration of library function 'strcpy'}} \
// expected-note{{'strcpy' is a builtin with type 'char *(char *, const char *)'}}
}
void f2() {
fprintf(0, "foo"); // expected-warning{{declaration of built-in function 'fprintf' requires inclusion of the header <stdio.h>}} \
expected-warning {{implicit declaration of function 'fprintf' is invalid in C99}}
}
// PR2892
void __builtin_object_size(); // expected-error{{conflicting types}} \
// expected-note{{'__builtin_object_size' is a builtin with type}}
int a[10];
int f0() {
return __builtin_object_size(&a); // expected-error {{too few arguments to function}}
}
void * realloc(void *p, int size) { // expected-warning{{incompatible redeclaration of library function 'realloc'}} \
// expected-note{{'realloc' is a builtin with type 'void *(void *,}}
return p;
}
// PR3855
void snprintf(); // expected-warning{{incompatible redeclaration of library function 'snprintf'}} \
// expected-note{{'snprintf' is a builtin}}
int
main(int argc, char *argv[])
{
snprintf();
}
void snprintf() { }
// PR8316
void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header <setjmp.h>}}
extern float fmaxf(float, float);
struct __jmp_buf_tag {};
void sigsetjmp(struct __jmp_buf_tag[1], int); // expected-warning{{declaration of built-in function 'sigsetjmp' requires inclusion of the header <setjmp.h>}}
// CHECK: FunctionDecl {{.*}} <line:[[@LINE-2]]:1, col:44> col:6 sigsetjmp '
// CHECK-NOT: FunctionDecl
// CHECK: ReturnsTwiceAttr {{.*}} <{{.*}}> Implicit
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/int-arith-convert.c
|
// RUN: %clang_cc1 -triple=i686-linux-gnu -fsyntax-only -verify %s
// expected-no-diagnostics
// Check types are the same through redeclaration
unsigned long x;
__typeof(1u+1l) x;
unsigned y;
__typeof(1+1u) y;
__typeof(1u+1) y;
long long z;
__typeof(1ll+1u) z;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ppc-bool.c
|
// RUN: %clang_cc1 -triple powerpc-apple-macosx10.4.0 -verify -fsyntax-only %s
// expected-no-diagnostics
extern __typeof(+(_Bool)0) should_be_int;
extern int should_be_int;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/arm64-inline-asm.c
|
// RUN: %clang_cc1 -triple arm64-apple-ios7.1 -fsyntax-only -verify %s
void foo() {
asm volatile("USE(%0)" :: "z"(0LL));
asm volatile("USE(%x0)" :: "z"(0LL));
asm volatile("USE(%w0)" :: "z"(0));
asm volatile("USE(%0)" :: "z"(0)); // expected-warning {{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-type-safety.c
|
// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify %s
// RUN: %clang_cc1 -x c++ -std=c++98 -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c99 -fno-signed-char -fsyntax-only -verify %s
struct A {};
typedef struct A *MPI_Datatype;
int wrong1(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag )); // expected-error {{'pointer_with_type_tag' attribute requires parameter 1 to be an identifier}}
int wrong2(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,0,7) )); // expected-error {{attribute parameter 2 is out of bounds}}
int wrong3(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,3,7) )); // expected-error {{attribute parameter 2 is out of bounds}}
int wrong4(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,1,0) )); // expected-error {{attribute parameter 3 is out of bounds}}
int wrong5(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,1,3) )); // expected-error {{attribute parameter 3 is out of bounds}}
int wrong6(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,0x8000000000000001ULL,1) )); // expected-error {{attribute parameter 2 is out of bounds}}
extern int x;
int wrong7(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,x,2) )); // expected-error {{attribute requires parameter 2 to be an integer constant}}
int wrong8(void *buf, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,1,x) )); // expected-error {{attribute requires parameter 3 to be an integer constant}}
int wrong9 __attribute__(( pointer_with_type_tag(mpi,1,2) )); // expected-error {{attribute only applies to functions and methods}}
int wrong10(double buf, MPI_Datatype type)
__attribute__(( pointer_with_type_tag(mpi,1,2) )); // expected-error {{'pointer_with_type_tag' attribute only applies to pointer arguments}}
extern struct A datatype_wrong1
__attribute__(( type_tag_for_datatype )); // expected-error {{'type_tag_for_datatype' attribute requires parameter 1 to be an identifier}}
extern struct A datatype_wrong2
__attribute__(( type_tag_for_datatype(mpi,1,2) )); // expected-error {{expected a type}}
extern struct A datatype_wrong3
__attribute__(( type_tag_for_datatype(mpi,not_a_type) )); // expected-error {{unknown type name 'not_a_type'}}
extern struct A datatype_wrong4
__attribute__(( type_tag_for_datatype(mpi,int,int) )); // expected-error {{expected identifier}}
extern struct A datatype_wrong5
__attribute__(( type_tag_for_datatype(mpi,int,not_a_flag) )); // expected-error {{invalid comparison flag 'not_a_flag'}}
extern struct A datatype_wrong6
__attribute__(( type_tag_for_datatype(mpi,int,layout_compatible,not_a_flag) )); // expected-error {{invalid comparison flag 'not_a_flag'}}
void datatype_wrong7(void) __attribute__((type_tag_for_datatype(datatype_wrong7, int))); // expected-error {{'type_tag_for_datatype' attribute only applies to variables}}
// Using a tag with kind A in a place where the function requires kind B should
// warn.
void A_func(void *ptr, void *tag) __attribute__(( pointer_with_type_tag(a,1,2) ));
extern struct A A_tag __attribute__(( type_tag_for_datatype(a,int) ));
extern struct A B_tag __attribute__(( type_tag_for_datatype(b,int) ));
void C_func(void *ptr, int tag) __attribute__(( pointer_with_type_tag(c,1,2) ));
static const int C_tag __attribute__(( type_tag_for_datatype(c,int) )) = 10;
static const int D_tag __attribute__(( type_tag_for_datatype(d,int) )) = 20;
void test_tag_mismatch(int *ptr)
{
A_func(ptr, &A_tag); // no-warning
A_func(ptr, &B_tag); // expected-warning {{this type tag was not designed to be used with this function}}
C_func(ptr, C_tag); // no-warning
C_func(ptr, D_tag); // expected-warning {{this type tag was not designed to be used with this function}}
C_func(ptr, 10); // no-warning
C_func(ptr, 20); // should warn, but may cause false positives
}
void test_null_pointer()
{
C_func(0, C_tag); // no-warning
C_func((void *) 0, C_tag); // no-warning
C_func((int *) 0, C_tag); // no-warning
C_func((long *) 0, C_tag); // expected-warning {{argument type 'long *' doesn't match specified 'c' type tag that requires 'int *'}}
}
// Check that we look through typedefs in the special case of allowing 'char'
// to be matched with 'signed char' or 'unsigned char'.
void E_func(void *ptr, int tag) __attribute__(( pointer_with_type_tag(e,1,2) ));
typedef char E_char;
typedef char E_char_2;
typedef signed char E_char_signed;
typedef unsigned char E_char_unsigned;
static const int E_tag __attribute__(( type_tag_for_datatype(e,E_char) )) = 10;
void test_char_typedef(char *char_buf,
E_char_2 *e_char_buf,
E_char_signed *e_char_signed_buf,
E_char_unsigned *e_char_unsigned_buf)
{
E_func(char_buf, E_tag);
E_func(e_char_buf, E_tag);
#ifdef __CHAR_UNSIGNED__
E_func(e_char_signed_buf, E_tag); // expected-warning {{argument type 'E_char_signed *' (aka 'signed char *') doesn't match specified 'e' type tag that requires 'E_char *' (aka 'char *')}}
E_func(e_char_unsigned_buf, E_tag);
#else
E_func(e_char_signed_buf, E_tag);
E_func(e_char_unsigned_buf, E_tag); // expected-warning {{argument type 'E_char_unsigned *' (aka 'unsigned char *') doesn't match specified 'e' type tag that requires 'E_char *' (aka 'char *')}}
#endif
}
// Tests for argument_with_type_tag.
#define F_DUPFD 10
#define F_SETLK 20
struct flock { };
static const int F_DUPFD_tag __attribute__(( type_tag_for_datatype(fcntl,int) )) = F_DUPFD;
static const int F_SETLK_tag __attribute__(( type_tag_for_datatype(fcntl,struct flock *) )) = F_SETLK;
int fcntl(int fd, int cmd, ...) __attribute__(( argument_with_type_tag(fcntl,3,2) ));
void test_argument_with_type_tag(struct flock *f)
{
fcntl(0, F_DUPFD, 10); // no-warning
fcntl(0, F_SETLK, f); // no-warning
fcntl(0, F_SETLK, 10); // expected-warning {{argument type 'int' doesn't match specified 'fcntl' type tag that requires 'struct flock *'}}
fcntl(0, F_DUPFD, f); // expected-warning {{argument type 'struct flock *' doesn't match specified 'fcntl' type tag that requires 'int'}}
}
void test_tag_expresssion(int b) {
fcntl(0, b ? F_DUPFD : F_SETLK, 10); // no-warning
fcntl(0, b + F_DUPFD, 10); // no-warning
fcntl(0, (b, F_DUPFD), 10); // expected-warning {{expression result unused}}
}
// Check that using 64-bit magic values as tags works and tag values do not
// overflow internally.
void F_func(void *ptr, unsigned long long tag) __attribute__((pointer_with_type_tag(f,1,2) ));
static const unsigned long long F_tag1 __attribute__(( type_tag_for_datatype(f,int) )) = 0xFFFFFFFFFFFFFFFFULL;
static const unsigned long long F_tag2 __attribute__(( type_tag_for_datatype(f,float) )) = 0xFFFFFFFFULL;
void test_64bit_magic(int *int_ptr, float *float_ptr)
{
F_func(int_ptr, 0xFFFFFFFFFFFFFFFFULL);
F_func(int_ptr, 0xFFFFFFFFULL); // expected-warning {{argument type 'int *' doesn't match specified 'f' type tag that requires 'float *'}}
F_func(float_ptr, 0xFFFFFFFFFFFFFFFFULL); // expected-warning {{argument type 'float *' doesn't match specified 'f' type tag that requires 'int *'}}
F_func(float_ptr, 0xFFFFFFFFULL);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-cast-qual.c
|
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -Wcast-qual -verify %s
#include <stdint.h>
void foo() {
const char * const ptr = 0;
const char * const *ptrptr = 0;
char *y = (char *)ptr; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}}
char **y1 = (char **)ptrptr; // expected-warning {{cast from 'const char *const' to 'char *' drops const qualifier}}
const char **y2 = (const char **)ptrptr; // expected-warning {{cast from 'const char *const *' to 'const char **' drops const qualifier}}
char *z = (char *)(uintptr_t)(const void *)ptr; // no warning
char *z1 = (char *)(const void *)ptr; // expected-warning {{cast from 'const void *' to 'char *' drops const qualifier}}
volatile char *vol = 0;
char *vol2 = (char *)vol; // expected-warning {{cast from 'volatile char *' to 'char *' drops volatile qualifier}}
const volatile char *volc = 0;
char *volc2 = (char *)volc; // expected-warning {{cast from 'const volatile char *' to 'char *' drops const and volatile qualifiers}}
int **intptrptr;
const int **intptrptrc = (const int **)intptrptr; // expected-warning {{cast from 'int **' to 'const int **' must have all intermediate pointers const qualified}}
volatile int **intptrptrv = (volatile int **)intptrptr; // expected-warning {{cast from 'int **' to 'volatile int **' must have all intermediate pointers const qualified}}
int *intptr;
const int *intptrc = (const int *)intptr; // no warning
const char **charptrptrc;
char **charptrptr = (char **)charptrptrc; // expected-warning {{cast from 'const char *' to 'char *' drops const qualifier}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-ownership.c
|
// RUN: %clang_cc1 %s -verify
void f1(void) __attribute__((ownership_takes("foo"))); // expected-error {{'ownership_takes' attribute requires parameter 1 to be an identifier}}
void *f2(void) __attribute__((ownership_returns(foo, 1, 2))); // expected-error {{'ownership_returns' attribute takes no more than 1 argument}}
void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
void *f4(void) __attribute__((ownership_returns(foo)));
void f5(void) __attribute__((ownership_holds(foo))); // expected-error {{'ownership_holds' attribute takes at least 2 arguments}}
void f6(void) __attribute__((ownership_holds(foo, 1, 2, 3))); // expected-error {{'ownership_holds' attribute parameter 1 is out of bounds}}
void f7(void) __attribute__((ownership_takes(foo))); // expected-error {{'ownership_takes' attribute takes at least 2 arguments}}
void f8(int *i, int *j, int k) __attribute__((ownership_holds(foo, 1, 2, 4))); // expected-error {{'ownership_holds' attribute parameter 3 is out of bounds}}
int f9 __attribute__((ownership_takes(foo, 1))); // expected-warning {{'ownership_takes' attribute only applies to functions}}
void f10(int i) __attribute__((ownership_holds(foo, 1))); // expected-error {{'ownership_holds' attribute only applies to pointer arguments}}
void *f11(float i) __attribute__((ownership_returns(foo, 1))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
void *f12(float i, int k, int f, int *j) __attribute__((ownership_returns(foo, 4))); // expected-error {{'ownership_returns' attribute only applies to integer arguments}}
void f13(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_takes(foo, 2)));
void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) __attribute__((ownership_takes(foo, 3))); // expected-error {{'ownership_holds' and 'ownership_takes' attributes are not compatible}}
void f15(int, int)
__attribute__((ownership_returns(foo, 1))) // expected-note {{declared with index 1 here}}
__attribute__((ownership_returns(foo, 2))); // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/arm64-neon-args.c
|
// RUN: %clang_cc1 -triple arm64-apple-darwin -target-feature +neon -fsyntax-only -ffreestanding -verify %s
// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -target-feature +neon -fsyntax-only -ffreestanding -verify %s
#include <arm_neon.h>
// rdar://13527900
void vcopy_reject(float32x4_t vOut0, float32x4_t vAlpha, int t) {
vcopyq_laneq_f32(vOut0, 1, vAlpha, t); // expected-error {{argument to '__builtin_neon_vgetq_lane_f32' must be a constant integer}}
}
// rdar://problem/15256199
float32x4_t test_vmlsq_lane(float32x4_t accum, float32x4_t lhs, float32x2_t rhs) {
return vmlsq_lane_f32(accum, lhs, rhs, 1);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-misc.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks
void donotwarn();
int (^IFP) ();
int (^II) (int);
int test1() {
int (^PFR) (int) = 0; // OK
PFR = II; // OK
if (PFR == II) // OK
donotwarn();
if (PFR == IFP) // OK
donotwarn();
if (PFR == (int (^) (int))IFP) // OK
donotwarn();
if (PFR == 0) // OK
donotwarn();
if (PFR) // OK
donotwarn();
if (!PFR) // OK
donotwarn();
return PFR != IFP; // OK
}
int test2(double (^S)()) {
double (^I)(int) = (void*) S;
(void*)I = (void *)S; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
void *pv = I;
pv = S;
I(1);
return (void*)I == (void *)S;
}
int^ x; // expected-error {{block pointer to non-function type is invalid}}
int^^ x1; // expected-error {{block pointer to non-function type is invalid}} expected-error {{block pointer to non-function type is invalid}}
void test3() {
char *^ y; // expected-error {{block pointer to non-function type is invalid}}
}
enum {NSBIRLazilyAllocated = 0};
int test4(int argc) { // rdar://6251437
^{
switch (argc) {
case NSBIRLazilyAllocated: // is an integer constant expression.
default:
break;
}
}();
return 0;
}
void bar(void*);
// rdar://6257721 - reference to static/global is byref by default.
static int test5g;
void test5() {
bar(^{ test5g = 1; });
}
// rdar://6405429 - __func__ in a block refers to the containing function name.
const char*test6() {
return ^{
return __func__;
} ();
}
// radr://6732116 - block comparisons
void (^test7a)();
int test7(void (^p)()) {
return test7a == p;
}
void test8() {
somelabel:
^{ goto somelabel; }(); // expected-error {{use of undeclared label 'somelabel'}}
}
void test9() {
goto somelabel; // expected-error {{use of undeclared label 'somelabel'}}
^{ somelabel: ; }();
}
void test10(int i) {
switch (i) {
case 41: ;
^{ case 42: ; }(); // expected-error {{'case' statement not in switch statement}}
}
}
void test11(int i) {
switch (i) {
case 41: ;
^{ break; }(); // expected-error {{'break' statement not in loop or switch statement}}
}
for (; i < 100; ++i)
^{ break; }(); // expected-error {{'break' statement not in loop or switch statement}}
}
void (^test12f)(void);
void test12() {
test12f = ^test12f; // expected-error {{type name requires a specifier or qualifier}} expected-error {{expected expression}}
}
// rdar://6808730
void *test13 = ^{
int X = 32;
void *P = ^{
return X+4; // References outer block's "X", so outer block is constant.
};
};
void test14() {
int X = 32;
static void *P = ^{ // expected-error {{initializer element is not a compile-time constant}}
void *Q = ^{
// References test14's "X": outer block is non-constant.
return X+4;
};
};
}
enum { LESS };
void foo(long (^comp)()) { // expected-note{{passing argument to parameter 'comp' here}}
}
void (^test15f)(void);
void test15() {
foo(^{ return LESS; }); // expected-error {{incompatible block pointer types passing 'int (^)(void)' to parameter of type 'long (^)()'}}
}
__block int test16i; // expected-error {{__block attribute not allowed, only allowed on local variables}}
void test16(__block int i) { // expected-error {{__block attribute not allowed, only allowed on local variables}}
int size = 5;
extern __block double extern_var; // expected-error {{__block attribute not allowed, only allowed on local variables}}
static __block char * pch; // expected-error {{__block attribute not allowed, only allowed on local variables}}
__block int a[size]; // expected-error {{__block attribute not allowed on declaration with a variably modified type}}
__block int (*ap)[size]; // expected-error {{__block attribute not allowed on declaration with a variably modified type}}
}
void f();
void test17() {
void (^bp)(int);
void (*rp)(int);
void (^bp1)();
void *vp = bp;
f(1 ? bp : vp);
f(1 ? vp : bp);
f(1 ? bp : bp1);
(void)(bp > rp); // expected-error {{invalid operands}}
(void)(bp > 0); // expected-error {{invalid operands}}
(void)(bp > bp); // expected-error {{invalid operands}}
(void)(bp > vp); // expected-error {{invalid operands}}
f(1 ? bp : rp); // expected-error {{incompatible operand types ('void (^)(int)' and 'void (*)(int)')}}
(void)(bp == 1); // expected-error {{invalid operands to binary expression}}
(void)(bp == 0);
(void)(1 == bp); // expected-error {{invalid operands to binary expression}}
(void)(0 == bp);
(void)(bp < 1); // expected-error {{invalid operands to binary expression}}
(void)(bp < 0); // expected-error {{invalid operands to binary expression}}
(void)(1 < bp); // expected-error {{invalid operands to binary expression}}
(void)(0 < bp); // expected-error {{invalid operands to binary expression}}
}
void test18() {
void (^const blockA)(void) = ^{ }; // expected-note {{variable 'blockA' declared const here}}
blockA = ^{ }; // expected-error {{cannot assign to variable 'blockA' with const-qualified type 'void (^const)(void)}}
}
// rdar://7072507
int test19() {
goto L0; // expected-error {{cannot jump}}
__block int x; // expected-note {{jump bypasses setup of __block variable}}
L0:
x = 0;
^(){ ++x; }();
return x;
}
// radr://7438948
void test20() {
int n = 7;
int vla[n]; // expected-note {{declared here}}
int (*vm)[n] = 0; // expected-note {{declared here}}
vla[1] = 4341;
^{
(void)vla[1]; // expected-error {{cannot refer to declaration with a variably modified type inside block}}
(void)(vm+1); // expected-error {{cannot refer to declaration with a variably modified type inside block}}
}();
}
// radr://7438948
void test21() {
int a[7]; // expected-note {{declared here}}
__block int b[10]; // expected-note {{declared here}}
a[1] = 1;
^{
(void)a[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
(void)b[1]; // expected-error {{cannot refer to declaration with an array type inside block}}
}();
}
// rdar ://8218839
const char * (^func)(void) = ^{ return __func__; };
const char * (^function)(void) = ^{ return __FUNCTION__; };
const char * (^pretty)(void) = ^{ return __PRETTY_FUNCTION__; };
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-darwin.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -Wformat-non-iso -DALLOWED %s
// RUN: %clang_cc1 -fsyntax-only -verify -triple thumbv6-apple-ios4.0 -Wformat-non-iso -DALLOWED %s
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-mingw32 -Wformat-non-iso %s
// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-pc-win32 -Wformat-non-iso %s
// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu -Wformat-non-iso %s
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-freebsd -Wformat-non-iso %s
int printf(const char *restrict, ...);
int scanf(const char * restrict, ...) ;
void test() {
int justRight = 1;
long tooLong = 2;
printf("%D", justRight);
printf("%D", tooLong);
printf("%U", justRight);
printf("%U", tooLong);
printf("%O", justRight);
printf("%O", tooLong);
#ifdef ALLOWED
// expected-warning@-8 {{'D' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'd'?}}
// expected-warning@-8 {{'D' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'd'?}} expected-warning@-8 {{format specifies type 'int' but the argument has type 'long'}}
// expected-warning@-8 {{'U' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'u'?}}
// expected-warning@-8 {{'U' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'u'?}} expected-warning@-8 {{format specifies type 'unsigned int' but the argument has type 'long'}}
// expected-warning@-8 {{'O' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'o'?}}
// expected-warning@-8 {{'O' conversion specifier is not supported by ISO C}} expected-note@-8 {{did you mean to use 'o'?}} expected-warning@-8 {{format specifies type 'unsigned int' but the argument has type 'long'}}
#else
// expected-warning@-15 {{invalid conversion specifier 'D'}}
// expected-warning@-15 {{invalid conversion specifier 'D'}}
// expected-warning@-15 {{invalid conversion specifier 'U'}}
// expected-warning@-15 {{invalid conversion specifier 'U'}}
// expected-warning@-15 {{invalid conversion specifier 'O'}}
// expected-warning@-15 {{invalid conversion specifier 'O'}}
#endif
}
#ifdef ALLOWED
void testPrintf(short x, long y) {
printf("%hD", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
printf("%lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
printf("%hU", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
printf("%lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
printf("%hO", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
printf("%lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
printf("%+'0.5lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
printf("% '0.5lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
printf("%#0.5lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
printf("%'0.5lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
}
void testScanf(short *x, long *y) {
scanf("%hD", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
scanf("%lD", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'd'?}}
scanf("%hU", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
scanf("%lU", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'u'?}}
scanf("%hO", x); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
scanf("%lO", y); // expected-warning{{conversion specifier is not supported by ISO C}} expected-note {{did you mean to use 'o'?}}
}
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/heinous-extensions-on.c
|
// RUN: %clang_cc1 %s -verify -fheinous-gnu-extensions
void foo() {
int a;
// PR3788
asm("nop" : : "m"((int)(a))); // expected-warning {{cast in an inline asm context requiring an l-value}}
// PR3794
asm("nop" : "=r"((unsigned)a)); // expected-warning {{cast in an inline asm context requiring an l-value}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/typedef-retain.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -fno-lax-vector-conversions
typedef float float4 __attribute__((vector_size(16)));
typedef int int4 __attribute__((vector_size(16)));
typedef int4* int4p;
void test1(float4 a, int4 *result, int i) {
result[i] = a; // expected-error {{assigning to 'int4' (vector of 4 'int' values) from incompatible type 'float4' (vector of 4 'float' values)}}
}
void test2(float4 a, int4p result, int i) {
result[i] = a; // expected-error {{assigning to 'int4' (vector of 4 'int' values) from incompatible type 'float4' (vector of 4 'float' values)}}
}
// PR2039
typedef int a[5];
void test3() {
typedef const a b;
b r;
r[0]=10; // expected-error {{read-only variable is not assignable}}
}
int test4(const a y) {
y[0] = 10; // expected-error {{read-only variable is not assignable}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/outof-range-constant-compare.c
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wtautological-constant-out-of-range-compare -verify %s
// rdar://12202422
int value(void);
int main()
{
int a = value();
if (a == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (a != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
return 0;
if (a < 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
return 0;
if (a <= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
return 0;
if (a > 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (a >= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (0x1234567812345678L == a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (0x1234567812345678L != a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
return 0;
if (0x1234567812345678L < a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (0x1234567812345678L <= a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (0x1234567812345678L > a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
return 0;
if (0x1234567812345678L >= a) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always true}}
return 0;
if (a == 0x1234567812345678LL) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (a == -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (a < -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (a > -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always true}}
return 0;
if (a <= -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always false}}
return 0;
if (a >= -0x1234567812345678L) // expected-warning {{comparison of constant -1311768465173141112 with expression of type 'int' is always true}}
return 0;
if (a == 0x12345678L) // no warning
return 1;
short s = value();
if (s == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
return 0;
if (s != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
return 0;
if (s < 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
return 0;
if (s <= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
return 0;
if (s > 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
return 0;
if (s >= 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
return 0;
if (0x1234567812345678L == s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
return 0;
if (0x1234567812345678L != s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
return 0;
if (0x1234567812345678L < s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
return 0;
if (0x1234567812345678L <= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
return 0;
if (0x1234567812345678L > s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
return 0;
if (0x1234567812345678L >= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
return 0;
long l = value();
if (l == 0x1234567812345678L)
return 0;
if (l != 0x1234567812345678L)
return 0;
if (l < 0x1234567812345678L)
return 0;
if (l <= 0x1234567812345678L)
return 0;
if (l > 0x1234567812345678L)
return 0;
if (l >= 0x1234567812345678L)
return 0;
if (0x1234567812345678L == l)
return 0;
if (0x1234567812345678L != l)
return 0;
if (0x1234567812345678L < l)
return 0;
if (0x1234567812345678L <= l)
return 0;
if (0x1234567812345678L > l)
return 0;
if (0x1234567812345678L >= l)
return 0;
unsigned un = 0;
if (un == 0x0000000000000000L)
return 0;
if (un != 0x0000000000000000L)
return 0;
if (un < 0x0000000000000000L)
return 0;
if (un <= 0x0000000000000000L)
return 0;
if (un > 0x0000000000000000L)
return 0;
if (un >= 0x0000000000000000L)
return 0;
if (0x0000000000000000L == un)
return 0;
if (0x0000000000000000L != un)
return 0;
if (0x0000000000000000L < un)
return 0;
if (0x0000000000000000L <= un)
return 0;
if (0x0000000000000000L > un)
return 0;
if (0x0000000000000000L >= un)
return 0;
float fl = 0;
if (fl == 0x0000000000000000L) // no warning
return 0;
float dl = 0;
if (dl == 0x0000000000000000L) // no warning
return 0;
enum E {
yes,
no,
maybe
};
enum E e;
if (e == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'enum E' is always false}}
return 0;
return 1;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/tentative-decls.c
|
// RUN: %clang_cc1 %s -fsyntax-only -Wprivate-extern -verify
// PR3310
struct a x1; // expected-note 2{{forward declaration of 'struct a'}}
static struct a x2; // expected-warning{{tentative definition of variable with internal linkage has incomplete non-array type 'struct a'}}
struct a x3[10]; // expected-error{{array has incomplete element type 'struct a'}}
struct a {int x;};
static struct a x2_okay;
struct a x3_okay[10];
struct b x4; // expected-error{{tentative definition has type 'struct b' that is never completed}} \
// expected-note{{forward declaration of 'struct b'}}
const int a [1] = {1};
extern const int a[];
extern const int b[];
const int b [1] = {1};
extern const int c[] = {1}; // expected-warning{{'extern' variable has an initializer}}
const int c[];
int i1 = 1; // expected-note {{previous definition is here}}
int i1 = 2; // expected-error {{redefinition of 'i1'}}
int i1;
int i1;
extern int i5; // expected-note {{previous declaration is here}}
static int i5; // expected-error{{static declaration of 'i5' follows non-static declaration}}
static int i2 = 5; // expected-note 1 {{previous definition is here}}
int i2 = 3; // expected-error{{non-static declaration of 'i2' follows static declaration}}
static int i3 = 5;
extern int i3;
// rdar://7703982
__private_extern__ int pExtern; // expected-warning {{use of __private_extern__ on a declaration may not produce external symbol private to the linkage unit and is deprecated}} \
// expected-note {{use __attribute__((visibility("hidden"))) attribute instead}}
int pExtern = 0;
int i4;
int i4;
extern int i4;
int (*pToArray)[];
int (*pToArray)[8];
int redef[10];
int redef[]; // expected-note {{previous definition is here}}
int redef[11]; // expected-error{{redefinition of 'redef'}}
void func() {
extern int i6; // expected-note {{previous declaration is here}}
static int i6; // expected-error{{static declaration of 'i6' follows non-static declaration}}
}
void func2(void)
{
extern double *p;
extern double *p;
}
// <rdar://problem/6808352>
static int a0[];
static int b0;
static int a0[] = { 4 };
static int b0 = 5;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-pack-apple.c
|
// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
// RUN: %clang_cc1 -fsyntax-only -fapple-pragma-pack %s 2>&1 | FileCheck -check-prefix=CHECK-APPLE %s
#pragma pack(push,1)
#pragma pack(2)
#pragma pack()
#pragma pack(show)
// CHECK: pack(show) == 8
// CHECK-APPLE: pack(show) == 1
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-overlap.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-overlap-compare %s
#define mydefine 2
void f(int x) {
int y = 0;
// > || <
if (x > 2 || x < 1) { }
if (x > 2 || x < 2) { }
if (x != 2 || x != 3) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x > 2 || x < 3) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x > 0 || x < 0) { }
if (x > 2 || x <= 1) { }
if (x > 2 || x <= 2) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x > 2 || x <= 3) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x >= 2 || x < 1) { }
if (x >= 2 || x < 2) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x >= 2 || x < 3) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x >= 2 || x <= 1) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x >= 2 || x <= 2) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x >= 2 || x <= 3) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x >= 0 || x <= 0) { } // expected-warning {{overlapping comparisons always evaluate to true}}
// > && <
if (x > 2 && x < 1) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x > 2 && x < 2) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x > 2 && x < 3) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x > 0 && x < 1) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x > 2 && x <= 1) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x > 2 && x <= 2) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x > 2 && x <= 3) { }
if (x >= 2 && x < 1) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x >= 2 && x < 2) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x >= 2 && x < 3) { }
if (x >= 0 && x < 0) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x >= 2 && x <= 1) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x >= 2 && x <= 2) { }
if (x >= 2 && x <= 3) { }
// !=, ==, ..
if (x != 2 || x != 3) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x != 2 || x < 3) { } // expected-warning {{overlapping comparisons always evaluate to true}}
if (x == 2 && x == 3) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x == 2 && x > 3) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x == 3 && x < 0) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (3 == x && x < 0) { } // expected-warning {{overlapping comparisons always evaluate to false}}
if (x == mydefine && x > 3) { }
if (x == (mydefine + 1) && x > 3) { }
}
// Don't generate a warning here.
void array_out_of_bounds() {
int x;
int buffer[4];
x = (-7 > 0) ? (buffer[-7]) : 0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/builtin-stackaddress.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void* a(unsigned x) {
return __builtin_return_address(0);
}
void b(unsigned x) {
return __builtin_return_address(x); // expected-error{{argument to '__builtin_return_address' must be a constant integer}}
}
void* c(unsigned x) {
return __builtin_frame_address(0);
}
void d(unsigned x) {
return __builtin_frame_address(x); // expected-error{{argument to '__builtin_frame_address' must be a constant integer}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-freestanding-complex.c
|
// RUN: %clang_cc1 -fsyntax-only -ffreestanding -pedantic -verify %s
void foo(float _Complex c) { // expected-warning{{complex numbers are an extension in a freestanding C99 implementation}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/complex-promotion.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
// expected-no-diagnostics
float a;
int b[__builtin_classify_type(a + 1i) == 9 ? 1 : -1];
int c[__builtin_classify_type(1i + a) == 9 ? 1 : -1];
double d;
__typeof__ (d + 1i) e;
int f[sizeof(e) == 2 * sizeof(double) ? 1 : -1];
int g;
int h[__builtin_classify_type(g + 1.0i) == 9 ? 1 : -1];
int i[__builtin_classify_type(1.0i + a) == 9 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-regparm.c
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
__attribute((regparm(2))) int x0(void);
__attribute((regparm(1.0))) int x1(void); // expected-error{{'regparm' attribute requires an integer constant}}
__attribute((regparm(-1))) int x2(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
__attribute((regparm(5))) int x3(void); // expected-error{{'regparm' parameter must be between 0 and 3 inclusive}}
__attribute((regparm(5,3))) int x4(void); // expected-error{{'regparm' attribute takes one argument}}
void __attribute__((regparm(3))) x5(int);
void x5(int); // expected-note{{previous declaration is here}}
void __attribute__((regparm(2))) x5(int); // expected-error{{function declared with regparm(2) attribute was previously declared with the regparm(3) attribute}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/arm-interrupt-attr.c
|
// RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
__attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
__attribute__((interrupt("irq"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
__attribute__((interrupt("IRQ", 1))) void foo2() {} // expected-error {{'interrupt' attribute takes no more than 1 argument}}
__attribute__((interrupt("IRQ"))) void foo3() {}
__attribute__((interrupt("FIQ"))) void foo4() {}
__attribute__((interrupt("SWI"))) void foo5() {}
__attribute__((interrupt("ABORT"))) void foo6() {}
__attribute__((interrupt("UNDEF"))) void foo7() {}
__attribute__((interrupt)) void foo8() {}
__attribute__((interrupt())) void foo9() {}
__attribute__((interrupt(""))) void foo10() {}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/alignas.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=__alignof %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=_Alignof -DUSING_C11_SYNTAX %s
_Alignas(3) int align_illegal; //expected-error {{requested alignment is not a power of 2}}
_Alignas(int) char align_big;
_Alignas(1) int align_small; // expected-error {{requested alignment is less than minimum}}
_Alignas(1) unsigned _Alignas(8) int _Alignas(1) align_multiple;
struct align_member {
_Alignas(8) int member;
_Alignas(1) char bitfield : 1; // expected-error {{'_Alignas' attribute cannot be applied to a bit-field}}
};
typedef _Alignas(8) char align_typedef; // expected-error {{'_Alignas' attribute only applies to variables and fields}}
void f(_Alignas(1) char c) { // expected-error {{'_Alignas' attribute cannot be applied to a function parameter}}
_Alignas(1) register char k; // expected-error {{'_Alignas' attribute cannot be applied to a variable with 'register' storage class}}
}
#ifdef USING_C11_SYNTAX
// expected-warning@+4{{'_Alignof' applied to an expression is a GNU extension}}
// expected-warning@+4{{'_Alignof' applied to an expression is a GNU extension}}
// expected-warning@+4{{'_Alignof' applied to an expression is a GNU extension}}
#endif
_Static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong");
_Static_assert(alignof(align_small) == 1, "j's alignment is wrong");
_Static_assert(alignof(align_multiple) == 8, "l's alignment is wrong");
_Static_assert(alignof(struct align_member) == 8, "quuux's alignment is wrong");
_Static_assert(sizeof(struct align_member) == 8, "quuux's size is wrong");
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/cast.c
|
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown %s -verify
typedef struct { unsigned long bits[(((1) + (64) - 1) / (64))]; } cpumask_t;
cpumask_t x;
void foo() {
(void)x;
}
void bar() {
char* a;
double b;
b = (double)a; // expected-error {{pointer cannot be cast to type}}
a = (char*)b; // expected-error {{cannot be cast to a pointer type}}
}
long bar1(long *next) {
return (long)(*next)++;
}
typedef _Bool Bool;
typedef int Int;
typedef long Long;
typedef float Float;
typedef double Double;
typedef _Complex int CInt;
typedef _Complex long CLong;
typedef _Complex float CFloat;
typedef _Complex double CDouble;
typedef void *VoidPtr;
typedef char *CharPtr;
void testBool(Bool v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
(void) (VoidPtr) v;
(void) (CharPtr) v;
}
void testInt(Int v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
(void) (VoidPtr) v; // expected-warning{{cast to 'VoidPtr' (aka 'void *') from smaller integer type 'Int' (aka 'int')}}
(void) (CharPtr) v; // expected-warning{{cast to 'CharPtr' (aka 'char *') from smaller integer type 'Int' (aka 'int')}}
// Test that casts to void* can be controlled separately
// from other -Wint-to-pointer-cast warnings.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast"
(void) (VoidPtr) v; // no-warning
(void) (CharPtr) v; // expected-warning{{cast to 'CharPtr' (aka 'char *') from smaller integer type 'Int' (aka 'int')}}
#pragma clang diagnostic pop
}
void testLong(Long v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
(void) (VoidPtr) v;
(void) (CharPtr) v;
}
void testFloat(Float v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
}
void testDouble(Double v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
}
void testCI(CInt v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
}
void testCLong(CLong v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
}
void testCFloat(CFloat v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
}
void testCDouble(CDouble v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (Float) v;
(void) (Double) v;
(void) (CInt) v;
(void) (CLong) v;
(void) (CFloat) v;
(void) (CDouble) v;
}
void testVoidPtr(VoidPtr v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (VoidPtr) v;
(void) (CharPtr) v;
}
void testCharPtr(CharPtr v) {
(void) (Bool) v;
(void) (Int) v;
(void) (Long) v;
(void) (VoidPtr) v;
(void) (CharPtr) v;
}
typedef enum { x_a, x_b } X;
void *intToPointerCast2(X x) {
return (void*)x;
}
void *intToPointerCast3() {
return (void*)(1 + 3);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/constant-conversion.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin %s
// This file tests -Wconstant-conversion, a subcategory of -Wconversion
// which is on by default.
// rdar://problem/6792488
void test_6792488(void) {
int x = 0x3ff0000000000000U; // expected-warning {{implicit conversion from 'unsigned long' to 'int' changes value from 4607182418800017408 to 0}}
}
void test_7809123(void) {
struct { int i5 : 5; } a;
a.i5 = 36; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 36 to 4}}
}
void test() {
struct { int bit : 1; } a;
a.bit = 1; // shouldn't warn
}
enum Test2 { K_zero, K_one };
enum Test2 test2(enum Test2 *t) {
*t = 20;
return 10; // shouldn't warn
}
void test3() {
struct A {
unsigned int foo : 2;
int bar : 2;
};
struct A a = { 0, 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}}
struct A b[] = { 0, 10, 0, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to -2}}
struct A c[] = {{10, 0}}; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
struct A d = (struct A) { 10, 0 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
struct A e = { .foo = 10 }; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 10 to 2}}
}
void test4() {
struct A {
char c : 2;
} a;
a.c = 0x101; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 257 to 1}}
}
void test5() {
struct A {
_Bool b : 1;
} a;
// Don't warn about this implicit conversion to bool, or at least
// don't warn about it just because it's a bitfield.
a.b = 100;
}
void test6() {
// Test that unreachable code doesn't trigger the truncation warning.
unsigned char x = 0 ? 65535 : 1; // no-warning
unsigned char y = 1 ? 65535 : 1; // expected-warning {{changes value}}
}
void test7() {
struct {
unsigned int twoBits1:2;
unsigned int twoBits2:2;
unsigned int reserved:28;
} f;
f.twoBits1 = ~1; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -2 to 2}}
f.twoBits2 = ~2; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -3 to 1}}
f.twoBits1 &= ~1; // no-warning
f.twoBits2 &= ~2; // no-warning
}
void test8() {
enum E { A, B, C };
struct { enum E x : 1; } f;
f.x = C; // expected-warning {{implicit truncation from 'int' to bitfield changes value from 2 to 0}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/mips16_attr_not_allowed.c
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
void __attribute__((nomips16)) foo32(); // expected-warning {{unknown attribute 'nomips16' ignored}}
void __attribute__((mips16)) foo16(); // expected-warning {{unknown attribute 'mips16' ignored}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/expr-address-of.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
struct xx { int bitf:1; };
struct entry { struct xx *whatever;
int value;
int bitf:1; };
void add_one(int *p) { (*p)++; }
void test() {
register struct entry *p;
add_one(&p->value);
struct entry pvalue;
add_one(&p->bitf); // expected-error {{address of bit-field requested}}
add_one(&pvalue.bitf); // expected-error {{address of bit-field requested}}
add_one(&p->whatever->bitf); // expected-error {{address of bit-field requested}}
}
void foo() {
register int x[10];
&x[10]; // expected-error {{address of register variable requested}}
register int *y;
int *x2 = &y; // expected-error {{address of register variable requested}}
int *x3 = &y[10];
}
void testVectorComponentAccess() {
typedef float v4sf __attribute__ ((vector_size (16)));
static v4sf q;
float* r = &q[0]; // expected-error {{address of vector element requested}}
}
typedef __attribute__(( ext_vector_type(4) )) float float4;
float *testExtVectorComponentAccess(float4 x) {
return &x.w; // expected-error {{address of vector element requested}}
}
void f0() {
register int *x0;
int *_dummy0 = &(*x0);
register int *x1;
int *_dummy1 = &(*(x1 + 1));
}
// FIXME: The checks for this function are broken; we should error
// on promoting a register array to a pointer! (C99 6.3.2.1p3)
void f1() {
register int x0[10];
int *_dummy00 = x0; // fixme-error {{address of register variable requested}}
int *_dummy01 = &(*x0); // fixme-error {{address of register variable requested}}
register int x1[10];
int *_dummy1 = &(*(x1 + 1)); // fixme-error {{address of register variable requested}}
register int *x2;
int *_dummy2 = &(*(x2 + 1));
register int x3[10][10][10];
int (*_dummy3)[10] = &x3[0][0]; // expected-error {{address of register variable requested}}
register struct { int f0[10]; } x4;
int *_dummy4 = &x4.f0[2]; // expected-error {{address of register variable requested}}
}
void f2() {
register int *y;
int *_dummy0 = &y; // expected-error {{address of register variable requested}}
int *_dummy1 = &y[10];
}
void f3() {
extern void f4();
void (*_dummy0)() = &****f4;
}
void f4() {
register _Complex int x;
int *_dummy0 = &__real__ x; // expected-error {{address of register variable requested}}
}
void f5() {
register int arr[2];
/* This is just here because if we happened to support this as an
lvalue we would need to give a warning. Note that gcc warns about
this as a register before it warns about it as an invalid
lvalue. */
int *_dummy0 = &(int*) arr; // expected-error {{cannot take the address of an rvalue}}
int *_dummy1 = &(arr + 1); // expected-error {{cannot take the address of an rvalue}}
}
void f6(register int x) {
int * dummy0 = &x; // expected-error {{address of register variable requested}}
}
char* f7() {
register struct {char* x;} t1 = {"Hello"};
char* dummy1 = &(t1.x[0]);
struct {int a : 10;} t2;
int* dummy2 = &(t2.a); // expected-error {{address of bit-field requested}}
void* t3 = &(*(void*)0);
}
void f8() {
void *dummy0 = &f8(); // expected-error {{cannot take the address of an rvalue of type 'void'}}
extern void v;
void *dummy1 = &(1 ? v : f8()); // expected-error {{cannot take the address of an rvalue of type 'void'}}
void *dummy2 = &(f8(), v); // expected-error {{cannot take the address of an rvalue of type 'void'}}
void *dummy3 = &({ ; }); // expected-error {{cannot take the address of an rvalue of type 'void'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/incomplete-decl.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct foo; // expected-note 5 {{forward declaration of 'struct foo'}}
void b; // expected-error {{variable has incomplete type 'void'}}
struct foo f; // expected-error{{tentative definition has type 'struct foo' that is never completed}}
static void c; // expected-error {{variable has incomplete type 'void'}}
static struct foo g; // expected-warning {{tentative definition of variable with internal linkage has incomplete non-array type 'struct foo'}} \
expected-error{{tentative definition has type 'struct foo' that is never completed}}
extern void d;
extern struct foo e;
int ary[]; // expected-warning {{tentative array definition assumed to have one element}}
struct foo bary[]; // expected-error {{array has incomplete element type 'struct foo'}}
void func() {
int ary[]; // expected-error{{definition of variable with array type needs an explicit size or an initializer}}
void b; // expected-error {{variable has incomplete type 'void'}}
struct foo f; // expected-error {{variable has incomplete type 'struct foo'}}
}
int h[]; // expected-warning {{tentative array definition assumed to have one element}}
int (*i)[] = &h+1; // expected-error {{arithmetic on a pointer to an incomplete type 'int []'}}
struct bar j = {1}; // expected-error {{variable has incomplete type 'struct bar'}} \
expected-note {{forward declaration of 'struct bar'}}
struct bar k;
struct bar { int a; };
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-unsequenced.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Wno-unused %s
int f(int, int);
typedef struct A {
int x, y;
} A;
void test() {
int a;
int xs[10];
a + ++a; // expected-warning {{unsequenced modification and access to 'a'}}
a = ++a; // expected-warning {{multiple unsequenced modifications to 'a'}}
a + a++; // expected-warning {{unsequenced modification and access to 'a'}}
a = a++; // expected-warning {{multiple unsequenced modifications to 'a'}}
(a++, a++); // ok
++a + ++a; // expected-warning {{multiple unsequenced modifications}}
a++ + a++; // expected-warning {{multiple unsequenced modifications}}
a = xs[++a]; // expected-warning {{multiple unsequenced modifications}}
a = xs[a++]; // expected-warning {{multiple unsequenced modifications}}
a = (++a, ++a); // expected-warning {{multiple unsequenced modifications}}
a = (a++, ++a); // expected-warning {{multiple unsequenced modifications}}
a = (a++, a++); // expected-warning {{multiple unsequenced modifications}}
f(a, a); // ok
f(a = 0, a); // expected-warning {{unsequenced modification and access}}
f(a, a += 0); // expected-warning {{unsequenced modification and access}}
f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications}}
a = f(++a, 0); // ok
a = f(a++, 0); // ok
a = f(++a, a++); // expected-warning {{multiple unsequenced modifications}}
++a + f(++a, 0); // expected-warning {{multiple unsequenced modifications}}
f(++a, 0) + ++a; // expected-warning {{multiple unsequenced modifications}}
a++ + f(a++, 0); // expected-warning {{multiple unsequenced modifications}}
f(a++, 0) + a++; // expected-warning {{multiple unsequenced modifications}}
a = ++a; // expected-warning {{multiple unsequenced modifications}}
a += ++a; // expected-warning {{unsequenced modification and access}}
A agg1 = { a++, a++ }; // expected-warning {{multiple unsequenced modifications}}
A agg2 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access}}
(xs[2] && (a = 0)) + a; // ok
(0 && (a = 0)) + a; // ok
(1 && (a = 0)) + a; // expected-warning {{unsequenced modification and access}}
(xs[3] || (a = 0)) + a; // ok
(0 || (a = 0)) + a; // expected-warning {{unsequenced modification and access}}
(1 || (a = 0)) + a; // ok
(xs[4] ? a : ++a) + a; // ok
(0 ? a : ++a) + a; // expected-warning {{unsequenced modification and access}}
(1 ? a : ++a) + a; // ok
(xs[5] ? ++a : ++a) + a; // FIXME: warn here
(++a, xs[6] ? ++a : 0) + a; // expected-warning {{unsequenced modification and access}}
// Here, the read of the fourth 'a' might happen before or after the write to
// the second 'a'.
a += (a++, a) + a; // expected-warning {{unsequenced modification and access}}
int *p = xs;
a = *(a++, p); // ok
a = a++ && a; // ok
A *q = &agg1;
(q = &agg2)->y = q->x; // expected-warning {{unsequenced modification and access to 'q'}}
// This has undefined behavior if a == 0; otherwise, the side-effect of the
// increment is sequenced before the value computation of 'f(a, a)', which is
// sequenced before the value computation of the '&&', which is sequenced
// before the assignment. We treat the sequencing in '&&' as being
// unconditional.
a = a++ && f(a, a);
// This has undefined behavior if a != 0. FIXME: We should diagnose this.
(a && a++) + a;
(xs[7] && ++a) * (!xs[7] && ++a); // ok
xs[0] = (a = 1, a); // ok
xs[8] ? ++a + a++ : 0; // expected-warning {{multiple unsequenced modifications}}
xs[8] ? 0 : ++a + a++; // expected-warning {{multiple unsequenced modifications}}
xs[8] ? ++a : a++; // ok
xs[8] && (++a + a++); // expected-warning {{multiple unsequenced modifications}}
xs[8] || (++a + a++); // expected-warning {{multiple unsequenced modifications}}
(__builtin_classify_type(++a) ? 1 : 0) + ++a; // ok
(__builtin_constant_p(++a) ? 1 : 0) + ++a; // ok
(__builtin_expect(++a, 0) ? 1 : 0) + ++a; // expected-warning {{multiple unsequenced modifications}}
_Generic(++a, default: 0) + ++a; // ok
sizeof(++a) + ++a; // ok
_Alignof(++a) + ++a; // expected-warning {{extension}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-string-conversion.c
|
// RUN: %clang_cc1 -verify -fsyntax-only -Wstring-conversion %s
void do_nothing();
void assert_error();
#define assert1(expr) \
if (expr) \
do_nothing(); \
else \
assert_error()
#define assert2(expr) \
((expr) ? do_nothing() : assert_error())
// Expection for common assert form.
void test1() {
assert1(0 && "foo");
assert1("foo" && 0);
assert1(0 || "foo"); // expected-warning {{string literal}}
assert1("foo"); // expected-warning {{string literal}}
assert2(0 && "foo");
assert2("foo" && 0);
assert2(0 || "foo"); // expected-warning {{string literal}}
assert2("foo"); // expected-warning {{string literal}}
}
void test2() {
if ("hi") {} // expected-warning {{string literal}}
while ("hello") {} // expected-warning {{string literal}}
for (;"howdy";) {} // expected-warning {{string literal}}
do { } while ("hey"); // expected-warning {{string literal}}
int x = "hey" ? 1 : 2; // expected-warning {{string literal}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/indirect-goto.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct c {int x;};
int a(struct c x, long long y) {
void const* l1_ptr = &&l1;
goto *l1_ptr;
l1:
goto *x; // expected-error{{incompatible type}}
goto *y; // expected-warning{{incompatible integer to pointer conversion}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/zvector.c
|
// RUN: %clang_cc1 -triple s390x-linux-gnu -fzvector \
// RUN: -fno-lax-vector-conversions -W -Wall -Wconversion \
// RUN: -Werror -fsyntax-only -verify %s
vector signed char sc, sc2;
vector unsigned char uc, uc2;
vector bool char bc, bc2;
vector signed short ss, ss2;
vector unsigned short us, us2;
vector bool short bs, bs2;
vector signed int si, si2;
vector unsigned int ui, ui2;
vector bool int bi, bi2;
vector signed long long sl, sl2;
vector unsigned long long ul, ul2;
vector bool long long bl, bl2;
vector double fd, fd2;
vector long ll; // expected-error {{cannot use 'long' with '__vector'}}
vector float ff; // expected-error {{cannot use 'float' with '__vector'}}
signed char sc_scalar;
unsigned char uc_scalar;
signed short ss_scalar;
unsigned short us_scalar;
signed int si_scalar;
unsigned int ui_scalar;
signed long sl_scalar;
unsigned long ul_scalar;
double fd_scalar;
void foo(void)
{
// -------------------------------------------------------------------------
// Test assignment.
// -------------------------------------------------------------------------
sc = sc2;
uc = uc2;
bc = bc2;
ss = ss2;
us = us2;
bs = bs2;
si = si2;
ui = ui2;
bi = bi2;
sl = sl2;
ul = ul2;
bl = bl2;
fd = fd2;
sc = uc2; // expected-error {{incompatible type}}
sc = bc2; // expected-error {{incompatible type}}
uc = sc2; // expected-error {{incompatible type}}
uc = bc2; // expected-error {{incompatible type}}
bc = sc2; // expected-error {{incompatible type}}
bc = uc2; // expected-error {{incompatible type}}
sc = sc_scalar; // expected-error {{incompatible type}}
sc = uc_scalar; // expected-error {{incompatible type}}
uc = sc_scalar; // expected-error {{incompatible type}}
uc = uc_scalar; // expected-error {{incompatible type}}
bc = sc_scalar; // expected-error {{incompatible type}}
bc = uc_scalar; // expected-error {{incompatible type}}
sc = ss2; // expected-error {{incompatible type}}
sc = si2; // expected-error {{incompatible type}}
sc = sl2; // expected-error {{incompatible type}}
sc = fd2; // expected-error {{incompatible type}}
ss = sc2; // expected-error {{incompatible type}}
si = sc2; // expected-error {{incompatible type}}
sl = sc2; // expected-error {{incompatible type}}
fd = sc2; // expected-error {{incompatible type}}
uc = us2; // expected-error {{incompatible type}}
uc = ui2; // expected-error {{incompatible type}}
uc = ul2; // expected-error {{incompatible type}}
uc = fd2; // expected-error {{incompatible type}}
us = uc2; // expected-error {{incompatible type}}
ui = uc2; // expected-error {{incompatible type}}
ul = uc2; // expected-error {{incompatible type}}
fd = uc2; // expected-error {{incompatible type}}
bc = us2; // expected-error {{incompatible type}}
bc = ui2; // expected-error {{incompatible type}}
bc = ul2; // expected-error {{incompatible type}}
bc = fd2; // expected-error {{incompatible type}}
bs = bc2; // expected-error {{incompatible type}}
bi = bc2; // expected-error {{incompatible type}}
bl = bc2; // expected-error {{incompatible type}}
fd = bc2; // expected-error {{incompatible type}}
// -------------------------------------------------------------------------
// Test casts to same element width.
// -------------------------------------------------------------------------
sc = (vector signed char)bc2;
bc = (vector bool char)uc2;
uc = (vector unsigned char)sc2;
ss = (vector signed short)bs2;
bs = (vector bool short)us2;
us = (vector unsigned short)ss2;
si = (vector signed int)bi2;
bi = (vector bool int)ui2;
ui = (vector unsigned int)si2;
sl = (vector signed long long)bl2;
bl = (vector bool long long)ul2;
ul = (vector unsigned long long)fd2;
fd = (vector double)sl2;
// -------------------------------------------------------------------------
// Test casts to different element width.
// -------------------------------------------------------------------------
sc = (vector signed char)bs2;
bc = (vector bool char)us2;
uc = (vector unsigned char)fd2;
ss = (vector signed short)bi2;
bs = (vector bool short)ui2;
us = (vector unsigned short)fd2;
si = (vector signed int)bl2;
bi = (vector bool int)ul2;
ui = (vector unsigned int)fd2;
sl = (vector signed long long)bc2;
bl = (vector bool long long)uc2;
ul = (vector unsigned long long)sc2;
fd = (vector double)sc2;
// -------------------------------------------------------------------------
// Test ++.
// -------------------------------------------------------------------------
++sc2;
++uc2;
++bc2; // expected-error {{cannot increment}}
++ss2;
++us2;
++bs2; // expected-error {{cannot increment}}
++si2;
++ui2;
++bi2; // expected-error {{cannot increment}}
++sl2;
++ul2;
++bl2; // expected-error {{cannot increment}}
++fd2;
sc++;
uc++;
bc++; // expected-error {{cannot increment}}
ss++;
us++;
bs++; // expected-error {{cannot increment}}
si++;
ui++;
bi++; // expected-error {{cannot increment}}
sl++;
ul++;
bl++; // expected-error {{cannot increment}}
fd++;
// -------------------------------------------------------------------------
// Test --.
// -------------------------------------------------------------------------
--sc2;
--uc2;
--bc2; // expected-error {{cannot decrement}}
--ss2;
--us2;
--bs2; // expected-error {{cannot decrement}}
--si2;
--ui2;
--bi2; // expected-error {{cannot decrement}}
--sl2;
--ul2;
--bl2; // expected-error {{cannot decrement}}
--fd2;
sc--;
uc--;
bc--; // expected-error {{cannot decrement}}
ss--;
us--;
bs--; // expected-error {{cannot decrement}}
si--;
ui--;
bi--; // expected-error {{cannot decrement}}
sl--;
ul--;
bl--; // expected-error {{cannot decrement}}
fd--;
// -------------------------------------------------------------------------
// Test unary +.
// -------------------------------------------------------------------------
sc = +sc2;
uc = +uc2;
bc = +bc2; // expected-error {{invalid argument type}}
ss = +ss2;
us = +us2;
bs = +bs2; // expected-error {{invalid argument type}}
si = +si2;
ui = +ui2;
bi = +bi2; // expected-error {{invalid argument type}}
sl = +sl2;
ul = +ul2;
bl = +bl2; // expected-error {{invalid argument type}}
fd = +fd2;
sc = +si2; // expected-error {{assigning to}}
ui = +si2; // expected-error {{assigning to}}
ui = +bi2; // expected-error {{invalid argument type}}
// -------------------------------------------------------------------------
// Test unary -.
// -------------------------------------------------------------------------
sc = -sc2;
uc = -uc2;
bc = -bc2; // expected-error {{invalid argument type}}
ss = -ss2;
us = -us2;
bs = -bs2; // expected-error {{invalid argument type}}
si = -si2;
ui = -ui2;
bi = -bi2; // expected-error {{invalid argument type}}
sl = -sl2;
ul = -ul2;
bl = -bl2; // expected-error {{invalid argument type}}
fd = -fd2;
sc = -si2; // expected-error {{assigning to}}
ui = -si2; // expected-error {{assigning to}}
ui = -bi2; // expected-error {{invalid argument type}}
// -------------------------------------------------------------------------
// Test ~.
// -------------------------------------------------------------------------
sc = ~sc2;
uc = ~uc2;
bc = ~bc2;
ss = ~ss2;
us = ~us2;
bs = ~bs2;
si = ~si2;
ui = ~ui2;
bi = ~bi2;
sl = ~sl2;
ul = ~ul2;
bl = ~bl2;
fd = ~fd2; // expected-error {{invalid argument}}
sc = ~si2; // expected-error {{assigning to}}
ui = ~si2; // expected-error {{assigning to}}
ui = ~bi2; // expected-error {{assigning to}}
// -------------------------------------------------------------------------
// Test binary +.
// -------------------------------------------------------------------------
sc = sc + sc2;
sc = sc + uc2; // expected-error {{can't convert}}
sc = uc + sc2; // expected-error {{can't convert}}
sc = sc + bc2;
sc = bc + sc2;
uc = uc + uc2;
uc = sc + uc2; // expected-error {{can't convert}}
uc = uc + sc2; // expected-error {{can't convert}}
uc = bc + uc2;
uc = uc + bc2;
bc = bc + bc2; // expected-error {{invalid operands}}
bc = bc + uc2; // expected-error {{incompatible type}}
bc = uc + bc2; // expected-error {{incompatible type}}
bc = bc + sc2; // expected-error {{incompatible type}}
bc = sc + bc2; // expected-error {{incompatible type}}
sc = sc + sc_scalar; // expected-error {{can't convert}}
sc = sc + uc_scalar; // expected-error {{can't convert}}
sc = sc_scalar + sc; // expected-error {{can't convert}}
sc = uc_scalar + sc; // expected-error {{can't convert}}
uc = uc + sc_scalar; // expected-error {{can't convert}}
uc = uc + uc_scalar; // expected-error {{can't convert}}
uc = sc_scalar + uc; // expected-error {{can't convert}}
uc = uc_scalar + uc; // expected-error {{can't convert}}
ss = ss + ss2;
us = us + us2;
bs = bs + bs2; // expected-error {{invalid operands}}
si = si + si2;
ui = ui + ui2;
bi = bi + bi2; // expected-error {{invalid operands}}
sl = sl + sl2;
ul = ul + ul2;
bl = bl + bl2; // expected-error {{invalid operands}}
fd = fd + fd2;
fd = fd + ul2; // expected-error {{can't convert}}
fd = sl + fd2; // expected-error {{can't convert}}
sc += sc2;
sc += uc2; // expected-error {{can't convert}}
sc += bc2;
uc += uc2;
uc += sc2; // expected-error {{can't convert}}
uc += bc2;
bc += bc2; // expected-error {{invalid operands}}
bc += sc2; // expected-error {{can't convert}}
bc += uc2; // expected-error {{can't convert}}
sc += ss2; // expected-error {{can't convert}}
sc += si2; // expected-error {{can't convert}}
sc += sl2; // expected-error {{can't convert}}
sc += fd2; // expected-error {{can't convert}}
sc += sc_scalar; // expected-error {{can't convert}}
sc += uc_scalar; // expected-error {{can't convert}}
uc += sc_scalar; // expected-error {{can't convert}}
uc += uc_scalar; // expected-error {{can't convert}}
ss += ss2;
us += us2;
bs += bs2; // expected-error {{invalid operands}}
si += si2;
ui += ui2;
bi += bi2; // expected-error {{invalid operands}}
sl += sl2;
ul += ul2;
bl += bl2; // expected-error {{invalid operands}}
fd += fd2;
// -------------------------------------------------------------------------
// Test that binary + rules apply to binary - too.
// -------------------------------------------------------------------------
sc = sc - sc2;
uc = uc - uc2;
bc = bc - bc2; // expected-error {{invalid operands}}
sc = uc - sc2; // expected-error {{can't convert}}
sc = sc - bc2;
uc = bc - uc2;
sc -= sc2;
uc -= uc2;
bc -= bc2; // expected-error {{invalid operands}}
sc -= uc2; // expected-error {{can't convert}}
uc -= bc2;
bc -= sc2; // expected-error {{can't convert}}
ss -= ss2;
us -= us2;
bs -= bs2; // expected-error {{invalid operands}}
si -= si2;
ui -= ui2;
bi -= bi2; // expected-error {{invalid operands}}
sl -= sl2;
ul -= ul2;
bl -= bl2; // expected-error {{invalid operands}}
fd -= fd2;
// -------------------------------------------------------------------------
// Test that binary + rules apply to * too. 64-bit integer multiplication
// is not required by the spec and so isn't tested here.
// -------------------------------------------------------------------------
sc = sc * sc2;
uc = uc * uc2;
bc = bc * bc2; // expected-error {{invalid operands}}
sc = uc * sc2; // expected-error {{can't convert}}
sc = sc * bc2; // expected-error {{can't convert}}
uc = bc * uc2; // expected-error {{can't convert}}
sc *= sc2;
uc *= uc2;
bc *= bc2; // expected-error {{invalid operands}}
sc *= uc2; // expected-error {{can't convert}}
uc *= bc2; // expected-error {{can't convert}}
bc *= sc2; // expected-error {{can't convert}}
ss *= ss2;
us *= us2;
bs *= bs2; // expected-error {{invalid operands}}
si *= si2;
ui *= ui2;
bi *= bi2; // expected-error {{invalid operands}}
sl *= sl2;
ul *= ul2;
bl *= bl2; // expected-error {{invalid operands}}
fd *= fd2;
// -------------------------------------------------------------------------
// Test that * rules apply to / too.
// -------------------------------------------------------------------------
sc = sc / sc2;
uc = uc / uc2;
bc = bc / bc2; // expected-error {{invalid operands}}
sc = uc / sc2; // expected-error {{can't convert}}
sc = sc / bc2; // expected-error {{can't convert}}
uc = bc / uc2; // expected-error {{can't convert}}
sc /= sc2;
uc /= uc2;
bc /= bc2; // expected-error {{invalid operands}}
sc /= uc2; // expected-error {{can't convert}}
uc /= bc2; // expected-error {{can't convert}}
bc /= sc2; // expected-error {{can't convert}}
ss /= ss2;
us /= us2;
bs /= bs2; // expected-error {{invalid operands}}
si /= si2;
ui /= ui2;
bi /= bi2; // expected-error {{invalid operands}}
sl /= sl2;
ul /= ul2;
bl /= bl2; // expected-error {{invalid operands}}
fd /= fd2;
// -------------------------------------------------------------------------
// Test that / rules apply to % too, except that doubles are not allowed.
// -------------------------------------------------------------------------
sc = sc % sc2;
uc = uc % uc2;
bc = bc % bc2; // expected-error {{invalid operands}}
sc = uc % sc2; // expected-error {{can't convert}}
sc = sc % bc2; // expected-error {{can't convert}}
uc = bc % uc2; // expected-error {{can't convert}}
sc %= sc2;
uc %= uc2;
bc %= bc2; // expected-error {{invalid operands}}
sc %= uc2; // expected-error {{can't convert}}
uc %= bc2; // expected-error {{can't convert}}
bc %= sc2; // expected-error {{can't convert}}
ss %= ss2;
us %= us2;
bs %= bs2; // expected-error {{invalid operands}}
si %= si2;
ui %= ui2;
bi %= bi2; // expected-error {{invalid operands}}
sl %= sl2;
ul %= ul2;
bl %= bl2; // expected-error {{invalid operands}}
fd %= fd2; // expected-error {{invalid operands}}
// -------------------------------------------------------------------------
// Test &.
// -------------------------------------------------------------------------
sc = sc & sc2;
sc = sc & uc2; // expected-error {{can't convert}}
sc = uc & sc2; // expected-error {{can't convert}}
sc = sc & bc2;
sc = bc & sc2;
uc = uc & uc2;
uc = sc & uc2; // expected-error {{can't convert}}
uc = uc & sc2; // expected-error {{can't convert}}
uc = bc & uc2;
uc = uc & bc2;
bc = bc & bc2;
bc = bc & uc2; // expected-error {{incompatible type}}
bc = uc & bc2; // expected-error {{incompatible type}}
bc = bc & sc2; // expected-error {{incompatible type}}
bc = sc & bc2; // expected-error {{incompatible type}}
fd = fd & fd2; // expected-error {{invalid operands}}
fd = bl & fd2; // expected-error {{invalid operands}}
fd = fd & bl2; // expected-error {{invalid operands}}
fd = fd & sl2; // expected-error {{invalid operands}}
fd = fd & ul2; // expected-error {{invalid operands}}
sc &= sc2;
sc &= uc2; // expected-error {{can't convert}}
sc &= bc2;
uc &= uc2;
uc &= sc2; // expected-error {{can't convert}}
uc &= bc2;
bc &= bc2;
bc &= sc2; // expected-error {{can't convert}}
bc &= uc2; // expected-error {{can't convert}}
sc &= ss2; // expected-error {{can't convert}}
sc &= si2; // expected-error {{can't convert}}
sc &= sl2; // expected-error {{can't convert}}
sc &= fd2; // expected-error {{invalid operands}}
us &= bc2; // expected-error {{can't convert}}
ui &= bc2; // expected-error {{can't convert}}
ul &= bc2; // expected-error {{can't convert}}
fd &= bc2; // expected-error {{invalid operands}}
ss &= ss2;
us &= us2;
bs &= bs2;
si &= si2;
ui &= ui2;
bi &= bi2;
sl &= sl2;
ul &= ul2;
bl &= bl2;
// -------------------------------------------------------------------------
// Test that & rules apply to | too.
// -------------------------------------------------------------------------
sc = sc | sc2;
sc = sc | uc2; // expected-error {{can't convert}}
sc = sc | bc2;
uc = uc | uc2;
uc = sc | uc2; // expected-error {{can't convert}}
uc = bc | uc2;
bc = bc | bc2;
bc = uc | bc2; // expected-error {{incompatible type}}
bc = bc | sc2; // expected-error {{incompatible type}}
fd = fd | fd2; // expected-error {{invalid operands}}
fd = bl | fd2; // expected-error {{invalid operands}}
ss |= ss2;
us |= us2;
bs |= bs2;
si |= si2;
ui |= ui2;
bi |= bi2;
sl |= sl2;
ul |= ul2;
bl |= bl2;
fd |= bl2; // expected-error {{invalid operands}}
fd |= fd2; // expected-error {{invalid operands}}
// -------------------------------------------------------------------------
// Test that & rules apply to ^ too.
// -------------------------------------------------------------------------
sc = sc ^ sc2;
sc = sc ^ uc2; // expected-error {{can't convert}}
sc = sc ^ bc2;
uc = uc ^ uc2;
uc = sc ^ uc2; // expected-error {{can't convert}}
uc = bc ^ uc2;
bc = bc ^ bc2;
bc = uc ^ bc2; // expected-error {{incompatible type}}
bc = bc ^ sc2; // expected-error {{incompatible type}}
fd = fd ^ fd2; // expected-error {{invalid operands}}
fd = bl ^ fd2; // expected-error {{invalid operands}}
ss ^= ss2;
us ^= us2;
bs ^= bs2;
si ^= si2;
ui ^= ui2;
bi ^= bi2;
sl ^= sl2;
ul ^= ul2;
bl ^= bl2;
fd ^= bl2; // expected-error {{invalid operands}}
fd ^= fd2; // expected-error {{invalid operands}}
// -------------------------------------------------------------------------
// Test <<.
// -------------------------------------------------------------------------
sc = sc << sc2;
sc = sc << uc2;
sc = uc << sc2; // expected-error {{incompatible type}}
sc = sc << bc2; // expected-error {{invalid operands}}
sc = bc << sc2; // expected-error {{invalid operands}}
uc = uc << uc2;
uc = sc << uc2; // expected-error {{assigning to}}
uc = uc << sc2;
uc = bc << uc2; // expected-error {{invalid operands}}
uc = uc << bc2; // expected-error {{invalid operands}}
bc = bc << bc2; // expected-error {{invalid operands}}
bc = bc << uc2; // expected-error {{invalid operands}}
bc = uc << bc2; // expected-error {{invalid operands}}
bc = bc << sc2; // expected-error {{invalid operands}}
bc = sc << bc2; // expected-error {{invalid operands}}
sc = sc << 1;
sc = sc << 1.0f; // expected-error {{integer is required}}
sc = sc << sc_scalar;
sc = sc << uc_scalar;
sc = sc << ss_scalar;
sc = sc << us_scalar;
sc = sc << si_scalar;
sc = sc << ui_scalar;
sc = sc << sl_scalar;
sc = sc << ul_scalar;
sc = sc_scalar << sc; // expected-error {{first operand is not a vector}}
sc = uc_scalar << sc; // expected-error {{first operand is not a vector}}
uc = uc << sc_scalar;
uc = uc << uc_scalar;
uc = sc_scalar << uc; // expected-error {{first operand is not a vector}}
uc = uc_scalar << uc; // expected-error {{first operand is not a vector}}
ss = ss << ss2;
ss = ss << ss_scalar;
us = us << us2;
us = us << us_scalar;
bs = bs << bs2; // expected-error {{invalid operands}}
si = si << si2;
si = si << si_scalar;
ui = ui << ui2;
ui = ui << ui_scalar;
bi = bi << bi2; // expected-error {{invalid operands}}
sl = sl << sl2;
sl = sl << sl_scalar;
ul = ul << ul2;
ul = ul << ul_scalar;
bl = bl << bl2; // expected-error {{invalid operands}}
fd = fd << fd2; // expected-error {{integer is required}}
fd = fd << ul2; // expected-error {{integer is required}}
fd = sl << fd2; // expected-error {{integer is required}}
sc <<= sc2;
sc <<= uc2;
sc <<= bc2; // expected-error {{invalid operands}}
sc <<= sc_scalar;
uc <<= uc2;
uc <<= sc2;
uc <<= bc2; // expected-error {{invalid operands}}
uc <<= uc_scalar;
bc <<= bc2; // expected-error {{invalid operands}}
bc <<= sc2; // expected-error {{invalid operands}}
bc <<= uc2; // expected-error {{invalid operands}}
sc <<= ss2; // expected-error {{vector operands do not have the same number of elements}}
sc <<= si2; // expected-error {{vector operands do not have the same number of elements}}
sc <<= sl2; // expected-error {{vector operands do not have the same number of elements}}
sc <<= fd2; // expected-error {{integer is required}}
ss <<= ss2;
ss <<= ss_scalar;
us <<= us2;
us <<= us_scalar;
bs <<= bs2; // expected-error {{invalid operands}}
si <<= si2;
si <<= si_scalar;
ui <<= ui2;
ui <<= ui_scalar;
bi <<= bi2; // expected-error {{invalid operands}}
sl <<= sl2;
sl <<= sl_scalar;
ul <<= ul2;
ul <<= ul_scalar;
bl <<= bl2; // expected-error {{invalid operands}}
fd <<= fd2; // expected-error {{integer is required}}
// -------------------------------------------------------------------------
// Test >>.
// -------------------------------------------------------------------------
sc = sc >> sc2;
sc = sc >> uc2;
sc = uc >> sc2; // expected-error {{incompatible type}}
sc = sc >> bc2; // expected-error {{invalid operands}}
sc = bc >> sc2; // expected-error {{invalid operands}}
uc = uc >> uc2;
uc = sc >> uc2; // expected-error {{assigning to}}
uc = uc >> sc2;
uc = bc >> uc2; // expected-error {{invalid operands}}
uc = uc >> bc2; // expected-error {{invalid operands}}
bc = bc >> bc2; // expected-error {{invalid operands}}
bc = bc >> uc2; // expected-error {{invalid operands}}
bc = uc >> bc2; // expected-error {{invalid operands}}
bc = bc >> sc2; // expected-error {{invalid operands}}
bc = sc >> bc2; // expected-error {{invalid operands}}
sc = sc >> 1;
sc = sc >> 1.0f; // expected-error {{integer is required}}
sc = sc >> sc_scalar;
sc = sc >> uc_scalar;
sc = sc >> ss_scalar;
sc = sc >> us_scalar;
sc = sc >> si_scalar;
sc = sc >> ui_scalar;
sc = sc >> sl_scalar;
sc = sc >> ul_scalar;
sc = sc_scalar >> sc; // expected-error {{first operand is not a vector}}
sc = uc_scalar >> sc; // expected-error {{first operand is not a vector}}
uc = uc >> sc_scalar;
uc = uc >> uc_scalar;
uc = sc_scalar >> uc; // expected-error {{first operand is not a vector}}
uc = uc_scalar >> uc; // expected-error {{first operand is not a vector}}
ss = ss >> ss2;
ss = ss >> ss_scalar;
us = us >> us2;
us = us >> us_scalar;
bs = bs >> bs2; // expected-error {{invalid operands}}
si = si >> si2;
si = si >> si_scalar;
ui = ui >> ui2;
ui = ui >> ui_scalar;
bi = bi >> bi2; // expected-error {{invalid operands}}
sl = sl >> sl2;
sl = sl >> sl_scalar;
ul = ul >> ul2;
ul = ul >> ul_scalar;
bl = bl >> bl2; // expected-error {{invalid operands}}
fd = fd >> fd2; // expected-error {{integer is required}}
fd = fd >> ul2; // expected-error {{integer is required}}
fd = sl >> fd2; // expected-error {{integer is required}}
sc >>= sc2;
sc >>= uc2;
sc >>= bc2; // expected-error {{invalid operands}}
sc >>= sc_scalar;
uc >>= uc2;
uc >>= sc2;
uc >>= bc2; // expected-error {{invalid operands}}
uc >>= uc_scalar;
bc >>= bc2; // expected-error {{invalid operands}}
bc >>= sc2; // expected-error {{invalid operands}}
bc >>= uc2; // expected-error {{invalid operands}}
sc >>= ss2; // expected-error {{vector operands do not have the same number of elements}}
sc >>= si2; // expected-error {{vector operands do not have the same number of elements}}
sc >>= sl2; // expected-error {{vector operands do not have the same number of elements}}
sc >>= fd2; // expected-error {{integer is required}}
ss >>= ss2;
ss >>= ss_scalar;
us >>= us2;
us >>= us_scalar;
bs >>= bs2; // expected-error {{invalid operands}}
si >>= si2;
si >>= si_scalar;
ui >>= ui2;
ui >>= ui_scalar;
bi >>= bi2; // expected-error {{invalid operands}}
sl >>= sl2;
sl >>= sl_scalar;
ul >>= ul2;
ul >>= ul_scalar;
bl >>= bl2; // expected-error {{invalid operands}}
fd >>= fd2; // expected-error {{integer is required}}
// -------------------------------------------------------------------------
// Test ==.
// -------------------------------------------------------------------------
(void)(sc == sc2);
(void)(uc == uc2);
(void)(bc == bc2);
(void)(sc == uc); // expected-error {{can't convert}}
(void)(sc == bc);
(void)(uc == sc); // expected-error {{can't convert}}
(void)(uc == bc);
(void)(bc == sc);
(void)(bc == uc);
(void)(ss == ss2);
(void)(us == us2);
(void)(bs == bs2);
(void)(si == si2);
(void)(ui == ui2);
(void)(bi == bi2);
(void)(sl == sl2);
(void)(ul == ul2);
(void)(bl == bl2);
(void)(fd == fd2);
(void)(fd == ul); // expected-error {{can't convert}}
(void)(ul == fd); // expected-error {{can't convert}}
// -------------------------------------------------------------------------
// Test that == rules apply to != too.
// -------------------------------------------------------------------------
(void)(sc != sc2);
(void)(uc != uc2);
(void)(bc != bc2);
(void)(sc != uc); // expected-error {{can't convert}}
(void)(sc != bc);
(void)(ss != ss2);
(void)(us != us2);
(void)(bs != bs2);
(void)(si != si2);
(void)(ui != ui2);
(void)(bi != bi2);
(void)(sl != sl2);
(void)(ul != ul2);
(void)(bl != bl2);
(void)(fd != fd2);
// -------------------------------------------------------------------------
// Test that == rules apply to <= too.
// -------------------------------------------------------------------------
(void)(sc <= sc2);
(void)(uc <= uc2);
(void)(bc <= bc2);
(void)(sc <= uc); // expected-error {{can't convert}}
(void)(sc <= bc);
(void)(ss <= ss2);
(void)(us <= us2);
(void)(bs <= bs2);
(void)(si <= si2);
(void)(ui <= ui2);
(void)(bi <= bi2);
(void)(sl <= sl2);
(void)(ul <= ul2);
(void)(bl <= bl2);
(void)(fd <= fd2);
// -------------------------------------------------------------------------
// Test that == rules apply to >= too.
// -------------------------------------------------------------------------
(void)(sc >= sc2);
(void)(uc >= uc2);
(void)(bc >= bc2);
(void)(sc >= uc); // expected-error {{can't convert}}
(void)(sc >= bc);
(void)(ss >= ss2);
(void)(us >= us2);
(void)(bs >= bs2);
(void)(si >= si2);
(void)(ui >= ui2);
(void)(bi >= bi2);
(void)(sl >= sl2);
(void)(ul >= ul2);
(void)(bl >= bl2);
(void)(fd >= fd2);
// -------------------------------------------------------------------------
// Test that == rules apply to < too.
// -------------------------------------------------------------------------
(void)(sc < sc2);
(void)(uc < uc2);
(void)(bc < bc2);
(void)(sc < uc); // expected-error {{can't convert}}
(void)(sc < bc);
(void)(ss < ss2);
(void)(us < us2);
(void)(bs < bs2);
(void)(si < si2);
(void)(ui < ui2);
(void)(bi < bi2);
(void)(sl < sl2);
(void)(ul < ul2);
(void)(bl < bl2);
(void)(fd < fd2);
// -------------------------------------------------------------------------
// Test that == rules apply to > too.
// -------------------------------------------------------------------------
(void)(sc > sc2);
(void)(uc > uc2);
(void)(bc > bc2);
(void)(sc > uc); // expected-error {{can't convert}}
(void)(sc > bc);
(void)(ss > ss2);
(void)(us > us2);
(void)(bs > bs2);
(void)(si > si2);
(void)(ui > ui2);
(void)(bi > bi2);
(void)(sl > sl2);
(void)(ul > ul2);
(void)(bl > bl2);
(void)(fd > fd2);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/exprs.c
|
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
// PR 8876 - don't warn about trivially unreachable null derefs. Note that
// we put this here because the reachability analysis only kicks in for
// suppressing false positives when code has no errors.
#define PR8876(err_ptr) do {\
if (err_ptr) *(int*)(err_ptr) = 1;\
} while (0)
#define PR8876_pos(err_ptr) do {\
if (!err_ptr) *(int*)(err_ptr) = 1;\
} while (0)
// Test that we don't report divide-by-zero errors in unreachable code.
// This test should be left as is, as it also tests CFG functionality.
void radar9171946() {
if (0) {
0 / (0 ? 1 : 0); // expected-warning {{expression result unused}}
}
}
int test_pr8876() {
PR8876(0); // no-warning
PR8876_pos(0); // expected-warning{{indirection of non-volatile null pointer will be deleted, not trap}} expected-note{{consider using __builtin_trap() or qualifying pointer with 'volatile'}}
return 0;
}
// PR 8183 - Handle null pointer constants on the left-side of the '&&', and reason about
// this when determining the reachability of the null pointer dereference on the right side.
void pr8183(unsigned long long test)
{
(void)((((void*)0)) && (*((unsigned long long*)(((void*)0))) = ((unsigned long long)((test)) % (unsigned long long)((1000000000))))); // no-warning
(*((unsigned long long*)(((void*)0))) = ((unsigned long long)((test)) % (unsigned long long)((1000000000)))); // expected-warning {{indirection of non-volatile null pointer will be deleted, not trap}} expected-note {{consider using __builtin_trap() or qualifying pointer with 'volatile'}}
}
// PR1966
_Complex double test1() {
return __extension__ 1.0if;
}
_Complex double test2() {
return 1.0if; // expected-warning {{imaginary constants are a GNU extension}}
}
// rdar://6097308
void test3() {
int x;
(__extension__ x) = 10;
}
// rdar://6162726
void test4() {
static int var;
var =+ 5; // expected-warning {{use of unary operator that may be intended as compound assignment (+=)}}
var =- 5; // expected-warning {{use of unary operator that may be intended as compound assignment (-=)}}
var = +5; // no warning when space between the = and +.
var = -5;
var =+5; // no warning when the subexpr of the unary op has no space before it.
var =-5;
#define FIVE 5
var=-FIVE; // no warning with macros.
var=-FIVE;
}
// rdar://6319320
void test5(int *X, float *P) {
(float*)X = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
#define FOO ((float*) X)
FOO = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
}
void test6() {
int X;
X(); // expected-error {{called object type 'int' is not a function or function pointer}}
}
void test7(int *P, _Complex float Gamma) {
P = (P-42) + Gamma*4; // expected-error {{invalid operands to binary expression ('int *' and '_Complex float')}}
}
// rdar://6095061
int test8(void) {
int i;
__builtin_choose_expr (0, 42, i) = 10;
return i;
}
// PR3386
struct f { int x : 4; float y[]; };
int test9(struct f *P) {
int R;
R = __alignof(P->x); // expected-error {{invalid application of 'alignof' to bit-field}}
R = __alignof(P->y); // ok.
R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bit-field}}
return R;
}
// PR3562
void test10(int n,...) {
struct S {
double a[n]; // expected-error {{fields must have a constant size}}
} s;
double x = s.a[0]; // should not get another error here.
}
#define MYMAX(A,B) __extension__ ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
struct mystruct {int A; };
void test11(struct mystruct P, float F) {
MYMAX(P, F); // expected-error {{invalid operands to binary expression ('typeof (P)' (aka 'struct mystruct') and 'typeof (F)' (aka 'float'))}}
}
// PR3753
int test12(const char *X) {
return X == "foo"; // expected-warning {{comparison against a string literal is unspecified (use strncmp instead)}}
}
int test12b(const char *X) {
return sizeof(X == "foo"); // no-warning
}
// rdar://6719156
void test13(
void (^P)()) { // expected-error {{blocks support disabled - compile with -fblocks}}
P();
P = ^(){}; // expected-error {{blocks support disabled - compile with -fblocks}}
}
void test14() {
typedef long long __m64 __attribute__((__vector_size__(8)));
typedef short __v4hi __attribute__((__vector_size__(8)));
// Ok.
__v4hi a;
__m64 mask = (__m64)((__v4hi)a > (__v4hi)a);
}
// PR5242
typedef unsigned long *test15_t;
test15_t test15(void) {
return (test15_t)0 + (test15_t)0; // expected-error {{invalid operands to binary expression ('test15_t' (aka 'unsigned long *') and 'test15_t')}}
}
// rdar://7446395
void test16(float x) { x == ((void*) 0); } // expected-error {{invalid operands to binary expression}}
// PR6004
void test17(int x) {
x = x / 0; // expected-warning {{division by zero is undefined}}
x = x % 0; // expected-warning {{remainder by zero is undefined}}
x /= 0; // expected-warning {{division by zero is undefined}}
x %= 0; // expected-warning {{remainder by zero is undefined}}
x = sizeof(x/0); // no warning.
}
// PR6501 & PR11857
void test18_a(int a); // expected-note 2 {{'test18_a' declared here}}
void test18_b(int); // expected-note {{'test18_b' declared here}}
void test18_c(int a, int b); // expected-note 2 {{'test18_c' declared here}}
void test18_d(int a, ...); // expected-note {{'test18_d' declared here}}
void test18_e(int a, int b, ...); // expected-note {{'test18_e' declared here}}
void test18(int b) {
test18_a(b, b); // expected-error {{too many arguments to function call, expected single argument 'a', have 2}}
test18_a(); // expected-error {{too few arguments to function call, single argument 'a' was not specified}}
test18_b(); // expected-error {{too few arguments to function call, expected 1, have 0}}
test18_c(b); // expected-error {{too few arguments to function call, expected 2, have 1}}
test18_c(b, b, b); // expected-error {{too many arguments to function call, expected 2, have 3}}
test18_d(); // expected-error {{too few arguments to function call, at least argument 'a' must be specified}}
test18_e(); // expected-error {{too few arguments to function call, expected at least 2, have 0}}
}
// PR7569
void test19() {
*(int*)0 = 0; // expected-warning {{indirection of non-volatile null pointer}} \
// expected-note {{consider using __builtin_trap}}
*(volatile int*)0 = 0; // Ok.
// rdar://9269271
int x = *(int*)0; // expected-warning {{indirection of non-volatile null pointer}} \
// expected-note {{consider using __builtin_trap}}
int x2 = *(volatile int*)0; // Ok.
int *p = &(*(int*)0); // Ok;
}
int test20(int x) {
return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
return x && sizeof(int) == 4; // no warning, RHS is logical op.
// no warning, this is an idiom for "true" in old C style.
return x && (signed char)1;
return x || 0;
return x || 1;
return x || -1; // expected-warning {{use of logical '||' with constant operand}} \
// expected-note {{use '|' for a bitwise operation}}
return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
// expected-note {{use '|' for a bitwise operation}}
return x && 0;
return x && 1;
return x && -1; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
return x && 5; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
return x || (0);
return x || (1);
return x || (-1); // expected-warning {{use of logical '||' with constant operand}} \
// expected-note {{use '|' for a bitwise operation}}
return x || (5); // expected-warning {{use of logical '||' with constant operand}} \
// expected-note {{use '|' for a bitwise operation}}
return x && (0);
return x && (1);
return x && (-1); // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
return x && (5); // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
}
struct Test21; // expected-note 2 {{forward declaration}}
void test21(volatile struct Test21 *ptr) {
void test21_help(void);
(test21_help(), *ptr); // expected-error {{incomplete type 'struct Test21' where a complete type is required}}
(*ptr, test21_help()); // expected-error {{incomplete type 'struct Test21' where a complete type is required}}
}
// Make sure we do function/array decay.
void test22() {
if ("help")
(void) 0;
if (test22) // expected-warning {{address of function 'test22' will always evaluate to 'true'}} \
// expected-note {{prefix with the address-of operator to silence this warning}}
(void) 0;
if (&test22)
(void) 0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ucn-cstring.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
int printf(const char *, ...);
int main(void) {
int a[sizeof("hello \u2192 \u2603 \u2190 world") == 24 ? 1 : -1];
printf("%s (%zd)\n", "hello \u2192 \u2603 \u2190 world", sizeof("hello \u2192 \u2603 \u2190 world"));
printf("%s (%zd)\n", "\U00010400\U0001D12B", sizeof("\U00010400\U0001D12B"));
// Some error conditions...
printf("%s\n", "\U"); // expected-error{{\U used with no following hex digits}}
printf("%s\n", "\U00"); // expected-error{{incomplete universal character name}}
printf("%s\n", "\U0001"); // expected-error{{incomplete universal character name}}
printf("%s\n", "\u0001"); // expected-error{{universal character name refers to a control character}}
return 0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-return-2.c
|
// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
void foo() {
^ (void) __attribute__((noreturn)) { }(); // expected-error {{block declared 'noreturn' should not return}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/compound-literal.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
// REQUIRES: LP64
struct foo { int a, b; };
static struct foo t = (struct foo){0,0};
static struct foo t1 = __builtin_choose_expr(0, (struct foo){0,0}, (struct foo){0,0});
static struct foo t2 = {0,0};
static struct foo t3 = t2; // expected-error {{initializer element is not a compile-time constant}}
static int *p = (int []){2,4};
static int x = (int){1};
static int *p2 = (int []){2,x}; // expected-error {{initializer element is not a compile-time constant}}
static long *p3 = (long []){2,"x"}; // expected-warning {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [2]'}}
typedef struct { } cache_t; // expected-warning{{empty struct is a GNU extension}}
static cache_t clo_I1_cache = ((cache_t) { } ); // expected-warning{{use of GNU empty initializer extension}}
typedef struct Test {int a;int b;} Test;
static Test* ll = &(Test) {0,0};
extern void fooFunc(struct foo *pfoo);
int main(int argc, char **argv) {
int *l = (int []){x, *p, *p2};
fooFunc(&(struct foo){ 1, 2 });
}
struct Incomplete; // expected-note{{forward declaration of 'struct Incomplete'}}
struct Incomplete* I1 = &(struct Incomplete){1, 2, 3}; // expected-error {{variable has incomplete type}}
void IncompleteFunc(unsigned x) {
struct Incomplete* I2 = (struct foo[x]){1, 2, 3}; // expected-error {{variable-sized object may not be initialized}}
(void){1,2,3}; // expected-error {{variable has incomplete type}}
(void(void)) { 0 }; // expected-error{{illegal initializer type 'void (void)'}}
}
// PR6080
int array[(sizeof(int[3]) == sizeof( (int[]) {0,1,2} )) ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/private-extern.c
|
// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern %s
// RUN: %clang_cc1 -verify -fsyntax-only -Wno-private-extern -fmodules %s
static int g0; // expected-note{{previous definition}}
int g0; // expected-error{{non-static declaration of 'g0' follows static declaration}}
static int g1;
extern int g1;
static int g2;
__private_extern__ int g2;
int g3; // expected-note{{previous definition}}
static int g3; // expected-error{{static declaration of 'g3' follows non-static declaration}}
extern int g4; // expected-note{{previous declaration}}
static int g4; // expected-error{{static declaration of 'g4' follows non-static declaration}}
__private_extern__ int g5; // expected-note{{previous declaration}}
static int g5; // expected-error{{static declaration of 'g5' follows non-static declaration}}
void f0() {
int g6; // expected-note {{previous}}
extern int g6; // expected-error {{extern declaration of 'g6' follows non-extern declaration}}
}
void f1() {
int g7; // expected-note {{previous}}
__private_extern__ int g7; // expected-error {{extern declaration of 'g7' follows non-extern declaration}}
}
void f2() {
extern int g8; // expected-note{{previous declaration}}
int g8; // expected-error {{non-extern declaration of 'g8' follows extern declaration}}
}
void f3() {
__private_extern__ int g9; // expected-note{{previous declaration}}
int g9; // expected-error {{non-extern declaration of 'g9' follows extern declaration}}
}
void f4() {
extern int g10;
extern int g10;
}
void f5() {
__private_extern__ int g11;
__private_extern__ int g11;
}
void f6() {
// FIXME: Diagnose
extern int g12;
__private_extern__ int g12;
}
void f7() {
// FIXME: Diagnose
__private_extern__ int g13;
extern int g13;
}
struct s0;
void f8() {
extern struct s0 g14;
__private_extern__ struct s0 g14;
}
struct s0 { int x; };
void f9() {
extern int g15 = 0; // expected-error{{'extern' variable cannot have an initializer}}
// FIXME: linkage specifier in warning.
__private_extern__ int g16 = 0; // expected-error{{'extern' variable cannot have an initializer}}
}
extern int g17;
int g17 = 0;
extern int g18 = 0; // expected-warning{{'extern' variable has an initializer}}
__private_extern__ int g19;
int g19 = 0;
__private_extern__ int g20 = 0;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/short-enums.c
|
// RUN: not %clang_cc1 -fsyntax-only %s -verify
// RUN: %clang_cc1 -fshort-enums -fsyntax-only %s -verify
// expected-no-diagnostics
enum x { A };
int t0[sizeof(enum x) == 1 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/illegal-types.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -x c++ -std=c++98 %s
void a (void []()); // expected-error{{'type name' declared as array of functions}}
void b (void p[]()); // expected-error{{'p' declared as array of functions}}
void c (int &[]); // expected-error{{'type name' declared as array of references}}
void d (int &p[]); // expected-error{{'p' declared as array of references}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-null.c
|
// RUN: %clang_cc1 %s -verify
#define SOME_ADDR (unsigned long long)0
// PR10837: Warn if a non-pointer-typed expression is folded to a null pointer
int *p = 0;
int *q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
int *r = (1 - 1); // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
void f() {
p = 0;
q = '\0'; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
r = 1 - 1; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
p = SOME_ADDR; // expected-warning{{expression which evaluates to zero treated as a null pointer constant}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-shadow-intrinsics.c
|
// RUN: %clang_cc1 -ffreestanding -triple x86_64-apple-macosx10.8.0 -fsyntax-only %s
#include <emmintrin.h>
// Test that using two macros from emmintrin do not cause a
// useless -Wshadow warning.
void rdar10679282() {
__m128i qf = _mm_setzero_si128();
qf = _mm_slli_si128(_mm_add_epi64(qf, _mm_srli_si128(qf, 8)), 8); // no-warning
(void) qf;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-section.c
|
// RUN: %clang_cc1 -verify -fsyntax-only -triple x86_64-apple-darwin9 %s
int x __attribute__((section(
42))); // expected-error {{'section' attribute requires a string}}
// rdar://4341926
int y __attribute__((section(
"sadf"))); // expected-error {{mach-o section specifier requires a segment and section separated by a comma}}
// PR6007
void test() {
__attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute only applies to functions and global variables}}
__attribute__((section("NEAR,x"))) static int n2; // ok.
}
// pr9356
void __attribute__((section("foo,zed"))) test2(void); // expected-note {{previous attribute is here}}
void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning {{section does not match previous declaration}}
enum __attribute__((section("NEAR,x"))) e { one }; // expected-error {{'section' attribute only applies to functions and global variables}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/anonymous-struct-union-c11.c
|
// Check for warnings in non-C11 mode:
// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wc11-extensions %s
// Expect no warnings in C11 mode:
// RUN: %clang_cc1 -fsyntax-only -std=c11 -pedantic -Werror %s
struct s {
int a;
struct { // expected-warning{{anonymous structs are a C11 extension}}
int b;
};
};
struct t {
int a;
union { // expected-warning{{anonymous unions are a C11 extension}}
int b;
};
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/knr-variadic-def.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
// expected-no-diagnostics
// PR4287
#include <stdarg.h>
char *foo = "test";
int test(char*,...);
int test(fmt)
char*fmt;
{
va_list ap;
char*a;
int x;
va_start(ap,fmt);
a=va_arg(ap,char*);
x=(a!=foo);
va_end(ap);
return x;
}
void exit();
int main(argc,argv)
int argc;char**argv;
{
exit(test("",foo));
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ext_vector_components.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
typedef __attribute__(( ext_vector_type(2) )) float float2;
typedef __attribute__(( ext_vector_type(3) )) float float3;
typedef __attribute__(( ext_vector_type(4) )) float float4;
typedef __attribute__(( ext_vector_type(16) )) float float16;
static float4 vec4_0 = (float4)0.5f;
static void test() {
float2 vec2, vec2_2;
float3 vec3;
float4 vec4, vec4_2, *vec4p;
float16 vec16;
float f;
vec2.z; // expected-error {{vector component access exceeds type 'float2'}}
vec2.xyzw; // expected-error {{vector component access exceeds type 'float2'}}
vec4.xyzw; // expected-warning {{expression result unused}}
vec4.xyzc; // expected-error {{illegal vector component name 'c'}}
vec4.s01z; // expected-error {{illegal vector component name 'z'}}
vec2 = vec4.s01; // legal, shorten
vec2 = vec4.S01; // legal, shorten
vec3 = vec4.xyz; // legal, shorten
f = vec2.x; // legal, shorten
f = vec4.xy.x; // legal, shorten
vec4_2.xyzx = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
vec4_2.xyzz = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
vec4_2.xyyw = vec4.xyzw; // expected-error {{vector is not assignable (contains duplicate components)}}
vec2.x = f;
vec2.xx = vec2_2.xy; // expected-error {{vector is not assignable (contains duplicate components)}}
vec2.yx = vec2_2.xy;
vec4 = (float4){ 1,2,3,4 };
vec4.xy.w; // expected-error {{vector component access exceeds type 'float2'}}
vec4.s06; // expected-error {{vector component access exceeds type 'float4'}}
vec4.x = vec16.sf;
vec4.x = vec16.sF;
vec4p->yz = vec4p->xy;
}
float2 lo(float3 x) { return x.lo; }
float2 hi(float3 x) { return x.hi; }
float2 ev(float3 x) { return x.even; }
float2 od(float3 x) { return x.odd; }
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-documentation.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
// This file contains lots of corner cases, so ensure that XML we generate is not invalid.
// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG
// WRONG-NOT: CommentXMLInvalid
// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
// expected-warning@+1 {{expected quoted string after equals sign}}
/// <a href=>
int test_html1(int);
// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
// expected-warning@+1 {{expected quoted string after equals sign}}
/// <a href==>
int test_html2(int);
// expected-warning@+3 {{HTML tag 'a' requires an end tag}}
// expected-warning@+2 {{expected quoted string after equals sign}}
// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
/// <a href= blah
int test_html3(int);
// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
/// <a =>
int test_html4(int);
// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
/// <a "aaa">
int test_html5(int);
// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
/// <a a="b" =>
int test_html6(int);
// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
/// <a a="b" "aaa">
int test_html7(int);
// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
/// <a a="b" =
int test_html8(int);
// expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
/** Aaa bbb<img ddd eee
* fff ggg.
*/
int test_html9(int);
// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
/** Aaa bbb<img ddd eee 42%
* fff ggg.
*/
int test_html10(int);
// expected-warning@+1 {{HTML end tag 'br' is forbidden}}
/// <br></br>
int test_html11(int);
/// <blockquote>Meow</blockquote>
int test_html_nesting1(int);
/// <b><i>Meow</i></b>
int test_html_nesting2(int);
/// <p>Aaa<br>
/// Bbb</p>
int test_html_nesting3(int);
/// <p>Aaa<br />
/// Bbb</p>
int test_html_nesting4(int);
// expected-warning@+3 {{HTML tag 'b' requires an end tag}}
// expected-warning@+2 {{HTML tag 'i' requires an end tag}}
// expected-warning@+1 {{HTML end tag does not match any start tag}}
/// <b><i>Meow</a>
int test_html_nesting5(int);
// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
// expected-warning@+1 {{HTML end tag does not match any start tag}}
/// <b><i>Meow</b></b>
int test_html_nesting6(int);
// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
// expected-warning@+1 {{HTML end tag does not match any start tag}}
/// <b><i>Meow</b></i>
int test_html_nesting7(int);
// expected-warning@+1 {{HTML tag 'b' requires an end tag}}
/// <b>Meow
int test_html_nesting8(int);
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\returns Aaa
int test_block_command1(int);
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief \returns Aaa
int test_block_command2(int);
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief
/// \returns Aaa
int test_block_command3(int);
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief
///
/// \returns Aaa
int test_block_command4(int);
// There is trailing whitespace on one of the following lines, don't remove it!
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief
///
/// \returns Aaa
int test_block_command5(int);
/// \brief \c Aaa
int test_block_command6(int);
// expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}}
/// \brief Aaa
///
/// Bbb
///
/// \brief Ccc
int test_duplicate_brief1(int);
// expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}}
/// \short Aaa
///
/// Bbb
///
/// \short Ccc
int test_duplicate_brief2(int);
// expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}}
/// \short Aaa
///
/// Bbb
///
/// \brief Ccc
int test_duplicate_brief3(int);
/// \return Aaa
///
/// Bbb
///
/// \return Ccc
int test_multiple_returns1(int);
/// \returns Aaa
///
/// Bbb
///
/// \returns Ccc
int test_multiple_returns2(int);
/// \result Aaa
///
/// Bbb
///
/// \result Ccc
int test_multiple_returns3(int);
/// \returns Aaa
///
/// Bbb
///
/// \return Ccc
int test_multiple_returns4(int);
// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
/// \param a Blah blah.
int test_param1_backslash;
// rdar://13066276
// Check that the diagnostic uses the same command marker as the comment.
// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
/// @param a Blah blah.
int test_param1_at;
// expected-warning@+1 {{empty paragraph passed to '\param' command}}
/// \param
/// \param a Blah blah.
int test_param2(int a);
// expected-warning@+1 {{empty paragraph passed to '\param' command}}
/// \param a
int test_param3(int a);
/// \param a Blah blah.
int test_param4(int a);
/// \param [in] a Blah blah.
int test_param5(int a);
/// \param [out] a Blah blah.
int test_param6(int a);
/// \param [in,out] a Blah blah.
int test_param7(int a);
// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
/// \param [ in ] a Blah blah.
int test_param8(int a);
// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
/// \param [in, out] a Blah blah.
int test_param9(int a);
// expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
/// \param [ junk] a Blah blah.
int test_param10(int a);
// expected-warning@+1 {{parameter 'a' not found in the function declaration}}
/// \param a Blah blah.
int test_param11();
// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
/// \param A Blah blah.
int test_param12(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 test_param13(int aaa, int bbb);
// expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
/// \param aaa Blah blah.
/// \param aab Blah blah.
int test_param14(int aaa, int bbb);
// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
/// \param aab Blah blah.
int test_param15(int bbb, int ccc);
// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
/// \param aab Ccc.
/// \param aaa Aaa.
/// \param bbb Bbb.
int test_param16(int aaa, int bbb);
// expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
/// \param aaa Aaa.
/// \param aab Ccc.
/// \param bbb Bbb.
int test_param17(int aaa, int bbb);
// expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
/// \param aaa Aaa.
/// \param bbb Bbb.
/// \param aab Ccc.
int test_param18(int aaa, int bbb);
class C {
// expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
/// \param aaa Blah blah.
C(int bbb, int ccc);
// expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
/// \param aaa Blah blah.
int test_param19(int bbb, int ccc);
};
// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
/// \param aab Blah blah.
template<typename T>
void test_param20(int bbb, int ccc);
// expected-warning@+3 {{parameter 'a' is already documented}}
// expected-note@+1 {{previous documentation}}
/// \param a Aaa.
/// \param a Aaa.
int test_param21(int a);
// expected-warning@+4 {{parameter 'x2' is already documented}}
// expected-note@+2 {{previous documentation}}
/// \param x1 Aaa.
/// \param x2 Bbb.
/// \param x2 Ccc.
int test_param22(int x1, int x2, int x3);
//===---
// Test that we treat typedefs to some non-function types as functions for the
// purposes of documentation comment parsing.
//===---
namespace foo {
inline namespace bar {
template<typename>
struct function_wrapper {};
template<unsigned>
struct not_a_function_wrapper {};
}
};
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
typedef int test_function_like_typedef1(int aaa, int ccc);
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
typedef int (*test_function_like_typedef2)(int aaa, int ccc);
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
typedef int (* const test_function_like_typedef3)(int aaa, int ccc);
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
typedef int (C::*test_function_like_typedef4)(int aaa, int ccc);
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef5;
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
typedef foo::function_wrapper<int (int aaa, int ccc)> &test_function_like_typedef7;
// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
/// \param aaa Meow.
/// \param bbb Bbb.
/// \returns aaa.
typedef foo::function_wrapper<int (int aaa, int ccc)> &&test_function_like_typedef8;
typedef int (*test_not_function_like_typedef1)(int aaa);
// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
/// \param aaa Meow.
typedef test_not_function_like_typedef1 test_not_function_like_typedef2;
// rdar://13066276
// Check that the diagnostic uses the same command marker as the comment.
// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
/// @param aaa Meow.
typedef unsigned int test_not_function_like_typedef3;
// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
/// \param aaa Meow.
typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4;
/// \param aaa Aaa
/// \param ... Vararg
int test_vararg_param1(int aaa, ...);
/// \param ... Vararg
int test_vararg_param2(...);
// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
/// \param ... Vararg
int test_vararg_param3(int aaa);
// expected-warning@+1 {{parameter '...' not found in the function declaration}}
/// \param ... Vararg
int test_vararg_param4();
/// \param aaa Aaa
/// \param ... Vararg
template<typename T>
int test_template_vararg_param1(int aaa, ...);
/// \param ... Vararg
template<typename T>
int test_template_vararg_param2(...);
// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
/// \param ... Vararg
template<typename T>
int test_template_vararg_param3(int aaa);
// expected-warning@+1 {{parameter '...' not found in the function declaration}}
/// \param ... Vararg
template<typename T>
int test_template_vararg_param4();
// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
/// \tparam T Aaa
int test_tparam1;
// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
/// \tparam T Aaa
void test_tparam2(int aaa);
// expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
/// \tparam
/// \param aaa Blah blah
template<typename T>
void test_tparam3(T aaa);
// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
/// \tparam T Aaa
template<typename TT>
void test_tparam4(TT aaa);
// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
/// \tparam T Aaa
template<typename TT>
class test_tparam5 {
// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
/// \tparam T Aaa
template<typename TTT>
void test_tparam6(TTT aaa);
};
/// \tparam T1 Aaa
/// \tparam T2 Bbb
template<typename T1, typename T2>
void test_tparam7(T1 aaa, T2 bbb);
// 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 test_tparam8(SomeTy aaa, OtherTy bbb);
// expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
/// \tparam T1 Aaa
/// \tparam T1 Bbb
template<typename T1, typename T2>
void test_tparam9(T1 aaa, T2 bbb);
/// \tparam T Aaa
/// \tparam TT Bbb
template<template<typename T> class TT>
void test_tparam10(TT<int> aaa);
/// \tparam T Aaa
/// \tparam TT Bbb
/// \tparam TTT Ccc
template<template<template<typename T> class TT, class C> class TTT>
void test_tparam11();
/// \tparam I Aaa
template<int I>
void test_tparam12();
template<typename T, typename U>
class test_tparam13 { };
/// \tparam T Aaa
template<typename T>
using test_tparam14 = test_tparam13<T, int>;
// expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
/// \tparam U Aaa
template<typename T>
using test_tparam15 = test_tparam13<T, int>;
// ----
/// \tparam T Aaa
template<typename T>
class test_tparam16 { };
typedef test_tparam16<int> test_tparam17;
typedef test_tparam16<double> test_tparam18;
// ----
template<typename T>
class test_tparam19;
typedef test_tparam19<int> test_tparam20;
typedef test_tparam19<double> test_tparam21;
/// \tparam T Aaa
template<typename T>
class test_tparam19 { };
// ----
// expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
/// @tparam T Aaa
int test_tparam22;
// ----
/// Aaa
/// \deprecated Bbb
void test_deprecated_1(int a) __attribute__((deprecated));
// We don't want \deprecated to warn about empty paragraph. It is fine to use
// \deprecated by itself without explanations.
/// Aaa
/// \deprecated
void test_deprecated_2(int a) __attribute__((deprecated));
/// Aaa
/// \deprecated
void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
/// Aaa
/// \deprecated
void test_deprecated_4(int a) __attribute__((unavailable));
// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
/// Aaa
/// \deprecated
void test_deprecated_5(int a);
// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
/// Aaa
/// \deprecated
void test_deprecated_6(int a) {
}
// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
/// Aaa
/// \deprecated
template<typename T>
void test_deprecated_7(T aaa);
// rdar://12397511
// expected-note@+2 {{previous command '\headerfile' here}}
// expected-warning@+2 {{duplicated command '\headerfile'}}
/// \headerfile ""
/// \headerfile foo.h
int test__headerfile_1(int a);
/// \invariant aaa
void test_invariant_1(int a);
// expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
/// \invariant
void test_invariant_2(int a);
// no-warning
/// \returns Aaa
int test_returns_right_decl_1(int);
class test_returns_right_decl_2 {
// no-warning
/// \returns Aaa
int test_returns_right_decl_3(int);
};
// no-warning
/// \returns Aaa
template<typename T>
int test_returns_right_decl_4(T aaa);
// no-warning
/// \returns Aaa
template<>
int test_returns_right_decl_4(int aaa);
/// \returns Aaa
template<typename T>
T test_returns_right_decl_5(T aaa);
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
/// \returns Aaa
int test_returns_wrong_decl_1_backslash;
// rdar://13066276
// Check that the diagnostic uses the same command marker as the comment.
// expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
/// @returns Aaa
int test_returns_wrong_decl_1_at;
// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
/// \return Aaa
int test_returns_wrong_decl_2;
// expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
/// \result Aaa
int test_returns_wrong_decl_3;
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
/// \returns Aaa
void test_returns_wrong_decl_4(int);
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
/// \returns Aaa
template<typename T>
void test_returns_wrong_decl_5(T aaa);
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
/// \returns Aaa
template<>
void test_returns_wrong_decl_5(int aaa);
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
/// \returns Aaa
struct test_returns_wrong_decl_6 { };
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
/// \returns Aaa
class test_returns_wrong_decl_7 {
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
/// \returns Aaa
test_returns_wrong_decl_7();
// expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
/// \returns Aaa
~test_returns_wrong_decl_7();
};
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
/// \returns Aaa
enum test_returns_wrong_decl_8 {
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
/// \returns Aaa
test_returns_wrong_decl_9
};
// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
/// \returns Aaa
namespace test_returns_wrong_decl_10 { };
// rdar://13094352
// expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
/*! @function test_function
*/
typedef unsigned int Base64Flags;
unsigned test_function(Base64Flags inFlags);
// expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
/*! @callback test_callback
*/
typedef unsigned int BaseFlags;
unsigned (*test_callback)(BaseFlags inFlags);
// expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
/// \endverbatim
int test_verbatim_1();
// expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
/// \endcode
int test_verbatim_2();
// FIXME: we give a bad diagnostic here because we throw away non-documentation
// comments early.
//
// expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
/// \code
// foo
/// \endcode
int test_verbatim_3();
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
int test1; ///< \brief\author Aaa
// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
int test2, ///< \brief\author Aaa
test3; ///< \brief\author Aaa
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
int test4; ///< \brief
///< \author Aaa
class TestRelates {};
/// \relates TestRelates
/// \brief Aaa
void test_relates_1();
/// \related TestRelates
/// \brief Aaa
void test_relates_2();
/// \relatesalso TestRelates
/// \brief Aaa
void test_relates_3();
/// \relatedalso TestRelates
/// \brief Aaa
void test_relates_4();
// Check that we attach the comment to the declaration during parsing in the
// following cases. The test is based on the fact that we don't parse
// documentation comments that are not attached to anything.
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
int test_attach1;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
int test_attach2(int);
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
struct test_attach3 {
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
int test_attach4;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
int test_attach5; ///< \brief\author Aaa
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
int test_attach6(int);
};
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
class test_attach7 {
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
int test_attach8;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
int test_attach9; ///< \brief\author Aaa
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
int test_attach10(int);
};
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
enum test_attach9 {
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
test_attach10,
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
test_attach11 ///< \brief\author Aaa
};
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
struct test_noattach12 *test_attach13;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
typedef struct test_noattach14 *test_attach15;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
typedef struct test_attach16 { int a; } test_attach17;
struct S { int a; };
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
struct S *test_attach18;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
typedef struct S *test_attach19;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
struct test_attach20;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
typedef struct test_attach21 {
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
int test_attach22;
} test_attach23;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
namespace test_attach24 {
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
namespace test_attach25 {
}
}
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T>
void test_attach26(T aaa);
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T, typename U>
void test_attach27(T aaa, U bbb);
// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
/// \brief\author Aaa
/// \tparam T Aaa
template<>
void test_attach27(int aaa, int bbb);
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T>
class test_attach28 {
T aaa;
};
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
using test_attach29 = test_attach28<int>;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T, typename U>
class test_attach30 { };
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T>
class test_attach30<T, int> { };
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
template<>
class test_attach30<int, int> { };
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
template<typename T>
using test_attach31 = test_attach30<T, int>;
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T, typename U, typename V>
class test_attach32 { };
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T, typename U>
class test_attach32<T, U, int> { };
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T>
class test_attach32<T, int, int> { };
// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
/// \brief\author Aaa
/// \tparam T Aaa
template<>
class test_attach32<int, int, int> { };
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
class test_attach33 {
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T, typename U>
void test_attach34(T aaa, U bbb);
};
template<typename T>
class test_attach35 {
// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename TT, typename UU>
void test_attach36(TT aaa, UU bbb);
};
// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
/// \brief\author Aaa
/// \tparam T Aaa
template<> template<>
void test_attach35<int>::test_attach36(int aaa, int bbb) {}
template<typename T>
class test_attach37 {
// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
// expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
/// \brief\author Aaa
/// \tparam T Aaa
void test_attach38(int aaa, int bbb);
void test_attach39(int aaa, int bbb);
};
// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
/// \brief\author Aaa
/// \tparam T Aaa
template<>
void test_attach37<int>::test_attach38(int aaa, int bbb) {}
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \brief\author Aaa
/// \tparam T Aaa
template<typename T>
void test_attach37<T>::test_attach39(int aaa, int bbb) {}
// We used to emit warning that parameter 'a' is not found because we parsed
// the comment in context of the redeclaration which does not have parameter
// names.
template <typename T>
struct test_attach38 {
/*!
\param a First param
\param b Second param
*/
template <typename B>
void test_attach39(T a, B b);
};
template <>
template <typename B>
void test_attach38<int>::test_attach39(int, B);
// PR13411, reduced. We used to crash on this.
/**
* @code Aaa.
*/
void test_nocrash1(int);
// We used to crash on this.
// expected-warning@+2 {{empty paragraph passed to '\param' command}}
// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
/// \param\brief
void test_nocrash2(int);
// PR13593, example 1 and 2
/**
* Bla.
*/
template <typename>
void test_nocrash3();
/// Foo
template <typename, typename>
void test_nocrash4() { }
template <typename>
void test_nocrash3()
{
}
// PR13593, example 3
/**
* aaa
*/
template <typename T>
inline T test_nocrash5(T a1)
{
return a1;
}
///
//,
inline void test_nocrash6()
{
test_nocrash5(1);
}
// We used to crash on this.
/*!
Blah.
*/
typedef const struct test_nocrash7 * test_nocrash8;
// We used to crash on this.
// expected-warning@+1 {{unknown command tag name}}
/// aaa \unknown aaa \unknown aaa
int test_nocrash9;
// We used to crash on this. PR15068
// expected-warning@+2 {{empty paragraph passed to '@param' command}}
// expected-warning@+2 {{empty paragraph passed to '@param' command}}
///@param x
///@param y
int test_nocrash10(int x, int y);
// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
///@param x
///@param y
int test_nocrash11();
// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
/**
@param x
@param y
**/
int test_nocrash12();
// expected-warning@+2 {{empty paragraph passed to '@param' command}}
// expected-warning@+1 {{empty paragraph passed to '@param' command}}
///@param x@param y
int test_nocrash13(int x, int y);
/**
* \verbatim
* Aaa
**/
int test_nocrash14();
// rdar://12379114
// expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
/*!
@union U This is new
*/
struct U { int iS; };
/*!
@union U1
*/
union U1 {int i; };
// expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
/*!
@struct S2
*/
union S2 {};
/*!
@class C1
*/
class C1;
/*!
@struct S3;
*/
class S3;
// rdar://14124702
//----------------------------------------------------------------------
/// @class Predicate Predicate.h "lldb/Host/Predicate.h"
/// @brief A C++ wrapper class for providing threaded access to a value
/// of type T.
///
/// A templatized class.
/// specified values.
//----------------------------------------------------------------------
template <class T, class T1>
class Predicate
{
};
//----------------------------------------------------------------------
/// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
/// @brief A C++ wrapper class for providing threaded access to a value
/// of type T.
///
/// A template specilization class.
//----------------------------------------------------------------------
template<> class Predicate<int, char>
{
};
//----------------------------------------------------------------------
/// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
/// @brief A C++ wrapper class for providing threaded access to a value
/// of type T.
///
/// A partial specialization template class.
//----------------------------------------------------------------------
template<class T> class Predicate<T, int>
{
};
/*! @function test_function
*/
template <class T> T test_function (T arg);
/*! @function test_function<int>
*/
template <> int test_function<int> (int arg);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-thread-safety-analysis.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta %s
#define LOCKABLE __attribute__ ((lockable))
#define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
#define GUARDED_BY(x) __attribute__ ((guarded_by(x)))
#define GUARDED_VAR __attribute__ ((guarded_var))
#define PT_GUARDED_BY(x) __attribute__ ((pt_guarded_by(x)))
#define PT_GUARDED_VAR __attribute__ ((pt_guarded_var))
#define ACQUIRED_AFTER(...) __attribute__ ((acquired_after(__VA_ARGS__)))
#define ACQUIRED_BEFORE(...) __attribute__ ((acquired_before(__VA_ARGS__)))
#define EXCLUSIVE_LOCK_FUNCTION(...) __attribute__ ((exclusive_lock_function(__VA_ARGS__)))
#define SHARED_LOCK_FUNCTION(...) __attribute__ ((shared_lock_function(__VA_ARGS__)))
#define ASSERT_EXCLUSIVE_LOCK(...) __attribute__ ((assert_exclusive_lock(__VA_ARGS__)))
#define ASSERT_SHARED_LOCK(...) __attribute__ ((assert_shared_lock(__VA_ARGS__)))
#define EXCLUSIVE_TRYLOCK_FUNCTION(...) __attribute__ ((exclusive_trylock_function(__VA_ARGS__)))
#define SHARED_TRYLOCK_FUNCTION(...) __attribute__ ((shared_trylock_function(__VA_ARGS__)))
#define UNLOCK_FUNCTION(...) __attribute__ ((unlock_function(__VA_ARGS__)))
#define LOCK_RETURNED(x) __attribute__ ((lock_returned(x)))
#define LOCKS_EXCLUDED(...) __attribute__ ((locks_excluded(__VA_ARGS__)))
#define EXCLUSIVE_LOCKS_REQUIRED(...) \
__attribute__ ((exclusive_locks_required(__VA_ARGS__)))
#define SHARED_LOCKS_REQUIRED(...) \
__attribute__ ((shared_locks_required(__VA_ARGS__)))
#define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis))
// Define the mutex struct.
// Simplified only for test purpose.
struct LOCKABLE Mutex {};
struct Foo {
struct Mutex *mu_;
};
// Declare mutex lock/unlock functions.
void mutex_exclusive_lock(struct Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu);
void mutex_shared_lock(struct Mutex *mu) SHARED_LOCK_FUNCTION(mu);
void mutex_unlock(struct Mutex *mu) UNLOCK_FUNCTION(mu);
void mutex_shared_unlock(struct Mutex *mu) __attribute__((release_shared_capability(mu)));
void mutex_exclusive_unlock(struct Mutex *mu) __attribute__((release_capability(mu)));
// Define global variables.
struct Mutex mu1;
struct Mutex mu2 ACQUIRED_AFTER(mu1);
struct Foo foo_ = {&mu1};
int a_ GUARDED_BY(foo_.mu_);
int *b_ PT_GUARDED_BY(foo_.mu_) = &a_;
int c_ GUARDED_VAR;
int *d_ PT_GUARDED_VAR = &c_;
// Define test functions.
int Foo_fun1(int i) SHARED_LOCKS_REQUIRED(mu2) EXCLUSIVE_LOCKS_REQUIRED(mu1) {
return i;
}
int Foo_fun2(int i) EXCLUSIVE_LOCKS_REQUIRED(mu2) SHARED_LOCKS_REQUIRED(mu1) {
return i;
}
int Foo_func3(int i) LOCKS_EXCLUDED(mu1, mu2) {
return i;
}
static int Bar_fun1(int i) EXCLUSIVE_LOCKS_REQUIRED(mu1) {
return i;
}
void set_value(int *a, int value) EXCLUSIVE_LOCKS_REQUIRED(foo_.mu_) {
*a = value;
}
int get_value(int *p) SHARED_LOCKS_REQUIRED(foo_.mu_){
return *p;
}
int main() {
Foo_fun1(1); // expected-warning{{calling function 'Foo_fun1' requires holding mutex 'mu2'}} \
expected-warning{{calling function 'Foo_fun1' requires holding mutex 'mu1' exclusively}}
mutex_exclusive_lock(&mu1);
mutex_shared_lock(&mu2);
Foo_fun1(1);
mutex_shared_lock(&mu1); // expected-warning{{acquiring mutex 'mu1' that is already held}}
mutex_unlock(&mu1);
mutex_unlock(&mu2);
mutex_shared_lock(&mu1);
mutex_exclusive_lock(&mu2);
Foo_fun2(2);
mutex_unlock(&mu2);
mutex_unlock(&mu1);
mutex_exclusive_lock(&mu1);
Bar_fun1(3);
mutex_unlock(&mu1);
mutex_exclusive_lock(&mu1);
Foo_func3(4); // expected-warning{{cannot call function 'Foo_func3' while mutex 'mu1' is held}}
mutex_unlock(&mu1);
Foo_func3(5);
set_value(&a_, 0); // expected-warning{{calling function 'set_value' requires holding mutex 'foo_.mu_' exclusively}}
get_value(b_); // expected-warning{{calling function 'get_value' requires holding mutex 'foo_.mu_'}}
mutex_exclusive_lock(foo_.mu_);
set_value(&a_, 1);
mutex_unlock(foo_.mu_);
mutex_shared_lock(foo_.mu_);
(void)(get_value(b_) == 1);
mutex_unlock(foo_.mu_);
c_ = 0; // expected-warning{{writing variable 'c_' requires holding any mutex exclusively}}
(void)(*d_ == 0); // expected-warning{{reading the value pointed to by 'd_' requires holding any mutex}}
mutex_exclusive_lock(foo_.mu_);
c_ = 1;
(void)(*d_ == 1);
mutex_unlock(foo_.mu_);
mutex_exclusive_lock(&mu1);
mutex_shared_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' using shared access, expected exclusive access}}
mutex_exclusive_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' that was not held}}
mutex_shared_lock(&mu1);
mutex_exclusive_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' using exclusive access, expected shared access}}
mutex_shared_unlock(&mu1); // expected-warning {{releasing mutex 'mu1' that was not held}}
return 0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/bitfield-layout.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
// expected-no-diagnostics
#define CHECK_SIZE(kind, name, size) extern int name##1[sizeof(kind name) == size ? 1 : -1];
#define CHECK_ALIGN(kind, name, size) extern int name##2[__alignof(kind name) == size ? 1 : -1];
// Zero-width bit-fields
struct a {char x; int : 0; char y;};
CHECK_SIZE(struct, a, 5)
CHECK_ALIGN(struct, a, 1)
// Zero-width bit-fields with packed
struct __attribute__((packed)) a2 { short x : 9; char : 0; int y : 17; };
CHECK_SIZE(struct, a2, 5)
CHECK_ALIGN(struct, a2, 1)
// Zero-width bit-fields at the end of packed struct
struct __attribute__((packed)) a3 { short x : 9; int : 0; };
CHECK_SIZE(struct, a3, 4)
CHECK_ALIGN(struct, a3, 1)
// For comparison, non-zero-width bit-fields at the end of packed struct
struct __attribute__((packed)) a4 { short x : 9; int : 1; };
CHECK_SIZE(struct, a4, 2)
CHECK_ALIGN(struct, a4, 1)
union b {char x; int : 0; char y;};
CHECK_SIZE(union, b, 1)
CHECK_ALIGN(union, b, 1)
// Unnamed bit-field align
struct c {char x; int : 20;};
CHECK_SIZE(struct, c, 4)
CHECK_ALIGN(struct, c, 1)
union d {char x; int : 20;};
CHECK_SIZE(union, d, 3)
CHECK_ALIGN(union, d, 1)
// Bit-field packing
struct __attribute__((packed)) e {int x : 4, y : 30, z : 30;};
CHECK_SIZE(struct, e, 8)
CHECK_ALIGN(struct, e, 1)
// Alignment on bit-fields
struct f {__attribute((aligned(8))) int x : 30, y : 30, z : 30;};
CHECK_SIZE(struct, f, 24)
CHECK_ALIGN(struct, f, 8)
// Large structure (overflows i32, in bits).
struct s0 {
char a[0x32100000];
int x:30, y:30;
};
CHECK_SIZE(struct, s0, 0x32100008)
CHECK_ALIGN(struct, s0, 4)
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/darwin-align-cast.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
typedef long unsigned int __darwin_size_t;
typedef long __darwin_ssize_t;
typedef __darwin_size_t size_t;
typedef __darwin_ssize_t ssize_t;
struct cmsghdr {};
#if 0
This code below comes from the following system headers:
sys/socket.h:#define CMSG_SPACE(l) (__DARWIN_ALIGN(sizeof(struct
cmsghdr)) + __DARWIN_ALIGN(l))
i386/_param.h:#define __DARWIN_ALIGN(p) ((__darwin_size_t)((char *)(p)
+ __DARWIN_ALIGNBYTES) &~ __DARWIN_ALIGNBYTES)
#endif
ssize_t sendFileDescriptor(int fd, void *data, size_t nbytes, int sendfd) {
union {
char control[(((__darwin_size_t)((char *)(sizeof(struct cmsghdr)) + (sizeof(__darwin_size_t) - 1)) &~ (sizeof(__darwin_size_t) - 1)) + ((__darwin_size_t)((char *)(sizeof(int)) + (sizeof(__darwin_size_t) - 1)) &~ (sizeof(__darwin_size_t) - 1)))];
} control_un;
return 0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/decl-invalid.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify
// See Sema::ParsedFreeStandingDeclSpec about the double diagnostic
typedef union <anonymous> __mbstate_t; // expected-error {{declaration of anonymous union must be a definition}} expected-warning {{typedef requires a name}}
// PR2017
void x();
int a() {
int r[x()]; // expected-error {{size of array has non-integer type 'void'}}
static y ?; // expected-error{{unknown type name 'y'}} \
expected-error{{expected identifier or '('}}
}
int; // expected-warning {{declaration does not declare anything}}
typedef int; // expected-warning {{typedef requires a name}}
const int; // expected-warning {{declaration does not declare anything}}
struct; // expected-error {{declaration of anonymous struct must be a definition}} // expected-warning {{declaration does not declare anything}}
typedef int I;
I; // expected-warning {{declaration does not declare anything}}
// rdar://6880449
register int test1; // expected-error {{illegal storage class on file-scoped variable}}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.