[all-commits] [llvm/llvm-project] 881125: Allow use of an elaborated type specifier in a _Ge...

Aaron Ballman via All-commits all-commits at lists.llvm.org
Mon Jun 6 04:18:41 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 881125ad9178120acef186f579e36ced0888dfdb
      https://github.com/llvm/llvm-project/commit/881125ad9178120acef186f579e36ced0888dfdb
  Author: Aaron Ballman <aaron at aaronballman.com>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Parse/Parser.h
    M clang/include/clang/Sema/DeclSpec.h
    M clang/lib/Parse/ParseDecl.cpp
    M clang/lib/Parse/ParseDeclCXX.cpp
    M clang/lib/Parse/ParseExpr.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/test/Sema/generic-selection.c
    M clang/test/SemaCXX/generic-selection.cpp

  Log Message:
  -----------
  Allow use of an elaborated type specifier in a _Generic association in C++

Currently, Clang accepts this code in C mode (where the tag is required
to be used) but rejects it in C++ mode thinking that the association is
defining a new type.

void foo(void) {
  struct S { int a; };
  _Generic(something, struct S : 1);
}
Clang thinks this in C++ because it sees struct S : when parsing the
class specifier and decides that must be a type definition (because the
colon signifies the presence of a base class type). This patch adds a
new declarator context to represent a _Generic association so that we
can distinguish these situations properly.

Fixes #55562

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




More information about the All-commits mailing list