[llvm-bugs] [Bug 47198] New: Clang crashed in clang/include/clang/Sema/DeclSpec.h:2313: DeclaratorChunk::FunctionTypeInfo &clang::Declarator::getFunctionTypeInfo(): Assertion `isFunctionDeclarator() && "Not a function declarator!"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Aug 16 20:00:25 PDT 2020


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

            Bug ID: 47198
           Summary: Clang crashed in
                    clang/include/clang/Sema/DeclSpec.h:2313:
                    DeclaratorChunk::FunctionTypeInfo
                    &clang::Declarator::getFunctionTypeInfo(): Assertion
                    `isFunctionDeclarator() && "Not a function
                    declarator!"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Keywords: crash-on-invalid
          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 and released Clang crashed.

Input:
//small.cc
class a {};
(::*a ::operator enum b)(int c)

Command:
clang++ small.cc

Output:
small.cc:2:23: error: ISO C++ forbids forward references to 'enum' types
(::*a ::operator enum b)(int c)
                      ^
small.cc:2:2: error: 'type name' does not point into a class
(::*a ::operator enum b)(int c)
 ^~
small.cc:2:9: error: conversion function cannot have any parameters
(::*a ::operator enum b)(int c)
        ^
clang-12:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/clang/include/clang/Sema/DeclSpec.h:2313:
DeclaratorChunk::FunctionTypeInfo &clang::Declarator::getFunctionTypeInfo():
Assertion `isFunctionDeclarator() && "Not a function declarator!"' 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/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/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/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/lib/clang/12.0.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward
-internal-isystem /usr/local/include -internal-isystem
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/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/haoxin/test -ferror-limit 19
-fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics
-faddrsig -o /tmp/small-9451f0.o -x c++ small.cc 
1.      <eof> parser at end of file
 #0 0x0000000002758f44 PrintStackTraceSignalHandler(void*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2758f44)
 #1 0x0000000002756b4e llvm::sys::RunSignalHandlers()
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2756b4e)
 #2 0x0000000002759265 SignalHandler(int)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2759265)
 #3 0x00007f7033bf0390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
 #4 0x00007f703275a438 raise
/build/glibc-e6zv40/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
 #5 0x00007f703275c03a abort /build/glibc-e6zv40/glibc-2.23/stdlib/abort.c:91:0
 #6 0x00007f7032752be7 __assert_fail_base
/build/glibc-e6zv40/glibc-2.23/assert/assert.c:92:0
 #7 0x00007f7032752c92 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc92)
 #8 0x0000000003fc6e3d clang::Declarator::getFunctionTypeInfo()
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc6e3d)
 #9 0x00000000042c67d7
clang::Sema::CheckConversionDeclarator(clang::Declarator&, clang::QualType&,
clang::StorageClass&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x42c67d7)
#10 0x00000000041f5416 clang::Sema::ActOnFunctionDeclarator(clang::Scope*,
clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*,
clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>,
bool&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x41f5416)
#11 0x00000000041f2b76 clang::Sema::HandleDeclarator(clang::Scope*,
clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x41f2b76)
#12 0x00000000041f1d88 clang::Sema::ActOnDeclarator(clang::Scope*,
clang::Declarator&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x41f1d88)
#13 0x0000000003fe25c0
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fe25c0)
#14 0x0000000003fe0f47 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fe0f47)
#15 0x0000000003fc568c
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc568c)
#16 0x0000000003fc5125
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc5125)
#17 0x0000000003fc3f0f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc3f0f)
#18 0x0000000003fc1f7d
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fc1f7d)
#19 0x0000000003fbd29d clang::ParseAST(clang::Sema&, bool, bool)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x3fbd29d)
#20 0x0000000002f2a393 clang::FrontendAction::Execute()
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2f2a393)
#21 0x0000000002ec4ea3
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2ec4ea3)
#22 0x0000000002fd43b2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x2fd43b2)
#23 0x0000000000983453 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x983453)
#24 0x00000000009818ec ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x9818ec)
#25 0x0000000000981594 main
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x981594)
#26 0x00007f7032745840 __libc_start_main
/build/glibc-e6zv40/glibc-2.23/csu/../csu/libc-start.c:325:0
#27 0x000000000097e5a9 _start
(/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/build/bin/clang-12+0x97e5a9)
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
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/home/haoxin/corpus-compilers/llvm-trunk/llvm-project-master/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-3df53e.cpp
clang-12: note: diagnostic msg: /tmp/small-3df53e.sh
clang-12: note: diagnostic msg: 

Best,
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/20200817/1a67ebfc/attachment.html>


More information about the llvm-bugs mailing list