Add __builtion_unreachable to vector::size(), vector::capacity()
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / deref-before-check-pr112790.c
blob8f74468f849b96e3d5acf0075d469f140a4dad5b
1 /* Reproducer for false positive from -Wanalyzer-deref-before-check
2 seen on Linux kernel's block/bdev.c due to -fanalyzer mishandling
3 inlined functions. */
5 /* { dg-additional-options "-O2 -g -fno-delete-null-pointer-checks" } */
7 typedef unsigned char u8;
8 struct inode {
9 void *i_mapping;
10 u8 i_blkbits;
12 struct block_device {
13 struct inode *bd_inode;
15 int sync_blockdev(struct block_device *bdev);
16 int set_blocksize(struct block_device *bdev, u8 size) {
17 if (bdev->bd_inode->i_blkbits != size) { /* { dg-bogus "pointer 'bdev' is dereferenced here" } */
18 sync_blockdev(bdev);
20 return 0;
22 extern int filemap_write_and_wait(void *);
23 int sync_blockdev(struct block_device *bdev) {
24 if (!bdev) /* { dg-bogus "check of 'bdev' for NULL after already dereferencing it" } */
25 return 0;
26 return filemap_write_and_wait(bdev->bd_inode->i_mapping);