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 2266 - semantic analyzer assertion on malformed code: "The next DeclContext should be directly contained in the current one."
Summary: semantic analyzer assertion on malformed code: "The next DeclContext should b...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: unspecified
Hardware: PC All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-30 11:43 PDT by Ted Kremenek
Modified: 2018-11-07 00:22 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ted Kremenek 2008-04-30 11:43:11 PDT
We're seeing an assertion failure that appears to be a regression in handling malformed code.  The following code triggers an assertion:

int f1 (struct X *x, struct Y *y) {
  int error = 0;
  error = f2 (x, y);
  return error;
}

int
f2 (struct X *x, struct Y *y)
{

I am at revision r50483 of clang.  I am using Mac OS X (Leopard), although I believe the bug will appear on other platforms (haven't tested yet).

The output of clang:

$ clang /tmp/t.c
Assertion failed: (( (isa<ObjCMethodDecl>(DC) && isa<TranslationUnitDecl>(CurContext)) || DC->getParent() == CurContext ) && "The next DeclContext should be directly contained in the current one."), function PushDeclContext, file SemaDecl.cpp, line 48.
0   clang                               0x00297b19 _ZNK4llvm3sys4PathneERKS1_ + 79
1   clang                               0x00297d15 _ZN4llvm3sys28PrintStackTraceOnErrorSignalEv + 387
2   libSystem.B.dylib                   0x915d65eb _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   libSystem.B.dylib                   0x9164f3f2 raise + 26
5   libSystem.B.dylib                   0x9165e9af abort + 73
6   libSystem.B.dylib                   0x91650593 __assert_rtn + 101
7   clang                               0x000e1cb3 _ZN5clang4Sema15PushDeclContextEPNS_11DeclContextE + 135
8   clang                               0x000e2112 _ZN5clang4Sema23ActOnStartOfFunctionDefEPNS_5ScopeERNS_10DeclaratorE + 1104
9   clang                               0x00171425 _ZN5clang6Parser23ParseFunctionDefinitionERNS_10DeclaratorE + 505
10  clang                               0x0017198b _ZN5clang6Parser36ParseDeclarationOrFunctionDefinitionEv + 1333
11  clang                               0x00171ae5 _ZN5clang6Parser24ParseExternalDeclarationEv + 85
12  clang                               0x00171d03 _ZN5clang6Parser17ParseTopLevelDeclERPv + 61
13  clang                               0x000d6f5f _ZN5clang8ParseASTERNS_12PreprocessorEPNS_11ASTConsumerEb + 339
14  clang                               0x00028de4 _Z16InitializeGCModeRN5clang11LangOptionsE + 5620
15  clang                               0x0002b917 main + 1345
16  clang                               0x00001b62 start + 54
Comment 1 Ted Kremenek 2008-05-01 16:41:12 PDT
Fixed by Argiris in r50538:

http://llvm.org/viewvc/llvm-project?rev=50538&view=rev