llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Assert failed after throwing syntax error for incorrect brace

Open BalaRishi-AMD opened this issue 9 years ago • 3 comments

Bugzilla Link 31798
Version trunk
OS Linux
Attachments Preprocessed source, Run script, Console output having error details
CC @DougGregor

Extended Description

For the attached small testcase syntax errors are thrown as expected for incorrect brace. Then the below assertion failure occurs: clang++: /home/amd/JENKINS/workspace/CPUPC_Mirror_Branch/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp:7362: clang::ExprResult clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, l lvm::function_ref<clang::ActionResultclang::Expr*(clang::Expr*)>): Assertion `TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr"' failed.

This regression was introduced in 3.8.

Attached required files to reproduce the issue.

This issue was faced while trying to reproduce the issue, "Compilation not completing for gnomon_engine.cpp of BlastC++" (Bug-id: 31751) with a smaller testcase.

BalaRishi-AMD avatar Jan 30 '17 11:01 BalaRishi-AMD

Invocation command: clang++ -c

BalaRishi-AMD avatar Jan 30 '17 12:01 BalaRishi-AMD

This seems to have been fixed between 6.0.0 and 7.0.0 https://godbolt.org/z/5zfa5o6GG

As a note the issue only seems to show up in assertion builds

for reference

code

template<class Position>
class COpenRange
{
public:
    typedef Position position_type;
    typedef COpenRange<Position> TThisType;


    position_type GetToOpen(void) const
        {
            return m_ToOpen;
        }

   TThisType& CombineWith( )
        {
            m_ToOpen = max(m_ToOpen, GetToOpen());
            return *this;
        }
    TThisType CombinationWith() const
        {
            }
            return *this;
        }

private:
    position_type m_From, m_ToOpen;
};


dump

gnomon_engine_ce.cpp:23:13: error: expected member name or ';' after declaration specifiers
            return *this;
            ^
gnomon_engine_ce.cpp:12:20: error: use of undeclared identifier 'm_ToOpen'; did you mean 'GetToOpen'?
            return m_ToOpen;
                   ^~~~~~~~
                   GetToOpen
gnomon_engine_ce.cpp:10:19: note: 'GetToOpen' declared here
    position_type GetToOpen(void) const
                  ^
gnomon_engine_ce.cpp:17:13: error: use of undeclared identifier 'm_ToOpen'
            m_ToOpen = max(m_ToOpen, GetToOpen());
            ^
clang-6.0: /home/tonik/llvm-project/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp:7508: clang::ExprResult clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, llvm::function_ref<clang::ActionResult<clang::Expr*>(clang::Expr*)>): Assertion `TyposInContext < ~0U && "Recursive call of CorrectDelayedTyposInExpr"' failed.
#0 0x0000000002305e1a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x2305e1a)
#1 0x0000000002303a46 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x2303a46)
#2 0x0000000002303de5 SignalHandler(int) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x2303de5)
#3 0x00007f0cc2254df0 __restore_rt (/lib64/libc.so.6+0x54df0)
#4 0x00007f0cc22a154c __pthread_kill_implementation (/lib64/libc.so.6+0xa154c)
#5 0x00007f0cc2254d46 __GI_raise (/lib64/libc.so.6+0x54d46)
#6 0x00007f0cc22287f3 __GI_abort (/lib64/libc.so.6+0x287f3)
#7 0x00007f0cc222871b _nl_load_domain.cold (/lib64/libc.so.6+0x2871b)
#8 0x00007f0cc224dce6 (/lib64/libc.so.6+0x4dce6)
#9 0x0000000003520640 clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, llvm::function_ref<clang::ActionResult<clang::Expr*, true> (clang::Expr*)>) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x3520640)
#10 0x00000000034c8f86 clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x34c8f86)
#11 0x0000000003513015 (anonymous namespace)::TransformTypos::RebuildCallExpr(clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x3513015)
#12 0x0000000003532d99 clang::TreeTransform<(anonymous namespace)::TransformTypos>::TransformCallExpr(clang::CallExpr*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x3532d99)
#13 0x000000000351ec66 clang::Sema::CorrectDelayedTyposInExpr(clang::Expr*, clang::VarDecl*, llvm::function_ref<clang::ActionResult<clang::Expr*, true> (clang::Expr*)>) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x351ec66)
#14 0x00000000030e21fa clang::Parser::ParseRHSOfBinaryExpression(clang::ActionResult<clang::Expr*, true>, clang::prec::Level) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30e21fa)
#15 0x00000000030e3ee9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30e3ee9)
#16 0x00000000031259aa clang::Parser::ParseExprStatement() (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x31259aa)
#17 0x0000000003122ca6 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*, clang::Parser::ParsedAttributesWithRange&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x3122ca6)
#18 0x0000000003122f9c clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x3122f9c)
#19 0x0000000003127430 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x3127430)
#20 0x00000000031299b0 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x31299b0)
#21 0x00000000030a60a9 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30a60a9)
#22 0x00000000030a5d7e clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30a5d7e)
#23 0x00000000030d9269 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30d9269)
#24 0x00000000030db9ba clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::Parser::ParsedAttributesWithRange&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30db9ba)
#25 0x00000000030b7a07 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30b7a07)
#26 0x00000000031360a2 clang::Parser::ParseSingleDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x31360a2)
#27 0x0000000003137e75 clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x3137e75)
#28 0x00000000031380b9 clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x31380b9)
#29 0x00000000030c57d6 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30c57d6)
#30 0x00000000030a3ecd clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30a3ecd)
#31 0x00000000030a4b9b clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30a4b9b)
#32 0x00000000030a4f12 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30a4f12)
#33 0x00000000030994eb clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x30994eb)
#34 0x0000000002c578f8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x2c578f8)
#35 0x00000000028d5d66 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x28d5d66)
#36 0x000000000289d89e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x289d89e)
#37 0x000000000297300a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0x297300a)
#38 0x0000000000af9330 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0xaf9330)
#39 0x0000000000a7e95e main (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0xa7e95e)
#40 0x00007f0cc223feb0 __libc_start_call_main (/lib64/libc.so.6+0x3feb0)
#41 0x00007f0cc223ff60 __libc_start_main_alias_2 (/lib64/libc.so.6+0x3ff60)
#42 0x0000000000af52f9 _start (/opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0+0xaf52f9)
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-6.0.0-assert/bin/clang-6.0 -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -main-file-name example.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /tmp/compiler-explorer-compiler202367-976657-1330u5c.747p/output.gcno -resource-dir /opt/compiler-explorer/clang-6.0.0-assert/lib/clang/6.0.0 -internal-isystem /opt/compiler-explorer/gcc-7.3.0/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /opt/compiler-explorer/gcc-7.3.0/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-7.3.0/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/clang-6.0.0-assert/lib/clang/6.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir /tmp/compiler-explorer-compiler202367-976657-1330u5c.747p -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -o /tmp/compiler-explorer-compiler202367-976657-1330u5c.747p/output.s -x c++ <source> 
1.	gnomon_engine_ce.cpp:17:50: current parser token ';'
2.	gnomon_engine_ce.cpp:3:1: parsing struct/union/class body 'COpenRange'
3.	gnomon_engine_ce.cpp:16:9: parsing function body 'COpenRange::CombineWith'
4.	gnomon_engine_ce.cpp:16:9: in compound statement ('{}')
clang-6.0: error: unable to execute command: Aborted (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 254

wheatman avatar Jul 07 '23 01:07 wheatman

@llvm/issue-subscribers-clang-frontend

llvmbot avatar Jul 07 '23 01:07 llvmbot