Age | Commit message (Collapse) | Author | Files | Lines |
|
For PR go/119098
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/654477
|
|
This is a backport of https://go.dev/cl/640237 from the main repo.
Fixes PR go/118286
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/640435
|
|
We were not consistently traversing method declarations, which appear
if there is a method without a body. The gc compiler rejects that
case, but gofrontend currently permits it. Maybe that should change,
but not today.
This avoids a compiler crash if there are method declarations
with types that require specific functions. I didn't bother
with a test case because a program with method declarations is
almost certainly invalid anyhow.
Fixes PR go/117891
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/633495
|
|
GCC has a new -Wformat-truncation warning that triggers on this code:
../../gcc/go/gofrontend/go-encode-id.cc: In function 'std::string go_encode_id(const std::string&)':
../../gcc/go/gofrontend/go-encode-id.cc:176:48: error: '%02x' directive output may be truncated writing between 2 and 8 bytes into a region of size 6 [-Werror=format-truncation=]
176 | snprintf(buf, sizeof buf, "_x%02x", c);
| ^~~~
../../gcc/go/gofrontend/go-encode-id.cc:176:45: note: directive argument in the range [128, 4294967295]
176 | snprintf(buf, sizeof buf, "_x%02x", c);
| ^~~~~~~~
../../gcc/go/gofrontend/go-encode-id.cc:176:27: note: 'snprintf' output between 5 and 11 bytes into a destination of size 8
176 | snprintf(buf, sizeof buf, "_x%02x", c);
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The code is safe, because the value of c is known to be >= 0 && <= 0xff.
But it's difficult for the compiler to know that.
Bump the buffer size to avoid the warning.
Fixes PR go/117833
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/632455
|
|
No functional change intended.
gcc/analyzer/ChangeLog:
PR c/104896
* sm-malloc.cc: Replace "%<%s%>" with "%qs" in message wording.
gcc/c-family/ChangeLog:
PR c/104896
* c-lex.cc (c_common_lex_availability_macro): Replace "%<%s%>"
with "%qs" in message wording.
* c-opts.cc (c_common_handle_option): Likewise.
* c-warn.cc (warn_parm_array_mismatch): Likewise.
gcc/ChangeLog:
PR c/104896
* common/config/ia64/ia64-common.cc (ia64_handle_option): Replace
"%<%s%>" with "%qs" in message wording.
* common/config/rs6000/rs6000-common.cc (rs6000_handle_option):
Likewise.
* config/aarch64/aarch64.cc (aarch64_validate_sls_mitigation):
Likewise.
(aarch64_override_options): Likewise.
(aarch64_process_target_attr): Likewise.
* config/arm/aarch-common.cc (aarch_validate_mbranch_protection):
Likewise.
* config/pru/pru.cc (pru_insert_attributes): Likewise.
* config/riscv/riscv-target-attr.cc
(riscv_target_attr_parser::parse_arch): Likewise.
* omp-general.cc (oacc_verify_routine_clauses): Likewise.
* tree-ssa-uninit.cc (maybe_warn_read_write_only): Likewise.
(maybe_warn_pass_by_reference): Likewise.
gcc/cp/ChangeLog:
PR c/104896
* cvt.cc (maybe_warn_nodiscard): Replace "%<%s%>" with "%qs" in
message wording.
gcc/fortran/ChangeLog:
PR c/104896
* resolve.cc (resolve_operator): Replace "%<%s%>" with "%qs" in
message wording.
gcc/go/ChangeLog:
PR c/104896
* gofrontend/embed.cc (Gogo::initializer_for_embeds): Replace
"%<%s%>" with "%qs" in message wording.
* gofrontend/expressions.cc
(Selector_expression::lower_method_expression): Likewise.
* gofrontend/gogo.cc (Gogo::set_package_name): Likewise.
(Named_object::export_named_object): Likewise.
* gofrontend/parse.cc (Parse::struct_type): Likewise.
(Parse::parameter_list): Likewise.
gcc/rust/ChangeLog:
PR c/104896
* backend/rust-compile-expr.cc
(CompileExpr::compile_integer_literal): Replace "%<%s%>" with
"%qs" in message wording.
(CompileExpr::compile_float_literal): Likewise.
* backend/rust-compile-intrinsic.cc (Intrinsics::compile):
Likewise.
* backend/rust-tree.cc (maybe_warn_nodiscard): Likewise.
* checks/lints/rust-lint-scan-deadcode.h: Likewise.
* lex/rust-lex.cc (Lexer::parse_partial_unicode_escape): Likewise.
(Lexer::parse_raw_byte_string): Likewise.
* lex/rust-token.cc (Token::get_str): Likewise.
* metadata/rust-export-metadata.cc
(PublicInterface::write_to_path): Likewise.
* parse/rust-parse.cc
(peculiar_fragment_match_compatible_fragment): Likewise.
(peculiar_fragment_match_compatible): Likewise.
* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path):
Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go):
Likewise.
* rust-session-manager.cc (validate_crate_name): Likewise.
(Session::load_extern_crate): Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Likewise.
(TypeCheckExpr::resolve_fn_trait_call): Likewise.
* typecheck/rust-hir-type-check-implitem.cc
(TypeCheckImplItemWithTrait::visit): Likewise.
* typecheck/rust-hir-type-check-item.cc
(TypeCheckItem::validate_trait_impl_block): Likewise.
* typecheck/rust-hir-type-check-struct.cc
(TypeCheckStructExpr::visit): Likewise.
* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit):
Likewise.
* typecheck/rust-tyty.cc (BaseType::bounds_compatible): Likewise.
* typecheck/rust-unify.cc (UnifyRules::emit_abi_mismatch):
Likewise.
* util/rust-attributes.cc (AttributeChecker::visit): Likewise.
libcpp/ChangeLog:
PR c/104896
* pch.cc (cpp_valid_state): Replace "%<%s%>" with "%qs" in message
wording.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
|
|
Patch from Samuel Thibault.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/623415
|
|
Backport https://go.dev/cl/620955 from main repo. Original description:
src/runtime/testdata/testprogcgo/threadprof.go contains C code with a
variable called nullptr. This conflicts with the nullptr keyword in
the C23 revision of the C standard (showing up as gccgo test build
failures when updating GCC to use C23 by default when building C
code).
Rename that variable to nullpointer to avoid the clash with the
keyword (any other name that's not a keyword would work just as well).
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/621059
|
|
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/604075
|
|
After CL 536643 passing NULL as the expected type permitted an untyped
constant expression to remain untyped. Change to passing the empty
interface type.
The panic and print/println functions are the only builtin functions
that turn an untyped constant expression into a regular function call,
and we already handled print/println specially.
The test case is https://go.dev/cl/603096.
Fixes golang/go#68734
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/603215
|
|
Patch by Rainer Orth <ro@gcc.gnu.org>.
Fixes PR go/106813
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/581724
|
|
<stdbool.h> has been available since C99. Use it rather than defining
our own boolean type and values.
Fixes https://gcc.gnu.org/PR114875
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/582275
|
|
This has apparently been wrong since I introduced the code ten years ago.
Fixes PR go/114500
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/574835
|
|
Fixes PR go/114463
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/574476
|
|
PR go/113668
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/560676
|
|
As we move toward generics, the error messages need to be able
to refer to types in a readable manner. Add that capability,
and use it today in AST dumps.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536716
|
|
PR go/113530
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/557655
|
|
Otherwise we can't tell the difference between builtin type "any" and
a locally defined type "any".
This will require updates to the gccgo export data parsers in the main
Go repo and the x/tools repo. These updates are https://go.dev/cl/537195
and https://go.dev/cl/537215.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536715
|
|
It is no longer used. The iota value is now handled in the
determine-types pass.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536644
|
|
This change moves the lowering pass after the type determination and
the type checking passes. This lets us simplify some of the code that
determines the type of an expression, which previously had to work
correctly both before and after type determination.
I'm doing this to help with future generic support. For example, with
generics, we can see code like
func ident[T any](v T) T { return v }
func F() int32 {
s := int32(1)
return ident(s)
}
Before this change, we would type check return statements in the
lowering pass (see Return_statement::do_lower). With a generic
example like the above, that means we have to determine the type of s,
and use that to infer the type arguments passed to ident, and use that
to determine the result type of ident. That is too much to do at
lowering time. Of course we can change the way that return statements
work, but similar issues arise with index expressions, the types of
closures for function literals, and probably other cases as well.
Rather than try to deal with all those cases, we move the lowering
pass after type checking. This requires a bunch of changes, notably
for determining constant types. We have to add type checking for
various constructs that formerly disappeared in the lowering pass.
So it's a lot of shuffling. Sorry for the size of the patch.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536643
|
|
The libgo/configure.ac file in upstream GCC was changed in
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6a6d3817afa02bbcd2388c8e005da6faf88932f1
This adds an automake conditional that is not used, but will be used
in the future when and if libgo is ported to Darwin.
This CL makes the corresponding change in this repo.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/546435
|
|
This is a mechanical change to move Selector_expression up in expressions.cc.
This will make it visible to Builtin_call_expression for later work.
This produces a very large "git --diff", but "git diff --minimal" is clear.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536642
|
|
This changes the Expression {numeric,string,boolean}_constant_value
methods non-const. This does not affect anything immediately,
but will be useful for later CLs in this series.
The only real effect is to Builtin_call_expression::do_export,
which remains const and can no longer call numeric_constant_value.
But it never needed to call it, as do_export runs after do_lower,
and do_lower replaces a constant expression with the actual constant.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536641
|
|
This is a boilerplate change to pass gogo to Runtime::make_call.
It's not currently used but will be used by later CLs in this series.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536640
|
|
This method is not currently used by anything, but it will be used
by later CLs in this series.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536639
|
|
The gofrontend incorrectly accepted code that was missing a type conversion.
The test case for this is bug518.go in https://go.dev/cl/536537.
Future CLs in this series will detect the type error.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536638
|
|
The last caller was removed in https://go.dev/cl/18261 in 2016.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536637
|
|
It's not used for anything.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536636
|
|
Also pass Gogo to the type verification pass.
This is a refactoring that does not change the compiler behavior.
This is in preparation for future CLs that rearrange the pass ordering.
This introduces one new call to go_get_gogo, which will be removed in
a future CL.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536635
|
|
Patch from Thomas Schwinge.
PR testsuite/109951
* configure.ac: 'AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)'.
* Makefile.in: Regenerate.
* configure: Likewise.
* testsuite/Makefile.in: Likewise.
* testsuite/lib/libgo.exp (libgo_init): If
'--with-build-sysroot=[...]' was specified, use it for build-tree
testing.
* testsuite/libgo-test-support.exp.in (GOC_UNDER_TEST): Don't set.
(SYSROOT_CFLAGS_FOR_TARGET): Set.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/527755
|
|
Handle the AR environment variable, used by gccgo,
the same way we handle the CC environment variable.
This ports https://go.dev/cl/526275 to the gofrontend repo.
This is needed for gccgo testing because the top-level GCC Makefile
now passes a --plugin option to ar if it supports one.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/526295
|
|
They are already collected via cmd/cgo.
The gccgo_link_c test is tweaked to do real linking as with this
change the cgo ldflags are not fully reflected in go build -n output,
since they now only come from the built archive.
This is a backport of https://go.dev/cl/497117 from the main repo.
For golang/go#60287
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/511675
|
|
* lang.opt (fgo-importcfg): New option.
* go-c.h (struct go_create_gogo_args): Add importcfg field.
* go-lang.cc (go_importcfg): New static variable.
(go_langhook_init): Set args.importcfg.
(go_langhook_handle_option): Handle -fgo-importcfg.
* gccgo.texi (Invoking gccgo): Document -fgo-importcfg.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/506095
|
|
In the Go 1.21 release the package internal/profile imports
internal/lazyregexp. That works when bootstrapping with Go 1.17,
because that compiler has internal/lazyregep and permits importing it.
We also have internal/lazyregexp in libgo, but since it is not installed
it is not available for importing. This CL adds internal/lazyregexp
to the list of internal packages that are installed for bootstrapping.
The Go 1.21, and earlier, releases have a couple of functions in
the internal/abi package that are always fully intrinsified.
The gofrontend recognizes and intrinsifies those functions as well.
However, the gofrontend was also building function descriptors
for references to the functions without calling them, which
failed because there was nothing to refer to. That is OK for the
gc compiler, which guarantees that the functions are only called,
not referenced. This CL arranges to not generate function descriptors
for these functions.
For golang/go#60913
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/504798
|
|
This fixes an accidental omission in the determine types pass.
Test case is https://go.dev/cl/505015.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/504797
|
|
The final argument to mmap, of type off_t, varies.
In CL 445375 we changed it to always use the C off_t type,
but that broke 32-bit big-endian Linux systems. On those systems,
using the C off_t type requires calling the mmap64 function.
In C this is automatically handled by the <sys/mman.h> file.
In Go, we would have to change the magic //extern comment to
call mmap64 when appropriate. Rather than try to get that right,
we instead go through a C function that uses C implicit type
conversions to pick the right type.
Fixes PR go/110297
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/504415
|
|
In CL 384695 I simplified the code that built lists of benchmarks,
examples, and fuzz tests, and managed to break it. This CL corrects
the code to once again make the benchmarks available, and to run
the examples with output and the fuzz targets.
Doing this revealed a test failure in internal/fuzz on 32-bit x86:
a signalling NaN is turned into a quiet NaN on the 387 floating-point
stack that GCC uses by default. This CL skips the test.
Fixes golang/go#60826
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/503798
|
|
As of https://go.dev/cl/476695 golang.org/x/sys/unix can call
syscall.prlimit, so we need such a function in libgo.
For golang/go#46279
Fixes golang/go#59712
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/486576
|
|
Backport CL 421442 from upstream.
Original description:
Arrange for tests that call setMimeInit to fully restore the old values,
by clearing the sync.Once that controls initialization.
Once we've done that, call initMime in initMimeUnixTest because
otherwise the test types loaded there will be cleared by the call to
initMime that previously was not being done.
For golang/go#51648
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/483117
|
|
In https://go.dev/cl/343873 we stopped padding zero-sized trailing
fields in functions that return multiple results where the last result
is zero-sized. This CL makes the corresponding change on the caller side.
The test case is https://go.dev/cl/479898.
Fixes golang/go#55242
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/479955
|
|
Fixes golang/go#59169
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/478176
|
|
This avoids clang warnings:
gcc/go/gofrontend/escape.cc:1290:17: warning: private field 'fn_' is not used [-Wunused-private-field]
gcc/go/gofrontend/escape.cc:3478:19: warning: private field 'context_' is not used [-Wunused-private-field]
gcc/go/gofrontend/lex.h:564:15: warning: private field 'input_file_name_' is not used [-Wunused-private-field]
gcc/go/gofrontend/types.cc:5788:20: warning: private field 'call_' is not used [-Wunused-private-field]
gcc/go/gofrontend/wb.cc:206:9: warning: private field 'gogo_' is not used [-Wunused-private-field]
Path by Martin Liška.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/458975
|
|
Patch from Sören Tempel.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/458396
|
|
PR go/108057
The current version is the same as for the previous GCC release,
but there have been minor changes like new type descriptors that
make it impossible to run Go programs built with the previous GCC
release with the current libgo.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/456976
|
|
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/454275
|
|
This does the right thing for either glibc or musl on GNU/Linux.
Based on patch by Sören Tempel.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/454176
|
|
The last argument to the C mmap function is type off_t, not uintptr.
On some 32-bit systems, off_t is larger than uintptr.
Based on patch by Sören Tempel.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/445735
|
|
The compiler neglected to notice that a conversion from a string
constant to a string type was a valid string constant.
No test case because this only caused a compiler failure when compiling
without optimization, which is not the normal case, and is not a case
that we test.
Fixes golang/go#56113
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/441555
|
|
Instead of building the thunk struct type in the determine_types pass,
build it when we need it. That ensures that we are consistent in
determining whether an argument is constant.
We no longer need to add a field for a call to recover, as the
simplify_thunk_statements pass runs after the build_recover_thunks pass,
so the additional argument will already have been added to the call.
The test case is https://go.dev/cl/440297.
Fixes golang/go#56109
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/440298
|
|
Tighten up the argument type checking for Builtin_call_expression to
catch erroneous cases such as
panic(panic("bad")))
where an argument void type is being passed to panic/alignof/sizeof.
Fixes golang/go#56071.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/439815
|
|
Previously, libgo relied on the _sigev_un implementation-specific
field in struct sigevent, which is only available on glibc.
This patch uses the sigev_notify_thread_id macro instead which is
mandated by timer_create(2). In theory, this should work with any libc
implementation for Linux. Unfortunately, there is an open glibc bug
as glibc does not define this macro. For this reason, a glibc-specific
workaround is required. Other libcs (such as musl) define the macro
and don't require the workaround.
See https://sourceware.org/bugzilla/show_bug.cgi?id=27417
This makes libgo compatible with musl libc.
Based on patch by Sören Tempel.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/434755
|