LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 18994 - MS style ASM results in assertion failure
Summary: MS style ASM results in assertion failure
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: 3.4
Hardware: PC Windows XP
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-27 12:31 PST by JB Feldman
Modified: 2014-03-07 22:26 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
The crashed asked me to include this, so I did. (576 bytes, application/octet-stream)
2014-02-27 12:31 PST, JB Feldman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JB Feldman 2014-02-27 12:31:13 PST
Created attachment 12159 [details]
The crashed asked me to include this, so I did.

This bug was discovered when trying to include ntddk.h (from the 3790 version of the DDK). Minimal code necessary to reproduce is:

    #define _PCR fs:[0]

    typedef struct _s {
	int value;
    } s;

    unsigned int DriverEntry()    
    {
  	__asm { movzx eax, _PCR s.value }
	
    }  

This results in the following output

$>clang-cl driver.c
driver.c(17,25) :  error: unexpected type name 's': expected expression
        __asm { movzx eax, _PCR s.value }
                                ^
Assertion failed: End.getPointer() <= EndPtr && "frontend claimed part of a toke
n?", file ..\..\..\..\..\lib\Target\X86\AsmParser\X86AsmParser.cpp, line 1481
Stack dump:
0.      Program arguments: C:\WINDDK\3790~1.183\bin\clang-cl.exe -cc1 -triple i6
86-pc-win32 -emit-obj -mrelax-all -disable-free -main-file-name driver.c -mreloc
ation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-al
iases -target-cpu pentium4 -D_MT --dependent-lib=libcmt --dependent-lib=oldnames
 -cxx-abi microsoft -fdiagnostics-format msvc -resource-dir C:\WINDDK\3790~1.183
\bin\..\lib\clang\3.5 -internal-isystem C:\WINDDK\3790~1.183\bin\..\lib\clang\3.
5\include -internal-isystem C:\WINDDK\3790~1.183\inc\w2K -fdebug-compilation-dir
 C:\Users\XXX\Desktop\helloworld -ferror-limit 19 -fmessage-length 80 -mstackrea
lign -fms-extensions -fms-compatibility -fmsc-version=1700 -fdelayed-template-pa
rsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -vectoriz
e-slp -o C:\Users\XXX\AppData\Local\Temp\driver-224438.obj -x c driver.c
1.      driver.c:19:1: current parser token '}'
2.      driver.c:16:1: parsing function body 'DriverEntry'
3.      driver.c:16:1: in compound statement ('{}')
0x5C0A14FA (0x0000000A 0x00000000 0x04E7AF30 0x5C179AC4), memcmp() + 0xABA bytes
(s)
0x5C18B26C (0x04E7AF80 0x04E7AF44 0x0000009E 0x5C1EACA8), abort() + 0x1C bytes(s
)
0x5C179AC4 (0x03956888 0x03956810 0x000005C9 0x04E7B0D0), _wassert() + 0xD4 byte
s(s)
0x008086E7 (0x04E7B0B0 0x04E7B094 0x04E7B204 0x00000000), `anonymous namespace':
:X86AsmParser::ParseIntelIdentifier() + 0x127 bytes(s), c:\llvm\llvm\lib\target\
x86\asmparser\x86asmparser.cpp, line 1481 + 0x2D byte(s)
0x00807C61 (0x04E7B164 0x04E7B230 0x04E7B328 0x04E7B26C), `anonymous namespace':
:X86AsmParser::ParseIntelExpression() + 0x251 bytes(s), c:\llvm\llvm\lib\target\
x86\asmparser\x86asmparser.cpp, line 1338 + 0x1A byte(s)
0x008081CC (0x00000020 0x04E7C73F 0x00000000 0x00000000), `anonymous namespace':
:X86AsmParser::ParseIntelBracExpression() + 0xDC bytes(s), c:\llvm\llvm\lib\targ
et\x86\asmparser\x86asmparser.cpp, line 1410 + 0x13 byte(s)
0x0080768B (0x00000020 0x04E7C73F 0x00000000 0x04E7B9C4), `anonymous namespace':
:X86AsmParser::ParseIntelSegmentOverride() + 0x21B bytes(s), c:\llvm\llvm\lib\ta
rget\x86\asmparser\x86asmparser.cpp, line 1524 + 0x1C byte(s)
0x00806C7D (0x0513EDF8 0x04E7B9C4 0x0080D6A2 0x04E7BD2C), `anonymous namespace':
:X86AsmParser::ParseIntelOperand() + 0x64D bytes(s), c:\llvm\llvm\lib\target\x86
\asmparser\x86asmparser.cpp, line 1760 + 0x17 byte(s)
0x00806375 (0x04E7BD2C 0x04E7B9E0 0xCCCCCCCC 0xCCCCCCCC), `anonymous namespace':
:X86AsmParser::ParseOperand() + 0x25 bytes(s), c:\llvm\llvm\lib\target\x86\asmpa
rser\x86asmparser.cpp, line 1180 + 0x8 byte(s)
0x0080D6A2 (0x04E7BC88 0x04E7BC98 0x00000005 0x04E7C734), `anonymous namespace':
:X86AsmParser::ParseInstruction() + 0xAD2 bytes(s), c:\llvm\llvm\lib\target\x86\
asmparser\x86asmparser.cpp, line 2068 + 0x8 byte(s)
0x00CAC89D (0x04E7BF24 0x04E7CB04 0x04E7C1A0 0xCCCCCCCC), `anonymous namespace':
:AsmParser::parseStatement() + 0xFDD bytes(s), c:\llvm\llvm\lib\mc\mcparser\asmp
arser.cpp, line 1541 + 0x41 byte(s)
0x00CA94A0 (0x000000E3 0x04E7C414 0x04E7C444 0x04E7C438), `anonymous namespace':
:AsmParser::parseMSInlineAsm() + 0xF0 bytes(s), c:\llvm\llvm\lib\mc\mcparser\asm
parser.cpp, line 4194 + 0xF byte(s)
0x0219E4D1 (0x04E7CDF0 0x000000E3 0x04E7CEC0 0x04E7E104), clang::Parser::ParseMi
crosoftAsmStatement() + 0xAE1 bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parse
stmt.cpp, line 2202 + 0x6E byte(s)
0x0219D1C2 (0x04E7CDF0 0x04E7CE33 0x04E7CF24 0x00000076), clang::Parser::ParseAs
mStatement() + 0xC2 bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parsestmt.cpp,
line 2261 + 0x10 byte(s)
0x021989D5 (0x04E7CEE8 0x04E7D124 0x00000000 0x00000000), clang::Parser::ParseSt
atementOrDeclarationAfterAttributes() + 0x4E5 bytes(s), c:\llvm\llvm\tools\clang
\lib\parse\parsestmt.cpp, line 280 + 0x16 byte(s)
0x021983B7 (0x04E7CF5C 0x04E7D124 0x00000000 0x00000000), clang::Parser::ParseSt
atementOrDeclaration() + 0x67 bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parse
stmt.cpp, line 121
0x0219A4E9 (0x04E7D260 0x00000000 0x04E7D48C 0x04E7E104), clang::Parser::ParseCo
mpoundStatementBody() + 0x399 bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parse
stmt.cpp, line 902 + 0x1A byte(s)
0x021A038F (0x050FDAE0 0x04E7D378 0x04E7DA90 0x04E7E104), clang::Parser::ParseFu
nctionStatementBody() + 0xDF bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parses
tmt.cpp, line 2459
0x02147976 (0x04E7D620 0x04E7D52C 0x04E7D600 0x04E7DB24), clang::Parser::ParseFu
nctionDefinition() + 0x9B6 bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parser.c
pp, line 1186 + 0x16 byte(s)
0x02160BA9 (0x04E7E0A8 0x04E7DB5C 0x00000000 0x00000001), clang::Parser::ParseDe
clGroup() + 0x179 bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parsedecl.cpp, li
ne 1700 + 0x22 byte(s)
0x02146F4E (0x04E7E0A8 0x04E7E0D0 0x04E7DB5C 0x00000003), clang::Parser::ParseDe
clOrFunctionDefInternal() + 0x2CE bytes(s), c:\llvm\llvm\tools\clang\lib\parse\p
arser.cpp, line 953 + 0x18 byte(s)
0x02146C09 (0x04E7E0A8 0x04E7E0D0 0x00000000 0x00000003), clang::Parser::ParseDe
clarationOrFunctionDefinition() + 0x89 bytes(s), c:\llvm\llvm\tools\clang\lib\pa
rse\parser.cpp, line 969 + 0x1B byte(s)
0x02146614 (0x04E7E0A8 0x04E7E0D0 0x00000000 0x04E7E188), clang::Parser::ParseEx
ternalDeclaration() + 0x934 bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parser.
cpp, line 828 + 0x16 byte(s)
0x0214310F (0x04E7E140 0x04E7E394 0x04E7E198 0x0513B548), clang::Parser::ParseTo
pLevelDecl() + 0x1DF bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parser.cpp, li
ne 633 + 0x12 byte(s)
0x02140E49 (0x0512D9B8 0x00000000 0x00000000 0x04E7E39C), clang::ParseAST() + 0x
1B9 bytes(s), c:\llvm\llvm\tools\clang\lib\parse\parseast.cpp, line 144 + 0xC by
te(s)
0x01603901 (0x04E7E418 0xCCCCCCCC 0xCCCCCCCC 0xCCCCCCCC), clang::ASTFrontendActi
on::ExecuteAction() + 0x101 bytes(s), c:\llvm\llvm\tools\clang\lib\frontend\fron
tendaction.cpp, line 477 + 0x30 byte(s)
0x01F64286 (0x04E7E3C4 0xCCCCCCCC 0xCCCCCCCC 0xCCCCCCCC), clang::CodeGenAction::
ExecuteAction() + 0x3A6 bytes(s), c:\llvm\llvm\tools\clang\lib\codegen\codegenac
tion.cpp, line 432
0x0160351C (0x04E7E4B4 0x04E7F51C 0xCCCCCCCC 0xCCCCCCCC), clang::FrontendAction:
:Execute() + 0xAC bytes(s), c:\llvm\llvm\tools\clang\lib\frontend\frontendaction
.cpp, line 379 + 0xF byte(s)
0x015D4E01 (0x050D28A0 0x04E7EA14 0xCCCCCCCC 0xCCCCCCCC), clang::CompilerInstanc
e::ExecuteAction() + 0x281 bytes(s), c:\llvm\llvm\tools\clang\lib\frontend\compi
lerinstance.cpp, line 708
0x01705C5B (0x050D13D0 0x04E7F93C 0xCCCCCCCC 0xCCCCCCCC), clang::ExecuteCompiler
Invocation() + 0x30B bytes(s), c:\llvm\llvm\tools\clang\lib\frontendtool\execute
compilerinvocation.cpp, line 238 + 0x11 byte(s)
0x0027B310 (0x04E7F524 0x04E7F5E4 0x050D41F8 0x001C12F3), cc1_main() + 0x2F0 byt
es(s), c:\llvm\llvm\tools\clang\tools\driver\cc1_main.cpp, line 101 + 0xE byte(s
)
0x0026BA3F (0x00000032 0x050D0F00 0x050C95A8 0x9303FCE3), main() + 0x22F bytes(s
), c:\llvm\llvm\tools\clang\tools\driver\driver.cpp, line 315 + 0x45 byte(s)
0x02BC29D9 (0x04E7F9A0 0x750333AA 0x7EFDE000 0x04E7F9E0), __tmainCRTStartup() +
0x199 bytes(s), f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c, line 626 + 0x19 byte
(s)
0x02BC2B1D (0x7EFDE000 0x04E7F9E0 0x76F19F72 0x7EFDE000), mainCRTStartup() + 0xD
 bytes(s), f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c, line 466
0x750333AA (0x7EFDE000 0x7AB23ACF 0x00000000 0x00000000), BaseThreadInitThunk()
+ 0x12 bytes(s)
0x76F19F72 (0x02BC2B10 0x7EFDE000 0x00000000 0x00000000), RtlInitializeException
Chain() + 0x63 bytes(s)
0x76F19F45 (0x02BC2B10 0x7EFDE000 0x00000000 0x00000000), RtlInitializeException
Chain() + 0x36 bytes(s)
clang-cl.exe: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.5
Target: i686-pc-win32
Thread model: posix
clang-cl.exe: note: diagnostic msg: PLEASE submit a bug report to  and include t
he crash backtrace, preprocessed source, and associated run script.
clang-cl.exe: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-cl.exe: note: diagnostic msg: C:\Users\XXX\AppData\Local\Temp\driver-d39a4
4.c
clang-cl.exe: note: diagnostic msg: C:\Users\XXX\AppData\Local\Temp\driver-d39a4
4.sh
clang-cl.exe: note: diagnostic msg:

********************

This code is mirrored nearly identically in ntddk.h
Comment 1 Reid Kleckner 2014-03-06 13:21:44 PST
Should be fixed in r203146.  The solution was to use the code we already have for parsing field access, but let the leading dot be optional.
Comment 2 JB Feldman 2014-03-07 22:25:06 PST
Tested against ntddk.h this morning without issue.