[llvm-bugs] [Bug 34993] New: Syntax error for "new struct" inside conditional-expression
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Oct 18 12:15:50 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34993
Bug ID: 34993
Summary: Syntax error for "new struct" inside
conditional-expression
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: zeratul976 at hotmail.com
CC: llvm-bugs at lists.llvm.org
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] http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2141
--
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/20171018/eb375cc5/attachment.html>
More information about the llvm-bugs
mailing list