File tree Expand file tree Collapse file tree 4 files changed +8
-5
lines changed Expand file tree Collapse file tree 4 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -944,6 +944,8 @@ def err_tentative_def_incomplete_type : Error<
944
944
"tentative definition has type %0 that is never completed">;
945
945
def err_tentative_def_incomplete_type_arr : Error<
946
946
"tentative definition has array of type %0 that is never completed">;
947
+ def warn_tentative_incomplete_array : Warning<
948
+ "tentative array definition assumed to have one element">;
947
949
948
950
def err_realimag_invalid_type : Error<"invalid type %0 to %1 operator">;
949
951
def err_typecheck_sclass_fscope : Error<
Original file line number Diff line number Diff line change @@ -253,8 +253,9 @@ void Sema::ActOnEndOfTranslationUnit() {
253
253
VD->setInvalidDecl ();
254
254
else {
255
255
// Set the length of the array to 1 (C99 6.9.2p5).
256
- llvm::APSInt One (Context.getTypeSize (Context.getSizeType ()),
257
- true );
256
+ Diag (VD->getLocation (), diag::warn_tentative_incomplete_array);
257
+ llvm::APInt One (Context.getTypeSize (Context.getSizeType ()),
258
+ true );
258
259
QualType T
259
260
= Context.getConstantArrayType (ArrayT->getElementType (),
260
261
One, ArrayType::Normal, 0 );
Original file line number Diff line number Diff line change 1
1
// RUN: clang-cc -fsyntax-only -verify -pedantic -fblocks %s
2
2
3
3
// PR2241
4
- float test2241 [] = {
4
+ float test2241 [2 ] = {
5
5
1e , // expected-error {{exponent}}
6
6
1ee0 // expected-error {{exponent}}
7
7
};
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ static struct foo g; // expected-error {{variable has incomplete type 'struct f
11
11
extern void d ;
12
12
extern struct foo e ;
13
13
14
- int ary [];
14
+ int ary []; // expected-warning {{tentative array definition assumed to have one element}}
15
15
struct foo bary []; // expected-error {{array has incomplete element type 'struct foo'}}
16
16
17
17
void func () {
@@ -20,7 +20,7 @@ void func() {
20
20
struct foo f ; // expected-error {{variable has incomplete type 'struct foo'}}
21
21
}
22
22
23
- int h [];
23
+ int h []; // expected-warning {{tentative array definition assumed to have one element}}
24
24
int (* i )[] = & h + 1 ; // expected-error {{arithmetic on pointer to incomplete type 'int (*)[]'}}
25
25
26
26
struct bar j = {1 }; // expected-error {{variable has incomplete type 'struct bar'}} \
You can’t perform that action at this time.
0 commit comments