[llvm-bugs] [Bug 50122] New: Parser::ParseCastExpression - dodgy unused write

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 26 04:03:27 PDT 2021


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

            Bug ID: 50122
           Summary: Parser::ParseCastExpression - dodgy unused write
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: llvm-bugs at lists.llvm.org, martongabesz at gmail.com,
                    neeilans at live.com, richard-llvm at metafoo.co.uk,
                    saar at raz.email

The static analyzer is warning about an unread variable write in
Parser::ParseCastExpression:

  switch (SavedKind) {
  case tok::l_paren: {
    // If this expression is limited to being a unary-expression, the paren can
    // not start a cast expression.
    ParenParseOption ParenExprType;
    switch (ParseKind) {
      case CastParseKind::UnaryExprOnly:
        if (!getLangOpts().CPlusPlus)
          ParenExprType = CompoundLiteral; // <<<< UNUSED WRITE WARNING
        LLVM_FALLTHROUGH;
      case CastParseKind::AnyCastExpr:
        ParenExprType = ParenParseOption::CastExpr;
        break;
      case CastParseKind::PrimaryExprOnly:
        ParenExprType = FoldExpr;
        break;
    }

This looks like it was introduced in https://reviews.llvm.org/D43357

Before that the code looked like:

ParenParseOption ParenExprType =
        (isUnaryExpression && !getLangOpts().CPlusPlus) ? CompoundLiteral
                                                        : CastExpr;
So maybe we're missing a break ?

-- 
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/20210426/81804a1c/attachment-0001.html>


More information about the llvm-bugs mailing list