[clang] db4c7ad - Suppress false-positive -Wuninitialized warnings in the constructor of a
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 11 14:26:37 PST 2019
Author: Richard Smith
Date: 2019-12-11T14:26:28-08:00
New Revision: db4c7adfa365282e8cb9a067c509fa711c4b96fe
URL: https://github.com/llvm/llvm-project/commit/db4c7adfa365282e8cb9a067c509fa711c4b96fe
DIFF: https://github.com/llvm/llvm-project/commit/db4c7adfa365282e8cb9a067c509fa711c4b96fe.diff
LOG: Suppress false-positive -Wuninitialized warnings in the constructor of a
templated but non-template class.
Added:
Modified:
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/uninitialized.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 5373bb422ad6..ba4d450984a3 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -3807,7 +3807,7 @@ namespace {
const CXXRecordDecl *RD = Constructor->getParent();
- if (RD->getDescribedClassTemplate())
+ if (RD->isDependentContext())
return;
// Holds fields that are uninitialized.
diff --git a/clang/test/SemaCXX/uninitialized.cpp b/clang/test/SemaCXX/uninitialized.cpp
index 331a948eb6f1..63d5e7b92eac 100644
--- a/clang/test/SemaCXX/uninitialized.cpp
+++ b/clang/test/SemaCXX/uninitialized.cpp
@@ -1449,3 +1449,12 @@ void if_switch_init_stmt(int k) {
switch (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}} expected-warning {{boolean}}
}
+
+template<typename T> struct Outer {
+ struct Inner {
+ int a = 1;
+ int b;
+ Inner() : b(a) {}
+ };
+};
+Outer<int>::Inner outerinner;
More information about the cfe-commits
mailing list