Re: [PATCH][AArch64] Remove '*' from movsi/di/ti patterns
On Wed, Jul 26, 2017 at 6:46 AM, Wilco Dijkstra wrote: > Remove the remaining uses of '*' from the movsi/di/ti patterns. > Using '*' in alternatives is typically incorrect at it tells the register > allocator to ignore those alternatives. So remove these from all the > integer move patterns. This removes unnecessary int to float moves, for > example gcc.target/aarch64/pr62178.c no longer generates a redundant fmov > since the w = m variant is now allowed. > > Passes regress & bootstrap, OK for commit? I had looked into doing the similar thing but I did not have any way of benchmarking the patch, I decided to drop the patch. That is the patch looks good to me (though I cannot approve it). Thanks, Andrew > > ChangeLog: > 2017-07-26 Wilco Dijkstra > > * gcc/config/aarch64/aarch64.md (movsi_aarch64): Remove all '*'. > (movdi_aarch64): Likewise. > (movti_aarch64): Likewise. > -- > > diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md > index > 225b64e1daf1663d28bbe8c2d30ba373b4722176..97c5fb08a2fd5d2eee556e1fc20dbf65b089d84b > 100644 > --- a/gcc/config/aarch64/aarch64.md > +++ b/gcc/config/aarch64/aarch64.md > @@ -920,8 +920,8 @@ (define_expand "mov" > ) > > (define_insn_and_split "*movsi_aarch64" > - [(set (match_operand:SI 0 "nonimmediate_operand" "=r,k,r,r,r,r,*w,m, > m,r,r ,*w,r,*w") > - (match_operand:SI 1 "aarch64_mov_operand" " r,r,k,M,n,m, > m,rZ,*w,Usa,Ush,rZ,w,*w"))] > + [(set (match_operand:SI 0 "nonimmediate_operand" "=r,k,r,r,r,r,w,m, m, r, > r, w,r,w") > + (match_operand:SI 1 "aarch64_mov_operand" " > r,r,k,M,n,m,m,rZ,w,Usa,Ush,rZ,w,w"))] >"(register_operand (operands[0], SImode) > || aarch64_reg_or_zero (operands[1], SImode))" >"@ > @@ -952,8 +952,8 @@ (define_insn_and_split "*movsi_aarch64" > ) > > (define_insn_and_split "*movdi_aarch64" > - [(set (match_operand:DI 0 "nonimmediate_operand" "=r,k,r,r,r,r,*w,m, > m,r,r, *w,r,*w,w") > - (match_operand:DI 1 "aarch64_mov_operand" " r,r,k,N,n,m, > m,rZ,*w,Usa,Ush,rZ,w,*w,Dd"))] > + [(set (match_operand:DI 0 "nonimmediate_operand" "=r,k,r,r,r,r,w, m,m, r, > r, w,r,w,w") > + (match_operand:DI 1 "aarch64_mov_operand" " > r,r,k,N,n,m,m,rZ,w,Usa,Ush,rZ,w,w,Dd"))] >"(register_operand (operands[0], DImode) > || aarch64_reg_or_zero (operands[1], DImode))" >"@ > @@ -1008,9 +1008,9 @@ (define_expand "movti" > > (define_insn "*movti_aarch64" >[(set (match_operand:TI 0 > -"nonimmediate_operand" "=r, *w,r ,*w,r,m,m,*w,m") > +"nonimmediate_operand" "=r, w,r,w,r,m,m,w,m") > (match_operand:TI 1 > -"aarch64_movti_operand" " rn,r ,*w,*w,m,r,Z, m,*w"))] > +"aarch64_movti_operand" " rn,r,w,w,m,r,Z,m,w"))] >"(register_operand (operands[0], TImode) > || aarch64_reg_or_zero (operands[1], TImode))" >"@
Re: [PATCH][GCC][AArch64] Restrict lrint inlining on ILP32.
On Fri, Aug 11, 2017 at 2:58 AM, Tamar Christina wrote: > Hi All, > > The inlining of lrint isn't valid in all cases on ILP32 when > -fno-math-errno is used because an inexact exception is raised in > certain circumstances. > > For ILP32 I now restrict the inlining only when -fno-trapping-math > is also specified. > > This fixed PR/81800. > > Regtested on aarch64-none-linux-gnu and no regressions. > > Ok for trunk? I can't approve this patch but it looks good except for your changelog does not match what the code is doing. Maybe: Add check on !ilp32 or !flag_trapping_math. Thanks, Andrew > > Thanks, > Tamar > > gcc/ > 2017-08-11 Tamar Christina > > PR target/81800 > * config/aarch64/aarch64.md (lrint2): Add > flag_trapping_math. > > gcc/testsuite/ > 2017-08-11 Tamar Christina > > * gcc.target/aarch64/inline-lrint_2.c (dg-options): Add > -fno-trapping-math. > > --
[libstdc++,doc] Update reference to Hoard
This server moved from http to https, and the trailing slash is not needed for top-level domains (so best use however the server is representing itself). Applied. Gerald 2017-09-09 Gerald Pfeifer * doc/xml/manual/allocator.xml: Adjust link for Hoard. * doc/html/manual/memory.html: Regenerate. Index: doc/html/manual/memory.html === --- doc/html/manual/memory.html (revision 251917) +++ doc/html/manual/memory.html (working copy) @@ -320,7 +320,7 @@ . Matt Austern. C/C++ Users Journal . - http://www.hoard.org/"; target="_top"> + https://www.hoard.org"; target="_top"> The Hoard Memory Allocator . Emery Berger. @@ -676,4 +676,4 @@ . N2461 -. Prev Up NextPairs Home Traits \ No newline at end of file +. Prev Up NextPairs Home Traits Index: doc/xml/manual/allocator.xml === --- doc/xml/manual/allocator.xml(revision 251917) +++ doc/xml/manual/allocator.xml(working copy) @@ -520,7 +520,7 @@ http://www.w3.org/1999/xlink"; - xlink:href="http://www.hoard.org/";> + xlink:href="https://www.hoard.org";> The Hoard Memory Allocator
[wwwdocs] Update reference to MMIX
Knuth's homepage has moved, apparently. This adjust two references to MMIX in general and his book about it, and omits one in the GCC 3.1 release notes. Committed. Gerald Index: readings.html === RCS file: /cvs/gcc/wwwdocs/htdocs/readings.html,v retrieving revision 1.279 diff -u -r1.279 readings.html --- readings.html 9 Sep 2017 06:24:29 - 1.279 +++ readings.html 9 Sep 2017 06:31:26 - @@ -208,9 +208,10 @@ MMIX is used in program examples in Donald E. Knuth's http://www-cs-faculty.stanford.edu/~uno/taocp.html";>The Art of Computer Programming (ISBN 0-201-89683-4). - The http://www-cs-faculty.stanford.edu/~uno/mmix.html";>MMIX + The http://www-cs-faculty.stanford.edu/~knuth/mmix.htmll";>MMIX page has more information about MMIX. Knuth also wrote a - http://www-cs-faculty.stanford.edu/~uno/mmixware.html";>book + http://www-cs-faculty.stanford.edu/~knuth/mmixware.html";>book specifically about MMIX (MMIXware, ISBN 3-540-66938-8). Index: gcc-3.1/changes.html === RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.1/changes.html,v retrieving revision 1.72 diff -u -r1.72 changes.html --- gcc-3.1/changes.html29 Jan 2017 21:58:41 - 1.72 +++ gcc-3.1/changes.html9 Sep 2017 06:31:26 - @@ -255,8 +255,7 @@ New Targets and Target Specific Improvements -Hans-Peter Nilsson has contributed a port to http://www-cs-faculty.stanford.edu/~uno/mmix.html";>MMIX, +Hans-Peter Nilsson has contributed a port to MMIX, the CPU architecture used in new editions of Donald E. Knuth's The Art of Computer Programming.
Re: Ping on MIPS specific patch adds `short_call` synonym for `near` attribute
Hi Paul, Probably the patch in the original message is broken somehow. Anyway I attach updated patch to this mail. $ svn up Updating '.': At revision 251918. $ patch -p0 < ~/add_short_call_attribute.patch patching file gcc/config/mips/mips.c patching file gcc/doc/extend.texi patching file gcc/testsuite/gcc.target/mips/near-far-1.c patching file gcc/testsuite/gcc.target/mips/near-far-2.c patching file gcc/testsuite/gcc.target/mips/near-far-3.c patching file gcc/testsuite/gcc.target/mips/near-far-4.c On Sat, Sep 09, 2017 at 11:26:57AM +0800, Paul Hua wrote: > I would like to testing your patch on mips64el target. but your patch > can't apply to current trunk. > > On Thu, Sep 7, 2017 at 7:22 PM, Simon Atanasyan wrote: > > This is a ping for a small MIPS specific patch adds `short_call` > > synonym for existing `near` attribute. The patch has not been approved > > or commented on. > > > > Add 'short_call' attribute for MIPS targets. > > https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01280.html -- Simon Atanasyan Index: gcc/config/mips/mips.c === --- gcc/config/mips/mips.c (revision 251917) +++ gcc/config/mips/mips.c (working copy) @@ -598,6 +598,7 @@ static const struct attribute_spec mips_attribute_ /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler, om_diagnostic } */ { "long_call", 0, 0, false, true, true, NULL, false }, + { "short_call", 0, 0, false, true, true, NULL, false }, { "far", 0, 0, false, true, true, NULL, false }, { "near",0, 0, false, true, true, NULL, false }, /* We would really like to treat "mips16" and "nomips16" as type @@ -1171,13 +1172,14 @@ mflip_mips16_use_mips16_p (tree decl) return *slot; } -/* Predicates to test for presence of "near" and "far"/"long_call" +/* Predicates to test for presence of "near"/"short_call" and "far"/"long_call" attributes on the given TYPE. */ static bool mips_near_type_p (const_tree type) { - return lookup_attribute ("near", TYPE_ATTRIBUTES (type)) != NULL; + return (lookup_attribute ("short_call", TYPE_ATTRIBUTES (type)) != NULL + || lookup_attribute ("near", TYPE_ATTRIBUTES (type)) != NULL); } static bool Index: gcc/doc/extend.texi === --- gcc/doc/extend.texi (revision 251917) +++ gcc/doc/extend.texi (working copy) @@ -4528,10 +4528,12 @@ void __attribute__ ((interrupt("vector=hw3"))) v9 @end smallexample @item long_call +@itemx short_call @itemx near @itemx far @cindex indirect calls, MIPS @cindex @code{long_call} function attribute, MIPS +@cindex @code{short_call} function attribute, MIPS @cindex @code{near} function attribute, MIPS @cindex @code{far} function attribute, MIPS These attributes specify how a particular function is called on MIPS@. @@ -4539,8 +4541,9 @@ The attributes override the @option{-mlong-calls} command-line switch. The @code{long_call} and @code{far} attributes are synonyms, and cause the compiler to always call the function by first loading its address into a register, and then using -the contents of that register. The @code{near} attribute has the opposite -effect; it specifies that non-PIC calls should be made using the more +the contents of that register. The @code{short_call} and @code{near} +attributes are synonyms, and have the opposite +effect; they specify that non-PIC calls should be made using the more efficient @code{jal} instruction. @item mips16 Index: gcc/testsuite/gcc.target/mips/near-far-1.c === --- gcc/testsuite/gcc.target/mips/near-far-1.c (revision 251917) +++ gcc/testsuite/gcc.target/mips/near-far-1.c (working copy) @@ -3,6 +3,7 @@ extern int long_call_func () __attribute__((long_call)); extern int far_func () __attribute__((far)); +extern int short_call_func () __attribute__((short_call)); extern int near_func () __attribute__((near)); extern int normal_func (); @@ -10,6 +11,7 @@ int test () { return (long_call_func () + far_func () + + short_call_func () + near_func () + normal_func ()); } @@ -16,5 +18,6 @@ int test () /* { dg-final { scan-assembler-not "\tjal\tlong_call_func\n" } } */ /* { dg-final { scan-assembler-not "\tjal\tfar_func\n" } } */ +/* { dg-final { scan-assembler "\t(jal(|s)|balc)\tshort_call_func\n" } } */ /* { dg-final { scan-assembler "\t(jal(|s)|balc)\tnear_func\n" } } */ /* { dg-final { scan-assembler-not "\tjal\tnormal_func\n" } } */ Index: gcc/testsuite/gcc.target/mips/near-far-2.c === --- gcc/testsuite/gcc.target/mips/near-far-2.c (revision 251917) +++ gcc/testsuite/gcc.target/mips/near-far-2.c (working copy) @@ -3,6 +3,7 @@ extern int long_call_func () __attribute__((long_call)); extern int far_func () __attribute__((far)); +extern int short_c
[wwwdocs] readings.html - adjust link to compilers.iecc.com
Committed. Gerald (unfortunately on a train out of Praha - have a lovely and interesting day everyone there) Index: readings.html === RCS file: /cvs/gcc/wwwdocs/htdocs/readings.html,v retrieving revision 1.278 diff -u -r1.278 readings.html --- readings.html 29 Apr 2017 07:32:11 - 1.278 +++ readings.html 9 Sep 2017 06:23:54 - @@ -621,8 +621,7 @@ http://www.compilerconnection.com/";>Links related to many compiler topics - http://compilers.iecc.com/index.phtml";>comp.compilers archive + https://compilers.iecc.com";>comp.compilers archive Steven Muchnick (1997) "Advanced Compiler Design and Implementation". 880pp. ISBN: 1-55860-320-4.
Go patch committedd: Don't do implicit double pointer indirection
The Go frontend code that lowers field references could sometimes introduce a double pointer indirection in cases where it is not/safe appropriate. For example, in var p **struct { f int } p.f = 0 the assignment LHS was being incorrectly lowered to (*(*p)).f. This patch by Than McIntosh detects this situation and issues an error message. This fixes https://golang.org/issue/21770. A test will be committed to the master testsuite in https://golang.org/cl/62331. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE === --- gcc/go/gofrontend/MERGE (revision 251574) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -9d0d5c03a8086f5dd3a23e910abd6e470196973c +52ebad939927e6cbfb48dd277cef8db451e36533 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/types.cc === --- gcc/go/gofrontend/types.cc (revision 251533) +++ gcc/go/gofrontend/types.cc (working copy) @@ -11829,6 +11829,12 @@ Type::bind_field_or_method(Gogo* gogo, c go_assert(st != NULL); if (type->struct_type() == NULL) { + if (dereferenced) +{ + go_error_at(location, "pointer type has no field %qs", + Gogo::message_name(name).c_str()); + return Expression::make_error(location); +} go_assert(type->points_to() != NULL); expr = Expression::make_unary(OPERATOR_MULT, expr, location);
Re: Ping on MIPS specific patch adds `short_call` synonym for `near` attribute
Hi, Simon: I would like to testing your patch on mips64el target. but your patch can't apply to current trunk. error likes: --cut--- xuchenghua@fc21-2k4w:61: gcc_git_trunk $ patch -p0 < add_short_call_attribute.patch patching file gcc/config/mips/mips.c Hunk #1 FAILED at 598. Hunk #2 FAILED at 1171. 2 out of 2 hunks FAILED -- saving rejects to file gcc/config/mips/mips.c.rej patching file gcc/doc/extend.texi patching file gcc/testsuite/gcc.target/mips/near-far-1.c patching file gcc/testsuite/gcc.target/mips/near-far-2.c patching file gcc/testsuite/gcc.target/mips/near-far-3.c patching file gcc/testsuite/gcc.target/mips/near-far-4.c patch: malformed patch at line 159: "\t(j(|al|als)|b(|al)c)\tnormal_func\n" } } */ -- Could you give a new patch? Thanks, Paul Hua. On Thu, Sep 7, 2017 at 7:22 PM, Simon Atanasyan wrote: > This is a ping for a small MIPS specific patch adds `short_call` > synonym for existing `near` attribute. The patch has not been approved > or commented on. > > Add 'short_call' attribute for MIPS targets. > https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01280.html > > -- > Simon Atanasyan
Re: [PATCH] Improve alloca alignment
Hi Rainer, Can you post the disassembly for say the 8-byte aligned tests? It may not be built correctly or hit an offset that is accidentally aligned, however pass/fail status can't change due to my patch as it doesn't change alignment at all. Wilco
Re: [PATCH] Improve alloca alignment
Hi Wilco, > Eric Botcazou wrote: > >> The stack is aligned before the allocation but it gets misaligned during the >> allocation because the dynamic offset is not a multiple of STACK_BOUNDARY. > > No, the stack never gets misaligned - my patch doesn't change that at > all. The issue is that Sparc backend doesn't correctly set STACK_BOUNDSARY > and neither aligns the outgoing args. Run my test which proves alloca was > broken before my patch. I'm currently running my SPARC bootstraps with your patch backed out so regressions don't go overboard. The test PASSes this way. Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [PATCH] Improve alloca alignment
Eric Botcazou wrote: > The stack is aligned before the allocation but it gets misaligned during the > allocation because the dynamic offset is not a multiple of STACK_BOUNDARY. No, the stack never gets misaligned - my patch doesn't change that at all. The issue is that Sparc backend doesn't correctly set STACK_BOUNDSARY and neither aligns the outgoing args. Run my test which proves alloca was broken before my patch. Wilco
Re: [PATCH, rs6000] Fix PR target/80210: ICE in extract_insn
On 9/8/17 2:11 PM, Andreas Schwab wrote: > Executing on host: /daten/gcc/gcc-20170907/Build/gcc/xgcc > -B/daten/gcc/gcc-20170907/Build/gcc/ > /daten/gcc/gcc-20170907/gcc/testsuite/gcc.target/powerpc/pr80125.c -m32 > -fno-diagnostics-show-caret -fdiagnostics-color=never -O2 -maltivec -S -o > pr80125.s(timeout = 300) > > FAIL: gcc.target/powerpc/pr80210.c (internal compiler error) > FAIL: gcc.target/powerpc/pr80210.c (test for excess errors) David mentioned this to me earlier that he saw the same thing on AIX. I didn't see this on my BE builds, because my build scripts were using the --with-cpu=... configure command and using any -mcpu=... option will work around the bug. The bug isn't in my patch, since the ICE existed before my patch, we just didn't have the test case to notice before. The problem is due to a mismatch between TARGET_DEFAULT, which contains MASK_PPC_GPOPT and the ISA flags for the default "powerpc64" cpu, which does not contain MASK_PPC_GPOPT and how rs6000_option_override_internal() decides which one to use. The failure scenario is: Early on, we call init_all_optabs() which setups up a table which describes which patterns that generate some HW insns are "valid". Before we call init_all_optabs(), rs6000_option_override_internal() gets called with global_init_p arg set to "true" and we basically set rs6000_isa_flags to TARGET_DEFAULT. This is because we do not have a -mcpu= value nor do we have an "implicit_cpu", which forces us to use TARGET_DEFAULT. With this, init_all_optabs() thinks we can generate a HW sqrt, so it enables generating its pattern. Later, after we've scanned the entire file, we go to expand our function into RTL and we reset our compiler options and we end up calling rs6000_option_override_internal() again, but with global_init_p arg now false and we encounter this code: struct cl_target_option *main_target_opt = ((global_init_p || target_option_default_node == NULL) ? NULL : TREE_TARGET_OPTION (target_option_default_node)); This ends up setting main_target_opt to a non-NULL value, then: ... else if (main_target_opt != NULL && main_target_opt->x_rs6000_cpu_index >= 0) { rs6000_cpu_index = cpu_index = main_target_opt->x_rs6000_cpu_index; have_cpu = true; } So now we act as if the user explicitly passed in a -mcpu= option, then: ... /* If we have a cpu, either through an explicit -mcpu= or if the compiler was configured with --with-cpu=, replace all of the ISA bits with those from the cpu, except for options that were explicitly set. If we don't have a cpu, do not override the target bits set in TARGET_DEFAULT. */ if (have_cpu) { rs6000_isa_flags &= ~set_masks; rs6000_isa_flags |= (processor_target_table[cpu_index].target_enable & set_masks); } else { /* If no -mcpu=, inherit any default options that were cleared via POWERPC_MASKS. Originally, TARGET_DEFAULT was used to initialize target_flags via the TARGET_DEFAULT_TARGET_FLAGS hook. When we switched to using rs6000_isa_flags, we need to do the initialization here. If there is a TARGET_DEFAULT, use that. Otherwise fall back to using -mcpu=powerpc, -mcpu=powerpc64, or -mcpu=powerpc64le defaults. */ HOST_WIDE_INT flags = ((TARGET_DEFAULT) ? TARGET_DEFAULT : processor_target_table[cpu_index].target_enable); rs6000_isa_flags |= (flags & ~rs6000_isa_flags_explicit); } So the first time through here with global_init_p == true, have_cpu is set to false and we get TARGET_DEFAULT. The next time we come here, global_init_p == false and we set have_cpu to true because main_target_opt is non-NULL and the cpu_index value is set to "powerpc64" (for -m64 compiles) or "powerpc" (for -m32 compiles). This causes us to now grab the ISA flags from: processor_target_table[cpu_index].target_enable instead of from TARGET_DEFAULT and neither "powerpc64" or "powerpc" contain the MASK_PPC_GPOPT flag, which leads us to ICE because the optabs allows us to generate the HW sqrt pattern, but our ISA flags don't allow it. This doesn't affect LE builds, because it has a TARGET_DEFAULT value that matches the "powerpc64l" default masks. We also enforce passing a -mcpu=power8 option when the user doesn't explicitly use one, so again, not a problem. This also doesn't affect --target=powerpc-linux builds or --target=powerpc64-linux builds that default to 32-bit binaries, because we use a value of TARGET_DEFAULT == 0 (for both -m32 and -m64), so the first time through rs6000_option_override_internal(), we end up using processor_target_table[cpu_index].target_enable right from the beginning. The following patch fixes the problem I saw on Linux and bootstraps and regtests with no regressions on LE and BE (running testsuite in both 32-bit and 64-bit modes). I was waiting to submit this until David had a
Re: [PATCH][RFA/RFC] Stack clash mitigation patch 01/08 - V3
On 08/23/2017 10:39 AM, Richard Biener wrote: > On August 23, 2017 6:36:32 PM GMT+02:00, Jeff Law wrote: >> On 08/23/2017 03:07 AM, Richard Biener wrote: >> > Both -fstack-clash-protection and -fstack-check cannot be turned > off per function. This means they would need merging in >> lto-wrapper. > The alternative is to mark them with 'Optimization' and allow >> per-function > specification (like we do for -fstack-protector). Do you have a strong preference here? I'd tend to go with tweaking lto-wrapper as we really don't want to have this stuff varying >> per-function. >>> >>> Any reason? I see no technical one at least, it might break IPA >> assumptions >>> you make when instrumenting? I guess you just don't want to think >> about >>> the implications when mixing them (or mixing -fstack-clash-protection >>> with -fno-stack-clash-protection)? >> On some targets (s390 for example), a stack guard jump can be >> accomplished by a combination of caller and callee stack adjustments -- >> even though neither the caller nor the callee have a large enough >> adjustment individually to jump the guard. >> >> So a mis-informed developer could audit their code, declare various >> functions as safe & turn off protections on a per-function basis based >> on that analysis. But that would be mis-guided as it opens them up to >> a >> potential attack where the combination of caller and callee stack >> adjustments are used to jump the guard. >> >> >> >> >> >>> Presumably in lto-wrapper we just have to detect that both were >> enabled and do something sensible. We drop -fstack-check in toplev.c when >> both are specified, we could just as easily call that situation a fatal >> error in both toplev.c and lto-wrapper.c >>> >>> So what happens if you LTO link Ada (-fstack-check) with C >>> (-fstack-clash-protection)? >> When in the Ada code you'll be mostly protected from stack clashes and >> you can detect stack overflows and catch the signal properly. When in >> C >> code, you'd be fully protected from stack clash, but not necessarily >> able to take a signal. >> >> At the boundaries where you call from Ada to C, you're potentially >> vulnerable to stack clash on architectures like aarch64/s390. When >> calling from C into Ada, you're not guaranteed to be able to handle a >> signal when you overflow the stack. >> >>> The user is already allowed to (without LTO) specify things on a CU >> granularity. >> True. And you end up with a mixture of protections depending on what >> code is executing or what boundary you're crossing. > > So the natural thing for LTO ist to make it function granular. That way you > don't need any magic in LTO-wrapper. Done. jeff
Re: Ping on target independent stack clash protection patches
On 08/18/2017 09:56 AM, Eric Botcazou wrote: >> #01 of #08: >> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01971.html >> >> #02 of #08: >> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01972.html >> >> #03 of #08: >> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01974.html >> >> Need to reach some kind of closure on these, then I can start pinging >> the target maintainers for the rest of the bits... > > All OK with me, thanks for your attention to the interaction with Ada. > > Minor nit: > > + Stack checking is designed to detect infinite recursion for Ada > + programs. Furthermore stack checking tries to ensure that scenario > + that enough stack space is left to run a signal handler. > > Let's use the same wording as in invoke.texi: "...infinite recursion and > stack > overflows for...". Missing "in" before "that scenario'. Both nits fixed. Jeff
[PATCH] PR c++/81852 define feature-test macro for -fthreadsafe-statics
Define the __cpp_lib_threadsafe_static_init feature-test macro as per recent SD-6 drafts. Tested powerpc64le-linux and x86_64-linux. OK for trunk? The branches too? commit 3ff1faeb36fad84f682f9b353152d450f8dfff92 Author: Jonathan Wakely Date: Fri Sep 8 19:07:24 2017 +0100 PR c++/81852 define feature-test macro for -fthreadsafe-statics gcc/c-family: PR c++/81852 * c-cppbuiltin.c (c_cpp_builtins): Define __cpp_threadsafe_static_init. gcc/testsuite: PR c++/81852 * g++.dg/cpp1y/feat-cxx11.C: Check __cpp_threadsafe_static_init. * g++.dg/cpp1y/feat-cxx14.C: Likewise. * g++.dg/cpp1y/feat-cxx98.C: Likewise. * g++.dg/cpp1y/feat-neg.C: Likewise. * g++.dg/cpp1z/feat-cxx1z.C: Likewise. diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 8f377f698a6..4330c9102d9 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -987,6 +987,8 @@ c_cpp_builtins (cpp_reader *pfile) } if (flag_new_ttp) cpp_define (pfile, "__cpp_template_template_args=201611"); + if (flag_threadsafe_statics) + cpp_define (pfile, "__cpp_threadsafe_static_init=200806"); } /* Note that we define this for C as well, so that we know if __attribute__((cleanup)) will interface with EH. */ diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C index 98112218d8f..b18fcfabad4 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx11.C @@ -125,6 +125,12 @@ # error "__cpp_alias_templates != 200704" #endif +#ifndef __cpp_threadsafe_static_init +# error "__cpp_threadsafe_static_init" +#elif __cpp_threadsafe_static_init != 200806 +# error "__cpp_threadsafe_static_init != 200806" +#endif + // C++14 features allowed in C++11 in non-ANSI modes: #ifndef __cpp_binary_literals diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C index 3b141ef67c4..412b9a33b8f 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx14.C @@ -118,6 +118,12 @@ # error "__cpp_alias_templates != 200704" #endif +#ifndef __cpp_threadsafe_static_init +# error "__cpp_threadsafe_static_init" +#elif __cpp_threadsafe_static_init != 200806 +# error "__cpp_threadsafe_static_init != 200806" +#endif + // C++14 features: #ifndef __cpp_binary_literals diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C index d15e7aadcee..4db499cc2f4 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-cxx98.C @@ -15,6 +15,14 @@ # error "__cpp_exceptions != 199711" #endif +// C++11 features allowed in C++98: + +#ifndef __cpp_threadsafe_static_init +# error "__cpp_threadsafe_static_init" +#elif __cpp_threadsafe_static_init != 200806 +# error "__cpp_threadsafe_static_init != 200806" +#endif + // C++14 features allowed in C++98 in non-ANSI modes: #ifndef __cpp_binary_literals diff --git a/gcc/testsuite/g++.dg/cpp1y/feat-neg.C b/gcc/testsuite/g++.dg/cpp1y/feat-neg.C index 9f4a0412403..5e95418dfe4 100644 --- a/gcc/testsuite/g++.dg/cpp1y/feat-neg.C +++ b/gcc/testsuite/g++.dg/cpp1y/feat-neg.C @@ -1,5 +1,5 @@ // { dg-do compile } -// { dg-options "-fno-rtti -fno-exceptions" } +// { dg-options "-fno-rtti -fno-exceptions -fno-threadsafe-statics" } // C++98 features with explicit opt-out: @@ -10,3 +10,9 @@ #ifndef __cpp_exceptions # error "__cpp_exceptions" // { dg-error "error" } #endif + +// C++11 features with explicit opt-out: + +#ifndef __cpp_threadsafe_static_init +# error "__cpp_threadsafe_static_init" // { dg-error "error" } +#endif diff --git a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C index e424e1c0ff0..a7c6cfe5169 100644 --- a/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C +++ b/gcc/testsuite/g++.dg/cpp1z/feat-cxx1z.C @@ -106,6 +106,12 @@ # error "__cpp_alias_templates != 200704" #endif +#ifndef __cpp_threadsafe_static_init +# error "__cpp_threadsafe_static_init" +#elif __cpp_threadsafe_static_init != 200806 +# error "__cpp_threadsafe_static_init != 200806" +#endif + // C++14 features: #ifndef __cpp_binary_literals
Re: [PATCH, rs6000] Fix PR target/80210: ICE in extract_insn
Executing on host: /daten/gcc/gcc-20170907/Build/gcc/xgcc -B/daten/gcc/gcc-20170907/Build/gcc/ /daten/gcc/gcc-20170907/gcc/testsuite/gcc.target/powerpc/pr80125.c -m32 -fno-diagnostics-show-caret -fdiagnostics-color=never -O2 -maltivec -S -o pr80125.s(timeout = 300) FAIL: gcc.target/powerpc/pr80210.c (internal compiler error) FAIL: gcc.target/powerpc/pr80210.c (test for excess errors) Excess errors: /daten/gcc/gcc-20170907/gcc/testsuite/gcc.target/powerpc/pr80210.c:9:1: error: unrecognizable insn: (insn 6 3 7 2 (set (reg:DF 121 [ ]) (sqrt:DF (reg/v:DF 122 [ a ]))) "/daten/gcc/gcc-20170907/gcc/testsuite/gcc.target/powerpc/pr80210.c":8 -1 (nil)) during RTL pass: vregs /daten/gcc/gcc-20170907/gcc/testsuite/gcc.target/powerpc/pr80210.c:9:1: internal compiler error: in extract_insn, at recog.c:2306 0x1013f86f _fatal_insn(char const*, rtx_def const*, char const*, int, char const*) ../../gcc/rtl-error.c:108 0x1013f8b3 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*) ../../gcc/rtl-error.c:116 0x106926fb extract_insn(rtx_insn*) ../../gcc/recog.c:2306 0x1043e5f7 instantiate_virtual_regs_in_insn ../../gcc/function.c:1591 0x1043e5f7 instantiate_virtual_regs ../../gcc/function.c:1959 0x1043e5f7 execute ../../gcc/function.c:2008 Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Re: [PATCH], PR target/82015, add PowerPC warning for unpack_vector_int128 with illegal 2nd argument
FAIL: gcc.target/powerpc/pr82015.c (test for errors, line 8) FAIL: gcc.target/powerpc/pr82015.c (test for errors, line 13) FAIL: gcc.target/powerpc/pr82015.c (test for excess errors) Excess errors: /daten/gcc/gcc-20170907/gcc/testsuite/gcc.target/powerpc/pr82015.c:6:22: error: unknown type name 'vector' /daten/gcc/gcc-20170907/gcc/testsuite/gcc.target/powerpc/pr82015.c:11:21: error: unknown type name 'vector' Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
[PATCH version 2, rs6000] Add builtins to convert from float/double to int/long using current rounding mode
GCC Maintainers: The following patch adds support for a couple of requested builtins that convert from float/double to int / long using the current rounding mode. I initially posted an early version of this patch which generated redundant instructions. The patch has been tested on powerpc64le-unknown-linux-gnu (Power 8 LE). Please let me know if the following patch is acceptable. Thanks. Carl Love -- gcc/ChangeLog: 2017-09-08 Carl Love * config/rs6000/rs6000-builtin.def (FCTID, FCTIW): Add BU_P7_MISC_1 macro expansion for builtins. * config/rs6000/rs6000.md (fctid, fctiw): Add define_insn for the fctid and fctiw instructions. gcc/testsuite/ChangeLog: 2017-09-08 Carl Love * gcc.target/powerpc/builtin-fctid-fctiw-runnable.c: New test file for the __builtin_fctid and __builtin_fctiw builtins. --- gcc/config/rs6000/rs6000-builtin.def | 2 + gcc/config/rs6000/rs6000.md| 16 +++ .../powerpc/builtin-fctid-fctiw-runnable.c | 140 + 3 files changed, 158 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/builtin-fctid-fctiw-runnable.c diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def index 850164a..c7983e9 100644 --- a/gcc/config/rs6000/rs6000-builtin.def +++ b/gcc/config/rs6000/rs6000-builtin.def @@ -2231,6 +2231,8 @@ BU_DFP_MISC_2 (DSCRIQ,"dscriq", CONST, dfp_dscri_td) /* 1 argument BCD functions added in ISA 2.06. */ BU_P7_MISC_1 (CDTBCD, "cdtbcd", CONST, cdtbcd) BU_P7_MISC_1 (CBCDTD, "cbcdtd", CONST, cbcdtd) +BU_P7_MISC_1 (FCTID, "fctid",CONST, fctid) +BU_P7_MISC_1 (FCTIW, "fctiw",CONST, fctiw) /* 2 argument BCD functions added in ISA 2.06. */ BU_P7_MISC_2 (ADDG6S, "addg6s", CONST, addg6s) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index 20873ac..3113fe7 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -115,6 +115,8 @@ UNSPEC_CMPB UNSPEC_FCTIW UNSPEC_FCTID + UNSPEC_FCTID_INST + UNSPEC_FCTIW_INST UNSPEC_LFIWAX UNSPEC_LFIWZX UNSPEC_FCTIWUZ @@ -14054,6 +14056,20 @@ [(set_attr "type" "integer") (set_attr "length" "4")]) +(define_insn "fctid" + [(set (match_operand:DI 0 "gpc_reg_operand" "=d") +(unspec:DI [(match_operand:DF 1 "gpc_reg_operand" "d")] + UNSPEC_FCTID_INST))] + "" + "fctid %0,%1") + +(define_insn "fctiw" + [(set (match_operand:SI 0 "gpc_reg_operand" "=d") + (unspec:SI [(match_operand:DF 1 "gpc_reg_operand" "d")] + UNSPEC_FCTIW_INST))] + "" + "fctiw %0,%1") + (define_int_iterator UNSPEC_DIV_EXTEND [UNSPEC_DIVE UNSPEC_DIVEO UNSPEC_DIVEU diff --git a/gcc/testsuite/gcc.target/powerpc/builtin-fctid-fctiw-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtin-fctid-fctiw-runnable.c new file mode 100644 index 000..e6cf46f --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/builtin-fctid-fctiw-runnable.c @@ -0,0 +1,140 @@ +/* { dg-do run { target { powerpc64*-*-* && { lp64 && p8vector_hw } } } } */ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-options "-mcpu=power8" } */ + +#define DEBUG 1 + +#ifdef DEBUG +#include +#endif + +void abort (void); + +long +test_bi_lrint_1 (float __A) +{ + return (__builtin_fctid (__A)); +} +long +test_bi_lrint_2 (double __A) +{ + return (__builtin_fctid (__A)); +} + +int +test_bi_rint_1 (float __A) +{ + return (__builtin_fctiw (__A)); +} + +int +test_bi_rint_2 (double __A) +{ + return (__builtin_fctiw (__A)); +} + + +int main( void) +{ + signed long lx, expected_l; + double dy; + + signed int x, expected_i; + float y; + + dy = 1.45; + expected_l = 1; + lx = __builtin_fctid (dy); + + if( lx != expected_l) +#ifdef DEBUG +printf("ERROR: __builtin_fctid(dy= %f) = %ld, expected %ld\n", + dy, lx, expected_l); +#else +abort(); +#endif + + dy = 3.51; + expected_l = 4; + lx = __builtin_fctid (dy); + + if( lx != expected_l) +#ifdef DEBUG +printf("ERROR: __builtin_fctid(dy= %f) = %ld, expected %ld\n", + dy, lx, expected_l); +#else +abort(); +#endif + + dy = 5.57; + expected_i = 6; + x = __builtin_fctiw (dy); + + if( x != expected_i) +#ifdef DEBUG +printf("ERROR: __builtin_fctiw(dy= %f) = %d, expected %d\n", + dy, x, expected_i); +#else +abort(); +#endif + + y = 11.47; + expected_i = 11; + x = __builtin_fctiw (y); + + if( x != expected_i) +#ifdef DEBUG +printf("ERROR: __builtin_fctiw(y = %f) = %d, expected %d\n", + y, x, expected_i); +#else +abort(); +#endif + + y = 17.77; + expected_l = 18; + lx = test_bi_lrint_1 (y); + + if( lx !=
Re: [Ada] Move non-tasking runtime sources to libgnat subdirectory
> Given that you're moving the files, I wonder what the rationale is for > moving them to another subdirectory within gcc/ada, rather than to > something within the top-level libada directory (or some other top-level > directory or directories, as appropriate), since such top-level > directories outside gcc/ are the normal location for target library files? The main reason is that it's much more practical wrt to our source setup at AdaCore since Ada sources are standalone and can be used e.g. without GCC, so depending on the GCC layout for GNAT sources isn't very convenient. Arno
Re: [Ada] Move non-tasking runtime sources to libgnat subdirectory
On Fri, 8 Sep 2017, Arnaud Charlet wrote: > This is the second big source reorg in the GNAT sources, this time all > runtimme source belonging to libgnat are moved to a new subdirectory > libgnat. Given that you're moving the files, I wonder what the rationale is for moving them to another subdirectory within gcc/ada, rather than to something within the top-level libada directory (or some other top-level directory or directories, as appropriate), since such top-level directories outside gcc/ are the normal location for target library files? -- Joseph S. Myers jos...@codesourcery.com
Re: [doc,libgomp] Updates for www.openacc.org URLs
On Sep 8, 2017, at 5:27 AM, Gerald Pfeifer wrote: > > I committed the patch below, but am wondering whether we really, > really, really need as many instances of one and the same URL in > one section of the documentation? Can we simplify this somehow? Curious that they don't link to https://www.openacc.org/sites/default/files/inline-files/OpenACC_2_0_specification.pdf for that actual document. The generic link to the top matter can be in the first paragraph. It would be nice if all the links could be links to the actual section, something like https://www.openacc.org/sites/default/files/inline-files/OpenACC_2_0_specification.pdf#page=31, but I guess that would be a little bit of work. :-) Not sure this is what you wanted to hear.
[SPARC] Fix PR target/81988
This is a regression present on the mainline and 7 branch: when the register pressure is high, the use of DI/SI paradoxical subregs causes LRA to generate invalid accesses to odd-numbered FP registers when registers are spilled. The attached patch is aimed at drying up a big source of DI/SI paradoxical subregs, namely 32-bit multiplication operations. Tested on SPARC64/Linux, applied on mainline and 7 branch. 2017-09-08 Eric Botcazou PR target/81988 * config/sparc/sparc.md (mulsi3): Rename into *mulsi3_sp32. (*mulsi3_sp64): New instruction. (mulsi3): New expander. 2017-09-08 Eric Botcazou * gcc.dg/pr81988.c: New test. -- Eric BotcazouIndex: config/sparc/sparc.md === --- config/sparc/sparc.md (revision 251861) +++ config/sparc/sparc.md (working copy) @@ -4517,7 +4517,14 @@ (define_insn "*cmp_ccv_minus_sltu_set" ;; The 32-bit multiply/divide instructions are deprecated on v9, but at ;; least in UltraSPARC I, II and IIi it is a win tick-wise. -(define_insn "mulsi3" +(define_expand "mulsi3" + [(set (match_operand:SI 0 "register_operand" "") + (mult:SI (match_operand:SI 1 "arith_operand" "") + (match_operand:SI 2 "arith_operand" "")))] + "TARGET_HARD_MUL || TARGET_ARCH64" + "") + +(define_insn "*mulsi3_sp32" [(set (match_operand:SI 0 "register_operand" "=r") (mult:SI (match_operand:SI 1 "arith_operand" "%r") (match_operand:SI 2 "arith_operand" "rI")))] @@ -4525,6 +4532,14 @@ (define_insn "mulsi3" "smul\t%1, %2, %0" [(set_attr "type" "imul")]) +(define_insn "*mulsi3_sp64" + [(set (match_operand:SI 0 "register_operand" "=r") + (mult:SI (match_operand:SI 1 "arith_operand" "%r") + (match_operand:SI 2 "arith_operand" "rI")))] + "TARGET_ARCH64" + "mulx\t%1, %2, %0" + [(set_attr "type" "imul")]) + (define_expand "muldi3" [(set (match_operand:DI 0 "register_operand" "") (mult:DI (match_operand:DI 1 "arith_operand" "") /* PR target/81988 */ /* Testcase by James Cowgill */ /* { dg-do assemble } */ /* { dg-require-effective-target pie } */ /* { dg-options "-O3 -fpie" } */ int c, d; short **e; int *a; void foo(void) { int g[64 * 35], *h = g; do { short *f = e[d]; for (int i = 0; i < 4; i++) a[i] = a[i] + (h[364] + f[4] * h[64] + f[5] * h[i] + f[6] * h[i + 3 * 4] + f[7] * h[i + 4]); } while (c); }
Re: [PATCH] Improve alloca alignment
> This patch brought back PR libgomp/78468, which had caused its > predecessor to be backed out of gcc-7. Yes, it's exactly the same mistake: + /* Since the stack is presumed to be aligned before this allocation, + we only need to increase the size of the allocation if the required + alignment is more than the stack alignment. */ The stack is aligned before the allocation but it gets misaligned during the allocation because the dynamic offset is not a multiple of STACK_BOUNDARY. The code had been realigning the stack pointer for more than 2 decades to enforce STACK_BOUNDARY but suddenly stopped again with Wilco's patch. The failure mode is very nasty (random corruption of the stack contents) and there are very likely other affected targets among the ~50 supported ones. -- Eric Botcazou
Re: RFA (langhook): PATCH for c++/70029, ICE in verify_type with ref-qualifier
On September 8, 2017 4:56:18 PM GMT+02:00, Jason Merrill wrote: >The issue here is that the C++ front end represents the ref-qualifier >as a variant but includes it in the canonical type, because at the >language level the types are distinct. Note that this is also true of >language-independent qualifiers like "const", so this doesn't seem >like an unreasonable thing for the front end to do. > >But as a result, when build_type_attribute_qual_variant builds a >distinct type copy of the ref-qualified type, it is now its own main >variant, while the canonical type is still a variant of another type, >and verify_type doesn't like that. > >This patch introduces a langhook to mimic for language-dependent >qualifiers the b_t_a_q_v behavior for cv-qualifiers, i.e. strip them >before making the copy and reintroduce them afterward. > >Tested x86_64-pc-linux-gnu. OK for trunk? OK. Richard.
Re: [PATCH] Fix atomic builtins on arrays (PR target/82112)
On Thu, Sep 7, 2017 at 11:38 PM, Joseph Myers wrote: > On Thu, 7 Sep 2017, Jakub Jelinek wrote: > >> Ah, ok, so like this instead? >> >> 2017-09-07 Jakub Jelinek >> >> PR target/82112 >> * c-common.c (sync_resolve_size): Instead of c_dialect_cxx () >> assertion check that in the condition. >> (get_atomic_generic_size): Likewise. Before testing if parameter >> has pointer type, if it has array type, call for C++ >> default_conversion to perform array-to-pointer conversion. >> >> * c-c++-common/pr82112.c: New test. >> * gcc.dg/pr82112.c: New test. > > This version is OK. OK with me as well. Jason
Re: std::forward_list optim for always equal allocator
On 28/08/17 21:09 +0200, François Dumont wrote: Hi Any news for this patch ? It does remove a constructor: -_Fwd_list_impl(const _Node_alloc_type& __a) -: _Node_alloc_type(__a), _M_head() It was already unused before the patch. Do you think it has ever been used and so do I need to restore it ? I eventually restore the _M_head() in _Fwd_list_impl constructors cause IMO it is the inline init of _M_next in _Fwd_list_node_base which should be removed. But I remember Jonathan that you didn't want to do so because gcc was not good enough in detecting usage of uninitialized variables, is it still true ? Why should it be removed?
Re: [libstdc++/71500] make back reference work with icase
On 04/09/17 03:31 -0700, Tim Shen via libstdc++ wrote: This fixes the follow-up comments in 71500. Back-reference matching is different from other matching, as the content the back-reference refers to is at "run-time", aka during regex_match(), not regex() compilation. For compilation we do have an abstraction layer to catch all comparison customizations, namely _M_translator in regex_compiler.h. Until this patch, we don't have an abstraction for "run-time" matching. I believe that back-reference is the only place that needs run-time matching, so I just build a _Backref_matcher in regex_executot.tcc. Looks like a nice solution. OK for trunk, thanks. I think this looks safe to backport too, but let's leave it on trunk for a while first.
Re: Rb_tree constructor optimization
On 28/08/17 21:12 +0200, François Dumont wrote: Hi Here is the always equal allocator optimization for associative containers. Tested under Linux x86_64. * include/bits/stl_tree.h (_Rb_tree_impl(_Rb_tree_impl&&, _Node_allocator&&)): New. (_Rb_tree(_Rb_tree&&, _Node_allocator&&, std::true_type)): New. (_Rb_tree(_Rb_tree&&, _Node_allocator&&, std::false_type)): Likewise. (_Rb_tree(_Rb_tree&&, _Node_allocator&&)): Adapt, use latters. Ok to apply ? François diff --git a/libstdc++-v3/include/bits/stl_tree.h b/libstdc++-v3/include/bits/stl_tree.h index c2417f1..f7d34e3 100644 --- a/libstdc++-v3/include/bits/stl_tree.h +++ b/libstdc++-v3/include/bits/stl_tree.h @@ -704,6 +704,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #else _Rb_tree_impl(_Rb_tree_impl&&) = default; + _Rb_tree_impl(_Rb_tree_impl&& __x, _Node_allocator&& __a) noexcept This is an unconditional noexcept, but ... + : _Node_allocator(std::move(__a)), + _Base_key_compare(std::move(__x)), This constructor has a conditional noexcept. That's a bug. + _Rb_tree_header(std::move(__x)) + { } However, I don't think we need this new constructor anyway, see below. _Rb_tree_impl(const _Key_compare& __comp, _Node_allocator&& __a) : _Node_allocator(std::move(__a)), _Base_key_compare(__comp) { } @@ -947,7 +953,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _Rb_tree(std::move(__x), _Node_allocator(__a)) { } - _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a); +private: + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, std::true_type) noexcept This noexcept should be conditional. + : _M_impl(std::move(__x._M_impl), std::move(__a)) + { } Since we know __a == __x.get_allocator() we could just do: _Rb_tree(_Rb_tree&& __x, _Node_allocator&&, true_type) noexcept(is_nothrow_move_constructible<_Rb_tree_impl<_Compare>>::value) : _M_impl(std::move(__x._M_impl)) { } This means we don't need the new constructor. Or equivalently, just delegate to the move constructor: _Rb_tree(_Rb_tree&& __x, _Node_allocator&&, true_type) noexcept(is_nothrow_move_constructible<_Rb_tree>::value) : _Rb_tree(std::move(__x)) { } + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, std::false_type); + +public: + _Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a) + : _Rb_tree(std::move(__x), std::move(__a), +typename _Alloc_traits::is_always_equal{}) + { } #endif ~_Rb_tree() _GLIBCXX_NOEXCEPT @@ -1591,12 +1608,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: -_Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a) +_Rb_tree(_Rb_tree&& __x, _Node_allocator&& __a, std::false_type __eq) : _M_impl(__x._M_impl._M_key_compare, std::move(__a)) { - using __eq = typename _Alloc_traits::is_always_equal; if (__x._M_root() != nullptr) - _M_move_data(__x, __eq()); + _M_move_data(__x, __eq); } I think this constructor is simple enough that it should be defined in-class, so it's inline. There's no need to qualify true_type and false_type with the std namespace (I don't know why some of the existing code does that).
[Ada] Move non-tasking runtime sources to libgnat subdirectory
This is the second big source reorg in the GNAT sources, this time all runtimme source belonging to libgnat are moved to a new subdirectory libgnat. Diff is too large to be attached, even compressed with bzip2 -9. I'm only including the diff on gcc-interface which is the not completely trivial and not completely mechanical part. Note that this change requires a complete removal of your build/obj dir and a new build from scratch (configure; make). In other words, incremental builds will not survive this change. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Nicolas Roche * gcc-interface/Make-lang.in, gcc-interface/Makefile.in: Find runtime source in libgnat/ * a-lfztio.ads, g-timsta.ads, g-sercom-linux.adb, s-osprim-solaris.adb, a-inteio.ads, s-stchop-rtems.adb, s-casuti.adb, s-pack39.adb, i-vxwork-x86.ads, a-strbou.adb, a-stzmap.adb, s-assert.adb, a-sfecin.ads, a-cohama.adb, s-casuti.ads, a-suenco.adb, s-pack39.ads, a-stzmap.ads, a-strbou.ads, s-stalib.adb, s-trasym.adb, g-comver.adb, s-assert.ads, s-vector.ads, g-cgi.adb, a-cohama.ads, s-wchcnv.adb, a-titest.adb, s-pack48.adb, a-suenco.ads, a-strunb.adb, s-stalib.ads, s-trasym.ads, a-nudira.adb, g-comver.ads, a-nuflra.adb, g-cgi.ads, a-chacon.adb, s-wchcnv.ads, a-excach.adb, s-pack48.ads, a-titest.ads, a-strunb.ads, s-dwalin.adb, a-nudira.ads, a-chtgbo.adb, s-resfil.adb, a-scteio.ads, a-nuflra.ads, g-soliop-mingw.ads, s-pack57.adb, a-chacon.ads, s-bytswa.ads, s-pooloc.adb, g-os_lib.adb, s-dwalin.ads, a-szuzha.adb, s-resfil.ads, a-chtgbo.ads, s-spsufi.adb, s-pack57.ads, s-pooloc.ads, g-os_lib.ads, a-stfiha.ads, a-lcteio.ads, a-wtcoau.adb, a-szuzha.ads, s-mmosin-unix.adb, a-stmaco.ads, s-spsufi.ads, s-stchop-limit.ads, a-wtcoau.ads, a-exctra.adb, s-mmosin-unix.ads, s-sequio.adb, s-conca2.adb, g-table.adb, s-imglli.adb, a-numaux-x86.adb, a-strsea.adb, s-wchstw.adb, a-clrefi.adb, a-wwboio.adb, a-exctra.ads, s-sequio.ads, s-conca2.ads, a-wwunio.ads, system-linux-hppa.ads, g-table.ads, s-dimkio.ads, s-imglli.ads, a-cofove.adb, a-numaux-x86.ads, s-wchstw.ads, a-strsea.ads, a-clrefi.ads, a-wwboio.ads, s-stratt-xdr.adb, s-crc32.adb, s-excmac-arm.adb, g-busora.adb, a-cofove.ads, s-osprim-unix.adb, g-io.adb, s-pack49.adb, s-crc32.ads, s-excmac-arm.ads, a-fzteio.ads, g-busora.ads, s-stausa.adb, system-linux-mips.ads, sequenio.ads, g-exctra.adb, g-rewdat.adb, a-cgaaso.adb, g-io.ads, s-pack49.ads, a-wtflau.adb, a-undesu.adb, s-stausa.ads, a-ztenau.adb, g-enutst.ads, calendar.ads, s-pack58.adb, g-rewdat.ads, g-exctra.ads, s-ststop.adb, a-cgaaso.ads, a-strfix.adb, a-comlin.adb, a-strunb-shared.adb, a-wtflau.ads, a-undesu.ads, a-cbhase.adb, a-ztenau.ads, s-os_lib.adb, a-coorse.adb, a-chlat1.ads, s-pack58.ads, s-ststop.ads, a-strfix.ads, a-comlin.ads, a-strunb-shared.ads, a-nscefu.ads, s-valboo.adb, directio.ads, a-chtgke.adb, a-cbhase.ads, a-wtinau.adb, system-linux-alpha.ads, s-os_lib.ads, a-coorse.ads, system-linux-s390.ads, s-imgwiu.adb, a-chtgop.adb, s-valboo.ads, a-chtgke.ads, a-tienio.adb, s-conca3.adb, a-wtinau.ads, system-darwin-ppc.ads, i-c.adb, s-expllu.adb, g-expect.adb, g-sha256.ads, s-vallld.adb, s-imgwiu.ads, a-chtgop.ads, a-strmap.adb, a-tienio.ads, s-conca3.ads, s-imgint.adb, i-c.ads, s-expllu.ads, s-osprim-darwin.adb, a-cogeso.adb, g-expect.ads, a-iwteio.ads, s-vallld.ads, a-coinho-shared.adb, g-shsh64.adb, a-strmap.ads, g-comlin.adb, a-excpol.adb, s-imgint.ads, a-ztdeau.adb, a-cogeso.ads, a-coinho-shared.ads, g-shsh64.ads, g-comlin.ads, a-stzsup.adb, a-rbtgbk.adb, a-wtmoau.adb, a-ztdeau.ads, s-exnlli.adb, g-tty.adb, g-heasor.adb, g-socthi-dummy.adb, s-llflex.ads, a-zchara.ads, a-stzsup.ads, a-ztcstr.adb, a-rbtgbk.ads, a-sfwtio.ads, a-wtmoau.ads, a-sulcin.adb, s-exnlli.ads, system-freebsd.ads, a-stunha.adb, a-charac.ads, g-tty.ads, g-heasor.ads, s-exctra.adb, g-socthi-dummy.ads, a-coboho.adb, a-ztcstr.ads, a-tideio.adb, a-sulcin.ads, a-wrstfi.adb, g-alleve.adb, s-pack59.adb, a-ngrear.adb, a-stboha.adb, a-stunau-shared.adb, a-stunha.ads, a-lfwtio.ads, s-fileio.adb, s-exctra.ads, a-coboho.ads, a-ioexce.ads, a-tideio.ads, a-ngrear.ads, a-wrstfi.ads, s-pack59.ads, g-alleve.ads, a-stboha.ads, s-poosiz.adb, g-traceb.adb, g-rannum.adb, machcode.ads, s-purexc.ads, s-fileio.ads, a-cfinve.adb, a-crbtgk.adb, system-solaris-x86.ads, s-poosiz.ads, g-rannum.ads, g-traceb.ads, a-except.adb, s-conca4.adb, a-stream.adb, a-cfinve.ads, a-crbtgk.ads, s-wchwts.adb, system-mingw.ads, a-except.ads, s-conca4.ads, a-chzla9.ads, s-valenu.adb, s-soflin.adb, a-stream.ads, a-cgarso.a
RFA (langhook): PATCH for c++/70029, ICE in verify_type with ref-qualifier
The issue here is that the C++ front end represents the ref-qualifier as a variant but includes it in the canonical type, because at the language level the types are distinct. Note that this is also true of language-independent qualifiers like "const", so this doesn't seem like an unreasonable thing for the front end to do. But as a result, when build_type_attribute_qual_variant builds a distinct type copy of the ref-qualified type, it is now its own main variant, while the canonical type is still a variant of another type, and verify_type doesn't like that. This patch introduces a langhook to mimic for language-dependent qualifiers the b_t_a_q_v behavior for cv-qualifiers, i.e. strip them before making the copy and reintroduce them afterward. Tested x86_64-pc-linux-gnu. OK for trunk? commit 50a71bc8cbf3d17f0039f531b96e64f348b83549 Author: Jason Merrill Date: Fri Sep 8 00:09:46 2017 +0200 PR c++/70029 - ICE with ref-qualifier and -flto gcc/ * langhooks.h (struct lang_hooks_for_types): Add copy_lang_qualifiers. * attribs.c (build_type_attribute_qual_variant): Use it. * langhooks-def.h (LANG_HOOKS_COPY_LANG_QUALIFIERS): Default to NULL. (LANG_HOOKS_FOR_TYPES_INITIALIZER): Use it. * tree.c (verify_type): Re-enable TYPE_CANONICAL main variant check. gcc/cp/ * tree.c (cxx_copy_lang_qualifiers): New. * cp-tree.h: Declare it. * cp-objcp-common.h: Define LANG_HOOKS_COPY_LANG_QUALIFIERS. diff --git a/gcc/attribs.c b/gcc/attribs.c index faa0649..b8f58a7 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -959,8 +959,9 @@ build_decl_attribute_variant (tree ddecl, tree attribute) Record such modified types already made so we don't make duplicates. */ tree -build_type_attribute_qual_variant (tree ttype, tree attribute, int quals) +build_type_attribute_qual_variant (tree otype, tree attribute, int quals) { + tree ttype = otype; if (! attribute_list_equal (TYPE_ATTRIBUTES (ttype), attribute)) { tree ntype; @@ -983,6 +984,11 @@ build_type_attribute_qual_variant (tree ttype, tree attribute, int quals) } ttype = build_qualified_type (ttype, TYPE_UNQUALIFIED); + if (lang_hooks.types.copy_lang_qualifiers + && otype != TYPE_MAIN_VARIANT (otype)) + ttype = (lang_hooks.types.copy_lang_qualifiers +(ttype, TYPE_MAIN_VARIANT (otype))); + ntype = build_distinct_type_copy (ttype); TYPE_ATTRIBUTES (ntype) = attribute; @@ -1000,6 +1006,9 @@ build_type_attribute_qual_variant (tree ttype, tree attribute, int quals) TYPE_CANONICAL (ntype) = TYPE_CANONICAL (ttype); ttype = build_qualified_type (ntype, quals); + if (lang_hooks.types.copy_lang_qualifiers + && otype != TYPE_MAIN_VARIANT (otype)) + ttype = lang_hooks.types.copy_lang_qualifiers (ttype, otype); } else if (TYPE_QUALS (ttype) != quals) ttype = build_qualified_type (ttype, quals); diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index 10fcdf3..3e4cc9c 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -99,6 +99,8 @@ extern void cp_register_dumps (gcc::dump_manager *); #define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE cxx_builtin_function_ext_scope #undef LANG_HOOKS_TYPE_HASH_EQ #define LANG_HOOKS_TYPE_HASH_EQcxx_type_hash_eq +#undef LANG_HOOKS_COPY_LANG_QUALIFIERS +#define LANG_HOOKS_COPY_LANG_QUALIFIERScxx_copy_lang_qualifiers #undef LANG_HOOKS_MISSING_NORETURN_OK_P #define LANG_HOOKS_MISSING_NORETURN_OK_P cp_missing_noreturn_ok_p #undef LANG_HOOKS_BLOCK_MAY_FALLTHRU diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a0e31d3..a57de33 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6963,6 +6963,7 @@ extern tree convert_bitfield_to_declared_type (tree); extern tree cp_save_expr (tree); extern bool cast_valid_in_integral_constant_expression_p (tree); extern bool cxx_type_hash_eq (const_tree, const_tree); +extern tree cxx_copy_lang_qualifiers (const_tree, const_tree); extern void cxx_print_statistics (void); extern bool maybe_warn_zero_as_null_pointer_constant (tree, location_t); diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 12c31fb..f387f38 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -4626,6 +4626,21 @@ cxx_type_hash_eq (const_tree typea, const_tree typeb) TYPE_RAISES_EXCEPTIONS (typeb), ce_exact); } +/* Copy the language-specific type variant modifiers from TYPEB to TYPEA. For + C++, these are the exception-specifier and ref-qualifier. */ + +tree +cxx_copy_lang_qualifiers (const_tree typea, const_tree typeb) +{ + tree type = CONST_CAST_TREE (typea); + if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE) +{ + type = build_exception_variant (type, TYPE_RAISES_EXCEPTIONS (typeb)); +
[PATCH, alpha]: Fix bootstrap failure due to -Wtautological-compare warning
The alpha bootstrap currently fails due to always true condition warning in a dead code. Patch removes the unneeded code. 2017-09-08 Uros Bizjak * config/alpha/alpha.c (alpha_print_operand) : Remove. Bootstrapped and regression tested on alphaev68-linux-gnu. Committed to mainline SVN. Uros. Index: config/alpha/alpha.c === --- config/alpha/alpha.c(revision 251898) +++ config/alpha/alpha.c(working copy) @@ -5294,17 +5294,6 @@ alpha_print_operand (FILE *file, rtx x, int code) fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) / 8); break; -case 'S': - /* Same, except compute (64 - c) / 8 */ - - if (!CONST_INT_P (x) - && (unsigned HOST_WIDE_INT) INTVAL (x) >= 64 - && (INTVAL (x) & 7) != 8) - output_operand_lossage ("invalid %%s value"); - - fprintf (file, HOST_WIDE_INT_PRINT_DEC, (64 - INTVAL (x)) / 8); - break; - case 'C': case 'D': case 'c': case 'd': /* Write out comparison name. */ {
[Ada] New pragma Ada_2020
This patch allows pragma Ada_2020 to be used to enable Ada 2020 features that have been implemented in GNAT. Ada_2020 is a configuration pragma. This is in addition to the -gnat2020 command-line switch. Note: There is no synonym pragma Ada_20. We have Ada_05 and Ada_12, but we decided long ago that for years after 2000, four-digit numbers look better. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Bob Duff * par-prag.adb, sem_prag.adb, snames.ads-tmpl: Implement pragma Ada_2020, along the same lines as the other Ada version pragmas. Index: par-prag.adb === --- par-prag.adb(revision 251892) +++ par-prag.adb(working copy) @@ -326,14 +326,16 @@ case Prag_Id is + -- Ada version pragmas must be processed at parse time, because we want + -- to set the Ada version properly at parse time to recognize the + -- appropriate Ada version syntax. However, pragma Ada_2005 and higher + -- have an optional argument; it is only the zero argument form that + -- must be processed at parse time. + -- Ada_83 -- - -- This pragma must be processed at parse time, since we want to set - -- the Ada version properly at parse time to recognize the appropriate - -- Ada version syntax. - when Pragma_Ada_83 => if not Latest_Ada_Only then Ada_Version := Ada_83; @@ -345,10 +347,6 @@ -- Ada_95 -- - -- This pragma must be processed at parse time, since we want to set - -- the Ada version properly at parse time to recognize the appropriate - -- Ada version syntax. - when Pragma_Ada_95 => if not Latest_Ada_Only then Ada_Version := Ada_95; @@ -360,11 +358,6 @@ -- Ada_05/Ada_2005 -- - - -- These pragmas must be processed at parse time, since we want to set - -- the Ada version properly at parse time to recognize the appropriate - -- Ada version syntax. However, it is only the zero argument form that - -- must be processed at parse time. - when Pragma_Ada_05 | Pragma_Ada_2005 => @@ -378,11 +371,6 @@ -- Ada_12/Ada_2012 -- - - -- These pragmas must be processed at parse time, since we want to set - -- the Ada version properly at parse time to recognize the appropriate - -- Ada version syntax. However, it is only the zero argument form that - -- must be processed at parse time. - when Pragma_Ada_12 | Pragma_Ada_2012 => @@ -392,6 +380,17 @@ Ada_Version_Pragma := Pragma_Node; end if; + -- + -- Ada_2020 -- + -- + + when Pragma_Ada_2020 => + if Arg_Count = 0 then +Ada_Version := Ada_2020; +Ada_Version_Explicit := Ada_2020; +Ada_Version_Pragma := Pragma_Node; + end if; + --- -- Compiler_Unit_Warning -- --- Index: sem_prag.adb === --- sem_prag.adb(revision 251893) +++ sem_prag.adb(working copy) @@ -11835,7 +11835,7 @@ -- The one argument form is used for managing the transition from Ada -- 2005 to Ada 2012 in the run-time library. If an entity is marked - -- as Ada_201 only, then referencing the entity in any pre-Ada_2012 + -- as Ada_2012 only, then referencing the entity in any pre-Ada_2012 -- mode will generate a warning. In addition, in any pre-Ada_2012 -- mode, a preference rule is established which does not choose -- such an entity unless it is unambiguously specified. This avoids @@ -11883,6 +11883,28 @@ end if; end; + -- + -- Ada_2020 -- + -- + + -- pragma Ada_2020; + + -- Note: this pragma also has some specific processing in Par.Prag + -- because we want to set the Ada 2020 version mode during parsing. + + when Pragma_Ada_2020 => +GNAT_Pragma; + +Check_Arg_Count (0); + +Check_Valid_Configuration_Pragma; + +-- Now set appropriate Ada mode + +Ada_Version := Ada_2020; +Ada_Version_Explicit := Ada_2020; +Ada_Version_Pragma := N; + -- -- All_Calls_Remote -- -- @@ -29419,6 +29441,7 @@ Pragma_Ada_2005 => -1, Pragma_Ada_12 => -1, Pragma_Ada_2012 => -1, + Pragma_Ada_2020 => -1, Pragma_All_Calls_Remote => -1, Pragma_All
[Ada] Extend efficient array reset to all elementary types
This change extends the efficient handling of an array reset to 0 by means of an aggregate with a single Others choice from a discrete component type to any elementary type. The 3 instances of the Reset procedure below must invoke memset: with G; package P is subtype Index is Positive range 1 .. 128; type Ptr is access all Integer; package My_G_I is new G (Index, Integer, 0); package My_G_F is new G (Index, Float, 0.0); package My_G_P is new G (Index, Ptr, null); end P; generic type Header_Num is range <>; type Element is private; Null_Element : Element; package G is procedure Reset; end G; package body G is Table : array (Header_Num) of Element; procedure Reset is begin Table := (others => Null_Element); end; end G; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Eric Botcazou * exp_aggr.adb: Add with & use clause for Urealp. (Aggr_Assignment_OK_For_Backend): Accept (almost all) elementary types instead of just discrete types. * sem_eval.adb (Expr_Value): Deal with N_Null for access types. * gcc-interface/trans.c (gnat_to_gnu) : Be prepared for the FP zero value in the memset case. Add small guard. Index: exp_aggr.adb === --- exp_aggr.adb(revision 251893) +++ exp_aggr.adb(working copy) @@ -61,6 +61,7 @@ with Stringt; use Stringt; with Tbuild; use Tbuild; with Uintp;use Uintp; +with Urealp; use Urealp; package body Exp_Aggr is @@ -4894,7 +4895,7 @@ --4. The array type has no null ranges (the purpose of this is to -- avoid a bogus warning for an out-of-range value). - --5. The component type is discrete + --5. The component type is elementary --6. The component size is Storage_Unit or the value is of the form -- M * (1 + A**1 + A**2 + .. A**(K-1)) where A = 2**(Storage_Unit) @@ -4970,7 +4971,13 @@ return False; end if; - if not Is_Discrete_Type (Ctyp) then + -- All elementary types are supported except for fat pointers + -- because they are not really elementary for the backend. + + if not Is_Elementary_Type (Ctyp) + or else (Is_Access_Type (Ctyp) + and then Esize (Ctyp) /= System_Address_Size) + then return False; end if; @@ -4990,6 +4997,14 @@ return False; end if; + -- The only supported value for floating point is 0.0 + + if Is_Floating_Point_Type (Ctyp) then +return Expr_Value_R (Expr) = Ureal_0; + end if; + + -- For other types, we can look into the value as an integer + Value := Expr_Value (Expr); if Has_Biased_Representation (Ctyp) then Index: sem_eval.adb === --- sem_eval.adb(revision 251892) +++ sem_eval.adb(working copy) @@ -4199,6 +4199,12 @@ pragma Assert (Is_Fixed_Point_Type (Underlying_Type (Etype (N; Val := Corresponding_Integer_Value (N); + -- The NULL access value + + elsif Kind = N_Null then + pragma Assert (Is_Access_Type (Underlying_Type (Etype (N; + Val := Uint_0; + -- Otherwise must be character literal else Index: gcc-interface/trans.c === --- gcc-interface/trans.c (revision 251892) +++ gcc-interface/trans.c (working copy) @@ -7037,14 +7037,17 @@ /* Or else, use memset when the conditions are met. */ else if (use_memset_p) { - tree value = fold_convert (integer_type_node, gnu_rhs); + tree value + = real_zerop (gnu_rhs) + ? integer_zero_node + : fold_convert (integer_type_node, gnu_rhs); tree to = gnu_lhs; tree type = TREE_TYPE (to); tree size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (TYPE_SIZE_UNIT (type), to); tree to_ptr = build_fold_addr_expr (to); tree t = builtin_decl_explicit (BUILT_IN_MEMSET); - if (TREE_CODE (value) == INTEGER_CST) + if (TREE_CODE (value) == INTEGER_CST && !integer_zerop (value)) { tree mask = build_int_cst (integer_type_node,
[Ada] No room for new warning switches
This patch adds machinary to create new warning flags using the underscore "_" prefix. This is necessary because all letters of the alphabet and letters prefixed with a dot "." are used already. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Justin Squirek * switch-c.adb (Scan_Front_End_Switches): Add new warning switch case to handle underscore flags. * warnsw.adb, warnsw.ads (Set_Underscore_Warning_Switch): Create new procedure to handle underscores. Index: switch-c.adb === --- switch-c.adb(revision 251892) +++ switch-c.adb(working copy) @@ -1268,8 +1268,20 @@ Bad_Switch ("-gnatw." & Switch_Chars (Ptr .. Max)); end if; - -- Normal case, no dot + -- Case of underscore switch + elsif C = '_' and then Ptr < Max then + Ptr := Ptr + 1; + C := Switch_Chars (Ptr); + + if Set_Underscore_Warning_Switch (C) then +Store_Compilation_Switch ("-gnatw_" & C); + else +Bad_Switch ("-gnatw_" & Switch_Chars (Ptr .. Max)); + end if; + + -- Normal case, no dot + else if Set_Warning_Switch (C) then Store_Compilation_Switch ("-gnatw" & C); Index: warnsw.adb === --- warnsw.adb (revision 251892) +++ warnsw.adb (working copy) @@ -471,6 +471,24 @@ return True; end Set_Dot_Warning_Switch; + --- + -- Set_Underscore_Warning_Switch -- + --- + + function Set_Underscore_Warning_Switch (C : Character) return Boolean is + begin + case C is + when others => +if Ignore_Unrecognized_VWY_Switches then + Write_Line ("unrecognized switch -gnatw_" & C & " ignored"); +else + return False; +end if; + end case; + + return True; + end Set_Underscore_Warning_Switch; + -- Set_GNAT_Mode_Warnings -- Index: warnsw.ads === --- warnsw.ads (revision 251892) +++ warnsw.ads (working copy) @@ -147,6 +147,13 @@ -- the command line or .C in a string literal in pragma Warnings. Returns -- True for valid warning character C, False for invalid character. + function Set_Underscore_Warning_Switch (C : Character) return Boolean; + -- This function sets the warning switch or switches corresponding to the + -- given character preceded by an underscore. Used to process a -gnatw_ + -- switch on the command line or _C in a string literal in pragma Warnings. + -- Returns True for valid warnings character C, False for invalid + -- character. + procedure Set_GNAT_Mode_Warnings; -- This is called in -gnatg mode to set the warnings for gnat mode. It is -- also used to set the proper warning statuses for -gnatw.g. Note that
[Ada] Missing error in function expressions
The compiler skips reporting errors located in function expressions. After this patch the error is reported in the following sources: package Base is type Base_Type is tagged record V : Integer; end record; function Func_1 (B : Base_Type) return Integer is (B.V); end; with Base; package DB is type DB_Type is new Base.Base_Type with record Y : Integer; end record; overriding function Func_1 (B : DB_Type) return Integer; private function Func_1 (B : DB_Type) return Integer is (Base.Func_1 (Base_Type (B)) / 8 * 4); -- Error end; Command: gcc -c db.ads Output: db.ads:13:20: "Base_Type" is not visible db.ads:13:20: non-visible declaration at base.ads:2 Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Javier Miranda * sem_ch8.adb (Find_Direct_Name.Undefined): Do not add entries into the undefined reference table when we are compiling with errors ignored. Index: sem_ch8.adb === --- sem_ch8.adb (revision 251892) +++ sem_ch8.adb (working copy) @@ -5328,9 +5328,10 @@ -- Make entry in undefined references table unless the full errors -- switch is set, in which case by refraining from generating the -- table entry, we guarantee that we get an error message for every - -- undefined reference. + -- undefined reference. The entry is not added if we are ignoring + -- errors. - if not All_Errors_Mode then + if not All_Errors_Mode and then Ignore_Errors_Enable = 0 then Urefs.Append ( (Node => N, Err => Emsg,
[Ada] Spurious error on formal package with Inline_Always
This patch removes spurious errors appearing on a formal package of an instantiation nestled within an enclosing instance body. when the inner instance is a package that includes a subprogram with an Inline_Always aspect. The following must compile quietly: gnstmske -q -gnatws main --- with Def_Volume_Act_Conf; with Env_Volume_Act_Conf; with Iterate_On_Weekly_Values_General_G; package body Airspace_Utilities is procedure Iteration_On_Active_Configurations_G (Airspace_Uid : Env_Volume.T; During_Period : Period.T) is pragma Unreferenced (Airspace_Uid); procedure Local_Action (Activation_Info : Env_Volume_Act_Conf.T; The_Period : Period.T) is pragma Unreferenced (Activation_Info); procedure Config_Action (Subperiod : Period.T; Config: Env_Configuration.T) is begin Action (Subperiod, Config); end Config_Action; use Def_Volume_Act_Conf; procedure Iterate_On_Periods is new Iterate_On_Weekly_Values_General_G (Value_T => Env_Configuration.T, Interval_T => Def_Volume_Act_Conf.Base_Interval.T, Value_Weekly => Def_Volume_Act_Conf.Weekly, Action => Config_Action); begin Iterate_On_Periods (Activity => Def_Volume_Act_Conf.Weekly.None, Validity => The_Period); end Local_Action; procedure Iterate_On_Weekly_Activities is new Env_Volume_Act_Conf.Iteration_During_Period_G (Local_Action); begin Iterate_On_Weekly_Activities (Env_Volume.None, During_Period); end Iteration_On_Active_Configurations_G; procedure Set_Active (The_Airspace : Env_Volume.T) is procedure One_Configuration (Subperiod : Period.T; The_Configuration : Env_Configuration.T) is null; procedure Examine is new Iteration_On_Active_Configurations_G (Action => One_Configuration); pragma Compile_Time_Warning (True, "Instantiation fails with rather bogus error message."); begin Examine (The_Airspace, Period.None); end Set_Active; end Airspace_Utilities; --- with Env_Volume; with Env_Configuration; with Period; package Airspace_Utilities is generic with procedure Action (Subperiod: Period.T; Configurable_Uid : Env_Configuration.T); procedure Iteration_On_Active_Configurations_G (Airspace_Uid : Env_Volume.T; During_Period : Period.T); procedure Set_Active (The_Airspace : Env_Volume.T); end Airspace_Utilities; --- with Ada.Strings; generic type Bound_T is private; package Base_Interval_G is type T is private; private type T is array (Ada.Strings.Alignment) of Bound_T; pragma Compile_Time_Warning (True, "Indexed(?) type triggers the bug."); -- type T is null record; -- This version does not trigger the bug. end Base_Interval_G; --- with Base_Interval_G; with Env_Configuration; with General_Interval_Partition_G; with Time; package Def_Volume_Act_Conf is package Base_Interval is new Base_Interval_G (Bound_T => Time.Duration_T); package Weekly is new General_Interval_Partition_G (Item_T => Time.Duration_T, Interval_T => Base_Interval.T, Value_T=> Env_Configuration.T); end Def_Volume_Act_Conf; --- with Env_Versioned_Value_Set_G; with Interfaces; package Env_Configuration is new Env_Versioned_Value_Set_G (Base_Uid_T => Interfaces.Integer_16); generic type Base_Uid_T is range <>; package Env_Versioned_Value_Set_G is type Base_T is new Base_Uid_T range Base_Uid_T'First .. Base_Uid_T'Last - 1; subtype T is Base_T range 0 .. Base_T'Last; subtype Uid_T is T; None : constant Uid_T := 0; end Env_Versioned_Value_Set_G; --- with Env_Versioned_Value_Set_G; with Interfaces; package Env_Volume is new Env_Versioned_Value_Set_G (Base_Uid_T => Interfaces.Integer_16); package body Env_Volume_Act_Conf is procedure Iteration_During_Period_G (Vol : Env_Volume.T; During_Period : Period.T) is pragma Unreferenced (Vol, During_Period); begin null; end Iteration_During_Period_G; end Env_Volume_Act_Conf; --- with Env_Volume; with Period; package Env_Volume_Act_Conf is type T is private; generic with procedure Action (Info : T; Validity : Period.T); pragma Unreferenced (Action); procedure Iteration_During_Period_G (Vol : Env_Volume.T; During_Period : Period.T); private type T is new Natural; end Env_Volume_Act_Conf; package body General_Interval_Partition_G is function Get (Partition : T; Key : Item_T) return Value_T is pragma
[Ada] Crash on string concatenation
This patch replaces several calls to New_Copy in aggregage expansion and all calls to New_Copy in concatenation expansion with calls to New_Copy_Tree. The former left the syntactic structure of the tree ambiguous, where certain nodes would theoretically have two parents, while the AST supports only one parent. The incorrect parent pointers then prohibited the replication of itypes in the context of New_Copy_Tree. The patch also reimplements New_Copy_Tree to address the following issues: * Multiple itypes may have the same Associated_Node_For_Itype which needs to be updated for all those itypes once the node is replicated. This was not happening correctly, the update was performed for only the "last" itype. * Certain semantic attributes of non-itype entities were not replicated. * Certain semantic attributes of nodes were not replicated. -- Source -- -- q.ads package Q is type Arr is array (Natural range <>) of Integer; function Length (S : String) return Integer; function Get return String; end Q; -- p.ads with Q; use Q; package P is function F return Arr; end P; -- p.adb package body P is function F return Arr is begin return (1 => Length (Get & ".")); end F; end P; - -- Compilation -- - $ gcc -c -gnatd.h p.adb Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Hristian Kirtchev * exp_aggr.adb (Expand_Array_Aggregate): Use New_Copy_Tree instead of New_Copy because the latter leaves the syntactic structure of the tree inconsistent (a child is accessible through two parents) and prevents proper replication of itypes by subsequent calls to New_Copy_Tree. * exp_ch4.adb (Expand_Concatenate): Use New_Copy_Tree instead of New_Copy because the latter leaves the syntactic structure of the tree inconsistent (a child is accessible through two parents) and prevents proper replication of itypes by subsequent calls to New_Copy_Tree. * sem_util.adb (In_Subtree): New routine. (New_Copy_Tree): Reimplemented. * sem_util.ads (In_Subtree): New routine. (New_Copy_Tree): Reimplemented. Index: exp_aggr.adb === --- exp_aggr.adb(revision 251892) +++ exp_aggr.adb(working copy) @@ -6275,7 +6275,7 @@ New_List ( Make_Assignment_Statement (Loc, Name => Target, - Expression => New_Copy (N))); + Expression => New_Copy_Tree (N))); else Aggr_Code := Index: exp_ch4.adb === --- exp_ch4.adb (revision 251892) +++ exp_ch4.adb (working copy) @@ -3194,7 +3194,7 @@ Object_Definition => New_Occurrence_Of (Artyp, Loc), Expression => Make_Op_Add (Loc, -Left_Opnd => New_Copy (Aggr_Length (NN - 1)), +Left_Opnd => New_Copy_Tree (Aggr_Length (NN - 1)), Right_Opnd => Clen))); Aggr_Length (NN) := Make_Identifier (Loc, Chars => Chars (Ent)); @@ -3275,7 +3275,7 @@ function Get_Known_Bound (J : Nat) return Node_Id is begin if Is_Fixed_Length (J) or else J = NN then - return New_Copy (Opnd_Low_Bound (J)); + return New_Copy_Tree (Opnd_Low_Bound (J)); else return @@ -3288,7 +3288,7 @@ Right_Opnd => Make_Integer_Literal (Loc, 0)), -New_Copy (Opnd_Low_Bound (J)), +New_Copy_Tree (Opnd_Low_Bound (J)), Get_Known_Bound (J + 1))); end if; end Get_Known_Bound; @@ -3313,10 +3313,10 @@ High_Bound := To_Ityp (Make_Op_Add (Loc, - Left_Opnd => To_Artyp (New_Copy (Low_Bound)), + Left_Opnd => To_Artyp (New_Copy_Tree (Low_Bound)), Right_Opnd => Make_Op_Subtract (Loc, - Left_Opnd => New_Copy (Aggr_Length (NN)), + Left_Opnd => New_Copy_Tree (Aggr_Length (NN)), Right_Opnd => Make_Artyp_Literal (1; -- Note that calculation of the high bound may cause overflow in some @@ -3341,7 +3341,7 @@ Make_If_Expression (Loc, Expressions => New_List ( Make_Op_Eq (Loc, - Left_Opnd => New_Copy (Aggr_Length (NN)), + Left_Opnd => New_Copy_Tree (Aggr_Length (NN)), Right_Opnd => Make_Artyp_Literal (0)), Last_Opnd_Low_Bound, Low_Bound)); @@ -3350,7 +3350,7 @@ Make_If_Expression (Loc, Express
[doc,libgomp] Updates for www.openacc.org URLs
We were nearly down to around a dozen of problematic links on gcc.gnu.org and our online docs, when the following popped up: www.openacc.org switched to https (and does not require a trailing slash). I committed the patch below, but am wondering whether we really, really, really need as many instances of one and the same URL in one section of the documentation? Can we simplify this somehow? (Note, this came in with revision 232283 and the following ChangeLog: 2016-01-12 James Norris * libgomp.texi: Updates for OpenACC. ) Gerald PS: Here's my committed patch. 2017-09-03 Gerald Pfeifer * libgomp.texi (Top): www.openacc.org now uses https. (Enabling OpenACC): Ditto. (acc_get_num_devices): Ditto. (acc_set_device_type): Ditto. (acc_get_device_type): Ditto. (acc_set_device_num): Ditto. (acc_get_device_num): Ditto. (acc_async_test): Ditto. (acc_async_test_all): Ditto. (acc_wait): Ditto. (acc_wait_all): Ditto. (acc_wait_all_async): Ditto. (acc_wait_async): Ditto. (acc_init): Ditto. (acc_shutdown): Ditto. (acc_on_device): Ditto. (acc_malloc): Ditto. (acc_free): Ditto. (acc_copyin): Ditto. (acc_present_or_copyin): Ditto. (acc_create): Ditto. (acc_present_or_create): Ditto. (acc_copyout): Ditto. (acc_delete): Ditto. (acc_update_device): Ditto. (acc_update_self): Ditto. (acc_map_data): Ditto. (acc_unmap_data): Ditto. (acc_deviceptr): Ditto. (acc_hostptr): Ditto. (acc_is_present): Ditto. (acc_memcpy_to_device): Ditto. (acc_memcpy_from_device): Ditto. (acc_get_current_cuda_device): Ditto. (acc_get_current_cuda_context): Ditto. (acc_get_cuda_stream): Ditto. (acc_set_cuda_stream): Ditto. (ACC_DEVICE_TYPE): Ditto. (ACC_DEVICE_NUM): Ditto. (OpenACC Library Interoperability): Ditto. Index: libgomp/libgomp.texi === --- libgomp/libgomp.texi(revision 251887) +++ libgomp/libgomp.texi(working copy) @@ -77,7 +77,7 @@ implementation of the @uref{http://www.openmp.org, OpenMP} Application Programming Interface (API) for multi-platform shared-memory parallel programming in C/C++ and Fortran, and the GNU implementation of the -@uref{http://www.openacc.org/, OpenACC} Application Programming +@uref{https://www.openacc.org, OpenACC} Application Programming Interface (API) for offloading of code to accelerator devices in C/C++ and Fortran. @@ -1816,7 +1816,7 @@ (@ref{OpenACC Runtime Library Routines}). A complete description of all OpenACC directives accepted may be found in -the @uref{http://www.openacc.org/, OpenACC} Application Programming +the @uref{https://www.openacc.org, OpenACC} Application Programming Interface manual, version 2.0. Note that this is an experimental feature and subject to @@ -1918,7 +1918,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, section +@uref{https://www.openacc.org, OpenACC specification v2.0}, section 3.2.1. @end table @@ -1943,7 +1943,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, section +@uref{https://www.openacc.org, OpenACC specification v2.0}, section 3.2.2. @end table @@ -1968,7 +1968,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, section +@uref{https://www.openacc.org, OpenACC specification v2.0}, section 3.2.3. @end table @@ -1995,7 +1995,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, section +@uref{https://www.openacc.org, OpenACC specification v2.0}, section 3.2.4. @end table @@ -2022,7 +2022,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, section +@uref{https://www.openacc.org, OpenACC specification v2.0}, section 3.2.5. @end table @@ -2051,7 +2051,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, section +@uref{https://www.openacc.org, OpenACC specification v2.0}, section 3.2.6. @end table @@ -2079,7 +2079,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, section +@uref{https://www.openacc.org, OpenACC specification v2.0}, section 3.2.7. @end table @@ -2107,7 +2107,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, section +@uref{https://www.openacc.org, OpenACC specification v2.0}, section 3.2.8. @end table @@ -2132,7 +2132,7 @@ @end multitable @item @emph{Reference}: -@uref{http://www.openacc.org/, OpenACC specification v2.0}, sectio
[Ada] Compiler crash on mixed-case source file names
This patch fixes a bug in which if mixed-case file names are used, and a file name contains any of the capital letters 'U', 'W', 'Q', or 'O', then in rare cases the compiler can crash. No small test is available. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Bob Duff * exp_intr.adb (Add_Source_Info): Do not decode file names; they were not encoded in the first place. Index: exp_intr.adb === --- exp_intr.adb(revision 251883) +++ exp_intr.adb(working copy) @@ -125,7 +125,7 @@ Append (Buf, Nat (Get_Logical_Line_Number (Loc))); when Name_File => -Append_Decoded (Buf, Reference_Name (Get_Source_File_Index (Loc))); +Append (Buf, Reference_Name (Get_Source_File_Index (Loc))); when Name_Source_Location => Build_Location_String (Buf, Loc);
[Ada] T'Class'Input reading corrupted data
If T'Class'Input is called on a stream containing data that does not look like it comes from T'Class'Output, it could crash. This patch fixes that bug by making sure it raises an exception. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Bob Duff * a-tags.adb (Internal_Tag): Unsuppress checks, so we get exceptions instead of crashes. Check for absurdly long strings and empty strings. Empty strings cause trouble because they can have super-null ranges (e.g. 100..10), which causes Ext_Copy to be empty, which causes an array index out of bounds. * s-ststop.adb (Input): Unsuppress checks, so we get exceptions instead of crashes. Index: a-tags.adb === --- a-tags.adb (revision 251863) +++ a-tags.adb (working copy) @@ -641,10 +641,22 @@ Header_Separator: constant Character := '#'; function Internal_Tag (External : String) return Tag is - Ext_Copy : aliased String (External'First .. External'Last + 1); - Res : Tag := null; + pragma Unsuppress (All_Checks); + -- To make T'Class'Input robust in the case of bad data + Res : Tag := null; + begin + -- Raise Tag_Error for empty strings, and for absurdly long strings. + -- This is to make T'Class'Input robust in the case of bad data, for + -- example a String(123456789..1234). The limit of 10,000 characters is + -- arbitrary, but is unlikely to be exceeded by legitimate external tag + -- names. + + if External'Length not in 1 .. 10_000 then + raise Tag_Error; + end if; + -- Handle locally defined tagged types if External'Length > Internal_Tag_Header'Length @@ -731,9 +743,14 @@ else -- Make NUL-terminated copy of external tag string - Ext_Copy (External'Range) := External; - Ext_Copy (Ext_Copy'Last) := ASCII.NUL; - Res := External_Tag_HTable.Get (Ext_Copy'Address); + declare +Ext_Copy : aliased String (External'First .. External'Last + 1); +pragma Assert (Ext_Copy'Length > 1); -- See Length check at top + begin +Ext_Copy (External'Range) := External; +Ext_Copy (Ext_Copy'Last) := ASCII.NUL; +Res := External_Tag_HTable.Get (Ext_Copy'Address); + end; end if; if Res = null then Index: s-ststop.adb === --- s-ststop.adb(revision 251863) +++ s-ststop.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2008-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 2008-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -128,17 +128,20 @@ (Strm : access Root_Stream_Type'Class; IO : IO_Kind) return Array_Type is + pragma Unsuppress (All_Checks); + -- To make T'Class'Input robust in the case of bad data. The + -- declaration of Item below could raise Storage_Error if the length + -- is huge. begin if Strm = null then raise Constraint_Error; end if; declare -Low : Index_Type; -High : Index_Type; - +Low, High : Index_Type'Base; begin --- Read the bounds of the string +-- Read the bounds of the string. Note that they could be out of +-- range of Index_Type in the case of empty arrays. Index_Type'Read (Strm, Low); Index_Type'Read (Strm, High);
[Ada] New debug switch -gnatdJ
Introduce a new debug switch -gnatdJ to prepend the name of the enclosing entity (subprogram, task, ...) relevant for a given warning or style message. This can be useful in the context of integrating these messages in other tools, e.g. CodePeer or gnatcheck. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Arnaud Charlet * exp_intr.adb (Append_Entity_Name): Move to ... * sem_util.ads, sem_util.adb: ... here to share it. (Subprogram_Name): New subprogram, to compute the name of the enclosing subprogram/entity. * errutil.adb (Error_Msg): Fill new field Node. * erroutc.ads (Subprogram_Name_Ptr): New. (Error_Msg_Object): New field Node. * erroutc.adb (dmsg, Output_Msg_Text): Take new field Node into account. * errout.adb (Error_Msg): New variant with node id parameter. Fill new parameter Node when emitting messages. Revert previous changes for Include_Subprogram_In_Messages. * sem_ch5.adb (Check_Unreachable_Code): Supply Node parameter when generating warning message. Index: errout.adb === --- errout.adb (revision 251880) +++ errout.adb (working copy) @@ -100,7 +100,8 @@ (Msg : String; Sptr : Source_Ptr; Optr : Source_Ptr; - Msg_Cont : Boolean); + Msg_Cont : Boolean; + Node : Node_Id); -- This is the low level routine used to post messages after dealing with -- the issue of messages placed on instantiations (which get broken up -- into separate calls in Error_Msg). Sptr is the location on which the @@ -111,7 +112,9 @@ -- copy. So typically we can see Optr pointing to the template location -- in an instantiation copy when Sptr points to the source location of -- the actual instantiation (i.e the line with the new). Msg_Cont is - -- set true if this is a continuation message. + -- set true if this is a continuation message. Node is the relevant + -- Node_Id for this message, to be used to compute the enclosing entity if + -- Opt.Include_Subprogram_In_Messages is set. function No_Warnings (N : Node_Or_Entity_Id) return Boolean; -- Determines if warnings should be suppressed for the given node @@ -303,6 +306,15 @@ -- referencing the generic declaration. procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr) is + begin + Error_Msg (Msg, Flag_Location, Empty); + end Error_Msg; + + procedure Error_Msg + (Msg : String; + Flag_Location : Source_Ptr; + N : Node_Id) + is Sindex : Source_File_Index; -- Source index for flag location @@ -310,8 +322,6 @@ -- Original location of Flag_Location (i.e. location in original -- template in instantiation case, otherwise unchanged). - Entity : Bounded_String; - begin -- Return if all errors are to be ignored @@ -338,18 +348,6 @@ Prescan_Message (Msg); Orig_Loc := Original_Location (Flag_Location); - if Include_Subprogram_In_Messages then - declare -Ent : constant Entity_Id := Current_Subprogram_Ptr.all; - begin -if Present (Ent) then - Append_Unqualified_Decoded (Entity, Chars (Ent)); -else - Append (Entity, "unknown subprogram"); -end if; - end; - end if; - -- If the current location is in an instantiation, the issue arises of -- whether to post the message on the template or the instantiation. @@ -419,14 +417,7 @@ -- Error_Msg_Internal to place the message in the requested location. if Instantiation (Sindex) = No_Location then - if Include_Subprogram_In_Messages then -Append (Entity, ": "); -Append (Entity, Msg); -Error_Msg_Internal (+Entity, Flag_Location, Flag_Location, False); - else -Error_Msg_Internal (Msg, Flag_Location, Flag_Location, False); - end if; - + Error_Msg_Internal (Msg, Flag_Location, Flag_Location, False, N); return; end if; @@ -521,23 +512,35 @@ if Inlined_Body (X) then if Is_Info_Msg then Error_Msg_Internal - ("info: in inlined body #", -Actual_Error_Loc, Flag_Location, Msg_Cont_Status); + (Msg => "info: in inlined body #", +Sptr => Actual_Error_Loc, +Optr => Flag_Location, +Msg_Cont => Msg_Cont_Status, +Node => N); elsif Is_Warning_Msg then Error_Msg_Internal - (Warn_Insertion & "in inlined body #", -Actual_Error_Loc, Flag_Location, Msg_Cont_Status); +
[Ada] Infinite loop on call to nested subprogram with -gnatE in SPARK
This patch suppresses the processing of references to internal variables for SPARK. As a result, this eliminates an infinite loop triggered by walking the scope chain of an internal variable which plays the role of an elaboration flag. -- Source -- -- gnat.adc pragma SPARK_Mode (On); -- pack1.ads package Pack1 is procedure Proc; end Pack1; -- pack1.adb package body Pack1 is procedure Proc is begin null; end Proc; end Pack1; -- pack2.ads package Pack2 is procedure Proc; end Pack2; -- pack2.adb with Pack1; package body Pack2 is procedure Proc is procedure Nested_Proc is begin Pack1.Proc; end Nested_Proc; begin Nested_Proc; end Proc; end Pack2; -- main.adb with Pack2; procedure Main is begin null; end Main; - -- Compilation -- - $ gnatmake -q -gnatE main.adb Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Hristian Kirtchev * sem_elab.adb (Check_A_Call): Do not consider references to internal variables for SPARK semantics. Index: sem_elab.adb === --- sem_elab.adb(revision 251863) +++ sem_elab.adb(working copy) @@ -721,23 +721,26 @@ and then not Is_Call_Of_Generic_Formal (N) then return; - end if; -- If this is a rewrite of a Valid_Scalars attribute, then nothing to -- check, we don't mind in this case if the call occurs before the body -- since this is all generated code. - if Nkind (Original_Node (N)) = N_Attribute_Reference + elsif Nkind (Original_Node (N)) = N_Attribute_Reference and then Attribute_Name (Original_Node (N)) = Name_Valid_Scalars then return; - end if; -- Intrinsics such as instances of Unchecked_Deallocation do not have -- any body, so elaboration checking is not needed, and would be wrong. - if Is_Intrinsic_Subprogram (E) then + elsif Is_Intrinsic_Subprogram (E) then return; + + -- Do not consider references to internal variables for SPARK semantics + + elsif Variable_Case and then not Comes_From_Source (E) then + return; end if; -- Proceed with check
[Ada] Copy representation aspects from type to constrained subtype
This change ensures that the representation aspects Atomic, Independent and Volatile_Full_Access are copied from the base type to the subtype when it is declared with an explicit constraint. For the following package: package P is type Bit is mod 2**1 with Size => 1; type UInt2 is mod 2**2 with Size => 2; type UInt22 is mod 2**22 with Size => 22; type MODE_ENUM is ( Function_0_Default, Function_1, Function_2, Function_3, Function_4, Function_5, Function_6, Function_7) with Size => 3; type EPD_ENUM is ( Disable_Pull_Down, Enable_Pull_Down) with Size => 1; type EPUN_ENUM is ( Enable_Pull_Up, Disable_Pull_Up) with Size => 1; type EHS_ENUM is ( Slow_Low_Noise_With, Fast_Medium_Noise_W) with Size => 1; type EZI_ENUM is ( Disable_Input_Buffer, Enable_Input_Buffer) with Size => 1; type ZIF_ENUM is ( Enable_Input_Glitch, Disable_Input_Glitch) with Size => 1; type EHD_ENUM is ( Normal_Drive_4_Ma_D, Medium_Drive_8_Ma_D, High_Drive_14_Ma_Dr, Ultra_High_Drive_20) with Size => 2; type Pin_Type is (Normal_Drive, High_Drive, High_Speed); type SFS_Register(Pin : Pin_Type := Normal_Drive) is record MODE : MODE_ENUM; EPD : EPD_ENUM; EPUN : EPUN_ENUM; EZI : EZI_ENUM; ZIF : ZIF_ENUM; RESERVED : UInt22; case Pin is when Normal_Drive => ND_EHS_RESERVED : Bit; ND_EHD_RESERVED : UInt2; when High_Drive => EHD : EHD_ENUM; HD_EHS_RESERVED : Bit; when High_Speed => EHS: EHS_ENUM; HS_EHD_RESERVED : UInt2; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access; for SFS_Register use record MODEat 0 range 0 .. 2; EPD at 0 range 3 .. 3; EPUNat 0 range 4 .. 4; ND_EHS_RESERVED at 0 range 5 .. 5; HD_EHS_RESERVED at 0 range 5 .. 5; EHS at 0 range 5 .. 5; EZI at 0 range 6 .. 6; ZIF at 0 range 7 .. 7; ND_EHD_RESERVED at 0 range 8 .. 9; EHD at 0 range 8 .. 9; HS_EHD_RESERVED at 0 range 8 .. 9; RESERVEDat 0 range 10 .. 31; end record; type Arr is array (Integer range <>) of SFS_Register(Normal_Drive); end P; the components of the Arr type must inherit the Volatile_Full_Access aspect. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Eric Botcazou * sem_util.ads (Set_Rep_Info): New inline procedure. * sem_util.adb (Set_Rep_Info): Implement it. * sem_ch3.adb (Process_Subtype): If the case of a constraint present, always copy the representation aspects onto the subtype. Index: sem_ch3.adb === --- sem_ch3.adb (revision 251877) +++ sem_ch3.adb (working copy) @@ -21556,9 +21556,11 @@ Error_Msg_N ("invalid subtype mark in subtype indication", S); end case; - -- Size and Convention are always inherited from the base type + -- Size, Alignment, Representation aspects and Convention are always + -- inherited from the base type. Set_Size_Info (Def_Id,(Subtype_Mark_Id)); + Set_Rep_Info (Def_Id,(Subtype_Mark_Id)); Set_Convention (Def_Id, Convention (Subtype_Mark_Id)); return Def_Id; Index: sem_util.adb === --- sem_util.adb(revision 251880) +++ sem_util.adb(working copy) @@ -21659,6 +21659,20 @@ end if; end Set_Referenced_Modified; + -- + -- Set_Rep_Info -- + -- + + procedure Set_Rep_Info (T1, T2 : Entity_Id) is + begin + Set_Is_Atomic (T1, Is_Atomic (T2)); + Set_Is_Independent (T1, Is_Independent (T2)); + Set_Is_Volatile_Full_Access (T1, Is_Volatile_Full_Access (T2)); + if Is_Base_Type (T1) then + Set_Is_Volatile (T1, Is_Volatile (T2)); + end if; + end Set_Rep_Info; + -- Set_Scope_Is_Transient -- Index: sem_util.ads === --- sem_util.ads(revision 251875) +++ sem_util.ads(working copy) @@ -2473,6 +2473,12 @@ -- (Referenced_As_LHS if Out_Param is False, Referenced_As_Out_Parameter -- if Out_Param is True) is set True, and the other flag set False. + procedure Set_Rep_Info (T1, T2 : Entity_Id); + pragma Inline (Set_Rep_Info); + -- Copies the Is_Atomic, Is_Independent and Is_Volatile_Full_Access flags + -- from sub(type) entit
[Ada] Fix crash on expression function that is a completion
This change fixes a crash on an expression function which is the completion of a previous declaration, when the type of the expression is a record type which contains private components. Such a code is illegal as per AI12-0103, which says that expression functions that are a completion freeze their expression (but don't freeze anything else), and must therefore be properly rejected. Compiling the following package: package P is type Cursor is private; package Nested is type Rec is record C : Cursor; end record; function F (R : Rec) return Rec; private function F (R : Rec) return Rec is (R); end Nested; private type Cursor is null record; end P; must yield: p.ads:15:43: premature usage of incomplete type "Rec" defined at line 7 p.ads:15:43: type "Rec" has private component Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Eric Botcazou * sem_ch6.adb (Freeze_Expr_Types): Really freeze all the types that are referenced by the expression. (Analyze_Expression_Function): Call Freeze_Expr_Types for a completion instead of manually freezing the type of the expression. (Analyze_Subprogram_Body_Helper): Do not call Freeze_Expr_Types here. Index: sem_ch6.adb === --- sem_ch6.adb (revision 251875) +++ sem_ch6.adb (working copy) @@ -267,18 +267,214 @@ LocX : constant Source_Ptr := Sloc (Expr); Spec : constant Node_Id:= Specification (N); + procedure Freeze_Expr_Types (Spec_Id : Entity_Id); + -- N is an expression function that is a completion and Spec_Id its + -- defining entity. Freeze before N all the types referenced by the + -- expression of the function. + + --- + -- Freeze_Expr_Types -- + --- + + procedure Freeze_Expr_Types (Spec_Id : Entity_Id) is + function Cloned_Expression return Node_Id; + -- Build a duplicate of the expression of the return statement that + -- has no defining entities shared with the original expression. + + function Freeze_Type_Refs (Node : Node_Id) return Traverse_Result; + -- Freeze all types referenced in the subtree rooted at Node + + --- + -- Cloned_Expression -- + --- + + function Cloned_Expression return Node_Id is +function Clone_Id (Node : Node_Id) return Traverse_Result; +-- Tree traversal routine that clones the defining identifier of +-- iterator and loop parameter specification nodes. + + +-- Check_Node -- + + +function Clone_Id (Node : Node_Id) return Traverse_Result is +begin + if Nkind_In (Node, N_Iterator_Specification, + N_Loop_Parameter_Specification) + then + Set_Defining_Identifier (Node, +New_Copy (Defining_Identifier (Node))); + end if; + + return OK; +end Clone_Id; + +procedure Clone_Def_Ids is new Traverse_Proc (Clone_Id); + +-- Local variable + +Dup_Expr : constant Node_Id := New_Copy_Tree (Expr); + + -- Start of processing for Cloned_Expression + + begin +-- We must duplicate the expression with semantic information to +-- inherit the decoration of global entities in generic instances. +-- Set the parent of the new node to be the parent of the original +-- to get the proper context, which is needed for complete error +-- reporting and for semantic analysis. + +Set_Parent (Dup_Expr, Parent (Expr)); + +-- Replace the defining identifier of iterators and loop param +-- specifications by a clone to ensure that the cloned expression +-- and the original expression don't have shared identifiers; +-- otherwise, as part of the preanalysis of the expression, these +-- shared identifiers may be left decorated with itypes which +-- will not be available in the tree passed to the backend. + +Clone_Def_Ids (Dup_Expr); + +return Dup_Expr; + end Cloned_Expression; + + -- + -- Freeze_Type_Refs -- + -- + + function Freeze_Type_Refs (Node : Node_Id) return Traverse_Result is + +procedure Check_And_Freeze_Type (Typ : Entity_Id); +-- Check that Typ is fully declared and freeze it if so + +--- +-- Check_And_Freeze_Type -- +--- + +procedure Check_And_Freeze_Type (Typ : Entity_Id) is +
[Ada] Generic dispatching constructors of limited interface types
The compiler crashes processing a generic dispatching constructor that is invoked to build-in-place objects that cover limited interface types. After this patch the following test compiles without errors: package Base is type Root is limited interface; function Constructor (Params : not null access String) return Root is abstract; function Factory (Params : not null access String) return Root'Class; end Base; with Ada.Tags.Generic_Dispatching_Constructor; with Ada.Tags; package body Base is function Factory (Params : not null access String) return Root'Class is function C is new Ada.Tags.Generic_Dispatching_Constructor (T => Root, Parameters => String, Constructor => Base.Constructor); T : Ada.Tags.Tag; begin return Obj : Root'Class := C (T, Params); -- Test end Factory; end Base; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Javier Miranda * exp_ch6.ads (Make_Build_In_Place_Iface_Call_In_Allocator): New subprogram. (Make_Build_In_Place_Iface_Call_In_Anonymous_Context): New subprogram. (Make_Build_In_Place_Iface_Call_In_Object_Declaration): New subprogram. (Unqual_BIP_Iface_Function_Call): New subprogram. * exp_ch6.adb (Replace_Renaming_Declaration_Id): New subprogram containing code that was previously inside Make_Build_In_Place_Call_In_Object_Declaration since it is also required for one of the new subprograms. (Expand_Actuals): Invoke Make_Build_In_Place_Iface_Call_In_Anonymous_Context (Expand_N_Extended_Return_Statement): Extend the cases covered by an assertion on expected BIP object declarations. (Make_Build_In_Place_Call_In_Assignment): Removing unused code; found working on this ticket. (Make_Build_In_Place_Call_In_Object_Declaration): Move the code that replaces the internal name of the renaming declaration into the new subprogram Replace_Renaming_Declaration_Id. (Make_Build_In_Place_Iface_Call_In_Allocator): New subprogram. (Make_Build_In_Place_Iface_Call_In_Anonymous_Context): New subprogram. (Make_Build_In_Place_Iface_Call_In_Object_Declaration): New subprogram. (Unqual_BIP_Iface_Function_Call): New subprogram. * exp_ch3.adb (Expand_N_Object_Declaration): Invoke the new subprogram Make_Build_In_Place_Iface_Call_In_Object_Declaration. * exp_attr.adb (Expand_N_Attribute_Reference): Invoke the new subprogram Make_Build_In_Place_Iface_Call_In_Anonymous_Context. * exp_ch4.adb (Expand_Allocator_Expression): Invoke the new subprogram Make_Build_In_Place_Iface_Call_In_Allocator. (Expand_N_Indexed_Component): Invoke the new subprogram Make_Build_In_Place_Iface_Call_In_Anonymous_Context. (Expand_N_Selected_Component): Invoke the new subprogram Make_Build_In_Place_Iface_Call_In_Anonymous_Context. (Expand_N_Slice): Invoke the new subprogram Make_Build_In_Place_Iface_Call_In_Anonymous_Context. * exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Invoke the new subprogram Make_Build_In_Place_Iface_Call_In_Anonymous_Context. Index: einfo.adb === --- einfo.adb (revision 251876) +++ einfo.adb (working copy) @@ -9293,15 +9293,15 @@ function Underlying_Type (Id : E) return E is begin - -- For record_with_private the underlying type is always the direct - -- full view. Never try to take the full view of the parent it - -- doesn't make sense. + -- For record_with_private the underlying type is always the direct full + -- view. Never try to take the full view of the parent it does not make + -- sense. if Ekind (Id) = E_Record_Type_With_Private then return Full_View (Id); - -- If we have a class-wide type that comes from the limited view then - -- we return the Underlying_Type of its nonlimited view. + -- If we have a class-wide type that comes from the limited view then we + -- return the Underlying_Type of its nonlimited view. elsif Ekind (Id) = E_Class_Wide_Type and then From_Limited_With (Id) @@ -9311,8 +9311,8 @@ elsif Ekind (Id) in Incomplete_Or_Private_Kind then - -- If we have an incomplete or private type with a full view, - -- then we return the Underlying_Type of this full view. + -- If we have an incomplete or private type with a full view, then we + -- return the Underlying_Type of this full view. if Present (Full_View (Id)) then if Id = Full_View (Id) then @@ -9347,10 +9347,9 @@ elsif Etype (Id) /= Id then return Underlying_Type (Etype (Id)); - -- Otherwise we ha
[Ada] Compiler crash on anonymous array with component with invariant
This patch fixes a compiler abort on an object declaration with an anonymous array when the component type of the array has an invariant aspect. The following must compile quietly: gcc -c -gnata main.adb with Lrs; procedure Main is begin Lrs.Initialise; end Main; --- with Global; package Lrs is type Quadrant_Specification is private; procedure Initialise; private type Quadrant_Specification is record N_Klingons: Global.Klingon_Counter := 0; Has_Starbase: Boolean := False; N_Stars: Global.Local_Star_Counter := 0; Is_Scanned: Boolean := False; end record with Type_Invariant => N_Klingons <= Global.MAX_LOCAL_KLINGONS; Quadrant_Specifications: array(Global.Quadrant_X_Index'Range, Global.Quadrant_Y_Index'Range) of Quadrant_Specification; end Lrs; --- package Global is MAX_KLINGONS: constant := 20; -- The maximum number of Klingons in the universe MAX_LOCAL_KLINGONS: constant := 3; -- The maximum number of Klingons in a quadrant MAX_LOCAL_STARS: constant := 8; -- The maximum number of stars in a quadrant UNIVERSE_SIZE: constant := 8; -- The X and Y size of the universe, in quadrants subtype Klingon_Counter is Integer range 0..MAX_KLINGONS; -- Type for the number of Klingons subtype Local_Star_Counter is Integer range 0..MAX_LOCAL_STARS; -- Type for the number of stars in a quadrant subtype Quadrant_X_Index is Integer range 1..UNIVERSE_SIZE; -- Subtype for quadrant X-indexes subtype Quadrant_Y_Index is Integer range 1..UNIVERSE_SIZE; -- Subtype for quadrant Y-indexes end Global; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Ed Schonberg * exp_util.adb (Build_Invariant_Procedure_Declaration): If the type is an anonymous array in an object declaration, whose component type has an invariant, use the object declaration as the insertion point for the invariant procedure, given that there is no explicit type declaration for an anonymous array type. Index: exp_util.adb === --- exp_util.adb(revision 251863) +++ exp_util.adb(working copy) @@ -3408,7 +3408,12 @@ -- Derived types with the full view as parent do not have a partial -- view. Insert the invariant procedure after the derived type. + -- Anonymous arrays in object declarations have no explicit declaration + -- so use the related object declaration as the insertion point. + elsif Is_Itype (Work_Typ) and then Is_Array_Type (Work_Typ) then + Typ_Decl := Associated_Node_For_Itype (Work_Typ); + else Typ_Decl := Declaration_Node (Full_Typ); end if;
[Ada] Wrong interface tag visible through limited with clause
If the designated type of an access to a class-wide interface type is visible through a limited-with clause, and attribute 'Tag is applied to the dereference of a pointer of such type, and such 'Tag value is used to invoke the routines of the Ada.Tags runtime package then the Ada.Tags routine may return a wrong value or raise an exception. After this patch the following test compiles and executes fine. with Pkg_Iface_Ptr; package Pkg_Iface is type Iface is interface; end; limited with Pkg_Iface; package Pkg_Iface_Ptr is type Lim_Iface_Ptr is access all Pkg_Iface.Iface'Class; end; with Pkg_Iface; use Pkg_Iface; package Types is type Root is abstract tagged null record; type DT is new Root and Iface with null record; end; with Pkg_Iface; package Pkg_Aux is end; with Pkg_Aux; with Pkg_Iface_Ptr; use Pkg_Iface_Ptr; package Pkg_Test is function Do_Test (Ptr : Lim_Iface_Ptr) return String; end; with Ada.Tags; package body Pkg_Test is function Do_Test (Ptr : Lim_Iface_Ptr) return String is begin return Ada.Tags.External_Tag (Ptr.all'Tag); -- Test end; end; with Types; use Types; with Pkg_Test; use Pkg_Test; with GNAT.IO; use GNAT.IO; procedure Main is begin GNAT.IO.Put_Line (Do_Test (new DT)); end; Command: gnatmake -q main; ./main Output: TYPES.DT Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Javier Miranda * einfo.adb (Underlying_Type): Add missing support for class-wide types that come from the limited view. * exp_attr.adb (Attribute_Address): Check class-wide type interfaces using the underlying type to handle limited-withed types. (Attribute_Tag): Check class-wide type interfaces using the underlying type to handle limited-withed types. Index: einfo.adb === --- einfo.adb (revision 251863) +++ einfo.adb (working copy) @@ -9300,6 +9300,15 @@ if Ekind (Id) = E_Record_Type_With_Private then return Full_View (Id); + -- If we have a class-wide type that comes from the limited view then + -- we return the Underlying_Type of its nonlimited view. + + elsif Ekind (Id) = E_Class_Wide_Type +and then From_Limited_With (Id) +and then Present (Non_Limited_View (Id)) + then + return Underlying_Type (Non_Limited_View (Id)); + elsif Ekind (Id) in Incomplete_Or_Private_Kind then -- If we have an incomplete or private type with a full view, @@ -9324,9 +9333,8 @@ then return Underlying_Type (Underlying_Full_View (Id)); - -- If we have an incomplete entity that comes from the limited - -- view then we return the Underlying_Type of its non-limited - -- view. + -- If we have an incomplete entity that comes from the limited view + -- then we return the Underlying_Type of its nonlimited view. elsif From_Limited_With (Id) and then Present (Non_Limited_View (Id)) Index: exp_attr.adb === --- exp_attr.adb(revision 251863) +++ exp_attr.adb(working copy) @@ -2235,7 +2235,7 @@ -- issues are taken care of by the virtual machine. elsif Is_Class_Wide_Type (Ptyp) - and then Is_Interface (Ptyp) + and then Is_Interface (Underlying_Type (Ptyp)) and then Tagged_Type_Expansion and then not (Nkind (Pref) in N_Has_Entity and then Is_Subprogram (Entity (Pref))) @@ -6241,7 +6241,7 @@ elsif Comes_From_Source (N) and then Is_Class_Wide_Type (Etype (Prefix (N))) -and then Is_Interface (Etype (Prefix (N))) +and then Is_Interface (Underlying_Type (Etype (Prefix (N then -- Generate: --(To_Tag_Ptr (Prefix'Address)).all
[Ada] Subtype indications inherit predicates
A subtype indication whose type mark is a predicated subtype inherits the predicates of its parent type. A loop whose specification has the form: for S1 in T range Lo .. Hi loop ... and in which T has a static predicate, is executed over the values of T in the specified range that satisfy the predicate. Previous to this patch the inherited predicate was ignored and the loop executed for all values in the range. Executing: gnatmake -q main main must yield: TRUE TRUE Forward 3 4 10 11 12 Backwards 12 11 10 4 3 --- with Bar; use Bar; procedure Main is begin P; end; --- package Bar with SPARK_Mode is subtype B is Boolean with Static_Predicate => B = True; subtype C is integer with Static_Predicate => C in 1..4 | 10..20; function Ident (X : B) return B is (X); function Bizarre (X : Boolean) return B is (Ident (X)); procedure P; end Bar; --- With TExt_IO; use Text_IO; package body Bar with SPARK_Mode is procedure P is Thing : B; Thing2 : B := True; begin for X in B range False .. True loop THing := X; Thing := THing2; Put_Line (Thing'Img); end loop; put_line ("Forward"); for Y in C range 3 .. 12 loop Put_Line (Integer'Image (Y)); end loop; put_line ("Backwards"); for Y in reverse C range 3 .. 12 loop Put_Line (Integer'Image (Y)); end loop; end P; end Bar; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Ed Schonberg * exp_ch5.adb (Expand_Predicated_Loop): Handle properly a loop over a subtype of a type with a static predicate, taking into account the predicate function of the parent type and the bounds given in the loop specification. * sem_ch3.adb (Inherit_Predicate_Flags): For qn Itype created for a loop specification that is a subtype indication whose type mark is a type with a static predicate, inherit predicate function, used to build case statement for rewritten loop. Index: exp_ch5.adb === --- exp_ch5.adb (revision 251863) +++ exp_ch5.adb (working copy) @@ -4698,6 +4698,10 @@ --end loop; -- end; + -- In addition, if the loop specification is given by a subtype + -- indication that constrains a predicated type, the bounds of + -- iteration are given by those of the subtype indication. + else Static_Predicate : declare S: Node_Id; @@ -4706,6 +4710,11 @@ Alts : List_Id; Cstm : Node_Id; +-- If the domain is an itype, note the bounds of its range. + +L_Hi : Node_Id; +L_Lo : Node_Id; + function Lo_Val (N : Node_Id) return Node_Id; -- Given static expression or static range, returns an identifier -- whose value is the low bound of the expression value or range. @@ -4760,6 +4769,11 @@ Set_Warnings_Off (Loop_Id); +if Is_Itype (Ltype) then + L_Hi := High_Bound (Scalar_Range (Ltype)); + L_Lo := Low_Bound (Scalar_Range (Ltype)); +end if; + -- Loop to create branches of case statement Alts := New_List; @@ -4768,12 +4782,21 @@ -- Initial value is largest value in predicate. - D := - Make_Object_Declaration (Loc, - Defining_Identifier => Loop_Id, - Object_Definition => New_Occurrence_Of (Ltype, Loc), - Expression => Hi_Val (Last (Stat))); + if Is_Itype (Ltype) then + D := +Make_Object_Declaration (Loc, + Defining_Identifier => Loop_Id, + Object_Definition => New_Occurrence_Of (Ltype, Loc), + Expression => L_Hi); + else + D := +Make_Object_Declaration (Loc, + Defining_Identifier => Loop_Id, + Object_Definition => New_Occurrence_Of (Ltype, Loc), + Expression => Hi_Val (Last (Stat))); + end if; + P := Last (Stat); while Present (P) loop if No (Prev (P)) then @@ -4794,15 +4817,34 @@ Prev (P); end loop; + if Is_Itype (Ltype) + and then Is_OK_Static_Expression (L_Lo) + and then + Expr_Value (L_Lo) /= Expr_Value (Lo_Val (First (Stat))) + then + Append_To (Alts, +Make_Case_Statement_Alternative (Loc, + Statements => New_List (Make_Exit_Statement (Loc)), + Discrete_Choices => New_L
[Ada] PR ada/80888 Text_IO encoding should match source encoding
The wide character encoding used for Text_IO files is supposed to match the encoding of the source files, as specified by the -gnatW switch, unless it is specified explicitly in the Form string. Instead it incorrectly defaults to brackets encoding. The same applies to Wide_Text_IO and Wide_Wide_Text_IO. This already worked properly for standard output. This patch fixes the problem for files opened by Text_IO.Create and Text_IO.Open. When compiled without -gnatW, the following test should send Latin-1 text to standard output and to log1, and UTF-8 text to log2. With -gnatW8, it should use UTF-8 for all three. with Ada.Text_IO; use Ada.Text_IO; procedure encode_text_io is file1 : File_Type; file2 : File_Type; begin Put (Character'Val (16#A1#)); Create (file1, Out_File, "log1"); Put (file1, Character'Val (16#A1#)); Create (file2, Out_File, "log2", Form=>"WCEM=8"); Put (file2, Character'Val (16#A1#)); Close (file1); Close (file2); end; UTF-8 encoding is: ¡ Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Bob Duff PR ada/80888 * a-textio.adb, a-witeio.adb, a-ztexio.adb (Set_WCEM): Use Default_WCEM by default (i.e. if the encoding is not specified by the Form string). Index: a-ztexio.adb === --- a-ztexio.adb(revision 251863) +++ a-ztexio.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1626,11 +1626,10 @@ Stop : Natural; begin - File.WC_Method := WCEM_Brackets; FIO.Form_Parameter (File.Form.all, "wcem", Start, Stop); if Start = 0 then - File.WC_Method := WCEM_Brackets; + File.WC_Method := Default_WCEM; else if Stop = Start then Index: a-textio.adb === --- a-textio.adb(revision 251863) +++ a-textio.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1810,11 +1810,10 @@ Stop : Natural; begin - File.WC_Method := WCEM_Brackets; FIO.Form_Parameter (File.Form.all, "wcem", Start, Stop); if Start = 0 then - File.WC_Method := WCEM_Brackets; + File.WC_Method := Default_WCEM; else if Stop = Start then Index: a-witeio.adb === --- a-witeio.adb(revision 251863) +++ a-witeio.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1652,11 +1652,10 @@ Stop : Natural; begin - File.WC_Method := WCEM_Brackets; FIO.Form_Parameter (File.Form.all, "wcem", Start, Stop); if Start = 0 then - File.WC_Method := WCEM_Brackets; + File.WC_Method := Default_WCEM; else if Stop = Start then
[Ada] Implement extended version of -gnatR for record sub-components
This adds a -gnatRe variant to the -gnatR switch, which displays extended representation information for components of records that are themselves records by recursing on the layout of sub-components. This also makes the compiler accept -gnatR0, as documented in the User Guide. For the following package: pragma No_Component_Reordering; package P is type Int7 is mod 2 ** 7; for Int7'Size use 7; type Rec1 is record I1 : Integer; I2 : Int7; B1 : Boolean; B2 : Boolean; end record; pragma Pack (Rec1); type Rec2 is record B : Boolean; C : Character; R1 : Rec1; I : Integer; end record; pragma Pack (Rec2); type Rec3 is record B1 : Boolean; B2 : Boolean; R2 : Rec2; C : Character; end record; pragma Pack (Rec3); end P; the compiler must give the following information with -gnatRe: Representation information for unit P (spec) for Rec1'Object_Size use 48; for Rec1'Value_Size use 41; for Rec1'Alignment use 1; for Rec1 use record I1 at 0 range 0 .. 31; I2 at 4 range 0 .. 6; B1 at 4 range 7 .. 7; B2 at 5 range 0 .. 0; end record; for Rec2'Object_Size use 88; for Rec2'Value_Size use 82; for Rec2'Alignment use 1; for Rec2 use record B at 0 range 0 .. 0; C at 0 range 1 .. 8; R1.I1 at 1 range 1 .. 32; R1.I2 at 5 range 1 .. 7; R1.B1 at 6 range 0 .. 0; R1.B2 at 6 range 1 .. 1; I at 6 range 2 .. 33; end record; for Rec3'Object_Size use 96; for Rec3'Value_Size use 92; for Rec3'Alignment use 1; for Rec3 use record B1 at 0 range 0 .. 0; B2 at 0 range 1 .. 1; R2.B at 0 range 2 .. 2; R2.C at 0 range 3 .. 10; R2.R1.I1 at 1 range 3 .. 34; R2.R1.I2 at 5 range 3 .. 9; R2.R1.B1 at 6 range 2 .. 2; R2.R1.B2 at 6 range 3 .. 3; R2.I at 6 range 4 .. 35; Cat 10 range 4 .. 11; end record; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Eric Botcazou * debug.adb (dA): Adjust comment. * gnat1drv.adb (Gnat1drv): Likewise. * opt.ads (List_Representation_Info_Extended): New variable. * repinfo.adb (List_Record_Info): Split implementation into... (Compute_Max_Length): ...this. Recurse on records if requested. (List_Record_Layout): Likewise. * switch-c.adb (Scan_Front_End_Switches) <'R'>: Use case statement, accept '0' and set List_Representation_Info_Extended on 'e'. * usage.adb (Usage): Document new -gnatRe variant. Index: switch-c.adb === --- switch-c.adb(revision 251863) +++ switch-c.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1143,19 +1143,24 @@ while Ptr <= Max loop C := Switch_Chars (Ptr); - if C in '1' .. '3' then + case C is + + when '0' .. '3' => List_Representation_Info := Character'Pos (C) - Character'Pos ('0'); - elsif Switch_Chars (Ptr) = 's' then + when 's' => List_Representation_Info_To_File := True; - elsif Switch_Chars (Ptr) = 'm' then + when 'm' => List_Representation_Info_Mechanisms := True; - else + when 'e' => + List_Representation_Info_Extended := True; + + when others => Bad_Switch ("-gnatR" & Switch_Chars (Ptr .. Max)); - end if; + end case; Ptr := Ptr + 1; end loop; Index: usage.adb === --- usage.adb (revision 251863) +++ usage.adb (working copy) @@ -392,7 +392,7 @@ Write_Switch_Char ("R?"); Write_Line - ("List rep info (?=0/1/2/3/m for none/types/all/variable/mechanisms)"); + ("List rep info (?=0/1/2/3/e/m for none/types/all/symbolic/ext/mech)"); Write_Switch_Char ("R?s"); Write_Line ("List rep info to file.rep instead of standard output"); Index: debug.adb === --- debug.adb (revision 251872) +++ debug.adb (working copy) @
[Ada] Spurious error on actual array type in generic child instantiation.
This patch suppresses the check for compatibility of the component types of the formal and the corresponding actual in the instantiation of a generic child unit, when the component type of the formal is itself a formal of an enclosing generic unit. This removes spurious conformance errors in complex sets of nested instantiations of generic hierarchies. No short example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Ed Schonberg * sem_ch12.adb (Validate_Array_Type_Instance): Suppress check for compatibility of component types of formal and actual in an instantiation of a child unit, when the component type of the formal is itself a formal of an enclosing generic. Index: sem_ch12.adb === --- sem_ch12.adb(revision 251869) +++ sem_ch12.adb(working copy) @@ -12080,7 +12080,10 @@ -- for static matching has failed. The case where both the component -- type and the array type are separate formals, and the component -- type is a private view may also require special checking in - -- Subtypes_Match. + -- Subtypes_Match. Finally, we assume that a child instance where + -- the component type comes from a formal of a parent instance is + -- correct because the generic was correct. A more precise check + -- seems too complex to install??? if Subtypes_Match (Component_Type (A_Gen_T), Component_Type (Act_T)) @@ -12088,6 +12091,9 @@ Subtypes_Match (Find_Actual_Type (Component_Type (A_Gen_T), A_Gen_T), Component_Type (Act_T)) +or else + (not Inside_A_Generic + and then Is_Child_Unit (Scope (Component_Type (A_Gen_T then null; else
[Ada] Failure to allocate on storage subpool
This patch modifies the processing of allocators to account for a case where a simple allocation still requires a call to Allocate_Any_Controlled due to subpool management. No small reproducer possible. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Hristian Kirtchev * exp_ch4.adb (Expand_N_Allocator): Generate a call to Allocate_Any_Controlled when the allocation does not require any initialization. Index: exp_ch4.adb === --- exp_ch4.adb (revision 251863) +++ exp_ch4.adb (working copy) @@ -4632,7 +4632,9 @@ -- No initialization required else - null; + Build_Allocate_Deallocate_Proc + (N => N, + Is_Allocate => True); end if; -- Case of initialization procedure present, must be called
[Ada] Inheritance of Default_Iterator from interfaces
This patch fixes a bug in which if a type implements interfaces, the Default_Iterator aspect is not inherited from all interfaces, but only from the parent type. The following test should compile and run quietly. with Ada.Iterator_Interfaces; procedure Main is type Element_Type is null record; type Cursor is null record; function Has_Element (Position : in Cursor) return Boolean is (False); package Iterators is new Ada.Iterator_Interfaces (Cursor, Has_Element); type Iterable_Base is limited interface with Default_Iterator => Iterate, Iterator_Element => Element_Type, Constant_Indexing => Element; type Iterator is new Iterators.Forward_Iterator with null record; function First (This : in Iterator) return Cursor is ((others => <>)); function Next (This : in Iterator; Position : in Cursor) return Cursor is (Position); function Iterate (This : in Iterable_Base'Class) return Iterators.Forward_Iterator'Class is (Iterator'(others => <>)); function Element (This : in Iterable_Base'Class; Position : in Cursor) return Element_Type is ((others => <>)); type IDummy is limited interface; type Iterator_First is new Iterable_Base and IDummy with null record; type Iterator_Last is new IDummy and Iterable_Base with null record; A : Iterator_First; B : Iterator_Last; begin for El of A loop null; end loop; for El of B loop null; end loop; end Main; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Bob Duff * sem_ch3.adb (Build_Derived_Private_Type): Inherit representation items from interfaces that the derived type implements, not just from the parent type. * sem_util.ads, sem_util.adb (Abstract_Interface_List): Change this to return an empty list when there are no interfaces. * einfo.ads, sem_ch13.adb: Minor comment fixes. Index: sem_ch3.adb === --- sem_ch3.adb (revision 251863) +++ sem_ch3.adb (working copy) @@ -9576,9 +9576,18 @@ Set_Has_Predicates (Derived_Type); end if; - -- The derived type inherits the representation clauses of the parent + -- The derived type inherits representation clauses from the parent + -- type, and from any interfaces. Inherit_Rep_Item_Chain (Derived_Type, Parent_Type); + declare + Iface : Node_Id := First (Abstract_Interface_List (Derived_Type)); + begin + while Present (Iface) loop +Inherit_Rep_Item_Chain (Derived_Type, Entity (Iface)); +Next (Iface); + end loop; + end; -- If the parent type has delayed rep aspects, then mark the derived -- type as possibly inheriting a delayed rep aspect. Index: einfo.ads === --- einfo.ads (revision 251863) +++ einfo.ads (working copy) @@ -2730,8 +2730,8 @@ --Is_Interface (Flag186) -- Defined in record types and subtypes. Set to indicate that the current --- entity corresponds with an abstract interface. Because abstract --- interfaces are conceptually a special kind of abstract tagged types +-- entity corresponds to an abstract interface. Because abstract +-- interfaces are conceptually a special kind of abstract tagged type -- we represent them by means of tagged record types and subtypes -- marked with this attribute. This allows us to reuse most of the -- compiler support for abstract tagged types to implement interfaces Index: sem_util.adb === --- sem_util.adb(revision 251869) +++ sem_util.adb(working copy) @@ -198,12 +198,17 @@ return Abstract_Interface_List (Etype (Typ)); - else pragma Assert ((Ekind (Typ)) = E_Record_Type); + elsif Ekind (Typ) = E_Record_Type then if Nkind (Parent (Typ)) = N_Formal_Type_Declaration then Nod := Formal_Type_Definition (Parent (Typ)); else Nod := Type_Definition (Parent (Typ)); end if; + + -- It's not the kind of type that can implement interfaces + + else + return Empty_List; end if; return Interface_List (Nod); Index: sem_util.ads === --- sem_util.ads(revision 251868) +++ sem_util.ads(working copy) @@ -37,8 +37,9 @@ package Sem_Util is function Abstract_Interface_List (Typ : Entity_Id) return List_Id; - -- Given a type that implements interfaces look for its associated - -- definition node and return its list of interfaces. + -- The list of interfaces implemented by Typ. Empty if there are none, + -- including the cases where there c
[Ada] Do not generate .ali files for subunits
This patch fixes a bug in which the compiler creates .ali files when a subunit is compiled. Given the following code: package P is procedure F; end P; package body P is procedure F is separate; end P; separate (P) procedure F is begin null; end F; The command: gcc -c p-f.adb should generate an error: cannot generate code for file p-f.adb (subunit) and p-f.ali should not be created. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Bob Duff * gnat1drv.adb (Gnat1drv): Do not set the Force_ALI_Tree_File flag in the subunit case. It's still OK to set it in the "missing subunits" case, because that won't cause the obsolete .ali files that cause confusion. Index: gnat1drv.adb === --- gnat1drv.adb(revision 251863) +++ gnat1drv.adb(working copy) @@ -1353,10 +1353,10 @@ Write_Str (" (subunit)"); Write_Eol; - -- Force generation of ALI file, for backward compatibility + -- Do not generate an ALI file in this case, because it would + -- become obsolete when the parent is compiled, and thus + -- confuse tools such as gnatfind. - Opt.Force_ALI_Tree_File := True; - elsif Main_Unit_Kind = N_Subprogram_Declaration then Write_Str (" (subprogram spec)"); Write_Eol;
[Ada] Expand barrier conditions permitted by the restriction Pure_Barrier
This patch permits the use of type conversions and components of objects subject to the following conditions: type conversions cannot potentially raise contraint errors and access types cannot be dereferenced. These additions provide greater functionality to users while respecting the aims of the Pure_Barrier restriction: side effects, exceptions, and recursion cannot occur during the evaluation of the barriers. In practise this patch allows users to compare the result of the Count attribute with a literal or named number, and reference components of array or record types in barriers. The following must compile quietly: --- package Test_PO is type BooT is record Far : Integer; end record; type FooT is record Bar : BooT; end record; protected PO is entry A; entry B; private Foo : FooT; end PO; end Test_PO; --- pragma Restrictions (Pure_Barriers); package body Test_PO is protected body PO is entry A when A'Count > 5 is begin null; end A; entry B when Foo.Bar.Far = 5 is begin null; end B; end PO; end Test_PO; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Patrick Bernardi * exp_ch9.adb (Is_Pure_Barrier): Allow type conversions and components of objects. Simplified the detection of the Count attribute by identifying the corresponding run-time calls. Index: exp_ch9.adb === --- exp_ch9.adb (revision 251863) +++ exp_ch9.adb (working copy) @@ -5999,8 +5999,9 @@ Renamed : Node_Id; begin - -- Check for case of _object.all.field (note that the explicit - -- dereference gets inserted by analyze/expand of _object.field). + -- Check if the name is a component of the protected object. If + -- the expander is active, the component has been transformed into + -- a renaming of _object.all.component. if Expander_Active then Renamed := Renamed_Object (Entity (N)); @@ -6010,7 +6011,7 @@ and then Nkind (Renamed) = N_Selected_Component and then Chars (Prefix (Prefix (Renamed))) = Name_uObject; else -return Scope (Entity (N)) = Current_Scope; +return Is_Protected_Component (Entity (N)); end if; end Is_Simple_Barrier_Name; @@ -6019,25 +6020,6 @@ - function Is_Pure_Barrier (N : Node_Id) return Traverse_Result is - function Is_Count_Attribute (N : Node_Id) return Boolean; - -- Check whether N is part of an expansion of the Count attribute. - -- Return True if N represents the expanded function call. - - - -- Is_Count_Attribute -- - - - function Is_Count_Attribute (N : Node_Id) return Boolean is - begin -return - Nkind (N) = N_Function_Call -and then Present (Original_Node (N)) -and then Nkind (Original_Node (N)) = N_Attribute_Reference -and then Attribute_Name (Original_Node (N)) = Name_Count; - end Is_Count_Attribute; - - -- Start of processing for Is_Pure_Barrier - begin case Nkind (N) is when N_Expanded_Name @@ -6045,11 +6027,8 @@ => if No (Entity (N)) then return Abandon; - end if; - if Present (Parent (N)) - and then Is_Count_Attribute (Parent (N)) - then + elsif Is_Universal_Numeric_Type (Entity (N)) then return OK; end if; @@ -6062,25 +6041,36 @@ => return OK; - when E_Component - | E_Variable - => - -- A variable in the protected type is expanded as a - -- component. + when E_Component => + return OK; + when E_Variable => if Is_Simple_Barrier_Name (N) then return OK; end if; + when E_Function => + + -- The count attribute has been transformed into run-time + -- calls. + + if Is_RTE (Entity (N), RE_Protected_Count) + or else Is_RTE (Entity (N), RE_Protected_Count_Entry) + then +return OK; + end if; + when others => null; end case; when N_Function_Call => - if Is_Count_Attribute (N) then - return OK; - end if; + -- Function call checks are carried o
[Ada] Infinite loop on an interface conversion involving private extensions.
This patch fixes a loop in the compiler, on an interface conversion from an interface declared as a synchronized private extension to one of its ancestors. databases-instantiations,adb below must compile quietly: --- package body Databases.Generics is New_Data_ID : Data_ID_Type := 1; protected body Database_Type is procedure Register (Data_Name : in Data_Name_Type; Data_ID : out Data_ID_Type) is Tmp_Data_ID : constant Data_ID_Type := New_Data_ID; begin Data_Names (Data_ID) := Data_Name; Data_Objects_Map (Data_ID) := Data_Object' (Data => Init_Data, Timestamp => Time_First); New_Data_ID := New_Data_ID + 1; Data_ID := Tmp_Data_ID; end Register; procedure Set (Data_ID : in Data_ID_Type; Raw_Data : in UInt8_Array) is Data : Data_Type with Address => Raw_Data'Address; begin Set (Data_ID => Data_ID, Data=> Data); end Set; function Get (Data_ID : in Data_ID_Type) return UInt8_Array is Data_Size : constant Natural := Data_Type'Size / 8; Data : constant Data_Type := Get (Data_ID); Raw_Data : UInt8_Array (1 .. Data_Size) with Address => Data'Address; begin return Raw_Data; end Get; procedure Set (Data_ID : in Data_ID_Type; Data: in Data_Type) is begin Data_Objects_Map (Data_ID).Timestamp := Clock; Data_Objects_Map (Data_ID).Data := Data; end Set; function Get (Data_ID : in Data_ID_Type) return Data_Type is begin return Data_Objects_Map (Data_ID).Data; end Get; function Get_Timestamp (Data_ID : in Data_ID_Type) return Ada.Real_Time.Time is begin return Data_Objects_Map (Data_ID).Timestamp; end Get_Timestamp; end Database_Type; function Get_Database_Instance return Database_Access is begin return Database_Instance'Access; end Get_Database_Instance; end Databases.Generics; with Ada.Real_Time; use Ada.Real_Time; with Databases; use Databases; generic type Data_Type is private; -- The data type that should be stored in the database Init_Data : Data_Type; -- The value that should be set just after the data registration Max_Nb_Data : Positive; -- The maximun number of data that can be stored in the database package Databases.Generics is type Typed_Database_Interface is synchronized interface; function Get (Database : Typed_Database_Interface; Data_ID : Data_ID_Type) return Data_Type is abstract; -- Get the currently set value for given Data_ID function Get_Timestamp (Database : Typed_Database_Interface; Data_ID : Data_ID_Type) return Time is abstract; procedure Set (Database : in out Typed_Database_Interface; Data_ID : Data_ID_Type; Data : Data_Type) is abstract; -- Set a value for the given Data_ID type Database_Type is synchronized new Root_Database_Type and Typed_Database_Interface with private; type Database_Access is access all Database_Type'Class; -- Database types for the given Data_Type. function Get_Database_Instance return Database_Access; -- Return the unique database instance for this package. private type Data_Object is record Data : Data_Type; Timestamp : Ada.Real_Time.Time; end record; type Data_Object_Array is array (Data_ID_Type'First .. Data_ID_Type (Max_Nb_Data)) of Data_Object; protected type Database_Type is new Root_Database_Type and Typed_Database_Interface with overriding procedure Register (Data_Name : in Data_Name_Type; Data_ID : out Data_ID_Type); overriding function Get (Data_ID : in Data_ID_Type) return UInt8_Array; overriding procedure Set (Data_ID : in Data_ID_Type; Raw_Data : UInt8_Array); overriding function Get (Data_ID : in Data_ID_Type) return Data_Type; -- Get the currently set value for given Data_ID overriding function Get_Timestamp (Data_ID : in Data_ID_Type) return Time; overriding procedure Set (Data_ID : in Data_ID_Type; Data: in Data_Type); -- Set a value for the given Data_ID private ID : Database_ID_Type := Get_New_Database_ID; Data_Objects_Map : Data_Object_Array; Data_Names : Data_Name_Array; end Database_Type; Database_Instance : aliased Database_Type; end Databases.Generics; package body Databases.Instantiations is procedure Set_Raw_Data (Database_ID : Database_ID_Type; Data_ID : Data_ID_Type; Raw_Data: UInt8_Array) is begin Databases (Database_ID).Set (Data_ID => Data_ID, Raw_Data => Raw_Data); end Set_Raw_Data; functio
[Ada] Small fix for couple of internal glitches with record layout
This change ensures that (1) -gnatR always displays the record layout that was used internally by the compiler for code generation and (2) the record layout is fully adjusted internally when the reverse bit order is specified. No functional changes expected because the first issue was papering over the second issue and the second issue was very likely harmless in practice since the normalized position is redundant with the bit offset, which was correct. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Eric Botcazou * repinfo.adb (List_Record_Info): During first loop, do not override the normalized position and first bit if they have already been set. Move fallback code for the packed case to the case where it belongs. * sem_ch13.adb (Adjust_Record_For_Reverse_Bit_Order): Also adjust the normalized position of components. (Adjust_Record_For_Reverse_Bit_Order_Ada_95): Likewise. Index: repinfo.adb === --- repinfo.adb (revision 251863) +++ repinfo.adb (working copy) @@ -894,30 +894,30 @@ Cfbit := Component_Bit_Offset (Comp); if Rep_Not_Constant (Cfbit) then - UI_Image_Length := 2; + -- If the record is not packed, then we know that all fields + -- whose position is not specified have a starting normalized + -- bit position of zero. + if Unknown_Normalized_First_Bit (Comp) + and then not Is_Packed (Ent) + then + Set_Normalized_First_Bit (Comp, Uint_0); + end if; + + UI_Image_Length := 2; -- For "??" marker else -- Complete annotation in case not done - Set_Normalized_Position (Comp, Cfbit / SSU); - Set_Normalized_First_Bit (Comp, Cfbit mod SSU); + if Unknown_Normalized_First_Bit (Comp) then + Set_Normalized_Position (Comp, Cfbit / SSU); + Set_Normalized_First_Bit (Comp, Cfbit mod SSU); + end if; Sunit := Cfbit / SSU; UI_Image (Sunit); end if; --- If the record is not packed, then we know that all fields --- whose position is not specified have a starting normalized --- bit position of zero. - -if Unknown_Normalized_First_Bit (Comp) - and then not Is_Packed (Ent) -then - Set_Normalized_First_Bit (Comp, Uint_0); -end if; - -Max_Suni_Length := - Natural'Max (Max_Suni_Length, UI_Image_Length); +Max_Suni_Length := Natural'Max (Max_Suni_Length, UI_Image_Length); end if; Next_Component_Or_Discriminant (Comp); Index: sem_ch13.adb === --- sem_ch13.adb(revision 251866) +++ sem_ch13.adb(working copy) @@ -627,6 +627,7 @@ end if; Set_Component_Bit_Offset (Comp, Pos * SSU + NFB); + Set_Normalized_Position (Comp, Pos + NFB / SSU); Set_Normalized_First_Bit (Comp, NFB mod SSU); end; end loop; @@ -750,6 +751,9 @@ (System_Storage_Unit - 1) - (Start_Bit + CSZ - 1)); + Set_Normalized_Position (Comp, +Component_Bit_Offset (Comp) / System_Storage_Unit); + Set_Normalized_First_Bit (Comp, Component_Bit_Offset (Comp) mod System_Storage_Unit); end if;
[Ada] Use of renamings of function results in SPARK annotations
This patch changes the expansion of object renamings in SPARK to reuse the entity associated with the renaming when the name denotes a function call. The patch also modifies a routine used to extract the entity of references to abstract states and whole objects to handle renamings of function results. Together, both these changes allow for function result renamings in SPARK annotations. -- Source -- -- pack.ads package Pack with SPARK_Mode is type Lim_Rec is limited record Data : Integer; end record; function Get_Integer return Integer; function Get_Lim_Rec return Lim_Rec; function Get_String return String; end Pack; -- pack.adb package body Pack with SPARK_Mode is function Get_Integer return Integer is begin return 123; end Get_Integer; function Get_Lim_Rec return Lim_Rec is begin return Result : Lim_Rec; end Get_Lim_Rec; function Get_String return String is begin return "456"; end Get_String; package Nested with Initializes => (Int_Ren, Lim_Ren, Str_Ren) is Int_Ren : Integer renames Get_Integer; Lim_Ren : Lim_Rec renames Get_Lim_Rec; Str_Ren : String renames Get_String; procedure Proc with Global => (Int_Ren, Lim_Ren, Str_Ren), Depends => (null => (Int_Ren, Lim_Ren, Str_Ren)); end Nested; package body Nested is procedure Proc is begin null; end Proc; end Nested; end Pack; -- Compilation and output -- $ gcc -c pack.adb $ gcc -c pack.adb -gnatd.F pack.adb:9:14: warning: variable "Result" is read but never assigned pack.adb:9:14: warning: variable "Result" is read but never assigned Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-08 Hristian Kirtchev * exp_spark.adb (Expand_SPARK_N_Object_Renaming_Declaration): Reimplemented. (Expand_SPARK_Potential_Renaming): Code clean up. * sem_prag.adb (Analyze_Initialization_Item): Add a guard in case the item does not have a proper entity. (Analyze_Input_Item): Add a guard in case the item does not have a proper entity. (Collect_States_And_Objects): Include object renamings in the items being collected. (Resolve_State): Update the documentation of this routine. * sem_util.adb (Entity_Of): Add circuitry to handle renamings of function results. (Remove_Entity): New routine. (Remove_Overloaded_Entity): Take advantage of factorization. * sem_util.ads (Entity_Of): Update the documentation of this routine. (Remove_Entity): New routine. (Remove_Overloaded_Entity): Update the documentation of this routine. Index: exp_spark.adb === --- exp_spark.adb (revision 251863) +++ exp_spark.adb (working copy) @@ -292,10 +292,55 @@ procedure Expand_SPARK_N_Object_Renaming_Declaration (N : Node_Id) is + CFS: constant Boolean:= Comes_From_Source (N); + Loc: constant Source_Ptr := Sloc (N); + Obj_Id : constant Entity_Id := Defining_Entity (N); + Nam: constant Node_Id:= Name (N); + Typ: constant Entity_Id := Etype (Subtype_Mark (N)); + begin - -- Unconditionally remove all side effects from the name + -- Transform a renaming of the form - Evaluate_Name (Name (N)); + --Obj_Id : renames ; + + -- into + + --Obj_Id : constant := ; + + -- Invoking Evaluate_Name and ultimately Remove_Side_Effects introduces + -- a temporary to capture the function result. Once potential renamings + -- are rewritten for SPARK, the temporary may be leaked out into source + -- constructs and lead to confusing error diagnostics. Using an object + -- declaration prevents this unwanted side effect. + + if Nkind (Nam) = N_Function_Call then + Rewrite (N, + Make_Object_Declaration (Loc, + Defining_Identifier => Obj_Id, + Constant_Present=> True, + Object_Definition => New_Occurrence_Of (Typ, Loc), + Expression => Nam)); + + -- Inherit the original Comes_From_Source status of the renaming + + Set_Comes_From_Source (N, CFS); + + -- Sever the link to the renamed function result because the entity + -- will no longer alias anything. + + Set_Renamed_Object (Obj_Id, Empty); + + -- Remove the entity of the renaming declaration from visibility as + -- the analysis of the object declaration will reintroduce it again. + + Remove_Entity (Obj_Id); + Analyze (N); + + -- Otherwise unconditionally remove all side effects from the name + + else + Evaluate_Name (Nam); + end if; end Expand_S
Re: Add support to trace comparison instructions and switch statements
Hi David, > On Thu, Sep 7, 2017 at 6:57 PM, Rainer Orth > wrote: >> Jakub Jelinek writes: >> >>> On Wed, Sep 06, 2017 at 10:08:01PM +0200, David Edelsohn wrote: This change broke bootstrap on AIX because sancov.c now references a macro that is defined as a function on AIX. sancov.c needs to include tm_p.h to pull in the target-dependent prototypes. The following patch works for me. Is this okay? * sancov.c: Include tm_p.h. >>> >>> Ok, thanks. And sorry for the breakage. >>> Index: sancov.c === --- sancov.c(revision 251817) +++ sancov.c(working copy) @@ -28,6 +28,7 @@ #include "basic-block.h" #include "options.h" #include "flags.h" +#include "tm_p.h" #include "stmt.h" #include "gimple-iterator.h" #include "gimple-builder.h" >> >> This broke SPARC bootstrap, however: >> >> In file included from ./tm_p.h:4:0, >> from /vol/gcc/src/hg/trunk/local/gcc/sancov.c:31: >> /vol/gcc/src/hg/trunk/local/gcc/config/sparc/sparc-protos.h:46:47: error: >> use of enum 'memmodel' without previous declaration >> extern void sparc_emit_membar_for_model (enum memmodel, int, int); >>^ >> >> This fix allows the bootstrap to continue, but I'm not certain how >> header inclusion is supposed to be done this way: > > It looks like sancov.c also needs to include memmodel.h before tm_p.h. > One should not include memmodel.h in sparc-protos.h. You're right, of course: I'd mostly forgotten about the include flattening. I've now installed the patch below as obvious after successful sparc-sun-solaris2.11 and i386-pc-solaris2.11 bootstraps. However, this seems extremely fragile to me: neither Jakub nor yourself remembered about this requirement and it affects only a few platforms. Feels like an incomplete transition... Rainer -- - Rainer Orth, Center for Biotechnology, Bielefeld University 2017-09-08 Rainer Orth * sancov.c: Include memmodel.h. changeset: 40433:6390d6278d19 tag: tip user:Rainer Orth date:Fri Sep 08 10:34:07 2017 +0200 summary: Fix SPARC bootstrap: sancov.c needs memmodel.h diff --git a/gcc/sancov.c b/gcc/sancov.c --- a/gcc/sancov.c +++ b/gcc/sancov.c @@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. #include "basic-block.h" #include "options.h" #include "flags.h" +#include "memmodel.h" #include "tm_p.h" #include "stmt.h" #include "gimple-iterator.h"