2009-03-24 10:24:46 +08:00
|
|
|
// RUN: clang-cc %s -verify -pedantic -fsyntax-only
|
2008-02-03 04:20:10 +08:00
|
|
|
|
|
|
|
// PR1966
|
|
|
|
_Complex double test1() {
|
|
|
|
return __extension__ 1.0if;
|
|
|
|
}
|
|
|
|
|
|
|
|
_Complex double test2() {
|
|
|
|
return 1.0if; // expected-warning {{imaginary constants are an extension}}
|
|
|
|
}
|
|
|
|
|
2008-07-26 02:07:19 +08:00
|
|
|
// rdar://6097308
|
|
|
|
void test3() {
|
|
|
|
int x;
|
|
|
|
(__extension__ x) = 10;
|
|
|
|
}
|
|
|
|
|
2008-08-22 02:04:13 +08:00
|
|
|
// rdar://6162726
|
|
|
|
void test4() {
|
|
|
|
static int var;
|
|
|
|
var =+ 5; // expected-warning {{use of unary operator that may be intended as compound assignment (+=)}}
|
|
|
|
var =- 5; // expected-warning {{use of unary operator that may be intended as compound assignment (-=)}}
|
2009-03-08 14:51:10 +08:00
|
|
|
var = +5; // no warning when space between the = and +.
|
2008-08-22 02:04:13 +08:00
|
|
|
var = -5;
|
2009-03-08 14:51:10 +08:00
|
|
|
|
|
|
|
var =+5; // no warning when the subexpr of the unary op has no space before it.
|
|
|
|
var =-5;
|
2009-03-09 15:11:10 +08:00
|
|
|
|
|
|
|
#define FIVE 5
|
|
|
|
var=-FIVE; // no warning with macros.
|
|
|
|
var=-FIVE;
|
2008-08-22 02:04:13 +08:00
|
|
|
}
|
|
|
|
|
2008-11-18 03:51:54 +08:00
|
|
|
// rdar://6319320
|
|
|
|
void test5(int *X, float *P) {
|
|
|
|
(float*)X = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
|
|
|
|
}
|
|
|
|
|
2008-11-22 02:27:34 +08:00
|
|
|
void test6() {
|
|
|
|
int X;
|
|
|
|
X(); // expected-error {{called object type 'int' is not a function or function pointer}}
|
|
|
|
}
|
2008-11-23 03:57:03 +08:00
|
|
|
|
|
|
|
void test7(int *P, _Complex float Gamma) {
|
|
|
|
P = (P-42) + Gamma*4; // expected-error {{invalid operands to binary expression ('int *' and '_Complex float')}}
|
|
|
|
}
|
|
|
|
|
2008-12-12 13:35:08 +08:00
|
|
|
|
|
|
|
// rdar://6095061
|
|
|
|
int test8(void) {
|
|
|
|
int i;
|
2008-12-12 13:59:56 +08:00
|
|
|
__builtin_choose_expr (0, 42, i) = 10; // expected-warning {{extension used}}
|
2008-12-12 13:35:08 +08:00
|
|
|
return i;
|
|
|
|
}
|
2009-01-25 04:17:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
// PR3386
|
|
|
|
struct f { int x : 4; float y[]; };
|
|
|
|
int test9(struct f *P) {
|
2009-01-25 05:29:22 +08:00
|
|
|
int R;
|
|
|
|
R = __alignof(P->x); // expected-error {{invalid application of '__alignof' to bitfield}} expected-warning {{extension used}}
|
|
|
|
R = __alignof(P->y); // ok. expected-warning {{extension used}}
|
|
|
|
R = sizeof(P->x); // expected-error {{invalid application of 'sizeof' to bitfield}}
|
|
|
|
return R;
|
2009-01-25 04:17:12 +08:00
|
|
|
}
|
|
|
|
|
2009-02-14 06:08:30 +08:00
|
|
|
// PR3562
|
|
|
|
void test10(int n,...) {
|
|
|
|
struct S {
|
|
|
|
double a[n]; // expected-error {{fields must have a constant size}}
|
|
|
|
} s;
|
|
|
|
double x = s.a[0]; // should not get another error here.
|
|
|
|
}
|
2009-02-20 07:45:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
#define MYMAX(A,B) __extension__ ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
|
|
|
|
|
|
|
|
struct mystruct {int A; };
|
2009-03-09 03:39:53 +08:00
|
|
|
void test11(struct mystruct P, float F) {
|
2009-02-20 07:45:49 +08:00
|
|
|
MYMAX(P, F); // expected-error {{invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))}}
|
|
|
|
}
|
|
|
|
|
2009-03-09 03:39:53 +08:00
|
|
|
// PR3753
|
|
|
|
int test12(const char *X) {
|
2009-03-09 03:52:14 +08:00
|
|
|
return X == "foo"; // expected-warning {{comparison against a string literal is unspecified}}
|
2009-03-09 03:39:53 +08:00
|
|
|
}
|
|
|
|
|