[LLVMbugs] [Bug 10264] New: Rejects-valid and sometimes a crash with defining fixed enums out of scope

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jul 4 03:14:00 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10264

           Summary: Rejects-valid and sometimes a crash with defining
                    fixed enums out of scope
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: rjmccall at apple.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


In my original test case, this didn't crash, but it still rejected what I
believe is valid code.  This is probably just a matter of protecting colons
when parsing nested names on enum specifiers.  However, it also suggests that
we aren't handling incomplete enums safely when they're the base of a nested
name;  i.e. ns::A::foo should not lead to crashes when A is an incomplete
unscoped enum.

daysthatwere:trunk clang$ cat /tmp/red3.cpp
namespace ns {
  typedef unsigned type;
  enum A : ns::type;
}

enum ns::A : ns::type {
  X
};

daysthatwere:trunk clang$ clang -std=c++0x /tmp/red3.cpp 
/tmp/red3.cpp:6:12: error: unexpected ':' in nested name specifier
enum ns::A : ns::type {
           ^
           ::
Assertion failed: ((!isa<TagDecl>(LookupCtx) || LookupCtx->isDependentContext()
|| cast<TagDecl>(LookupCtx)->isDefinition() ||
Context.getTypeDeclType(cast<TagDecl>(LookupCtx))->getAs<TagType>()
->isBeingDefined()) && "Declaration context must already be complete!"),
function LookupQualifiedName, file SemaLookup.cpp, line 1334.
0  clang             0x0000000102025835 PrintStackTrace(void*) + 53
1  clang             0x0000000102025dfb SignalHandler(int) + 379
2  libSystem.B.dylib 0x00007fff8718a66a _sigtramp + 26
3  clang             0x0000000100fb99ce clang::EnumType::classof(clang::TagType
const*) + 30
4  clang             0x000000010004252b raise + 27
5  clang             0x00000001000425ea abort + 26
6  clang             0x00000001000425c4 __assert_rtn + 132
7  clang             0x00000001006fbc3f
clang::Sema::LookupQualifiedName(clang::LookupResult&, clang::DeclContext*,
bool) + 495
8  clang             0x00000001004fd999
clang::Sema::BuildCXXNestedNameSpecifier(clang::Scope*, clang::IdentifierInfo&,
clang::SourceLocation, clang::SourceLocation, clang::QualType, bool,
clang::CXXScopeSpec&, clang::NamedDecl*, bool) + 937
9  clang             0x00000001004ff2f7
clang::Sema::ActOnCXXNestedNameSpecifier(clang::Scope*, clang::IdentifierInfo&,
clang::SourceLocation, clang::SourceLocation,
clang::OpaquePtr<clang::QualType>, bool, clang::CXXScopeSpec&) + 263

10 clang             0x000000010046c040
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool*, bool) + 4896
11 clang             0x000000010043f04e
clang::Parser::ParseEnumSpecifier(clang::SourceLocation, clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier) + 382
12 clang             0x000000010043c296
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext) + 10534
13 clang             0x00000001004a8e69
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsingDeclSpec&,
clang::AccessSpecifier) + 137
14 clang             0x00000001004a93a0
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&,
clang::AccessSpecifier) + 96
15 clang             0x00000001004a84d1
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::Parser::ParsingDeclSpec*) + 3681
16 clang             0x00000001004a7623
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 451
17 clang             0x00000001004307cc clang::ParseAST(clang::Sema&, bool) +
396
18 clang             0x00000001000ebd0c
clang::ASTFrontendAction::ExecuteAction() + 284
19 clang             0x00000001003eed62 clang::CodeGenAction::ExecuteAction() +
1250
20 clang             0x00000001000eb8c8 clang::FrontendAction::Execute() + 360
21 clang             0x00000001000c5ab6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1078
22 clang             0x0000000100059e7c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1132
23 clang             0x0000000100045d64 cc1_main(char const**, char const**,
char const*, void*) + 1252
24 clang             0x00000001000533ad main + 701
25 clang             0x0000000100045874 start + 52
26 clang             0x0000000000000026 start + 4294682598
Stack dump:
0.    Program arguments: /Volumes/Data/llvm/Debug+Asserts/bin/clang -cc1
-triple x86_64-apple-macosx10.6.7 -emit-obj -mrelax-all -disable-free
-main-file-name red3.cpp -pic-level 1 -mdisable-fp-elim -masm-verbose
-munwind-tables -target-cpu core2 -target-linker-version 97.17 -resource-dir
/Volumes/Data/llvm/Debug+Asserts/bin/../lib/clang/3.0 -std=c++0x
-fdeprecated-macro -ferror-limit 19 -fmessage-length 85 -stack-protector 1
-fblocks -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o
/var/folders/s9/s96FsWmjFfOmejEGjQKJMU+++TI/-Tmp-/cc-8cHSPp.o -x c++
/tmp/red3.cpp 
1.    /tmp/red3.cpp:6:18: current parser token 'type'
clang: error: unable to execute command: Illegal instruction
clang: error: clang frontend command failed due to signal 2 (use -v to see
invocation)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list