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 9459 - Assertion `Ctx->isFileContext() && "We should have been looking only at file context here already."' on invalid code
Summary: Assertion `Ctx->isFileContext() && "We should have been looking only at file ...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords: crash-on-invalid
Depends on:
Blocks:
 
Reported: 2011-03-11 09:44 PST by Christopher Jefferson
Modified: 2011-04-22 13:53 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
testcase (115 bytes, application/octet-stream)
2011-03-11 09:44 PST, Christopher Jefferson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Jefferson 2011-03-11 09:44:22 PST
Created attachment 6311 [details]
testcase

The attached test (also given below) causes the following backtrace:

Code:

template<typename>struct ae_same;
template<typename>struct ts{}ap()
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); };


Backtrace:

ssert1.cc:3:5: error: use of undeclared identifier 'a'
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); };
    ^
assert1.cc:3:26: error: expected unqualified-id                                                                                                                                                    
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); };
                         ^
assert1.cc:3:35: error: a space is required between consecutive right angle brackets (use '> >')                                                                                                   
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); };
                                  ^~
                                  > >                                                                                                                                                              
assert1.cc:3:27: error: too few template arguments for class template 'ae_same'                                                                                                                    
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); };
                          ^
assert1.cc:1:26: note: template is declared here                                                                                                                                                   
template<typename>struct ae_same;
~~~~~~~~~~~~~~~~~~       ^
assert1.cc:3:35: error: expected '(' for function-style cast or type construction                                                                                                                  
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); };
                          ~~~~~~~~^~
assert1.cc:3:39: error: definition or redeclaration of 'p' cannot name the global scope                                                                                                            
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); };
                                    ~~^
assert1.cc:3:39: error: no member named 'p' in the global namespace                                                                                                                                
{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); };
                                    ~~^
clang: SemaLookup.cpp:1001: bool clang::Sema::CppLookupName(clang::LookupResult&, clang::Scope*): Assertion `Ctx->isFileContext() && "We should have been looking only at file context here already."' failed.
0  clang           0x00000000023fb09d
1  clang           0x00000000023fae90
2  libpthread.so.0 0x00007f0c60b578f0
3  libc.so.6       0x00007f0c5fe46a75 gsignal + 53
4  libc.so.6       0x00007f0c5fe4a5c0 abort + 384
5  libc.so.6       0x00007f0c5fe3f941 __assert_fail + 241
6  clang           0x0000000001437f5d clang::Sema::CppLookupName(clang::LookupResult&, clang::Scope*) + 2243
7  clang           0x00000000014383d5 clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool) + 795
8  clang           0x00000000014392db clang::Sema::LookupParsedName(clang::LookupResult&, clang::Scope*, clang::CXXScopeSpec*, bool, bool) + 323
9  clang           0x00000000013c1e4c clang::Sema::ActOnIdExpression(clang::Scope*, clang::CXXScopeSpec&, clang::UnqualifiedId&, bool, bool) + 880
10 clang           0x00000000012d055b clang::Parser::ParseCastExpression(bool, bool, bool&, clang::OpaquePtr<clang::QualType>) + 2745
11 clang           0x00000000012cfa56 clang::Parser::ParseCastExpression(bool, bool, clang::OpaquePtr<clang::QualType>) + 60
12 clang           0x00000000012cf018 clang::Parser::ParseAssignmentExpression() + 168
13 clang           0x00000000012d4a23 clang::Parser::ParseExpressionList(llvm::SmallVectorImpl<clang::Expr*>&, llvm::SmallVectorImpl<clang::SourceLocation>&, void (clang::Sema::*)(clang::Scope*, clang::Expr*, clang::Expr**, unsigned int), clang::Expr*) + 277
14 clang           0x00000000012b9243 clang::Parser::ParseDeclarationAfterDeclarator(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&) + 1747
15 clang           0x00000000012b88df clang::Parser::ParseDeclGroup(clang::Parser::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*) + 753
16 clang           0x00000000012b85cd clang::Parser::ParseSimpleDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&, bool) + 483
17 clang           0x00000000012b83b2 clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 624
18 clang           0x00000000012a5db5 clang::Parser::ParseStatementOrDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, bool) + 581
19 clang           0x00000000012a7332 clang::Parser::ParseCompoundStatementBody(bool) + 968
20 clang           0x00000000012aacae clang::Parser::ParseFunctionStatementBody(clang::Decl*) + 220
21 clang           0x00000000012b242a clang::Parser::ParseFunctionDefinition(clang::Parser::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&) + 1036
22 clang           0x00000000012e102c clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::AccessSpecifier) + 1280
23 clang           0x00000000012e0ade clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int, clang::SourceLocation&, clang::AccessSpecifier) + 996
24 clang           0x00000000012e0663 clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int, clang::SourceLocation&, clang::AccessSpecifier) + 175
25 clang           0x00000000012b81fb clang::Parser::ParseDeclaration(clang::ASTOwningVector<clang::Stmt*, 32u>&, unsigned int, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&) + 185
26 clang           0x00000000012b15bb clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::Parser::ParsingDeclSpec*) + 1225
27 clang           0x00000000012b1062 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 210
28 clang           0x0000000001299705 clang::ParseAST(clang::Sema&, bool) + 328
29 clang           0x00000000010015c1 clang::ASTFrontendAction::ExecuteAction() + 263
30 clang           0x000000000113bfaf clang::CodeGenAction::ExecuteAction() + 947
31 clang           0x0000000001001212 clang::FrontendAction::Execute() + 320
32 clang           0x0000000000fe9ec9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 751
33 clang           0x0000000000f93583 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 912
34 clang           0x0000000000f855c7 cc1_main(char const**, char const**, char const*, void*) + 982
35 clang           0x0000000000f8ea3c main + 499
36 libc.so.6       0x00007f0c5fe31c4d __libc_start_main + 253
37 clang           0x0000000000f84c69
Stack dump:
0.      Program arguments: /llvmdebug/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name assert1.cc -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.20.1 -momit-leaf-frame-pointer -resource-dir /llvmdebug/bin/../lib/clang/3.0 -ferror-limit 19 -fmessage-length 195 -fcxx-exceptions -fexceptions -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o assert1.o -x c++ assert1.cc 
1.      assert1.cc:3:42: current parser token ')'
2.      assert1.cc:3:1: parsing function body 'ap'
3.      assert1.cc:3:1: in compound statement ('{}')
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal 1 (use -v to see invocation)
Comment 1 Ted Kremenek 2011-03-11 15:16:37 PST
clone to <rdar://problem/9122937>
Comment 2 Argyrios Kyrtzidis 2011-04-22 13:53:28 PDT
Fixed at r130006.