History

Fix type compatiblity of enums and ints

an enum must be compatible with one or more integer type, so adjust the test accordingly. That means the following redeclarations should work: enum e6 { E1 = -1, E0 }; void f3(enum e6); void f3(int); // should work as int and e6 are compatible while the following should not: void f4(enum e6 e); void f4(unsigned e); // should error as unsigned and e6 are incompatible

Michael Matz committed 6 years ago

Commit 9eef3391 parent 068d5b33 files · +41 −29Browse files

Showing the changes to tests (2 of 3 files). Show all

Unified · Split

2 files
  1. tests/tests2/60_errors_and_warnings.c +7 −0
  2. tests/tests2/60_errors_and_warnings.expect +31 −28
tests/tests2/60_errors_and_warnings.c+7−0
@@ -118,6 +118,13 @@ enum e5; · 117 unmodified lines
118118 void f3(enum e4 e);
119119 void f3(enum e5 e);
120120
121+#elif defined test_enum_compat_2
122+enum e6 { E1 = -1, E0 };
123+void f3(enum e6);
124+void f3(int); // should work as int and e6 are compatible
125+void f4(enum e6 e);
126+void f4(unsigned e); // should error as unsigned and e6 are incompatible
127+
121128 #elif defined test_ptr_to_str
122129 void f() { _Generic((int const *[]){0}, int:0); }
123130 #elif defined test_fnptr_to_str
tests/tests2/60_errors_and_warnings.expect+31−28
@@ -46,73 +46,76 @@ · 45 unmodified lines
4646 [test_enum_compat]
4747 60_errors_and_warnings.c:119: error: incompatible types for redefinition of 'f3'
4848
49+[test_enum_compat_2]
50+60_errors_and_warnings.c:126: error: incompatible types for redefinition of 'f4'
51+
4952 [test_ptr_to_str]
50−60_errors_and_warnings.c:122: error: type 'const int **' does not match any association
53+60_errors_and_warnings.c:129: error: type 'const int **' does not match any association
5154
5255 [test_fnptr_to_str]
53−60_errors_and_warnings.c:124: error: type 'int (*(*)(float, char))(double, int)' does not match any association
56+60_errors_and_warnings.c:131: error: type 'int (*(*)(float, char))(double, int)' does not match any association
5457
5558 [test_array_to_str]
56−60_errors_and_warnings.c:126: error: type 'int (*)[3]' does not match any association
59+60_errors_and_warnings.c:133: error: type 'int (*)[3]' does not match any association
5760
5861 [test_duplicate_def_1]
59−60_errors_and_warnings.c:128: error: redefinition of 'L'
62+60_errors_and_warnings.c:135: error: redefinition of 'L'
6063
6164 [test_duplicate_def_2]
62−60_errors_and_warnings.c:131: error: redeclaration of 'L'
65+60_errors_and_warnings.c:138: error: redeclaration of 'L'
6366
6467 [test_abstract_decls]
65−60_errors_and_warnings.c:141: error: identifier expected
68+60_errors_and_warnings.c:148: error: identifier expected
6669
6770 [test_invalid_1]
68−60_errors_and_warnings.c:146: error: identifier expected
71+60_errors_and_warnings.c:153: error: identifier expected
6972
7073 [test_invalid_2]
71−60_errors_and_warnings.c:149: error: ';' expected (got "{")
74+60_errors_and_warnings.c:156: error: ';' expected (got "{")
7275
7376 [test_invalid_3]
74−60_errors_and_warnings.c:153: error: ',' expected (got "a")
77+60_errors_and_warnings.c:160: error: ',' expected (got "a")
7578
7679 [test_invalid_4]
77−60_errors_and_warnings.c:157: error: division by zero in constant
80+60_errors_and_warnings.c:164: error: division by zero in constant
7881
7982 [test_conflicting_types]
80−60_errors_and_warnings.c:163: error: incompatible types for redefinition of 'i'
83+60_errors_and_warnings.c:170: error: incompatible types for redefinition of 'i'
8184
8285 [test_nested_types]
83−60_errors_and_warnings.c:170: error: struct/union/enum already defined
86+60_errors_and_warnings.c:177: error: struct/union/enum already defined
8487
8588 [test_vla_1]
86−60_errors_and_warnings.c:177: error: need explicit inner array size in VLAs
89+60_errors_and_warnings.c:184: error: need explicit inner array size in VLAs
8790
8891 [test_invalid_alignas]
89−60_errors_and_warnings.c:181: error: identifier expected
92+60_errors_and_warnings.c:188: error: identifier expected
9093
9194 [test_static_assert]
92−60_errors_and_warnings.c:187: error: ONE is not 1
95+60_errors_and_warnings.c:194: error: ONE is not 1
9396
9497 [test_static_assert_2]
95−60_errors_and_warnings.c:191: error: 0 is 0
98+60_errors_and_warnings.c:198: error: 0 is 0
9699
97100 [test_static_assert_c2x]
98−60_errors_and_warnings.c:195: error: _Static_assert fail
101+60_errors_and_warnings.c:202: error: _Static_assert fail
99102
100103 [test_void_array]
101−60_errors_and_warnings.c:198: error: declaration of an array of incomplete type elements
104+60_errors_and_warnings.c:205: error: declaration of an array of incomplete type elements
102105
103106 [test_incomplete_enum_array]
104−60_errors_and_warnings.c:201: error: declaration of an array of incomplete type elements
107+60_errors_and_warnings.c:208: error: declaration of an array of incomplete type elements
105108
106109 [test_incomplete_struct_array]
107−60_errors_and_warnings.c:204: error: declaration of an array of incomplete type elements
110+60_errors_and_warnings.c:211: error: declaration of an array of incomplete type elements
108111
109112 [test_const_fun_array]
110−60_errors_and_warnings.c:208: error: declaration of an array of functions
113+60_errors_and_warnings.c:215: error: declaration of an array of functions
111114
112115 [test_incomplete_array_array]
113116
114117 [test_extern_array]
115−60_errors_and_warnings.c:224: error: incompatible types for redefinition of 'x'
118+60_errors_and_warnings.c:231: error: incompatible types for redefinition of 'x'
116119
117120 [test_func_1]
118121 hello: a = 123
@@ -121,17 +124,17 @@ hello: a = 123 · 2 unmodified lines
121124 hello: a = 123
122125
123126 [test_func_3]
124−60_errors_and_warnings.c:254: warning: static storage ignored for redefinition of 'hello'
127+60_errors_and_warnings.c:261: warning: static storage ignored for redefinition of 'hello'
125128 hello: a = 123
126129
127130 [test_func_4]
128131 hello: a = 123
129132
130133 [test_func_5]
131−60_errors_and_warnings.c:254: error: incompatible types for redefinition of 'hello'
134+60_errors_and_warnings.c:261: error: incompatible types for redefinition of 'hello'
132135
133136 [test_func_6]
134−60_errors_and_warnings.c:242: error: function without file scope cannot be static
137+60_errors_and_warnings.c:249: error: function without file scope cannot be static
135138
136139 [test_var_1]
137140 main : 1 ; 1
@@ -144,12 +147,12 @@ main : 2 ; 2 · 6 unmodified lines
144147 bar : 3 ; 3
145148
146149 [test_var_3]
147−60_errors_and_warnings.c:286: error: incompatible types for redefinition of 'xxx'
150+60_errors_and_warnings.c:293: error: incompatible types for redefinition of 'xxx'
148151
149152 [test_var_4]
150153
151154 [test_long_double_type_for_win32]
152−60_errors_and_warnings.c:317: warning: assignment from incompatible pointer type
155+60_errors_and_warnings.c:324: warning: assignment from incompatible pointer type
153156
154157 [test_stray_backslash]
155−60_errors_and_warnings.c:323: error: stray '\' in program
158+60_errors_and_warnings.c:330: error: stray '\' in program

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t