llvm-project/clang/lib
Volodymyr Sapsai 30680e9437 [Sema] Add support for flexible array members in Obj-C.
Allow Obj-C ivars with incomplete array type but only as the last ivar.
Also add a requirement for ivars that contain a flexible array member to
be at the end of class too. It is possible to add in a subclass another
ivar at the end but we'll emit a warning in this case. Also we'll emit a
warning if a variable sized ivar is declared in class extension or in
implementation because subclasses won't know they should avoid adding
new ivars.

In ARC incomplete array objects are treated as __unsafe_unretained so
require them to be marked as such.

Prohibit synthesizing ivars with flexible array members because order of
synthesized ivars is not obvious and tricky to control. Spelling out
ivar explicitly gives control to developers and helps to avoid surprises
with unexpected ivar ordering.

For C and C++ changed diagnostic to tell explicitly a field is not the
last one and point to the next field. It is not as useful as in Obj-C
but it is an improvement and it is consistent with Obj-C. For C for
unions emit more specific err_flexible_array_union instead of generic
err_field_incomplete.

rdar://problem/21054495

Reviewers: rjmccall, theraven

Reviewed By: rjmccall

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D38773

llvm-svn: 316381
2017-10-23 22:01:41 +00:00
..
ARCMigrate Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC. 2017-06-03 06:23:19 +00:00
AST For better compatibility with C++11 and C++14, emit a nondiscardable definition 2017-10-23 03:58:34 +00:00
ASTMatchers [ASTMatchers] Expose forEachOverriden in dynamic AST matchers. 2017-10-23 16:48:46 +00:00
Analysis [Analyzer] Correctly handle parameters passed by reference when bodyfarming std::call_once 2017-10-20 23:29:59 +00:00
Basic Pull X86 "CPUKind" checking into .cpp file. [NFC] 2017-10-23 16:20:15 +00:00
CodeGen [OpenMP] Avoid VLAs for some reductions on array sections 2017-10-23 19:01:35 +00:00
CrossTU Fix implicit-fallthrough warning by adding missing break 2017-09-24 15:17:46 +00:00
Driver [Driver] Use ld.lld directly for Fuchsia rather than passing flavor 2017-10-23 21:31:05 +00:00
Edit [clang] Fix format specifiers fixits for nested macros 2017-06-20 20:46:58 +00:00
Format [clang-format] Sort whole block of using declarations while partially formatting 2017-10-18 22:13:25 +00:00
Frontend Create fewer copies of StringMaps. No functionality change intended. 2017-10-22 20:16:28 +00:00
FrontendTool [CMake] Use #cmakedefine01 for CLANG_ENABLE_(ARCMT|OBJC_REWRITER|STATIC_ANALYZER) 2017-10-18 05:21:17 +00:00
Headers [Headers] Fix typoed __ARM_DWARF_EH__ ifdefs 2017-10-19 07:40:45 +00:00
Index Fix indexer crash for default template template parameter value 2017-10-10 21:09:49 +00:00
Lex Add -f[no-]double-square-bracket-attributes as new driver options to control use of [[]] attributes in all language modes. This is the initial implementation of WG14 N2165, which is a proposal to add [[]] attributes to C2x, but also allows you to enable these attributes in C++98, or disable them in C++11 or later. 2017-10-15 15:01:42 +00:00
Parse Create fewer copies of StringMaps. No functionality change intended. 2017-10-22 20:16:28 +00:00
Rewrite [Analyzer] Add support for displaying cross-file diagnostic paths in HTML output 2017-08-03 18:12:22 +00:00
Sema [Sema] Add support for flexible array members in Obj-C. 2017-10-23 22:01:41 +00:00
Serialization [C++17] Fix PR34970 - tweak overload resolution for class template deduction-guides in line with WG21's p0620r0. 2017-10-22 14:45:08 +00:00
StaticAnalyzer [analyzer] Dump signed integers in SymIntExpr and IntSymExpr correctly 2017-10-19 11:58:21 +00:00
Tooling [rename] Don't overwrite the template argument when renaming a template function. 2017-10-23 08:58:50 +00:00
CMakeLists.txt Add Cross Translation Unit support library 2017-09-22 11:11:01 +00:00