File tree 6 files changed +57
-7
lines changed
regression/ansi-c/forceinline1
6 files changed +57
-7
lines changed Original file line number Diff line number Diff line change
1
+ #line 1 "test.c"
2
+
3
+ __inline int foo ()
4
+ {
5
+ return 0 ;
6
+ }
7
+
8
+ __forceinline int foo ()
9
+ {
10
+ return 1 ;
11
+ }
12
+
13
+ int main ()
14
+ {
15
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.i
3
+ --i386-win32
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ --
7
+ ^warning: ignoring
8
+ ^CONVERSION ERROR$
Original file line number Diff line number Diff line change @@ -333,10 +333,12 @@ void c_typecheck_baset::typecheck_redefinition_non_type(
333
333
// gcc allows re-definition if the first
334
334
// definition is marked as "extern inline"
335
335
336
- if (old_symbol.type .get_bool (ID_C_inlined) &&
337
- (config.ansi_c .mode ==configt::ansi_ct::flavourt::GCC ||
338
- config.ansi_c .mode ==configt::ansi_ct::flavourt::APPLE ||
339
- config.ansi_c .mode ==configt::ansi_ct::flavourt::ARM))
336
+ if (
337
+ old_symbol.type .get_bool (ID_C_inlined) &&
338
+ (config.ansi_c .mode == configt::ansi_ct::flavourt::GCC ||
339
+ config.ansi_c .mode == configt::ansi_ct::flavourt::APPLE ||
340
+ config.ansi_c .mode == configt::ansi_ct::flavourt::ARM ||
341
+ config.ansi_c .mode == configt::ansi_ct::flavourt::VISUAL_STUDIO))
340
342
{
341
343
// overwrite "extern inline" properties
342
344
old_symbol.is_extern =new_symbol.is_extern ;
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ extern char *yyansi_ctext;
164
164
%token TOK_MSC_EXCEPT " __except"
165
165
%token TOK_MSC_LEAVE " __leave"
166
166
%token TOK_MSC_DECLSPEC " __declspec"
167
+ %token TOK_MSC_FORCEINLINE " __forceinline"
167
168
%token TOK_INTERFACE " __interface"
168
169
%token TOK_CDECL " __cdecl"
169
170
%token TOK_STDCALL " __stdcall"
@@ -1384,6 +1385,25 @@ storage_class:
1384
1385
| TOK_THREAD_LOCAL { $$ =$1 ; set($$ , ID_thread_local); }
1385
1386
| TOK_GCC_ASM { $$ =$1 ; set($$ , ID_asm); }
1386
1387
| msc_declspec { $$ =$1 ; }
1388
+ | TOK_MSC_FORCEINLINE
1389
+ {
1390
+ // equivalent to always_inline, and seemingly also has the semantics
1391
+ // of extern inline in that multiple definitions can be provided in
1392
+ // the same translation unit
1393
+ init ($$);
1394
+ set ($$, ID_static);
1395
+ set ($1 , ID_inline);
1396
+ #if 0
1397
+ // enable once always_inline support is reinstantiated
1398
+ $1=merge($1, $$);
1399
+
1400
+ init($$);
1401
+ set($$, ID_always_inline);
1402
+ $$=merge($1, $$);
1403
+ #else
1404
+ $$=merge($1 , $$);
1405
+ #endif
1406
+ }
1387
1407
;
1388
1408
1389
1409
basic_type_name :
Original file line number Diff line number Diff line change @@ -1138,7 +1138,7 @@ __decltype { if(PARSER.cpp98 &&
1138
1138
1139
1139
" __forceinline" { if (PARSER.mode ==configt::ansi_ct::flavourt::VISUAL_STUDIO ||
1140
1140
PARSER.mode ==configt::ansi_ct::flavourt::ARM)
1141
- { loc (); return TOK_INLINE ; }
1141
+ { loc (); return TOK_MSC_FORCEINLINE ; }
1142
1142
else
1143
1143
return make_identifier ();
1144
1144
}
Original file line number Diff line number Diff line change @@ -1952,14 +1952,19 @@ bool Parser::optMemberSpec(cpp_member_spect &member_spec)
1952
1952
1953
1953
int t=lex.LookAhead (0 );
1954
1954
1955
- while (t==TOK_FRIEND || t==TOK_INLINE || t==TOK_VIRTUAL || t==TOK_EXPLICIT)
1955
+ while (
1956
+ t == TOK_FRIEND || t == TOK_INLINE || t == TOK_VIRTUAL ||
1957
+ t == TOK_EXPLICIT || t == TOK_MSC_FORCEINLINE)
1956
1958
{
1957
1959
cpp_tokent tk;
1958
1960
lex.get_token (tk);
1959
1961
1960
1962
switch (t)
1961
1963
{
1962
- case TOK_INLINE: member_spec.set_inline (true ); break ;
1964
+ case TOK_INLINE:
1965
+ case TOK_MSC_FORCEINLINE:
1966
+ member_spec.set_inline (true );
1967
+ break ;
1963
1968
case TOK_VIRTUAL: member_spec.set_virtual (true ); break ;
1964
1969
case TOK_FRIEND: member_spec.set_friend (true ); break ;
1965
1970
case TOK_EXPLICIT: member_spec.set_explicit (true ); break ;
You can’t perform that action at this time.
0 commit comments