aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-03-29 03:53:13 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-03-29 03:53:13 +0000
commita0c8ad3bdfe2b84c35388bf9937fa9296fe50278 (patch)
treea4e8c7e8ea099b688e9c92980ae88d0d055a99b9 /gcc
parent917c1602aa2bf8905890ee6c19a1624f80b1c8c3 (diff)
downloadgcc-a0c8ad3bdfe2b84c35388bf9937fa9296fe50278.zip
gcc-a0c8ad3bdfe2b84c35388bf9937fa9296fe50278.tar.gz
gcc-a0c8ad3bdfe2b84c35388bf9937fa9296fe50278.tar.bz2
compiler, libgo: unsafe.{Sizeof,Alignof,Offsetof} return uintptr.
From-SVN: r185946
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/expressions.cc14
-rw-r--r--gcc/go/gofrontend/unsafe.cc8
2 files changed, 13 insertions, 9 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 13c7de3..06e85eb 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -7091,7 +7091,8 @@ Builtin_call_expression::do_numeric_constant_value(Numeric_constant* nc) const
else
go_unreachable();
- nc->set_unsigned_long(NULL, static_cast<unsigned long>(ret));
+ nc->set_unsigned_long(Type::lookup_integer_type("uintptr"),
+ static_cast<unsigned long>(ret));
return true;
}
else if (this->code_ == BUILTIN_OFFSETOF)
@@ -7113,7 +7114,8 @@ Builtin_call_expression::do_numeric_constant_value(Numeric_constant* nc) const
farg->field_index(),
&offset))
return false;
- nc->set_unsigned_long(NULL, static_cast<unsigned long>(offset));
+ nc->set_unsigned_long(Type::lookup_integer_type("uintptr"),
+ static_cast<unsigned long>(offset));
return true;
}
else if (this->code_ == BUILTIN_REAL || this->code_ == BUILTIN_IMAG)
@@ -7246,10 +7248,12 @@ Builtin_call_expression::do_type()
case BUILTIN_CAP:
case BUILTIN_COPY:
case BUILTIN_LEN:
+ return Type::lookup_integer_type("int");
+
case BUILTIN_ALIGNOF:
case BUILTIN_OFFSETOF:
case BUILTIN_SIZEOF:
- return Type::lookup_integer_type("int");
+ return Type::lookup_integer_type("uintptr");
case BUILTIN_CLOSE:
case BUILTIN_DELETE:
@@ -8078,8 +8082,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
go_assert(saw_errors());
return error_mark_node;
}
- Type* int_type = Type::lookup_integer_type("int");
- tree type = type_to_tree(int_type->get_backend(gogo));
+ Type* uintptr_type = Type::lookup_integer_type("uintptr");
+ tree type = type_to_tree(uintptr_type->get_backend(gogo));
return build_int_cst(type, val);
}
diff --git a/gcc/go/gofrontend/unsafe.cc b/gcc/go/gofrontend/unsafe.cc
index bc949c6..930723e 100644
--- a/gcc/go/gofrontend/unsafe.cc
+++ b/gcc/go/gofrontend/unsafe.cc
@@ -57,11 +57,11 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported,
if (add_to_globals)
this->add_named_type(pointer_type);
- Type* int_type = this->lookup_global("int")->type_value();
+ Type* uintptr_type = Type::lookup_integer_type("uintptr");
// Sizeof.
Typed_identifier_list* results = new Typed_identifier_list;
- results->push_back(Typed_identifier("", int_type, bloc));
+ results->push_back(Typed_identifier("", uintptr_type, bloc));
Function_type* fntype = Type::make_function_type(NULL, NULL, results, bloc);
fntype->set_is_builtin();
no = bindings->add_function_declaration("Sizeof", package, fntype, bloc);
@@ -70,7 +70,7 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported,
// Offsetof.
results = new Typed_identifier_list;
- results->push_back(Typed_identifier("", int_type, bloc));
+ results->push_back(Typed_identifier("", uintptr_type, bloc));
fntype = Type::make_function_type(NULL, NULL, results, bloc);
fntype->set_is_varargs();
fntype->set_is_builtin();
@@ -80,7 +80,7 @@ Gogo::import_unsafe(const std::string& local_name, bool is_local_name_exported,
// Alignof.
results = new Typed_identifier_list;
- results->push_back(Typed_identifier("", int_type, bloc));
+ results->push_back(Typed_identifier("", uintptr_type, bloc));
fntype = Type::make_function_type(NULL, NULL, results, bloc);
fntype->set_is_varargs();
fntype->set_is_builtin();