Revise -mdisable-fpregs option and add new -msoft-mult option
[official-gcc.git] / gcc / testsuite / gcc.dg / attr-access-write-only.c
blob2718b0db4564f0b99ec6d19e43e638a7b9fa0ed2
1 /* PR middle-end/83859 - attribute to establish relation between parameters
2 for buffer and its size
3 Test to verify the handling of attribute access (write_only) syntax.
4 { dg-do compile }
5 { dg-options "-Wall -ftrack-macro-expansion=0" } */
7 int __attribute__ ((access))
8 access_v (void); // { dg-error "wrong number of arguments specified for 'access' attribute" }
10 int __attribute__ ((access ()))
11 access___v (void); // { dg-error "wrong number of arguments specified for 'access' attribute" }
13 int __attribute__ ((access (wronly)))
14 wronly_spelling (void); // { dg-error "attribute .access. invalid mode 'wronly'; expected one of 'read_only', 'read_write', 'write_only', or 'none'" }
16 int __attribute__ ((access (read_only)))
17 wronly_v_all (void); // { dg-error "attribute .access\\(read_only\\). missing an argument" }
19 int __attribute__ ((access (read_only ())))
20 wronly___v_all (void); // { dg-error "attribute 'access' unexpected '\\(' after mode 'read_only'; expected a positional argument or '\\)'" }
21 // { dg-warning "implicit declaration of function 'read_only'" "" { target *-*-* } .-2 }
24 int wronly (void);
26 int __attribute__ ((access (wronly ())))
27 wronly___v_all (void); // { dg-error "attribute 'access' invalid mode 'wronly'" }
29 #define WRONLY(...) __attribute__ ((access (write_only, __VA_ARGS__)))
31 int WRONLY (1)
32 wronly_pcv_1 (void*);
33 int WRONLY (2)
34 wronly_i_pcv_2 (int, void*);
35 int WRONLY (3)
36 wronly_i_i_pcv_3 (int, int, void*);
38 int WRONLY (0 + 1)
39 wronly_pcv_0p1 (void*);
41 int WRONLY (2 - 1)
42 wronly_pcv_2m1 (void*);
44 int WRONLY (1, 1)
45 wronly_pv_pi_1_1 (void*, const int*); // { dg-error "attribute 'access\\(write_only, 1, 1\\)' positional argument 2 references non-integer argument type 'void \\*'" }
47 int WRONLY (1, 2)
48 wronly_pcv_pc_1_2 (void*, char*); // { dg-error "attribute .access\\(write_only, 1, 2\\)' positional argument 2 references non-integer argument type 'char \\*'" }
50 int WRONLY (2, 1)
51 wronly_pcd_pcv_2_1 (const double*, void*); // { dg-error "attribute .access\\(write_only, 2, 1\\)' positional argument 2 references non-integer argument type 'const double \\*'" }
53 int WRONLY (2, 2)
54 wronly_pi_pcv_2_2 (int*, void*); // { dg-error "positional argument 2 references non-integer argument type 'void \\*'" }
56 int WRONLY (4)
57 wronly_i_i_i_4 (int, int, int); // { dg-error "attribute 'access\\(write_only, 4\\)' positional argument 1 value 4 exceeds number of function arguments 3" }
59 int WRONLY (1)
60 wronly_i_1 (int); // { dg-error "attribute 'access\\(write_only, 1\\)' positional argument 1 references non-pointer argument type 'int'" }
62 int WRONLY (2)
63 wronly_i_pc (int, const char*); // { dg-error "attribute 'access\\(write_only, 2\\)' positional argument 1 references 'const'-qualified argument type 'const char \\*'" }
65 int WRONLY (-1)
66 wronly_pcv_m1 (void*); // { dg-error "attribute 'access\\(write_only, -1\\)' positional argument 1 invalid value -1" }
68 int WRONLY (1, -12345)
69 wronly_pcv_i_1_m12345 (void*, int*); // { dg-error "attribute 'access\\(write_only, 1, -12345\\)' positional argument 2 invalid value -12345" }
71 int WRONLY ("blah")
72 wronly_pcv_str (void*); // { dg-error "attribute 'access\\(write_only, \"blah\"\\)' invalid positional argument 1" }
74 int WRONLY (1, "foobar")
75 wronly_pcv_i_1_str (void*, int); // { dg-error "attribute 'access\\(write_only, 1, \"foobar\"\\)' invalid positional argument 2" }
77 // Verify that attributes whose operands reference function pointers
78 // are rejected.
79 typedef int F (int, int);
80 WRONLY (1) void wronly_pf_1 (F*); // { dg-error "attribute 'access\\(write_only, 1\\)' positional argument 1 references argument of function type 'F' \\{aka 'int\\(int, *int\\)'\\}" }
82 // Verify pointers to functions.
83 void WRONLY(2) (*pwronly_pcv2)(int, void*);
84 void WRONLY(3, 1) (*pwronly_pcv2_1)(int, void*, void*);
85 void WRONLY(1, 2) (*pwronly_i_pcv_1_2)(int, void*); // { dg-error "attribute 'access\\(write_only, 1, 2\\)' positional argument 1 references non-pointer argument type 'int'" }
87 // Verify types.
88 typedef WRONLY (2) void wronly_p2_t (const int*, char*, const void*);
89 typedef WRONLY (2) void wronly_p2_1 (int, int*);