<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Syntax error for "new struct" inside conditional-expression"
   href="https://bugs.llvm.org/show_bug.cgi?id=34993">34993</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Syntax error for "new struct" inside conditional-expression
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>zeratul976@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This code does not compile with clang:

struct A {};
struct A* b = (1 == 1) ? new struct A : new struct A;

The error message suggests that it's trying to parse "struct A :" as a
class-specifier, with the ":" starting the base-clause.

I believe that this is valid, at least since DR 2141 [1], which introduced the
"defining-type-specifier" grammar production. A "new-type-id" can only contain
a "type-specifier", not a "defining-type-specifier", and a "class-specifier" is
only valid as a "defining-type-specifier", so I don't believe clang should be
trying to parse a "class-specifier" at all. (Instead, the "struct A" should be
parsed as an "elaborate-type-specifier", which is a valid "type-specifier".)

(I'm not convinced that the code was invalid even before DR 2141 - I would have
thought that, having tried and failed to parse a "class-specifier", the
compiler would backtrack and try to parse an "elaborate-type-specifier" instead
- but I'm less confident about that.)

[1] <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2141">http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2141</a></pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>