This is an archive of the discontinued LLVM Phabricator instance.

[Sema][SVE] Flip default RequireCompleteType behavior for sizeless types
Needs ReviewPublic

Authored by rsandifo-arm on Mar 16 2020, 3:42 AM.

Details

Summary

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...}}

Diff Detail