summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-01-19 19:26:10 +0000
committerDouglas Gregor <dgregor@apple.com>2009-01-19 19:26:10 +0000
commitdd430f7ec9511f440a55d090c1a8d4df118e0e68 (patch)
tree7b670938f8911ad43483817101a0f90454211517 /clang/test
parentababe7d47df60f0a68b3a3712de4032e1a12d3fb (diff)
downloadbcm5719-llvm-dd430f7ec9511f440a55d090c1a8d4df118e0e68.tar.gz
bcm5719-llvm-dd430f7ec9511f440a55d090c1a8d4df118e0e68.zip
Centralize error reporting of improper uses of incomplete types in the
new DiagnoseIncompleteType. It provides additional information about struct/class/union/enum types when possible, either by pointing to the forward declaration of that type or by pointing to the definition (if we're in the process of defining that type). Fixes <rdar://problem/6500531>. llvm-svn: 62521
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Parser/recovery.c2
-rw-r--r--clang/test/Sema/array-constraint.c2
-rw-r--r--clang/test/Sema/compound-literal.c2
-rw-r--r--clang/test/Sema/enum.c11
-rw-r--r--clang/test/Sema/incomplete-decl.c2
-rw-r--r--clang/test/Sema/init.c3
-rw-r--r--clang/test/Sema/pointer-addition.c6
-rw-r--r--clang/test/SemaCXX/dynamic-cast.cpp2
-rw-r--r--clang/test/SemaCXX/new-delete.cpp2
-rw-r--r--clang/test/SemaCXX/qualified-id-lookup.cpp2
-rw-r--r--clang/test/SemaCXX/try-catch.cpp2
-rw-r--r--clang/test/SemaObjC/ivar-sem-check-1.m8
12 files changed, 27 insertions, 17 deletions
diff --git a/clang/test/Parser/recovery.c b/clang/test/Parser/recovery.c
index 430d3c1caa1..b6ba9e6294f 100644
--- a/clang/test/Parser/recovery.c
+++ b/clang/test/Parser/recovery.c
@@ -65,6 +65,6 @@ int test6248081() {
[10] // expected-error {{expected expression}}
}
-struct forward;
+struct forward; // expected-note{{forward declaration of 'struct forward'}}
void x(struct forward* x) {switch(x->a) {}} // expected-error {{incomplete definition of type}}
diff --git a/clang/test/Sema/array-constraint.c b/clang/test/Sema/array-constraint.c
index 596d19f77c6..69475b76f64 100644
--- a/clang/test/Sema/array-constraint.c
+++ b/clang/test/Sema/array-constraint.c
@@ -1,6 +1,6 @@
// RUN: clang -fsyntax-only -verify -pedantic %s
-struct s;
+struct s; // expected-note {{forward declaration of 'struct s'}}
struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}}
return z;
}
diff --git a/clang/test/Sema/compound-literal.c b/clang/test/Sema/compound-literal.c
index c053a59fa7e..e457c72bee4 100644
--- a/clang/test/Sema/compound-literal.c
+++ b/clang/test/Sema/compound-literal.c
@@ -24,7 +24,7 @@ int main(int argc, char **argv) {
fooFunc(&(struct foo){ 1, 2 });
}
-struct Incomplete;
+struct Incomplete; // expected-note{{forward declaration of 'struct Incomplete'}}
struct Incomplete* I1 = &(struct Incomplete){1, 2, 3}; // -expected-error {{variable has incomplete type}}
void IncompleteFunc(unsigned x) {
struct Incomplete* I2 = (struct foo[x]){1, 2, 3}; // -expected-error {{variable-sized object may not be initialized}}
diff --git a/clang/test/Sema/enum.c b/clang/test/Sema/enum.c
index ea66c27aeff..55ddb0ddd93 100644
--- a/clang/test/Sema/enum.c
+++ b/clang/test/Sema/enum.c
@@ -21,7 +21,9 @@ int test() {
return sizeof(enum e) ;
}
-enum gccForwardEnumExtension ve; // expected-error {{variable has incomplete type 'enum gccForwardEnumExtension'}} expected-warning{{ISO C forbids forward references to 'enum' types}}
+enum gccForwardEnumExtension ve; // expected-error {{variable has incomplete type 'enum gccForwardEnumExtension'}} \
+ // expected-warning{{ISO C forbids forward references to 'enum' types}} \
+ // expected-note{{forward declaration of 'enum gccForwardEnumExtension'}}
int test2(int i)
{
@@ -52,7 +54,7 @@ enum someenum {}; // expected-warning {{use of empty enum extension}}
// <rdar://problem/6093889>
enum e0 { // expected-note {{previous definition is here}}
- E0 = sizeof(enum e0 { E1 }) // expected-error {{nested redefinition}}
+ E0 = sizeof(enum e0 { E1 }), // expected-error {{nested redefinition}}
};
// PR3173
@@ -66,3 +68,8 @@ void foo() {
// <rdar://problem/6503878>
typedef enum { X = 0 }; // expected-warning{{typedef requires a name}}
+
+
+enum NotYetComplete { // expected-note{{definition of 'enum NotYetComplete' is not complete until the closing '}'}}
+ NYC1 = sizeof(enum NotYetComplete) // expected-error{{invalid application of 'sizeof' to an incomplete type 'enum NotYetComplete'}}
+};
diff --git a/clang/test/Sema/incomplete-decl.c b/clang/test/Sema/incomplete-decl.c
index fedf2c69f7c..bd603681d64 100644
--- a/clang/test/Sema/incomplete-decl.c
+++ b/clang/test/Sema/incomplete-decl.c
@@ -1,5 +1,7 @@
// RUN: clang -fsyntax-only -verify %s
+struct foo; // expected-note {{forward declaration of 'struct foo'}}
+
void b; // expected-error {{variable has incomplete type 'void'}}
struct foo f; // expected-error {{variable has incomplete type 'struct foo'}}
diff --git a/clang/test/Sema/init.c b/clang/test/Sema/init.c
index 72586b13c48..abfab37b439 100644
--- a/clang/test/Sema/init.c
+++ b/clang/test/Sema/init.c
@@ -71,7 +71,8 @@ int sym_fw1a_scr[] = {
// PR3001
struct s1 s2 = {
- .a = sizeof(struct s3), // expected-error {{invalid application of 'sizeof'}}
+ .a = sizeof(struct s3), // expected-error {{invalid application of 'sizeof'}} \
+ // expected-note{{forward declaration of 'struct s3'}}
.b = bogus // expected-error {{use of undeclared identifier 'bogus'}}
}
diff --git a/clang/test/Sema/pointer-addition.c b/clang/test/Sema/pointer-addition.c
index f2fb973d1be..95f364fc676 100644
--- a/clang/test/Sema/pointer-addition.c
+++ b/clang/test/Sema/pointer-addition.c
@@ -1,6 +1,6 @@
// RUN: clang %s -fsyntax-only -verify -pedantic
-typedef struct S S;
+typedef struct S S; // expected-note{{forward declaration of 'struct S'}}
void a(S* b, void* c) {
b++; // expected-error {{arithmetic on pointer to incomplete type}}
b += 1; // expected-error {{arithmetic on pointer to incomplete type}}
@@ -9,6 +9,6 @@ void a(S* b, void* c) {
b = 1+b; // expected-error {{arithmetic on pointer to incomplete type}}
/* The next couple tests are only pedantic warnings in gcc */
void (*d)(S*,void*) = a;
- d += 1; // expected-error {{pointer to incomplete type}}
- d++; // expected-error {{pointer to incomplete type}}
+ d += 1; // expected-error {{arithmetic on pointer to function type}}}
+ d++; // expected-error {{arithmetic on pointer to function type}}}
}
diff --git a/clang/test/SemaCXX/dynamic-cast.cpp b/clang/test/SemaCXX/dynamic-cast.cpp
index 8b0b7488016..654f2e41bc5 100644
--- a/clang/test/SemaCXX/dynamic-cast.cpp
+++ b/clang/test/SemaCXX/dynamic-cast.cpp
@@ -8,7 +8,7 @@ struct D : private A {};
struct E : A {};
struct F : B, E {};
-struct Incomplete;
+struct Incomplete; // expected-note{{forward declaration of 'struct Incomplete'}}
struct Poly
{
diff --git a/clang/test/SemaCXX/new-delete.cpp b/clang/test/SemaCXX/new-delete.cpp
index fa19c6a0557..ce96897e1f8 100644
--- a/clang/test/SemaCXX/new-delete.cpp
+++ b/clang/test/SemaCXX/new-delete.cpp
@@ -8,7 +8,7 @@ struct S // expected-note {{candidate}}
S(double, int); // expected-note {{candidate}} expected-note {{candidate}}
S(float, int); // expected-note {{candidate}} expected-note {{candidate}}
};
-struct T;
+struct T; // expected-note{{forward declaration of 'struct T'}}
struct U
{
// A special new, to verify that the global version isn't used.
diff --git a/clang/test/SemaCXX/qualified-id-lookup.cpp b/clang/test/SemaCXX/qualified-id-lookup.cpp
index cf86971f350..e5721e00ee3 100644
--- a/clang/test/SemaCXX/qualified-id-lookup.cpp
+++ b/clang/test/SemaCXX/qualified-id-lookup.cpp
@@ -96,7 +96,7 @@ void test_a() {
a::a::a::i = 4;
}
-struct Undef {
+struct Undef { // expected-note{{definition of 'struct Undef' is not complete until the closing '}'}}
typedef int type;
Undef::type member;
diff --git a/clang/test/SemaCXX/try-catch.cpp b/clang/test/SemaCXX/try-catch.cpp
index 97dbaee10de..0d72f119df7 100644
--- a/clang/test/SemaCXX/try-catch.cpp
+++ b/clang/test/SemaCXX/try-catch.cpp
@@ -1,6 +1,6 @@
// RUN: clang -fsyntax-only -verify %s
-struct A;
+struct A; // expected-note{{forward declaration of 'struct A'}}
void f()
{
diff --git a/clang/test/SemaObjC/ivar-sem-check-1.m b/clang/test/SemaObjC/ivar-sem-check-1.m
index a6d1a22a915..1ec4e57ce84 100644
--- a/clang/test/SemaObjC/ivar-sem-check-1.m
+++ b/clang/test/SemaObjC/ivar-sem-check-1.m
@@ -1,19 +1,19 @@
// RUN: clang -fsyntax-only -verify %s
-struct S;
+struct S; // expected-note{{forward declaration of 'struct S'}}
typedef int FOO();
@interface INTF
{
struct F {} JJ;
- int arr[]; // expected-error {{field 'arr' has incomplete type}}
- struct S IC; // expected-error {{field 'IC' has incomplete type}}
+ int arr[]; // expected-error {{field has incomplete type}}
+ struct S IC; // expected-error {{field has incomplete type}}
struct T { // expected-note {{previous definition is here}}
struct T {} X; // expected-error {{nested redefinition of 'T'}}
}YYY;
FOO BADFUNC; // expected-error {{field 'BADFUNC' declared as a function}}
int kaka; // expected-note {{previous declaration is here}}
int kaka; // expected-error {{duplicate member 'kaka'}}
- char ch[]; // expected-error {{field 'ch' has incomplete type}}
+ char ch[]; // expected-error {{field has incomplete type}}
}
@end
OpenPOWER on IntegriCloud