[llvm-bugs] [Bug 44997] New: Parser crashes with invalid syntax

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Feb 22 13:30:35 PST 2020


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

            Bug ID: 44997
           Summary: Parser crashes with invalid syntax
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolas.alvarez at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Created attachment 23163
  --> https://bugs.llvm.org/attachment.cgi?id=23163&action=edit
Stack dump of crash

While reducing a test case with creduce, I ended up with a totally unrelated
crash than what I was looking for.

The following 9 tokens of invalid code abort the clang parser by executing an
llvm_unreachable statement:


class {
   a(struct b
  struct b   ;


The newlines are apparently significant. Since it's an llvm_unreachable, you
need asserts enabled to reproduce.

Output:

$ clang++ -fsyntax-only viewmodeE.cpp
viewmodeE.cpp:2:14: error: expected ';' after struct
   a(struct b
             ^
             ;                                                                  
viewmodeE.cpp:3:3: error: expected ')'
  struct b   ;
  ^
viewmodeE.cpp:2:5: note: to match this '('
   a(struct b
    ^
viewmodeE.cpp:2:4: error: C++ requires a type specifier for all declarations
   a(struct b
   ^
viewmodeE.cpp:3:10: error: 'b' redeclared with 'private' access
  struct b   ;
         ^
Invalid access specifier!
UNREACHABLE executed at ../llvm/tools/clang/lib/AST/DeclCXX.cpp:3165!


I bisected the crash back to this commit from 2016(!):
https://github.com/llvm/llvm-project/commit/078aea904331271c3fdc65b52d128a8acefe4e38

Full stack trace attached.

-- 
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/20200222/4f9db5ac/attachment.html>


More information about the llvm-bugs mailing list