[PATCH] D76221: [Sema][SVE] Flip default RequireCompleteType behavior for sizeless types
    Richard Sandiford via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Mon Mar 16 03:53:25 PDT 2020
    
    
  
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, danielkiss, psnobl, jfb, rkruppe, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
rsandifo-arm added a parent revision: D76219: [Sema][SVE] Reject "delete" with sizeless types.
Sizeless types are defined to be a form of incomplete type, but with
more relaxed rules in certain cases.  Previous patches in the series
took the following approach:
- Add tests for things that are explicitly supposed to be valid for sizeless types and that clang already handled correctly.
- Add diagnostics for things that are explicitly supposed to be invalid for sizeless types, in many cases inheriting the same rules as for incomplete types.
For any other cases, we should conservatively treat sizeless types as
in the same way as incomplete types.  This patch therefore flips the
default behavior for RequireCompleteType and co.  Callers that want
to accept sizeless types must then explicitly pass AcceptSizeless.
The Sema::BuildObjCEncodeExpression change is needed to keep
clang/test/CodeGenObjC/aarch64-sve-types.m passing.  If @encoding a
sizeless type will never be useful, we could enforce that here instead.
For reference, here's a list of every other function that now passes
AcceptSizeless, along with one example line from Sema/sizeless-1.c
or SemaCXX/sizeless-1.cpp that would regress without the change.
- CastOperation::CheckCStyleCast
  local_int8 = (svint8_t)0; // expected-error {{...arithmetic or pointer type is required...}}
- Sema::CheckParmsForFunctionDef
  int vararg_receiver(int count, svint8_t first, ...) {
- Sema::AddInitializerToDecl
  svint8_t init_int8 = local_int8;
- Sema::ActOnInitializerError
  svint8_t bad_init_int8 = for; // expected-error {{expected expression}}
- Sema::ActOnUninitializedDecl
  svint8_t local_int8;
- Sema::ActOnStartOfFunctionDef
  svint8_t ret_bad_conv() { return explicit_conv(); }
- Sema::SetParamDefaultArgument
  void with_default(svint8_t = svint8_t());
- Sema::BuildExceptionDeclaration
  } catch (svint8_t) { // expected-error {{...sizeless type...}}
- Sema::CheckSpecifiedExceptionType
  void throwing_func() throw(svint8_t); // expected-error {{...sizeless...}}
- Sema::DefaultVariadicArgumentPromotion
  varargs(1, local_int8, local_int16);
- Sema::GatherArgumentsForCall
  pass_int8(local_int8);
- Sema::BuildResolvedCallExpr
  noproto(local_int8);
- CheckCommaOperands
  0, local_int8;
- Sema::BuildVAArgExpr
  __builtin_va_arg(va, svint8_t);
- Sema::CheckCXXThrowOperand
  throw local_int8; // expected-error {{...sizeless type...}}
- Sema::BuildCXXTypeConstructExpr
  void with_default(svint8_t = svint8_t());
- CheckUnaryTypeTraitTypeCompleteness
  _Static_assert(__is_trivially_destructible(svint8_t), "");
- evaluateTypeTrait
  _Static_assert(__is_constructible(svint8_t), "");
- EvaluateBinaryTypeTrait
  _Static_assert(__is_convertible_to(svint8_t, svint8_t), ""); _Static_assert(!__is_assignable(svint8_t, svint8_t), "");
- Sema::IgnoredValueConversions
  (void)local_int8;
- CopyObject
  widget w(1);
- InitializationSequence::Diagnose
  svint8_t ret_bad_conv() { return explicit_conv(); }
- Sema::buildLambdaScope
  local_int8 = ([]() { return svint8_t(); })();
- TryListConversion
  template_fn_direct<svint8_t>({wrapper<svint8_t>()});
- Sema::AddConversionCandidate
  local_int8 = wrapper<svint8_t>();
- Sema::BuildCXXForRangeStmt
  for (auto x : local_int8) {
- Sema::BuildAtomicType
  _Atomic svint8_t atomic_int8; // expected-error {{...sizeless...}}
Repository:
  rG LLVM Github Monorepo
https://reviews.llvm.org/D76221
Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaType.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76221.250505.patch
Type: text/x-patch
Size: 19818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200316/b69702f9/attachment-0001.bin>
    
    
More information about the cfe-commits
mailing list