Skip to content

Commit 5278594

Browse files
committed
Add a diagnostic group for tentative array definitions
This diagnostic is one of the ones that GCC also does not have a warning group for, but a user requested adding a group to control selectively turning off this diagnostic. So this adds the diagnostic to a new group, -Wtentative-definition-array Fixes #87766
1 parent e47fd09 commit 5278594

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ Improvements to Clang's diagnostics
352352
(with initializer) entirely consist the condition expression of a if/while/for construct
353353
but are not actually used in the body of the if/while/for construct. Fixes #GH41447
354354

355+
- Clang emits a diagnostic when a tentative array definition is assumed to have
356+
a single element, but that diagnostic was never given a diagnostic group.
357+
Added the ``-Wtentative-definition-array`` warning group to cover this.
358+
Fixes #GH87766
359+
355360
Improvements to Clang's time-trace
356361
----------------------------------
357362

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7142,7 +7142,8 @@ def ext_typecheck_decl_incomplete_type : ExtWarn<
71427142
def err_tentative_def_incomplete_type : Error<
71437143
"tentative definition has type %0 that is never completed">;
71447144
def warn_tentative_incomplete_array : Warning<
7145-
"tentative array definition assumed to have one element">;
7145+
"tentative array definition assumed to have one element">,
7146+
InGroup<DiagGroup<"tentative-definition-array">>;
71467147
def err_typecheck_incomplete_array_needs_initializer : Error<
71477148
"definition of variable with array type needs an explicit size "
71487149
"or an initializer">;

clang/test/Misc/warning-flags.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This test serves two purposes:
1818

1919
The list of warnings below should NEVER grow. It should gradually shrink to 0.
2020

21-
CHECK: Warnings without flags (67):
21+
CHECK: Warnings without flags (66):
2222

2323
CHECK-NEXT: ext_expected_semi_decl_list
2424
CHECK-NEXT: ext_explicit_specialization_storage_class
@@ -80,7 +80,6 @@ CHECK-NEXT: warn_register_objc_catch_parm
8080
CHECK-NEXT: warn_related_result_type_compatibility_class
8181
CHECK-NEXT: warn_related_result_type_compatibility_protocol
8282
CHECK-NEXT: warn_template_export_unsupported
83-
CHECK-NEXT: warn_tentative_incomplete_array
8483
CHECK-NEXT: warn_typecheck_function_qualifiers
8584
CHECK-NEXT: warn_undef_interface
8685
CHECK-NEXT: warn_undef_interface_suggest
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %clang_cc1 -verify %s
2+
// RUN: %clang_cc1 -verify=good -Wno-tentative-definition-array %s
3+
// good-no-diagnostics
4+
5+
int foo[]; // expected-warning {{tentative array definition assumed to have one element}}

0 commit comments

Comments
 (0)