Skip to content

Commit cc63551

Browse files
author
Daniel Kroening
committed
revert bits of a9806c0; the width of these pointers is done during the conversion phase
1 parent 8fdb06f commit cc63551

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

src/ansi-c/parser.y

+28-7
Original file line numberDiff line numberDiff line change
@@ -3065,7 +3065,10 @@ unary_identifier_declarator:
30653065
{
30663066
// the type_qualifier_list is for the pointer,
30673067
// and not the identifier_declarator
3068-
stack_type($1)=pointer_type(typet(ID_abstract));
3068+
// The below is deliberately not using pointer_type();
3069+
// the width is added during conversion.
3070+
stack_type($1).id(ID_pointer);
3071+
stack_type($1).subtype()=typet(ID_abstract);
30693072
$2=merge($2, $1); // dest=$2
30703073
make_subtype($3, $2); // dest=$3
30713074
$$=$3;
@@ -3249,13 +3252,19 @@ unary_abstract_declarator:
32493252
'*'
32503253
{
32513254
$$=$1;
3252-
stack_type($$)=pointer_type(typet(ID_abstract));
3255+
// The below is deliberately not using pointer_type();
3256+
// the width is added during conversion.
3257+
stack_type($$).id(ID_pointer);
3258+
stack_type($$).subtype()=typet(ID_abstract);
32533259
}
32543260
| '*' attribute_type_qualifier_list
32553261
{
32563262
// The type_qualifier_list belongs to the pointer,
32573263
// not to the (missing) abstract declarator.
3258-
stack_type($1)=pointer_type(typet(ID_abstract));
3264+
// The below is deliberately not using pointer_type();
3265+
// the width is added during conversion.
3266+
stack_type($1).id(ID_pointer);
3267+
stack_type($1).subtype()=typet(ID_abstract);
32593268
$$=merge($2, $1);
32603269
}
32613270
| '*' abstract_declarator
@@ -3267,7 +3276,10 @@ unary_abstract_declarator:
32673276
{
32683277
// The type_qualifier_list belongs to the pointer,
32693278
// not to the abstract declarator.
3270-
stack_type($1)=pointer_type(typet(ID_abstract));
3279+
// The below is deliberately not using pointer_type();
3280+
// the width is added during conversion.
3281+
stack_type($1).id(ID_pointer);
3282+
stack_type($1).subtype()=typet(ID_abstract);
32713283
$2=merge($2, $1); // dest=$2
32723284
make_subtype($3, $2); // dest=$3
32733285
$$=$3;
@@ -3286,13 +3298,19 @@ parameter_unary_abstract_declarator:
32863298
'*'
32873299
{
32883300
$$=$1;
3289-
stack_type($$)=pointer_type(typet(ID_abstract));
3301+
// The below is deliberately not using pointer_type();
3302+
// the width is added during conversion.
3303+
stack_type($$).id(ID_pointer);
3304+
stack_type($$).subtype()=typet(ID_abstract);
32903305
}
32913306
| '*' attribute_type_qualifier_list
32923307
{
32933308
// The type_qualifier_list belongs to the pointer,
32943309
// not to the (missing) abstract declarator.
3295-
stack_type($1)=pointer_type(typet(ID_abstract));
3310+
// The below is deliberately not using pointer_type();
3311+
// the width is added during conversion.
3312+
stack_type($1).id(ID_pointer);
3313+
stack_type($1).subtype()=typet(ID_abstract);
32963314
$$=merge($2, $1);
32973315
}
32983316
| '*' parameter_abstract_declarator
@@ -3304,7 +3322,10 @@ parameter_unary_abstract_declarator:
33043322
{
33053323
// The type_qualifier_list belongs to the pointer,
33063324
// not to the (missing) abstract declarator.
3307-
stack_type($1)=pointer_type(typet(ID_abstract));
3325+
// The below is deliberately not using pointer_type();
3326+
// the width is added during conversion.
3327+
stack_type($1).id(ID_pointer);
3328+
stack_type($1).subtype()=typet(ID_abstract);
33083329
$2=merge($2, $1); // dest=$2
33093330
make_subtype($3, $2); // dest=$3
33103331
$$=$3;

src/ansi-c/parser_static.inc

+4-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,10 @@ Function: make_pointer
290290

291291
static void make_pointer(const YYSTYPE dest)
292292
{
293-
stack_type(dest)=pointer_type(typet(ID_abstract));
293+
// The below deliberately avoids pointer_type().
294+
// The width is set during conversion.
295+
stack_type(dest).id(ID_pointer);
296+
stack_type(dest).subtype()=typet(ID_abstract);
294297
}
295298

296299
/*******************************************************************\

src/cpp/parse.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Author: Daniel Kroening, [email protected]
1818
#include <util/std_code.h>
1919
#include <util/std_expr.h>
2020
#include <util/std_types.h>
21-
#include <util/c_types.h>
2221

2322
#include <ansi-c/ansi_c_y.tab.h>
2423

@@ -3016,7 +3015,7 @@ bool Parser::optPtrOperator(typet &ptrs)
30163015

30173016
if(t=='*')
30183017
{
3019-
typet op=pointer_type(typet(ID_nil));
3018+
typet op(ID_pointer); // width gets set during conversion
30203019
cpp_tokent tk;
30213020
lex.get_token(tk);
30223021
set_location(op, tk);
@@ -3079,7 +3078,7 @@ bool Parser::optPtrOperator(typet &ptrs)
30793078
{
30803079
cpp_tokent tk;
30813080
lex.get_token(tk);
3082-
typet op=pointer_type(typet(ID_nil));
3081+
typet op(ID_pointer); // width gets set during conversion
30833082
op.set(ID_C_reference, true);
30843083
set_location(op, tk);
30853084
t_list.push_front(op);
@@ -3088,7 +3087,7 @@ bool Parser::optPtrOperator(typet &ptrs)
30883087
{
30893088
cpp_tokent tk;
30903089
lex.get_token(tk);
3091-
typet op=pointer_type(typet(ID_nil));
3090+
typet op(ID_pointer); // width gets set during conversion
30923091
op.set(ID_C_rvalue_reference, true);
30933092
set_location(op, tk);
30943093
t_list.push_front(op);
@@ -3531,7 +3530,7 @@ bool Parser::rPtrToMember(irept &ptr_to_mem)
35313530
std::cout << std::string(__indent, ' ') << "Parser::rPtrToMember 0\n";
35323531
#endif
35333532

3534-
typet ptm=pointer_type(typet(ID_nil));
3533+
typet ptm(ID_pointer); // width gets set during conversion
35353534
irept &name = ptm.add("to-member");
35363535
name=cpp_namet();
35373536
irept::subt &components=name.get_sub();
@@ -6478,7 +6477,8 @@ bool Parser::rPrimaryExpr(exprt &exp)
64786477

64796478
case TOK_NULLPTR:
64806479
lex.get_token(tk);
6481-
exp=constant_exprt(ID_NULL, pointer_type(typet(ID_nullptr)));
6480+
// width of pointer gets done during conversion
6481+
exp=constant_exprt(ID_NULL, typet(ID_pointer, typet(ID_nullptr)));
64826482
set_location(exp, tk);
64836483
#ifdef DEBUG
64846484
std::cout << std::string(__indent, ' ') << "Parser::rPrimaryExpr 6\n";

0 commit comments

Comments
 (0)