2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fblocks %s
|
2008-08-21 06:07:34 +08:00
|
|
|
|
2008-12-12 14:19:11 +08:00
|
|
|
// PR2241
|
2009-04-16 05:35:27 +08:00
|
|
|
float test2241[2] = {
|
2008-12-12 14:19:11 +08:00
|
|
|
1e, // expected-error {{exponent}}
|
|
|
|
1ee0 // expected-error {{exponent}}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-08-21 06:07:34 +08:00
|
|
|
// Testcase derived from PR2692
|
2009-07-22 08:43:08 +08:00
|
|
|
static void f (char * (*g) (char **, int), char **p, ...) {
|
|
|
|
char *s;
|
|
|
|
va_list v; // expected-error {{identifier}}
|
|
|
|
s = g (p, __builtin_va_arg(v, int)); // expected-error {{identifier}}
|
2008-08-21 06:07:34 +08:00
|
|
|
}
|
|
|
|
|
2008-12-09 05:59:01 +08:00
|
|
|
|
|
|
|
// PR3172
|
|
|
|
} // expected-error {{expected external declaration}}
|
|
|
|
|
|
|
|
|
2008-12-12 14:19:11 +08:00
|
|
|
// rdar://6094870
|
2009-07-22 08:43:08 +08:00
|
|
|
void test(int a) {
|
2008-12-12 14:19:11 +08:00
|
|
|
struct { int i; } x;
|
|
|
|
|
|
|
|
if (x.hello) // expected-error {{no member named 'hello'}}
|
|
|
|
test(0);
|
|
|
|
else
|
|
|
|
;
|
|
|
|
|
|
|
|
if (x.hello == 0) // expected-error {{no member named 'hello'}}
|
|
|
|
test(0);
|
|
|
|
else
|
|
|
|
;
|
|
|
|
|
|
|
|
if ((x.hello == 0)) // expected-error {{no member named 'hello'}}
|
|
|
|
test(0);
|
|
|
|
else
|
|
|
|
;
|
|
|
|
|
|
|
|
if (x.i == 0)) // expected-error {{expected expression}}
|
|
|
|
test(0);
|
|
|
|
else
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2008-12-12 14:21:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
char (((( /* expected-note {{to match this '('}} */
|
|
|
|
*X x ] )))); /* expected-error {{expected ')'}} */
|
|
|
|
|
|
|
|
; // expected-warning {{ISO C does not allow an extra ';' outside of a function}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct S { void *X, *Y; };
|
|
|
|
|
|
|
|
struct S A = {
|
|
|
|
&BADIDENT, 0 /* expected-error {{use of undeclared identifier}} */
|
|
|
|
};
|
2008-12-13 03:20:14 +08:00
|
|
|
|
|
|
|
// rdar://6248081
|
2009-07-22 08:43:08 +08:00
|
|
|
void test6248081() {
|
2008-12-13 03:20:14 +08:00
|
|
|
[10] // expected-error {{expected expression}}
|
|
|
|
}
|
|
|
|
|
2009-01-20 03:26:10 +08:00
|
|
|
struct forward; // expected-note{{forward declaration of 'struct forward'}}
|
2008-12-18 06:22:03 +08:00
|
|
|
void x(struct forward* x) {switch(x->a) {}} // expected-error {{incomplete definition of type}}
|
2008-12-18 06:19:57 +08:00
|
|
|
|
Introduce code modification hints into the diagnostics system. When we
know how to recover from an error, we can attach a hint to the
diagnostic that states how to modify the code, which can be one of:
- Insert some new code (a text string) at a particular source
location
- Remove the code within a given range
- Replace the code within a given range with some new code (a text
string)
Right now, we use these hints to annotate diagnostic information. For
example, if one uses the '>>' in a template argument in C++98, as in
this code:
template<int I> class B { };
B<1000 >> 2> *b1;
we'll warn that the behavior will change in C++0x. The fix is to
insert parenthese, so we use code insertion annotations to illustrate
where the parentheses go:
test.cpp:10:10: warning: use of right-shift operator ('>>') in template
argument will require parentheses in C++0x
B<1000 >> 2> *b1;
^
( )
Use of these annotations is partially implemented for HTML
diagnostics, but it's not (yet) producing valid HTML, which may be
related to PR2386, so it has been #if 0'd out.
In this future, we could consider hooking this mechanism up to the
rewriter to actually try to fix these problems during compilation (or,
after a compilation whose only errors have fixes). For now, however, I
suggest that we use these code modification hints whenever we can, so
that we get better diagnostics now and will have better coverage when
we find better ways to use this information.
This also fixes PR3410 by placing the complaint about missing tokens
just after the previous token (rather than at the location of the next
token).
llvm-svn: 65570
2009-02-27 05:00:50 +08:00
|
|
|
// PR3410
|
|
|
|
void foo() {
|
|
|
|
int X;
|
|
|
|
X = 4 // expected-error{{expected ';' after expression}}
|
|
|
|
}
|
2010-05-15 01:44:56 +08:00
|
|
|
|
2011-06-25 01:58:59 +08:00
|
|
|
// rdar://9045701
|
|
|
|
void test9045701(int x) {
|
|
|
|
#define VALUE 0
|
|
|
|
x = VALUE // expected-error{{expected ';' after expression}}
|
|
|
|
}
|
2010-05-15 01:44:56 +08:00
|
|
|
|
|
|
|
// rdar://7980651
|
|
|
|
typedef int intptr_t; // expected-note {{'intptr_t' declared here}}
|
|
|
|
void bar(intptr y); // expected-error {{unknown type name 'intptr'; did you mean 'intptr_t'?}}
|
2010-09-08 02:31:03 +08:00
|
|
|
|
|
|
|
void test1(void) {
|
|
|
|
int x = 2: // expected-error {{expected ';' at end of declaration}}
|
|
|
|
int y = x;
|
|
|
|
int z = y;
|
|
|
|
}
|