File tree Expand file tree Collapse file tree 6 files changed +17
-10
lines changed Expand file tree Collapse file tree 6 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -319,6 +319,9 @@ Improvements to Clang's diagnostics
319
319
- ``-Wc++98-compat `` no longer diagnoses use of ``__auto_type `` or
320
320
``decltype(auto) `` as though it was the extension for ``auto ``. (#GH47900)
321
321
322
+ - Now correctly diagnose a tentative definition of an array with static
323
+ storage duration in pedantic mode in C. (#GH50661)
324
+
322
325
Improvements to Clang's time-trace
323
326
----------------------------------
324
327
Original file line number Diff line number Diff line change @@ -7350,8 +7350,9 @@ def err_typecheck_pointer_arith_void_type : Error<
7350
7350
"arithmetic on%select{ a|}0 pointer%select{|s}0 to void">;
7351
7351
def err_typecheck_decl_incomplete_type : Error<
7352
7352
"variable has incomplete type %0">;
7353
- def ext_typecheck_decl_incomplete_type : ExtWarn<
7354
- "tentative definition of variable with internal linkage has incomplete non-array type %0">,
7353
+ def ext_typecheck_decl_incomplete_type : Extension<
7354
+ "tentative definition of variable with internal linkage has incomplete "
7355
+ "%select{non-array|array}0 type %1">,
7355
7356
InGroup<DiagGroup<"tentative-definition-incomplete-type">>;
7356
7357
def err_tentative_def_incomplete_type : Error<
7357
7358
"tentative definition has type %0 that is never completed">;
Original file line number Diff line number Diff line change @@ -14246,7 +14246,8 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
14246
14246
Var->getLocation(), ArrayT->getElementType(),
14247
14247
diag::err_array_incomplete_or_sizeless_type))
14248
14248
Var->setInvalidDecl();
14249
- } else if (Var->getStorageClass() == SC_Static) {
14249
+ }
14250
+ if (Var->getStorageClass() == SC_Static) {
14250
14251
// C99 6.9.2p3: If the declaration of an identifier for an object is
14251
14252
// a tentative definition and has internal linkage (C99 6.2.2p3), the
14252
14253
// declared type shall not be an incomplete type.
@@ -14258,7 +14259,8 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
14258
14259
// NOTE: to avoid multiple warnings, only check the first declaration.
14259
14260
if (Var->isFirstDecl())
14260
14261
RequireCompleteType(Var->getLocation(), Type,
14261
- diag::ext_typecheck_decl_incomplete_type);
14262
+ diag::ext_typecheck_decl_incomplete_type,
14263
+ Type->isArrayType());
14262
14264
}
14263
14265
}
14264
14266
Original file line number Diff line number Diff line change @@ -139,7 +139,9 @@ int dr010_c = sizeof(dr010_t); /* expected-error {{invalid application of 'sizeo
139
139
* Note: DR034 has a question resolved by DR011 and another question where the
140
140
* result is UB.
141
141
*/
142
- static int dr011_a []; /* expected-warning {{tentative array definition assumed to have one element}} */
142
+ static int dr011_a []; /* expected-warning {{tentative array definition assumed to have one element}}
143
+ expected-warning {{tentative definition of variable with internal linkage has incomplete array type 'int[]'}}
144
+ */
143
145
void dr011 (void ) {
144
146
extern int i [];
145
147
{
Original file line number Diff line number Diff line change 3
3
4
4
5
5
6
- struct foo ; // c-note 5 {{forward declaration of 'struct foo'}} \
6
+ struct foo ; // c-note 4 {{forward declaration of 'struct foo'}} \
7
7
cxx-note 3 {{forward declaration of 'foo'}}
8
8
9
9
void b ; // expected-error {{variable has incomplete type 'void'}}
10
10
struct foo f ; // c-error {{tentative definition has type 'struct foo' that is never completed}} \
11
11
cxx-error {{variable has incomplete type 'struct foo'}}
12
12
13
13
static void c ; // expected-error {{variable has incomplete type 'void'}}
14
- static struct foo g ; // c-warning {{tentative definition of variable with internal linkage has incomplete non-array type 'struct foo'}} \
15
- c-error {{tentative definition has type 'struct foo' that is never completed}} \
14
+ static struct foo g ; // c-error {{tentative definition has type 'struct foo' that is never completed}} \
16
15
cxx-error {{variable has incomplete type 'struct foo'}}
17
16
18
17
extern void d ; // cxx-error {{variable has incomplete type 'void'}}
Original file line number Diff line number Diff line change 1
- // RUN: %clang_cc1 %s -fsyntax-only -Wprivate-extern -verify
1
+ // RUN: %clang_cc1 %s -fsyntax-only -Wprivate-extern -pedantic - verify
2
2
3
3
// PR3310
4
4
struct a x1 ; // expected-note 2{{forward declaration of 'struct a'}}
@@ -58,7 +58,7 @@ void func2(void)
58
58
extern double * p ;
59
59
}
60
60
61
- static int a0 [];
61
+ static int a0 []; // expected-warning {{tentative definition of variable with internal linkage has incomplete array type 'int[]'}}
62
62
static int b0 ;
63
63
64
64
static int a0 [] = { 4 };
You can’t perform that action at this time.
0 commit comments