From 0cd78dd579312f72fb666e6fa2ed78e795ba0914 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 20 Dec 2012 00:23:44 +0100 Subject: [PATCH] Cleanup: Clang warning fixes. No warnings left on a '-Wall' build except for a single tautological compare in gen/asm-x86-32.h, which indeed seems like a bug. --- dmd/mars.h | 3 ++- dmd2/mars.h | 5 +++++ dmd2/root/stringtable.h | 2 ++ gen/asm-x86-32.h | 7 ++++--- gen/asm-x86-64.h | 12 +++++++----- gen/asmstmt.cpp | 2 ++ gen/llvmhelpers.cpp | 6 +++--- gen/module.cpp | 2 +- gen/nested.cpp | 1 - gen/runtime.cpp | 23 ++++------------------- gen/tollvm.cpp | 2 +- gen/typinf.cpp | 4 ++-- ir/irfuncty.h | 2 +- 13 files changed, 34 insertions(+), 37 deletions(-) diff --git a/dmd/mars.h b/dmd/mars.h index 685b6f6e..ae92eaeb 100644 --- a/dmd/mars.h +++ b/dmd/mars.h @@ -515,7 +515,8 @@ void errorSupplemental(Loc loc, const char *format, ...); void verror(Loc loc, const char *format, va_list ap, const char *p1 = NULL, const char *p2 = NULL); void vwarning(Loc loc, const char *format, va_list); void verrorSupplemental(Loc loc, const char *format, va_list); -#ifdef __GNUC__ + +#if defined(__GNUC__) || defined(__clang__) __attribute__((noreturn)) #endif void fatal(); diff --git a/dmd2/mars.h b/dmd2/mars.h index a158e192..baa7c437 100644 --- a/dmd2/mars.h +++ b/dmd2/mars.h @@ -514,7 +514,12 @@ void errorSupplemental(Loc loc, const char *format, ...); void verror(Loc loc, const char *format, va_list ap, const char *p1 = NULL, const char *p2 = NULL); void vwarning(Loc loc, const char *format, va_list); void verrorSupplemental(Loc loc, const char *format, va_list); + +#if defined(__GNUC__) || defined(__clang__) +__attribute__((noreturn)) +#endif void fatal(); + void err_nomem(); #if IN_LLVM void error(const char *format, ...) IS_PRINTF(1); diff --git a/dmd2/root/stringtable.h b/dmd2/root/stringtable.h index 170894e6..403a98b8 100644 --- a/dmd2/root/stringtable.h +++ b/dmd2/root/stringtable.h @@ -33,8 +33,10 @@ private: unsigned length; #ifndef IN_GCC +#if _MSC_VER // Disable warning about nonstandard extension #pragma warning (disable : 4200) +#endif #endif char lstring[]; diff --git a/gen/asm-x86-32.h b/gen/asm-x86-32.h index 4c1b66f0..d2724a37 100644 --- a/gen/asm-x86-32.h +++ b/gen/asm-x86-32.h @@ -2973,11 +2973,11 @@ namespace AsmParserx8632 void doData() { + // FIXME: data instructions not implemented. +#if 0 static const char * directives[] = { ".byte", ".short", ".long", ".long", "", "", "" }; -// FIXME - /* machine_mode mode; insnTemplate->writestring(static_cast(directives[op - Op_db])); @@ -3048,7 +3048,8 @@ namespace AsmParserx8632 } } while (1); - setAsmCode();*/ + setAsmCode(); +#endif } }; diff --git a/gen/asm-x86-64.h b/gen/asm-x86-64.h index 4cf3d1e4..671631d3 100644 --- a/gen/asm-x86-64.h +++ b/gen/asm-x86-64.h @@ -420,9 +420,9 @@ namespace AsmParserx8664 typedef struct { Opr operands[3]; - unsigned char + unsigned short needsType : 3, - implicitClobbers : 8, + implicitClobbers : 9, linkType : 2; unsigned link; @@ -3111,11 +3111,12 @@ namespace AsmParserx8664 void doData() { + // FIXME: data instructions not implemented. +#if 0 static const char * directives[] = { ".byte", ".short", ".long", ".long", "", "", "" }; -// FIXME - /* + machine_mode mode; insnTemplate->writestring(static_cast(directives[op - Op_db])); @@ -3186,7 +3187,8 @@ namespace AsmParserx8664 } } while (1); - setAsmCode();*/ + setAsmCode(); +#endif } }; diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 957e8b63..94882caa 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -178,10 +178,12 @@ Statement *AsmStatement::semantic(Scope *sc) return this; if (!asmparser) + { if (global.params.cpu == ARCHx86) asmparser = new AsmParserx8632::AsmParser; else if (global.params.cpu == ARCHx86_64) asmparser = new AsmParserx8664::AsmParser; + } asmparser->run(sc, this); diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 16cc4ce7..a20c6dd5 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -1252,7 +1252,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration) } } // template - else if (TemplateDeclaration* t = declaration->isTemplateDeclaration()) + else if (declaration->isTemplateDeclaration()) { Logger::println("TemplateDeclaration"); // do nothing @@ -1437,7 +1437,7 @@ DValue* DtoInitializer(LLValue* target, Initializer* init) assert(ex->exp); return ex->exp->toElem(gIR); } - else if (ArrayInitializer* ai = init->isArrayInitializer()) + else if (init->isArrayInitializer()) { // TODO: do nothing ? } @@ -1445,7 +1445,7 @@ DValue* DtoInitializer(LLValue* target, Initializer* init) { // do nothing } - else if (StructInitializer *si = init->isStructInitializer()) { + else if (init->isStructInitializer()) { // TODO: again nothing ? } else { diff --git a/gen/module.cpp b/gen/module.cpp index 6a57a3b6..17bac5e5 100644 --- a/gen/module.cpp +++ b/gen/module.cpp @@ -197,7 +197,7 @@ static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo) IRBuilder<> builder(bb); // debug info - llvm::DISubprogram subprog = DtoDwarfSubProgramInternal(fname.c_str(), fname.c_str()); + DtoDwarfSubProgramInternal(fname.c_str(), fname.c_str()); // get current beginning LLValue* curbeg = builder.CreateLoad(mref, "current"); diff --git a/gen/nested.cpp b/gen/nested.cpp index 796ef985..48962c64 100644 --- a/gen/nested.cpp +++ b/gen/nested.cpp @@ -96,7 +96,6 @@ DValue* DtoNestedVariable(Loc loc, Type* astype, VarDeclaration* vd, bool byref) LLValue *dwarfValue = 0; std::vector dwarfAddr; - LLType *int64Ty = LLType::getInt64Ty(gIR->context()); // get the nested context LLValue* ctx = 0; diff --git a/gen/runtime.cpp b/gen/runtime.cpp index 069f87fe..0c77cf32 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -170,14 +170,6 @@ static LLType* rt_dg2() return LLStructType::get(gIR->context(), types); } -static LLType* rt_complex(LLType* type) -{ - llvm::SmallVector types; - types.push_back(type); - types.push_back(type); - return llvm::StructType::get(gIR->context(), types); -} - static void LLVM_D_BuildRuntimeModule() { Logger::println("building module"); @@ -187,24 +179,17 @@ static void LLVM_D_BuildRuntimeModule() LLType* voidTy = LLType::getVoidTy(gIR->context()); LLType* boolTy = LLType::getInt1Ty(gIR->context()); LLType* byteTy = LLType::getInt8Ty(gIR->context()); - LLType* shortTy = LLType::getInt16Ty(gIR->context()); LLType* intTy = LLType::getInt32Ty(gIR->context()); LLType* longTy = LLType::getInt64Ty(gIR->context()); LLType* sizeTy = DtoSize_t(); Logger::println("building float types"); - LLType* floatTy = LLType::getFloatTy(gIR->context()); - LLType* doubleTy = LLType::getDoubleTy(gIR->context()); LLType* realTy; if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64)) realTy = LLType::getX86_FP80Ty(gIR->context()); else realTy = LLType::getDoubleTy(gIR->context()); - LLType* cfloatTy = rt_complex(floatTy); - LLType* cdoubleTy = rt_complex(doubleTy); - LLType* crealTy = rt_complex(realTy); - Logger::println("building aggr types"); LLType* voidPtrTy = rt_ptr(byteTy); LLType* voidArrayTy = rt_array(byteTy); @@ -247,8 +232,6 @@ static void LLVM_D_BuildRuntimeModule() = Attr_ReadOnly.addAttr(gIR->context(), 1, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), Attr_ReadOnly_1_3_NoCapture = Attr_ReadOnly_1_NoCapture.addAttr(gIR->context(), 3, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), - Attr_ReadOnly_1_4_NoCapture - = Attr_ReadOnly_1_NoCapture.addAttr(gIR->context(), 4, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), Attr_ReadOnly_NoUnwind_1_NoCapture = Attr_ReadOnly_1_NoCapture.addAttr(gIR->context(), ~0U, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoUnwind))), Attr_ReadNone @@ -257,8 +240,10 @@ static void LLVM_D_BuildRuntimeModule() = NoAttrs.addAttr(gIR->context(), 1, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), Attr_NoAlias_1_NoCapture = Attr_1_NoCapture.addAttr(gIR->context(), 0, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoAlias))), +#if DMDV1 Attr_NoAlias_3_NoCapture = Attr_NoAlias.addAttr(gIR->context(), 3, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), +#endif Attr_1_2_NoCapture = Attr_1_NoCapture.addAttr(gIR->context(), 2, llvm::Attributes::get(gIR->context(), llvm::AttrBuilder().addAttribute(llvm::Attributes::NoCapture))), Attr_1_3_NoCapture @@ -280,8 +265,6 @@ static void LLVM_D_BuildRuntimeModule() = Attr_ReadOnly.addAttr(1, NoCapture), Attr_ReadOnly_1_3_NoCapture = Attr_ReadOnly_1_NoCapture.addAttr(3, NoCapture), - Attr_ReadOnly_1_4_NoCapture - = Attr_ReadOnly_1_NoCapture.addAttr(4, NoCapture), Attr_ReadOnly_NoUnwind_1_NoCapture = Attr_ReadOnly_1_NoCapture.addAttr(~0U, NoUnwind), Attr_ReadNone @@ -290,8 +273,10 @@ static void LLVM_D_BuildRuntimeModule() = NoAttrs.addAttr(1, NoCapture), Attr_NoAlias_1_NoCapture = Attr_1_NoCapture.addAttr(0, NoAlias), +#if DMDV1 Attr_NoAlias_3_NoCapture = Attr_NoAlias.addAttr(3, NoCapture), +#endif Attr_1_2_NoCapture = Attr_1_NoCapture.addAttr(2, NoCapture), Attr_1_3_NoCapture diff --git a/gen/tollvm.cpp b/gen/tollvm.cpp index a3e9139a..ca4392ce 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -732,7 +732,7 @@ void DtoStore(LLValue* src, LLValue* dst) { // if (Logger::enabled()) // Logger::cout() << "storing " << *src << " into " << *dst << '\n'; - LLValue* st = gIR->ir->CreateStore(src,dst); + gIR->ir->CreateStore(src,dst); //st->setVolatile(gIR->func()->inVolatile); } diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 02c375e3..748039d2 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -271,9 +271,9 @@ int TypeBasic::builtinTypeInfo() int TypeDArray::builtinTypeInfo() { #if DMDV2 - return !mod && (next->isTypeBasic() != NULL && !next->mod || + return !mod && ((next->isTypeBasic() != NULL && !next->mod) || // strings are so common, make them builtin - next->ty == Tchar && next->mod == MODimmutable); + (next->ty == Tchar && next->mod == MODimmutable)); #else return next->isTypeBasic() != NULL; #endif diff --git a/ir/irfuncty.h b/ir/irfuncty.h index 1ce0a0b8..43c78453 100644 --- a/ir/irfuncty.h +++ b/ir/irfuncty.h @@ -101,12 +101,12 @@ struct IrFuncTy : IrBase IrFuncTy() : ret(NULL), - args(), arg_sret(NULL), arg_this(NULL), arg_nest(NULL), arg_arguments(NULL), arg_argptr(NULL), + args(), c_vararg(false), reverseParams(false) {}