You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.1 KiB
62 lines
1.1 KiB
7 years ago
|
/*
|
||
|
* Copyright (c) 2017 - present Facebook, Inc.
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This source code is licensed under the BSD style license found in the
|
||
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||
|
*/
|
||
|
#include <Foundation/Foundation.h>
|
||
|
|
||
|
int define_array_ok() {
|
||
|
size_t len = 10;
|
||
|
uint8_t a[len]; // we should not report on array definition
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int bad1() {
|
||
|
int a[10];
|
||
|
|
||
|
return a[2]; // report here as values of the array are not initialized
|
||
|
}
|
||
|
|
||
|
void use_int(int);
|
||
|
|
||
|
int bad2() {
|
||
|
int a[10];
|
||
|
use_int(a[2]); // report here as values of the array are not initialized
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int use_array_ok() {
|
||
|
int a[10];
|
||
|
a[1] = 5;
|
||
|
|
||
|
return a[1];
|
||
|
}
|
||
|
|
||
|
int initialize_array_ok1() {
|
||
|
int arr[10];
|
||
|
arr[0] = 5;
|
||
|
}
|
||
|
|
||
|
int initialize_array_ok2() {
|
||
|
int arr[] = {1, 2};
|
||
|
arr[0] = 5;
|
||
|
}
|
||
|
|
||
|
void use_array(int[]);
|
||
|
|
||
|
int pass_array_FN() {
|
||
|
int arr[5];
|
||
|
use_array(arr); // we do not report here because of intraprocedural analysi a
|
||
|
// the array passed by ref
|
||
|
}
|
||
|
|
||
|
int array_length_undef_bad() {
|
||
|
int x;
|
||
|
int arr[x];
|
||
|
}
|