-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Give this diagnostic a diagnostic group #136182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AaronBallman
merged 1 commit into
llvm:main
from
AaronBallman:aballman-refconst-diag-group
Apr 18, 2025
Merged
Give this diagnostic a diagnostic group #136182
AaronBallman
merged 1 commit into
llvm:main
from
AaronBallman:aballman-refconst-diag-group
Apr 18, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I put this under -Wunitialized because that's the same group it's under in GCC. Fixes llvm#41104
@llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) ChangesI put this under -Wunitialized because that's the same group it's under in GCC. Fixes #41104 Full diff: https://github.com/llvm/llvm-project/pull/136182.diff 4 Files Affected:
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c75d83a6d1a7a..21f6aba8498b7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -385,6 +385,10 @@ Improvements to Clang's diagnostics
Fixes #GH131127
+- ``-Wuninitialized`` now diagnoses when a class does not declare any
+ constructors to initialize their non-modifiable members. The diagnostic is
+ not new; being controlled via a warning group is what's new. Fixes #GH41104
+
Improvements to Clang's time-trace
----------------------------------
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6cbe8b60fe9bf..c29a3422acd26 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2266,7 +2266,8 @@ def err_constructor_byvalue_arg : Error<
"copy constructor must pass its first argument by reference">;
def warn_no_constructor_for_refconst : Warning<
"%select{struct|interface|union|class|enum}0 %1 does not declare any "
- "constructor to initialize its non-modifiable members">;
+ "constructor to initialize its non-modifiable members">,
+ InGroup<Uninitialized>;
def note_refconst_member_not_initialized : Note<
"%select{const|reference}0 member %1 will never be initialized">;
def ext_ms_explicit_constructor_call : ExtWarn<
diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c
index 7ac77cc91fdc1..3dc4bb55aa69c 100644
--- a/clang/test/Misc/warning-flags.c
+++ b/clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@ This test serves two purposes:
The list of warnings below should NEVER grow. It should gradually shrink to 0.
-CHECK: Warnings without flags (57):
+CHECK: Warnings without flags (56):
CHECK-NEXT: ext_expected_semi_decl_list
CHECK-NEXT: ext_missing_whitespace_after_macro_name
@@ -57,7 +57,6 @@ CHECK-NEXT: warn_method_param_redefinition
CHECK-NEXT: warn_missing_case_for_condition
CHECK-NEXT: warn_missing_dependent_template_keyword
CHECK-NEXT: warn_missing_whitespace_after_macro_name
-CHECK-NEXT: warn_no_constructor_for_refconst
CHECK-NEXT: warn_not_compound_assign
CHECK-NEXT: warn_objc_property_copy_missing_on_block
CHECK-NEXT: warn_objc_protocol_qualifier_missing_id
diff --git a/clang/test/SemaCXX/uninitialized-no-ctor.cpp b/clang/test/SemaCXX/uninitialized-no-ctor.cpp
new file mode 100644
index 0000000000000..7a08f2f3dc37e
--- /dev/null
+++ b/clang/test/SemaCXX/uninitialized-no-ctor.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-uninitialized -verify=good %s
+//good-no-diagnostics
+
+template <class T>
+class RefMem { // expected-warning {{class 'RefMem<int &>' does not declare any constructor to initialize its non-modifiable members}}
+ T &M; // expected-note {{reference member 'M' will never be initialized}}
+};
+
+struct RefRef {
+ RefMem<int &> R; // expected-note {{in instantiation of template class 'RefMem<int &>' requested here}}
+};
+
|
Sirraide
approved these changes
Apr 17, 2025
erichkeane
approved these changes
Apr 17, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
I put this under -Wunitialized because that's the same group it's under in GCC. Fixes llvm#41104
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
I put this under -Wunitialized because that's the same group it's under in GCC. Fixes llvm#41104
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
c++
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I put this under -Wunitialized because that's the same group it's under in GCC.
Fixes #41104