Re: [PATCH] 69759 - document __builtin_alloca and __builtin_alloca_with_align

2016-02-20 Thread Andreas Schwab
Martin Sebor  writes:

> +in bits (not bytes).  @var{size} must be positive and not exceed the stack
> +size limit.  @var{align} must be a constant integer expression that

Don't use a lowercase word at the start of a sentence.

> +The @code{__builtin_alloca_with_align} function is provided to make
> +it possible to allocate overaligned arrays with a runtime bound on
> +the stack.

That sentence is confusing.  What is a runtime, and why is it bound on
the stack?

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: i386: add a variant peephole for decl (mem)

2016-02-20 Thread Uros Bizjak
(please CC me on x86 specific patches)

> PR 49095 requested the following optimization:

[...]

> * config/i386/i386.md (operation on memory peephole): Duplicate an
> existing peephole and adapt it to match lea rather than an operation
> that clobbers CC.

OK for mainline and release branches after a week or so without
problems in mainline.

Thanks,
Uros.


Re: [PATCH, PR middle-end/68134] Reject scalar modes in default get_mask_mode hook

2016-02-20 Thread Ilya Enkovich
2016-02-19 20:36 GMT+03:00 Alan Lawrence :
> On 17/11/15 11:49, Ilya Enkovich wrote:
>>
>> Hi,
>>
>> Default hook for get_mask_mode is supposed to return integer vector modes.
>> This means it should reject calar modes returned by mode_for_vector.
>> Bootstrapped and regtested on x86_64-unknown-linux-gnu, regtested on
>> aarch64-unknown-linux-gnu.  OK for trunk?
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2015-11-17  Ilya Enkovich  
>>
>> PR middle-end/68134
>> * targhooks.c (default_get_mask_mode): Filter out
>> scalar modes returned by mode_for_vector.
>
>
> I've been playing around with a patch that expands arbitrary VEC_COND_EXPRs
> using the vec_cmp and vcond_mask optabs - allowing platforms to drop the
> ugly vcond pattern (for which a cross-product of modes is
> usually required) where vcond = vec_cmp + vcond_mask. (E.g. ARM and
> AArch64.)
>
> Mostly this is fairly straightforward, relatively little midend code is
> required, and the backend cleans up quite a bit. However, I get stuck on the
> case of singleton vectors (64x1). No surprises there, then...
>
> The PR/68134 fix, makes the 'mask mode' for comparing 64x1 vectors, into
> BLKmode, so that we get past this in expand_vector_operations:
>
> /* A scalar operation pretending to be a vector one.  */
>   if (VECTOR_BOOLEAN_TYPE_P (type)
>   && !VECTOR_MODE_P (TYPE_MODE (type))
>   && TYPE_MODE (type) != BLKmode)
> return;
>
> and we do the operation piecewise. (Which is what we want; there is only one
> piece!)
>
> However, with my vec_cmp + vcond_mask changes, dropping vconddidi, this
> means we look for a vcond_maskdiblk and vec_cmpdiblk. Which doesn't really
> feel right - it feels like the 64x1 mask should be a DImode, just like other
> 64x1 vectors.

The problem here is to distinguish vector mask of one DI element and
DI scalar mask.  We don't want to lower scalar mask manipulations
because they are simple integer operations, not vector ones. Probably
vector of a single DI should have V1DI mode and not pretend to be a
scalar?  This would make things easier.

>
> So, I'm left thinking - is there a better way to look for "scalar operations
> pretending to be vector ones", such that we can get a DImode vec
> through the above? What exactly do we want that check to do? In my AArch64
> testing, I was able to take it out altogether and get all tests passing...?
> (I don't have AVX512 hardware)

You were able to do it because it is related to scalar masks supported
by AVX512 only for now.

Thanks,
Ilya

>
> Thanks, Alan
>


Re: [PATCH][RFC][Offloading] Fix PR68463

2016-02-20 Thread Ilya Verbin
On Fri, Feb 19, 2016 at 15:53:08 +0100, Jakub Jelinek wrote:
> On Wed, Feb 10, 2016 at 08:19:34PM +0300, Ilya Verbin wrote:
> > This patch adds crtoffload{begin,end}.o to all -fopenmp programs, if they 
> > exist.
> > I couldn't think of a better solution...
> > Tested using the testcase from the previous mail, e.g.:
> > 
> > $ gcc -DNUM=1 -c -fopenmp test.c -o obj1.o
> > $ gcc -DNUM=2 -c -fopenmp test.c -o obj2.o
> > $ gcc -DNUM=3 -c -fopenmp test.c -o obj3.o
> > $ gcc -DNUM=4 -c -fopenmp test.c -o obj4.o -flto
> > $ gcc -DNUM=5 -c -fopenmp test.c -o obj5.o
> > $ gcc -DNUM=6 -c -fopenmp test.c -o obj6.o -flto
> > $ gcc -DNUM=7 -c -fopenmp test.c -o obj7.o
> > $ gcc-ar -cvq libtest.a obj3.o obj4.o obj5.o
> > $ gcc -fopenmp main.c obj1.o obj2.o libtest.a obj6.o obj7.o
> > 
> > And other combinations.
> 
> Looking at this, I think I have no problem with crtoffloadbegin.o being
> included in all -fopenmp/-fopenacc linked programs/shared libraries,
> that just defines the symbols and nothing else.
> I have no problem with the
> __offload_funcs_end/__offload_vars_end part of crtoffloadend.o being
> included too.
> But, I really don't like __OFFLOAD_TABLE__ being added to all programs, that
> wastes real space in data (rodata or relro?) section, and dynamic
> relocations.
> So, perhaps, can we split offloadstuff.c into 3 objects instead of 2,
> crtoffload{begin,end,table}.o*, where the last one would be what
> defines __OFFLOAD_TABLE__, and add the last one only by the linker
> plugin/lto-wrapper/whatever, if any input objects had any offloading stuff
> in it?

Done.  Bootstrapped and regtested, lto-bootstrap in progress.

Thomas, could you please test it using nvptx, including the testcase with static
libraries?

Could this patch be considered for stage4?  On the one hand, this is not a
regression.  On the other hand, it fixes quite serious issues, and it shouldn't
affect non-offloading configurations.


gcc/
PR driver/68463
* config/gnu-user.h (GNU_USER_TARGET_STARTFILE_SPEC): Add
crtoffloadbegin.o for -fopenacc/-fopenmp if it exists.
(GNU_USER_TARGET_ENDFILE_SPEC): Add crtoffloadend.o for
-fopenacc/-fopenmp if it exists.
* lto-wrapper.c (offloadbegin, offloadend): Remove static vars.
(offload_objects_file_name): New static var.
(tool_cleanup): Remove offload_objects_file_name file.
(find_offloadbeginend): Replace with ...
(find_crtoffloadtable): ... this.
(run_gcc): Remove offload_argc and offload_argv.
Get offload_objects_file_name from -foffload-objects=... option.
Read names of object files with offload from this file, pass them to
compile_images_for_offload_targets.  Don't call find_offloadbeginend and
don't pass offloadbegin and offloadend to the linker.  Don't pass
offload non-LTO files to the linker, because now they're not claimed.
libgcc/
PR driver/68463
* Makefile.in (crtoffloadtable$(objext)): New rule.
* configure.ac (extra_parts): Add crtoffloadtable$(objext) if
enable_offload_targets is not empty.
* configure: Regenerate.
* offloadstuff.c: Move __OFFLOAD_TABLE__ from crtoffloadend to
crtoffloadtable.
lto-plugin/
PR driver/68463
* lto-plugin.c (struct plugin_offload_file): New.
(offload_files): Change type.
(offload_files_last, offload_files_last_obj): New.
(offload_files_last_lto): New.
(free_2): Adjust accordingly.
(all_symbols_read_handler): Don't add offload files to lto_arg_ptr.
Don't call free_1 for offload_files.  Write names of object files with
offloading to the temporary file.  Add new option to lto_arg_ptr.
(claim_file_handler): Don't claim file if it contains offload sections
without LTO sections.  If it contains offload sections, add to the list.


diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
index 2f1bbcc..2fdb63c 100644
--- a/gcc/config/gnu-user.h
+++ b/gcc/config/gnu-user.h
@@ -49,14 +49,16 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
  %{" NO_PIE_SPEC ":crtbegin.o%s}} \
%{fvtable-verify=none:%s; \
  fvtable-verify=preinit:vtv_start_preinit.o%s; \
- fvtable-verify=std:vtv_start.o%s}"
+ fvtable-verify=std:vtv_start.o%s} \
+   %{fopenacc|fopenmp:%:if-exists(crtoffloadbegin%O%s)}"
 #else
 #define GNU_USER_TARGET_STARTFILE_SPEC \
   "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
%{fvtable-verify=none:%s; \
  fvtable-verify=preinit:vtv_start_preinit.o%s; \
- fvtable-verify=std:vtv_start.o%s}"
+ fvtable-verify=std:vtv_start.o%s} \
+   %{fopenacc|fopenmp:%:if-exists(crtoffloadbegin%O%s)}"
 #endif
 #undef  STARTFILE_SPEC
 #define STARTFILE_SPEC GNU_USER_TARGET_STARTFILE_SPEC
@@ -73,13 +75,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If 

Re: Wonly-top-basic-asm

2016-02-20 Thread Bernd Edlinger
On 20.02.2016 02:03, David Wohlferd wrote:
>   @example
> -/* Note that this code will not compile with -masm=intel */
> -#define DebugBreak() asm("int $3")
> +/* Define macro at file scope with basic asm.  */
> +/* Add macro parameter p to eax.  */
> +asm (".macro testme p\n\t"
> +"addl $\\p, %eax\n\t"
> +".endm");
> +
> +/* Use macro in function using extended asm.  It needs
> +   the "cc" clobber since the flags are changed and uses
> +   the "a" constraint since it modifies eax.  */
> +int DoAdd (int value)
> +@{
> +   asm ("testme 5" : "+a" (value) : : "cc");
> +   return value;
> +@}
>   @end example

Sorry, but I don't like this example at all.

First the new example is essentially academic and useless,
while the previous example could well be used
in real world code, except we could note here
that we also have a __builtin_trap () now.

Second if you don't mention that "cc" is already implicitly
clobbered by default, and if it is written here it is ignored
on i386 targets, then everybody will hurry to modify their
asm code when there is no real reason for that.


Bernd.


[PATCH 2/3] gdb.trace: Surround $call_insn with \y in entry-values.exp

2016-02-20 Thread Marcin Kościelnicki
The PPC64 tracepoint patch added \y at the end of the call_insn pattern -
without that, it embarassed itself and matched the 'bl' in "Dump of
assem*bl*er code for function" as the powerpc call opcode.  Since that
sounds like a generally good idea, I've added \y before and after
call_insn for every target.  As a result, I had to change x86_64's mnemonic
to 'callq'.

gdb/testsuite/ChangeLog:

* gdb.trace/entry-values.exp: Surround $call_insn with '\y'.
* lib/trace-support.exp: Change x86_64 call_insn to 'callq'.
---
 gdb/testsuite/ChangeLog  | 5 +
 gdb/testsuite/gdb.trace/entry-values.exp | 2 +-
 gdb/testsuite/lib/trace-support.exp  | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ec2773b..4546cc7 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
 2016-02-19  Marcin Kościelnicki  
 
+   * gdb.trace/entry-values.exp: Surround $call_insn with '\y'.
+   * lib/trace-support.exp: Change x86_64 call_insn to 'callq'.
+
+2016-02-19  Marcin Kościelnicki  
+
* gdb.trace/entry-values.exp: Move call_insn setting to
trace-support.exp.
* gdb.trace/ftrace.exp: Move arg0exp setting to trace-support.exp.
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp 
b/gdb/testsuite/gdb.trace/entry-values.exp
index 75c788a..2890112 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -42,7 +42,7 @@ set returned_from_foo ""
 # Calculate the offset of the instruction in bar returned from foo.
 set test "disassemble bar"
 gdb_test_multiple $test $test {
--re ".*$hex <\\+$decimal>:\[ \t\]+$call_insn\[^\r\n\]+\r\n\[ \]+$hex 
<\\+($decimal)>:.*$gdb_prompt $" {
+-re ".*$hex <\\+$decimal>:\[ \t\]+\\y$call_insn\\y\[^\r\n\]+\r\n\[ \]+$hex 
<\\+($decimal)>:.*$gdb_prompt $" {
set returned_from_foo $expect_out(1,string)
 }
 -re ".*$gdb_prompt $" {
diff --git a/gdb/testsuite/lib/trace-support.exp 
b/gdb/testsuite/lib/trace-support.exp
index 0565030..96f2c35 100644
--- a/gdb/testsuite/lib/trace-support.exp
+++ b/gdb/testsuite/lib/trace-support.exp
@@ -35,7 +35,7 @@ if [is_amd64_regs_target] {
 # register usage in tracepoint conditions.
 set arg0exp "\$rdi"
 # The mnemonic of the usual, unconditional call instruction.
-set call_insn "call"
+set call_insn "callq"
 # Number of the PC register.
 set pcnum 16
 # Number of any GPR (it's supposed to be some register that's not
-- 
2.7.1



[PATCH 1/3] gdb.trace: Move more target dependencies to trace-support.exp

2016-02-20 Thread Marcin Kościelnicki
While groveling through the old PPC64 tracepoint support patch, I've
noticed a few target dependencies in the testsuite that both me and
Antoine missed for s390 and ARM tracepoints, respectively.  This patch
moves them all to one place, so that anyone working on a new target
will hopefully see the whole set of needed changes.

For some strange reason, the call_insn setting code already knew about
powerpc, s390, and mips - I went ahead and added the remaining
information about those.  I'm not particularly sure if I got mips right,
but that won't matter anyway until someone actually writes tracepoint
support for that.

Tested on x86_64, i386, ppc, ppc64, ppc64le, s390, s390x.  Would be good
to test it on aarch64.

gdb/testsuite/ChangeLog:

* gdb.trace/entry-values.exp: Move call_insn setting to
trace-support.exp.
* gdb.trace/ftrace.exp: Move arg0exp setting to trace-support.exp.
* gdb.trace/mi-trace-unavailable.exp (proc_trace_unavailable): Move
pcnum setting to trace-support.exp, change fixed register 0 to
gpr0num variable.
* lib/trace-support.exp: Add setting pcnum, gpr0num, arg0exp,
call_insn; add powerpc, s390, and mips support.
---
Split up and removed arm in this version.

 gdb/testsuite/ChangeLog  | 11 
 gdb/testsuite/gdb.trace/entry-values.exp | 26 +
 gdb/testsuite/gdb.trace/ftrace.exp   | 11 
 gdb/testsuite/gdb.trace/mi-trace-unavailable.exp | 25 +++--
 gdb/testsuite/lib/trace-support.exp  | 69 +++-
 5 files changed, 87 insertions(+), 55 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 5676cac..ec2773b 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2016-02-19  Marcin Kościelnicki  
+
+   * gdb.trace/entry-values.exp: Move call_insn setting to
+   trace-support.exp.
+   * gdb.trace/ftrace.exp: Move arg0exp setting to trace-support.exp.
+   * gdb.trace/mi-trace-unavailable.exp (proc_trace_unavailable): Move
+   pcnum setting to trace-support.exp, change fixed register 0 to
+   gpr0num variable.
+   * lib/trace-support.exp: Add setting pcnum, gpr0num, arg0exp,
+   call_insn; add powerpc, s390, and mips support.
+
 2016-02-18  Iain Buclaw  
 
* lib/future.exp: Add D support.
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp 
b/gdb/testsuite/gdb.trace/entry-values.exp
index 825928d..75c788a 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -12,6 +12,8 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see .
+
+load_lib "trace-support.exp"
 load_lib dwarf.exp
 
 # This test can only be run on targets which support DWARF-2 and use gas.
@@ -37,30 +39,6 @@ gdb_load ${binfile}1.o
 
 set returned_from_foo ""
 
-if { [istarget "arm*-*-*"] || [istarget "aarch64*-*-*"] } {
-set call_insn "bl"
-} elseif { [istarget "s390*-*-*"] } {
-set call_insn "brasl"
-} elseif { [istarget "powerpc*-*-*"] } {
-set call_insn "bl"
-} elseif { [istarget "mips*-*-*"] } {
-# Skip the delay slot after the instruction used to make a call
-# (which can be a jump or a branch) if it has one.
-#
-#  JUMP (or BRANCH) foo
-#  insn1
-#  insn2
-#
-# Most MIPS instructions used to make calls have a delay slot.
-# These include JAL, JALS, JALX, JALR, JALRS, BAL and BALS.
-# In this case the program continues from `insn2' when `foo'
-# returns.  The only exception is JALRC, in which case execution
-# resumes from `insn1' instead.
-set call_insn {jalrc|[jb]al[sxr]*[ \t][^\r\n]+\r\n}
-} else {
-set call_insn "call"
-}
-
 # Calculate the offset of the instruction in bar returned from foo.
 set test "disassemble bar"
 gdb_test_multiple $test $test {
diff --git a/gdb/testsuite/gdb.trace/ftrace.exp 
b/gdb/testsuite/gdb.trace/ftrace.exp
index 15ad7e7..b9b2d8b 100644
--- a/gdb/testsuite/gdb.trace/ftrace.exp
+++ b/gdb/testsuite/gdb.trace/ftrace.exp
@@ -239,17 +239,6 @@ test_ftrace_condition "(globvar >> 2) == 2" "globvar" { 8 
9 10 }
 # Test emit_call by accessing trace state variables.
 test_ftrace_condition "(\$tsv = \$tsv + 2) > 10" "globvar" { 6 7 8 9 10 }
 
-# This expression is used for testing emit_reg.
-if [is_amd64_regs_target] {
-set arg0exp "\$rdi"
-} elseif [is_x86_like_target] {
-set arg0exp "*(int *) (\$ebp + 8)"
-} elseif { [istarget "aarch64*-*-*"] } {
-set arg0exp "\$x0"
-} else {
-set arg0exp ""
-}
-
 if { "$arg0exp" != "" } {
 test_ftrace_condition "($arg0exp > 500)" "globvar" { 6 7 8 9 10 }
 }
diff --git a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp 
b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
index 82c6101..a39b82e 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-unavaila

[PATCH 3/3] gdb.trace: Remove unnecessary target check from ftrace.exp.

2016-02-20 Thread Marcin Kościelnicki
The check used hardcoded targets and wasn't doing anything useful anyway,
since unsupported architectures blow up on link due to missing the IPA
library before they ever get to that check.

gdb/testsuite/ChangeLog:

* gdb.trace/ftrace.exp: Remove unnecessary target check.
---
 gdb/testsuite/ChangeLog|   4 ++
 gdb/testsuite/gdb.trace/ftrace.exp | 135 ++---
 2 files changed, 70 insertions(+), 69 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 4546cc7..8d695ec 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2016-02-19  Marcin Kościelnicki  
 
+   * gdb.trace/ftrace.exp: Remove unnecessary target check.
+
+2016-02-19  Marcin Kościelnicki  
+
* gdb.trace/entry-values.exp: Surround $call_insn with '\y'.
* lib/trace-support.exp: Change x86_64 call_insn to 'callq'.
 
diff --git a/gdb/testsuite/gdb.trace/ftrace.exp 
b/gdb/testsuite/gdb.trace/ftrace.exp
index b9b2d8b..b587896 100644
--- a/gdb/testsuite/gdb.trace/ftrace.exp
+++ b/gdb/testsuite/gdb.trace/ftrace.exp
@@ -84,97 +84,94 @@ proc test_fast_tracepoints {} {
 
 gdb_test "print gdb_agent_gdb_trampoline_buffer_error" ".*" ""
 
-if { [istarget "x86_64-*-*"] || [istarget "i\[34567\]86-*-*"] || 
[is_aarch64_target] } {
+gdb_test "ftrace set_point" "Fast tracepoint .*" \
+"fast tracepoint at a long insn"
 
-   gdb_test "ftrace set_point" "Fast tracepoint .*" \
-   "fast tracepoint at a long insn"
+gdb_trace_setactions "collect at set_point: define actions" \
+"" \
+"collect globvar, anarg" "^$"
 
-   gdb_trace_setactions "collect at set_point: define actions" \
-   "" \
-   "collect globvar, anarg" "^$"
+# Make a test of shorter fast tracepoints, 32-bit x86 only
 
-   # Make a test of shorter fast tracepoints, 32-bit x86 only
+if { [istarget "i?86-*-*"] } {
 
-   if { [istarget "i?86-*-*"] } {
+# A Linux target needs to be able to allocate trampolines in the
+# 16-bit range, check mmap_min_addr so we can warn testers.
+if { [istarget "i?86-*-linux*"] } {
 
-   # A Linux target needs to be able to allocate trampolines in the
-   # 16-bit range, check mmap_min_addr so we can warn testers.
-   if { [istarget "i?86-*-linux*"] } {
+set minaddr [exec sh -c "cat /proc/sys/vm/mmap_min_addr"]
 
-   set minaddr [exec sh -c "cat /proc/sys/vm/mmap_min_addr"]
+if { [expr $minaddr > 64512] } {
+warning "mmap_min_addr > 64512, fast tracepoint will fail"
+warning "do \"sudo sysctl -w vm.mmap_min_addr=32768\" to 
adjust"
+}
+}
 
-   if { [expr $minaddr > 64512] } {
-   warning "mmap_min_addr > 64512, fast tracepoint will fail"
-   warning "do \"sudo sysctl -w vm.mmap_min_addr=32768\" to 
adjust"
-   }
-   }
+gdb_test_multiple "ftrace four_byter" "set 4-byte fast tracepoint" {
+-re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
+pass "4-byte fast tracepoint could not be set"
+}
+-re "Fast tracepoint .*\r\n$gdb_prompt $" {
+pass "4-byte fast tracepoint is set"
+set fourgood 1
+}
+}
 
-   gdb_test_multiple "ftrace four_byter" "set 4-byte fast tracepoint" {
-   -re "May not have a fast tracepoint at .*\r\n$gdb_prompt $" {
-   pass "4-byte fast tracepoint could not be set"
-   }
-   -re "Fast tracepoint .*\r\n$gdb_prompt $" {
-   pass "4-byte fast tracepoint is set"
-   set fourgood 1
-   }
-   }
+if { $fourgood } {
 
-   if { $fourgood } {
-
-   gdb_trace_setactions "collect at four_byter: define actions" \
-   "" \
-   "collect globvar, anarg" "^$"
-   }
-   }
-
-   run_trace_experiment
+gdb_trace_setactions "collect at four_byter: define actions" \
+"" \
+"collect globvar, anarg" "^$"
+}
+}
 
-   gdb_test "tfind pc *set_point" "Found trace frame .*" \
-   "tfind set_point frame, first time"
+run_trace_experiment
 
-   setup_kfail "gdb/13808" "x86_64-*-linux*"
-   gdb_test "print globvar" " = 1"
+gdb_test "tfind pc *set_point" "Found trace frame .*" \
+"tfind set_point frame, first time"
 
-   gdb_test "tfind pc *set_point" "Found trace frame .*" \
-   "tfind set_point frame, second time"
+setup_kfail "gdb/13808" "x86_64-*-linux*"
+gdb_test "print globvar" " = 1"
 
-   setup_kfail "gdb/13808" "x86_64-*-linux*"
-   gdb_test "print anarg" " = 200"
+gdb_test "tfind pc *set_point" "Found trace frame .*" \
+"tfind set_point frame, second time"
 
-  

[RFC] Add contrib/fix-ChangeLog.sh

2016-02-20 Thread Tom de Vries

Hi,

this patch adds a script contrib/fix-ChangeLog.sh.

It fixes whitespace issues, and shows ChangeLog lines that look suspicious.

Using the script, I was able to find a stray changelog entry (removed in 
rr233583, https://gcc.gnu.org/viewcvs?rev=233583&root=gcc&view=rev ).


And I've

Any comments?

Thanks,
- Tom
Add contrib/fix-ChangeLog.sh

---
 contrib/fix-ChangeLog.sh | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/contrib/fix-ChangeLog.sh b/contrib/fix-ChangeLog.sh
new file mode 100755
index 000..b09ab83
--- /dev/null
+++ b/contrib/fix-ChangeLog.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+f="$1"
+
+# Make white-space-only lines empty
+sed -i 's/^[ \t]*$//' "$f"
+
+# Remove trailing whitespace
+sed -i 's/[ \t]*$//' "$f"
+
+# Replace 8/16 spaces at start of line with tab(s)
+sed -i 's/^/\t/' "$f"
+sed -i 's/^/\t\t/' "$f"
+
+# Replace 1-7 spaces followed by tab at start of line with tab
+sed -i 's/^   \t/\t/' "$f"
+sed -i 's/^  \t/\t/' "$f"
+sed -i 's/^ \t/\t/' "$f"
+sed -i 's/^\t/\t/' "$f"
+sed -i 's/^   \t/\t/' "$f"
+sed -i 's/^  \t/\t/' "$f"
+sed -i 's/^ \t/\t/' "$f"
+
+# Replace 1-7 spaces at start of line with tab
+sed -i 's/^   /\t/' "$f"
+sed -i 's/^  /\t/' "$f"
+sed -i 's/^ /\t/' "$f"
+sed -i 's/^/\t/' "$f"
+sed -i 's/^   /\t/' "$f"
+sed -i 's/^  /\t/' "$f"
+sed -i 's/^ /\t/' "$f"
+
+# Remove duplicate empty lines
+sed -i '/^$/N;/^\n$/D' "$f"
+
+# Detect lines that are not allowed.
+# Allowed are:
+# - '^$'   : empty line
+# - '^'   : tab at start of line
+# - '^[a-zA-Z0-9]' : line starting with letter or number
+# - '^<^L>$'   : form feed line
+egrep -H -C2 -v '^$|^	|^[a-zA-Z0-9]|^$' "$f"


Re: New tests for PRs 52531 and 57365

2016-02-20 Thread Dominique d'Humières
Committed on trunk as revision r233588.

Dominique

> Le 15 févr. 2016 à 14:53, Dominique d'Humières  a écrit :
> 
> PRs 52531 and 57365 are fixed on trunk and gcc5 branch. Unless someone 
> objects I am planing to add the following tests in the coming days.
> 
> Tested on x86_64-apple-darwin15.
> 
> Cheers,
> 
> Dominique
> 
> Index: gcc/testsuite/ChangeLog
> ===
> --- gcc/testsuite/ChangeLog   (revision 233424)
> +++ gcc/testsuite/ChangeLog   (working copy)
> @@ -1,3 +1,13 @@
> +2016-02-15  Dominique d'Humieres  
> +
> + PR fortran/57365
> + gfortran.dg/allocate_with_source_18.f03: New test.
> +
> +2016-02-15  Harald Anlauf  
> +
> + PR fortran/52531
> + gfortran.dg/gomp/pr52531.f90: New test.
> +
> 2016-02-15  Richard Biener  
> 
>   PR tree-optimization/69783
> Index: gcc/testsuite/gfortran.dg/allocate_with_source_18.f03
> ===
> --- gcc/testsuite/gfortran.dg/allocate_with_source_18.f03 (nonexistent)
> +++ gcc/testsuite/gfortran.dg/allocate_with_source_18.f03 (working copy)
> @@ -0,0 +1,31 @@
> +! { dg-do run }
> +!
> +! PR fortran/57365
> +! [OOP] Sourced allocation fails with unlimited polymorphism
> +! Contributed by 
> +!
> +program bug
> +
> +implicit none
> +character(len=:), allocatable :: test
> +
> +test = "A test case"
> +call allocate_test(test)
> +deallocate(test)
> +
> +contains
> +
> +subroutine allocate_test(var)
> +class(*) :: var
> +class(*), pointer :: copyofvar
> +allocate(copyofvar, source=var)
> +select type (copyofvar)
> +type is (character(len=*))
> +!print*, len(copyofvar), copyofvar
> +if (len(copyofvar) /= 11) call abort ()
> +if (copyofvar /= "A test case") call abort ()
> +end select
> +deallocate(copyofvar)
> +end subroutine
> +
> +end program bug
> Index: gcc/testsuite/gfortran.dg/gomp/pr52531.f90
> ===
> --- gcc/testsuite/gfortran.dg/gomp/pr52531.f90(nonexistent)
> +++ gcc/testsuite/gfortran.dg/gomp/pr52531.f90(working copy)
> @@ -0,0 +1,16 @@
> +! { dg-do compile }
> +! PR fortran/52531
> +module test_mod
> +  type, public :: test_type
> +  end type
> +contains
> +  subroutine foo(bar)
> +type(test_type) :: bar
> +!$omp parallel default(none) shared(bar) ! Compiles if one removes 
> default(none)
> +call question(bar)
> +!$omp end parallel
> +  end subroutine
> +  subroutine question(var)
> +class(test_type), intent(in) :: var ! Compiles if one replaces class by 
> type
> +  end subroutine
> +end module
> 



Re: [RFC] Add contrib/fix-ChangeLog.sh

2016-02-20 Thread Tom de Vries

On 20/02/16 15:04, Tom de Vries wrote:

Hi,

this patch adds a script contrib/fix-ChangeLog.sh.

It fixes whitespace issues, and shows ChangeLog lines that look suspicious.

Using the script, I was able to find a stray changelog entry (removed in
rr233583, https://gcc.gnu.org/viewcvs?rev=233583&root=gcc&view=rev ).

And I've


[ slip of the keyboard ]

cleaned up a few ChangeLogs using the script (r233584 - r233587): 
ChangeLog, gcc/ChangeLog, gcc/testsuite/ChangeLog, libgomp/ChangeLog.




Any comments?

Thanks,
- Tom

0001-Add-contrib-fix-ChangeLog.sh.patch


Add contrib/fix-ChangeLog.sh

---
  contrib/fix-ChangeLog.sh | 42 ++
  1 file changed, 42 insertions(+)

diff --git a/contrib/fix-ChangeLog.sh b/contrib/fix-ChangeLog.sh
new file mode 100755
index 000..b09ab83
--- /dev/null
+++ b/contrib/fix-ChangeLog.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+f="$1"
+
+# Make white-space-only lines empty
+sed -i 's/^[ \t]*$//' "$f"
+
+# Remove trailing whitespace
+sed -i 's/[ \t]*$//' "$f"
+
+# Replace 8/16 spaces at start of line with tab(s)
+sed -i 's/^/\t/' "$f"
+sed -i 's/^/\t\t/' "$f"
+
+# Replace 1-7 spaces followed by tab at start of line with tab
+sed -i 's/^   \t/\t/' "$f"
+sed -i 's/^  \t/\t/' "$f"
+sed -i 's/^ \t/\t/' "$f"
+sed -i 's/^\t/\t/' "$f"
+sed -i 's/^   \t/\t/' "$f"
+sed -i 's/^  \t/\t/' "$f"
+sed -i 's/^ \t/\t/' "$f"
+
+# Replace 1-7 spaces at start of line with tab
+sed -i 's/^   /\t/' "$f"
+sed -i 's/^  /\t/' "$f"
+sed -i 's/^ /\t/' "$f"
+sed -i 's/^/\t/' "$f"
+sed -i 's/^   /\t/' "$f"
+sed -i 's/^  /\t/' "$f"
+sed -i 's/^ /\t/' "$f"
+
+# Remove duplicate empty lines
+sed -i '/^$/N;/^\n$/D' "$f"
+
+# Detect lines that are not allowed.
+# Allowed are:
+# - '^$'   : empty line
+# - '^'   : tab at start of line
+# - '^[a-zA-Z0-9]' : line starting with letter or number
+# - '^<^L>$'   : form feed line
+egrep -H -C2 -v '^$|^  |^[a-zA-Z0-9]|^$' "$f"





Re: [PATCH 1/3] gdb.trace: Move more target dependencies to trace-support.exp

2016-02-20 Thread Marcin Kościelnicki

Whoops, sorry for that mail - I typoed gdb-patches to gcc-patches.

On 20/02/16 14:56, Marcin Kościelnicki wrote:

While groveling through the old PPC64 tracepoint support patch, I've
noticed a few target dependencies in the testsuite that both me and
Antoine missed for s390 and ARM tracepoints, respectively.  This patch
moves them all to one place, so that anyone working on a new target
will hopefully see the whole set of needed changes.

For some strange reason, the call_insn setting code already knew about
powerpc, s390, and mips - I went ahead and added the remaining
information about those.  I'm not particularly sure if I got mips right,
but that won't matter anyway until someone actually writes tracepoint
support for that.

Tested on x86_64, i386, ppc, ppc64, ppc64le, s390, s390x.  Would be good
to test it on aarch64.

gdb/testsuite/ChangeLog:

* gdb.trace/entry-values.exp: Move call_insn setting to
trace-support.exp.
* gdb.trace/ftrace.exp: Move arg0exp setting to trace-support.exp.
* gdb.trace/mi-trace-unavailable.exp (proc_trace_unavailable): Move
pcnum setting to trace-support.exp, change fixed register 0 to
gpr0num variable.
* lib/trace-support.exp: Add setting pcnum, gpr0num, arg0exp,
call_insn; add powerpc, s390, and mips support.




Re: [PATCH] Fix Bug 17896: The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)

2016-02-20 Thread Prasad Ghangal
PING
Sorry I didn't include [Fix PR c/17896] in prev mail

https://gcc.gnu.org/ml/gcc-patches/2016-01/msg02361.html

On 30 January 2016 at 19:05, Prasad Ghangal  wrote:
> Hi!
>
> This is my first proposed patch for
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896. I was willing to
> do it using "APPEARS_TO_BE_BOOLEAN_EXPR_P(CODE, ARG)" to check
> booleans but gcc doesn't allow (bootstraping fails). Hence I am using
> "TREE_CODE_CLASS (CODE) == tcc_comparison"
>
>
>
> --
> Thanks and Regards,
> Prasad Ghangal



-- 
Thanks and Regards,
Prasad Ghangal


[PATCH 2/2] PR preprocessor/69126: avoid comparing ad-hoc and non-ad-hoc locations

2016-02-20 Thread David Malcolm
Comment #18 of PR preprocessor/69126 reported a difficult-to-reproduce
re-occurrence of that bug, where attempts to suppress
  -Wdeprecated-declarations
via a _Pragma could fail.

The root cause is a bug in linemap_compare_locations when comparing
certain macro expansions with certain non-macro expansions.

(gdb) call inform (pre, "pre")
test.cc:8:16: note: pre
 #define IGNORE _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
^
test.cc:8:16: note: in definition of macro ‘IGNORE’
 #define IGNORE _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
^~~
(gdb) call inform (post, "post")
test.cc:12:5: note: post
 f();
 ^
After macro expansion, we have (at the end of linemap_compare_locations):
(gdb) p /x l0
$13 = 0x800101ec
(gdb) p /x l1
$14 = 0x50684c05

and hence:

(gdb) p /x l1 - l0
$23 = 0xd0674a19

it's effectively negative, and so "before_p" is false; it's erroneously
treating the _Pragma as if it were *after* the diagnostic (and hence
it doesn't affect it).

But this is wrong: l0 is an ad-hoc loc, whereas l1 is a non-ad-hoc loc.

It's clearly insane to do pure numeric comparisons of ad-hoc
locations with non-ad-hoc locations, since doing so will make the
latter always be "after" the former.  The fix is simple: resolve
ad-hoc locations at the end of linemap_compare_locations.

For this bug to occur, we need a location for the macro name that's an
ad-hoc location, and a location for the diagnostic that's *not* an
ad-hoc location.

The reason it triggered for the reporter of comment #18 of the PR is
that the sheer quantity of code in his reproducer meant that both
locations in question were above LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES
(but below LINE_MAP_MAX_LOCATION_WITH_COLS), so range-packing was
disabled, in particular for the "IGNORE" macro, giving an ad-hoc
location for the _Pragma; in contrast, the diagnostic a single
character, and thus used a non-ad-hoc location.

The attached patch fixes the issue, and adds test coverage, via a pair
of test cases c-c++-common/pr69126-2-{long|short}.c, where the "long"
version of the test case uses a macro name that's >=32 characters (thus
forcing the use of an ad-hoc location), which reproduced the issue.

Given that this adds calls to get_location_from_adhoc_loc to the end
of linemap_compare_locations, I went ahead and removed the hand-inlined
copies from the top of the function (but I can avoid that change if
that's too much for stage 4).

This also fixes the xfail in pr69543-1.c, as
"YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN" is longer than 31 chars and
was thus affected by this.

Successfully bootstrapped®rtested on x86_64-pc-linux-gnu in
combination with the previous patch.

OK for trunk in stage 4?

gcc/testsuite/ChangeLog:
PR preprocessor/69126
PR preprocessor/69543
* c-c++-common/pr69126-2-long.c: New test.
* c-c++-common/pr69126-2-short.c: New test.
* c-c++-common/pr69543-1.c: Remove xfail.

libcpp/ChangeLog:
PR preprocessor/69126
PR preprocessor/69543
* line-map.c (linemap_compare_locations): At the function top,
replace inlined bodies of get_location_from_adhoc_loc with calls
to get_location_from_adhoc_loc.  Add a pair of calls to
get_location_from_adhoc_loc at the bottom of the function, to
avoid meaningless comparisons of ad-hoc and non-ad-hoc locations.
---
 gcc/testsuite/c-c++-common/pr69126-2-long.c  | 11 +++
 gcc/testsuite/c-c++-common/pr69126-2-short.c | 11 +++
 gcc/testsuite/c-c++-common/pr69543-1.c   |  4 +---
 libcpp/line-map.c|  9 +++--
 4 files changed, 30 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/pr69126-2-long.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69126-2-short.c

diff --git a/gcc/testsuite/c-c++-common/pr69126-2-long.c 
b/gcc/testsuite/c-c++-common/pr69126-2-long.c
new file mode 100644
index 000..f4f1964
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69126-2-long.c
@@ -0,0 +1,11 @@
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* The macro's name is >= 32 characters long, and hence its location
+   requires an ad-hoc location.  */
+
+#define IGNORE_WHERE_MACRO_IS_LONGER_THAN_31_CHARS  _Pragma("GCC diagnostic 
ignored \"-Wdeprecated-declarations\"")
+__attribute__((deprecated)) void f();
+int main() {
+IGNORE_WHERE_MACRO_IS_LONGER_THAN_31_CHARS
+f();
+}
diff --git a/gcc/testsuite/c-c++-common/pr69126-2-short.c 
b/gcc/testsuite/c-c++-common/pr69126-2-short.c
new file mode 100644
index 000..aee43e5
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr69126-2-short.c
@@ -0,0 +1,11 @@
+/* { dg-options "-Wdeprecated-declarations" } */
+
+/* IGNORE_SHORT_MACRO is < 32 characters long, and hence its location
+   can be stored without needing an ad-hoc location.  */
+
+#define IGNORE_SHORT_MACRO  _Pragma("GCC diagnostic ignored 
\"-Wdeprecated-declarations\"")
+__attribu

[PATCH 1/2] RFC: Add test coverage for _Pragma (PR preprocessor 69126, 69543, 69558)

2016-02-20 Thread David Malcolm
We had some regressions in the ability for _Pragma to disable a warning
(PR preprocessor/69126, PR preprocessor/69543, PR preprocessor/69558).

This patch attempts to add more test coverage for this, for the
various combinations of:
  - various warnings:
-Wunused-variable
-Wuninitialized
-Wdeprecated-declarations
  - various combinations of location of _Pragma relative to location of
the warning:
 - _Pragma is in a macro, warning isn't a macro
 - neither is in a macro
 - _Pragma isnt't in a macro, warning is in a macro
 - in different macros
 - both in the same macro
  - C vs C++ frontend.

It adds some XFAILs:
  - pr69543-1.c for C++ (fixed in the followup patch)
  - pr69543-3.c for both C and C++
  - pr69543-4.c for both C and C++
  - pr69558.c for C++ (moving it from gcc.dg to c-c++-common,
marking it as xfail for C++ for now)

I've also tested the new cases on gcc 5.  The only regression we
currently have in trunk relative to gcc 5 is
c-c++-common/pr69543-1.c lines 19, which the followup patch fixes.

Successfully bootstrapped®rtested on x86_64-pc-linux-gnu in
combination with the followup patch.

OK for trunk?

gcc/testsuite/ChangeLog:
PR preprocessor/69126
PR preprocessor/69543
PR preprocessor/69558
* c-c++-common/pr69126.c (MACRO_1, test_1): New.
(f): Rename to...
(test_2): ...this, and add leading comment.
(MACRO_3, test_3): New.
(MACRO_4A, MACRO_4B, test_4): New.
(MACRO): Rename to...
(MACRO_5): ...this.
(g): Rename to...
(test_5): ...this, updating for renaming of MACRO, and
add leading comment.
* c-c++-common/pr69543-1.c: New.
* c-c++-common/pr69543-2.c: New.
* c-c++-common/pr69543-3.c: New.
* c-c++-common/pr69543-4.c: New.
* c-c++-common/pr69558-1.c: New.
* c-c++-common/pr69558-2.c: New.
* c-c++-common/pr69558-3.c: New.
* c-c++-common/pr69558-4.c: New.
* gcc.dg/pr69558.c: Move to...
* c-c++-common/pr69558.c: ...here.  Add dg-bogus directives, with
xfail for c++.
---
 gcc/testsuite/c-c++-common/pr69126.c   | 65 +++---
 gcc/testsuite/c-c++-common/pr69543-1.c | 21 +++
 gcc/testsuite/c-c++-common/pr69543-2.c | 14 
 gcc/testsuite/c-c++-common/pr69543-3.c | 20 +++
 gcc/testsuite/c-c++-common/pr69543-4.c | 25 +
 gcc/testsuite/c-c++-common/pr69558-1.c | 21 +++
 gcc/testsuite/c-c++-common/pr69558-2.c | 16 +
 gcc/testsuite/c-c++-common/pr69558-3.c | 19 ++
 gcc/testsuite/c-c++-common/pr69558-4.c | 23 
 gcc/testsuite/c-c++-common/pr69558.c   | 19 ++
 gcc/testsuite/gcc.dg/pr69558.c | 17 -
 11 files changed, 239 insertions(+), 21 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/pr69543-1.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69543-2.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69543-3.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69543-4.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69558-1.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69558-2.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69558-3.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69558-4.c
 create mode 100644 gcc/testsuite/c-c++-common/pr69558.c
 delete mode 100644 gcc/testsuite/gcc.dg/pr69558.c

diff --git a/gcc/testsuite/c-c++-common/pr69126.c 
b/gcc/testsuite/c-c++-common/pr69126.c
index fb4dcfb..52c96eb 100644
--- a/gcc/testsuite/c-c++-common/pr69126.c
+++ b/gcc/testsuite/c-c++-common/pr69126.c
@@ -1,22 +1,79 @@
 /* { dg-options "-Wunused-variable" } */
 
+/* Verify that ignoring -Wunused-variable works, for various placements
+   of the variable and the _Pragma.  */
+
+/* Test 1: the _Pragma is in a macro, but the affected code isn't.  */
+
+#pragma GCC diagnostic push
+
+#define MACRO_1 \
+_Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+
+int test_1()
+{
+_Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+int x;
+return 0;
+}
+#pragma GCC diagnostic pop
+
+
+/* Test 2: neither the _Pragma nor the affected code are in a macro.  */
+
+#pragma GCC diagnostic push
+int test_2()
+{
+_Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+int x;
+return 0;
+}
+#pragma GCC diagnostic pop
+
+
+/* Test 3: the _Pragma isn't in a macro, but the affected code is.  */
+
+#define MACRO_3 \
+int x;
+
 #pragma GCC diagnostic push
-int f()
+int test_3()
 {
 _Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+MACRO_3
+return 0;
+}
+#pragma GCC diagnostic pop
+
+
+/* Test 4: the _Pragma and the affected code are in different macros.  */
+
+#pragma GCC diagnostic push
+#define MACRO_4A \
+_Pragma("GCC diagnostic ignored \"-Wunused-variable\"")
+
+#define MACRO_4B \
 int x;
+
+int test_4()
+{
+MACRO_4A;
+MACRO_4B
 return 0;
 }
 #pragma GCC diagnostic pop
 
+
+/* Test 5: both

[PATCH] Add testcase for PR61033

2016-02-20 Thread Maxim Kuvyrkov
This patch adds a testcase for PR61033 [1].

The bug is about compiler going into infinite loop while solving data-flow in 
vt_find_locations on arm-* targets.  The issue in fixed in GCC 5 and later by 
Richard B.'s r211624 [2].

The bug affects GCC 4.8 and 4.9, but is unlikely to be fixed there.

This patch adds a regression test to make sure we catch the problem should it 
re-appear again.

Tested on arm-linux-gnueabihf and x86_64-linux-gnu.

OK to apply?


[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61033

[2] http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=211625
2014-06-13  Richard Biener  

1bf2ea41.diff
Description: Binary data


[Fortran, Patch] (Coarrays) Wrong events size

2016-02-20 Thread Alessandro Fanfarillo
Dear all,

currently, the compiler doesn't pass the right size to the
registration routine of OpenCoarrays for event variables:

size.15 = 0;

ev.data = (void * restrict) _gfortran_caf_register (MAX_EXPR , 6, &ev.token, 0B, 0B, 0);

The attached patch solves the problem.

I don't understand the following block in trans-types.c:

  if (flag_coarray != GFC_FCOARRAY_LIB
  && derived->from_intmod == INTMOD_ISO_FORTRAN_ENV
  && derived->intmod_sym_id == ISOFORTRAN_EVENT_TYPE)
return gfc_get_int_type (gfc_default_integer_kind);

Why should an event variable be different from a lock variable when
LIBCAF_SINGLE is used?

The patch has been built and regtested on x86_64-pc-linux-gnu.

Ok for trunk and gcc-5-branch?
gcc/fortran/Changelog

2016-02-20  Alessandro Fanfarillo  

* trans.c (gfc_allocate_allocatable): size conversion
from byte to number of elements for event variables.
* trans-types.c (gfc_get_derived_type): event variables
represented as a pointer (like lock variable).

commit 095c091a8a3ff10fc703e75585b9b57340723648
Author: Alessandro 
Date:   Sat Feb 20 18:11:22 2016 +0100

Right size for events

diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index f3d0841..a71cf0b 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2370,7 +2370,8 @@ gfc_get_derived_type (gfc_symbol * derived)
   if (derived->attr.unlimited_polymorphic
   || (flag_coarray == GFC_FCOARRAY_LIB
  && derived->from_intmod == INTMOD_ISO_FORTRAN_ENV
- && derived->intmod_sym_id == ISOFORTRAN_LOCK_TYPE))
+ && (derived->intmod_sym_id == ISOFORTRAN_LOCK_TYPE
+ || derived->intmod_sym_id == ISOFORTRAN_EVENT_TYPE)))
 return ptr_type_node;
 
   if (flag_coarray != GFC_FCOARRAY_LIB
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index e71430b..c6688d3 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -820,7 +820,7 @@ gfc_allocate_allocatable (stmtblock_t * block, tree mem, 
tree size, tree token,
 the FE only passes the pointer around and leaves the actual
 representation to the library. Hence, we have to convert back to the
 number of elements.  */
-  if (lock_var)
+  if (lock_var || event_var)
size = fold_build2_loc (input_location, TRUNC_DIV_EXPR, size_type_node,
size, TYPE_SIZE_UNIT (ptr_type_node));
 


Re: [Patch, fortran] PR69423 - [6 Regression] Invalid optimization with deferred-length character

2016-02-20 Thread Paul Richard Thomas
Dear Dominique, dear all,

Many thanks for picking up the regression, which turned out to have a
trivial cause. I have taken the liberty of assuming that this is
tantamount to approval and have committed the patch as revision
233589. Any style or other wrinkles can be corrected later.

The reason that I took this liberty is that I must get past the
deferred character length business as rapidly as possible. I will
prepare a composite patch for 5-branch, with a view to committing it
in a weeks time, so that both branches have the same capability. I
have several other patches that should be backported to 5-branch,
which will take most of the time that I can devote to gfortran
tomorrow. More importantly, now that it has happened in the field, I
must fix the collisions in SELECT TYPE. The only way that I know to do
this reliably is to drop the use of a has and to use the extended type
names directly. This will take a bit of work!

Cheers

Paul


On 20 February 2016 at 13:11, Dominique d'Humières  wrote:
>
>> Le 20 févr. 2016 à 10:58, Paul Richard Thomas 
>>  a écrit :
>>
>> Dear Dominique,
>>
>> Thanks for giving it a try. Although I cannot reproduce the problem, I
>> am pretty sure that it is due to the omission of a couple of
>> gfc_start_blocks. In the circumstances, it is a bit odd that the ICE
>> does not show up on my system!
>>
>> Please give the attached a whirl.
>
> It fixes the PR without regression.
>
> Thanks,
>
> Dominique
>
>



-- 
The difference between genius and stupidity is; genius has its limits.

Albert Einstein


Re: [Patch, fortran] PR69423 - [6 Regression] Invalid optimization with deferred-length character

2016-02-20 Thread Mikael Morin

Le 20/02/2016 19:35, Paul Richard Thomas a écrit :

The only way that I know to do
this reliably is to drop the use of a has and to use the extended type
names directly. This will take a bit of work!


Maybe the vtab pointer can be used to discriminate between types?
There is one vtab struct for each type, isn't there?

Mikael


Re: [Patch, fortran] PR69423 - [6 Regression] Invalid optimization with deferred-length character

2016-02-20 Thread Thomas Koenig

Hi Paul,


More importantly, now that it has happened in the field, I
must fix the collisions in SELECT TYPE. The only way that I know to do
this reliably is to drop the use of a has and to use the extended type
names directly


Can you also use the hash in the usual case and only do a name-by-name
comparison in the case of hash collision?

I think this is the standard method of dealing with such cases.

Regards

Thomas


Re: [PATCH] Fix Bug 17896: The expression (a>0 & b>0) should give clearer warning message (-Wparentheses)

2016-02-20 Thread David Malcolm
On Sat, 2016-01-30 at 19:05 +0530, Prasad Ghangal wrote:
> Hi!
> 
> This is my first proposed patch for
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17896. I was willing to
> do it using "APPEARS_TO_BE_BOOLEAN_EXPR_P(CODE, ARG)" to check
> booleans but gcc doesn't allow (bootstraping fails). Hence I am using
> "TREE_CODE_CLASS (CODE) == tcc_comparison"

Thanks for submitting this patch, and welcome!

I'm not a patch reviewer, but hopefully the following will be helpful.

Is this your first patch for GCC?  For non-trivial patches, there's
some legal rubric that must be followed; see:
https://gcc.gnu.org/contribute.html#legal

When submitting a patch it's a good idea to be explicit about what
testing you've done on it.  Typically you should do a full bootstrap
with the patch, and then run the test suite, and verify that nothing
has regressed.  So typically with a patch sent to this list you should
state that you successfully performed a bootstrap and regression
testing with the patch, and you should state which kind of host you did
this on (e.g. "x86_64-pc-linux-gnu").

See https://gcc.gnu.org/contribute.html for more information.

For a patch like this that improves a warning, it ought to include test
cases (or extend existing ones).  Some information on creating test
cases can be seen here:
https://gcc.gnu.org/wiki/HowToPrepareATestcase

There are a couple of trivial stylistic issues in the patch itself:

> Index: gcc/c-family/c-common.c
> ===
> --- gcc/c-family/c-common.c   (revision 232768)
> +++ gcc/c-family/c-common.c   (working copy)
> @@ -11596,6 +11596,11 @@
>  || code_right == PLUS_EXPR || code_right == MINUS_EXPR)
>   warning_at (EXPR_LOC_OR_LOC (arg_right, loc), OPT_Wparentheses,
>"suggest parentheses around arithmetic in operand of %<|%>");
> +  /* Check cases like (x +  else if(TREE_CODE_CLASS (code_left) == tcc_comparison

There should be a space between the "if" and the open paren here.

> +&& (TREE_CODE_CLASS (code_right) == tcc_comparison))
> + warning_at (loc, OPT_Wparentheses,
> +  "suggest %<||%> instead of %<|%> when joining booleans");
>/* Check cases like x|y==z */
>else if (TREE_CODE_CLASS (code_left) == tcc_comparison)
>   warning_at (EXPR_LOC_OR_LOC (arg_left, loc), OPT_Wparentheses,
> @@ -11642,6 +11647,11 @@
>   else if (code_right == MINUS_EXPR)
>   warning_at (EXPR_LOC_OR_LOC (arg_right, loc), OPT_Wparentheses,
>"suggest parentheses around %<-%> in operand of %<&%>");
> +  /* Check cases like (x +  else if(TREE_CODE_CLASS (code_left) == tcc_comparison 
Likewise here.

> +   && TREE_CODE_CLASS (code_right) == tcc_comparison)
> + warning_at (loc, OPT_Wparentheses,
> +  "suggest %<&&%> instead of %<&%> when joining booleans");
>   /* Check cases like x&y==z */
>   else if (TREE_CODE_CLASS (code_left) == tcc_comparison)
>   warning_at (EXPR_LOC_OR_LOC (arg_left, loc), OPT_Wparentheses,

...but IMHO the main thing is to add test cases, so that we can see
what the effect of the patch is, and so that the test suite
automatically
ensures that gcc continues to do the right thing.

A full patch should also include a ChangeLog entry summarizing the
change.

One other thing to note is that currently we're in "stage 4" of
development for gcc 6, meaning that we're in deep feature freeze, and
only fixing the most severe bugs.  Given that, your patch is probably
more appropriate for gcc 7 than gcc 6.

Hope this is helpful; thanks and welcome again.
Dave


[PATCH] Fix PR c++/69694 (non-dependent MODOP_EXPR with NULL type)

2016-02-20 Thread Patrick Palka
The problem here is that when processing_template_decl, the non-compound
MODOP_EXPRs we build (i.e. a = b and not a += b) are given a NULL
TREE_TYPE even if none of its operands are dependent.  This causes
decltypes such as "decltype (a = b)" (where a and b are not dependent)
to fail to get resolved to a concrete type since the MODOP_EXPR within
is considered to be dependent according to instantiation_dependent_expression_p.
And in the case of decltype65.C this causes partial-specialization
selection to malfunction since the template parameter type
"void_t" never gets resolved to "void".

This patch fixes this issue by adjusting build_x_modify_expr to give
non-compound non-dependent MODOP_EXPRs an accurate non-NULL TREE_TYPE.
To do this we have to first process the assignment at template
processing time using cp_build_modify_expr.  This means we will now
diagnose invalid assignments at template-processing time, necessitating
some minor adjustments to the testsuite.

The changes to the test suite are trivial except for the change to
unary2.C.  Here, whereas before we were always failing to diagnose at
template processing time the invalid assignment -n = 0 (whose LHS is not
an lvalue), after this patch we now fail to diagnose this invalid
assignment only with c++98.  This is because lvalue_kind treats
NON_DEPENDENT_EXPRs differently depending on the cxx_dialect:

case NON_DEPENDENT_EXPR:
  /* We just return clk_ordinary for NON_DEPENDENT_EXPR in C++98, but
 in C++11 lvalues don't bind to rvalue references, so we need to
 work harder to avoid bogus errors (c++/44870).  */
  if (cxx_dialect < cxx11)
return clk_ordinary;
  else
return lvalue_kind (TREE_OPERAND (ref, 0));

So in c++98 mode any NON_DEPENDENT_EXPR is considered to be a valid LHS
of an assignment even if the underlying expression is not actually an
lvalue.  Removing this special case is not completely trivial.

Bootstrap + regtest in progress on x86_64-pc-linux-gnu, will also test
against Boost.  Does this look OK if testing passes?

gcc/cp/ChangeLog:

PR c++/69694
* semantics.c (finish_paranthesized_expr): Set the
TREE_NO_WARNING flag on MODOP_EXPRs that are wrapped in an
implicit INDIRECT_REF.
* typeck.c (build_x_modify_expr): Give the middle operand of
the resulting MODOP_EXPR a dummy non-NULL type.  When MODIFYCODE
is NOP_EXPR and the operands are not dependent, don't exit early
and instead process the expression with cp_build_modify_expr.
Assert that the return value of build_new_op is non-NULL.

gcc/testsuite/ChangeLog:

PR c++/69694
* g++.dg/cpp0x/decltype64.C: New test.
* g++.dg/cpp0x/decltype65.C: New test.
* g++.dg/expr/unary2.C: The XFAILs no longer fail
on c++11 or later, only with c++98.
* g++.dg/cpp0x/error2.C: Adjust expected error message.
* g++.dg/ext/fixed1.C: Likewise.
* g++.dg/template/error35.C: Likewise.
* g++.dg/template/init7.C: Likewise.
---
 gcc/cp/semantics.c  |  7 +++
 gcc/cp/typeck.c | 30 +-
 gcc/testsuite/g++.dg/cpp0x/decltype64.C | 30 ++
 gcc/testsuite/g++.dg/cpp0x/decltype65.C | 24 
 gcc/testsuite/g++.dg/cpp0x/error2.C |  2 +-
 gcc/testsuite/g++.dg/expr/unary2.C  |  4 ++--
 gcc/testsuite/g++.dg/ext/fixed1.C   |  4 ++--
 gcc/testsuite/g++.dg/template/error35.C |  2 +-
 gcc/testsuite/g++.dg/template/init7.C   |  3 ++-
 9 files changed, 90 insertions(+), 16 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype64.C
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype65.C

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 4bbc698..20f263f 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1704,6 +1704,13 @@ finish_parenthesized_expr (cp_expr expr)
 /* This inhibits warnings in c_common_truthvalue_conversion.  */
 TREE_NO_WARNING (expr) = 1;
 
+  /* This inhibits -Wparentheses warnings for parenthesized non-dependent
+ MODOP_EXPRs, which are wrapped in an implicit INDIRECT_REF.   */
+  if (processing_template_decl
+  && REFERENCE_REF_P (expr)
+  && TREE_CODE (TREE_OPERAND (expr, 0)) == MODOP_EXPR)
+TREE_NO_WARNING (TREE_OPERAND (expr, 0)) = 1;
+
   if (TREE_CODE (expr) == OFFSET_REF
   || TREE_CODE (expr) == SCOPE_REF)
 /* [expr.unary.op]/3 The qualified id of a pointer-to-member must not be
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 5145879..3da6ea1 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -7869,26 +7869,39 @@ build_x_modify_expr (location_t loc, tree lhs, enum 
tree_code modifycode,
   tree orig_lhs = lhs;
   tree orig_rhs = rhs;
   tree overload = NULL_TREE;
-  tree op = build_nt (modifycode, NULL_TREE, NULL_TREE);
+  /* Give this middle operand of the resulting MODOP_EXPR a dummy non-NULL type
+ so 

[PATCH] PR28901 Add two levels for -Wunused-const-variable.

2016-02-20 Thread Mark Wielaard
There is some controversy about enabling -Wunused-const-variable for all
unused static const variables because some feel there are too many errors
exposed in header files. Create two levels for -Wunused-const-variable.
One level to only check for unused static const variables in the main
compilation file. Which is enabled by -Wunused-variable. And a second
level that also checks for unused static const variables in included
header files. Which must be explicitly enabled.

gcc/ChangeLog

PR c/28901
* cgraphunit.c (check_global_declaration): Check level of
warn_unused_const_variable and main_input_filename.
* doc/invoke.texi (Warning Options): Add -Wunused-const-variable=.
(-Wunused-variable): For C implies -Wunused-const-variable=1.
(-Wunused-const-variable): Explain levels 1 and 2.

gcc/c-family/ChangeLog

PR c/28901
* c.opt (Wunused-const-variable): Turn into Alias for...
(Wunused-const-variable=): New option.

gcc/testsuite/ChangeLog

PR c/28901
* gcc.dg/unused-variable-3.c: New test.
---
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 638e9c2..7c5f6c7 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -949,7 +949,11 @@ C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wunused)
 ; documented in common.opt
 
 Wunused-const-variable
-C ObjC C++ ObjC++ Var(warn_unused_const_variable) Warning LangEnabledBy(C 
ObjC,Wunused-variable)
+C ObjC C++ ObjC++ Warning Alias(Wunused-const-variable=, 2, 0)
+Warn when a const variable is unused.
+
+Wunused-const-variable=
+C ObjC C++ ObjC++ Joined RejectNegative UInteger 
Var(warn_unused_const_variable) Warning LangEnabledBy(C ObjC,Wunused-variable, 
1, 0)
 Warn when a const variable is unused.
 
 Wvariadic-macros
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 0a745f0..27a073a 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -942,7 +942,10 @@ check_global_declaration (symtab_node *snode)
   /* Warn about static fns or vars defined but not used.  */
   if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
|| (((warn_unused_variable && ! TREE_READONLY (decl))
-   || (warn_unused_const_variable && TREE_READONLY (decl)))
+   || (warn_unused_const_variable > 0 && TREE_READONLY (decl)
+   && (warn_unused_const_variable == 2
+   || filename_cmp (main_input_filename,
+DECL_SOURCE_FILE (decl)) == 0)))
   && TREE_CODE (decl) == VAR_DECL))
   && ! DECL_IN_SYSTEM_HEADER (decl)
   && ! snode->referred_to_p (/*include_self=*/false)
@@ -971,7 +974,7 @@ check_global_declaration (symtab_node *snode)
(TREE_CODE (decl) == FUNCTION_DECL)
? OPT_Wunused_function
: (TREE_READONLY (decl)
-  ? OPT_Wunused_const_variable
+  ? OPT_Wunused_const_variable_
   : OPT_Wunused_variable),
"%qD defined but not used", decl);
 }
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c1ab788..490df93 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -303,7 +303,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wunsuffixed-float-constants  -Wunused  -Wunused-function @gol
 -Wunused-label  -Wunused-local-typedefs -Wunused-parameter @gol
 -Wno-unused-result -Wunused-value @gol -Wunused-variable @gol
--Wunused-const-variable @gol
+-Wunused-const-variable -Wunused-const-variable=@var{n} @gol
 -Wunused-but-set-parameter -Wunused-but-set-variable @gol
 -Wuseless-cast -Wvariadic-macros -Wvector-operation-performance @gol
 -Wvla -Wvolatile-register-var  -Wwrite-strings @gol
@@ -4231,23 +4231,39 @@ its return value. The default is 
@option{-Wunused-result}.
 @opindex Wunused-variable
 @opindex Wno-unused-variable
 Warn whenever a local or static variable is unused aside from its
-declaration. This option implies @option{-Wunused-const-variable} for C,
+declaration. This option implies @option{-Wunused-const-variable=1} for C,
 but not for C++. This warning is enabled by @option{-Wall}.
 
 To suppress this warning use the @code{unused} attribute
 (@pxref{Variable Attributes}).
 
 @item -Wunused-const-variable
+@itemx -Wunused-const-variable=@var{n}
 @opindex Wunused-const-variable
 @opindex Wno-unused-const-variable
 Warn whenever a constant static variable is unused aside from its declaration.
-This warning is enabled by @option{-Wunused-variable} for C, but not for C++.
-In C++ this is normally not an error since const variables take the place of
-@code{#define}s in C++.
+@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
+for C, but not for C++. In C this declares variable storage, but in C++ this
+is not an error since const variables take the place of @code{#define}s.
 
 To suppress this warning use the @code{unused} attribute
 (@pxref{Variable Attributes}).
 
+@table @gcctabopt
+@item -Wunused-const-variable=1
+This is the warnin