-
-
Notifications
You must be signed in to change notification settings - Fork 652
fix Issue 24130 - ImportC: Windows headers use inline asm with differ… #15595
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -780,7 +780,9 @@ extern (C++) final class Module : Package | |
{ | ||
filetype = FileType.c; | ||
|
||
global.compileEnv.masm = target.os == Target.OS.Windows && !target.omfobj; // Microsoft inline assembler format | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... platform-specific global variables that gdc (and ldc?) don't define or set. |
||
scope p = new CParser!AST(this, buf, cast(bool) docfile, global.errorSink, target.c, &defines, &global.compileEnv); | ||
global.compileEnv.masm = false; | ||
p.nextToken(); | ||
checkCompiledImport(); | ||
members = p.parseModule(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6601,7 +6601,7 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer | |
} | ||
|
||
case TOK.asm_: | ||
s = parseAsm(); | ||
s = parseAsm(false); | ||
break; | ||
|
||
case TOK.import_: | ||
|
@@ -6972,10 +6972,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer | |
* AsmInstruction ; | ||
* AsmInstruction ; AsmInstruction | ||
* | ||
* Params: | ||
* endOfLine = true if EOL means end of asm statement | ||
* Returns: | ||
* inline assembler block as a Statement | ||
*/ | ||
AST.Statement parseAsm() | ||
AST.Statement parseAsm(bool endOfLine) | ||
{ | ||
// Parse the asm block into a sequence of AsmStatements, | ||
// each AsmStatement is one instruction. | ||
|
@@ -6998,6 +7000,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer | |
size_t nestlevel = 0; | ||
while (1) | ||
{ | ||
if (endOfLine) | ||
nextDefineLine(); | ||
switch (token.value) | ||
{ | ||
case TOK.identifier: | ||
|
@@ -7032,14 +7036,20 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer | |
} | ||
break; | ||
|
||
case TOK.endOfLine: | ||
nextDefineLine(); | ||
goto case; | ||
|
||
case TOK.semicolon: | ||
Comment on lines
+7039
to
7043
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like it unintentionally bleeds into D code parser. Did you forget an |
||
if (nestlevel != 0) | ||
error("mismatched number of curly brackets"); | ||
|
||
if (toklist || label) | ||
{ | ||
// Create AsmStatement from list of tokens we've saved | ||
AST.Statement s = new AST.AsmStatement(token.loc, toklist); | ||
AST.AsmStatement as = new AST.AsmStatement(token.loc, toklist); | ||
as.caseSensitive = !endOfLine; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two variables mean different things, why is one setting the other? |
||
AST.Statement s = as; | ||
toklist = null; | ||
ptoklist = &toklist; | ||
if (label) | ||
|
@@ -7083,6 +7093,8 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer | |
break; | ||
} | ||
nextToken(); | ||
if (token.value == TOK.endOfLine) | ||
nextToken(); | ||
auto s = new AST.CompoundAsmStatement(loc, statements, stc); | ||
return s; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* DISABLED: freebsd32 freebsd64 linux32 linux64 osx32 osx64 win64 dragonflybsd openbsd | ||
*/ | ||
|
||
// https://issues.dlang.org/show_bug.cgi?id=24130 | ||
|
||
void test(int ShiftCount, int Value) | ||
{ | ||
#ifdef _MSC_VER | ||
__asm { | ||
mov ecx, ShiftCount | ||
mov eax, dword ptr [Value] | ||
mov edx, dword ptr [Value+4] | ||
shrd eax, edx, cl | ||
shr edx, cl | ||
} | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say just pass
true
instead of relying on...