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/arm-special-register.c
|
// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -triple arm %s
void string_literal(unsigned v) {
__builtin_arm_wsr(0, v); // expected-error {{expression is not a string literal}}
}
void wsr_1(unsigned v) {
__builtin_arm_wsr("sysreg", v);
}
void wsrp_1(void *v) {
__builtin_arm_wsrp("sysreg", v);
}
void wsr64_1(unsigned long v) {
__builtin_arm_wsr64("sysreg", v); //expected-error {{invalid special register for builtin}}
}
unsigned rsr_1() {
return __builtin_arm_rsr("sysreg");
}
void *rsrp_1() {
return __builtin_arm_rsrp("sysreg");
}
unsigned long rsr64_1() {
return __builtin_arm_rsr64("sysreg"); //expected-error {{invalid special register for builtin}}
}
void wsr_2(unsigned v) {
__builtin_arm_wsr("cp0:1:c2:c3:4", v);
}
void wsrp_2(void *v) {
__builtin_arm_wsrp("cp0:1:c2:c3:4", v);
}
void wsr64_2(unsigned long v) {
__builtin_arm_wsr64("cp0:1:c2:c3:4", v); //expected-error {{invalid special register for builtin}}
}
unsigned rsr_2() {
return __builtin_arm_rsr("cp0:1:c2:c3:4");
}
void *rsrp_2() {
return __builtin_arm_rsrp("cp0:1:c2:c3:4");
}
unsigned long rsr64_2() {
return __builtin_arm_rsr64("cp0:1:c2:c3:4"); //expected-error {{invalid special register for builtin}}
}
void wsr_3(unsigned v) {
__builtin_arm_wsr("cp0:1:c2", v); //expected-error {{invalid special register for builtin}}
}
void wsrp_3(void *v) {
__builtin_arm_wsrp("cp0:1:c2", v); //expected-error {{invalid special register for builtin}}
}
void wsr64_3(unsigned long v) {
__builtin_arm_wsr64("cp0:1:c2", v);
}
unsigned rsr_3() {
return __builtin_arm_rsr("cp0:1:c2"); //expected-error {{invalid special register for builtin}}
}
void *rsrp_3() {
return __builtin_arm_rsrp("cp0:1:c2"); //expected-error {{invalid special register for builtin}}
}
unsigned long rsr64_3() {
return __builtin_arm_rsr64("cp0:1:c2");
}
unsigned rsr_4() {
return __builtin_arm_rsr("0:1:2:3:4"); //expected-error {{invalid special register for builtin}}
}
void *rsrp_4() {
return __builtin_arm_rsrp("0:1:2:3:4"); //expected-error {{invalid special register for builtin}}
}
unsigned long rsr64_4() {
return __builtin_arm_rsr64("0:1:2"); //expected-error {{invalid special register for builtin}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-mode.c
|
// RUN: %clang_cc1 -triple i686-pc-linux-gnu -DTEST_32BIT_X86 -fsyntax-only \
// RUN: -verify %s
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -DTEST_64BIT_X86 -fsyntax-only \
// RUN: -verify %s
// RUN: %clang_cc1 -triple powerpc64-pc-linux-gnu -DTEST_64BIT_PPC64 -fsyntax-only \
// RUN: -verify %s
typedef int i16_1 __attribute((mode(HI)));
int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
typedef int i16_2 __attribute((__mode__(__HI__)));
int i16_2_test[sizeof(i16_1) == 2 ? 1 : -1];
typedef float f64 __attribute((mode(DF)));
int f64_test[sizeof(f64) == 8 ? 1 : -1];
typedef int invalid_1 __attribute((mode)); // expected-error{{'mode' attribute takes one argument}}
typedef int invalid_2 __attribute((mode())); // expected-error{{'mode' attribute takes one argument}}
typedef int invalid_3 __attribute((mode(II))); // expected-error{{unknown machine mode}}
typedef struct {int i,j,k;} invalid_4 __attribute((mode(SI))); // expected-error{{mode attribute only supported for integer and floating-point types}}
typedef float invalid_5 __attribute((mode(SI))); // expected-error{{type of machine mode does not match type of base type}}
typedef int invalid_6 __attribute__((mode(12))); // expected-error{{'mode' attribute requires an identifier}}
typedef unsigned unwind_word __attribute((mode(unwind_word)));
int **__attribute((mode(QI)))* i32; // expected-error{{mode attribute}}
typedef _Complex double c32 __attribute((mode(SC)));
int c32_test[sizeof(c32) == 8 ? 1 : -1];
typedef _Complex float c64 __attribute((mode(DC)));
#ifndef TEST_64BIT_PPC64 // Note, 'XC' mode is illegal for PPC64 machines.
typedef _Complex float c80 __attribute((mode(XC)));
#endif
// PR6108: Correctly select 'long' built in type on 64-bit platforms for 64 bit
// modes. Also test other mode-based conversions.
typedef int i8_mode_t __attribute__ ((__mode__ (__QI__)));
typedef unsigned int ui8_mode_t __attribute__ ((__mode__ (__QI__)));
typedef int i16_mode_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int ui16_mode_t __attribute__ ((__mode__ (__HI__)));
typedef int i32_mode_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int ui32_mode_t __attribute__ ((__mode__ (__SI__)));
typedef int i64_mode_t __attribute__ ((__mode__ (__DI__)));
typedef unsigned int ui64_mode_t __attribute__ ((__mode__ (__DI__)));
void f_i8_arg(i8_mode_t* x) { (void)x; }
void f_ui8_arg(ui8_mode_t* x) { (void)x; }
void f_i16_arg(i16_mode_t* x) { (void)x; }
void f_ui16_arg(ui16_mode_t* x) { (void)x; }
void f_i32_arg(i32_mode_t* x) { (void)x; }
void f_ui32_arg(ui32_mode_t* x) { (void)x; }
void f_i64_arg(i64_mode_t* x) { (void)x; }
void f_ui64_arg(ui64_mode_t* x) { (void)x; }
void test_char_to_i8(signed char* y) { f_i8_arg(y); }
void test_char_to_ui8(unsigned char* y) { f_ui8_arg(y); }
void test_short_to_i16(short* y) { f_i16_arg(y); }
void test_short_to_ui16(unsigned short* y) { f_ui16_arg(y); }
void test_int_to_i32(int* y) { f_i32_arg(y); }
void test_int_to_ui32(unsigned int* y) { f_ui32_arg(y); }
#if TEST_32BIT_X86
void test_long_to_i64(long long* y) { f_i64_arg(y); }
void test_long_to_ui64(unsigned long long* y) { f_ui64_arg(y); }
#elif TEST_64BIT_X86
void test_long_to_i64(long* y) { f_i64_arg(y); }
void test_long_to_ui64(unsigned long* y) { f_ui64_arg(y); }
typedef float f128ibm __attribute__ ((mode (TF))); // expected-error{{unsupported machine mode 'TF'}}
#elif TEST_64BIT_PPC64
typedef float f128ibm __attribute__ ((mode (TF)));
typedef _Complex float c128ibm __attribute__ ((mode (TC)));
void f_ft128_arg(long double *x);
void f_ft128_complex_arg(_Complex long double *x);
void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
#else
#error Unknown test architecture.
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-deprecated-message.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
// rdar: // 6734520
typedef int INT1 __attribute__((deprecated("Please avoid INT1"))); // expected-note 3 {{'INT1' has been explicitly marked deprecated here}}
typedef INT1 INT2 __attribute__ ((__deprecated__("Please avoid INT2")));
typedef INT1 INT1a; // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
typedef INT1 INT1b __attribute__ ((deprecated("Please avoid INT1b")));
INT1 should_be_unavailable; // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
INT1a should_not_be_deprecated;
INT1 f1(void) __attribute__ ((deprecated("Please avoid f1"))); // expected-note {{'f1' has been explicitly marked deprecated here}}
INT1 f2(void); // expected-warning {{'INT1' is deprecated: Please avoid INT1}}
typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color"))); // expected-note {{'Color' has been explicitly marked deprecated here}}
Color c1; // expected-warning {{'Color' is deprecated: Please avoid Color}}
int g1;
int g2 __attribute__ ((deprecated("Please avoid g2"))); // expected-note {{'g2' has been explicitly marked deprecated here}}
int func1()
{
int (*pf)() = f1; // expected-warning {{'f1' is deprecated: Please avoid f1}}
int i = f2();
return g1 + g2; // expected-warning {{'g2' is deprecated: Please avoid g2}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/overloadable-complex.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
char *foo(float) __attribute__((__overloadable__));
void test_foo_1(float fv, double dv, float _Complex fc, double _Complex dc) {
char *cp1 = foo(fv);
char *cp2 = foo(dv);
// Note: GCC and EDG reject these two, but they are valid C99 conversions
char *cp3 = foo(fc);
char *cp4 = foo(dc);
}
int *foo(float _Complex) __attribute__((__overloadable__));
void test_foo_2(float fv, double dv, float _Complex fc, double _Complex dc) {
char *cp1 = foo(fv);
char *cp2 = foo(dv);
int *ip = foo(fc);
int *lp = foo(dc);
}
long *foo(double _Complex) __attribute__((__overloadable__));
void test_foo_3(float fv, double dv, float _Complex fc, double _Complex dc) {
char *cp1 = foo(fv);
char *cp2 = foo(dv);
int *ip = foo(fc);
long *lp = foo(dc);
}
char *promote_or_convert(double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}}
int *promote_or_convert(long double _Complex) __attribute__((__overloadable__)); // expected-note 2 {{candidate function}}
void test_promote_or_convert(float f, float _Complex fc) {
char *cp = promote_or_convert(fc); // expected-error{{call to 'promote_or_convert' is ambiguous}}
int *ip2 = promote_or_convert(f); // expected-error{{call to 'promote_or_convert' is ambiguous}}
}
char *promote_or_convert2(float) __attribute__((__overloadable__));
int *promote_or_convert2(double _Complex) __attribute__((__overloadable__));
void test_promote_or_convert2(float _Complex fc) {
int *cp = promote_or_convert2(fc);
}
char *promote_or_convert3(int _Complex) __attribute__((__overloadable__));
int *promote_or_convert3(long _Complex) __attribute__((__overloadable__));
void test_promote_or_convert3(short _Complex sc) {
char *cp = promote_or_convert3(sc);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ms-wchar.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
// C++ mode with -fno-wchar works the same as C mode for wchar_t.
// RUN: %clang_cc1 -x c++ -fno-wchar -fsyntax-only -verify -fms-extensions -triple i386-pc-win32 %s
wchar_t f(); // expected-error{{unknown type name 'wchar_t'}}
// __wchar_t is available as an MS extension.
__wchar_t g = L'a'; // expected-note {{previous}}
// __wchar_t is a distinct type, separate from the target's integer type for wide chars.
unsigned short g; // expected-error {{redefinition of 'g' with a different type: 'unsigned short' vs '__wchar_t'}}
// The type of a wide string literal is actually not __wchar_t.
__wchar_t s[] = L"Hello world!"; // expected-error-re {{array initializer must be an initializer list{{$}}}}
// Do not suggest initializing with a string here, because it would not work.
__wchar_t t[] = 1; // expected-error-re {{array initializer must be an initializer list{{$}}}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/tls_alignment.cpp
|
// TLS variable cannot be aligned to more than 32 bytes on PS4.
// RUN: %clang_cc1 -triple x86_64-scei-ps4 -fsyntax-only -verify %s
// A non-aligned type.
struct non_aligned_struct {
int some_data[16]; // 64 bytes of stuff, non aligned.
};
// An aligned type.
struct __attribute__(( aligned(64) )) aligned_struct {
int some_data[12]; // 48 bytes of stuff, aligned to 64.
};
// A type with an aligned field.
struct struct_with_aligned_field {
int some_aligned_data[12] __attribute__(( aligned(64) )); // 48 bytes of stuff, aligned to 64.
};
// A typedef of the aligned struct.
typedef aligned_struct another_aligned_struct;
// A typedef to redefine a non-aligned struct as aligned.
typedef __attribute__(( aligned(64) )) non_aligned_struct yet_another_aligned_struct;
// Non aligned variable doesn't cause an error.
__thread non_aligned_struct foo;
// Variable aligned because of its type should cause an error.
__thread aligned_struct bar; // expected-error{{alignment (64) of thread-local variable}}
// Variable explicitly aligned in the declaration should cause an error.
__thread non_aligned_struct bar2 __attribute__(( aligned(64) )); // expected-error{{alignment (64) of thread-local variable}}
// Variable aligned because of one of its fields should cause an error.
__thread struct_with_aligned_field bar3; // expected-error{{alignment (64) of thread-local variable}}
// Variable aligned because of typedef, first case.
__thread another_aligned_struct bar4; // expected-error{{alignment (64) of thread-local variable}}
// Variable aligned because of typedef, second case.
__thread yet_another_aligned_struct bar5; // expected-error{{alignment (64) of thread-local variable}}
int baz ()
{
return foo.some_data[0] + bar.some_data[1] + bar2.some_data[2] +
bar3.some_aligned_data[3] + bar4.some_data[4] +
bar5.some_data[5];
}
// Verify alignment check where a dependent type is involved.
// The check is (correctly) not performed on "t", but the check still is
// performed on the structure as a whole once it has been instantiated.
template<class T> struct templated_tls {
static __thread T t;
T other_t __attribute__(( aligned(64) ));
};
__thread templated_tls<int> blah; // expected-error{{alignment (64) of thread-local variable}}
int blag() {
return blah.other_t * 2;
}
// Verify alignment check where the alignment is a template parameter.
// The check is only performed during instantiation.
template <int N>
struct S {
static int __thread __attribute__((aligned(N))) x; // expected-error{{alignment (64) of thread-local variable}}
};
S<64> s_instance; // expected-note{{in instantiation of template class 'S<64>' requested here}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-scanf.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s
// Test that -Wformat=0 works:
// RUN: %clang_cc1 -fsyntax-only -Werror -Wformat=0 %s
#include <stdarg.h>
typedef __typeof(sizeof(int)) size_t;
typedef struct _FILE FILE;
typedef __WCHAR_TYPE__ wchar_t;
int fscanf(FILE * restrict, const char * restrict, ...) ;
int scanf(const char * restrict, ...) ;
int sscanf(const char * restrict, const char * restrict, ...) ;
int my_scanf(const char * restrict, ...) __attribute__((__format__(__scanf__, 1, 2)));
int vscanf(const char * restrict, va_list);
int vfscanf(FILE * restrict, const char * restrict, va_list);
int vsscanf(const char * restrict, const char * restrict, va_list);
void test(const char *s, int *i) {
scanf(s, i); // expected-warning{{ormat string is not a string literal}}
scanf("%0d", i); // expected-warning{{zero field width in scanf format string is unused}}
scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}}
scanf("%d%[asdfasdfd", i, s); // expected-warning{{no closing ']' for '%[' in scanf format string}}
unsigned short s_x;
scanf ("%" "hu" "\n", &s_x); // no-warning
scanf("%y", i); // expected-warning{{invalid conversion specifier 'y'}}
scanf("%%"); // no-warning
scanf("%%%1$d", i); // no-warning
scanf("%1$d%%", i); // no-warning
scanf("%d", i, i); // expected-warning{{data argument not used by format string}}
scanf("%*d", i); // // expected-warning{{data argument not used by format string}}
scanf("%*d", i); // // expected-warning{{data argument not used by format string}}
scanf("%*d%1$d", i); // no-warning
scanf("%s", (char*)0); // no-warning
scanf("%s", (volatile char*)0); // no-warning
scanf("%s", (signed char*)0); // no-warning
scanf("%s", (unsigned char*)0); // no-warning
scanf("%hhu", (signed char*)0); // no-warning
}
void bad_length_modifiers(char *s, void *p, wchar_t *ws, long double *ld) {
scanf("%hhs", "foo"); // expected-warning{{length modifier 'hh' results in undefined behavior or no effect with 's' conversion specifier}}
scanf("%1$zp", &p); // expected-warning{{length modifier 'z' results in undefined behavior or no effect with 'p' conversion specifier}}
scanf("%ls", ws); // no-warning
scanf("%#.2Lf", ld); // expected-warning{{invalid conversion specifier '#'}}
}
// Test that the scanf call site is where the warning is attached. If the
// format string is somewhere else, point to it in a note.
void pr9751() {
int *i;
char str[100];
const char kFormat1[] = "%00d"; // expected-note{{format string is defined here}}}
scanf(kFormat1, i); // expected-warning{{zero field width in scanf format string is unused}}
scanf("%00d", i); // expected-warning{{zero field width in scanf format string is unused}}
const char kFormat2[] = "%["; // expected-note{{format string is defined here}}}
scanf(kFormat2, str); // expected-warning{{no closing ']' for '%[' in scanf format string}}
scanf("%[", str); // expected-warning{{no closing ']' for '%[' in scanf format string}}
const char kFormat3[] = "%hu"; // expected-note{{format string is defined here}}}
scanf(kFormat3, &i); // expected-warning {{format specifies type 'unsigned short *' but the argument}}
const char kFormat4[] = "%lp"; // expected-note{{format string is defined here}}}
scanf(kFormat4, &i); // expected-warning {{length modifier 'l' results in undefined behavior or no effect with 'p' conversion specifier}}
}
void test_variants(int *i, const char *s, ...) {
FILE *f = 0;
char buf[100];
fscanf(f, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
sscanf(buf, "%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
my_scanf("%ld", i); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
va_list ap;
va_start(ap, s);
vscanf("%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
vfscanf(f, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
vsscanf(buf, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
}
void test_scanlist(int *ip, char *sp, wchar_t *ls) {
scanf("%[abc]", ip); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}}
scanf("%h[abc]", sp); // expected-warning{{length modifier 'h' results in undefined behavior or no effect with '[' conversion specifier}}
scanf("%l[xyx]", ls); // no-warning
scanf("%ll[xyx]", ls); // expected-warning {{length modifier 'll' results in undefined behavior or no effect with '[' conversion specifier}}
// PR19559
scanf("%[]% ]", sp); // no-warning
scanf("%[^]% ]", sp); // no-warning
scanf("%[a^]% ]", sp); // expected-warning {{invalid conversion specifier ' '}}
}
void test_alloc_extension(char **sp, wchar_t **lsp, float *fp) {
/* Make sure "%a" gets parsed as a conversion specifier for float,
* even when followed by an 's', 'S' or '[', which would cause it to be
* parsed as a length modifier in C90. */
scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
scanf("%aS", lsp); // expected-warning{{format specifies type 'float *' but the argument has type 'wchar_t **'}}
scanf("%a[bcd]", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
// Test that the 'm' length modifier is only allowed with s, S, c, C or [.
// TODO: Warn that 'm' is an extension.
scanf("%ms", sp); // No warning.
scanf("%mS", lsp); // No warning.
scanf("%mc", sp); // No warning.
scanf("%mC", lsp); // No warning.
scanf("%m[abc]", sp); // No warning.
scanf("%md", sp); // expected-warning{{length modifier 'm' results in undefined behavior or no effect with 'd' conversion specifier}}
// Test argument type check for the 'm' length modifier.
scanf("%ms", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
scanf("%mS", fp); // expected-warning-re{{format specifies type 'wchar_t **' (aka '{{[^']+}}') but the argument has type 'float *'}}
scanf("%mc", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
scanf("%mC", fp); // expected-warning-re{{format specifies type 'wchar_t **' (aka '{{[^']+}}') but the argument has type 'float *'}}
scanf("%m[abc]", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
}
void test_quad(int *x, long long *llx) {
scanf("%qd", x); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
scanf("%qd", llx); // no-warning
}
void test_writeback(int *x) {
scanf("%n", (void*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'void *'}}
scanf("%n %c", x, x); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}}
scanf("%hhn", (signed char*)0); // no-warning
scanf("%hhn", (char*)0); // no-warning
scanf("%hhn", (unsigned char*)0); // no-warning
scanf("%hhn", (int*)0); // expected-warning{{format specifies type 'signed char *' but the argument has type 'int *'}}
scanf("%hn", (short*)0); // no-warning
scanf("%hn", (unsigned short*)0); // no-warning
scanf("%hn", (int*)0); // expected-warning{{format specifies type 'short *' but the argument has type 'int *'}}
scanf("%n", (int*)0); // no-warning
scanf("%n", (unsigned int*)0); // no-warning
scanf("%n", (char*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}}
scanf("%ln", (long*)0); // no-warning
scanf("%ln", (unsigned long*)0); // no-warning
scanf("%ln", (int*)0); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}}
scanf("%lln", (long long*)0); // no-warning
scanf("%lln", (unsigned long long*)0); // no-warning
scanf("%lln", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
scanf("%qn", (long long*)0); // no-warning
scanf("%qn", (unsigned long long*)0); // no-warning
scanf("%qn", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}}
}
void test_qualifiers(const int *cip, volatile int* vip,
const char *ccp, volatile char* vcp,
const volatile int *cvip) {
scanf("%d", cip); // expected-warning{{format specifies type 'int *' but the argument has type 'const int *'}}
scanf("%n", cip); // expected-warning{{format specifies type 'int *' but the argument has type 'const int *'}}
scanf("%s", ccp); // expected-warning{{format specifies type 'char *' but the argument has type 'const char *'}}
scanf("%d", cvip); // expected-warning{{format specifies type 'int *' but the argument has type 'const volatile int *'}}
scanf("%d", vip); // No warning.
scanf("%n", vip); // No warning.
scanf("%c", vcp); // No warning.
typedef int* ip_t;
typedef const int* cip_t;
scanf("%d", (ip_t)0); // No warning.
scanf("%d", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/gnu-attributes.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
struct s {};
// FIXME: should warn that declaration attribute in type position is
// being applied to the declaration instead?
struct s __attribute__((used)) foo;
// FIXME: Should warn that type attribute in declaration position is
// being applied to the type instead?
struct s *bar __attribute__((address_space(1)));
// Should not warn because type attribute is in type position.
struct s *__attribute__((address_space(1))) baz;
// Should not warn because declaration attribute is in declaration position.
struct s *quux __attribute__((used));
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-unused-variables.c
|
// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -fblocks -verify %s
struct s0 {
unsigned int i;
};
int proto(int a, int b);
void f0(void) {
int a __attribute__((unused)),
b; // expected-warning{{unused}}
return;
}
void f1(void) {
int i;
(void)sizeof(i);
return;
}
// PR5933
int f2() {
int X = 4; // Shouldn't have a bogus 'unused variable X' warning.
return Y + X; // expected-error {{use of undeclared identifier 'Y'}}
}
int f3() {
int X1 = 4;
(void)(Y1 + X1); // expected-error {{use of undeclared identifier 'Y1'}}
(void)(^() { int X = 4; }); // expected-warning{{unused}}
(void)(^() { int X = 4; return Y + X; }); // expected-error {{use of undeclared identifier 'Y'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/uninit-det-order.c
|
// RUN: %clang_cc1 -Wuninitialized -fsyntax-only %s 2>&1 | FileCheck %s
void pr14901(int a) {
int b, c;
a = b;
a = c;
}
// CHECK: 5:8: warning: variable 'b' is uninitialized when used here
// CHECK: 4:9: note: initialize the variable 'b' to silence this warning
// CHECK: 6:8: warning: variable 'c' is uninitialized when used here
// CHECK: 4:12: note: initialize the variable 'c' to silence this warning
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/crash-invalid-builtin.c
|
// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
// PR23086
__builtin_isinf(...); // expected-warning {{type specifier missing, defaults to 'int'}} expected-error {{ISO C requires a named parameter before '...'}} // expected-error {{conflicting types for '__builtin_isinf'}} // expected-note {{'__builtin_isinf' is a builtin with type 'int ()'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-section.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32
#pragma const_seg(".my_const") // expected-note 2 {{#pragma entered here}}
extern const int a;
const int a = 1; // expected-note 2 {{declared here}}
#pragma data_seg(".my_const") // expected-note {{#pragma entered here}}
int b = 1; // expected-error {{'b' causes a section type conflict with 'a'}}
#pragma data_seg()
int c = 1;
__declspec(allocate(".my_const")) int d = 1; // expected-error {{'d' causes a section type conflict with 'a'}}
#pragma data_seg("\u") // expected-error {{\u used with no following hex digits}}
#pragma data_seg("a" L"b") // expected-warning {{expected non-wide string literal in '#pragma data_seg'}}
#pragma section(".my_seg", execute) // expected-note 2 {{#pragma entered her}}
__declspec(allocate(".my_seg")) int int_my_seg;
#pragma code_seg(".my_seg")
void fn_my_seg(void){}
__declspec(allocate(".bad_seg")) int int_bad_seg = 1; // expected-note {{declared here}}
#pragma code_seg(".bad_seg") // expected-note {{#pragma entered here}}
void fn_bad_seg(void){} // expected-error {{'fn_bad_seg' causes a section type conflict with 'int_bad_seg'}}
#pragma bss_seg // expected-warning {{missing '(' after '#pragma bss_seg' - ignoring}}
#pragma bss_seg(L".my_seg") // expected-warning {{expected push, pop or a string literal for the section name in '#pragma bss_seg' - ignored}}
#pragma bss_seg(1) // expected-warning {{expected push, pop or a string literal for the section name in '#pragma bss_seg' - ignored}}
#pragma bss_seg(push)
#pragma bss_seg(push, ".my_seg")
#pragma bss_seg(push, 1) // expected-warning {{expected a stack label or a string literal for the section name in '#pragma bss_seg'}}
#pragma bss_seg ".my_seg" // expected-warning {{missing '(' after '#pragma bss_seg' - ignoring}}
#pragma bss_seg(push, my_label, 1) // expected-warning {{expected a string literal for the section name in '#pragma bss_seg' - ignored}}
#pragma bss_seg(".my_seg", 1) // expected-warning {{missing ')' after '#pragma bss_seg' - ignoring}}
#pragma bss_seg(".my_seg" // expected-warning {{missing ')' after '#pragma bss_seg' - ignoring}}
#pragma section // expected-warning {{missing '(' after '#pragma section' - ignoring}}
#pragma section( // expected-warning {{expected a string literal for the section name in '#pragma section' - ignored}}
#pragma section(L".my_seg") // expected-warning {{expected a string literal for the section name in '#pragma section' - ignored}}
#pragma section(".my_seg" // expected-warning {{missing ')' after '#pragma section' - ignoring}}
#pragma section(".my_seg" 1 // expected-warning {{missing ')' after '#pragma section' - ignoring}}
#pragma section(".my_seg", // expected-warning {{expected action or ')' in '#pragma section' - ignored}}
#pragma section(".my_seg", read) // expected-error {{this causes a section type conflict with a prior #pragma section}}
#pragma section(".my_seg", bogus) // expected-warning {{unknown action 'bogus' for '#pragma section' - ignored}}
#pragma section(".my_seg", nopage) // expected-warning {{known but unsupported action 'nopage' for '#pragma section' - ignored}}
#pragma section(".my_seg", read, write) // expected-error {{this causes a section type conflict with a prior #pragma section}}
#pragma section(".my_seg", read, write, 1) // expected-warning {{expected action or ')' in '#pragma section' - ignored}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-pack.c
|
// RUN: %clang_cc1 -triple i686-apple-darwin9 -fsyntax-only -verify %s
/* expected-warning {{value of #pragma pack(show) == 8}} */ #pragma pack(show)
/* expected-warning {{expected #pragma pack parameter to be}} */ #pragma pack(3)
/* expected-warning {{value of #pragma pack(show) == 8}} */ #pragma pack(show)
#pragma pack(4)
/* expected-warning {{value of #pragma pack(show) == 4}} */ #pragma pack(show)
#pragma pack() // resets to default
/* expected-warning {{value of #pragma pack(show) == 8}} */ #pragma pack(show)
#pragma pack(2)
#pragma pack(push, eek, 16) // -> (eek, 2), 16
/* expected-warning {{value of #pragma pack(show) == 16}} */ #pragma pack(show)
#pragma pack(push) // -> (eek, 2), (, 2), 16
/* expected-warning {{value of #pragma pack(show) == 16}} */ #pragma pack(show)
#pragma pack(1)
#pragma pack(push, 8) // -> (eek, 2), (, 2), (, 1), 8
/* expected-warning {{value of #pragma pack(show) == 8}} */ #pragma pack(show)
#pragma pack(pop) // -> (eek, 2), (,2), 1
/* expected-warning {{value of #pragma pack(show) == 1}} */ #pragma pack(show)
#pragma pack(pop, eek)
/* expected-warning {{value of #pragma pack(show) == 2}} */ #pragma pack(show)
/* expected-warning {{pack(pop, ...) failed: stack empty}} */ #pragma pack(pop)
#pragma pack(push)
#pragma pack(pop, 16)
/* expected-warning {{value of #pragma pack(show) == 16}} */ #pragma pack(show)
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-deprecated.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
int f() __attribute__((deprecated)); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
void g() __attribute__((deprecated));
void g(); // expected-note {{'g' has been explicitly marked deprecated here}}
extern int var __attribute__((deprecated)); // expected-note {{'var' has been explicitly marked deprecated here}}
int a() {
int (*ptr)() = f; // expected-warning {{'f' is deprecated}}
f(); // expected-warning {{'f' is deprecated}}
// test if attributes propagate to functions
g(); // expected-warning {{'g' is deprecated}}
return var; // expected-warning {{'var' is deprecated}}
}
// test if attributes propagate to variables
extern int var; // expected-note {{'var' has been explicitly marked deprecated here}}
int w() {
return var; // expected-warning {{'var' is deprecated}}
}
int old_fn() __attribute__ ((deprecated));
int old_fn(); // expected-note {{'old_fn' has been explicitly marked deprecated here}}
int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}}
int old_fn() {
return old_fn()+1; // no warning, deprecated functions can use deprecated symbols.
}
struct foo {
int x __attribute__((deprecated)); // expected-note 3 {{'x' has been explicitly marked deprecated here}}
};
void test1(struct foo *F) {
++F->x; // expected-warning {{'x' is deprecated}}
struct foo f1 = { .x = 17 }; // expected-warning {{'x' is deprecated}}
struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}}
}
typedef struct foo foo_dep __attribute__((deprecated)); // expected-note 12 {{'foo_dep' has been explicitly marked deprecated here}}
foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}}
struct __attribute__((deprecated,
invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} expected-note 2 {{'bar_dep' has been explicitly marked deprecated here}}
struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}}
// These should not warn because the actually declaration itself is deprecated.
// rdar://6756623
foo_dep *test4 __attribute__((deprecated));
struct bar_dep *test5 __attribute__((deprecated));
typedef foo_dep test6(struct bar_dep*); // expected-warning {{'foo_dep' is deprecated}} \
// expected-warning {{'bar_dep' is deprecated}}
typedef foo_dep test7(struct bar_dep*) __attribute__((deprecated));
int test8(char *p) {
p += sizeof(foo_dep); // expected-warning {{'foo_dep' is deprecated}}
foo_dep *ptr; // expected-warning {{'foo_dep' is deprecated}}
ptr = (foo_dep*) p; // expected-warning {{'foo_dep' is deprecated}}
int func(foo_dep *foo); // expected-warning {{'foo_dep' is deprecated}}
return func(ptr);
}
foo_dep *test9(void) __attribute__((deprecated));
foo_dep *test9(void) {
void* myalloc(unsigned long);
foo_dep *ptr
= (foo_dep*)
myalloc(sizeof(foo_dep));
return ptr;
}
void test10(void) __attribute__((deprecated));
void test10(void) {
if (sizeof(foo_dep) == sizeof(void*)) {
}
foo_dep *localfunc(void);
foo_dep localvar;
}
char test11[sizeof(foo_dep)] __attribute__((deprecated));
char test12[sizeof(foo_dep)]; // expected-warning {{'foo_dep' is deprecated}}
int test13(foo_dep *foo) __attribute__((deprecated));
int test14(foo_dep *foo); // expected-warning {{'foo_dep' is deprecated}}
unsigned long test15 = sizeof(foo_dep); // expected-warning {{'foo_dep' is deprecated}}
unsigned long test16 __attribute__((deprecated))
= sizeof(foo_dep);
foo_dep test17, // expected-warning {{'foo_dep' is deprecated}}
test18 __attribute__((deprecated)),
test19;
// rdar://problem/8518751
enum __attribute__((deprecated)) Test20 { // expected-note {{'Test20' has been explicitly marked deprecated here}}
test20_a __attribute__((deprecated)), // expected-note {{'test20_a' has been explicitly marked deprecated here}}
test20_b // expected-note {{'test20_b' has been explicitly marked deprecated here}}
};
void test20() {
enum Test20 f; // expected-warning {{'Test20' is deprecated}}
f = test20_a; // expected-warning {{'test20_a' is deprecated}}
f = test20_b; // expected-warning {{'test20_b' is deprecated}}
}
char test21[__has_feature(attribute_deprecated_with_message) ? 1 : -1];
struct test22 {
foo_dep a __attribute((deprecated));
foo_dep b; // expected-warning {{'foo_dep' is deprecated}}
foo_dep c, d __attribute((deprecated)); // expected-warning {{'foo_dep' is deprecated}}
__attribute((deprecated)) foo_dep e, f;
};
typedef int test23_ty __attribute((deprecated));
typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}}
test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-args.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks
void take(void*);
void test() {
take(^(int x){});
take(^(int x, int y){});
take(^(int x, int y){});
take(^(int x, // expected-note {{previous declaration is here}}
int x){}); // expected-error {{redefinition of parameter 'x'}}
take(^(int x) { return x+1; });
int (^CP)(int) = ^(int x) { return x*x; };
take(CP);
int arg;
^{return 1;}();
^{return 2;}(arg); // expected-error {{too many arguments to block call}}
^(void){return 3;}(1); // expected-error {{too many arguments to block call}}
^(){return 4;}(arg); // expected-error {{too many arguments to block call}}
^(int x, ...){return 5;}(arg, arg); // Explicit varargs, ok.
}
int main(int argc, char** argv) {
^(int argCount) {
argCount = 3;
}(argc);
}
// radar 7528255
void f0() {
^(int, double d, char) {}(1, 1.34, 'a'); // expected-error {{parameter name omitted}} \
// expected-error {{parameter name omitted}}
}
// rdar://problem/8962770
void test4() {
int (^f)() = ^((x)) { }; // expected-error {{expected ')'}} expected-warning {{type specifier missing}} expected-note {{to match this}}
}
// rdar://problem/9170609
void test5_helper(void (^)(int, int[*]));
void test5(void) {
test5_helper(^(int n, int array[n]) {});
}
// Reduced from a problem on platforms where va_list is an array.
struct tag {
int x;
};
typedef struct tag array_ty[1];
void test6(void) {
void (^block)(array_ty) = ^(array_ty arr) { };
array_ty arr;
block(arr);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/address-constant.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
int i;
int a[] = {0};
struct { int i; } s;
int *array[] = {&i, a, &s.i};
extern void f(void);
void (*f_addr)(void) = &f;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/declspec.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
typedef char T[4];
T foo(int n, int m) { } // expected-error {{cannot return array type}}
void foof(const char *, ...) __attribute__((__format__(__printf__, 1, 2))), barf (void);
int typedef validTypeDecl() { } // expected-error {{function definition declared 'typedef'}}
struct _zend_module_entry { } // expected-error {{expected ';' after struct}}
int gv1;
typedef struct _zend_function_entry { } // expected-error {{expected ';' after struct}} \
// expected-warning {{typedef requires a name}}
int gv2;
static void buggy(int *x) { }
// Type qualifiers.
typedef int f(void);
typedef f* fptr;
const f* v1; // expected-warning {{qualifier on function type 'f' (aka 'int (void)') has unspecified behavior}}
__restrict__ f* v2; // expected-error {{restrict requires a pointer or reference ('f' (aka 'int (void)') is invalid)}}
__restrict__ fptr v3; // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
f *__restrict__ v4; // expected-error {{pointer to function type 'f' (aka 'int (void)') may not be 'restrict' qualified}}
restrict struct hallo; // expected-error {{restrict requires a pointer or reference}}
// PR6180
struct test1 {
} // expected-error {{expected ';' after struct}}
void test2() {}
// PR6423
struct test3s {
} // expected-error {{expected ';' after struct}}
typedef int test3g;
// PR8264
const const int pr8264_1 = 0; // expected-warning {{duplicate 'const' declaration specifier}}
volatile volatile int pr8264_2; // expected-warning {{duplicate 'volatile' declaration specifier}}
char * restrict restrict pr8264_3; // expected-warning {{duplicate 'restrict' declaration specifier}}
extern extern int pr8264_4; // expected-warning {{duplicate 'extern' declaration specifier}}
void pr8264_5() {
register register int x; // expected-warning {{duplicate 'register' declaration specifier}}
}
inline inline void pr8264_6() {} // expected-warning {{duplicate 'inline' declaration specifier}}
_Noreturn _Noreturn void pr8264_7(); // expected-warning {{duplicate '_Noreturn' declaration specifier}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/array-constraint.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
struct s; // expected-note 2 {{forward declaration of 'struct s'}}
struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}}
return z;
}
void ff() {
struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}}
p = &v;
}
void *k (void l[2]) { // expected-error {{array has incomplete element type}}
return l;
}
struct vari {
int a;
int b[];
};
struct vari *func(struct vari a[]) { // expected-warning {{'struct vari' may not be used as an array element due to flexible array member}}
return a;
}
int foo[](void); // expected-error {{'foo' declared as array of functions}}
int foo2[1](void); // expected-error {{'foo2' declared as array of functions}}
typedef int (*pfunc)(void);
pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}}
return f;
}
void check_size() {
float f;
int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}}
int negative_size[1-2]; // expected-error{{array with a negative size}}
int zero_size[0]; // expected-warning{{zero size arrays are an extension}}
}
static int I;
typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}}
void strFunc(char *); // expected-note{{passing argument to parameter here}}
const char staticAry[] = "test";
void checkStaticAry() {
strFunc(staticAry); // expected-warning{{passing 'const char [5]' to parameter of type 'char *' discards qualifiers}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/ext_vector_comparisons.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unreachable-code %s
typedef __attribute__(( ext_vector_type(4) )) int int4;
static int4 test1() {
int4 vec, rv;
// comparisons to self...
return vec == vec; // expected-warning{{self-comparison always evaluates to a constant}}
return vec != vec; // expected-warning{{self-comparison always evaluates to a constant}}
return vec < vec; // expected-warning{{self-comparison always evaluates to a constant}}
return vec <= vec; // expected-warning{{self-comparison always evaluates to a constant}}
return vec > vec; // expected-warning{{self-comparison always evaluates to a constant}}
return vec >= vec; // expected-warning{{self-comparison always evaluates to a constant}}
}
typedef __attribute__(( ext_vector_type(4) )) float float4;
static int4 test2() {
float4 vec, rv;
// comparisons to self. no warning, they're floats
return vec == vec; // no-warning
return vec != vec; // no-warning
return vec < vec; // no-warning
return vec <= vec; // no-warning
return vec > vec; // no-warning
return vec >= vec; // no-warning
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/gnu-flags.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
// RUN: -Wgnu-alignof-expression -Wgnu-case-range -Wgnu-complex-integer -Wgnu-conditional-omitted-operand \
// RUN: -Wgnu-empty-initializer -Wgnu-label-as-value -Wgnu-statement-expression \
// RUN: -Wgnu-compound-literal-initializer -Wgnu-flexible-array-initializer \
// RUN: -Wgnu-redeclared-enum -Wgnu-folding-constant -Wgnu-empty-struct \
// RUN: -Wgnu-union-cast -Wgnu-variable-sized-type-not-at-end
// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
// RUN: -Wno-gnu-alignof-expression -Wno-gnu-case-range -Wno-gnu-complex-integer -Wno-gnu-conditional-omitted-operand \
// RUN: -Wno-gnu-empty-initializer -Wno-gnu-label-as-value -Wno-gnu-statement-expression \
// RUN: -Wno-gnu-compound-literal-initializer -Wno-gnu-flexible-array-initializer \
// RUN: -Wno-gnu-redeclared-enum -Wno-gnu-folding-constant -Wno-gnu-empty-struct \
// RUN: -Wno-gnu-union-cast -Wno-gnu-variable-sized-type-not-at-end
// Additional disabled tests:
// %clang_cc1 -fsyntax-only -verify %s -DALIGNOF -Wno-gnu -Wgnu-alignof-expression
// %clang_cc1 -fsyntax-only -verify %s -DCASERANGE -Wno-gnu -Wgnu-case-range
// %clang_cc1 -fsyntax-only -verify %s -DCOMPLEXINT -Wno-gnu -Wgnu-complex-integer
// %clang_cc1 -fsyntax-only -verify %s -DOMITTEDOPERAND -Wno-gnu -Wgnu-conditional-omitted-operand
// %clang_cc1 -fsyntax-only -verify %s -DEMPTYINIT -Wno-gnu -Wgnu-empty-initializer
// %clang_cc1 -fsyntax-only -verify %s -DLABELVALUE -Wno-gnu -Wgnu-label-as-value
// %clang_cc1 -fsyntax-only -verify %s -DSTATEMENTEXP -Wno-gnu -Wgnu-statement-expression
// %clang_cc1 -fsyntax-only -verify %s -DCOMPOUNDLITERALINITIALIZER -Wno-gnu -Wgnu-compound-literal-initializer
// %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYINITIALIZER -Wno-gnu -Wgnu-flexible-array-initializer
// %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDENUM -Wno-gnu -Wgnu-redeclared-enum
// %clang_cc1 -fsyntax-only -verify %s -DUNIONCAST -Wno-gnu -Wgnu-union-cast
// %clang_cc1 -fsyntax-only -verify %s -DVARIABLESIZEDTYPENOTATEND -Wno-gnu -Wgnu-variable-sized-type-not-at-end
// %clang_cc1 -fsyntax-only -verify %s -DFOLDINGCONSTANT -Wno-gnu -Wgnu-folding-constant
// %clang_cc1 -fsyntax-only -verify %s -DEMPTYSTRUCT -Wno-gnu -Wgnu-empty-struct
#if NONE
// expected-no-diagnostics
#endif
#if ALL || ALIGNOF
// expected-warning@+4 {{'_Alignof' applied to an expression is a GNU extension}}
#endif
char align;
_Static_assert(_Alignof(align) > 0, "align's alignment is wrong");
#if ALL || CASERANGE
// expected-warning@+5 {{use of GNU case range extension}}
#endif
void caserange(int x) {
switch (x) {
case 42 ... 44: ;
}
}
#if ALL || COMPLEXINT
// expected-warning@+3 {{complex integer types are a GNU extension}}
#endif
_Complex short int complexint;
#if ALL || OMITTEDOPERAND
// expected-warning@+3 {{use of GNU ?: conditional expression extension, omitting middle operand}}
#endif
static const char* omittedoperand = (const char*)0 ?: "Null";
#if ALL || EMPTYINIT
// expected-warning@+3 {{use of GNU empty initializer extension}}
#endif
struct { int x; } emptyinit = {};
#if ALL || LABELVALUE
// expected-warning@+6 {{use of GNU address-of-label extension}}
// expected-warning@+7 {{use of GNU indirect-goto extension}}
#endif
void labelvalue() {
void *ptr;
ptr = &&foo;
foo:
goto *ptr;
}
#if ALL || STATEMENTEXP
// expected-warning@+5 {{use of GNU statement expression extension}}
#endif
void statementexp()
{
int a = ({ 1; });
}
#if ALL || COMPOUNDLITERALINITIALIZER
// expected-warning@+4 {{initialization of an array of type 'int [5]' from a compound literal of type 'int [5]' is a GNU extension}}
#endif
typedef int int5[5];
int cli[5] = (int[]){1, 2, 3, 4, 5};
#if ALL || FLEXIBLEARRAYINITIALIZER
// expected-note@+6 {{initialized flexible array member 'y' is here}}
// expected-warning@+6 {{flexible array initialization is a GNU extension}}
#endif
struct fai {
int x;
int y[];
} fai = { 1, { 2, 3, 4 } };
#if ALL || FOLDINGCONSTANT
// expected-warning@+5 {{expression is not an integer constant expression; folding it to a constant is a GNU extension}}
// expected-warning@+7 {{variable length array folded to constant array as an extension}}
#endif
enum {
fic = (int)(0.75 * 1000 * 1000)
};
static const int size = 100;
void foo(void) { int data[size]; }
#if ALL || REDECLAREDENUM
// expected-note@+4 {{previous definition is here}}
// expected-warning@+8 {{redeclaration of already-defined enum 'RE' is a GNU extension}}
#endif
enum RE {
Val1,
Val2
};
enum RE;
#if ALL || UNIONCAST
// expected-warning@+4 {{cast to union type is a GNU extension}}
#endif
union uc { int i; unsigned : 3; };
union uc w = (union uc)2;
#if ALL || VARIABLESIZEDTYPENOTATEND
// expected-warning@+8 {{field 'hdr' with variable sized type 'struct vst' not at the end of a struct or class is a GNU extension}}
#endif
struct vst {
short tag_type;
char tag_data[];
};
struct vstnae {
struct vst hdr;
char data;
};
#if ALL || EMPTYSTRUCT
// expected-warning@+4 {{empty struct is a GNU extension}}
// expected-warning@+4 {{struct without named members is a GNU extension}}
#endif
const struct {} es;
struct {int:5;} swnm;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-sentinel-attribute.c
|
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
void (^e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
int main() {
void (^bbad) (int arg, const char * format) __attribute__ ((__sentinel__)) ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}}
bbad = ^void (int arg, const char * format) __attribute__ ((__sentinel__)) {} ; // expected-warning {{'sentinel' attribute only supported for variadic blocks}}
void (^b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)) = // expected-note {{block has been explicitly marked sentinel here}}
^ __attribute__ ((__sentinel__)) (int arg, const char * format, ...) {};
void (^z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))) = ^ __attribute__ ((__sentinel__ (2))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
void (^y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))) = ^ __attribute__ ((__sentinel__ (5))) (int arg, const char * format, ...) {}; // expected-note {{block has been explicitly marked sentinel here}}
b(1, "%s", (void*)0); // OK
b(1, "%s", 0); // expected-warning {{missing sentinel in block call}}
z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in block call}}
z(1, "%s", (void*)0, 1, 0); // OK
y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in block call}}
y(1, "%s", (void*)0,3,4,5,6,7); // OK
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/enum-packed.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
// PR7477
enum __attribute__((packed)) E {
Ea, Eb, Ec, Ed
};
void test_E(enum E e) {
switch (e) {
case Ea:
case Eb:
case Ec:
case Ed:
break;
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-naked.cpp
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -triple arm-none-linux
class Foo {
void bar();
static void bar2();
unsigned v;
static unsigned s;
};
void __attribute__((naked)) Foo::bar() { // expected-note{{attribute is here}}
asm("mov r2, %0" : : "r"(v)); // expected-error{{'this' pointer references not allowed in naked functions}}
}
void __attribute__((naked)) Foo::bar2() {
asm("mov r2, %0" : : "r"(s)); // static member reference is OK
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/string-init.c
|
// RUN: %clang_cc1 -std=c11 -fsyntax-only -triple x86_64-pc-linux -verify %s
// Note: these match the types specified by the target above.
typedef int wchar_t;
typedef unsigned short char16_t;
typedef unsigned int char32_t;
void f() {
char a1[] = "a"; // No error.
char a2[] = u8"a"; // No error.
char a3[] = u"a"; // expected-error{{initializing char array with wide string literal}}
char a4[] = U"a"; // expected-error{{initializing char array with wide string literal}}
char a5[] = L"a"; // expected-error{{initializing char array with wide string literal}}
wchar_t b1[] = "a"; // expected-error{{initializing wide char array with non-wide string literal}}
wchar_t b2[] = u8"a"; // expected-error{{initializing wide char array with non-wide string literal}}
wchar_t b3[] = u"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
wchar_t b4[] = U"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
wchar_t b5[] = L"a"; // No error.
char16_t c1[] = "a"; // expected-error{{initializing wide char array with non-wide string literal}}
char16_t c2[] = u8"a"; // expected-error{{initializing wide char array with non-wide string literal}}
char16_t c3[] = u"a"; // No error.
char16_t c4[] = U"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
char16_t c5[] = L"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
char32_t d1[] = "a"; // expected-error{{initializing wide char array with non-wide string literal}}
char32_t d2[] = u8"a"; // expected-error{{initializing wide char array with non-wide string literal}}
char32_t d3[] = u"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
char32_t d4[] = U"a"; // No error.
char32_t d5[] = L"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
int e1[] = "a"; // expected-error{{initializing wide char array with non-wide string literal}}
int e2[] = u8"a"; // expected-error{{initializing wide char array with non-wide string literal}}
int e3[] = u"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
int e4[] = U"a"; // expected-error{{initializing wide char array with incompatible wide string literal}}
int e5[] = L"a"; // No error.
long f1[] = "a"; // expected-error{{array initializer must be an initializer list}}
long f2[] = u8"a"; // expected-error{{array initializer must be an initializer list}}}
long f3[] = u"a"; // expected-error{{array initializer must be an initializer list}}
long f4[] = U"a"; // expected-error{{array initializer must be an initializer list}}
long f5[] = L"a"; // expected-error{{array initializer must be an initializer list}}
}
void g() {
char a[] = 1; // expected-error{{array initializer must be an initializer list or string literal}}
wchar_t b[] = 1; // expected-error{{array initializer must be an initializer list or wide string literal}}
char16_t c[] = 1; // expected-error{{array initializer must be an initializer list or wide string literal}}
char32_t d[] = 1; // expected-error{{array initializer must be an initializer list or wide string literal}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-mode-vector-types.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-unknown-linux-gnu %s
// Correct cases.
typedef int __attribute__((mode(byte))) __attribute__((vector_size(256))) vec_t1;
typedef int __attribute__((mode(QI))) __attribute__((vector_size(256))) vec_t2;
typedef int __attribute__((mode(SI))) __attribute__((vector_size(256))) vec_t3;
typedef int __attribute__((mode(DI))) __attribute__((vector_size(256)))vec_t4;
typedef float __attribute__((mode(SF))) __attribute__((vector_size(256))) vec_t5;
typedef float __attribute__((mode(DF))) __attribute__((vector_size(256))) vec_t6;
typedef float __attribute__((mode(XF))) __attribute__((vector_size(256))) vec_t7;
// Incorrect cases.
typedef float __attribute__((mode(QC))) __attribute__((vector_size(256))) vec_t8;
// expected-error@-1{{unsupported machine mode 'QC'}}
// expected-error@-2{{type of machine mode does not match type of base type}}
typedef _Complex float __attribute__((mode(HC))) __attribute__((vector_size(256))) vec_t9;
// expected-error@-1{{unsupported machine mode 'HC'}}
// expected-error@-2{{invalid vector element type '_Complex float'}}
typedef int __attribute__((mode(SC))) __attribute__((vector_size(256))) vec_t10;
// expected-error@-1{{type of machine mode does not match type of base type}}
// expected-error@-2{{type of machine mode does not support base vector types}}
typedef float __attribute__((mode(DC))) __attribute__((vector_size(256))) vec_t11;
// expected-error@-1{{type of machine mode does not match type of base type}}
// expected-error@-2{{type of machine mode does not support base vector types}}
typedef _Complex float __attribute__((mode(XC))) __attribute__((vector_size(256))) vec_t12;
// expected-error@-1{{invalid vector element type '_Complex float'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-pack-5.c
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -verify -ffreestanding
// expected-no-diagnostics
// <rdar://problem/10494810> and PR9560
// Check #pragma pack handling with bitfields.
#include <stddef.h>
#pragma pack(2)
struct s0 {
char f1;
unsigned f2 : 32;
char f3;
};
extern int check[sizeof(struct s0) == 6 ? 1 : -1];
struct s1 {
char f1;
unsigned : 0;
char f3;
};
extern int check[sizeof(struct s1) == 5 ? 1 : -1];
struct s2 {
char f1;
unsigned : 0;
unsigned f3 : 8;
char f4;
};
extern int check[sizeof(struct s2) == 6 ? 1 : -1];
struct s3 {
char f1;
unsigned : 0;
unsigned f3 : 16;
char f4;
};
extern int check[sizeof(struct s3) == 8 ? 1 : -1];
extern int check[offsetof(struct s3, f4) == 6 ? 1 : -1];
struct s4 {
char f1;
unsigned f2 : 8;
char f3;
};
extern int check[sizeof(struct s4) == 4 ? 1 : -1];
extern int check[offsetof(struct s4, f3) == 2 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/nullability.c
|
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wnullable-to-nonnull-conversion -Wno-nullability-declspec %s -verify
#if __has_feature(nullability)
#else
# error nullability feature should be defined
#endif
typedef int * int_ptr;
// Parse nullability type specifiers.
typedef int * _Nonnull nonnull_int_ptr; // expected-note{{'_Nonnull' specified here}}
typedef int * _Nullable nullable_int_ptr;
typedef int * _Null_unspecified null_unspecified_int_ptr;
// Redundant nullability type specifiers.
typedef int * _Nonnull _Nonnull redundant_1; // expected-warning{{duplicate nullability specifier '_Nonnull'}}
// Conflicting nullability type specifiers.
typedef int * _Nonnull _Nullable conflicting_1; // expected-error{{nullability specifier '_Nonnull' conflicts with existing specifier '_Nullable'}}
typedef int * _Null_unspecified _Nonnull conflicting_2; // expected-error{{nullability specifier '_Null_unspecified' conflicts with existing specifier '_Nonnull'}}
// Redundant nullability specifiers via a typedef are okay.
typedef nonnull_int_ptr _Nonnull redundant_okay_1;
// Conflicting nullability specifiers via a typedef are not.
typedef nonnull_int_ptr _Nullable conflicting_2; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
typedef nonnull_int_ptr nonnull_int_ptr_typedef;
typedef nonnull_int_ptr_typedef _Nullable conflicting_2; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
typedef nonnull_int_ptr_typedef nonnull_int_ptr_typedef_typedef;
typedef nonnull_int_ptr_typedef_typedef _Null_unspecified conflicting_3; // expected-error{{nullability specifier '_Null_unspecified' conflicts with existing specifier '_Nonnull'}}
// Nullability applies to all pointer types.
typedef int (* _Nonnull function_pointer_type_1)(int, int);
typedef int (^ _Nonnull block_type_1)(int, int);
// Nullability must be on a pointer type.
typedef int _Nonnull int_type_1; // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'int'}}
// Nullability can move out to a pointer/block pointer declarator
// (with a suppressed warning).
typedef _Nonnull int * nonnull_int_ptr_2;
typedef int _Nullable * nullable_int_ptr_2;
typedef _Nonnull int (* function_pointer_type_2)(int, int);
typedef _Nonnull int (^ block_type_2)(int, int);
typedef _Nonnull int * * _Nullable nonnull_int_ptr_ptr_1;
typedef _Nonnull int *(^ block_type_3)(int, int);
typedef _Nonnull int *(* function_pointer_type_3)(int, int);
typedef _Nonnull int_ptr (^ block_type_4)(int, int);
typedef _Nonnull int_ptr (* function_pointer_type_4)(int, int);
void acceptFunctionPtr(_Nonnull int *(*)(void));
void acceptBlockPtr(_Nonnull int *(^)(void));
void testBlockFunctionPtrNullability() {
float *fp;
fp = (function_pointer_type_3)0; // expected-warning{{from 'function_pointer_type_3' (aka 'int * _Nonnull (*)(int, int)')}}
fp = (block_type_3)0; // expected-error{{from incompatible type 'block_type_3' (aka 'int * _Nonnull (^)(int, int)')}}
fp = (function_pointer_type_4)0; // expected-warning{{from 'function_pointer_type_4' (aka 'int_ptr _Nonnull (*)(int, int)')}}
fp = (block_type_4)0; // expected-error{{from incompatible type 'block_type_4' (aka 'int_ptr _Nonnull (^)(int, int)')}}
acceptFunctionPtr(0); // no-warning
acceptBlockPtr(0); // no-warning
}
// Moving nullability where it creates a conflict.
typedef _Nonnull int * _Nullable * conflict_int_ptr_ptr_2; // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'int'}}
// Nullability is not part of the canonical type.
typedef int * _Nonnull ambiguous_int_ptr;
typedef int * ambiguous_int_ptr;
typedef int * _Nullable ambiguous_int_ptr;
// Printing of nullability.
float f;
int * _Nonnull ip_1 = &f; // expected-warning{{incompatible pointer types initializing 'int * _Nonnull' with an expression of type 'float *'}}
// Check printing of nullability specifiers.
void printing_nullability(void) {
int * _Nonnull iptr;
float *fptr = iptr; // expected-warning{{incompatible pointer types initializing 'float *' with an expression of type 'int * _Nonnull'}}
int * * _Nonnull iptrptr;
float **fptrptr = iptrptr; // expected-warning{{incompatible pointer types initializing 'float **' with an expression of type 'int ** _Nonnull'}}
int * _Nullable * _Nonnull iptrptr2;
float * *fptrptr2 = iptrptr2; // expected-warning{{incompatible pointer types initializing 'float **' with an expression of type 'int * _Nullable * _Nonnull'}}
}
// Check passing null to a _Nonnull argument.
void accepts_nonnull_1(_Nonnull int *ptr);
void (*accepts_nonnull_2)(_Nonnull int *ptr);
void (^accepts_nonnull_3)(_Nonnull int *ptr);
void test_accepts_nonnull_null_pointer_literal() {
accepts_nonnull_1(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
accepts_nonnull_2(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
accepts_nonnull_3(0); // expected-warning{{null passed to a callee that requires a non-null argument}}
}
// Check returning nil from a _Nonnull-returning function.
_Nonnull int *returns_int_ptr(int x) {
if (x) {
return 0; // expected-warning{{null returned from function that requires a non-null return value}}
}
return (_Nonnull int *)0;
}
// Check nullable-to-nonnull conversions.
void nullable_to_nonnull(_Nullable int *ptr) {
int *a = ptr; // okay
_Nonnull int *b = ptr; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/shift.c
|
// RUN: %clang_cc1 -Wall -Wshift-sign-overflow -ffreestanding -fsyntax-only -verify %s
#include <limits.h>
#define WORD_BIT (sizeof(int) * CHAR_BIT)
enum {
X = 1 << 0,
Y = 1 << 1,
Z = 1 << 2
};
void test() {
char c;
c = 0 << 0;
c = 0 << 1;
c = 1 << 0;
c = 1 << -0;
c = 1 >> -0;
c = 1 << -1; // expected-warning {{shift count is negative}}
c = 1 >> -1; // expected-warning {{shift count is negative}}
c = 1 << c;
c <<= 0;
c >>= 0;
c <<= 1;
c >>= 1;
c <<= -1; // expected-warning {{shift count is negative}}
c >>= -1; // expected-warning {{shift count is negative}}
c <<= 999999; // expected-warning {{shift count >= width of type}}
c >>= 999999; // expected-warning {{shift count >= width of type}}
c <<= CHAR_BIT; // expected-warning {{shift count >= width of type}}
c >>= CHAR_BIT; // expected-warning {{shift count >= width of type}}
c <<= CHAR_BIT+1; // expected-warning {{shift count >= width of type}}
c >>= CHAR_BIT+1; // expected-warning {{shift count >= width of type}}
(void)((long)c << CHAR_BIT);
int i;
i = 1 << (WORD_BIT - 2);
i = 2 << (WORD_BIT - 1); // expected-warning {{bits to represent, but 'int' only has}}
i = 1 << (WORD_BIT - 1); // expected-warning {{sets the sign bit of the shift expression}}
i = -1 << (WORD_BIT - 1); // expected-warning {{shifting a negative signed value is undefined}}
i = -1 << 0; // expected-warning {{shifting a negative signed value is undefined}}
i = 0 << (WORD_BIT - 1);
i = (char)1 << (WORD_BIT - 2);
unsigned u;
u = 1U << (WORD_BIT - 1);
u = 5U << (WORD_BIT - 1);
long long int lli;
lli = INT_MIN << 2; // expected-warning {{shifting a negative signed value is undefined}}
lli = 1LL << (sizeof(long long) * CHAR_BIT - 2);
}
#define a 0
#define ashift 8
enum { b = (a << ashift) };
// Don't warn for negative shifts in code that is unreachable.
void test_pr5544() {
(void) (((1) > 63 && (1) < 128 ? (((unsigned long long) 1)<<((1)-64)) : (unsigned long long) 0)); // no-warning
}
void test_shift_too_much(char x) {
if (0)
(void) (x >> 80); // no-warning
(void) (x >> 80); // expected-warning {{shift count >= width of type}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/many-logical-ops.c
|
// RUN: %clang_cc1 -fsyntax-only -Wconstant-conversion -verify %s
// expected-no-diagnostics
// rdar://10913206&10941790
// Check that we don't get stack overflow trying to evaluate a huge number of
// logical operators.
int foo(int x) {
return
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x &&
x;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/inline-asm-validate.c
|
// RUN: %clang_cc1 -triple arm64-apple-macosx10.8.0 -fsyntax-only -verify %s
unsigned t, r, *p;
int foo (void) {
__asm__ __volatile__( "stxr %w[_t], %[_r], [%[_p]]" : [_t] "=&r" (t) : [_p] "p" (p), [_r] "r" (r) : "memory"); // expected-warning{{value size does not match register size specified by the constraint and modifier}} expected-note {{use constraint modifier "w"}}
return 1;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pid_t.c
|
// RUN: %clang_cc1 -triple i586-pc-haiku -fsyntax-only -verify %s
// RUN: %clang_cc1 -triple i686-pc-linux -fsyntax-only -verify %s
// expected-no-diagnostics
#ifdef __HAIKU__
typedef signed long pid_t;
#else
typedef signed int pid_t;
#endif
pid_t vfork(void);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-availability.c
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s
// RUN: %clang_cc1 -D WARN_PARTIAL -Wpartial-availability -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s
//
void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in OS X version 10.2 before it was introduced in version 10.4; attribute ignored}}
void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1)));
void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}}
// rdar://10095131
extern void
ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); // expected-note {{'ATSFontGetName' has been explicitly marked deprecated here}}
extern void
ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{'ATSFontGetPostScriptName' has been explicitly marked unavailable here}}
#if defined(WARN_PARTIAL)
// expected-note@+3 {{has been explicitly marked partial here}}
#endif
extern void
PartiallyAvailable() __attribute__((availability(macosx,introduced=10.8)));
enum __attribute__((availability(macosx,introduced=10.8))) PartialEnum {
kPartialEnumConstant,
};
void test_10095131() {
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in OS X 9.0 - use CTFontCopyFullName}}
ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in OS X 9.0 - use ATSFontGetFullPostScriptName}}
#if defined(WARN_PARTIAL)
// expected-warning@+2 {{is partial: introduced in OS X 10.8}} expected-note@+2 {{explicitly redeclare 'PartiallyAvailable' to silence this warning}}
#endif
PartiallyAvailable();
}
extern void PartiallyAvailable() ;
void with_redeclaration() {
PartiallyAvailable(); // Don't warn.
// enums should never warn.
enum PartialEnum p = kPartialEnumConstant;
}
// rdar://10711037
__attribute__((availability(macos, unavailable))) // expected-warning {{attribute 'availability' is ignored}}
enum {
NSDataWritingFileProtectionWriteOnly = 0x30000000,
NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000,
};
void f4(int) __attribute__((availability(ios,deprecated=3.0)));
void f4(int) __attribute__((availability(ios,introduced=4.0))); // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}}
void f5(int) __attribute__((availability(ios,deprecated=3.0),
availability(ios,introduced=4.0))); // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}}
void f6(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}}
void f6(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}}
void f7(int) __attribute__((availability(ios,introduced=2.0)));
void f7(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}}
void f7(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}}
// <rdar://problem/11886458>
#if !__has_feature(attribute_availability_with_message)
# error "Missing __has_feature"
#endif
extern int x __attribute__((availability(macosx,introduced=10.5)));
extern int x;
void f8() {
int (^b)(int);
b = ^ (int i) __attribute__((availability(macosx,introduced=10.2))) { return 1; }; // expected-warning {{'availability' attribute ignored}}
}
extern int x2 __attribute__((availability(macosx,introduced=10.2))); // expected-note {{previous attribute is here}}
extern int x2 __attribute__((availability(macosx,introduced=10.5))); // expected-warning {{availability does not match previous declaration}}
enum Original {
OriginalDeprecated __attribute__((availability(macosx, deprecated=10.2))), // expected-note + {{'OriginalDeprecated' has been explicitly marked deprecated here}}
OriginalUnavailable __attribute__((availability(macosx, unavailable))) // expected-note + {{'OriginalUnavailable' has been explicitly marked unavailable here}}
};
enum AllDeprecated {
AllDeprecatedCase, // expected-note + {{'AllDeprecatedCase' has been explicitly marked deprecated here}}
AllDeprecatedUnavailable __attribute__((availability(macosx, unavailable))) // expected-note + {{'AllDeprecatedUnavailable' has been explicitly marked unavailable here}}
} __attribute__((availability(macosx, deprecated=10.2)));
enum AllUnavailable {
AllUnavailableCase, // expected-note + {{'AllUnavailableCase' has been explicitly marked unavailable here}}
} __attribute__((availability(macosx, unavailable)));
enum User {
UserOD = OriginalDeprecated, // expected-warning {{deprecated}}
UserODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated,
UserODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated,
UserOU = OriginalUnavailable, // expected-error {{unavailable}}
UserOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable, // expected-error {{unavailable}}
UserOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable,
UserAD = AllDeprecatedCase, // expected-warning {{deprecated}}
UserADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
UserADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
UserADU = AllDeprecatedUnavailable, // expected-error {{unavailable}}
UserADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable, // expected-error {{unavailable}}
UserADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable,
UserAU = AllUnavailableCase, // expected-error {{unavailable}}
UserAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase, // expected-error {{unavailable}}
UserAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase,
};
enum UserDeprecated {
UserDeprecatedOD = OriginalDeprecated,
UserDeprecatedODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated,
UserDeprecatedODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated,
UserDeprecatedOU = OriginalUnavailable, // expected-error {{unavailable}}
UserDeprecatedOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable, // expected-error {{unavailable}}
UserDeprecatedOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable,
UserDeprecatedAD = AllDeprecatedCase,
UserDeprecatedADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
UserDeprecatedADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
UserDeprecatedADU = AllDeprecatedUnavailable, // expected-error {{unavailable}}
UserDeprecatedADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable, // expected-error {{unavailable}}
UserDeprecatedADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable,
UserDeprecatedAU = AllUnavailableCase, // expected-error {{unavailable}}
UserDeprecatedAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase, // expected-error {{unavailable}}
UserDeprecatedAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase,
} __attribute__((availability(macosx, deprecated=10.2)));
enum UserUnavailable {
UserUnavailableOD = OriginalDeprecated,
UserUnavailableODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated,
UserUnavailableODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated,
UserUnavailableOU = OriginalUnavailable,
UserUnavailableOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable,
UserUnavailableOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable,
UserUnavailableAD = AllDeprecatedCase,
UserUnavailableADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
UserUnavailableADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
UserUnavailableADU = AllDeprecatedUnavailable,
UserUnavailableADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable,
UserUnavailableADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable,
UserUnavailableAU = AllUnavailableCase,
UserUnavailableAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase,
UserUnavailableAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase,
} __attribute__((availability(macosx, unavailable)));
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/const-eval.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux %s -Wno-tautological-pointer-compare
#define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];});
int x;
EVAL_EXPR(1, (_Bool)&x)
EVAL_EXPR(2, (int)(1.0+(double)4))
EVAL_EXPR(3, (int)(1.0+(float)4.0))
EVAL_EXPR(4, (_Bool)(1 ? (void*)&x : 0))
EVAL_EXPR(5, (_Bool)(int[]){0})
struct y {int x,y;};
EVAL_EXPR(6, (int)(1+(struct y*)0))
EVAL_EXPR(7, (int)&((struct y*)0)->y)
EVAL_EXPR(8, (_Bool)"asdf")
EVAL_EXPR(9, !!&x)
EVAL_EXPR(10, ((void)1, 12))
void g0(void);
EVAL_EXPR(11, (g0(), 12)) // expected-error {{must have a constant size}}
EVAL_EXPR(12, 1.0&&2.0)
EVAL_EXPR(13, x || 3.0) // expected-error {{must have a constant size}}
unsigned int l_19 = 1;
EVAL_EXPR(14, (1 ^ l_19) && 1); // expected-error {{fields must have a constant size}}
void f()
{
int a;
EVAL_EXPR(15, (_Bool)&a);
}
// FIXME: Turn into EVAL_EXPR test once we have more folding.
_Complex float g16 = (1.0f + 1.0fi);
// ?: in constant expressions.
int g17[(3?:1) - 2];
EVAL_EXPR(18, ((int)((void*)10 + 10)) == 20 ? 1 : -1);
struct s {
int a[(int)-1.0f]; // expected-error {{'a' declared as an array with a negative size}}
};
EVAL_EXPR(19, ((int)&*(char*)10 == 10 ? 1 : -1));
EVAL_EXPR(20, __builtin_constant_p(*((int*) 10)));
EVAL_EXPR(21, (__imag__ 2i) == 2 ? 1 : -1);
EVAL_EXPR(22, (__real__ (2i+3)) == 3 ? 1 : -1);
int g23[(int)(1.0 / 1.0)] = { 1 };
int g24[(int)(1.0 / 1.0)] = { 1 , 2 }; // expected-warning {{excess elements in array initializer}}
int g25[(int)(1.0 + 1.0)], g26 = sizeof(g25);
EVAL_EXPR(26, (_Complex double)0 ? -1 : 1)
EVAL_EXPR(27, (_Complex int)0 ? -1 : 1)
EVAL_EXPR(28, (_Complex double)1 ? 1 : -1)
EVAL_EXPR(29, (_Complex int)1 ? 1 : -1)
// PR4027 + rdar://6808859
struct a { int x, y; };
static struct a V2 = (struct a)(struct a){ 1, 2};
static const struct a V1 = (struct a){ 1, 2};
EVAL_EXPR(30, (int)(_Complex float)((1<<30)-1) == (1<<30) ? 1 : -1)
EVAL_EXPR(31, (int*)0 == (int*)0 ? 1 : -1)
EVAL_EXPR(32, (int*)0 != (int*)0 ? -1 : 1)
EVAL_EXPR(33, (void*)0 - (void*)0 == 0 ? 1 : -1)
void foo(void) {}
EVAL_EXPR(34, (foo == (void *)0) ? -1 : 1)
// No PR. Mismatched bitwidths lead to a crash on second evaluation.
const _Bool constbool = 0;
EVAL_EXPR(35, constbool)
EVAL_EXPR(36, constbool)
EVAL_EXPR(37, (1,2.0) == 2.0 ? 1 : -1)
EVAL_EXPR(38, __builtin_expect(1,1) == 1 ? 1 : -1)
// PR7884
EVAL_EXPR(39, __real__(1.f) == 1 ? 1 : -1)
EVAL_EXPR(40, __imag__(1.f) == 0 ? 1 : -1)
// From gcc testsuite
EVAL_EXPR(41, (int)(1+(_Complex unsigned)2))
// rdar://8875946
void rdar8875946() {
double _Complex P;
float _Complex P2 = 3.3f + P;
}
double d = (d = 0.0); // expected-error {{not a compile-time constant}}
double d2 = ++d; // expected-error {{not a compile-time constant}}
int n = 2;
int intLvalue[*(int*)((long)&n ?: 1)] = { 1, 2 }; // expected-error {{variable length array}}
union u { int a; char b[4]; };
char c = ((union u)(123456)).b[0]; // expected-error {{not a compile-time constant}}
extern const int weak_int __attribute__((weak));
const int weak_int = 42;
int weak_int_test = weak_int; // expected-error {{not a compile-time constant}}
int literalVsNull1 = "foo" == 0;
int literalVsNull2 = 0 == "foo";
// PR11385.
int castViaInt[*(int*)(unsigned long)"test"]; // expected-error {{variable length array}}
// PR11391.
struct PR11391 { _Complex float f; } pr11391;
EVAL_EXPR(42, __builtin_constant_p(pr11391.f = 1))
// PR12043
float varfloat;
const float constfloat = 0;
EVAL_EXPR(43, varfloat && constfloat) // expected-error {{must have a constant size}}
// <rdar://problem/11205586>
// (Make sure we continue to reject this.)
EVAL_EXPR(44, "x"[0]); // expected-error {{variable length array}}
// <rdar://problem/10962435>
EVAL_EXPR(45, ((char*)-1) + 1 == 0 ? 1 : -1)
EVAL_EXPR(46, ((char*)-1) + 1 < (char*) -1 ? 1 : -1)
EVAL_EXPR(47, &x < &x + 1 ? 1 : -1)
EVAL_EXPR(48, &x != &x - 1 ? 1 : -1)
EVAL_EXPR(49, &x < &x - 100 ? 1 : -1) // expected-error {{must have a constant size}}
extern struct Test50S Test50;
EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-error {{must have a constant size}}
// <rdar://problem/11874571>
EVAL_EXPR(51, 0 != (float)1e99)
// PR21945
void PR21945() { int i = (({}), 0l); }
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/invalid-assignment-constant-address-space.c
|
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
#define OPENCL_CONSTANT 16776962
int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
void foo() {
c[0] = 1; //expected-error{{read-only variable is not assignable}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/x86-attr-force-align-arg-pointer.c
|
// RUN: %clang_cc1 -triple i386-apple-darwin10 -fsyntax-only -verify %s
int a __attribute__((force_align_arg_pointer)); // expected-warning{{attribute only applies to functions}}
// It doesn't matter where the attribute is located.
void b(void) __attribute__((force_align_arg_pointer));
void __attribute__((force_align_arg_pointer)) c(void);
// Functions only have to be declared force_align_arg_pointer once.
void b(void) {}
// It doesn't matter which declaration has the attribute.
void d(void);
void __attribute__((force_align_arg_pointer)) d(void) {}
// Attribute is ignored on function pointer types.
void (__attribute__((force_align_arg_pointer)) *p)();
typedef void (__attribute__((__force_align_arg_pointer__)) *p2)();
// Attribute is also ignored on function typedefs.
typedef void __attribute__((force_align_arg_pointer)) e(void);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/return.c
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
// clang emits the following warning by default.
// With GCC, -pedantic, -Wreturn-type or -Wall are required to produce the
// following warning.
int t14() {
return; // expected-warning {{non-void function 't14' should return a value}}
}
void t15() {
return 1; // expected-warning {{void function 't15' should not return a value}}
}
int unknown();
void test0() {
}
int test1() {
} // expected-warning {{control reaches end of non-void function}}
int test2() {
a: goto a;
}
int test3() {
goto a;
a: ;
} // expected-warning {{control reaches end of non-void function}}
void halt() {
a: goto a;
}
void halt2() __attribute__((noreturn));
int test4() {
halt2();
}
int test5() {
halt2(), (void)1;
}
int test6() {
1, halt2();
}
int j;
int unknown_nohalt() {
return j;
}
int test7() {
unknown();
} // expected-warning {{control reaches end of non-void function}}
int test8() {
(void)(1 + unknown());
} // expected-warning {{control reaches end of non-void function}}
int halt3() __attribute__((noreturn));
int test9() {
(void)(halt3() + unknown());
}
int test10() {
(void)(unknown() || halt3());
} // expected-warning {{control may reach end of non-void function}}
int test11() {
(void)(unknown() && halt3());
} // expected-warning {{control may reach end of non-void function}}
int test12() {
(void)(halt3() || unknown());
}
int test13() {
(void)(halt3() && unknown());
}
int test14() {
(void)(1 || unknown());
} // expected-warning {{control reaches end of non-void function}}
int test15() {
(void)(0 || unknown());
} // expected-warning {{control reaches end of non-void function}}
int test16() {
(void)(0 && unknown());
} // expected-warning {{control reaches end of non-void function}}
int test17() {
(void)(1 && unknown());
} // expected-warning {{control reaches end of non-void function}}
int test18() {
(void)(unknown_nohalt() && halt3());
} // expected-warning {{control may reach end of non-void function}}
int test19() {
(void)(unknown_nohalt() && unknown());
} // expected-warning {{control reaches end of non-void function}}
int test20() {
int i;
if (i)
return 0;
else if (0)
return 2;
} // expected-warning {{control may reach end of non-void function}}
int test21() {
int i;
if (i)
return 0;
else if (1)
return 2;
}
int test22() {
int i;
switch (i) default: ;
} // expected-warning {{control reaches end of non-void function}}
int test23() {
int i;
switch (i) {
case 0:
return 0;
case 2:
return 2;
}
} // expected-warning {{control may reach end of non-void function}}
int test24() {
int i;
switch (i) {
case 0:
return 0;
case 2:
return 2;
default:
return -1;
}
}
int test25() {
1 ? halt3() : unknown();
}
int test26() {
0 ? halt3() : unknown();
} // expected-warning {{control reaches end of non-void function}}
int j;
void (*fptr)() __attribute__((noreturn));
int test27() {
switch (j) {
case 1:
do { } while (1);
break;
case 2:
for (;;) ;
break;
case 3:
for (;1;) ;
for (;0;) {
goto done;
}
return 1;
case 4:
while (0) { goto done; }
return 1;
case 5:
while (1) { return 1; }
break;
case 6:
fptr();
break;
default:
return 1;
}
done: ;
}
// PR4624
void test28() __attribute__((noreturn));
void test28(x) { while (1) { } }
void exit(int);
int test29() {
exit(1);
}
// Include these declarations here explicitly so we don't depend on system headers.
typedef struct __jmp_buf_tag{} jmp_buf[1];
extern void longjmp (struct __jmp_buf_tag __env[1], int __val) __attribute__ ((noreturn));
extern void _longjmp (struct __jmp_buf_tag __env[1], int __val) __attribute__ ((noreturn));
jmp_buf test30_j;
int test30() {
if (j)
longjmp(test30_j, 1);
else
#if defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
longjmp(test30_j, 2);
#else
_longjmp(test30_j, 1);
#endif
}
typedef void test31_t(int status);
void test31(test31_t *callback __attribute__((noreturn)));
void test32() {
^ (void) { while (1) { } }();
^ (void) { if (j) while (1) { } }();
while (1) { }
}
void test33() {
if (j) while (1) { }
}
// Test that 'static inline' functions are only analyzed for CFG-based warnings
// when they are used.
static inline int si_has_missing_return() {} // expected-warning{{control reaches end of non-void function}}
static inline int si_has_missing_return_2() {}; // expected-warning{{control reaches end of non-void function}}
static inline int si_forward();
static inline int si_has_missing_return_3(int x) {
if (x)
return si_has_missing_return_3(x+1);
} // expected-warning{{control may reach end of non-void function}}
int test_static_inline(int x) {
si_forward();
return x ? si_has_missing_return_2() : si_has_missing_return_3(x);
}
static inline int si_forward() {} // expected-warning{{control reaches end of non-void function}}
// Test warnings on ignored qualifiers on return types.
const int ignored_c_quals(); // expected-warning{{'const' type qualifier on return type has no effect}}
const volatile int ignored_cv_quals(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
char* const volatile restrict ignored_cvr_quals(); // expected-warning{{'const volatile restrict' type qualifiers on return type have no effect}}
typedef const int CI;
CI ignored_quals_typedef();
const CI ignored_quals_typedef_2(); // expected-warning{{'const' type qualifier}}
// Test that for switch(enum) that if the switch statement covers all the cases
// that we don't consider that for -Wreturn-type.
enum Cases { C1, C2, C3, C4 };
int test_enum_cases(enum Cases C) {
switch (C) {
case C1: return 1;
case C2: return 2;
case C4: return 3;
case C3: return 4;
}
} // no-warning
// PR12318 - Don't give a may reach end of non-void function warning.
int test34(int x) {
if (x == 1) {
return 3;
} else if ( x == 2 || 1) {
return 5;
}
}
// PR18999
int test35() {
lbl:
if (1)
goto lbl;
}
// PR19074.
void abort(void) __attribute__((noreturn));
#define av_assert0(cond) do {\
if (!(cond)) {\
abort();\
}\
} while (0)
int PR19074(int x) {
switch(x) {
case 0:
return 0;
default:
av_assert0(0);
} // no-warning
}
int PR19074_positive(int x) {
switch(x) {
case 0:
return 0;
default:
break;
}
} // expected-warning {{control may reach end of non-void function}}
// sizeof(long) test.
int sizeof_long() {
if (sizeof(long) == 4)
return 1;
if (sizeof(long) == 8)
return 2;
} // no-warning
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/function.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
// PR1892, PR11354
void f(double a[restrict][5]) { __typeof(a) x = 10; } // expected-warning {{(aka 'double (*restrict)[5]')}}
int foo (__const char *__path);
int foo(__const char *__restrict __file);
void func(const char*); // expected-note {{previous declaration is here}}
void func(char*); // expected-error{{conflicting types for 'func'}}
void g(int (*)(const void **, const void **));
void g(int (*compar)()) {
}
void h(); // expected-note {{previous declaration is here}}
void h (const char *fmt, ...) {} // expected-error{{conflicting types for 'h'}}
// PR1965
int t5(b); // expected-error {{parameter list without types}}
int t6(int x, g); // expected-warning {{type specifier missing, defaults to 'int'}}
int t7(, ); // expected-error {{expected parameter declarator}} expected-error {{expected parameter declarator}}
int t8(, int a); // expected-error {{expected parameter declarator}}
int t9(int a, ); // expected-error {{expected parameter declarator}}
// PR2042
void t10(){}
void t11(){t10(1);} // expected-warning{{too many arguments}}
// PR3208
void t12(int) {} // expected-error{{parameter name omitted}}
// PR2790
void t13() {
return 0; // expected-error {{void function 't13' should not return a value}}
}
int t14() {
return; // expected-error {{non-void function 't14' should return a value}}
}
// <rdar://problem/6097326>
y(y) { return y; } // expected-warning{{parameter 'y' was not declared, defaulting to type 'int'}} \
// expected-warning{{type specifier missing, defaults to 'int'}}
// PR3137, <rdar://problem/6127293>
extern int g0_3137(void);
void f0_3137() {
int g0_3137(void);
}
void f1_3137() {
int (*fp)(void) = g0_3137;
}
void f1static() {
static void f2static(int); // expected-error{{function declared in block scope cannot have 'static' storage class}}
register void f2register(int); // expected-error{{illegal storage class on function}}
}
struct incomplete_test a(void) {} // expected-error{{incomplete result type 'struct incomplete_test' in function definition}} \
// expected-note{{forward declaration of 'struct incomplete_test'}}
extern __inline
__attribute__((__gnu_inline__))
void gnu_inline1() {}
void
__attribute__((__gnu_inline__)) // expected-warning {{'gnu_inline' attribute requires function to be marked 'inline', attribute ignored}}
gnu_inline2() {}
// rdar://6802350
inline foo_t invalid_type() { // expected-error {{unknown type name 'foo_t'}}
}
typedef void fn_t(void);
fn_t t17;
// PR4049
unknown_type t18(void*) { // expected-error {{unknown type name 'unknown_type'}} expected-error{{parameter name omitted}}
}
unknown_type t19(int* P) { // expected-error {{unknown type name 'unknown_type'}}
P = P+1; // no warning.
}
// missing ',' before '...'
void t20(int i...) { } // expected-error {{requires a comma}}
int n;
void t21(int n, int (*array)[n]);
int func_e(int x) {
int func_n(int y) { // expected-error {{function definition is not allowed here}}
if (y > 22) {
return y+2;
} else {
return y-2;
}
}
return x + 3;
}
void decays(int a[3][3]); // expected-note {{passing argument to parameter 'a' here}}
void no_decay(int (*a)[3]); // expected-note {{passing argument to parameter 'a' here}}
void t22(int *ptr, int (*array)[3]) {
decays(ptr); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
no_decay(ptr); // expected-warning {{incompatible pointer types passing 'int *' to parameter of type 'int (*)[3]'}}
decays(array);
no_decay(array);
}
void const Bar (void); // ok on decl
// PR 20146
void const Bar (void) // expected-warning {{function cannot return qualified void type 'const void'}}
{
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/typo-correction.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
//
// This file contains typo correction tests which hit different code paths in C
// than in C++ and may exhibit different behavior as a result.
__typeof__(struct F*) var[invalid]; // expected-error-re {{use of undeclared identifier 'invalid'{{$}}}}
void PR21656() {
float x;
x = (float)arst; // expected-error-re {{use of undeclared identifier 'arst'{{$}}}}
}
a = b ? : 0; // expected-warning {{type specifier missing, defaults to 'int'}} \
// expected-error {{use of undeclared identifier 'b'}}
int foobar; // expected-note {{'foobar' declared here}}
a = goobar ?: 4; // expected-warning {{type specifier missing, defaults to 'int'}} \
// expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
// expected-error {{initializer element is not a compile-time constant}}
struct ContainerStuct {
enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}}
};
void func(int arg) {
switch (arg) {
case SOME_ENUM_: // expected-error {{use of undeclared identifier 'SOME_ENUM_'; did you mean 'SOME_ENUM'}}
;
}
}
void banana(void); // expected-note {{'banana' declared here}}
int c11Generic(int arg) {
_Generic(hello, int : banana)(); // expected-error-re {{use of undeclared identifier 'hello'{{$}}}}
_Generic(arg, int : bandana)(); // expected-error {{use of undeclared identifier 'bandana'; did you mean 'banana'?}}
}
typedef long long __m128i __attribute__((__vector_size__(16)));
int PR23101(__m128i __x) {
return foo((__v2di)__x); // expected-warning {{implicit declaration of function 'foo'}} \
// expected-error {{use of undeclared identifier '__v2di'}}
}
void f(long *a, long b) {
__atomic_or_fetch(a, b, c); // expected-error {{use of undeclared identifier 'c'}}
}
extern double cabs(_Complex double z);
void fn1() {
cabs(errij); // expected-error {{use of undeclared identifier 'errij'}}
}
extern long afunction(int); // expected-note {{'afunction' declared here}}
void fn2() {
f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/many-parameters.c
|
// RUN: %clang_cc1 -fsyntax-only -std=c99 %s
// This test simply tests that the compiler does not crash. An optimization
// in ParmVarDecls means that functions with fewer than 256 parameters use a fast path,
// while those with >= 256 parameters use a slow path.
//
// Crash was reported in PR 10538.
void foo(
int x0,
int x1,
int x2,
int x3,
int x4,
int x5,
int x6,
int x7,
int x8,
int x9,
int x10,
int x11,
int x12,
int x13,
int x14,
int x15,
int x16,
int x17,
int x18,
int x19,
int x20,
int x21,
int x22,
int x23,
int x24,
int x25,
int x26,
int x27,
int x28,
int x29,
int x30,
int x31,
int x32,
int x33,
int x34,
int x35,
int x36,
int x37,
int x38,
int x39,
int x40,
int x41,
int x42,
int x43,
int x44,
int x45,
int x46,
int x47,
int x48,
int x49,
int x50,
int x51,
int x52,
int x53,
int x54,
int x55,
int x56,
int x57,
int x58,
int x59,
int x60,
int x61,
int x62,
int x63,
int x64,
int x65,
int x66,
int x67,
int x68,
int x69,
int x70,
int x71,
int x72,
int x73,
int x74,
int x75,
int x76,
int x77,
int x78,
int x79,
int x80,
int x81,
int x82,
int x83,
int x84,
int x85,
int x86,
int x87,
int x88,
int x89,
int x90,
int x91,
int x92,
int x93,
int x94,
int x95,
int x96,
int x97,
int x98,
int x99,
int x100,
int x101,
int x102,
int x103,
int x104,
int x105,
int x106,
int x107,
int x108,
int x109,
int x110,
int x111,
int x112,
int x113,
int x114,
int x115,
int x116,
int x117,
int x118,
int x119,
int x120,
int x121,
int x122,
int x123,
int x124,
int x125,
int x126,
int x127,
int x128,
int x129,
int x130,
int x131,
int x132,
int x133,
int x134,
int x135,
int x136,
int x137,
int x138,
int x139,
int x140,
int x141,
int x142,
int x143,
int x144,
int x145,
int x146,
int x147,
int x148,
int x149,
int x150,
int x151,
int x152,
int x153,
int x154,
int x155,
int x156,
int x157,
int x158,
int x159,
int x160,
int x161,
int x162,
int x163,
int x164,
int x165,
int x166,
int x167,
int x168,
int x169,
int x170,
int x171,
int x172,
int x173,
int x174,
int x175,
int x176,
int x177,
int x178,
int x179,
int x180,
int x181,
int x182,
int x183,
int x184,
int x185,
int x186,
int x187,
int x188,
int x189,
int x190,
int x191,
int x192,
int x193,
int x194,
int x195,
int x196,
int x197,
int x198,
int x199,
int x200,
int x201,
int x202,
int x203,
int x204,
int x205,
int x206,
int x207,
int x208,
int x209,
int x210,
int x211,
int x212,
int x213,
int x214,
int x215,
int x216,
int x217,
int x218,
int x219,
int x220,
int x221,
int x222,
int x223,
int x224,
int x225,
int x226,
int x227,
int x228,
int x229,
int x230,
int x231,
int x232,
int x233,
int x234,
int x235,
int x236,
int x237,
int x238,
int x239,
int x240,
int x241,
int x242,
int x243,
int x244,
int x245,
int x246,
int x247,
int x248,
int x249,
int x250,
int x251,
int x252,
int x253,
int x254,
int x255,
int x256,
int x257,
int x258,
int x259,
int x260,
int x261,
int x262,
int x263,
int x264,
int x265,
int x266,
int x267,
int x268,
int x269,
int x270,
int x271,
int x272,
int x273,
int x274,
int x275,
int x276,
int x277,
int x278,
int x279,
int x280,
int x281,
int x282,
int x283,
int x284,
int x285,
int x286,
int x287,
int x288,
int x289,
int x290,
int x291,
int x292,
int x293,
int x294,
int x295,
int x296,
int x297,
int x298,
int x299
);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/invalid-decl.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify
void test() {
char = 4; // expected-error {{expected identifier}}
}
// PR2400
typedef xtype (*x)(void* handle); // expected-error {{function cannot return function type}} expected-warning {{type specifier missing, defaults to 'int'}} expected-warning {{type specifier missing, defaults to 'int'}}
typedef void ytype();
typedef struct _zend_module_entry zend_module_entry;
struct _zend_module_entry {
ytype globals_size; // expected-error {{field 'globals_size' declared as a function}}
};
zend_module_entry openssl_module_entry = {
sizeof(zend_module_entry)
};
// <rdar://problem/11067144>
typedef int (FunctionType)(int *value);
typedef struct {
UndefinedType undef; // expected-error {{unknown type name 'UndefinedType'}}
FunctionType fun; // expected-error {{field 'fun' declared as a function}}
} StructType;
void f(StructType *buf) {
buf->fun = 0;
}
// rdar://11743706
static void bar(hid_t, char); // expected-error {{expected identifier}}
static void bar(hid_t p, char); // expected-error {{unknown type name 'hid_t'}}
void foo() {
(void)bar;
}
void test2();
void test2(undef); // expected-error {{a parameter list without types is only allowed in a function definition}}
void test2() { }
void test3();
void test3; // expected-error {{incomplete type}}
void test3() { }
void ellipsis1(...); // expected-error {{ISO C requires a named parameter before '...'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/inline.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
#if defined(INCLUDE)
// -------
// This section acts like a header file.
// -------
// Check the use of static variables in non-static inline functions.
static int staticVar; // expected-note + {{'staticVar' declared here}}
static int staticFunction(); // expected-note + {{'staticFunction' declared here}}
static struct { int x; } staticStruct; // expected-note + {{'staticStruct' declared here}}
inline int useStatic () { // expected-note 3 {{use 'static' to give inline function 'useStatic' internal linkage}}
staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
(void)staticStruct.x; // expected-warning{{static variable 'staticStruct' is used in an inline function with external linkage}}
return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
}
extern inline int useStaticFromExtern () { // no suggestions
staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
}
static inline int useStaticFromStatic () {
staticFunction(); // no-warning
return staticVar; // no-warning
}
extern inline int useStaticInlineFromExtern () {
// Heuristic: if the function we're using is also inline, don't warn.
// This can still be wrong (in this case, we end up inlining calls to
// staticFunction and staticVar) but this got very noisy even using
// standard headers.
return useStaticFromStatic(); // no-warning
}
static int constFunction() __attribute__((const));
inline int useConst () {
return constFunction(); // no-warning
}
#else
// -------
// This is the main source file.
// -------
#define INCLUDE
#include "inline.c"
// Check that we don't allow illegal uses of inline
inline int a; // expected-error{{'inline' can only appear on functions}}
typedef inline int b; // expected-error{{'inline' can only appear on functions}}
int d(inline int a); // expected-error{{'inline' can only appear on functions}}
// Check that the warnings from the "header file" aren't on by default in
// the main source file.
inline int useStaticMainFile () {
staticFunction(); // no-warning
return staticVar; // no-warning
}
// Check that the warnings show up when explicitly requested.
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wstatic-in-inline"
inline int useStaticAgain () { // expected-note 2 {{use 'static' to give inline function 'useStaticAgain' internal linkage}}
staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
}
#pragma clang diagnostic pop
inline void defineStaticVar() { // expected-note {{use 'static' to give inline function 'defineStaticVar' internal linkage}}
static const int x = 0; // ok
static int y = 0; // expected-warning {{non-constant static local variable in inline function may be different in different files}}
}
extern inline void defineStaticVarInExtern() {
static const int x = 0; // ok
static int y = 0; // ok
}
// Check behavior of line markers.
# 1 "XXX.h" 1
inline int useStaticMainFileInLineMarker() { // expected-note 2 {{use 'static' to give inline function 'useStaticMainFileInLineMarker' internal linkage}}
staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}}
return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}}
}
# 100 "inline.c" 2
inline int useStaticMainFileAfterLineMarker() {
staticFunction(); // no-warning
return staticVar; // no-warning
}
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/text-diag.c
|
// RUN: %clang_cc1 -fsyntax-only %s
unsigned char *foo = "texto\
que continua\
e continua";
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-nonnull.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
void f1(int *a1, int *a2, int *a3, int *a4, int *a5, int *a6, int *a7,
int *a8, int *a9, int *a10, int *a11, int *a12, int *a13, int *a14,
int *a15, int *a16) __attribute__((nonnull(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)));
void f2(void) __attribute__((nonnull())); // expected-warning {{'nonnull' attribute applied to function with no pointer arguments}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-visibility.c
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
void test0() __attribute__((visibility("default")));
void test1() __attribute__((visibility("hidden")));
void test2() __attribute__((visibility("internal")));
// rdar://problem/10753392
void test3() __attribute__((visibility("protected"))); // expected-warning {{target does not support 'protected' visibility; using 'default'}}
struct __attribute__((visibility("hidden"))) test4; // expected-note {{previous attribute is here}}
struct test4;
struct __attribute__((visibility("default"))) test4; // expected-error {{visibility does not match previous declaration}}
struct test5;
struct __attribute__((visibility("hidden"))) test5; // expected-note {{previous attribute is here}}
struct __attribute__((visibility("default"))) test5; // expected-error {{visibility does not match previous declaration}}
void test6() __attribute__((visibility("hidden"), // expected-note {{previous attribute is here}}
visibility("default"))); // expected-error {{visibility does not match previous declaration}}
extern int test7 __attribute__((visibility("default"))); // expected-note {{previous attribute is here}}
extern int test7 __attribute__((visibility("hidden"))); // expected-error {{visibility does not match previous declaration}}
typedef int __attribute__((visibility("default"))) bar; // expected-warning {{'visibility' attribute ignored}}
int x __attribute__((type_visibility("default"))); // expected-error {{'type_visibility' attribute only applies to types and namespaces}}
int PR17105 __attribute__((visibility(hidden))); // expected-error {{'visibility' attribute requires a string}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-pack-6.c
|
// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify
// expected-no-diagnostics
// Pragma pack handling with tag declarations
struct X;
#pragma pack(2)
struct X { int x; };
struct Y;
#pragma pack()
struct Y { int y; };
extern int check[__alignof(struct X) == 2 ? 1 : -1];
extern int check[__alignof(struct Y) == 4 ? 1 : -1];
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/conversion-64-32.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wshorten-64-to-32 -triple x86_64-apple-darwin %s
int test0(long v) {
return v; // expected-warning {{implicit conversion loses integer precision}}
}
// rdar://9546171
typedef int int4 __attribute__ ((vector_size(16)));
typedef long long long2 __attribute__((__vector_size__(16)));
int4 test1(long2 a) {
int4 v127 = a; // no warning.
return v127;
}
int test2(long v) {
return v / 2; // expected-warning {{implicit conversion loses integer precision: 'long' to 'int'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/atomic-expr.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only
// expected-no-diagnostics
_Atomic(unsigned int) data1;
int _Atomic data2;
// Shift operations
int func_01 (int x) {
return data1 << x;
}
int func_02 (int x) {
return x << data1;
}
int func_03 (int x) {
return data2 << x;
}
int func_04 (int x) {
return x << data2;
}
int func_05 () {
return data2 << data1;
}
int func_06 () {
return data1 << data2;
}
void func_07 (int x) {
data1 <<= x;
}
void func_08 (int x) {
data2 <<= x;
}
void func_09 (int* xp) {
*xp <<= data1;
}
void func_10 (int* xp) {
*xp <<= data2;
}
int func_11 (int x) {
return data1 == x;
}
int func_12 () {
return data1 < data2;
}
int func_13 (int x, unsigned y) {
return x ? data1 : y;
}
int func_14 () {
return data1 == 0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/static-init.c
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion %s
typedef __typeof((int*) 0 - (int*) 0) intptr_t;
static int f = 10;
static int b = f; // expected-error {{initializer element is not a compile-time constant}}
float r = (float) (intptr_t) &r; // expected-error {{initializer element is not a compile-time constant}}
intptr_t s = (intptr_t) &s;
_Bool t = &t;
union bar {
int i;
};
struct foo {
short ptr;
};
union bar u[1];
struct foo x = {(intptr_t) u}; // expected-error {{initializer element is not a compile-time constant}}
struct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}}
intptr_t z = (intptr_t) u; // no-error
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/annotate.c
|
// RUN: %clang_cc1 %s -fsyntax-only -verify
void __attribute__((annotate("foo"))) foo(float *a) {
__attribute__((annotate("bar"))) int x;
__attribute__((annotate(1))) int y; // expected-error {{'annotate' attribute requires a string}}
__attribute__((annotate("bar", 1))) int z; // expected-error {{'annotate' attribute takes one argument}}
int u = __builtin_annotation(z, (char*) 0); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}}
int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}}
int w = __builtin_annotation(z, "foo");
float b = __builtin_annotation(*a, "foo"); // expected-error {{first argument to __builtin_annotation must be an integer}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/pragma-unused.c
|
// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -Wused-but-marked-unused -Wunused -verify %s
void f1(void) {
int x, y, z;
#pragma unused(x)
#pragma unused(y, z)
int w; // expected-warning {{unused}}
#pragma unused w // expected-warning{{missing '(' after '#pragma unused' - ignoring}}
}
void f2(void) {
int x, y; // expected-warning {{unused}} expected-warning {{unused}}
#pragma unused(x,) // expected-warning{{expected '#pragma unused' argument to be a variable name}}
#pragma unused() // expected-warning{{expected '#pragma unused' argument to be a variable name}}
}
void f3(void) {
#pragma unused(x) // expected-warning{{undeclared variable 'x' used as an argument for '#pragma unused'}}
}
void f4(void) {
int w; // expected-warning {{unused}}
#pragma unused((w)) // expected-warning{{expected '#pragma unused' argument to be a variable name}}
}
void f6(void) {
int z; // no-warning
{
#pragma unused(z) // no-warning
}
}
void f7() {
int y;
#pragma unused(undeclared, undefined, y) // expected-warning{{undeclared variable 'undeclared' used as an argument for '#pragma unused'}} expected-warning{{undeclared variable 'undefined' used as an argument for '#pragma unused'}}
}
int f8(int x) { // expected-warning{{unused parameter 'x'}}
return 0;
}
int f9(int x) {
return x;
}
int f10(int x) {
#pragma unused(x)
return 0;
}
int f11(int x) {
#pragma unused(x)
return x; // expected-warning{{'x' was marked unused but was used}}
}
int f12(int x) {
int y = x;
#pragma unused(x) // expected-warning{{'x' was marked unused but was used}}
return y;
}
// rdar://8793832
static int glob_var = 0;
#pragma unused(glob_var)
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/format-strings-fixit-ssize_t.c
|
// RUN: cp %s %t
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -pedantic -Wall -fixit %t
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -Wall -Werror %t
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -E -o - %t | FileCheck %s
/* This is a test of the various code modification hints that are
provided as part of warning or extension diagnostics. All of the
warnings will be fixed by -fixit, and the resulting file should
compile cleanly with -Werror -pedantic. */
int printf(char const *, ...);
void test() {
typedef signed long int ssize_t;
printf("%f", (ssize_t) 42);
}
// CHECK: printf("%zd", (ssize_t) 42);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/block-literal.c
|
// RUN: %clang_cc1 -fsyntax-only %s -verify -fblocks
void I( void (^)(void));
void (^noop)(void);
void nothing();
int printf(const char*, ...);
typedef void (^T) (void);
void takeblock(T);
int takeintint(int (^C)(int)) { return C(4); }
T somefunction() {
if (^{ })
nothing();
noop = ^{};
noop = ^{printf("\nClosure\n"); };
I(^{ });
return ^{printf("\nClosure\n"); };
}
void test2() {
int x = 4;
takeblock(^{ printf("%d\n", x); });
while (1) {
takeblock(^{
break; // expected-error {{'break' statement not in loop or switch statement}}
continue; // expected-error {{'continue' statement not in loop statement}}
while(1) break; // ok
goto foo; // expected-error {{use of undeclared label 'foo'}}
a: goto a; // ok
});
break;
}
foo:
takeblock(^{ x = 4; }); // expected-error {{variable is not assignable (missing __block type specifier)}}
__block y = 7; // expected-warning {{type specifier missing, defaults to 'int'}}
takeblock(^{ y = 8; });
}
void (^test3())(void) {
return ^{};
}
void test4() {
void (^noop)(void) = ^{};
void (*noop2)() = 0;
}
void myfunc(int (^block)(int)) {}
void myfunc3(const int *x);
void test5() {
int a;
myfunc(^(int abcd) {
myfunc3(&a);
return 1;
});
}
void *X;
void test_arguments() {
int y;
int (^c)(char);
(1 ? c : 0)('x');
(1 ? 0 : c)('x');
(1 ? c : c)('x');
}
static int global_x = 10;
void (^global_block)(void) = ^{ printf("global x is %d\n", global_x); };
typedef void (^void_block_t)(void);
static const void_block_t myBlock = ^{ };
static const void_block_t myBlock2 = ^ void(void) { };
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/typedef-variable-type.c
|
// RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic -Wno-typedef-redefinition -std=c99
// Make sure we accept a single typedef
typedef int (*a)[!.0]; // expected-warning{{size of static array must be an integer constant expression}}
// And make sure we accept identical redefinitions in system headers
// (The test uses -Wno-typedef-redefinition to simulate this.)
typedef int (*a)[!.0]; // expected-warning{{size of static array must be an integer constant expression}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/warn-type-safety.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
typedef struct ompi_datatype_t *MPI_Datatype;
#define OMPI_PREDEFINED_GLOBAL(type, global) ((type) &(global))
#define MPI_FLOAT OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_float)
#define MPI_INT OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_int)
#define MPI_NULL OMPI_PREDEFINED_GLOBAL(MPI_Datatype, ompi_mpi_null)
extern struct ompi_predefined_datatype_t ompi_mpi_float __attribute__(( type_tag_for_datatype(mpi,float) ));
extern struct ompi_predefined_datatype_t ompi_mpi_int __attribute__(( type_tag_for_datatype(mpi,int) ));
extern struct ompi_predefined_datatype_t ompi_mpi_null __attribute__(( type_tag_for_datatype(mpi,void,must_be_null) ));
int f(int x) { return x; }
static const int wrong_init __attribute__(( type_tag_for_datatype(zzz,int) )) = f(100); // expected-error {{'type_tag_for_datatype' attribute requires the initializer to be an integral constant expression}}
//===--- Tests ------------------------------------------------------------===//
// Check that hidden 'this' is handled correctly.
class C
{
public:
void f1(void *buf, int count, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,5,6) )); // expected-error {{attribute parameter 2 is out of bounds}}
void f2(void *buf, int count, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,2,5) )); // expected-error {{attribute parameter 3 is out of bounds}}
void f3(void *buf, int count, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,1,5) )); // expected-error {{attribute is invalid for the implicit this argument}}
void f4(void *buf, int count, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,2,1) )); // expected-error {{attribute is invalid for the implicit this argument}}
void MPI_Send(void *buf, int count, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,2,4) )); // no-error
};
// Check that we don't crash on type and value dependent expressions.
template<int a>
void value_dep(void *buf, int count, MPI_Datatype datatype)
__attribute__(( pointer_with_type_tag(mpi,a,5) )); // expected-error {{attribute requires parameter 2 to be an integer constant}}
class OperatorIntStar
{
public:
operator int*();
};
void test1(C *c, int *int_buf)
{
c->MPI_Send(int_buf, 1, MPI_INT); // no-warning
c->MPI_Send(int_buf, 1, MPI_FLOAT); // expected-warning {{argument type 'int *' doesn't match specified 'mpi' type tag that requires 'float *'}}
c->MPI_Send(0, 0, MPI_INT); // no-warning
c->MPI_Send(nullptr, 0, MPI_INT); // no-warning
OperatorIntStar i;
c->MPI_Send(i, 1, MPI_INT); // no-warning
c->MPI_Send(i, 1, MPI_FLOAT); // expected-warning {{argument type 'int *' doesn't match specified 'mpi' type tag that requires 'float *'}}
}
template<typename T>
void test2(C *c, int *int_buf, T tag)
{
c->MPI_Send(int_buf, 1, tag); // no-warning
}
void test3(C *c, int *int_buf) {
test2(c, int_buf, MPI_INT);
test2(c, int_buf, MPI_NULL);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/attr-sentinel.c
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
#define NULL (void*)0
#define ATTR __attribute__ ((__sentinel__))
void foo1 (int x, ...) ATTR; // expected-note 3 {{function has been explicitly marked sentinel here}}
void foo5 (int x, ...) __attribute__ ((__sentinel__(1))); // expected-note {{function has been explicitly marked sentinel here}}
void foo6 (int x, ...) __attribute__ ((__sentinel__(5))); // expected-note {{function has been explicitly marked sentinel here}}
void foo7 (int x, ...) __attribute__ ((__sentinel__(0))); // expected-note {{function has been explicitly marked sentinel here}}
void foo10 (int x, ...) __attribute__ ((__sentinel__(1,1)));
void foo12 (int x, ... ) ATTR; // expected-note {{function has been explicitly marked sentinel here}}
#define FOOMACRO(...) foo1(__VA_ARGS__)
void test1() {
foo1(1, NULL); // OK
foo1(1, 0) ; // expected-warning {{missing sentinel in function call}}
foo5(1, NULL, 2); // OK
foo5(1,2,NULL, 1); // OK
foo5(1, NULL, 2, 1); // expected-warning {{missing sentinel in function call}}
foo6(1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
foo6(1,NULL,3,4,5,6,7); // OK
foo7(1); // expected-warning {{not enough variable arguments in 'foo7' declaration to fit a sentinel}}
foo7(1, NULL); // OK
foo12(1); // expected-warning {{not enough variable arguments in 'foo12' declaration to fit a sentinel}}
// PR 5685
struct A {};
struct A a, b, c;
foo1(3, &a, &b, &c); // expected-warning {{missing sentinel in function call}}
foo1(3, &a, &b, &c, (struct A*) 0);
// PR11002
FOOMACRO(1, 2); // expected-warning {{missing sentinel in function call}}
}
void (*e) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (1,1)));
void test2() {
void (*b) (int arg, const char * format, ...) __attribute__ ((__sentinel__)); // expected-note {{function has been explicitly marked sentinel here}}
void (*z) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (2))); // expected-note {{function has been explicitly marked sentinel here}}
void (*y) (int arg, const char * format, ...) __attribute__ ((__sentinel__ (5))); // expected-note {{function has been explicitly marked sentinel here}}
b(1, "%s", (void*)0); // OK
b(1, "%s", 0); // expected-warning {{missing sentinel in function call}}
z(1, "%s",4 ,1,0); // expected-warning {{missing sentinel in function call}}
z(1, "%s", (void*)0, 1, 0); // OK
y(1, "%s", 1,2,3,4,5,6,7); // expected-warning {{missing sentinel in function call}}
y(1, "%s", (void*)0,3,4,5,6,7); // OK
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/Sema
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/Inputs/format-unused-system-args.h
|
// "System header" for testing that -Wformat-extra-args does not apply to
// arguments specified in system headers.
#define PRINT2(fmt, a1, a2) \
printf((fmt), (a1), (a2))
#define PRINT1(fmt, a1) \
PRINT2((fmt), (a1), 0)
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/Sema
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/Inputs/pragma-arc-cf-code-audited.h
|
#pragma clang arc_cf_code_audited begin
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/Sema
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/Inputs/warn-unreachable.h
|
// Test that this unreachable code warning is
// not reported because it is in a header.
void foo_unreachable_header() {
return;
foo_unreachable_header(); // no-warning
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/Sema
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/Inputs/unused-expr-system-header.h
|
// "System header" for testing that -Wunused-value is properly suppressed in
// certain cases.
#define POSSIBLY_BAD_MACRO(x) \
{ int i = x; \
i; }
#define STATEMENT_EXPR_MACRO(x) \
(__extension__ \
({int i = x; \
i;}))
#define COMMA_MACRO_1(x, y) \
{x, y;}
#define COMMA_MACRO_2(x, y) \
if (x) { 1 == 2, y; }
#define COMMA_MACRO_3(x, y) \
(x, y)
#define COMMA_MACRO_4(x, y) \
( 1 == 2, y )
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/Sema
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/Inputs/ms-keyword-system-header.h
|
/* "System header" for testing GNU libc keyword conflict workarounds */
typedef union {
union w *__uptr;
#if defined(MS) && defined(NOT_SYSTEM)
// expected-warning@-2 {{keyword '__uptr' will be made available as an identifier here}}
#endif
int *__iptr;
} WS __attribute__((__transparent_union__));
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/Sema
|
repos/DirectXShaderCompiler/tools/clang/test/Sema/Inputs/conversion.h
|
/* Fake system header for Sema/conversion.c */
#define LONG_MAX __LONG_MAX__
#define SETBIT(set,bit) do { int i = bit; set[i/(8*sizeof(set[0]))] |= (1 << (i%(8*sizeof(set)))); } while(0)
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CodeGenSPIRV
|
repos/DirectXShaderCompiler/tools/clang/test/CodeGenSPIRV/legal-examples/README.md
|
Legalization Examples
=====================
HLSL legalization for SPIR-V is a fuzzy topic; it cannot be expressed precisely
using some grammar. Instead, we've collected a few simple examples here to
show what cases are allowed and what not.
These examples are all variants to `0-copy-sbuf.hlsl`. And `*-ok.hlsl` are
allowed cases, while `*-fail.hlsl` are not allowed cases.
Also keep in mind that legalization is an ongoing effort; support has evolved
and will continue to evolve over time in response to new use cases in the wild.
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx1y-initializer-aggregates.cpp
|
// RUN: %clang_cc1 -std=c++1y %s -verify
namespace in_class_init {
union U { char c; double d = 4.0; };
constexpr U u1 = U();
constexpr U u2 {};
constexpr U u3 { 'x' };
static_assert(u1.d == 4.0, "");
static_assert(u2.d == 4.0, "");
static_assert(u3.c == 'x', "");
struct A {
int n = 5;
int m = n * 3;
union {
char c;
double d = 4.0;
};
};
constexpr A a1 {};
constexpr A a2 { 8 };
constexpr A a3 { 1, 2, { 3 } };
constexpr A a4 { 1, 2, { .d = 3.0 } };
static_assert(a1.d == 4.0, "");
static_assert(a2.m == 24, "");
static_assert(a2.d == 4.0, "");
static_assert(a3.c == 3, "");
static_assert(a3.d == 4.0, ""); // expected-error {{constant expression}} expected-note {{active member 'c'}}
static_assert(a4.d == 3.0, "");
struct B {
int n;
constexpr int f() { return n * 5; }
int m = f();
};
B b1 {};
constexpr B b2 { 2 };
B b3 { 1, 2 };
static_assert(b2.m == 10, "");
struct C {
int k;
union {
int l = k; // expected-error {{invalid use of non-static}}
};
};
}
namespace nested_aggregate_init {
struct A {
int n = 5;
int b = n * 3;
};
struct B {
constexpr B(int k) : d(1.23), k(k) {}
// Within this aggregate, both this object's 'this' and the temporary's
// 'this' are used.
constexpr int f() const { return A{k}.b; }
double d;
int k;
};
static_assert(B(6).f() == 18, "");
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/zero-length-arrays.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
// <rdar://problem/10228639>
class Foo {
~Foo();
Foo(const Foo&);
public:
Foo(int);
};
class Bar {
int foo_count;
Foo foos[0];
Foo foos2[0][2];
Foo foos3[2][0];
public:
Bar(): foo_count(0) { }
~Bar() { }
};
void testBar() {
Bar b;
Bar b2(b);
b = b2;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/class.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
class C {
public:
auto int errx; // expected-error {{storage class specified for a member declaration}} expected-warning {{'auto' storage class specifier is redundant}}
register int erry; // expected-error {{storage class specified for a member declaration}}
extern int errz; // expected-error {{storage class specified for a member declaration}}
static void sm() {
sx = 0;
this->x = 0; // expected-error {{invalid use of 'this' outside of a non-static member function}}
x = 0; // expected-error {{invalid use of member 'x' in static member function}}
}
class NestedC {
public:
NestedC(int);
void f() {
sx = 0;
x = 0; // expected-error {{use of non-static data member 'x' of 'C' from nested type 'NestedC'}}
sm();
m(); // expected-error {{call to non-static member function 'm' of 'C' from nested type 'NestedC'}}
}
};
int b : 1, w : 2;
int : 1, : 2;
typedef int E : 1; // expected-error {{typedef member 'E' cannot be a bit-field}}
static int sb : 1; // expected-error {{static member 'sb' cannot be a bit-field}}
static int vs;
typedef int func();
func tm;
func *ptm;
func btm : 1; // expected-error {{bit-field 'btm' has non-integral type}}
NestedC bc : 1; // expected-error {{bit-field 'bc' has non-integral type}}
enum E1 { en1, en2 };
int i = 0; // expected-warning {{in-class initialization of non-static data member is a C++11 extension}}
static int si = 0; // expected-error {{non-const static data member must be initialized out of line}}
static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}}
static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}}
static const int vi = 0;
static const volatile int cvi = 0; // ok, illegal in C++11
static const E evi = 0;
void m() {
sx = 0;
this->x = 0;
y = 0;
this = 0; // expected-error {{expression is not assignable}}
}
int f1(int p) {
A z = 6;
return p + x + this->y + z;
}
typedef int A;
virtual int viv; // expected-error {{'virtual' can only appear on non-static member functions}}
virtual static int vsif(); // expected-error {{'virtual' can only appear on non-static member functions}}
virtual int vif();
private:
int x,y;
static int sx;
mutable int mi;
mutable int &mir; // expected-error {{'mutable' cannot be applied to references}}
mutable void mfn(); // expected-error {{'mutable' cannot be applied to functions}}
mutable const int mci; // expected-error {{'mutable' and 'const' cannot be mixed}}
static const int number = 50;
static int arr[number];
};
class C2 {
void f() {
static int lx;
class LC1 {
int m() { return lx; }
};
class LC2 {
int m() { return lx; }
};
}
};
struct C3 {
int i;
mutable int j;
};
void f()
{
const C3 c3 = { 1, 2 };
(void)static_cast<int*>(&c3.i); // expected-error {{static_cast from 'const int *' to 'int *' is not allowed}}
// but no error here
(void)static_cast<int*>(&c3.j);
}
// Play with mutable a bit more, to make sure it doesn't crash anything.
mutable int gi; // expected-error {{'mutable' can only be applied to member variables}}
mutable void gfn(); // expected-error {{illegal storage class on function}}
void ogfn()
{
mutable int ml; // expected-error {{'mutable' can only be applied to member variables}}
// PR3020: This used to crash due to double ownership of C4.
struct C4;
C4; // expected-warning {{declaration does not declare anything}}
}
struct C4 {
void f(); // expected-note{{previous declaration is here}}
int f; // expected-error{{duplicate member 'f'}}
};
// PR5415 - don't hang!
struct S
{
void f(); // expected-note 1 {{previous declaration}} expected-note {{previous declaration}}
void S::f() {} // expected-error {{extra qualification on member}} expected-error {{class member cannot be redeclared}}
void f() {} // expected-error {{class member cannot be redeclared}}
};
// Don't crash on this bogus code.
namespace pr6629 {
template<class T1, class T2> struct foo :
bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}}
{ };
template<> struct foo<unknown,unknown> { // expected-error {{undeclared identifier 'unknown'}}
template <typename U1, typename U2> struct bar {
typedef bar type;
static const int value = 0;
};
};
}
namespace PR7153 {
class EnclosingClass {
public:
struct A { } mutable *member;
};
void f(const EnclosingClass &ec) {
ec.member = 0;
}
}
namespace PR7196 {
struct A {
int a;
void f() {
char i[sizeof(a)];
enum { x = sizeof(i) };
enum { y = sizeof(a) };
}
};
}
namespace rdar8066414 {
class C {
C() {}
} // expected-error{{expected ';' after class}}
}
namespace rdar8367341 {
float foo();
struct A {
static const float x = 5.0f; // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}}
static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} expected-error {{in-class initializer for static data member is not a constant expression}}
};
}
namespace with_anon {
struct S {
union {
char c;
};
};
void f() {
S::c; // expected-error {{invalid use of non-static data member}}
}
}
struct PR9989 {
static int const PR9989_Member = sizeof PR9989_Member;
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/openmp_default_simd_align.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -triple x86_64-unknown-unknown -verify %s
struct S0 {
int x;
static const int test0 = __builtin_omp_required_simd_align(x); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an expression, only type is allowed}}
static const int test1 = __builtin_omp_required_simd_align(decltype(S0::x));
auto test2() -> char(&)[__builtin_omp_required_simd_align(decltype(x))];
};
struct S1; // expected-note 6 {{forward declaration}}
extern S1 s1;
const int test3 = __builtin_omp_required_simd_align(decltype(s1)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'decltype(s1)' (aka 'S1')}}
struct S2 {
S2();
S1 &s;
int x;
int test4 = __builtin_omp_required_simd_align(decltype(x)); // ok
int test5 = __builtin_omp_required_simd_align(decltype(s)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'S1'}}
};
const int test6 = __builtin_omp_required_simd_align(decltype(S2::x));
const int test7 = __builtin_omp_required_simd_align(decltype(S2::s)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'S1'}}
// Arguably, these should fail like the S1 cases do: the alignment of
// 's2.x' should depend on the alignment of both x-within-S2 and
// s2-within-S3 and thus require 'S3' to be complete. If we start
// doing the appropriate recursive walk to do that, we should make
// sure that these cases don't explode.
struct S3 {
S2 s2;
static const int test8 = __builtin_omp_required_simd_align(decltype(s2.x));
static const int test9 = __builtin_omp_required_simd_align(decltype(s2.s)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'S1'}}
auto test10() -> char(&)[__builtin_omp_required_simd_align(decltype(s2.x))];
static const int test11 = __builtin_omp_required_simd_align(decltype(S3::s2.x));
static const int test12 = __builtin_omp_required_simd_align(decltype(S3::s2.s)); // expected-error {{invalid application of '__builtin_omp_required_simd_align' to an incomplete type 'S1'}}
auto test13() -> char(&)[__builtin_omp_required_simd_align(decltype(s2.x))];
};
// Same reasoning as S3.
struct S4 {
union {
int x;
};
static const int test0 = __builtin_omp_required_simd_align(decltype(x));
static const int test1 = __builtin_omp_required_simd_align(decltype(S0::x));
auto test2() -> char(&)[__builtin_omp_required_simd_align(decltype(x))];
};
// Regression test for asking for the alignment of a field within an invalid
// record.
struct S5 {
S1 s; // expected-error {{incomplete type}}
int x;
};
const int test8 = __builtin_omp_required_simd_align(decltype(S5::x));
long long int test14[2];
static_assert(__builtin_omp_required_simd_align(decltype(test14)) == 16, "foo");
static_assert(__builtin_omp_required_simd_align(int[2]) == __builtin_omp_required_simd_align(int), ""); // ok
namespace __builtin_omp_required_simd_align_array_expr {
alignas(32) extern int n[2];
static_assert(__builtin_omp_required_simd_align(decltype(n)) == 16, "");
template<int> struct S {
static int a[];
};
template<int N> int S<N>::a[N];
static_assert(__builtin_omp_required_simd_align(decltype(S<1>::a)) == __builtin_omp_required_simd_align(int), "");
static_assert(__builtin_omp_required_simd_align(decltype(S<1128>::a)) == __builtin_omp_required_simd_align(int), "");
}
template <typename T> void n(T) {
alignas(T) int T1;
char k[__builtin_omp_required_simd_align(decltype(T1))];
static_assert(sizeof(k) == __builtin_omp_required_simd_align(long long), "");
}
template void n(long long);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/default2.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f(int i, int j, int k = 3);
void f(int i, int j, int k);
void f(int i, int j = 2, int k);
void f(int i, int j, int k);
void f(int i = 1, int j, int k);
void f(int i, int j, int k);
void i()
{
f();
f(0);
f(0, 1);
f(0, 1, 2);
}
int f1(int i, // expected-note {{previous declaration is here}}
int i, int j) { // expected-error {{redefinition of parameter 'i'}}
i = 17;
return j;
}
int x;
void g(int x, int y = x); // expected-error {{default argument references parameter 'x'}}
void g2(int x, int y, int z = x + y); // expected-error {{default argument references parameter 'x'}} expected-error {{default argument references parameter 'y'}}
class X {
void f(X* x = this); // expected-error{{invalid use of 'this' outside of a non-static member function}}
void g() {
int f(X* x = this); // expected-error{{default argument references 'this'}}
}
};
// C++ [dcl.fct.default]p6
class C {
static int x;
void f(int i = 3); // expected-note{{previous definition is here}}
void g(int i, int j = x);
void h();
};
void C::f(int i = 3) // expected-error{{redefinition of default argument}}
{ }
void C::g(int i = 88, int j) {}
void C::h() {
g(); // okay
}
// C++ [dcl.fct.default]p9
struct Y {
int a;
int mem1(int i = a); // expected-error{{invalid use of non-static data member 'a'}}
int mem2(int i = b); // OK; use Y::b
int mem3(int i);
int mem4(int i);
struct Nested {
int mem5(int i = b, // OK; use Y::b
int j = c, // OK; use Y::Nested::c
int k = j, // expected-error{{default argument references parameter 'j'}}
int l = a, // expected-error{{invalid use of non-static data member 'a'}}
Nested* self = this, // expected-error{{invalid use of 'this' outside of a non-static member function}}
int m); // expected-error{{missing default argument on parameter 'm'}}
static int c;
Nested(int i = 42);
};
int mem7(Nested n = Nested());
static int b;
};
int Y::mem3(int i = b) { return i; } // OK; use X::b
int Y::mem4(int i = a) // expected-error{{invalid use of non-static data member 'a'}}
{ return i; }
// Try to verify that default arguments interact properly with copy
// constructors.
class Z {
public:
Z(Z&, int i = 17); // expected-note 3 {{candidate constructor}}
void f(Z& z) {
Z z2; // expected-error{{no matching constructor for initialization}}
Z z3(z);
}
void test_Z(const Z& z) {
Z z2(z); // expected-error{{no matching constructor for initialization of 'Z'}}
}
};
void test_Z(const Z& z) {
Z z2(z); // expected-error{{no matching constructor for initialization of 'Z'}}
}
struct ZZ {
static ZZ g(int = 17);
void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}} \
// expected-note{{passing argument to parameter 'z' here}}
ZZ(ZZ&, int = 17); // expected-note{{candidate constructor}}
};
// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#325
class C2 {
static void g(int = f()); // expected-error{{use of default argument to function 'f' that is declared later in class 'C2'}}
static int f(int = 10); // expected-note{{default argument declared here}}
};
// Make sure we actually parse the default argument for an inline definition
class XX {
void A(int length = -1 ) { }
void B() { A(); }
};
template <int I = (1 * I)> struct S {}; // expected-error-re {{use of undeclared identifier 'I'{{$}}}}
S<1> s;
template <int I1 = I2, int I2 = 1> struct T {}; // expected-error-re {{use of undeclared identifier 'I2'{{$}}}}
T<0, 1> t;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/PR8884.cpp
|
// RUN: %clang_cc1 -fsyntax-only %s
extern "C" {
class bar {
friend struct foo;
static struct foo& baz ();
};
struct foo {
void zed () {
bar::baz();
}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-range-loop-analysis.cpp
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wloop-analysis -verify %s
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wrange-loop-analysis -verify %s
template <typename return_type>
struct Iterator {
return_type operator*();
Iterator operator++();
bool operator!=(const Iterator);
};
template <typename T>
struct Container {
typedef Iterator<T> I;
I begin();
I end();
};
struct Foo {};
struct Bar {
Bar(Foo);
Bar(int);
operator int();
};
// Testing notes:
// test0 checks that the full text of the warnings and notes is correct. The
// rest of the tests checks a smaller portion of the text.
// test1-6 are set in pairs, the odd numbers are the non-reference returning
// versions of the even numbers.
// test7-9 use an array instead of a range object
// tests use all four versions of the loop varaible, const &T, const T, T&, and
// T. Versions producing errors and are commented out.
//
// Conversion chart:
// double <=> int
// int <=> Bar
// double => Bar
// Foo => Bar
//
// Conversions during tests:
// test1-2
// int => int
// int => double
// int => Bar
// test3-4
// Bar => Bar
// Bar => int
// test5-6
// Foo => Bar
// test7
// double => double
// double => int
// double => Bar
// test8
// Foo => Foo
// Foo => Bar
// test9
// Bar => Bar
// Bar => int
void test0() {
Container<int> int_non_ref_container;
Container<int&> int_container;
Container<Bar&> bar_container;
for (const int &x : int_non_ref_container) {}
// expected-warning@-1 {{loop variable 'x' is always a copy because the range of type 'Container<int>' does not return a reference}}
// expected-note@-2 {{use non-reference type 'int'}}
for (const double &x : int_container) {}
// expected-warning@-1 {{loop variable 'x' has type 'const double &' but is initialized with type 'int' resulting in a copy}}
// expected-note@-2 {{use non-reference type 'double' to keep the copy or type 'const int &' to prevent copying}}
for (const Bar x : bar_container) {}
// expected-warning@-1 {{loop variable 'x' of type 'const Bar' creates a copy from type 'const Bar'}}
// expected-note@-2 {{use reference type 'const Bar &' to prevent copying}}
}
void test1() {
Container<int> A;
for (const int &x : A) {}
// expected-warning@-1 {{always a copy}}
// expected-note@-2 {{'int'}}
for (const int x : A) {}
// No warning, non-reference type indicates copy is made
//for (int &x : A) {}
// Binding error
for (int x : A) {}
// No warning, non-reference type indicates copy is made
for (const double &x : A) {}
// expected-warning@-1 {{always a copy}}
// expected-note@-2 {{'double'}}
for (const double x : A) {}
// No warning, non-reference type indicates copy is made
//for (double &x : A) {}
// Binding error
for (double x : A) {}
// No warning, non-reference type indicates copy is made
for (const Bar &x : A) {}
// expected-warning@-1 {{always a copy}}
// expected-note@-2 {{'Bar'}}
for (const Bar x : A) {}
// No warning, non-reference type indicates copy is made
//for (Bar &x : A) {}
// Binding error
for (Bar x : A) {}
// No warning, non-reference type indicates copy is made
}
void test2() {
Container<int&> B;
for (const int &x : B) {}
// No warning, this reference is not a temporary
for (const int x : B) {}
// No warning on POD copy
for (int &x : B) {}
// No warning
for (int x : B) {}
// No warning
for (const double &x : B) {}
// expected-warning@-1 {{resulting in a copy}}
// expected-note-re@-2 {{'double'{{.*}}'const int &'}}
for (const double x : B) {}
//for (double &x : B) {}
// Binding error
for (double x : B) {}
// No warning
for (const Bar &x : B) {}
// expected-warning@-1 {{resulting in a copy}}
// expected-note@-2 {{'Bar'}}
for (const Bar x : B) {}
//for (Bar &x : B) {}
// Binding error
for (Bar x : B) {}
// No warning
}
void test3() {
Container<Bar> C;
for (const Bar &x : C) {}
// expected-warning@-1 {{always a copy}}
// expected-note@-2 {{'Bar'}}
for (const Bar x : C) {}
// No warning, non-reference type indicates copy is made
//for (Bar &x : C) {}
// Binding error
for (Bar x : C) {}
// No warning, non-reference type indicates copy is made
for (const int &x : C) {}
// expected-warning@-1 {{always a copy}}
// expected-note@-2 {{'int'}}
for (const int x : C) {}
// No warning, copy made
//for (int &x : C) {}
// Binding error
for (int x : C) {}
// No warning, copy made
}
void test4() {
Container<Bar&> D;
for (const Bar &x : D) {}
// No warning, this reference is not a temporary
for (const Bar x : D) {}
// expected-warning@-1 {{creates a copy}}
// expected-note@-2 {{'const Bar &'}}
for (Bar &x : D) {}
// No warning
for (Bar x : D) {}
// No warning
for (const int &x : D) {}
// expected-warning@-1 {{resulting in a copy}}
// expected-note-re@-2 {{'int'{{.*}}'const Bar &'}}
for (const int x : D) {}
// No warning
//for (int &x : D) {}
// Binding error
for (int x : D) {}
// No warning
}
void test5() {
Container<Foo> E;
for (const Bar &x : E) {}
// expected-warning@-1 {{always a copy}}
// expected-note@-2 {{'Bar'}}
for (const Bar x : E) {}
// No warning, non-reference type indicates copy is made
//for (Bar &x : E) {}
// Binding error
for (Bar x : E) {}
// No warning, non-reference type indicates copy is made
}
void test6() {
Container<Foo&> F;
for (const Bar &x : F) {}
// expected-warning@-1 {{resulting in a copy}}
// expected-note-re@-2 {{'Bar'{{.*}}'const Foo &'}}
for (const Bar x : F) {}
// No warning.
//for (Bar &x : F) {}
// Binding error
for (Bar x : F) {}
// No warning
}
void test7() {
double G[2];
for (const double &x : G) {}
// No warning
for (const double x : G) {}
// No warning on POD copy
for (double &x : G) {}
// No warning
for (double x : G) {}
// No warning
for (const int &x : G) {}
// expected-warning@-1 {{resulting in a copy}}
// expected-note-re@-2 {{'int'{{.*}}'const double &'}}
for (const int x : G) {}
// No warning
//for (int &x : G) {}
// Binding error
for (int x : G) {}
// No warning
for (const Bar &x : G) {}
// expected-warning@-1 {{resulting in a copy}}
// expected-note-re@-2 {{'Bar'{{.*}}'const double &'}}
for (const Bar x : G) {}
// No warning
//for (int &Bar : G) {}
// Binding error
for (int Bar : G) {}
// No warning
}
void test8() {
Foo H[2];
for (const Foo &x : H) {}
// No warning
for (const Foo x : H) {}
// No warning on POD copy
for (Foo &x : H) {}
// No warning
for (Foo x : H) {}
// No warning
for (const Bar &x : H) {}
// expected-warning@-1 {{resulting in a copy}}
// expected-note-re@-2 {{'Bar'{{.*}}'const Foo &'}}
for (const Bar x : H) {}
// No warning
//for (Bar &x: H) {}
// Binding error
for (Bar x: H) {}
// No warning
}
void test9() {
Bar I[2] = {1,2};
for (const Bar &x : I) {}
// No warning
for (const Bar x : I) {}
// expected-warning@-1 {{creates a copy}}
// expected-note@-2 {{'const Bar &'}}
for (Bar &x : I) {}
// No warning
for (Bar x : I) {}
// No warning
for (const int &x : I) {}
// expected-warning@-1 {{resulting in a copy}}
// expected-note-re@-2 {{'int'{{.*}}'const Bar &'}}
for (const int x : I) {}
// No warning
//for (int &x : I) {}
// Binding error
for (int x : I) {}
// No warning
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx0x-delegating-ctors.cpp
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
struct foo {
int i;
foo();
foo(int);
foo(int, int);
foo(bool);
foo(char);
foo(const float*);
foo(const float&);
foo(void*);
};
// Good
foo::foo (int i) : i(i) {
}
// Good
foo::foo () : foo(-1) {
}
// Good
foo::foo (int, int) : foo() {
}
foo::foo (bool) : foo(true) { // expected-error{{creates a delegation cycle}}
}
// Good
foo::foo (const float* f) : foo(*f) { // expected-note{{it delegates to}}
}
foo::foo (const float &f) : foo(&f) { //expected-error{{creates a delegation cycle}} \
//expected-note{{which delegates to}}
}
foo::foo (char) :
i(3),
foo(3) { // expected-error{{must appear alone}}
}
// This should not cause an infinite loop
foo::foo (void*) : foo(4.0f) {
}
struct deleted_dtor {
~deleted_dtor() = delete; // expected-note{{'~deleted_dtor' has been explicitly marked deleted here}}
deleted_dtor();
deleted_dtor(int) : deleted_dtor() // expected-error{{attempt to use a deleted function}}
{}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/block-call.cpp
|
// RUN: %clang_cc1 -x c++ -fsyntax-only -verify %s -fblocks
int (*FP)();
int (^IFP) ();
int (^II) (int);
int main() {
int (*FPL) (int) = FP; // expected-error {{cannot initialize a variable of type 'int (*)(int)' with an lvalue of type 'int (*)()'}}
// For Blocks, the ASTContext::typesAreBlockCompatible() makes sure this is an error.
int (^PFR) (int) = IFP; // expected-error {{cannot initialize a variable of type 'int (^)(int)' with an lvalue of type 'int (^)()'}}
PFR = II; // OK
int (^IFP) () = PFR; // OK
const int (^CIC) () = IFP; // OK - initializing 'const int (^)()' with an expression of type 'int (^)()'}}
const int (^CICC) () = CIC;
int * const (^IPCC) () = 0;
int * const (^IPCC1) () = IPCC;
int * (^IPCC2) () = IPCC; // expected-error {{cannot initialize a variable of type 'int *(^)()' with an lvalue of type 'int *const (^)()'}}
int (^IPCC3) (const int) = PFR;
int (^IPCC4) (int, char (^CArg) (double));
int (^IPCC5) (int, char (^CArg) (double)) = IPCC4;
int (^IPCC6) (int, char (^CArg) (float)) = IPCC4; // expected-error {{cannot initialize a variable of type 'int (^)(int, char (^)(float))' with an lvalue of type}}
IPCC2 = 0;
IPCC2 = 1;
int (^x)() = 0;
int (^y)() = 3; // expected-error {{cannot initialize a variable of type 'int (^)()' with an rvalue of type 'int'}}
int a = 1;
int (^z)() = a+4; // expected-error {{cannot initialize a variable of type 'int (^)()' with an rvalue of type 'int'}}
}
int blah() {
int (^IFP) (float);
char (^PCP)(double, double, char);
IFP(1.0);
IFP (1.0, 2.0); // expected-error {{too many arguments to block call}}
char ch = PCP(1.0, 2.0, 'a');
return PCP(1.0, 2.0); // expected-error {{too few arguments to block}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-weak-vtables.cpp
|
// RUN: %clang_cc1 %s -fsyntax-only -verify -triple %itanium_abi_triple -Wweak-vtables -Wweak-template-vtables
// RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror -Wno-weak-vtables -Wno-weak-template-vtables
struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
virtual void f() { }
};
template<typename T> struct B {
virtual void f() { }
};
namespace {
struct C {
virtual void f() { }
};
}
void f() {
struct A {
virtual void f() { }
};
A a;
}
// Use the vtables
void uses_abc() {
A a;
B<int> b;
C c;
}
// <rdar://problem/9979458>
class Parent {
public:
Parent() {}
virtual ~Parent();
virtual void * getFoo() const = 0;
};
class Derived : public Parent {
public:
Derived();
void * getFoo() const;
};
class VeryDerived : public Derived { // expected-warning{{'VeryDerived' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
public:
void * getFoo() const { return 0; }
};
Parent::~Parent() {}
void uses_derived() {
Derived d;
VeryDerived vd;
}
template<typename T> struct TemplVirt {
virtual void f();
};
template class TemplVirt<float>; // expected-warning{{explicit template instantiation 'TemplVirt<float>' will emit a vtable in every translation unit}}
template<> struct TemplVirt<bool> {
virtual void f();
};
template<> struct TemplVirt<long> { // expected-warning{{'TemplVirt<long>' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
virtual void f() {}
};
void uses_templ() {
TemplVirt<float> f;
TemplVirt<bool> b;
TemplVirt<long> l;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/writable-strings-deprecated.cpp
|
// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-writable-strings -verify %s
// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated -Wdeprecated-increment-bool -verify %s
// RUN: %clang_cc1 -fsyntax-only -fwritable-strings -verify %s
// RUN: %clang_cc1 -fsyntax-only -Wno-write-strings -verify %s
// RUN: %clang_cc1 -fsyntax-only -Werror=c++11-compat -verify %s -DERROR
// RUN: %clang_cc1 -fsyntax-only -Werror=deprecated -Wno-error=deprecated-increment-bool -verify %s -DERROR
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wno-deprecated -Wdeprecated-increment-bool
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -pedantic-errors -DERROR
// rdar://8827606
char *fun(void)
{
return "foo";
#if __cplusplus >= 201103L
#ifdef ERROR
// expected-error@-3 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
#else
// expected-warning@-5 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
#endif
#elif defined(ERROR)
// expected-error@-8 {{deprecated}}
#endif
}
void test(bool b)
{
++b; // expected-warning {{incrementing expression of type bool is deprecated}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-static-const-float.cpp
|
// RUN: %clang_cc1 -verify %s -std=c++98 -DEXT
// RUN: %clang_cc1 -verify %s -std=c++98 -Wno-gnu -DNONE
// RUN: %clang_cc1 -verify %s -std=c++98 -Wno-static-float-init -DNONE
// RUN: %clang_cc1 -verify %s -std=c++98 -Wno-gnu-static-float-init -DNONE
// RUN: %clang_cc1 -verify %s -std=c++11 -DERR
// RUN: %clang_cc1 -verify %s -std=c++11 -Wno-gnu -DERR
// RUN: %clang_cc1 -verify %s -std=c++11 -Wno-static-float-init -DNONE
// RUN: %clang_cc1 -verify %s -std=c++11 -Wno-gnu-static-float-init -DERR
#if NONE
// expected-no-diagnostics
#elif ERR
// expected-error@20 {{in-class initializer for static data member of type 'const double' requires 'constexpr' specifier}}
// expected-note@20 {{add 'constexpr'}}
#elif EXT
// expected-warning@20 {{in-class initializer for static data member of type 'const double' is a GNU extension}}
#endif
struct X {
static const double x = 0.0;
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/unreachable-code.cpp
|
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -Wunreachable-code-aggressive -fblocks -verify %s
int j;
int bar();
int test1() {
for (int i = 0;
i != 10;
++i) { // expected-warning {{loop will run at most once (loop increment never executed)}}
if (j == 23) // missing {}'s
bar();
return 1;
}
return 0;
return 1; // expected-warning {{will never be executed}}
}
int test1_B() {
for (int i = 0;
i != 10;
++i) { // expected-warning {{loop will run at most once (loop increment never executed)}}
if (j == 23) // missing {}'s
bar();
return 1;
}
return 0;
return bar(); // expected-warning {{will never be executed}}
}
void test2(int i) {
switch (i) {
case 0:
break;
bar(); // expected-warning {{will never be executed}}
case 2:
switch (i) {
default:
a: goto a;
}
bar(); // expected-warning {{will never be executed}}
}
b: goto b;
bar(); // expected-warning {{will never be executed}}
}
void test3() {
^{ return;
bar(); // expected-warning {{will never be executed}}
}();
while (++j) {
continue;
bar(); // expected-warning {{will never be executed}}
}
}
// PR 6130 - Don't warn about bogus unreachable code with throw's and
// temporary objects.
class PR6130 {
public:
PR6130();
~PR6130();
};
int pr6130(unsigned i) {
switch(i) {
case 0: return 1;
case 1: return 2;
default:
throw PR6130(); // no-warning
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/type-formatting.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct X0 { };
struct X1 { };
template<typename T>
void f0() {
const T *t = (const X0*)0; // expected-error{{cannot initialize a variable of type 'const X1 *' with an rvalue of type 'const X0 *'}}
}
template void f0<X1>(); // expected-note{{instantiation of}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/qualified-id-lookup.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace Ns {
int f(); // expected-note{{previous declaration is here}}
enum E {
Enumerator
};
}
namespace Ns {
double f(); // expected-error{{functions that differ only in their return type cannot be overloaded}}
int x = Enumerator;
}
namespace Ns2 {
float f();
}
int y = Ns::Enumerator;
namespace Ns2 {
float f(int); // expected-note{{previous declaration is here}}
}
namespace Ns2 {
double f(int); // expected-error{{functions that differ only in their return type cannot be overloaded}}
}
namespace N {
int& f1();
}
namespace N {
struct f1 {
static int member;
typedef int type;
void foo(type);
};
void test_f1() {
int &i1 = f1();
}
}
void N::f1::foo(int i) {
f1::member = i;
f1::type &ir = i;
}
namespace N {
float& f1(int x) {
N::f1::type& i1 = x;
f1::type& i2 = x;
}
struct f2 {
static int member;
};
void f2();
}
int i1 = N::f1::member;
typedef struct N::f1 type1;
int i2 = N::f2::member;
typedef struct N::f2 type2;
void test_f1(int i) {
int &v1 = N::f1();
float &v2 = N::f1(i);
int v3 = ::i1;
int v4 = N::f1::member;
}
typedef int f2_type;
namespace a {
typedef int f2_type(int, int);
void test_f2() {
::f2_type(1, 2); // expected-error {{excess elements in scalar initializer}}
}
}
// PR clang/3291
namespace a {
namespace a { // A1
namespace a { // A2
int i; // expected-note{{'a::a::a::i' declared here}}
}
}
}
void test_a() {
a::a::i = 3; // expected-error{{no member named 'i' in namespace 'a::a'; did you mean 'a::a::a::i'?}}
a::a::a::i = 4;
a::a::j = 3; // expected-error-re{{no member named 'j' in namespace 'a::a'{{$}}}}
}
struct Undef { // expected-note{{definition of 'Undef' is not complete until the closing '}'}}
typedef int type;
Undef::type member;
static int size = sizeof(Undef); // expected-error{{invalid application of 'sizeof' to an incomplete type 'Undef'}}
int f();
};
int Undef::f() {
return sizeof(Undef);
}
// PR clang/5667
namespace test1 {
template <typename T> struct is_class {
enum { value = 0 };
};
template <typename T> class ClassChecker {
bool isClass() {
return is_class<T>::value;
}
};
template class ClassChecker<int>;
}
namespace PR6830 {
namespace foo {
class X {
public:
X() {}
};
} // namespace foo
class Z {
public:
explicit Z(const foo::X& x) {}
void Work() {}
};
void Test() {
Z(foo::X()).Work();
}
}
namespace pr12339 {
extern "C" void i; // expected-error{{variable has incomplete type 'void'}}
pr12339::FOO // expected-error{{no type named 'FOO' in namespace 'pr12339'}}
} // expected-error{{expected unqualified-id}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/new-delete.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -Wno-new-returns-null
#include <stddef.h>
struct S // expected-note {{candidate}}
{
S(int, int, double); // expected-note {{candidate}}
S(double, int); // expected-note 2 {{candidate}}
S(float, int); // expected-note 2 {{candidate}}
};
struct T; // expected-note{{forward declaration of 'T'}}
struct U
{
// A special new, to verify that the global version isn't used.
void* operator new(size_t, S*); // expected-note {{candidate}}
};
struct V : U
{
};
inline void operator delete(void *); // expected-warning {{replacement function 'operator delete' cannot be declared 'inline'}}
__attribute__((used))
inline void *operator new(size_t) { // no warning, due to __attribute__((used))
return 0;
}
// PR5823
void* operator new(const size_t); // expected-note 2 {{candidate}}
void* operator new(size_t, int*); // expected-note 3 {{candidate}}
void* operator new(size_t, float*); // expected-note 3 {{candidate}}
void* operator new(size_t, S); // expected-note 2 {{candidate}}
struct foo { };
void good_news()
{
int *pi = new int;
float *pf = new (pi) float();
pi = new int(1);
pi = new int('c');
const int *pci = new const int();
S *ps = new S(1, 2, 3.4);
ps = new (pf) (S)(1, 2, 3.4);
S *(*paps)[2] = new S*[*pi][2];
typedef int ia4[4];
ia4 *pai = new (int[3][4]);
pi = ::new int;
U *pu = new (ps) U;
V *pv = new (ps) V;
pi = new (S(1.0f, 2)) int;
(void)new int[true];
// PR7147
typedef int a[2];
foo* f1 = new foo;
foo* f2 = new foo[2];
typedef foo x[2];
typedef foo y[2][2];
x* f3 = new y;
}
struct abstract {
virtual ~abstract() = 0;
};
void bad_news(int *ip)
{
int i = 1; // expected-note 2{{here}}
(void)new; // expected-error {{expected a type}}
(void)new 4; // expected-error {{expected a type}}
(void)new () int; // expected-error {{expected expression}}
(void)new int[1.1]; // expected-error {{array size expression must have integral or enumeration type, not 'double'}}
(void)new int[1][i]; // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
(void)new (int[1][i]); // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
(void)new (int[i]); // expected-warning {{when type is in parentheses}}
(void)new int(*(S*)0); // expected-error {{no viable conversion from 'S' to 'int'}}
(void)new int(1, 2); // expected-error {{excess elements in scalar initializer}}
(void)new S(1); // expected-error {{no matching constructor}}
(void)new S(1, 1); // expected-error {{call to constructor of 'S' is ambiguous}}
(void)new const int; // expected-error {{default initialization of an object of const type 'const int'}}
(void)new float*(ip); // expected-error {{cannot initialize a new value of type 'float *' with an lvalue of type 'int *'}}
// Undefined, but clang should reject it directly.
(void)new int[-1]; // expected-error {{array size is negative}}
(void)new int[2000000000]; // expected-error {{array is too large}}
(void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumeration type, not 'S'}}
(void)::S::new int; // expected-error {{expected unqualified-id}}
(void)new (0, 0) int; // expected-error {{no matching function for call to 'operator new'}}
(void)new (0L) int; // expected-error {{call to 'operator new' is ambiguous}}
// This must fail, because the member version shouldn't be found.
(void)::new ((S*)0) U; // expected-error {{no matching function for call to 'operator new'}}
// This must fail, because any member version hides all global versions.
(void)new U; // expected-error {{no matching function for call to 'operator new'}}
(void)new (int[]); // expected-error {{array size must be specified in new expressions}}
(void)new int&; // expected-error {{cannot allocate reference type 'int &' with new}}
// Some lacking cases due to lack of sema support.
}
void good_deletes()
{
delete (int*)0;
delete [](int*)0;
delete (S*)0;
::delete (int*)0;
}
void bad_deletes()
{
delete 0; // expected-error {{cannot delete expression of type 'int'}}
delete [0] (int*)0; // expected-error {{expected expression}}
delete (void*)0; // expected-warning {{cannot delete expression with pointer-to-'void' type 'void *'}}
delete (T*)0; // expected-warning {{deleting pointer to incomplete type}}
::S::delete (int*)0; // expected-error {{expected unqualified-id}}
}
struct X0 { };
struct X1 {
operator int*();
operator float();
};
struct X2 {
operator int*(); // expected-note {{conversion}}
operator float*(); // expected-note {{conversion}}
};
void test_delete_conv(X0 x0, X1 x1, X2 x2) {
delete x0; // expected-error{{cannot delete}}
delete x1;
delete x2; // expected-error{{ambiguous conversion of delete expression of type 'X2' to a pointer}}
}
// PR4782
class X3 {
public:
static void operator delete(void * mem, size_t size);
};
class X4 {
public:
static void release(X3 *x);
static void operator delete(void * mem, size_t size);
};
void X4::release(X3 *x) {
delete x;
}
class X5 {
public:
void Destroy() const { delete this; }
};
class Base {
public:
static void *operator new(signed char) throw(); // expected-error {{'operator new' takes type size_t}}
static int operator new[] (size_t) throw(); // expected-error {{operator new[]' must return type 'void *'}}
};
class Tier {};
class Comp : public Tier {};
class Thai : public Base {
public:
Thai(const Tier *adoptDictionary);
};
void loadEngineFor() {
const Comp *dict;
new Thai(dict);
}
template <class T> struct TBase {
void* operator new(T size, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}}
};
TBase<int> t1;
class X6 {
public:
static void operator delete(void*, int); // expected-note {{member found by ambiguous name lookup}}
};
class X7 {
public:
static void operator delete(void*, int); // expected-note {{member found by ambiguous name lookup}}
};
class X8 : public X6, public X7 {
};
void f(X8 *x8) {
delete x8; // expected-error {{member 'operator delete' found in multiple base classes of different types}}
}
class X9 {
public:
static void operator delete(void*, int); // expected-note {{'operator delete' declared here}}
static void operator delete(void*, float); // expected-note {{'operator delete' declared here}}
};
void f(X9 *x9) {
delete x9; // expected-error {{no suitable member 'operator delete' in 'X9'}}
}
struct X10 {
virtual ~X10();
};
struct X11 : X10 { // expected-error {{no suitable member 'operator delete' in 'X11'}}
void operator delete(void*, int); // expected-note {{'operator delete' declared here}}
};
void f() {
X11 x11; // expected-note {{implicit destructor for 'X11' first required here}}
}
struct X12 {
void* operator new(size_t, void*);
};
struct X13 : X12 {
using X12::operator new;
};
static void* f(void* g)
{
return new (g) X13();
}
class X14 {
public:
static void operator delete(void*, const size_t);
};
void f(X14 *x14a, X14 *x14b) {
delete x14a;
}
class X15 {
private:
X15(); // expected-note {{declared private here}}
~X15(); // expected-note {{declared private here}}
};
void f(X15* x) {
new X15(); // expected-error {{calling a private constructor}}
delete x; // expected-error {{calling a private destructor}}
}
namespace PR5918 { // Look for template operator new overloads.
struct S { template<typename T> static void* operator new(size_t, T); };
void test() {
(void)new(0) S;
}
}
namespace Test1 {
void f() {
(void)new int[10](1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
typedef int T[10];
(void)new T(1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
}
template<typename T>
void g(unsigned i) {
(void)new T[1](i); // expected-error {{array 'new' cannot have initialization arguments}}
}
template<typename T>
void h(unsigned i) {
(void)new T(i); // expected-error {{array 'new' cannot have initialization arguments}}
}
template void h<unsigned>(unsigned);
template void h<unsigned[10]>(unsigned); // expected-note {{in instantiation of function template specialization 'Test1::h<unsigned int [10]>' requested here}}
}
// Don't diagnose access for overload candidates that aren't selected.
namespace PR7436 {
struct S1 {
void* operator new(size_t);
void operator delete(void* p);
private:
void* operator new(size_t, void*); // expected-note {{declared private here}}
void operator delete(void*, void*);
};
class S2 {
void* operator new(size_t); // expected-note {{declared private here}}
void operator delete(void* p); // expected-note {{declared private here}}
};
void test(S1* s1, S2* s2) {
delete s1;
delete s2; // expected-error {{is a private member}}
(void)new S1();
(void)new (0L) S1(); // expected-error {{is a private member}}
(void)new S2(); // expected-error {{is a private member}}
}
}
namespace rdar8018245 {
struct X0 {
static const int value = 17;
};
const int X0::value;
struct X1 {
static int value;
};
int X1::value;
template<typename T>
int *f() {
return new (int[T::value]); // expected-warning{{when type is in parentheses, array cannot have dynamic size}}
}
template int *f<X0>();
template int *f<X1>(); // expected-note{{in instantiation of}}
}
// <rdar://problem/8248780>
namespace Instantiate {
template<typename T> struct X {
operator T*();
};
void f(X<int> &xi) {
delete xi;
}
}
namespace PR7810 {
struct X {
// cv is ignored in arguments
static void operator delete(void *const);
};
struct Y {
// cv is ignored in arguments
static void operator delete(void *volatile);
};
}
// Don't crash on template delete operators
namespace TemplateDestructors {
struct S {
virtual ~S() {}
void* operator new(const size_t size);
template<class T> void* operator new(const size_t, const int, T*);
void operator delete(void*, const size_t);
template<class T> void operator delete(void*, const size_t, const int, T*);
};
}
namespace DeleteParam {
struct X {
void operator delete(X*); // expected-error{{first parameter of 'operator delete' must have type 'void *'}}
};
struct Y {
void operator delete(void* const);
};
}
// <rdar://problem/8427878>
// Test that the correct 'operator delete' is selected to pair with
// the unexpected placement 'operator new'.
namespace PairedDelete {
template <class T> struct A {
A();
void *operator new(size_t s, double d = 0);
void operator delete(void *p, double d);
void operator delete(void *p) {
T::dealloc(p);
}
};
A<int> *test() {
return new A<int>();
}
}
namespace PR7702 {
void test1() {
new DoesNotExist; // expected-error {{unknown type name 'DoesNotExist'}}
}
}
namespace ArrayNewNeedsDtor {
struct A { A(); private: ~A(); }; // expected-note {{declared private here}}
struct B { B(); A a; }; // expected-error {{field of type 'ArrayNewNeedsDtor::A' has private destructor}}
B *test9() {
return new B[5]; // expected-note {{implicit destructor for 'ArrayNewNeedsDtor::B' first required here}}
}
}
namespace DeleteIncompleteClass {
struct A; // expected-note {{forward declaration}}
extern A x;
void f() { delete x; } // expected-error {{deleting incomplete class type}}
}
namespace DeleteIncompleteClassPointerError {
struct A; // expected-note {{forward declaration}}
void f(A *x) { 1+delete x; } // expected-warning {{deleting pointer to incomplete type}} \
// expected-error {{invalid operands to binary expression}}
}
namespace PR10504 {
struct A {
virtual void foo() = 0;
};
void f(A *x) { delete x; } // expected-warning {{delete called on 'PR10504::A' that is abstract but has non-virtual destructor}}
}
struct PlacementArg {};
inline void *operator new[](size_t, const PlacementArg &) throw () {
return 0;
}
inline void operator delete[](void *, const PlacementArg &) throw () {
}
namespace r150682 {
template <typename X>
struct S {
struct Inner {};
S() { new Inner[1]; }
};
struct T {
};
template<typename X>
void tfn() {
new (*(PlacementArg*)0) T[1];
}
void fn() {
tfn<int>();
}
}
namespace P12023 {
struct CopyCounter
{
CopyCounter();
CopyCounter(const CopyCounter&);
};
int main()
{
CopyCounter* f = new CopyCounter[10](CopyCounter()); // expected-error {{cannot have initialization arguments}}
return 0;
}
}
namespace PR12061 {
template <class C> struct scoped_array {
scoped_array(C* p = __null);
};
template <class Payload> struct Foo {
Foo() : a_(new scoped_array<int>[5]) { }
scoped_array< scoped_array<int> > a_;
};
class Bar {};
Foo<Bar> x;
template <class C> struct scoped_array2 {
scoped_array2(C* p = __null, C* q = __null);
};
template <class Payload> struct Foo2 {
Foo2() : a_(new scoped_array2<int>[5]) { }
scoped_array2< scoped_array2<int> > a_;
};
class Bar2 {};
Foo2<Bar2> x2;
class MessageLoop {
public:
explicit MessageLoop(int type = 0);
};
template <class CookieStoreTestTraits>
class CookieStoreTest {
protected:
CookieStoreTest() {
new MessageLoop;
}
};
struct CookieMonsterTestTraits {
};
class DeferredCookieTaskTest : public CookieStoreTest<CookieMonsterTestTraits>
{
DeferredCookieTaskTest() {}
};
}
class DeletingPlaceholder {
int* f() {
delete f; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
return 0;
}
int* g(int, int) {
delete g; // expected-error {{reference to non-static member function must be called}}
return 0;
}
};
namespace PR18544 {
inline void *operator new(size_t); // expected-error {{'operator new' cannot be declared inside a namespace}}
}
// PR19968
inline void* operator new(); // expected-error {{'operator new' must have at least one parameter}}
namespace {
template <class C>
struct A {
void f() { this->::new; } // expected-error {{expected unqualified-id}}
void g() { this->::delete; } // expected-error {{expected unqualified-id}}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/typedef-redecl.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
typedef int INT;
typedef INT REALLY_INT; // expected-note {{previous definition is here}}
typedef REALLY_INT REALLY_REALLY_INT;
typedef REALLY_INT BOB;
typedef float REALLY_INT; // expected-error{{typedef redefinition with different types ('float' vs 'INT' (aka 'int'))}}
struct X {
typedef int result_type; // expected-note {{previous definition is here}}
typedef INT result_type; // expected-error {{redefinition of 'result_type'}}
};
struct Y; // expected-note{{previous definition is here}}
typedef int Y; // expected-error{{typedef redefinition with different types ('int' vs 'Y')}}
typedef int Y2; // expected-note{{declared here}}
struct Y2; // expected-error{{definition of type 'Y2' conflicts with typedef of the same name}}
void f(); // expected-note{{previous definition is here}}
typedef int f; // expected-error{{redefinition of 'f' as different kind of symbol}}
typedef int f2; // expected-note{{previous definition is here}}
void f2(); // expected-error{{redefinition of 'f2' as different kind of symbol}}
typedef struct s s;
typedef int I;
typedef int I;
typedef I I;
struct s { };
// PR5874
namespace test1 {
typedef int foo;
namespace a { using test1::foo; };
typedef int foo;
using namespace a;
foo x;
}
namespace PR6923 {
struct A;
extern "C" {
struct A;
typedef struct A A;
}
struct A;
}
namespace PR7462 {
struct A {};
typedef int operator! (A); // expected-error{{typedef name must be an identifier}}
int i = !A(); // expected-error{{invalid argument type}}
}
template<typename T>
typedef T f(T t) { return t; } // expected-error {{function definition declared 'typedef'}}
int k = f(0);
int k2 = k;
namespace PR11630 {
template <class T>
struct S
{
static const unsigned C = 1;
static void f()
{
typedef int q[C == 1 ? 1 : -1]; // expected-note{{previous definition is here}}
typedef int q[C >= 1 ? 2 : -2]; // expected-error{{typedef redefinition with different types ('int [2]' vs 'int [1]')}}
typedef int n[C == 1 ? 1 : -1];
typedef int n[C >= 1 ? 1 : -1];
}
};
template <int T>
struct S2
{
static void f()
{
typedef int q[1]; // expected-note{{previous definition is here}}
typedef int q[T]; // expected-error{{typedef redefinition with different types ('int [2]' vs 'int [1]')}}
}
};
void f() {
S<int> a;
a.f(); // expected-note{{in instantiation of member function 'PR11630::S<int>::f' requested here}}
S2<1> b;
b.f();
S2<2> b2;
b2.f(); // expected-note{{in instantiation of member function 'PR11630::S2<2>::f' requested here}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/function-overload-typo-crash.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR10283
void min(); //expected-note {{'min' declared here}}
void min(int);
template <typename T> void max(T); //expected-note {{'max' declared here}}
void f() {
fin(); //expected-error {{use of undeclared identifier 'fin'; did you mean 'min'}}
fax(0); //expected-error {{use of undeclared identifier 'fax'; did you mean 'max'}}
}
template <typename T> void somefunc(T*, T*); //expected-note {{'somefunc' declared here}}
template <typename T> void somefunc(const T[]); //expected-note {{'somefunc' declared here}}
template <typename T1, typename T2> void somefunc(T1*, T2*); //expected-note {{'somefunc' declared here}}
template <typename T1, typename T2> void somefunc(T1*, const T2[]); //expected-note 2 {{'somefunc' declared here}}
void c() {
int *i = 0, *j = 0;
const int x[] = {1, 2, 3};
long *l = 0;
somefun(i, j); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
somefun(x); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
somefun(i, l); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
somefun(l, x); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
somefun(i, x); //expected-error {{use of undeclared identifier 'somefun'; did you mean 'somefunc'?}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-sysheader-macro.cpp
|
// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast %s
// Test that macro expansions from system headers don't trigger 'syntactic'
// warnings that are not actionable.
#ifdef IS_SYSHEADER
#pragma clang system_header
#define SANITY(a) (a / 0)
#define SHADOW(a) __extension__({ int v = a; v; })
#define OLD_STYLE_CAST(a) ((int) (a))
#else
#define IS_SYSHEADER
#include __FILE__
void testSanity() {
// Validate that the test is set up correctly
int i = SANITY(0); // expected-warning {{division by zero is undefined}}
}
void PR16093() {
// no -Wshadow in system macro expansion
int i = SHADOW(SHADOW(1));
}
void PR18147() {
// no -Wold_style_cast in system macro expansion
int i = OLD_STYLE_CAST(0);
}
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cast-explicit-ctor.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
struct B { explicit B(bool); };
void f() {
(void)(B)true;
(void)B(true);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/complex-folding.cpp
|
// RUN: %clang_cc1 %s -std=c++1z -fsyntax-only -verify
//
// Test the constant folding of builtin complex numbers.
static_assert((0.0 + 0.0j) == (0.0 + 0.0j));
static_assert((0.0 + 0.0j) != (0.0 + 0.0j)); // expected-error {{static_assert}}
static_assert((0.0 + 0.0j) == 0.0);
static_assert(0.0 == (0.0 + 0.0j));
static_assert(0.0 == 0.0j);
static_assert((0.0 + 1.0j) != 0.0);
static_assert(1.0 != (0.0 + 0.0j));
static_assert(0.0 != 1.0j);
// Walk around the complex plane stepping between angular differences and
// equality.
static_assert((1.0 + 0.0j) == (0.0 + 0.0j)); // expected-error {{static_assert}}
static_assert((1.0 + 0.0j) == (1.0 + 0.0j));
static_assert((1.0 + 1.0j) == (1.0 + 0.0j)); // expected-error {{static_assert}}
static_assert((1.0 + 1.0j) == (1.0 + 1.0j));
static_assert((0.0 + 1.0j) == (1.0 + 1.0j)); // expected-error {{static_assert}}
static_assert((0.0 + 1.0j) == (0.0 + 1.0j));
static_assert((-1.0 + 1.0j) == (0.0 + 1.0j)); // expected-error {{static_assert}}
static_assert((-1.0 + 1.0j) == (-1.0 + 1.0j));
static_assert((-1.0 + 0.0j) == (-1.0 + 1.0j)); // expected-error {{static_assert}}
static_assert((-1.0 + 0.0j) == (-1.0 + 0.0j));
static_assert((-1.0 - 1.0j) == (-1.0 + 0.0j)); // expected-error {{static_assert}}
static_assert((-1.0 - 1.0j) == (-1.0 - 1.0j));
static_assert((0.0 - 1.0j) == (-1.0 - 1.0j)); // expected-error {{static_assert}}
static_assert((0.0 - 1.0j) == (0.0 - 1.0j));
static_assert((1.0 - 1.0j) == (0.0 - 1.0j)); // expected-error {{static_assert}}
static_assert((1.0 - 1.0j) == (1.0 - 1.0j));
// Test basic mathematical folding of both complex and real operands.
static_assert(((1.0 + 0.5j) + (0.25 - 0.75j)) == (1.25 - 0.25j));
static_assert(((1.0 + 0.5j) + 0.25) == (1.25 + 0.5j));
static_assert((1.0 + (0.25 - 0.75j)) == (1.25 - 0.75j));
static_assert(((1.0 + 0.5j) - (0.25 - 0.75j)) == (0.75 + 1.25j));
static_assert(((1.0 + 0.5j) - 0.25) == (0.75 + 0.5j));
static_assert((1.0 - (0.25 - 0.75j)) == (0.75 + 0.75j));
static_assert(((1.25 + 0.5j) * (0.25 - 0.75j)) == (0.6875 - 0.8125j));
static_assert(((1.25 + 0.5j) * 0.25) == (0.3125 + 0.125j));
static_assert((1.25 * (0.25 - 0.75j)) == (0.3125 - 0.9375j));
static_assert(((1.25 + 0.5j) / (0.25 - 0.75j)) == (-0.1 + 1.7j));
static_assert(((1.25 + 0.5j) / 0.25) == (5.0 + 2.0j));
static_assert((1.25 / (0.25 - 0.75j)) == (0.5 + 1.5j));
// Test that infinities are preserved, don't turn into NaNs, and do form zeros
// when the divisor.
static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * 1.0)) == 1);
static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) * 1.0)) == 1);
static_assert(__builtin_isinf_sign(__real__(1.0 * (__builtin_inf() + 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__imag__(1.0 * (1.0 + __builtin_inf() * 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * (1.0 + 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) * (__builtin_inf() + 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * (__builtin_inf() + 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((1.0 + __builtin_inf() * 1.0j) * (1.0 + 1.0j))) == -1);
static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) * (1.0 + 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) * (1.0 + __builtin_inf() * 1.0j))) == -1);
static_assert(__builtin_isinf_sign(__imag__((1.0 + 1.0j) * (1.0 + __builtin_inf() * 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((1.0 + __builtin_inf() * 1.0j) * (1.0 + __builtin_inf() * 1.0j))) == -1);
static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + __builtin_inf() * 1.0j) * (__builtin_inf() + __builtin_inf() * 1.0j))) == -1);
static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) / (1.0 + 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__imag__(1.0 + (__builtin_inf() * 1.0j) / (1.0 + 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__imag__((__builtin_inf() + __builtin_inf() * 1.0j) / (1.0 + 1.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) / 1.0)) == 1);
static_assert(__builtin_isinf_sign(__imag__(1.0 + (__builtin_inf() * 1.0j) / 1.0)) == 1);
static_assert(__builtin_isinf_sign(__imag__((__builtin_inf() + __builtin_inf() * 1.0j) / 1.0)) == 1);
static_assert(((1.0 + 1.0j) / (__builtin_inf() + 1.0j)) == (0.0 + 0.0j));
static_assert(((1.0 + 1.0j) / (1.0 + __builtin_inf() * 1.0j)) == (0.0 + 0.0j));
static_assert(((1.0 + 1.0j) / (__builtin_inf() + __builtin_inf() * 1.0j)) == (0.0 + 0.0j));
static_assert(((1.0 + 1.0j) / __builtin_inf()) == (0.0 + 0.0j));
static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) / (0.0 + 0.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) / 0.0)) == 1);
static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) / (0.0 + 0.0j))) == 1);
static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) / (0.0 + 0.0j))) == 1);
static_assert(__builtin_isinf_sign(__imag__((__builtin_inf() + __builtin_inf() * 1.0j) / (0.0 + 0.0j))) == 1);
static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) / 0.0)) == 1);
static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) / 0.0)) == 1);
static_assert(__builtin_isinf_sign(__imag__((__builtin_inf() + __builtin_inf() * 1.0j) / 0.0)) == 1);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/alignment-of-derived-class.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
// expected-no-diagnostics
// Test that the alignment of a empty direct base class is correctly
// inherited by the derived class.
struct A {
} __attribute__ ((aligned(16)));
static_assert(__alignof(A) == 16, "A should be aligned to 16 bytes");
struct B1 : public A {
};
static_assert(__alignof(B1) == 16, "B1 should be aligned to 16 bytes");
struct B2 : public A {
} __attribute__ ((aligned(2)));
static_assert(__alignof(B2) == 16, "B2 should be aligned to 16 bytes");
struct B3 : public A {
} __attribute__ ((aligned(4)));
static_assert(__alignof(B3) == 16, "B3 should be aligned to 16 bytes");
struct B4 : public A {
} __attribute__ ((aligned(8)));
static_assert(__alignof(B4) == 16, "B4 should be aligned to 16 bytes");
struct B5 : public A {
} __attribute__ ((aligned(16)));
static_assert(__alignof(B5) == 16, "B5 should be aligned to 16 bytes");
struct B6 : public A {
} __attribute__ ((aligned(32)));
static_assert(__alignof(B6) == 32, "B6 should be aligned to 32 bytes");
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/PR9884.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
class Base {
protected:
Base(int val);
};
class Derived : public Base {
public:
Derived(int val);
};
Derived::Derived(int val)
: Base( val )
{
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx11-unused.cpp
|
// RUN: %clang_cc1 -std=c++11 -verify %s -Wunused-parameter
// PR19303 : Make sure we don't get a unused expression warning for deleted and
// defaulted functions
// expected-no-diagnostics
class A {
public:
int x;
A() = default;
~A() = default;
A(const A &other) = delete;
template <typename T>
void SetX(T x) {
this->x = x;
};
void SetX1(int x);
};
template <>
void A::SetX(A x) = delete;
class B {
public:
B() = default;
~B() = default;
B(const B &other);
};
B::B(const B &other) = default;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/access-base-class.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace T1 {
class A { };
class B : private A { }; // expected-note {{declared private here}}
void f(B* b) {
A *a = b; // expected-error{{cannot cast 'T1::B' to its private base class 'T1::A'}}
}
}
namespace T2 {
class A { };
class B : A { }; // expected-note {{implicitly declared private here}}
void f(B* b) {
A *a = b; // expected-error {{cannot cast 'T2::B' to its private base class 'T2::A'}}
}
}
namespace T3 {
class A { };
class B : public A { };
void f(B* b) {
A *a = b;
}
}
namespace T4 {
class A {};
class B : private virtual A {};
class C : public virtual A {};
class D : public B, public C {};
void f(D *d) {
// This takes the D->C->B->A path.
A *a = d;
}
}
namespace T5 {
class A {};
class B : private A {
void f(B *b) {
A *a = b;
}
};
}
namespace T6 {
class C;
class A {}; // expected-note{{member is declared here}}
class B : private A { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
void f(C* c);
};
class C : public B {
void f(C *c) {
A* a = c; // expected-error {{cannot cast 'T6::C' to its private base class 'T6::A'}} \
// expected-error {{'A' is a private member of 'T6::A'}}
}
};
void B::f(C *c) {
A *a = c;
}
}
namespace T7 {
class A {};
class B : public A {};
class C : private B {
void f(C *c) {
A* a = c; // okay
}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/windows-arm-valist.cpp
|
// RUN: %clang_cc1 -triple thumbv7--windows-msvc -std=c++11 -verify -fsyntax-only %s
// expected-no-diagnostics
#include <stdarg.h>
template <typename lhs_, typename rhs_>
struct is_same { enum { value = 0 }; };
template <typename type_>
struct is_same<type_, type_> { enum { value = 1 }; };
void check() {
va_list va;
char *cp;
static_assert(is_same<decltype(va), decltype(cp)>::value,
"type mismatch for va_list");
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/compare.cpp
|
// Force x86-64 because some of our heuristics are actually based
// on integer sizes.
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -std=c++11 %s
int test0(long a, unsigned long b) {
enum EnumA {A};
enum EnumB {B};
enum EnumC {C = 0x10000};
return
// (a,b)
(a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
(a == (unsigned int) b) +
(a == (unsigned short) b) +
(a == (unsigned char) b) +
((long) a == b) + // expected-warning {{comparison of integers of different signs}}
((int) a == b) + // expected-warning {{comparison of integers of different signs}}
((short) a == b) + // expected-warning {{comparison of integers of different signs}}
((signed char) a == b) + // expected-warning {{comparison of integers of different signs}}
((long) a == (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
((int) a == (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
((short) a == (unsigned short) b) +
((signed char) a == (unsigned char) b) +
(a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
(a < (unsigned int) b) +
(a < (unsigned short) b) +
(a < (unsigned char) b) +
((long) a < b) + // expected-warning {{comparison of integers of different signs}}
((int) a < b) + // expected-warning {{comparison of integers of different signs}}
((short) a < b) + // expected-warning {{comparison of integers of different signs}}
((signed char) a < b) + // expected-warning {{comparison of integers of different signs}}
((long) a < (unsigned long) b) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) b) + // expected-warning {{comparison of integers of different signs}}
((short) a < (unsigned short) b) +
((signed char) a < (unsigned char) b) +
// (A,b)
(A == (unsigned long) b) +
(A == (unsigned int) b) +
(A == (unsigned short) b) +
(A == (unsigned char) b) +
((long) A == b) +
((int) A == b) +
((short) A == b) +
((signed char) A == b) +
((long) A == (unsigned long) b) +
((int) A == (unsigned int) b) +
((short) A == (unsigned short) b) +
((signed char) A == (unsigned char) b) +
(A < (unsigned long) b) +
(A < (unsigned int) b) +
(A < (unsigned short) b) +
(A < (unsigned char) b) +
((long) A < b) +
((int) A < b) +
((short) A < b) +
((signed char) A < b) +
((long) A < (unsigned long) b) +
((int) A < (unsigned int) b) +
((short) A < (unsigned short) b) +
((signed char) A < (unsigned char) b) +
// (a,B)
(a == (unsigned long) B) +
(a == (unsigned int) B) +
(a == (unsigned short) B) +
(a == (unsigned char) B) +
((long) a == B) +
((int) a == B) +
((short) a == B) +
((signed char) a == B) +
((long) a == (unsigned long) B) +
((int) a == (unsigned int) B) +
((short) a == (unsigned short) B) +
((signed char) a == (unsigned char) B) +
(a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
(a < (unsigned int) B) +
(a < (unsigned short) B) +
(a < (unsigned char) B) +
((long) a < B) +
((int) a < B) +
((short) a < B) +
((signed char) a < B) +
((long) a < (unsigned long) B) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) B) + // expected-warning {{comparison of integers of different signs}}
((short) a < (unsigned short) B) +
((signed char) a < (unsigned char) B) +
// (C,b)
(C == (unsigned long) b) +
(C == (unsigned int) b) +
(C == (unsigned short) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned short' is always false}}
(C == (unsigned char) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned char' is always false}}
((long) C == b) +
((int) C == b) +
((short) C == b) +
((signed char) C == b) +
((long) C == (unsigned long) b) +
((int) C == (unsigned int) b) +
((short) C == (unsigned short) b) +
((signed char) C == (unsigned char) b) +
(C < (unsigned long) b) +
(C < (unsigned int) b) +
(C < (unsigned short) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned short' is always false}}
(C < (unsigned char) b) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'unsigned char' is always false}}
((long) C < b) +
((int) C < b) +
((short) C < b) +
((signed char) C < b) +
((long) C < (unsigned long) b) +
((int) C < (unsigned int) b) +
((short) C < (unsigned short) b) +
((signed char) C < (unsigned char) b) +
// (a,C)
(a == (unsigned long) C) +
(a == (unsigned int) C) +
(a == (unsigned short) C) +
(a == (unsigned char) C) +
((long) a == C) +
((int) a == C) +
((short) a == C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'short' is always false}}
((signed char) a == C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'signed char' is always false}}
((long) a == (unsigned long) C) +
((int) a == (unsigned int) C) +
((short) a == (unsigned short) C) +
((signed char) a == (unsigned char) C) +
(a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
(a < (unsigned int) C) +
(a < (unsigned short) C) +
(a < (unsigned char) C) +
((long) a < C) +
((int) a < C) +
((short) a < C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'short' is always true}}
((signed char) a < C) + // expected-warning {{comparison of constant 'C' (65536) with expression of type 'signed char' is always true}}
((long) a < (unsigned long) C) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) C) + // expected-warning {{comparison of integers of different signs}}
((short) a < (unsigned short) C) +
((signed char) a < (unsigned char) C) +
// (0x80000,b)
(0x80000 == (unsigned long) b) +
(0x80000 == (unsigned int) b) +
(0x80000 == (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
(0x80000 == (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
((long) 0x80000 == b) +
((int) 0x80000 == b) +
((short) 0x80000 == b) +
((signed char) 0x80000 == b) +
((long) 0x80000 == (unsigned long) b) +
((int) 0x80000 == (unsigned int) b) +
((short) 0x80000 == (unsigned short) b) +
((signed char) 0x80000 == (unsigned char) b) +
(0x80000 < (unsigned long) b) +
(0x80000 < (unsigned int) b) +
(0x80000 < (unsigned short) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned short' is always false}}
(0x80000 < (unsigned char) b) + // expected-warning {{comparison of constant 524288 with expression of type 'unsigned char' is always false}}
((long) 0x80000 < b) +
((int) 0x80000 < b) +
((short) 0x80000 < b) +
((signed char) 0x80000 < b) +
((long) 0x80000 < (unsigned long) b) +
((int) 0x80000 < (unsigned int) b) +
((short) 0x80000 < (unsigned short) b) +
((signed char) 0x80000 < (unsigned char) b) +
// (a,0x80000)
(a == (unsigned long) 0x80000) +
(a == (unsigned int) 0x80000) +
(a == (unsigned short) 0x80000) +
(a == (unsigned char) 0x80000) +
((long) a == 0x80000) +
((int) a == 0x80000) +
((short) a == 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'short' is always false}}
((signed char) a == 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'signed char' is always false}}
((long) a == (unsigned long) 0x80000) +
((int) a == (unsigned int) 0x80000) +
((short) a == (unsigned short) 0x80000) +
((signed char) a == (unsigned char) 0x80000) +
(a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
(a < (unsigned int) 0x80000) +
(a < (unsigned short) 0x80000) +
(a < (unsigned char) 0x80000) +
((long) a < 0x80000) +
((int) a < 0x80000) +
((short) a < 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'short' is always true}}
((signed char) a < 0x80000) + // expected-warning {{comparison of constant 524288 with expression of type 'signed char' is always true}}
((long) a < (unsigned long) 0x80000) + // expected-warning {{comparison of integers of different signs}}
((int) a < (unsigned int) 0x80000) + // expected-warning {{comparison of integers of different signs}}
((short) a < (unsigned short) 0x80000) +
((signed char) a < (unsigned char) 0x80000) +
10
;
}
int test1(int i) {
enum en { zero };
return i > zero;
}
enum E { e };
void test2(int i, void *vp) {
if (test1 == vp) { } // expected-warning{{equality comparison between function pointer and void pointer}}
if (test1 == e) { } // expected-error{{comparison between pointer and integer}}
if (vp < 0) { }
if (test1 < e) { } // expected-error{{comparison between pointer and integer}}
}
// PR7536
static const unsigned int kMax = 0;
int pr7536() {
return (kMax > 0);
}
// -Wsign-compare should not warn when ?: operands have different signedness.
// This will be caught by -Wsign-conversion
void test3() {
unsigned long a;
signed long b;
(void) (true ? a : b);
(void) (true ? (unsigned int)a : (signed int)b);
(void) (true ? b : a);
(void) (true ? (unsigned char)b : (signed char)a);
}
// Test comparison of short to unsigned. If tautological compare does not
// trigger, then the signed comparison warning will.
void test4(short s) {
// A is max short plus 1. All zero and positive shorts are smaller than it.
// All negative shorts are cast towards the max unsigned range. Relation
// comparisons are possible, but equality comparisons are tautological.
const unsigned A = 32768;
void (s < A); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s > A); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s <= A); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s >= A); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s == A); // expected-warning{{comparison of constant 32768 with expression of type 'short' is always false}}
void (s != A); // expected-warning{{comparison of constant 32768 with expression of type 'short' is always true}}
// When negative one is converted to an unsigned value, it becomes the max
// unsigned. Likewise, a negative one short can also be converted to max
// unsigned.
const unsigned B = -1;
void (s < B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s > B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s <= B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s >= B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s == B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
void (s != B); // expected-warning{{comparison of integers of different signs: 'short' and 'const unsigned int'}}
}
void test5(bool b) {
(void) (b < -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always false}}
(void) (b > -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always true}}
(void) (b == -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always false}}
(void) (b != -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always true}}
(void) (b <= -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always false}}
(void) (b >= -1); // expected-warning{{comparison of constant -1 with expression of type 'bool' is always true}}
(void) (b < -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always false}}
(void) (b > -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always true}}
(void) (b == -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always false}}
(void) (b != -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always true}}
(void) (b <= -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always false}}
(void) (b >= -10); // expected-warning{{comparison of constant -10 with expression of type 'bool' is always true}}
(void) (b < 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always true}}
(void) (b > 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always false}}
(void) (b == 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always false}}
(void) (b != 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always true}}
(void) (b <= 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always true}}
(void) (b >= 2); // expected-warning{{comparison of constant 2 with expression of type 'bool' is always false}}
(void) (b < 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always true}}
(void) (b > 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always false}}
(void) (b == 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always false}}
(void) (b != 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always true}}
(void) (b <= 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always true}}
(void) (b >= 10); // expected-warning{{comparison of constant 10 with expression of type 'bool' is always false}}
}
void test6(signed char sc) {
(void)(sc < 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(sc > 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(sc <= 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(sc >= 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(sc == 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(sc != 200); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(200 < sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(200 > sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(200 <= sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(200 >= sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
(void)(200 == sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always false}}
(void)(200 != sc); // expected-warning{{comparison of constant 200 with expression of type 'signed char' is always true}}
}
// Test many signedness combinations.
void test7(unsigned long other) {
// Common unsigned, other unsigned, constant unsigned
(void)((unsigned)other != (unsigned long)(0x1ffffffff)); // expected-warning{{true}}
(void)((unsigned)other != (unsigned long)(0xffffffff));
(void)((unsigned long)other != (unsigned)(0x1ffffffff));
(void)((unsigned long)other != (unsigned)(0xffffffff));
// Common unsigned, other signed, constant unsigned
(void)((int)other != (unsigned long)(0xffffffffffffffff)); // expected-warning{{different signs}}
(void)((int)other != (unsigned long)(0x00000000ffffffff)); // expected-warning{{true}}
(void)((int)other != (unsigned long)(0x000000000fffffff));
(void)((int)other < (unsigned long)(0x00000000ffffffff)); // expected-warning{{different signs}}
(void)((int)other == (unsigned)(0x800000000));
// Common unsigned, other unsigned, constant signed
(void)((unsigned long)other != (int)(0xffffffff)); // expected-warning{{different signs}}
// Common unsigned, other signed, constant signed
// Should not be possible as the common type should also be signed.
// Common signed, other signed, constant signed
(void)((int)other != (long)(0xffffffff)); // expected-warning{{true}}
(void)((int)other != (long)(0xffffffff00000000)); // expected-warning{{true}}
(void)((int)other != (long)(0xfffffff));
(void)((int)other != (long)(0xfffffffff0000000));
// Common signed, other signed, constant unsigned
(void)((int)other != (unsigned char)(0xffff));
(void)((int)other != (unsigned char)(0xff));
// Common signed, other unsigned, constant signed
(void)((unsigned char)other != (int)(0xff));
(void)((unsigned char)other != (int)(0xffff)); // expected-warning{{true}}
// Common signed, other unsigned, constant unsigned
(void)((unsigned char)other != (unsigned short)(0xff));
(void)((unsigned char)other != (unsigned short)(0x100)); // expected-warning{{true}}
(void)((unsigned short)other != (unsigned char)(0xff));
}
void test8(int x) {
enum E {
Negative = -1,
Positive = 1
};
(void)((E)x == 1);
(void)((E)x == -1);
}
void test9(int x) {
enum E : int {
Positive = 1
};
(void)((E)x == 1);
}
namespace templates {
template<class T> T max();
template<> constexpr int max<int>() { return 2147483647; };
template<typename T>
bool less_than_max(short num, T value) {
const T vmax = max<T>();
return (vmax >= num); // no warning
}
template<typename T>
bool less_than_max(short num) {
// This should trigger one warning on the template pattern, and not a
// warning per specialization.
return num < max<int>(); // expected-warning{{comparison of constant 2147483647 with expression of type 'short' is always true}}
}
void test10(short num, int x) {
less_than_max(num, x);
less_than_max<int>(num);
less_than_max<long>(num);
less_than_max<short>(num);
}
template<typename T>
inline bool less_than_zero(T num, T value) {
return num < 0; // no warning
}
template<typename T>
inline bool less_than_zero(unsigned num) {
// This should trigger one warning on the template pattern, and not a
// warning per specialization.
return num < 0; // expected-warning{{comparison of unsigned expression < 0 is always false}}
}
void test11(unsigned num) {
less_than_zero(num, num);
less_than_zero<int>(num);
less_than_zero<long>(num);
less_than_zero<short>(num);
}
template<unsigned n> bool compare(unsigned k) { return k >= n; }
void test12() {
compare<0>(42);
}
struct A { static int x; };
struct B { static int x; };
typedef A otherA;
template <typename T>
void testx() {
if (A::x == T::x && // no warning
A::x == otherA::x) // expected-warning{{self-comparison always evaluates to true}}
return;
}
void test13() {
testx<A>();
testx<B>();
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/builtin-ptrtomember-ambig.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
struct A {};
struct R {
operator const A*();
};
struct B : R {
operator A*();
};
struct C : B {
};
void foo(C c, int A::* pmf) {
// FIXME. Why so many built-in candidates?
int i = c->*pmf; // expected-error {{use of overloaded operator '->*' is ambiguous}} \
// expected-note {{built-in candidate operator->*(const struct A *, const int struct A::*)}} \
// expected-note {{built-in candidate operator->*(const struct A *, int struct A::*)}} \
// expected-note {{built-in candidate operator->*(struct A *, const int struct A::*)}} \
// expected-note {{built-in candidate operator->*(struct A *, int struct A::*)}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/PR12778.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void operator delete() throw(void*); // expected-error{{'operator delete' must have at least one parameter}}
void* allocate(int __n) {
return ::operator new(__n);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/format-strings-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s
extern "C" {
extern int scanf(const char *restrict, ...);
extern int printf(const char *restrict, ...);
}
void f(char **sp, float *fp) {
scanf("%as", sp); // expected-warning{{format specifies type 'float *' but the argument has type 'char **'}}
printf("%p", sp); // expected-warning{{format specifies type 'void *' but the argument has type 'char **'}}
scanf("%p", sp); // expected-warning{{format specifies type 'void **' but the argument has type 'char **'}}
printf("%a", 1.0);
scanf("%afoobar", fp);
printf(nullptr);
printf(*sp); // expected-warning {{not a string literal}}
// PR13099
printf(
R"foobar(%)foobar"
R"bazquux(d)bazquux" // expected-warning {{more '%' conversions than data arguments}}
R"xyzzy()xyzzy");
printf(u8"this is %d test", 0); // ok
printf(u8R"foo(
\u1234\U0010fffe
%d)foo" // expected-warning {{more '%' conversions than data arguments}}
);
printf("init list: %d", { 0 }); // expected-error {{cannot pass initializer list to variadic function; expected type from format string was 'int'}}
printf("void: %d", f(sp, fp)); // expected-error {{cannot pass expression of type 'void' to variadic function; expected type from format string was 'int'}}
printf(0, { 0 }); // expected-error {{cannot pass initializer list to variadic function}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/virtual-override-x64.cpp
|
// RUN: %clang_cc1 -triple=x86_64-pc-unknown -fsyntax-only -verify %s
// Non-x86 targets ignore the calling conventions by default (but will warn
// when one is encountered), so we want to make sure the virtual overrides
// continue to work.
namespace PR14339 {
class A {
public:
virtual void __attribute__((thiscall)) f(); // expected-warning {{calling convention 'thiscall' ignored for this target}}
};
class B : public A {
public:
void __attribute__((cdecl)) f();
};
class C : public A {
public:
void __attribute__((thiscall)) f(); // expected-warning {{calling convention 'thiscall' ignored for this target}}
};
class D : public A {
public:
void f();
};
class E {
public:
virtual void __attribute__((stdcall)) g(); // expected-warning {{calling convention 'stdcall' ignored for this target}}
};
class F : public E {
public:
void g();
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/cxx1y-init-captures.cpp
|
// RUN: %clang_cc1 -std=c++1y %s -verify -emit-llvm-only
namespace variadic_expansion {
int f(int &, char &) { return 0; }
template<class ... Ts> char fv(Ts ... ts) { return 0; }
// FIXME: why do we get 2 error messages
template <typename ... T> void g(T &... t) { //expected-note3{{declared here}}
f([&a(t)]()->decltype(auto) {
return a;
}() ...);
auto L = [x = f([&a(t)]()->decltype(auto) { return a; }()...)]() { return x; };
const int y = 10;
auto M = [x = y,
&z = y](T& ... t) { };
auto N = [x = y,
&z = y, n = f(t...),
o = f([&a(t)](T& ... t)->decltype(auto) { return a; }(t...)...), t...](T& ... s) {
fv([&a(t)]()->decltype(auto) {
return a;
}() ...);
};
auto N2 = [x = y, //expected-note3{{begins here}}
&z = y, n = f(t...),
o = f([&a(t)](T& ... t)->decltype(auto) { return a; }(t...)...)](T& ... s) {
fv([&a(t)]()->decltype(auto) { //expected-error 3{{captured}}
return a;
}() ...);
};
}
void h(int i, char c) { g(i, c); } //expected-note{{in instantiation}}
}
namespace odr_use_within_init_capture {
int test() {
{ // no captures
const int x = 10;
auto L = [z = x + 2](int a) {
auto M = [y = x - 2](char b) {
return y;
};
return M;
};
}
{ // should not capture
const int x = 10;
auto L = [&z = x](int a) {
return a;;
};
}
{
const int x = 10;
auto L = [k = x](char a) { //expected-note {{declared}}
return [](int b) { //expected-note {{begins}}
return [j = k](int c) { //expected-error {{cannot be implicitly captured}}
return c;
};
};
};
}
{
const int x = 10;
auto L = [k = x](char a) {
return [=](int b) {
return [j = k](int c) {
return c;
};
};
};
}
{
const int x = 10;
auto L = [k = x](char a) {
return [k](int b) {
return [j = k](int c) {
return c;
};
};
};
}
return 0;
}
int run = test();
}
namespace odr_use_within_init_capture_template {
template<class T = int>
int test(T t = T{}) {
{ // no captures
const T x = 10;
auto L = [z = x](char a) {
auto M = [y = x](T b) {
return y;
};
return M;
};
}
{ // should not capture
const T x = 10;
auto L = [&z = x](T a) {
return a;;
};
}
{ // will need to capture x in outer lambda
const T x = 10; //expected-note {{declared}}
auto L = [z = x](char a) { //expected-note {{begins}}
auto M = [&y = x](T b) { //expected-error {{cannot be implicitly captured}}
return y;
};
return M;
};
}
{ // will need to capture x in outer lambda
const T x = 10;
auto L = [=,z = x](char a) {
auto M = [&y = x](T b) {
return y;
};
return M;
};
}
{ // will need to capture x in outer lambda
const T x = 10;
auto L = [x, z = x](char a) {
auto M = [&y = x](T b) {
return y;
};
return M;
};
}
{ // will need to capture x in outer lambda
const int x = 10; //expected-note 2{{declared}}
auto L = [z = x](char a) { //expected-note 2{{begins}}
auto M = [&y = x](T b) { //expected-error 2{{cannot be implicitly captured}}
return y;
};
return M;
};
}
{
// no captures
const T x = 10;
auto L = [z =
[z = x, &y = x](char a) { return z + y; }('a')](char a)
{ return z; };
}
return 0;
}
int run = test(); //expected-note {{instantiation}}
}
namespace classification_of_captures_of_init_captures {
template <typename T>
void f() {
[a = 24] () mutable {
[&a] { a = 3; }();
}();
}
template <typename T>
void h() {
[a = 24] (auto param) mutable {
[&a] { a = 3; }();
}(42);
}
int run() {
f<int>();
h<int>();
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/overload-member-call.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct X {
int& f(int) const; // expected-note 2 {{candidate function}}
float& f(int); // expected-note 2 {{candidate function}}
void test_f(int x) const {
int& i = f(x);
}
void test_f2(int x) {
float& f2 = f(x);
}
int& g(int) const; // expected-note 2 {{candidate function}}
float& g(int); // expected-note 2 {{candidate function}}
static double& g(double); // expected-note 2 {{candidate function}}
void h(int);
void test_member() {
float& f1 = f(0);
float& f2 = g(0);
double& d1 = g(0.0);
}
void test_member_const() const {
int &i1 = f(0);
int &i2 = g(0);
double& d1 = g(0.0);
}
static void test_member_static() {
double& d1 = g(0.0);
g(0); // expected-error{{call to 'g' is ambiguous}}
}
};
void test(X x, const X xc, X* xp, const X* xcp, volatile X xv, volatile X* xvp) {
int& i1 = xc.f(0);
int& i2 = xcp->f(0);
float& f1 = x.f(0);
float& f2 = xp->f(0);
xv.f(0); // expected-error{{no matching member function for call to 'f'}}
xvp->f(0); // expected-error{{no matching member function for call to 'f'}}
int& i3 = xc.g(0);
int& i4 = xcp->g(0);
float& f3 = x.g(0);
float& f4 = xp->g(0);
double& d1 = xp->g(0.0);
double& d2 = X::g(0.0);
X::g(0); // expected-error{{call to 'g' is ambiguous}}
X::h(0); // expected-error{{call to non-static member function without an object argument}}
}
struct X1 {
int& member();
float& member() const;
};
struct X2 : X1 { };
void test_X2(X2 *x2p, const X2 *cx2p) {
int &ir = x2p->member();
float &fr = cx2p->member();
}
// Tests the exact text used to note the candidates
namespace test1 {
class A {
template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}}
void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}}
void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}}
void foo(int n, const char *s, int t, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}}
void foo(int n, const char *s, int t, int u = 0); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}}
void bar(double d); //expected-note {{candidate function not viable: 'this' argument has type 'const test1::A', but method is not marked const}}
void bar(int i); //expected-note {{candidate function not viable: 'this' argument has type 'const test1::A', but method is not marked const}}
void baz(A &d); // expected-note {{candidate function not viable: 1st argument ('const test1::A') would lose const qualifier}}
void baz(int i); // expected-note {{candidate function not viable: no known conversion from 'const test1::A' to 'int' for 1st argument}}
// PR 11857
void foo(int n); // expected-note {{candidate function not viable: requires single argument 'n', but 2 arguments were provided}}
void foo(unsigned n = 10); // expected-note {{candidate function not viable: allows at most single argument 'n', but 2 arguments were provided}}
void rab(double n, int u = 0); // expected-note {{candidate function not viable: requires at least argument 'n', but no arguments were provided}}
void rab(int n, int u = 0); // expected-note {{candidate function not viable: requires at least argument 'n', but no arguments were provided}}
void zab(double n = 0.0, int u = 0); // expected-note {{candidate function not viable: requires at most 2 arguments, but 3 were provided}}
void zab(int n = 0, int u = 0); // expected-note {{candidate function not viable: requires at most 2 arguments, but 3 were provided}}
};
void test() {
A a;
a.foo(4, "hello"); //expected-error {{no matching member function for call to 'foo'}}
const A b = A();
b.bar(0); //expected-error {{no matching member function for call to 'bar'}}
a.baz(b); //expected-error {{no matching member function for call to 'baz'}}
a.rab(); //expected-error {{no matching member function for call to 'rab'}}
a.zab(3, 4, 5); //expected-error {{no matching member function for call to 'zab'}}
}
}
namespace b7398190 {
struct S {
int f(); // expected-note {{'this' argument has type 'const b7398190::S', but method is not marked const}}
void f(int); // expected-note {{requires 1 argument, but 0 were provided}}
};
const S *p;
int k = p->f(); // expected-error {{no matching member function for call to 'f'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/warn-loop-analysis.cpp
|
// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify %s
struct S {
bool stop() { return false; }
bool keep_running;
};
void by_ref(int &value) { }
void by_value(int value) { }
void by_pointer(int *value) {}
void test1() {
S s;
for (; !s.stop();) {}
for (; s.keep_running;) {}
for (int i; i < 1; ++i) {}
for (int i; i < 1; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (int i; i < 1; ) { ++i; }
for (int i; i < 1; ) { return; }
for (int i; i < 1; ) { break; }
for (int i; i < 1; ) { goto exit_loop; }
exit_loop:
for (int i; i < 1; ) { by_ref(i); }
for (int i; i < 1; ) { by_value(i); } // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (int i; i < 1; ) { by_pointer(&i); }
for (int i; i < 1; ++i)
for (int j; j < 1; ++j)
{ }
for (int i; i < 1; ++i)
for (int j; j < 1; ++i) // expected-warning {{variable 'j' used in loop condition not modified in loop body}}
{ }
for (int i; i < 1; ++i)
for (int j; i < 1; ++j) // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
{ }
for (int *i, *j; i < j; ++i) {}
for (int *i, *j; i < j;) {} // expected-warning {{variables 'i' and 'j' used in loop condition not modified in loop body}}
// Dereferencing pointers is ignored for now.
for (int *i; *i; ) {}
}
void test2() {
int i, j, k;
int *ptr;
// Testing CastExpr
for (; i; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i; ) { i = 5; }
// Testing BinaryOperator
for (; i < j; ) {} // expected-warning {{variables 'i' and 'j' used in loop condition not modified in loop body}}
for (; i < j; ) { i = 5; }
for (; i < j; ) { j = 5; }
// Testing IntegerLiteral
for (; i < 5; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i < 5; ) { i = 5; }
// Testing FloatingLiteral
for (; i < 5.0; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i < 5.0; ) { i = 5; }
// Testing CharacterLiteral
for (; i == 'a'; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i == 'a'; ) { i = 5; }
// Testing CXXBoolLiteralExpr
for (; i == true; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i == true; ) { i = 5; }
// Testing GNUNullExpr
for (; ptr == __null; ) {} // expected-warning {{variable 'ptr' used in loop condition not modified in loop body}}
for (; ptr == __null; ) { ptr = &i; }
// Testing UnaryOperator
for (; -i > 5; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; -i > 5; ) { ++i; }
// Testing ImaginaryLiteral
for (; i != 3i; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i != 3i; ) { ++i; }
// Testing ConditionalOperator
for (; i ? j : k; ) {} // expected-warning {{variables 'i', 'j', and 'k' used in loop condition not modified in loop body}}
for (; i ? j : k; ) { ++i; }
for (; i ? j : k; ) { ++j; }
for (; i ? j : k; ) { ++k; }
for (; i; ) { j = i ? i : i; } // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i; ) { j = (i = 1) ? i : i; }
for (; i; ) { j = i ? i : ++i; }
// Testing BinaryConditionalOperator
for (; i ?: j; ) {} // expected-warning {{variables 'i' and 'j' used in loop condition not modified in loop body}}
for (; i ?: j; ) { ++i; }
for (; i ?: j; ) { ++j; }
for (; i; ) { j = i ?: i; } // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
// Testing ParenExpr
for (; (i); ) { } // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; (i); ) { ++i; }
// Testing non-evaluated variables
for (; i < sizeof(j); ) { } // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i < sizeof(j); ) { ++j; } // expected-warning {{variable 'i' used in loop condition not modified in loop body}}
for (; i < sizeof(j); ) { ++i; }
}
// False positive and how to silence.
void test3() {
int x;
int *ptr = &x;
for (;x<5;) { *ptr = 6; } // expected-warning {{variable 'x' used in loop condition not modified in loop body}}
for (;x<5;) {
*ptr = 6;
(void)x;
}
}
// Check ordering and printing of variables. Max variables is currently 4.
void test4() {
int a, b, c, d, e, f;
for (; a;); // expected-warning {{variable 'a' used in loop condition not modified in loop body}}
for (; a + b;); // expected-warning {{variables 'a' and 'b' used in loop condition not modified in loop body}}
for (; a + b + c;); // expected-warning {{variables 'a', 'b', and 'c' used in loop condition not modified in loop body}}
for (; a + b + c + d;); // expected-warning {{variables 'a', 'b', 'c', and 'd' used in loop condition not modified in loop body}}
for (; a + b + c + d + e;); // expected-warning {{variables used in loop condition not modified in loop body}}
for (; a + b + c + d + e + f;); // expected-warning {{variables used in loop condition not modified in loop body}}
for (; a + c + d + b;); // expected-warning {{variables 'a', 'c', 'd', and 'b' used in loop condition not modified in loop body}}
for (; d + c + b + a;); // expected-warning {{variables 'd', 'c', 'b', and 'a' used in loop condition not modified in loop body}}
}
// Ensure that the warning doesn't fail when lots of variables are used
// in the conditional.
void test5() {
for (int a; a+a+a+a+a+a+a+a+a+a;); // \
// expected-warning {{variable 'a' used in loop condition not modified in loop body}}
for (int a; a+a+a+a+a+a+a+a+a+a+a;); // \
// expected-warning {{variable 'a' used in loop condition not modified in loop body}}
for (int a; a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a;); // \
// expected-warning {{variable 'a' used in loop condition not modified in loop body}}
for (int a; a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a;);//\
// expected-warning {{variable 'a' used in loop condition not modified in loop body}}
}
// Ignore global variables and static variables.
int x6;
void test6() {
static int y;
for (;x6;);
for (;y;);
}
void test7() {
int i;
for (;;i++) { // expected-note{{incremented here}}
if (true) test7();
i++; // expected-warning{{incremented both}}
}
for (;;i++) { // expected-note{{incremented here}}
if (true) break;
++i; // expected-warning{{incremented both}}
}
for (;;++i) { // expected-note{{incremented here}}
while (true) return;
i++; // expected-warning{{incremented both}}
}
for (;;++i) { // expected-note{{incremented here}}
++i; // expected-warning{{incremented both}}
}
for (;;i--) { // expected-note{{decremented here}}
if (true) test7();
i--; // expected-warning{{decremented both}}
}
for (;;i--) { // expected-note{{decremented here}}
if (true) break;
--i; // expected-warning{{decremented both}}
}
for (;;--i) { // expected-note{{decremented here}}
while (true) return;
i--; // expected-warning{{decremented both}}
}
for (;;--i) { // expected-note{{decremented here}}
--i; // expected-warning{{decremented both}}
}
// Don't warn when loop is only one statement.
for (;;++i)
i++;
for (;;--i)
--i;
// Don't warn when loop has continue statement.
for (;;i++) {
if (true) continue;
i++;
}
for (;;i--) {
if (true) continue;
i--;
}
}
struct iterator {
iterator operator++() { return *this; }
iterator operator++(int) { return *this; }
iterator operator--() { return *this; }
iterator operator--(int) { return *this; }
};
void test8() {
iterator i;
for (;;i++) { // expected-note{{incremented here}}
if (true) test7();
i++; // expected-warning{{incremented both}}
}
for (;;i++) { // expected-note{{incremented here}}
if (true) break;
++i; // expected-warning{{incremented both}}
}
for (;;++i) { // expected-note{{incremented here}}
while (true) return;
i++; // expected-warning{{incremented both}}
}
for (;;++i) { // expected-note{{incremented here}}
++i; // expected-warning{{incremented both}}
}
for (;;i--) { // expected-note{{decremented here}}
if (true) test7();
i--; // expected-warning{{decremented both}}
}
for (;;i--) { // expected-note{{decremented here}}
if (true) break;
--i; // expected-warning{{decremented both}}
}
for (;;--i) { // expected-note{{decremented here}}
while (true) return;
i--; // expected-warning{{decremented both}}
}
for (;;--i) { // expected-note{{decremented here}}
--i; // expected-warning{{decremented both}}
}
// Don't warn when loop is only one statement.
for (;;++i)
i++;
for (;;--i)
--i;
// Don't warn when loop has continue statement.
for (;;i++) {
if (true) continue;
i++;
}
for (;;i--) {
if (true) continue;
i--;
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/literal-operators.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
#include <stddef.h>
struct tag {
void operator "" _tag_bad (const char *); // expected-error {{literal operator 'operator "" _tag_bad' must be in a namespace or global scope}}
friend void operator "" _tag_good (const char *);
};
namespace ns { void operator "" _ns_good (const char *); }
// Check extern "C++" declarations
extern "C++" void operator "" _extern_good (const char *);
extern "C++" { void operator "" _extern_good (const char *); }
void fn () { void operator "" _fn_good (const char *); }
// One-param declarations (const char * was already checked)
void operator "" _good (char);
void operator "" _good (wchar_t);
void operator "" _good (char16_t);
void operator "" _good (char32_t);
void operator "" _good (unsigned long long);
void operator "" _good (long double);
// Two-param declarations
void operator "" _good (const char *, size_t);
void operator "" _good (const wchar_t *, size_t);
void operator "" _good (const char16_t *, size_t);
void operator "" _good (const char32_t *, size_t);
// Check typedef and array equivalences
void operator "" _good (const char[]);
typedef const char c;
void operator "" _good (c*);
// Check extra cv-qualifiers
void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{parameter declaration for literal operator 'operator "" _cv_good' is not valid}}
// Template declaration
template <char...> void operator "" _good ();
// FIXME: Test some invalid decls that might crop up.
template <typename...> void operator "" _invalid(); // expected-error {{parameter declaration for literal operator 'operator "" _invalid' is not valid}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/redeclared-auto.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
extern int a;
auto a = 0; // expected-note 2{{here}}
auto a = 0; // expected-error {{redefinition}}
int a = 0; // expected-error {{redefinition}}
extern auto a; // expected-error {{requires an initializer}}
extern int b; // expected-note {{here}}
auto b = 0.0; // expected-error {{different type}}
struct S {
static int a;
static int b; // expected-note {{here}}
};
auto S::a = 0; // expected-note 2{{here}}
auto S::a; // expected-error {{redefinition}} expected-error {{requires an initializer}}
int S::a = 0; // expected-error {{redefinition}}
auto S::b = 0.0; // expected-error {{different type}}
void f() {
extern int a;
extern auto a; // expected-error {{requires an initializer}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/microsoft-varargs.cpp
|
// RUN: %clang_cc1 -triple thumbv7-windows -fms-compatibility -fsyntax-only %s -verify
// expected-no-diagnostics
extern "C" {
typedef char * va_list;
void __va_start(va_list *, ...);
}
int test___va_start(int i, ...) {
va_list ap;
__va_start(&ap, ( &reinterpret_cast<const char &>(i) ),
( (sizeof(i) + 4 - 1) & ~(4 - 1) ),
( &reinterpret_cast<const char &>(i) ));
return (*(int *)((ap += ( (sizeof(int) + 4 - 1) & ~(4 - 1) ) + ( ((va_list)0 - (ap)) & (__alignof(int) - 1) )) - ( (sizeof(int) + 4 - 1) & ~(4 - 1) )));
}
int builtin(int i, ...) {
__builtin_va_list ap;
__builtin_va_start(ap, i);
return __builtin_va_arg(ap, int);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/SemaCXX/bool-compare.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f(int x, int y, int z) {
bool a,b;
if(b > true) {} // expected-warning {{comparison of true with expression of type 'bool' is always false}}
if(b < true) {} // no warning
if(b >= true) {} // no warning
if(b <= true) {} // expected-warning {{comparison of true with expression of type 'bool' is always true}}
if(b == true) {} // no warning
if(b != true) {} // no warning
if(b > false) {} // no warning
if(b < false) {} // expected-warning {{comparison of false with expression of type 'bool' is always false}}
if(b >= false) {} // expected-warning {{comparison of false with expression of type 'bool' is always true}}
if(b <= false) {} // no warning
if(b == false) {} // no warning
if(b != false) {} // no warning
if(b > 1U){} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
if (a > b) {} // no warning
if (a < b) {} // no warning
if (a >= b) {} // no warning
if (a <= b) {} // no warning
if (a == b) {} // no warning
if (a != b) {} // no warning
if (a > 0) {} // no warning
if (a > 1) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
if (a > 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
if (a >= 0) {} // expected-warning {{comparison of constant 0 with expression of type 'bool' is always true}}
if (a >= 1) {} // no warning
if (a >= 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
if (a >= -1) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if (a <= 0) {} // no warning
if (a <= 1) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always true}}
if (a <= 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always true}}
if (a <= -1) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if (!a > 0) {} // no warning
if (!a > 1) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
if (!a > 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
if (!a > y) {} // no warning
if (!a > b) {} // no warning
if (!a > -1) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if (!a < 0) {} // expected-warning {{comparison of constant 0 with expression of type 'bool' is always false}}
if (!a < 1) {} // no warning
if (!a < 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always true}}
if (!a < y) {} // no warning
if (!a < b) {} // no warning
if (!a < -1) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if (!a >= 0) {} // expected-warning {{comparison of constant 0 with expression of type 'bool' is always true}}
if (!a >= 1) {} // no warning
if (!a >= 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
if (!a >= y) {} // no warning
if (!a >= b) {} // no warning
if (!a >= -1) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if (!a <= 0) {} // no warning
if (!a <= 1) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always true}}
if (!a <= 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always true}}
if (!a <= y) {} // no warning
if (!a <= b) {} // no warning
if (!a <= -1) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if ((a||b) > 0) {} // no warning
if ((a||b) > 1) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
if ((a||b) > 4) {} // expected-warning {{comparison of constant 4 with expression of type 'bool' is always false}}
if ((a||b) > -1) {}// expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if ((a&&b) > 0) {} // no warning
if ((a&&b) > 1) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
if ((a&&b) > 4) {} // expected-warning {{comparison of constant 4 with expression of type 'bool' is always false}}
if ((a<y) > 0) {} // no warning
if ((a<y) > 1) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
if ((a<y) > 4) {} // expected-warning {{comparison of constant 4 with expression of type 'bool' is always false}}
if ((a<y) > z) {} // no warning
if ((a<y) > -1) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if ((a<y) == 0) {} // no warning
if ((a<y) == 1) {} // no warning
if ((a<y) == 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
if ((a<y) == z) {} // no warning
if ((a<y) == -1) {}// expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if ((a<y) != 0) {} // no warning
if ((a<y) != 1) {} // no warning
if ((a<y) != 2) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always true}}
if ((a<y) != z) {} // no warning
if ((a<y) != -1) {}// expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if ((a<y) == z) {} // no warning
if (a>y<z) {} // no warning
if ((a<y) > z) {} // no warning
if((a<y)>(z<y)) {} // no warning
if((a<y)==(z<y)){} // no warning
if((a<y)!=(z<y)){} // no warning
if((z==x)<(y==z)){} // no warning
if((a<y)!=((z==x)<(y==z))){} // no warning
if (0 > !a) {} // expected-warning {{comparison of constant 0 with expression of type 'bool' is always false}}
if (1 > !a) {} // no warning
if (2 > !a) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always true}}
if (y > !a) {} // no warning
if (-1 > !a) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if (0 < !a) {} // no warning
if (1 < !a) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always false}}
if (2 < !a) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
if (y < !a) {} // no warning
if (-1 < !a) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if (0 >= !a) {} // no warning
if (1 >= !a) {} // expected-warning {{comparison of constant 1 with expression of type 'bool' is always true}}
if (2 >= !a) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always true}}
if (y >= !a) {} // no warning
if (-1 >= !a) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if (0 <= !a) {} // expected-warning {{comparison of constant 0 with expression of type 'bool' is always true}}
if (1 <= !a) {} // no warning
if (2 <= !a) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
if (y <= !a) {} //
if (-1 <= !a) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if (0 > (a||b)) {} // expected-warning {{comparison of constant 0 with expression of type 'bool' is always false}}
if (1 > (a||b)) {} // no warning
if (4 > (a||b)) {} // expected-warning {{comparison of constant 4 with expression of type 'bool' is always true}}
if (0 > (a&&b)) {} // expected-warning {{comparison of constant 0 with expression of type 'bool' is always false}}
if (1 > (a&&b)) {} // no warning
if (4 > (a&&b)) {} // expected-warning {{comparison of constant 4 with expression of type 'bool' is always true}}
if (0 > (a<y)) {} // expected-warning {{comparison of constant 0 with expression of type 'bool' is always false}}
if (1 > (a<y)) {} // no warning
if (4 > (a<y)) {} // expected-warning {{comparison of constant 4 with expression of type 'bool' is always true}}
if (z > (a<y)) {} //
if (-1 > (a<y)) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if (0 == (a<y)) {} // no warning
if (1 == (a<y)) {} // no warning
if (2 == (a<y)) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always false}}
if (z == (a<y)) {} // no warning
if (-1 == (a<y)){} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if (0 !=(a<y)) {} // no warning
if (1 !=(a<y)) {} // no warning
if (2 !=(a<y)) {} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always true}}
if (z !=(a<y)) {} // no warning
if (-1 !=(a<y)) {} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always true}}
if (z ==(a<y)) {} // no warning
if (z<a>y) {} // no warning
if (z > (a<y)) {} // no warning
if((z<y)>(a<y)) {} // no warning
if((z<y)==(a<y)){} // no warning
if((z<y)!=(a<y)){} // no warning
if((y==z)<(z==x)){} // no warning
if(((z==x)<(y==z))!=(a<y)){} // no warning
if(((z==x)<(-1==z))!=(a<y)){} // no warning
if(((z==x)<(z==-1))!=(a<y)){} // no warning
if(((z==x)<-1)!=(a<y)){} // expected-warning {{comparison of constant -1 with expression of type 'bool' is always false}}
if(((z==x)< 2)!=(a<y)){} // expected-warning {{comparison of constant 2 with expression of type 'bool' is always true}}
if(((z==x)<(z>2))!=(a<y)){} // no warning
}
template<typename T, typename U, typename V> struct X6 {
U f(T t, U u, V v) {
// IfStmt
if (t > 0)
return u;
else {
if (t < 0)
return v; // expected-error{{cannot initialize return object of type}}
}
bool r;
// FIXME: We should warn here, DiagRuntimeBehavior does currently not detect this.
if(r<0){}
if (T x = t) {
t = x;
}
return v; // expected-error{{cannot initialize return object of type}}
}
};
struct ConvertibleToInt {
operator int() const;
};
template struct X6<ConvertibleToInt, float, char>;
template struct X6<bool, int, int*>; // expected-note{{instantiation}}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.