Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issues 23130, 19528 : Inline asm was too liberal about operand si… #14152

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/dmd/iasmdmd.d
Expand Up @@ -1206,7 +1206,7 @@ opflag_t asm_determine_operand_flags(ref OPND popnd)
else
{
auto ptype = (ds && ds.storage_class & (STC.out_ | STC.ref_)) ? popnd.ptype.pointerTo() : popnd.ptype;
sz = asm_type_size(ptype, popnd.bPtr);
sz = asm_type_size(ptype);
}

if (popnd.bRIP)
Expand Down Expand Up @@ -3443,11 +3443,11 @@ void asm_token_trans(Token *tok)
/*******************************
*/

OpndSize asm_type_size(Type ptype, bool bPtr)
OpndSize asm_type_size(Type ptype)
{
OpndSize u;

//if (ptype) printf("asm_type_size('%s') = %d\n", ptype.toChars(), (int)ptype.size());
//if (ptype) printf("asm_type_size('%s') = %d\n", ptype.toChars(), cast(int)ptype.size());
u = OpndSize._anysize;
if (ptype && ptype.ty != Tfunction /*&& ptype.isscalar()*/)
{
Expand All @@ -3459,8 +3459,8 @@ OpndSize asm_type_size(Type ptype, bool bPtr)
case 4: u = OpndSize._32; break;
case 6: u = OpndSize._48; break;

case 8: if (target.is64bit || bPtr)
u = OpndSize._64;
case 8:
u = OpndSize._64;
break;

case 16: u = OpndSize._128; break;
Expand Down
18 changes: 18 additions & 0 deletions test/fail_compilation/failasm.d
Expand Up @@ -21,3 +21,21 @@ uint func()
inc long ptr [EAX];
}
}

#line 200

/* TEST_OUTPUT:
---
fail_compilation/failasm.d(213): Error: bad type/size of operands `mov`
---
*/

void foo()
{
long i = void;
static assert(long.sizeof == 8);
asm
{
mov i, EAX;
}
}
18 changes: 18 additions & 0 deletions test/fail_compilation/iasm1.d
Expand Up @@ -142,3 +142,21 @@ void test6()
}
L1:;
}

#line 700

/* TEST_OUTPUT:
---
fail_compilation/iasm1.d(713): Error: bad type/size of operands `mov`
---
*/

void foo()
maxhaton marked this conversation as resolved.
Show resolved Hide resolved
{
long i = void;
static assert(long.sizeof == 8);
asm
{
mov i, EAX;
}
}