[PATCH] D133574: [C2x] reject type definitions in offsetof

YingChi Long via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 26 18:01:51 PDT 2022


inclyc updated this revision to Diff 463063.
inclyc added a comment.

This revision fixes:

**anonymous struct**

> You should be able to pass in the TagDecl directly because the diagnostics
> engine knows how to print a NamedDecl.

I've switch back to using `Context.getTagDeclType(New)` because this can print
anonymous pretty.

  clang/test/C/C2x/n2350.c:23:29: error: 'struct (unnamed at clang/test/C/C2x/n2350.c:23:29)' cannot be defined in '__builtin_offsetof'
    return __builtin_offsetof(struct // expected-error-re{{'struct (unnamed at {{.*}})' cannot be defined in '__builtin_offsetof'}}

**definitions within the second parameter**

I've add a new test case for this. This bug is caused by the RAIIObject having
incorrect scope.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133574/new/

https://reviews.llvm.org/D133574

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Parse/RAIIObjectsForParser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/C/C2x/n2350.c
  clang/test/Parser/declarators.c
  clang/test/SemaCXX/offsetof.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133574.463063.patch
Type: text/x-patch
Size: 13153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220927/a847331f/attachment.bin>


More information about the cfe-commits mailing list