Skip to content

Commit 016ad92

Browse files
committed
Revert "Fully interpret __attribute__((always_inline))"
This partly reverts commit 9c93f59. The regression test stays in place, but is now marked as KNOWNBUG.
1 parent d20a12e commit 016ad92

11 files changed

+4
-123
lines changed

regression/ansi-c/always_inline1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CORE
1+
KNOWNBUG
22
main.c
33

44
^EXIT=0$

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,6 @@ void ansi_c_convert_typet::read_rec(const typet &type)
171171
c_storage_spec.is_weak=true;
172172
else if(type.id() == ID_used)
173173
c_storage_spec.is_used = true;
174-
else if(type.id() == ID_always_inline)
175-
c_storage_spec.is_always_inline = true;
176174
else if(type.id()==ID_auto)
177175
{
178176
// ignore

src/ansi-c/ansi_c_declaration.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ void ansi_c_declarationt::output(std::ostream &out) const
8181
out << " is_extern";
8282
if(get_is_static_assert())
8383
out << " is_static_assert";
84-
if(get_is_always_inline())
85-
out << " is_always_inline";
8684
out << "\n";
8785

8886
out << "Type: " << type().pretty() << "\n";
@@ -166,9 +164,6 @@ void ansi_c_declarationt::to_symbol(
166164
symbol.is_extern=false;
167165
else if(get_is_extern()) // traditional GCC
168166
symbol.is_file_local=true;
169-
170-
if(get_is_always_inline())
171-
symbol.is_macro = true;
172167
}
173168

174169
// GCC __attribute__((__used__)) - do not treat those as file-local

src/ansi-c/ansi_c_declaration.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,6 @@ class ansi_c_declarationt:public exprt
205205
set(ID_is_used, is_used);
206206
}
207207

208-
bool get_is_always_inline() const
209-
{
210-
return get_bool(ID_is_always_inline);
211-
}
212-
213-
void set_is_always_inline(bool is_always_inline)
214-
{
215-
set(ID_is_always_inline, is_always_inline);
216-
}
217-
218208
void to_symbol(
219209
const ansi_c_declaratort &,
220210
symbolt &symbol) const;

src/ansi-c/c_storage_spec.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ void c_storage_spect::read(const typet &type)
3434
is_weak=true;
3535
else if(type.id() == ID_used)
3636
is_used = true;
37-
else if(type.id() == ID_always_inline)
38-
is_always_inline = true;
3937
else if(type.id()==ID_auto)
4038
{
4139
// ignore

src/ansi-c/c_storage_spec.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ class c_storage_spect
3636
is_inline=false;
3737
is_weak=false;
3838
is_used = false;
39-
is_always_inline = false;
4039
alias.clear();
4140
asm_label.clear();
4241
section.clear();
4342
}
4443

45-
bool is_typedef, is_extern, is_static, is_register, is_inline,
46-
is_thread_local, is_weak, is_used, is_always_inline;
44+
bool is_typedef, is_extern, is_static, is_register,
45+
is_inline, is_thread_local, is_weak, is_used;
4746

4847
// __attribute__((alias("foo")))
4948
irep_idt alias;
@@ -54,7 +53,6 @@ class c_storage_spect
5453

5554
bool operator==(const c_storage_spect &other) const
5655
{
57-
// clang-format off
5856
return is_typedef==other.is_typedef &&
5957
is_extern==other.is_extern &&
6058
is_static==other.is_static &&
@@ -63,11 +61,9 @@ class c_storage_spect
6361
is_inline==other.is_inline &&
6462
is_weak==other.is_weak &&
6563
is_used == other.is_used &&
66-
is_always_inline == other.is_always_inline &&
6764
alias==other.alias &&
6865
asm_label==other.asm_label &&
6966
section==other.section;
70-
// clang-format on
7167
}
7268

7369
bool operator!=(const c_storage_spect &other) const
@@ -85,7 +81,6 @@ class c_storage_spect
8581
is_thread_local |=other.is_thread_local;
8682
is_weak |=other.is_weak;
8783
is_used |=other.is_used;
88-
is_always_inline |= other.is_always_inline;
8984
if(alias.empty())
9085
alias=other.alias;
9186
if(asm_label.empty())

src/ansi-c/c_typecheck_base.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,6 @@ void c_typecheck_baset::typecheck_declaration(
689689
declaration.set_is_typedef(full_spec.is_typedef);
690690
declaration.set_is_weak(full_spec.is_weak);
691691
declaration.set_is_used(full_spec.is_used);
692-
declaration.set_is_always_inline(full_spec.is_always_inline);
693692

694693
symbolt symbol;
695694
declaration.to_symbol(*d_it, symbol);

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ Author: Daniel Kroening, [email protected]
1818
#include <util/c_types.h>
1919
#include <util/config.h>
2020
#include <util/cprover_prefix.h>
21-
#include <util/expr_util.h>
2221
#include <util/ieee_float.h>
2322
#include <util/pointer_offset_size.h>
2423
#include <util/pointer_predicates.h>
25-
#include <util/replace_symbol.h>
2624
#include <util/simplify_expr.h>
2725
#include <util/string_constant.h>
2826

@@ -1920,10 +1918,7 @@ void c_typecheck_baset::typecheck_side_effect_function_call(
19201918
if(entry!=asm_label_map.end())
19211919
identifier=entry->second;
19221920

1923-
symbol_tablet::symbolst::const_iterator sym_entry =
1924-
symbol_table.symbols.find(identifier);
1925-
1926-
if(sym_entry == symbol_table.symbols.end())
1921+
if(symbol_table.symbols.find(identifier)==symbol_table.symbols.end())
19271922
{
19281923
// This is an undeclared function.
19291924
// Is this a builtin?
@@ -1965,87 +1960,6 @@ void c_typecheck_baset::typecheck_side_effect_function_call(
19651960
warning() << "function `" << identifier << "' is not declared" << eom;
19661961
}
19671962
}
1968-
else if(
1969-
sym_entry->second.type.get_bool(ID_C_inlined) &&
1970-
sym_entry->second.is_macro && sym_entry->second.value.is_not_nil())
1971-
{
1972-
// calling a function marked as always_inline
1973-
const symbolt &func_sym = sym_entry->second;
1974-
const code_typet &func_type = to_code_type(func_sym.type);
1975-
1976-
replace_symbolt replace;
1977-
1978-
const code_typet::parameterst &parameters = func_type.parameters();
1979-
auto p_it = parameters.begin();
1980-
for(const auto &arg : expr.arguments())
1981-
{
1982-
if(p_it == parameters.end())
1983-
{
1984-
// we don't support varargs with always_inline
1985-
err_location(f_op);
1986-
error() << "function call has additional arguments, "
1987-
<< "cannot apply always_inline" << eom;
1988-
throw 0;
1989-
}
1990-
1991-
irep_idt p_id = p_it->get_identifier();
1992-
if(p_id.empty())
1993-
{
1994-
p_id = id2string(func_sym.base_name) + "::" +
1995-
id2string(p_it->get_base_name());
1996-
}
1997-
replace.insert(p_id, arg);
1998-
1999-
++p_it;
2000-
}
2001-
2002-
if(p_it != parameters.end())
2003-
{
2004-
err_location(f_op);
2005-
error() << "function call has missing arguments, "
2006-
<< "cannot apply always_inline" << eom;
2007-
throw 0;
2008-
}
2009-
2010-
codet body = to_code(func_sym.value);
2011-
replace(body);
2012-
2013-
side_effect_exprt side_effect_expr(
2014-
ID_statement_expression, func_type.return_type());
2015-
body.make_block();
2016-
2017-
// simulates parts of typecheck_function_body
2018-
typet cur_return_type = return_type;
2019-
return_type = func_type.return_type();
2020-
typecheck_code(body);
2021-
return_type.swap(cur_return_type);
2022-
2023-
// replace final return by an ID_expression
2024-
codet &last = to_code_block(body).find_last_statement();
2025-
2026-
if(last.get_statement() == ID_return)
2027-
last.set_statement(ID_expression);
2028-
2029-
// NOLINTNEXTLINE(whitespace/braces)
2030-
const bool has_returns = has_subexpr(body, [&](const exprt &e) {
2031-
return e.id() == ID_code && to_code(e).get_statement() == ID_return;
2032-
});
2033-
if(has_returns)
2034-
{
2035-
// we don't support multiple return statements with always_inline
2036-
err_location(last);
2037-
error() << "function has multiple return statements, "
2038-
<< "cannot apply always_inline" << eom;
2039-
throw 0;
2040-
}
2041-
2042-
side_effect_expr.copy_to_operands(body);
2043-
typecheck_side_effect_statement_expression(side_effect_expr);
2044-
2045-
expr.swap(side_effect_expr);
2046-
2047-
return;
2048-
}
20491963
}
20501964

20511965
// typecheck it now

src/ansi-c/parser.y

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ extern char *yyansi_ctext;
150150
%token TOK_GCC_ATTRIBUTE_DESTRUCTOR "destructor"
151151
%token TOK_GCC_ATTRIBUTE_FALLTHROUGH "fallthrough"
152152
%token TOK_GCC_ATTRIBUTE_USED "used"
153-
%token TOK_GCC_ATTRIBUTE_ALWAYS_INLINE "always_inline"
154153
%token TOK_GCC_LABEL "__label__"
155154
%token TOK_MSC_ASM "__asm"
156155
%token TOK_MSC_BASED "__based"
@@ -1548,8 +1547,6 @@ gcc_type_attribute:
15481547
{ $$=$1; set($$, ID_destructor); }
15491548
| TOK_GCC_ATTRIBUTE_USED
15501549
{ $$=$1; set($$, ID_used); }
1551-
| TOK_GCC_ATTRIBUTE_ALWAYS_INLINE
1552-
{ $$=$1; set($$, ID_always_inline); }
15531550
;
15541551

15551552
gcc_attribute:

src/ansi-c/scanner.l

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,6 @@ __decltype { if(PARSER.cpp98 &&
15901590
"used" |
15911591
"__used__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_USED; }
15921592

1593-
"always_inline" |
1594-
"__always_inline__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_ALWAYS_INLINE; }
1595-
15961593
{ws} { /* ignore */ }
15971594
{newline} { /* ignore */ }
15981595
{identifier} { BEGIN(GCC_ATTRIBUTE4); }

src/util/irep_ids.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,6 @@ IREP_ID_TWO(C_abstract, #abstract)
673673
IREP_ID_ONE(synthetic)
674674
IREP_ID_ONE(interface)
675675
IREP_ID_TWO(C_must_not_throw, #must_not_throw)
676-
IREP_ID_ONE(always_inline)
677-
IREP_ID_ONE(is_always_inline)
678676
IREP_ID_ONE(is_inner_class)
679677

680678
// Projects depending on this code base that wish to extend the list of

0 commit comments

Comments
 (0)