[PATCH] D153857: [clang] Fix new-expression with elaborated-type-specifier

Mariya Podchishchaeva via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 27 04:47:33 PDT 2023


Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Expressions like

  new struct A {};
  struct A* b = (1 == 1) ? new struct A : new struct A;
  ``
  Were parsed as definitions of `struct A` and failed, however as clarified by
  `CWG2141` new-expression cannot define a type, so both these examples
  should be considered as valid.
  The patch adds a "new" kind context for parsing declaration specifiers in
  addition to already existing declarator context in order to track that
  the parser is inside of a new expression.
  
  Fixes https://github.com/llvm/llvm-project/issues/34341


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153857

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
  clang/test/CXX/drs/dr19xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/Parser/cxx11-type-specifier.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153857.534912.patch
Type: text/x-patch
Size: 7494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230627/a1f2ea2a/attachment-0001.bin>


More information about the cfe-commits mailing list