@@ -1585,6 +1585,17 @@ bool Parser::rIntegralDeclaration(
1585
1585
if (!rDeclarators (declaration.declarators (), true ))
1586
1586
return false ;
1587
1587
1588
+ // handle trailing return type
1589
+ if (
1590
+ declaration.type ().id () == ID_auto &&
1591
+ declaration.declarators ().size () == 1 &&
1592
+ declaration.declarators ().front ().type ().id () == ID_function_type &&
1593
+ declaration.declarators ().front ().type ().subtype ().is_not_nil ())
1594
+ {
1595
+ declaration.type () = declaration.declarators ().front ().type ().subtype ();
1596
+ declaration.declarators ().front ().type ().subtype ().make_nil ();
1597
+ }
1598
+
1588
1599
#ifdef DEBUG
1589
1600
std::cout << std::string (__indent, ' ' )
1590
1601
<< " Parser::rIntegralDeclaration 7\n " ;
@@ -1961,7 +1972,7 @@ bool Parser::optStorageSpec(cpp_storage_spect &storage_spec)
1961
1972
1962
1973
if (t==TOK_STATIC ||
1963
1974
t==TOK_EXTERN ||
1964
- t== TOK_AUTO ||
1975
+ (t == TOK_AUTO && !ansi_c_parser. cpp11 ) ||
1965
1976
t==TOK_REGISTER ||
1966
1977
t==TOK_MUTABLE ||
1967
1978
t==TOK_GCC_ASM ||
@@ -2224,6 +2235,7 @@ bool Parser::optIntegralTypeOrClassSpec(typet &p)
2224
2235
case TOK_GCC_FLOAT128: type_id=ID_gcc_float128; break ;
2225
2236
case TOK_BOOL: type_id=ID_bool; break ;
2226
2237
case TOK_CPROVER_BOOL: type_id=ID_proper_bool; break ;
2238
+ case TOK_AUTO: type_id = ID_auto; break ;
2227
2239
default : type_id=irep_idt ();
2228
2240
}
2229
2241
@@ -2912,6 +2924,11 @@ bool Parser::rDeclarator(
2912
2924
typet return_type;
2913
2925
if (!rTypeSpecifier (return_type, false ))
2914
2926
return false ;
2927
+
2928
+ if (d_outer.subtype ().is_not_nil ())
2929
+ return false ;
2930
+
2931
+ d_outer.subtype ().swap (return_type);
2915
2932
}
2916
2933
2917
2934
if (lex.LookAhead (0 )==' :' )
0 commit comments