mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 20:36:06 +00:00

The diagnostic was confusing and reporting that an array contains far more elements than it is defined to have, due to casting. For example, this code: double foo[4096]; ((char*)foo)[sizeof(foo)]; warns that the "index 32768 is past the end of the array (which contains 32768 elements)." Reviewed By: serge-sans-paille, aaron.ballman Differential Revision: https://reviews.llvm.org/D135920
27 lines
571 B
Objective-C
27 lines
571 B
Objective-C
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
// expected-no-diagnostics
|
|
//
|
|
// RUN: %clang_cc1 -fsyntax-only -fstrict-flex-arrays=2 -verify=warn %s
|
|
|
|
@interface Flexible {
|
|
@public
|
|
char flexible[];
|
|
}
|
|
@end
|
|
|
|
@interface Flexible0 {
|
|
@public
|
|
char flexible[0];
|
|
}
|
|
@end
|
|
|
|
@interface Flexible1 {
|
|
@public
|
|
char flexible[1];
|
|
}
|
|
@end
|
|
|
|
char readit(Flexible *p) { return p->flexible[2]; }
|
|
char readit0(Flexible0 *p) { return p->flexible[2]; }
|
|
char readit1(Flexible1 *p) { return p->flexible[2]; } // warn-warning {{array index 2 is past the end of the array (that has type 'char[1]')}}
|