[all-commits] [llvm/llvm-project] 4a792e: [clang] Fix new-expression with elaborated-type-sp...

Mariya Podchishchaeva via All-commits all-commits at lists.llvm.org
Mon Jul 3 03:13:53 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4a792e06e8e72f4c14e5a5251e71051d7a984820
  Author: Mariya Podchishchaeva <mariya.podchishchaeva at intel.com>
  Date:   2023-07-03 (Mon, 03 Jul 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Parse/Parser.h
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Parse/ParseExprCXX.cpp
    M clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp
    M clang/test/CXX/drs/dr19xx.cpp
    M clang/test/CXX/drs/dr21xx.cpp
    M clang/test/CXX/drs/dr6xx.cpp
    M clang/test/Parser/cxx11-type-specifier.cpp
    M clang/www/cxx_dr_status.html

  Log Message:
  [clang] Fix new-expression with elaborated-type-specifier

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

were parsed as redefinitions of `struct A` and failed, however as clarified by
`CWG2141` new-expression cannot define a type, so both these examples
should be considered as references to the previously declared `struct A`.
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

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D153857

More information about the All-commits mailing list