mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 19:16:40 +00:00

Old GCC used to aggressively fold VLAs to constant-bound arrays at block scope in GNU mode. That's non-conforming, and more modern versions of GCC only do this at file scope. Update Clang to do the same. Also promote the warning for this from off-by-default to on-by-default in all cases; more recent versions of GCC likewise warn on this by default. This is still slightly more permissive than GCC, as pointed out in PR44406, as we still fold VLAs to constant arrays in structs, but that seems justifiable given that we don't support VLA-in-struct (and don't intend to ever support it), but GCC does. Differential Revision: https://reviews.llvm.org/D89523
26 lines
1.1 KiB
Objective-C
26 lines
1.1 KiB
Objective-C
// RUN: %clang_cc1 -verify -Wno-pointer-to-int-cast -Wno-objc-root-class %s
|
|
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
|
|
typedef struct _NSRange { } NSRange;
|
|
|
|
@class PBXFileReference;
|
|
|
|
@interface PBXDocBookmark
|
|
+ alloc; // expected-note {{method 'alloc' declared here}}
|
|
- autorelease; // expected-note {{method 'autorelease' declared here}}
|
|
@end
|
|
|
|
// GCC allows pointer expressions in integer constant expressions.
|
|
struct {
|
|
char control[((int)(char *)2)]; // expected-warning {{extension}}
|
|
} xx;
|
|
|
|
@implementation PBXDocBookmark // expected-warning {{method definition for 'autorelease' not found}}\
|
|
// expected-warning {{method definition for 'alloc' not found}}
|
|
|
|
+ (id)bookmarkWithFileReference:(PBXFileReference *)fileRef gylphRange:(NSRange)range anchor:(NSString *)htmlAnchor
|
|
{
|
|
NSRange r = (NSRange)range;
|
|
return [[[self alloc] initWithFileReference:fileRef gylphRange:(NSRange)range anchor:(NSString *)htmlAnchor] autorelease]; // expected-warning {{method '-initWithFileReference:gylphRange:anchor:' not found (return type defaults to 'id')}}
|
|
}
|
|
@end
|