From f8b997e59867e19d06401f8c92718dd11a908987 Mon Sep 17 00:00:00 2001 From: Carlo Bertolli Date: Tue, 2 Jun 2015 16:35:41 -0400 Subject: Fix some warnings by either adding virtual destructors or deleting virtual specifier on non-re-implemented methods; re-order constructor initialization of instance variables. Add handling of nested do-loops with same target label by processing all nested do statements after the innermost one. Fix issue #15. --- include/flang/AST/ASTContext.h | 4 +--- include/flang/AST/Expr.h | 21 +++++++++++++++++++-- lib/CodeGen/ABIInfo.h | 1 + lib/CodeGen/CGABI.h | 3 +++ lib/CodeGen/CGValue.h | 8 ++++---- lib/CodeGen/CodeGenTypes.cpp | 2 ++ lib/CodeGen/ModuleBuilder.cpp | 5 ++--- lib/Sema/Sema.cpp | 17 +++++++++++++++++ 8 files changed, 49 insertions(+), 12 deletions(-) diff --git a/include/flang/AST/ASTContext.h b/include/flang/AST/ASTContext.h index 61033575aa..cff497ca2b 100644 --- a/include/flang/AST/ASTContext.h +++ b/include/flang/AST/ASTContext.h @@ -88,9 +88,7 @@ public: BumpAlloc.Deallocate((const void*) Ptr, size); } - LangOptions getLangOpts() const { - return LanguageOptions; - } + const LangOptions& getLangOpts() const { return LanguageOptions; } // Builtin Types: [R404] QualType VoidTy; diff --git a/include/flang/AST/Expr.h b/include/flang/AST/Expr.h index fd1650b00d..4b6c5314de 100644 --- a/include/flang/AST/Expr.h +++ b/include/flang/AST/Expr.h @@ -58,6 +58,7 @@ protected: Expr(ExprClass ET, QualType T, SourceLocation L) : ExprID(ET), Loc(L) { setType(T); } + //virtual ~Expr() {} public: QualType getType() const { return Ty; } @@ -66,8 +67,8 @@ public: ExprClass getExprClass() const { return ExprID; } SourceLocation getLocation() const { return Loc; } - virtual SourceLocation getLocStart() const { return Loc; } - virtual SourceLocation getLocEnd() const { return Loc; } + SourceLocation getLocStart() const { return Loc; } + SourceLocation getLocEnd() const { return Loc; } inline SourceRange getSourceRange() const { return SourceRange(getLocStart(), getLocEnd()); @@ -121,6 +122,8 @@ class ConstantExpr : public Expr { protected: ConstantExpr(ExprClass Ty, QualType T, SourceLocation Loc, SourceLocation MLoc) : Expr(Ty, T, Loc), Kind(0), MaxLoc(MLoc) {} + virtual ~ConstantExpr() {} + public: Expr *getKindSelector() const { return Kind; } void setKindSelector(Expr *K) { Kind = K; } @@ -205,6 +208,8 @@ class IntegerConstantExpr : public ConstantExpr { IntegerConstantExpr(ASTContext &C, SourceRange Range, StringRef Data); IntegerConstantExpr(ASTContext &C, SourceRange Range, APInt Value); + virtual ~IntegerConstantExpr() {} + public: static IntegerConstantExpr *Create(ASTContext &C, SourceRange Range, StringRef Data); @@ -227,6 +232,8 @@ private: APFloatStorage Num; RealConstantExpr(ASTContext &C, SourceRange Range, llvm::StringRef Data, QualType Type); + virtual ~RealConstantExpr() {} + public: static RealConstantExpr *Create(ASTContext &C, SourceRange Range, llvm::StringRef Data, @@ -245,6 +252,8 @@ private: Expr *Re, *Im; ComplexConstantExpr(ASTContext &C, SourceRange Range, Expr *Real, Expr *Imaginary, QualType Type); + virtual ~ComplexConstantExpr() {} + public: static ComplexConstantExpr *Create(ASTContext &C, SourceRange Range, Expr *Real, Expr *Imaginary, @@ -265,6 +274,7 @@ class CharacterConstantExpr : public ConstantExpr { CharacterConstantExpr(char *Str, SourceRange Range, QualType T); CharacterConstantExpr(ASTContext &C, SourceRange Range, StringRef Data, QualType T); + virtual ~CharacterConstantExpr() {} public: static CharacterConstantExpr *Create(ASTContext &C, SourceRange Range, StringRef Data, QualType T); @@ -294,6 +304,8 @@ private: BOZKind Kind; BOZConstantExpr(ASTContext &C, SourceLocation Loc, SourceLocation MaxLoc, llvm::StringRef Data); + virtual ~BOZConstantExpr() {} + public: static BOZConstantExpr *Create(ASTContext &C, SourceLocation Loc, SourceLocation MaxLoc, llvm::StringRef Data); @@ -317,6 +329,8 @@ class LogicalConstantExpr : public ConstantExpr { LogicalConstantExpr(ASTContext &C, SourceRange Range, llvm::StringRef Data, QualType T); + virtual ~LogicalConstantExpr() {} + public: static LogicalConstantExpr *Create(ASTContext &C, SourceRange Range, llvm::StringRef Data, QualType T); @@ -560,6 +574,8 @@ private: const ArraySpec &operator=(const ArraySpec&); protected: ArraySpec(ArraySpecKind K); + virtual ~ArraySpec() {} + public: ArraySpecKind getKind() const { return Kind; } @@ -586,6 +602,7 @@ class ExplicitShapeSpec : public ArraySpec { ExplicitShapeSpec(Expr *LB, Expr *UB); ExplicitShapeSpec(Expr *UB); + public: static ExplicitShapeSpec *Create(ASTContext &C, Expr *UB); static ExplicitShapeSpec *Create(ASTContext &C, Expr *LB, diff --git a/lib/CodeGen/ABIInfo.h b/lib/CodeGen/ABIInfo.h index 259b6142bf..76aeec0f04 100644 --- a/lib/CodeGen/ABIInfo.h +++ b/lib/CodeGen/ABIInfo.h @@ -110,6 +110,7 @@ public: /// passed or returned from functions. class ABIInfo { public: + virtual ~ABIInfo() {} virtual void computeReturnTypeInfo(QualType T, ABIRetInfo &Info) const = 0; }; diff --git a/lib/CodeGen/CGABI.h b/lib/CodeGen/CGABI.h index ea5e7b7d40..81fe852ec2 100644 --- a/lib/CodeGen/CGABI.h +++ b/lib/CodeGen/CGABI.h @@ -17,18 +17,21 @@ namespace CodeGen { class FortranABI { public: + virtual ~FortranABI() {} virtual ABIArgInfo GetArgABI(QualType ArgType); virtual ABIRetInfo GetRetABI(QualType RetType); }; class LibflangABI : public FortranABI { public: + virtual ~LibflangABI() {} ABIArgInfo GetArgABI(QualType ArgType); ABIRetInfo GetRetABI(QualType RetType); }; class LibflangTransferABI : public LibflangABI { public: + virtual ~LibflangTransferABI() {} ABIArgInfo GetArgABI(QualType ArgType); }; diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h index f995ecb89e..f937dbf435 100644 --- a/lib/CodeGen/CGValue.h +++ b/lib/CodeGen/CGValue.h @@ -138,16 +138,16 @@ private: llvm::Value *V2; RValueTy(llvm::Value *V, Kind Type) - : V1(V), ValueType(Type) {} + : ValueType(Type), V1(V) {} public: RValueTy() : ValueType(None) {} RValueTy(llvm::Value *V) - : V1(V), ValueType(Scalar) {} + : ValueType(Scalar), V1(V) {} RValueTy(ComplexValueTy C) - : V1(C.Re), V2(C.Im), ValueType(Complex) {} + : ValueType(Complex), V1(C.Re), V2(C.Im) {} RValueTy(CharacterValueTy CharValue) - : V1(CharValue.Ptr), V2(CharValue.Len), ValueType(Character) {} + : ValueType(Character), V1(CharValue.Ptr), V2(CharValue.Len) {} Kind getType() const { return ValueType; diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index e19b7edc7e..e3c0121c1c 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -67,6 +67,8 @@ llvm::Type *CodeGenTypes::ConvertBuiltInType(BuiltinType::TypeSpec Spec, BuiltinType::TypeKind Kind) { llvm::Type *Type; switch(Kind) { + default: + break; case BuiltinType::Int1: return CGM.Int8Ty; case BuiltinType::Int2: diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp index ba87058e91..f70c56aea8 100644 --- a/lib/CodeGen/ModuleBuilder.cpp +++ b/lib/CodeGen/ModuleBuilder.cpp @@ -42,9 +42,8 @@ namespace { const CodeGenOptions &CGO, const TargetOptions &TO, llvm::LLVMContext& C) - : Diags(diags), CodeGenOpts(CGO), - M(new llvm::Module(ModuleName, C)), - Target(TO) {} + : Diags(diags), CodeGenOpts(CGO), Target(TO), + M(new llvm::Module(ModuleName, C)) {} virtual ~CodeGeneratorImpl() {} diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 388822da8d..f36312ede0 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -235,6 +235,23 @@ void Sema::DeclareStatementLabel(Expr *StmtLabel, Stmt *S) { getCurrentStmtLabelScope()->Declare(StmtLabel, S); /// Check to see if it matches the last do stmt. CheckStatementLabelEndDo(StmtLabel, S); + + // Check to see if it matches any other enclosing do stmt and possibly + // replicate the body (nested loops with same label) + DoStmt *Result = nullptr; + auto Stack = getCurrentBody()->ControlFlowStack; + for(size_t I = Stack.size(); I != 0;) { + --I; + if(auto Do = dyn_cast(Stack[I].Statement)) { + if(Stack[I].hasExpectedDoLabel()) { + if(getCurrentStmtLabelScope()->IsSame(Stack[I].ExpectedEndDoLabel, StmtLabel)) { + RemoveLoopVar(Do->getDoVar()); + // leave the last statement + getCurrentBody()->Leave(Context); + } + } + } + } } } -- cgit v1.2.1