Skip to content

Commit

Permalink
Explicitly initialize StreamingDiagnostic in derived class copy ctors
Browse files Browse the repository at this point in the history
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) {
   ^
  • Loading branch information
zmodem committed Oct 20, 2020
1 parent 03a5f7c commit c76cdea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Diagnostic.h
Expand Up @@ -1284,7 +1284,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
public:
/// Copy constructor. When copied, this "takes" the diagnostic info from the
/// input and neuters it.
DiagnosticBuilder(const DiagnosticBuilder &D) {
DiagnosticBuilder(const DiagnosticBuilder &D) : StreamingDiagnostic() {
DiagObj = D.DiagObj;
DiagStorage = D.DiagStorage;
IsActive = D.IsActive;
Expand Down
3 changes: 2 additions & 1 deletion clang/include/clang/Basic/PartialDiagnostic.h
Expand Up @@ -49,7 +49,8 @@ class PartialDiagnostic : public StreamingDiagnostic {
PartialDiagnostic(unsigned DiagID, DiagStorageAllocator &Allocator_)
: StreamingDiagnostic(Allocator_), DiagID(DiagID) {}

PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) {
PartialDiagnostic(const PartialDiagnostic &Other)
: StreamingDiagnostic(), DiagID(Other.DiagID) {
Allocator = Other.Allocator;
if (Other.DiagStorage) {
DiagStorage = getStorage();
Expand Down

0 comments on commit c76cdea

Please sign in to comment.