[llvm-bugs] [Bug 27014] New: Clang crashes on simple testcase with syntax and sema errors

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 21 08:32:03 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27014

            Bug ID: 27014
           Summary: Clang crashes on simple testcase with syntax and sema
                    errors
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zinovy.nis at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Clang reports internal error on this (incorrect) code. GCC just prints
compilation error as expected:

$ clang -v
clang version 3.9.0 
Target: x86_64-unknown-linux-gnu

$ cat test.c

typedef double F64; 
typedef UL unsigned long; // THIS TYPO causes clang to crash

void test(UL a, UL b).
{
    UL c = a;
    for(i = 0; i < c/sizeof(F64); i++) c += 1; // "i" is also undeclared.
}

$ clang -c test.c

test.c:2:9: error: unknown type name 'UL'
typedef UL unsigned long; // THIS TYPO causes clang to crash
        ^
test.c:2:12: error: expected identifier or '('
typedef UL unsigned long; // THIS TYPO causes clang to crash
           ^
test.c:4:11: error: unknown type name 'UL'
void test(UL a, UL b)
          ^
test.c:4:17: error: unknown type name 'UL'
void test(UL a, UL b)
                ^
test.c:6:5: error: use of undeclared identifier 'UL'
    UL c = a;
    ^
test.c:7:13: error: use of undeclared identifier 'i'
        for(i = 0; i < c/sizeof(F64); i++) c += 1; // "i" is also undeclared.
            ^
test.c:7:24: error: use of undeclared identifier 'c'
        for(i = 0; i < c/sizeof(F64); i++) c += 1; // "i" is also undeclared.
                       ^
clang-3.9: llvm/llvm/tools/clang/lib/Sema/SemaLookup.cpp:5032: const
clang::Sema::TypoExprState& clang::Sema::getTypoExprState(clang::TypoExpr*)
const: Assertion `Entry != DelayedTypos.end() && "Failed to get the state for a
TypoExpr!"' failed.
0  clang-3.9       0x000000000131f2f5
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  clang-3.9       0x000000000131d0a6 llvm::sys::RunSignalHandlers() + 54
2  clang-3.9       0x000000000131d2d1
3  libpthread.so.0 0x00007f53d7336130
4  libc.so.6       0x00007f53d65665d7 gsignal + 55
5  libc.so.6       0x00007f53d6567cc8 abort + 328
6  libc.so.6       0x00007f53d655f546
7  libc.so.6       0x00007f53d655f5f2
8  clang-3.9       0x00000000022947a9
clang::Sema::getTypoExprState(clang::TypoExpr*) const + 153
9  clang-3.9       0x0000000002229007
10 clang-3.9       0x00000000022298c9
11 clang-3.9       0x000000000222662c
clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*,
llvm::function_ref<clang::ActionResult<clang::Expr*, true> (clang::Expr*)>) +
716
12 clang-3.9       0x0000000001e741cc
clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*,
true>, clang::prec::Level) + 3404
13 clang-3.9       0x0000000001e73902
clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*,
true>, clang::prec::Level) + 1154
14 clang-3.9       0x0000000001e733f9
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 57
15 clang-3.9       0x0000000001e73469
clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 9
16 clang-3.9       0x0000000001ea9ab8
clang::Parser::ParseForStatement(clang::SourceLocation*) + 2488
17 clang-3.9       0x0000000001ea6ebb
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) + 1083
18 clang-3.9       0x0000000001ea766d
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*) + 125
19 clang-3.9       0x0000000001eaa8c9
clang::Parser::ParseCompoundStatementBody(bool) + 1641
20 clang-3.9       0x0000000001ead0a8
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) + 216
21 clang-3.9       0x0000000001e3bbb5
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) +
1173
22 clang-3.9       0x0000000001e5d820
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int,
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 3072
23 clang-3.9       0x0000000001e38e52
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 274
24 clang-3.9       0x0000000001e394ee
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 942
25 clang-3.9       0x0000000001e3ceaf
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 255
26 clang-3.9       0x0000000001e3d680
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 384
27 clang-3.9       0x0000000001e36583 clang::ParseAST(clang::Sema&, bool, bool)
+ 371
28 clang-3.9       0x0000000001a2e0eb clang::CodeGenAction::ExecuteAction() +
59
29 clang-3.9       0x000000000176bc26 clang::FrontendAction::Execute() + 534
30 clang-3.9       0x000000000174755e
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 318
31 clang-3.9       0x00000000017ff69c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2300
32 clang-3.9       0x0000000000707b28 cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 2104
33 clang-3.9       0x00000000006d36db main + 6171
34 libc.so.6       0x00007f53d6552af5 __libc_start_main + 245
35 clang-3.9       0x0000000000703b65
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160321/f16924a2/attachment.html>


More information about the llvm-bugs mailing list