aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend
AgeCommit message (Collapse)AuthorFilesLines
2024-08-07compiler: don't assume that ATTRIBUTE_UNUSED is definedIan Lance Taylor2-2/+8
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/604075
2024-08-05compiler: panic arguments are empty interface typeIan Lance Taylor2-1/+7
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
2024-04-29runtime: dump registers on SolarisIan Lance Taylor1-1/+1
Patch by Rainer Orth <ro@gcc.gnu.org>. Fixes PR go/106813 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/581724
2024-04-29runtime: use <stdbool.h>Ian Lance Taylor1-1/+1
<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
2024-03-27compiler: use correct size and comparison in index value overflow checkIan Lance Taylor2-2/+2
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
2024-03-27compiler: initialize local variable in lower_method_expressionIan Lance Taylor2-2/+2
Fixes PR go/114463 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/574476
2024-02-05libgo: bump libgo version for GCC 14 releaseIan Lance Taylor1-1/+1
PR go/113668 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/560676
2024-02-05compiler: add Type::message_nameIan Lance Taylor4-25/+375
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
2024-02-02libgo: better error messages for unknown GOARCH/GOOSIan Lance Taylor1-1/+1
PR go/113530 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/557655
2024-02-02compiler: export the type "any" as a builtinIan Lance Taylor4-2/+5
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
2024-01-22compiler: don't pass iota value to lowering passIan Lance Taylor4-40/+37
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
2023-12-18compiler: move lowering pass after check types passIan Lance Taylor13-1595/+4034
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
2023-11-30libgo: update configure.ac to upstream GCCIan Lance Taylor1-1/+1
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
2023-10-23compiler: move Selector_expression up in fileIan Lance Taylor2-282/+282
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
2023-10-23compiler: make xx_constant_value methods non-constIan Lance Taylor3-67/+37
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
2023-10-23compiler: pass gogo to Runtime::make_callIan Lance Taylor9-170/+217
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
2023-10-23compiler: add Expression::is_untyped methodIan Lance Taylor3-1/+277
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
2023-10-23syscall: add missing type conversionIan Lance Taylor1-1/+1
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
2023-10-22compiler: remove traverse_assignments passIan Lance Taylor3-165/+1
The last caller was removed in https://go.dev/cl/18261 in 2016. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536637
2023-10-22compiler: remove name_ field from Type_switch_statementIan Lance Taylor4-15/+8
It's not used for anything. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536636
2023-10-22compiler: pass Gogo to determine types passIan Lance Taylor10-264/+280
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
2023-09-12libgo: fix DejaGNU testsuite compiler when using build sysrootIan Lance Taylor1-1/+1
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
2023-09-06cmd/go: permit $AR to include optionsIan Lance Taylor1-1/+1
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
2023-07-20cmd/go: don't collect package CGOLDFLAGS when using gccgoIan Lance Taylor1-1/+1
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
2023-06-26compiler: support -fgo-importcfgIan Lance Taylor6-7/+163
* 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
2023-06-23compiler, libgo: support bootstrapping gc compilerIan Lance Taylor3-3/+33
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
2023-06-21compiler: determine types of Slice_{value,info} expressionsIan Lance Taylor3-4/+13
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
2023-06-20runtime: use a C function to call mmapIan Lance Taylor1-1/+1
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
2023-06-16libgo/testsuite: add benchmarks and examples to listIan Lance Taylor1-1/+1
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
2023-05-11syscall: add prlimitIan Lance Taylor1-1/+1
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
2023-04-07mime: remove test ordering dependencyIan Lance Taylor1-1/+1
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
2023-03-28compiler: mark Call_expression multiple results as a result structIan Lance Taylor2-1/+2
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
2023-03-22compiler: add missing Slice_info_expression::do_traverseIan Lance Taylor2-1/+5
Fixes golang/go#59169 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/478176
2022-12-22compiler: remove unused fieldsIan Lance Taylor8-34/+19
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
2022-12-20libgo: check for makecontext in -lucontextIan Lance Taylor1-1/+1
Patch from Sören Tempel. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/458396
2022-12-12libgo: bump major versionIan Lance Taylor1-1/+1
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
2022-11-30runtime: force XSI strerror on hurdIan Lance Taylor1-1/+1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/454275
2022-11-29syscall, runtime: always call XSI strerror_rIan Lance Taylor1-1/+1
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
2022-10-27runtime: use _libgo_off_t_type when calling C mmapIan Lance Taylor1-1/+1
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
2022-10-10compiler: treat S("") as a string constantIan Lance Taylor2-1/+4
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
2022-10-10compiler: only build thunk struct type when it is neededIan Lance Taylor3-30/+11
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
2022-10-06compiler: better arg type checking for selected builtinsThan McIntosh2-2/+7
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
2022-09-27runtime: portable access to sigev_notify_thread_idIan Lance Taylor1-1/+1
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
2022-09-27runtime: synchronize empty struct field handlingmelonedo1-1/+1
In GCCGO and gollvm, the logic for allocating one byte for the last field is: 1. the last field has zero size 2. the struct itself does not have zero size 3. the last field is not blank this commit adds the last two conditions to runtime.structToFFI. For golang/go#55146 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/431735
2022-09-22cmd/cgo: add and use runtime/cgo.Incomplete instead of //go:notinheapIan Lance Taylor1-1/+1
This ports https://go.dev/cl/421879 to libgo. This is a quick port to update gofrontend to work with the version of cgo in gc mainline. A more complete port will follow, changing the gc version of cmd/cgo to choose an approach based on feature testing the gccgo in use. Updates golang/go#46731 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/432338
2022-09-06runtime: ignore __morestack function in runtime.CallersIan Lance Taylor1-1/+1
We were ignoring all functions starting with "__morestack_", but not the function "__morestack" itself. Without this change, some tests such as recover.go started failing recently, though I'm not sure exactly what changed. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/427935
2022-07-30libgo: use SYS_timer_settime32Ian Lance Taylor1-1/+1
Musl defines SYS_timer_settime32, not SYS_timer_settime, on 32-bit systems. Based on patch by Sören Tempel. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/420222
2022-07-22libgo: use POSIX shell arithmetic expansionIan Lance Taylor1-1/+1
Avoid bash-specific ((expression)) syntax. As the bash syntax converts a non-zero value to a zero status (and a zero value to a 1 status), and POSIX arithmetic expansion does not, we have to negate the result. Based on patch by Sören Tempel. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/419154
2022-07-13libgo: don't include <linux/fs.h> when building gen-sysinfo.goIan Lance Taylor1-1/+1
Removing this doesn't change anything at least with glibc 2.33. The include was added in https://go.dev/cl/6100049 but it's not clear why. Fixes PR go/106266 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/417294
2022-07-05compiler: propagate array length error marker fartherIan Lance Taylor3-2/+11
Fixes golang/go#53639 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/415936