Skip to content

Commit c76cdea

Browse files
committed
Explicitly initialize StreamingDiagnostic in derived class copy ctors
To pacify a GCC warning: [1/1] Building CXX object tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/Dominators.cpp.o In file included from /work/llvm.monorepo/clang/include/clang/AST/NestedNameSpecifier.h:18:0, from /work/llvm.monorepo/clang/include/clang/AST/Type.h:21, from /work/llvm.monorepo/clang/include/clang/AST/DeclarationName.h:16, from /work/llvm.monorepo/clang/include/clang/AST/DeclBase.h:18, from /work/llvm.monorepo/clang/include/clang/Analysis/AnalysisDeclContext.h:20, from /work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:16, from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9: /work/llvm.monorepo/clang/include/clang/Basic/Diagnostic.h: In copy constructor ‘clang::DiagnosticBuilder::DiagnosticBuilder(const clang::DiagnosticBuilder&)’: /work/llvm.monorepo/clang/include/clang/Basic/Diagnostic.h:1287:3: warning: base class ‘class clang::StreamingDiagnostic’ should be explicitly initialized in the copy constructor [-Wextra] DiagnosticBuilder(const DiagnosticBuilder &D) { ^ In file included from /work/llvm.monorepo/clang/include/clang/AST/Type.h:29:0, from /work/llvm.monorepo/clang/include/clang/AST/DeclarationName.h:16, from /work/llvm.monorepo/clang/include/clang/AST/DeclBase.h:18, from /work/llvm.monorepo/clang/include/clang/Analysis/AnalysisDeclContext.h:20, from /work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:16, from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9: /work/llvm.monorepo/clang/include/clang/Basic/PartialDiagnostic.h: In copy constructor ‘clang::PartialDiagnostic::PartialDiagnostic(const clang::PartialDiagnostic&)’: /work/llvm.monorepo/clang/include/clang/Basic/PartialDiagnostic.h:52:3: warning: base class ‘class clang::StreamingDiagnostic’ should be explicitly initialized in the copy constructor [-Wextra] PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) { ^
1 parent 03a5f7c commit c76cdea

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/include/clang/Basic/Diagnostic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
12841284
public:
12851285
/// Copy constructor. When copied, this "takes" the diagnostic info from the
12861286
/// input and neuters it.
1287-
DiagnosticBuilder(const DiagnosticBuilder &D) {
1287+
DiagnosticBuilder(const DiagnosticBuilder &D) : StreamingDiagnostic() {
12881288
DiagObj = D.DiagObj;
12891289
DiagStorage = D.DiagStorage;
12901290
IsActive = D.IsActive;

clang/include/clang/Basic/PartialDiagnostic.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class PartialDiagnostic : public StreamingDiagnostic {
4949
PartialDiagnostic(unsigned DiagID, DiagStorageAllocator &Allocator_)
5050
: StreamingDiagnostic(Allocator_), DiagID(DiagID) {}
5151

52-
PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) {
52+
PartialDiagnostic(const PartialDiagnostic &Other)
53+
: StreamingDiagnostic(), DiagID(Other.DiagID) {
5354
Allocator = Other.Allocator;
5455
if (Other.DiagStorage) {
5556
DiagStorage = getStorage();

0 commit comments

Comments
 (0)