[llvm-bugs] [Bug 46883] New: Clang crashed in clang/lib/Sema/SemaDeclCXX.cpp:16257: clang::Decl *clang::Sema::ActOnFriendTypeDecl(clang::Scope *, const clang::DeclSpec &, clang::MultiTemplateParamsArg): Assertion `DS.getStorageClassSpec() == DeclSpec::SCS_unspecified' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 28 23:23:08 PDT 2020


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

            Bug ID: 46883
           Summary: Clang crashed in clang/lib/Sema/SemaDeclCXX.cpp:16257:
                    clang::Decl
                    *clang::Sema::ActOnFriendTypeDecl(clang::Scope *,
                    const clang::DeclSpec &,
                    clang::MultiTemplateParamsArg): Assertion
                    `DS.getStorageClassSpec() ==
                    DeclSpec::SCS_unspecified' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: haoxintu at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Hi, all.

This invalid code makes Clang-trunk crashed. The behavior only occurs in
current trunk and not crashed the release versions.

Input:
//small.cc
class {
  typedef friend enum ::a : class A {};
}

Command:
clang++ small.cc


Output:
small.cc:2:35: error: 'A' cannot be defined in a type specifier
  typedef friend enum ::a : class A {};
                                  ^
small.cc:2:25: error: no enum named 'a' in the global namespace
  typedef friend enum ::a : class A {};
                      ~~^
clang-12:
/home/tuhaoxin/compilers/llvm-project-0726/clang/lib/Sema/SemaDeclCXX.cpp:16257:
clang::Decl *clang::Sema::ActOnFriendTypeDecl(clang::Scope *, const
clang::DeclSpec &, clang::MultiTemplateParamsArg): Assertion
`DS.getStorageClassSpec() == DeclSpec::SCS_unspecified' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments:
/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.cc -mrelocation-model static -mframe-pointer=all -fmath-errno
-fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64
-fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/home/tuhaoxin/compilers/llvm-project-0726/build/lib/clang/12.0.0 -c-isystem
/usr/local/include/csmith-2.3.0 -cxx-isystem /usr/local/include/csmith-2.3.0
-internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward
-internal-isystem /usr/local/include -internal-isystem
/home/tuhaoxin/compilers/llvm-project-0726/build/lib/clang/12.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir
/home/tuhaoxin/gitee/run-new-scg/comparison/grammarinator/ice-test-1000000/creduce-clang
-ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions
-fcolor-diagnostics -faddrsig -o /tmp/small-1dd4dd.o -x c++ small.cc 
1.      small.cc:3:1: current parser token '}'
2.      small.cc:1:1: parsing struct/union/class body '(anonymous)'
 #0 0x000000000275ec74 PrintStackTraceSignalHandler(void*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x275ec74)
 #1 0x000000000275c86e llvm::sys::RunSignalHandlers()
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x275c86e)
 #2 0x000000000275ef95 SignalHandler(int)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x275ef95)
 #3 0x00007f45b46158a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
 #4 0x00007f45b3073f47 raise
/build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f45b30758b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f45b306542a __assert_fail_base
/build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f45b30654a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
 #8 0x00000000043075ca clang::Sema::ActOnFriendTypeDecl(clang::Scope*,
clang::DeclSpec const&, llvm::MutableArrayRef<clang::TemplateParameterList*>)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x43075ca)
 #9 0x0000000004026516
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x4026516)
#10 0x0000000004027f97
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x4027f97)
#11 0x000000000402215b
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x402215b)
#12 0x000000000401fde1
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x401fde1)
#13 0x0000000004000a37
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x4000a37)
#14 0x0000000003fe990a
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe990a)
#15 0x0000000003fe9635
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe9635)
#16 0x0000000003fe841f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe841f)
#17 0x0000000003fe648d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe648d)
#18 0x0000000003fe5cd7
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe5cd7)
#19 0x0000000003fe189e clang::ParseAST(clang::Sema&, bool, bool)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x3fe189e)
#20 0x0000000002f3b553 clang::FrontendAction::Execute()
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x2f3b553)
#21 0x0000000002ed2193
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x2ed2193)
#22 0x0000000002fe73f2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x2fe73f2)
#23 0x0000000000989758 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x989758)
#24 0x00000000009877cc ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x9877cc)
#25 0x0000000000987481 main
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x987481)
#26 0x00007f45b3056b97 __libc_start_main
/build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
#27 0x000000000098449a _start
(/home/tuhaoxin/compilers/llvm-project-0726/build/bin/clang-12+0x98449a)
clang-12: error: unable to execute command: Aborted (core dumped)
clang-12: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
d135744c34dc7a6315f1d2d65a969a2791a97534)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project-0726/build/bin
clang-12: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-12: note: diagnostic msg: /tmp/small-1f0089.cpp
clang-12: note: diagnostic msg: /tmp/small-1f0089.sh
clang-12: note: diagnostic msg: 

********************

My clang version is:
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
d135744c34dc7a6315f1d2d65a969a2791a97534)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/tuhaoxin/compilers/llvm-project-0726/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Candidate multilib: .;@m64
Selected multilib: .;@m64

Thanks,
Haoxin

-- 
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/20200729/00da02b5/attachment-0001.html>


More information about the llvm-bugs mailing list