Skip to content

Commit 28760b6

Browse files
authored
Revert "Reapply "[clang][nullability] allow _Nonnull etc on nullable class types (#82705)"" (#87041)
This reverts commit bbbcc1d. This change is causing the following build bots to fail due to a missing header file: - https://lab.llvm.org/buildbot/#/builders/188/builds/43765 - https://lab.llvm.org/buildbot/#/builders/176/builds/9428 - https://lab.llvm.org/buildbot/#/builders/187/builds/14696 - https://lab.llvm.org/buildbot/#/builders/186/builds/15551 - https://lab.llvm.org/buildbot/#/builders/182/builds/9413 - https://lab.llvm.org/buildbot/#/builders/245/builds/22507 - https://lab.llvm.org/buildbot/#/builders/258/builds/16026 - https://lab.llvm.org/buildbot/#/builders/249/builds/17221 - https://lab.llvm.org/buildbot/#/builders/38/builds/18566 - https://lab.llvm.org/buildbot/#/builders/214/builds/11735 - https://lab.llvm.org/buildbot/#/builders/231/builds/21947 - https://lab.llvm.org/buildbot/#/builders/230/builds/26675 - https://lab.llvm.org/buildbot/#/builders/57/builds/33922 - https://lab.llvm.org/buildbot/#/builders/124/builds/10311 - https://lab.llvm.org/buildbot/#/builders/109/builds/86173 - https://lab.llvm.org/buildbot/#/builders/280/builds/1043 - https://lab.llvm.org/buildbot/#/builders/283/builds/440 - https://lab.llvm.org/buildbot/#/builders/247/builds/16034 - https://lab.llvm.org/buildbot/#/builders/139/builds/62423 - https://lab.llvm.org/buildbot/#/builders/216/builds/36718 - https://lab.llvm.org/buildbot/#/builders/259/builds/2039 - https://lab.llvm.org/buildbot/#/builders/36/builds/44091 - https://lab.llvm.org/buildbot/#/builders/272/builds/12629 - https://lab.llvm.org/buildbot/#/builders/271/builds/6020 - https://lab.llvm.org/buildbot/#/builders/236/builds/10319
1 parent 610b9e2 commit 28760b6

21 files changed

+29
-226
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,21 +253,6 @@ Attribute Changes in Clang
253253
added a new extension query ``__has_extension(swiftcc)`` corresponding to the
254254
``__attribute__((swiftcc))`` attribute.
255255

256-
- The ``_Nullable`` and ``_Nonnull`` family of type attributes can now apply
257-
to certain C++ class types, such as smart pointers:
258-
``void useObject(std::unique_ptr<Object> _Nonnull obj);``.
259-
260-
This works for standard library types including ``unique_ptr``, ``shared_ptr``,
261-
and ``function``. See
262-
`the attribute reference documentation <https://llvm.org/docs/AttributeReference.html#nullability-attributes>`_
263-
for the full list.
264-
265-
- The ``_Nullable`` attribute can be applied to C++ class declarations:
266-
``template <class T> class _Nullable MySmartPointer {};``.
267-
268-
This allows the ``_Nullable`` and ``_Nonnull`` family of type attributes to
269-
apply to this class.
270-
271256
Improvements to Clang's diagnostics
272257
-----------------------------------
273258
- Clang now applies syntax highlighting to the code snippets it

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,10 +2178,9 @@ def TypeNonNull : TypeAttr {
21782178
let Documentation = [TypeNonNullDocs];
21792179
}
21802180

2181-
def TypeNullable : DeclOrTypeAttr {
2181+
def TypeNullable : TypeAttr {
21822182
let Spellings = [CustomKeyword<"_Nullable">];
21832183
let Documentation = [TypeNullableDocs];
2184-
// let Subjects = SubjectList<[CXXRecord], ErrorDiag>;
21852184
}
21862185

21872186
def TypeNullableResult : TypeAttr {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4151,20 +4151,6 @@ non-underscored keywords. For example:
41514151
@property (assign, nullable) NSView *superview;
41524152
@property (readonly, nonnull) NSArray *subviews;
41534153
@end
4154-
4155-
As well as built-in pointer types, the nullability attributes can be attached
4156-
to C++ classes marked with the ``_Nullable`` attribute.
4157-
4158-
The following C++ standard library types are considered nullable:
4159-
``unique_ptr``, ``shared_ptr``, ``auto_ptr``, ``exception_ptr``, ``function``,
4160-
``move_only_function`` and ``coroutine_handle``.
4161-
4162-
Types should be marked nullable only where the type itself leaves nullability
4163-
ambiguous. For example, ``std::optional`` is not marked ``_Nullable``, because
4164-
``optional<int> _Nullable`` is redundant and ``optional<int> _Nonnull`` is
4165-
not a useful type. ``std::weak_ptr`` is not nullable, because its nullability
4166-
can change with no visible modification, so static annotation is unlikely to be
4167-
unhelpful.
41684154
}];
41694155
}
41704156

@@ -4199,17 +4185,6 @@ The ``_Nullable`` nullability qualifier indicates that a value of the
41994185
int fetch_or_zero(int * _Nullable ptr);
42004186

42014187
a caller of ``fetch_or_zero`` can provide null.
4202-
4203-
The ``_Nullable`` attribute on classes indicates that the given class can
4204-
represent null values, and so the ``_Nullable``, ``_Nonnull`` etc qualifiers
4205-
make sense for this type. For example:
4206-
4207-
.. code-block:: c
4208-
4209-
class _Nullable ArenaPointer { ... };
4210-
4211-
ArenaPointer _Nonnull x = ...;
4212-
ArenaPointer _Nullable y = nullptr;
42134188
}];
42144189
}
42154190

clang/include/clang/Basic/Features.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ EXTENSION(define_target_os_macros,
9494
FEATURE(enumerator_attributes, true)
9595
FEATURE(nullability, true)
9696
FEATURE(nullability_on_arrays, true)
97-
FEATURE(nullability_on_classes, true)
9897
FEATURE(nullability_nullable_result, true)
9998
FEATURE(memory_sanitizer,
10099
LangOpts.Sanitize.hasOneOf(SanitizerKind::Memory |

clang/include/clang/Parse/Parser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3014,7 +3014,6 @@ class Parser : public CodeCompletionHandler {
30143014
void DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
30153015
SourceLocation SkipExtendedMicrosoftTypeAttributes();
30163016
void ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs);
3017-
void ParseNullabilityClassAttributes(ParsedAttributes &attrs);
30183017
void ParseBorlandTypeAttributes(ParsedAttributes &attrs);
30193018
void ParseOpenCLKernelAttributes(ParsedAttributes &attrs);
30203019
void ParseOpenCLQualifiers(ParsedAttributes &Attrs);

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,9 +1655,6 @@ class Sema final {
16551655
/// Add [[gsl::Pointer]] attributes for std:: types.
16561656
void inferGslPointerAttribute(TypedefNameDecl *TD);
16571657

1658-
/// Add _Nullable attributes for std:: types.
1659-
void inferNullableClassAttribute(CXXRecordDecl *CRD);
1660-
16611658
enum PragmaOptionsAlignKind {
16621659
POAK_Native, // #pragma options align=native
16631660
POAK_Natural, // #pragma options align=natural

clang/lib/AST/Type.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4642,15 +4642,16 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
46424642
case Type::Auto:
46434643
return ResultIfUnknown;
46444644

4645-
// Dependent template specializations could instantiate to pointer types.
4645+
// Dependent template specializations can instantiate to pointer
4646+
// types unless they're known to be specializations of a class
4647+
// template.
46464648
case Type::TemplateSpecialization:
4647-
// If it's a known class template, we can already check if it's nullable.
4648-
if (TemplateDecl *templateDecl =
4649-
cast<TemplateSpecializationType>(type.getTypePtr())
4650-
->getTemplateName()
4651-
.getAsTemplateDecl())
4652-
if (auto *CTD = dyn_cast<ClassTemplateDecl>(templateDecl))
4653-
return CTD->getTemplatedDecl()->hasAttr<TypeNullableAttr>();
4649+
if (TemplateDecl *templateDecl
4650+
= cast<TemplateSpecializationType>(type.getTypePtr())
4651+
->getTemplateName().getAsTemplateDecl()) {
4652+
if (isa<ClassTemplateDecl>(templateDecl))
4653+
return false;
4654+
}
46544655
return ResultIfUnknown;
46554656

46564657
case Type::Builtin:
@@ -4707,17 +4708,6 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
47074708
}
47084709
llvm_unreachable("unknown builtin type");
47094710

4710-
case Type::Record: {
4711-
const RecordDecl *RD = cast<RecordType>(type)->getDecl();
4712-
// For template specializations, look only at primary template attributes.
4713-
// This is a consistent regardless of whether the instantiation is known.
4714-
if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
4715-
return CTSD->getSpecializedTemplate()
4716-
->getTemplatedDecl()
4717-
->hasAttr<TypeNullableAttr>();
4718-
return RD->hasAttr<TypeNullableAttr>();
4719-
}
4720-
47214711
// Non-pointer types.
47224712
case Type::Complex:
47234713
case Type::LValueReference:
@@ -4735,6 +4725,7 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
47354725
case Type::DependentAddressSpace:
47364726
case Type::FunctionProto:
47374727
case Type::FunctionNoProto:
4728+
case Type::Record:
47384729
case Type::DeducedTemplateSpecialization:
47394730
case Type::Enum:
47404731
case Type::InjectedClassName:

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4379,8 +4379,7 @@ void CodeGenFunction::EmitNonNullArgCheck(RValue RV, QualType ArgType,
43794379
NNAttr = getNonNullAttr(AC.getDecl(), PVD, ArgType, ArgNo);
43804380

43814381
bool CanCheckNullability = false;
4382-
if (SanOpts.has(SanitizerKind::NullabilityArg) && !NNAttr && PVD &&
4383-
!PVD->getType()->isRecordType()) {
4382+
if (SanOpts.has(SanitizerKind::NullabilityArg) && !NNAttr && PVD) {
43844383
auto Nullability = PVD->getType()->getNullability();
43854384
CanCheckNullability = Nullability &&
43864385
*Nullability == NullabilityKind::NonNull &&

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
989989
// return value. Initialize the flag to 'true' and refine it in EmitParmDecl.
990990
if (SanOpts.has(SanitizerKind::NullabilityReturn)) {
991991
auto Nullability = FnRetTy->getNullability();
992-
if (Nullability && *Nullability == NullabilityKind::NonNull &&
993-
!FnRetTy->isRecordType()) {
992+
if (Nullability && *Nullability == NullabilityKind::NonNull) {
994993
if (!(SanOpts.has(SanitizerKind::ReturnsNonnullAttribute) &&
995994
CurCodeDecl && CurCodeDecl->getAttr<ReturnsNonNullAttr>()))
996995
RetValNullabilityPrecondition =

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,15 +1502,6 @@ void Parser::ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs) {
15021502
}
15031503
}
15041504

1505-
void Parser::ParseNullabilityClassAttributes(ParsedAttributes &attrs) {
1506-
while (Tok.is(tok::kw__Nullable)) {
1507-
IdentifierInfo *AttrName = Tok.getIdentifierInfo();
1508-
auto Kind = Tok.getKind();
1509-
SourceLocation AttrNameLoc = ConsumeToken();
1510-
attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0, Kind);
1511-
}
1512-
}
1513-
15141505
/// Determine whether the following tokens are valid after a type-specifier
15151506
/// which could be a standalone declaration. This will conservatively return
15161507
/// true if there's any doubt, and is appropriate for insert-';' fixits.
@@ -1692,21 +1683,15 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
16921683

16931684
ParsedAttributes attrs(AttrFactory);
16941685
// If attributes exist after tag, parse them.
1695-
for (;;) {
1696-
MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1697-
// Parse inheritance specifiers.
1698-
if (Tok.isOneOf(tok::kw___single_inheritance,
1699-
tok::kw___multiple_inheritance,
1700-
tok::kw___virtual_inheritance)) {
1701-
ParseMicrosoftInheritanceClassAttributes(attrs);
1702-
continue;
1703-
}
1704-
if (Tok.is(tok::kw__Nullable)) {
1705-
ParseNullabilityClassAttributes(attrs);
1706-
continue;
1707-
}
1708-
break;
1709-
}
1686+
MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1687+
1688+
// Parse inheritance specifiers.
1689+
if (Tok.isOneOf(tok::kw___single_inheritance, tok::kw___multiple_inheritance,
1690+
tok::kw___virtual_inheritance))
1691+
ParseMicrosoftInheritanceClassAttributes(attrs);
1692+
1693+
// Allow attributes to precede or succeed the inheritance specifiers.
1694+
MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
17101695

17111696
// Source location used by FIXIT to insert misplaced
17121697
// C++11 attributes

clang/lib/Sema/SemaAttr.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,6 @@ void Sema::inferGslOwnerPointerAttribute(CXXRecordDecl *Record) {
215215
inferGslPointerAttribute(Record, Record);
216216
}
217217

218-
void Sema::inferNullableClassAttribute(CXXRecordDecl *CRD) {
219-
static llvm::StringSet<> Nullable{
220-
"auto_ptr", "shared_ptr", "unique_ptr", "exception_ptr",
221-
"coroutine_handle", "function", "move_only_function",
222-
};
223-
224-
if (CRD->isInStdNamespace() && Nullable.count(CRD->getName()) &&
225-
!CRD->hasAttr<TypeNullableAttr>())
226-
for (Decl *Redecl : CRD->redecls())
227-
Redecl->addAttr(TypeNullableAttr::CreateImplicit(Context));
228-
}
229-
230218
void Sema::ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
231219
SourceLocation PragmaLoc) {
232220
PragmaMsStackAction Action = Sema::PSK_Reset;

clang/lib/Sema/SemaChecking.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "clang/AST/ExprObjC.h"
2828
#include "clang/AST/ExprOpenMP.h"
2929
#include "clang/AST/FormatString.h"
30-
#include "clang/AST/IgnoreExpr.h"
3130
#include "clang/AST/NSAPI.h"
3231
#include "clang/AST/NonTrivialTypeVisitor.h"
3332
#include "clang/AST/OperationKinds.h"
@@ -7610,14 +7609,6 @@ bool Sema::getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
76107609
///
76117610
/// Returns true if the value evaluates to null.
76127611
static bool CheckNonNullExpr(Sema &S, const Expr *Expr) {
7613-
// Treat (smart) pointers constructed from nullptr as null, whether we can
7614-
// const-evaluate them or not.
7615-
// This must happen first: the smart pointer expr might have _Nonnull type!
7616-
if (isa<CXXNullPtrLiteralExpr>(
7617-
IgnoreExprNodes(Expr, IgnoreImplicitAsWrittenSingleStep,
7618-
IgnoreElidableImplicitConstructorSingleStep)))
7619-
return true;
7620-
76217612
// If the expression has non-null type, it doesn't evaluate to null.
76227613
if (auto nullability = Expr->IgnoreImplicit()->getType()->getNullability()) {
76237614
if (*nullability == NullabilityKind::NonNull)

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18317,10 +18317,8 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
1831718317
if (PrevDecl)
1831818318
mergeDeclAttributes(New, PrevDecl);
1831918319

18320-
if (auto *CXXRD = dyn_cast<CXXRecordDecl>(New)) {
18320+
if (auto *CXXRD = dyn_cast<CXXRecordDecl>(New))
1832118321
inferGslOwnerPointerAttribute(CXXRD);
18322-
inferNullableClassAttribute(CXXRD);
18323-
}
1832418322

1832518323
// If there's a #pragma GCC visibility in scope, set the visibility of this
1832618324
// record.

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5982,20 +5982,6 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
59825982
D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
59835983
}
59845984

5985-
static void handleNullableTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5986-
if (AL.isUsedAsTypeAttr())
5987-
return;
5988-
5989-
if (auto *CRD = dyn_cast<CXXRecordDecl>(D);
5990-
!CRD || !(CRD->isClass() || CRD->isStruct())) {
5991-
S.Diag(AL.getRange().getBegin(), diag::err_attribute_wrong_decl_type_str)
5992-
<< AL << AL.isRegularKeywordAttribute() << "classes";
5993-
return;
5994-
}
5995-
5996-
handleSimpleAttribute<TypeNullableAttr>(S, D, AL);
5997-
}
5998-
59995985
static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
60005986
if (!AL.hasParsedType()) {
60015987
S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
@@ -9947,10 +9933,6 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
99479933
case ParsedAttr::AT_UsingIfExists:
99489934
handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL);
99499935
break;
9950-
9951-
case ParsedAttr::AT_TypeNullable:
9952-
handleNullableTypeAttr(S, D, AL);
9953-
break;
99549936
}
99559937
}
99569938

clang/lib/Sema/SemaInit.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7079,11 +7079,6 @@ PerformConstructorInitialization(Sema &S,
70797079
hasCopyOrMoveCtorParam(S.Context,
70807080
getConstructorInfo(Step.Function.FoundDecl));
70817081

7082-
// A smart pointer constructed from a nullable pointer is nullable.
7083-
if (NumArgs == 1 && !Kind.isExplicitCast())
7084-
S.diagnoseNullableToNonnullConversion(
7085-
Entity.getType(), Args.front()->getType(), Kind.getLocation());
7086-
70877082
// Determine the arguments required to actually perform the constructor
70887083
// call.
70897084
if (S.CompleteConstructorCall(Constructor, Step.Type, Args, Loc,

clang/lib/Sema/SemaOverload.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14811,13 +14811,6 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
1481114811
}
1481214812
}
1481314813

14814-
// Check for nonnull = nullable.
14815-
// This won't be caught in the arg's initialization: the parameter to
14816-
// the assignment operator is not marked nonnull.
14817-
if (Op == OO_Equal)
14818-
diagnoseNullableToNonnullConversion(Args[0]->getType(),
14819-
Args[1]->getType(), OpLoc);
14820-
1482114814
// Convert the arguments.
1482214815
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
1482314816
// Best->Access is only meaningful for class members.

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,6 @@ DeclResult Sema::CheckClassTemplate(
21712171

21722172
AddPushedVisibilityAttribute(NewClass);
21732173
inferGslOwnerPointerAttribute(NewClass);
2174-
inferNullableClassAttribute(NewClass);
21752174

21762175
if (TUK != TUK_Friend) {
21772176
// Per C++ [basic.scope.temp]p2, skip the template parameter scopes.

clang/lib/Sema/SemaType.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4717,18 +4717,6 @@ static bool DiagnoseMultipleAddrSpaceAttributes(Sema &S, LangAS ASOld,
47174717
return false;
47184718
}
47194719

4720-
// Whether this is a type broadly expected to have nullability attached.
4721-
// These types are affected by `#pragma assume_nonnull`, and missing nullability
4722-
// will be diagnosed with -Wnullability-completeness.
4723-
static bool shouldHaveNullability(QualType T) {
4724-
return T->canHaveNullability(/*ResultIfUnknown=*/false) &&
4725-
// For now, do not infer/require nullability on C++ smart pointers.
4726-
// It's unclear whether the pragma's behavior is useful for C++.
4727-
// e.g. treating type-aliases and template-type-parameters differently
4728-
// from types of declarations can be surprising.
4729-
!isa<RecordType>(T->getCanonicalTypeInternal());
4730-
}
4731-
47324720
static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
47334721
QualType declSpecType,
47344722
TypeSourceInfo *TInfo) {
@@ -4847,7 +4835,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
48474835
// inner pointers.
48484836
complainAboutMissingNullability = CAMN_InnerPointers;
48494837

4850-
if (shouldHaveNullability(T) && !T->getNullability()) {
4838+
if (T->canHaveNullability(/*ResultIfUnknown*/ false) &&
4839+
!T->getNullability()) {
48514840
// Note that we allow but don't require nullability on dependent types.
48524841
++NumPointersRemaining;
48534842
}
@@ -5070,7 +5059,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
50705059
// If the type itself could have nullability but does not, infer pointer
50715060
// nullability and perform consistency checking.
50725061
if (S.CodeSynthesisContexts.empty()) {
5073-
if (shouldHaveNullability(T) && !T->getNullability()) {
5062+
if (T->canHaveNullability(/*ResultIfUnknown*/ false) &&
5063+
!T->getNullability()) {
50745064
if (isVaList(T)) {
50755065
// Record that we've seen a pointer, but do nothing else.
50765066
if (NumPointersRemaining > 0)

clang/test/Sema/nullability.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,3 @@ void arraysInBlocks(void) {
248248
void (^withTypedefBad)(INTS _Nonnull [2]) = // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'INTS' (aka 'int[4]')}}
249249
^(INTS _Nonnull x[2]) {}; // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'INTS' (aka 'int[4]')}}
250250
}
251-
252-
struct _Nullable NotCplusplusClass {}; // expected-error {{'_Nullable' attribute only applies to classes}}

0 commit comments

Comments
 (0)