libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / infoleak-2.c
blob43ab41b8a97b7a137dea729a7e3c5b06c6a34790
1 /* { dg-do compile } */
2 /* { dg-options "-fanalyzer" } */
3 /* { dg-require-effective-target analyzer } */
4 /* { dg-skip-if "structure layout assumption not met" { default_packed } } */
6 #include <string.h>
8 #include "test-uaccess.h"
10 typedef unsigned char u8;
11 typedef unsigned __INT16_TYPE__ u16;
12 typedef unsigned __INT32_TYPE__ u32;
14 /* Coverage for the various singular and plural forms of bits, bytes, and fields vs padding. */
16 struct st
18 u32 a; /* { dg-message "field 'a' is uninitialized \\(4 bytes\\)" } */
19 int b:1; /* { dg-message "field 'b' is uninitialized \\(1 bit\\)" "field" } */
20 /* { dg-message "padding after field 'b' is uninitialized \\(7 bits\\)" "padding" { target *-*-* } .-1 } */
21 u8 d; /* { dg-message "field 'd' is uninitialized \\(1 byte\\)" } */
22 int c:7; /* { dg-message "padding after field 'c' is uninitialized \\(9 bits\\)" } */
23 u16 e; /* { dg-message "padding after field 'e' is uninitialized \\(2 bytes\\)" } */
26 void test (void __user *dst, u16 v)
28 struct st s; /* { dg-message "region created on stack here" "where" } */
29 /* { dg-message "capacity: 12 bytes" "capacity" { target *-*-* } .-1 } */
30 /* { dg-message "suggest forcing zero-initialization by providing a '\\{0\\}' initializer" "fix-it" { target *-*-* } .-2 } */
31 s.e = v;
32 copy_to_user(dst, &s, sizeof (struct st)); /* { dg-warning "potential exposure of sensitive information by copying uninitialized data from stack" "warning" } */
33 /* { dg-message "10 bytes are uninitialized" "note how much" { target *-*-* } .-1 } */