]> granicus.if.org Git - clang/commit
Accept nullability qualifiers on array parameters.
authorJordan Rose <jordan_rose@apple.com>
Thu, 10 Nov 2016 23:28:17 +0000 (23:28 +0000)
committerJordan Rose <jordan_rose@apple.com>
Thu, 10 Nov 2016 23:28:17 +0000 (23:28 +0000)
commitb0eb2871c6471b7f99a3d8a25300fb57bb266804
tree2c6fd71e980adde808d2a0d71f150eecb01f43de
parentb5e3c67b858c2adac4e334b819c9af0873262796
Accept nullability qualifiers on array parameters.

Since array parameters decay to pointers, '_Nullable' and friends
should be available for use there as well. This is especially
important for parameters that are typedefs of arrays. The unsugared
syntax for this follows the syntax for 'static'-sized arrays in C:

  void test(int values[_Nullable]);

This syntax was previously accepted but the '_Nullable' (and any other
attributes) were silently discarded. However, applying '_Nullable' to
a typedef was previously rejected and is now accepted; therefore, it
may be necessary to test for the presence of this feature:

  #if __has_feature(nullability_on_arrays)

One important change here is that DecayedTypes don't always
immediately contain PointerTypes anymore; they may contain an
AttributedType instead. This only affected one place in-tree, so I
would guess it's not likely to cause problems elsewhere.

This commit does not change -Wnullability-completeness just yet. I
want to think about whether it's worth doing something special to
avoid breaking existing clients that compile with -Werror. It also
doesn't change '#pragma clang assume_nonnull' behavior, which
currently treats the following two declarations as equivalent:

  #pragma clang assume_nonnull begin
  void test(void *pointers[]);
  #pragma clang assume_nonnull end

  void test(void * _Nonnull pointers[]);

This is not the desired behavior, but changing it would break
backwards-compatibility. Most likely the best answer is going to be
adding a new warning.

Part of rdar://problem/25846421

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286519 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/Type.h
include/clang/Sema/Sema.h
lib/AST/ASTContext.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Parse/ParseDecl.cpp
lib/Sema/SemaType.cpp
test/Parser/nullability.c
test/Sema/nullability.c
test/SemaCXX/nullability.cpp
test/SemaObjC/nullability.m