Skip to content

Commit

Permalink
Merge pull request #4239 from schveiguy/removeclangwarnings
Browse files Browse the repository at this point in the history
Fix warnings on clang++
  • Loading branch information
yebblies committed Jan 5, 2015
2 parents e5490e9 + 930795e commit f5682e8
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/backend/cod1.c
Expand Up @@ -2844,22 +2844,26 @@ code *cdfunc(elem *e,regm_t *pretregs)
if (v ^ (preg != mreg))
{
if (preg != lreg)
{
if (mask[preg] & XMMREGS)
{ unsigned op = xmmload(ty1); // MOVSS/D preg,lreg
c1 = gen2(c1,op,modregxrmx(3,preg-XMM0,lreg-XMM0));
}
else
c1 = genmovreg(c1, preg, lreg);
}
}
else
{
if (preg2 != mreg)
{
if (mask[preg2] & XMMREGS)
{ unsigned op = xmmload(ty2); // MOVSS/D preg2,mreg
c1 = gen2(c1,op,modregxrmx(3,preg2-XMM0,mreg-XMM0));
}
else
c1 = genmovreg(c1, preg2, mreg);
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/backend/cod3.c
Expand Up @@ -796,8 +796,8 @@ void outblkexitcode(block *bl, code*& c, int& anyspill, const char* sflsave, sym
#endif
case BCgoto:
nextb = list_block(bl->Bsucc);
if ((funcsym_p->Sfunc->Fflags3 & Fnteh ||
(MARS /*&& config.flags2 & CFG2seh*/)) &&
if (((MARS /*&& config.flags2 & CFG2seh*/) ||
funcsym_p->Sfunc->Fflags3 & Fnteh) &&
bl->Btry != nextb->Btry &&
nextb->BC != BC_finally)
{ int toindex;
Expand Down Expand Up @@ -1367,7 +1367,7 @@ void doswitch(block *b)
if (I32 && config.flags3 & CFG3pic)
retregs &= ~mBX; // need EBX for GOT
#endif
bool modify = (vmin || I16 || I64);
bool modify = (I16 || I64 || vmin);
c = scodelem(e,&retregs,0,!modify);
unsigned reg = findreg(retregs & IDXREGS); // reg that result is in
unsigned reg2;
Expand Down Expand Up @@ -4068,7 +4068,7 @@ void cod3_thunk(symbol *sthunk,symbol *sfunc,unsigned p,tym_t thisty,
if (config.wflags & WFssneds ||
// If DS needs reloading from SS,
// then assume SS != DS on thunk entry
(config.wflags & WFss && LARGEDATA))
(LARGEDATA && config.wflags & WFss))
c1->Iflags |= CFss; /* SS: */
c = cat(c,c1);
}
Expand Down Expand Up @@ -4120,7 +4120,7 @@ void cod3_thunk(symbol *sthunk,symbol *sfunc,unsigned p,tym_t thisty,
if (config.wflags & WFssneds ||
// If DS needs reloading from SS,
// then assume SS != DS on thunk entry
(config.wflags & WFss && LARGEDATA))
(LARGEDATA && config.wflags & WFss))
c1->Iflags |= CFss; /* SS: */

/* MOV/LES BX,[ES:]d2[BX] */
Expand Down Expand Up @@ -5397,7 +5397,7 @@ void simplify_code(code* c)
(c->Iop == 0x81 || c->Iop == 0x80) &&
c->IFL2 == FLconst &&
reghasvalue((c->Iop == 0x80) ? BYTEREGS : ALLREGS,I64 ? c->IEV2.Vsize_t : c->IEV2.Vlong,&reg) &&
!(c->Iflags & CFopsize && I16)
!(I16 && c->Iflags & CFopsize)
)
{
// See if we can replace immediate instruction with register instruction
Expand Down
2 changes: 1 addition & 1 deletion src/backend/nteh.c
Expand Up @@ -344,7 +344,7 @@ code *nteh_prolog()
cs.IEV2.Vint = -1;
c1 = gen(CNIL,&cs); // PUSH -1

if ((usednteh & NTEHcpp) || MARS)
if (MARS || (usednteh & NTEHcpp))
{
// PUSH &framehandler
cs.IFL2 = FLframehandler;
Expand Down
4 changes: 2 additions & 2 deletions src/cppmangle.c
Expand Up @@ -163,7 +163,7 @@ class CppMangleVisitor : public Visitor
}
else
{
dinteger_t val = e->toInteger();
sinteger_t val = e->toInteger();
if (val < 0)
{
val = -val;
Expand Down Expand Up @@ -1479,7 +1479,7 @@ class VisualCPPMangler : public Visitor
}
else
{
dinteger_t val = e->toInteger();
sinteger_t val = e->toInteger();
if (val < 0)
{
val = -val;
Expand Down
2 changes: 1 addition & 1 deletion src/func.c
Expand Up @@ -2321,7 +2321,7 @@ void FuncDeclaration::buildResultVar(Scope *sc, Type *tret)
{
if (!vresult)
{
Loc loc = fensure ? fensure->loc : loc;
Loc loc = fensure ? fensure->loc : this->loc;

/* If inferRetType is true, tret may not be a correct return type yet.
* So, in here it may be a temporary type for vresult, and after
Expand Down
6 changes: 2 additions & 4 deletions src/parse.c
Expand Up @@ -5027,8 +5027,7 @@ Statement *Parser::parseStatement(int flags, const utf8_t** endPtr, Loc *pEndloc
error("debug conditions can only be declared at module scope");
nextToken();
nextToken();
check(TOKsemicolon);
break;
goto Lerror;
}
cond = parseDebugCondition();
goto Lcondition;
Expand All @@ -5040,8 +5039,7 @@ Statement *Parser::parseStatement(int flags, const utf8_t** endPtr, Loc *pEndloc
error("version conditions can only be declared at module scope");
nextToken();
nextToken();
check(TOKsemicolon);
break;
goto Lerror;
}
cond = parseVersionCondition();
goto Lcondition;
Expand Down
6 changes: 6 additions & 0 deletions src/posix.mak
Expand Up @@ -83,6 +83,12 @@ endif
else
# Default Warnings
WARNINGS := -Wno-deprecated -Wstrict-aliasing
ifeq ($(HOST_CC), clang++)
WARNINGS := $(WARNINGS) \
-Wno-logical-op-parentheses \
-Wno-dynamic-class-memaccess \
-Wno-switch
endif
endif

OS_UPCASE := $(shell echo $(OS) | tr '[a-z]' '[A-Z]')
Expand Down
2 changes: 1 addition & 1 deletion src/root/filename.c
Expand Up @@ -660,7 +660,7 @@ const char *FileName::canonicalName(const char *name)
void FileName::free(const char *str)
{
if (str)
{ assert(str[0] != 0xAB);
{ assert(str[0] != (char)0xAB);
memset((void *)str, 0xAB, strlen(str) + 1); // stomp
}
mem.free((void *)str);
Expand Down
22 changes: 22 additions & 0 deletions test/runnable/cppa.d
Expand Up @@ -5,6 +5,14 @@ import core.stdc.stdio;
import core.stdc.stdarg;
import core.stdc.config;

// BUG: fix for 13932 doesn't work on Win32 for some reason. Therefore
// it is disabled on Windows 32-bit, but enabled on all other platforms.
version(Win32) {}
else
{
version = doTest13932;
}

extern (C++)
int foob(int i, int j, int k);

Expand Down Expand Up @@ -631,6 +639,18 @@ void test13707()

/****************************************/

version(doTest13932)
{
struct S13932(int x)
{
int member;
}

extern(C++) void func13932(S13932!(-1) s);
}

/****************************************/

void main()
{
test1();
Expand All @@ -654,6 +674,8 @@ void main()
test15();
test16();
func13707();
version(doTest13932)
func13932(S13932!(-1)(0));

printf("Success\n");
}
8 changes: 8 additions & 0 deletions test/runnable/extra-files/cppb.cpp
Expand Up @@ -392,3 +392,11 @@ S13707 func13707()

/******************************************/

template <int x> struct S13932
{
int member;
};

void func13932(S13932<-1> s) {}

/******************************************/

0 comments on commit f5682e8

Please sign in to comment.