Re: [PATCH v2] extend shift count warnings to vector types

2016-07-02 Thread Marc Glisse

On Fri, 1 Jul 2016, Jan Beulich wrote:


gcc/c/
2016-07-01  Jan Beulich  

* c-fold.c (c_fully_fold_internal): Also emit shift count
warnings for vector types.
* c-typeck.c (build_binary_op): Likewise.


Hello,

I just wanted to advertise the function element_precision, whose goal is 
to unify handling of vectors and scalars. It is "overloaded" to apply 
TREE_TYPE the right number of times before TYPE_PRECISION. Since you are 
giving a different warning message for scalars and vectors, it probably 
wouldn't help you here though. (OTOH, if you decided that the same message 
was good enough for both...)


--
Marc Glisse


Backports to 6.2

2016-07-02 Thread Jakub Jelinek
Hi!

I've bootstrapped/regtested on x86_64-linux and i686-linux the following 
backports
from trunk to 6.2 and committed to 6.2.

Jakub
2016-07-02  Jakub Jelinek  

Backported from mainline
2016-06-20  Jakub Jelinek  

PR target/71559
* config/i386/i386.c (ix86_fp_cmp_code_to_pcmp_immediate): Fix up
returned values and add UN*/LTGT/*ORDERED cases with values matching
D operand modifier on vcmp for AVX.

* gcc.target/i386/sse2-pr71559.c: New test.
* gcc.target/i386/avx-pr71559.c: New test.
* gcc.target/i386/avx512f-pr71559.c: New test.

--- gcc/config/i386/i386.c  (revision 237613)
+++ gcc/config/i386/i386.c  (revision 237614)
@@ -23622,17 +23622,33 @@ ix86_fp_cmp_code_to_pcmp_immediate (enum
   switch (code)
 {
 case EQ:
-  return 0x08;
+  return 0x00;
 case NE:
   return 0x04;
 case GT:
-  return 0x16;
+  return 0x0e;
 case LE:
-  return 0x1a;
+  return 0x02;
 case GE:
-  return 0x15;
+  return 0x0d;
 case LT:
-  return 0x19;
+  return 0x01;
+case UNLE:
+  return 0x0a;
+case UNLT:
+  return 0x09;
+case UNGE:
+  return 0x05;
+case UNGT:
+  return 0x06;
+case UNEQ:
+  return 0x18;
+case LTGT:
+  return 0x0c;
+case ORDERED:
+  return 0x07;
+case UNORDERED:
+  return 0x03;
 default:
   gcc_unreachable ();
 }
--- gcc/testsuite/gcc.target/i386/avx-pr71559.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/avx-pr71559.c (revision 237614)
@@ -0,0 +1,8 @@
+/* PR target/71559 */
+/* { dg-do run { target avx } } */
+/* { dg-options "-O2 -ftree-vectorize -mavx" } */
+
+#include "avx-check.h"
+#define PR71559_TEST avx_test
+
+#include "sse2-pr71559.c"
--- gcc/testsuite/gcc.target/i386/avx512f-pr71559.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/avx512f-pr71559.c (revision 237614)
@@ -0,0 +1,8 @@
+/* PR target/71559 */
+/* { dg-do run { target avx512f } } */
+/* { dg-options "-O2 -ftree-vectorize -mavx512f" } */
+
+#include "avx512f-check.h"
+#define PR71559_TEST avx512f_test
+
+#include "sse2-pr71559.c"
--- gcc/testsuite/gcc.target/i386/sse2-pr71559.c(revision 0)
+++ gcc/testsuite/gcc.target/i386/sse2-pr71559.c(revision 237614)
@@ -0,0 +1,73 @@
+/* PR target/71559 */
+/* { dg-do run { target sse2 } } */
+/* { dg-options "-O2 -ftree-vectorize -msse2" } */
+
+#ifndef PR71559_TEST
+#include "sse2-check.h"
+#define PR71559_TEST sse2_test
+#endif
+
+#define N 16
+float a[N] = { 5.0f, -3.0f, 1.0f, __builtin_nanf (""), 9.0f, 7.0f, -3.0f, 
-9.0f,
+   -3.0f, -5.0f, -9.0f, __builtin_nanf (""), 0.5f, -0.5f, 0.0f, 
0.0f };
+float b[N] = { -5.0f, 3.0f, 1.0f, 7.0f, 8.0f, 8.0f, -3.0f, __builtin_nanf (""),
+   -4.0f, -4.0f, -9.0f, __builtin_nanf (""), 0.0f, 0.0f, 0.0f, 
__builtin_nanf ("") };
+int c[N], d[N];
+
+#define FN(name, op) \
+void   \
+name (void)\
+{  \
+  int i;   \
+  for (i = 0; i < N; i++)  \
+c[i] = (op || d[i] > 37) ? 5 : 32; \
+}
+FN (eq, a[i] == b[i])
+FN (ne, a[i] != b[i])
+FN (gt, a[i] > b[i])
+FN (ge, a[i] >= b[i])
+FN (lt, a[i] < b[i])
+FN (le, a[i] <= b[i])
+FN (unle, !__builtin_isgreater (a[i], b[i]))
+FN (unlt, !__builtin_isgreaterequal (a[i], b[i]))
+FN (unge, !__builtin_isless (a[i], b[i]))
+FN (ungt, !__builtin_islessequal (a[i], b[i]))
+FN (uneq, !__builtin_islessgreater (a[i], b[i]))
+FN (ordered, !__builtin_isunordered (a[i], b[i]))
+FN (unordered, __builtin_isunordered (a[i], b[i]))
+
+#define TEST(name, GT, LT, EQ, UO) \
+  name (); \
+  for (i = 0; i < N; i++)  \
+{  \
+  int v;   \
+  switch (i % 4)   \
+   {   \
+   case 0: v = GT ? 5 : 32; break; \
+   case 1: v = LT ? 5 : 32; break; \
+   case 2: v = EQ ? 5 : 32; break; \
+   case 3: v = UO ? 5 : 32; break; \
+   }   \
+  if (c[i] != v)   \
+   __builtin_abort (); \
+}
+
+void
+PR71559_TEST (void)
+{
+  int i;
+  asm volatile ("" : : "g" (a), "g" (b), "g" (c), "g" (d) : "memory");
+  TEST (eq, 0, 0, 1, 0)
+  TEST (ne, 1, 1, 0, 1)
+  TEST (gt, 1, 0, 0, 0)
+  TEST (ge, 1, 0, 1, 0)
+  TEST (lt, 0, 1, 0, 0)
+  TEST (le, 0, 1, 1, 0)
+  TEST (unle, 0, 1, 1, 1)
+  TEST (unlt, 0, 1, 0, 1)
+  TEST (unge, 1, 0, 1, 1)
+  TEST (ungt, 1, 0, 0, 1)
+  TEST (uneq, 0, 0, 1, 1)
+  TEST (ordered, 1, 1, 1, 0)
+  TEST (unordered, 0, 0, 0, 1)
+}
2016-07-02  Jakub Jelinek  

Backported from mainline
2016-06-28  Jakub Jelinek  

PR middle-end/71626
* config/i386/i386.c (ix86_expand_vector_move): For SUBREG of
a constant, force its SUBREG_REG into memory or register instead

Re: [PATCH 2/2] C++ FE: handle misspelled identifiers and typenames

2016-07-02 Thread Manuel López-Ibáñez

On 30/06/16 19:53, David Malcolm wrote:

This is a port of the C frontend's r237714 [1] to the C++ frontend:
   https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01052.html
offering spelling suggestions for misspelled identifiers, macro names,
and some keywords (e.g. "singed" vs "signed" aka PR c/70339).


Cool!


-  error_at (location, "%qE does not name a type", id);
+  const char *suggestion = NULL;
+  if (TREE_CODE (id) == IDENTIFIER_NODE)
+suggestion = lookup_name_fuzzy (id, FUZZY_LOOKUP_TYPENAME);
+  if (suggestion)
+   {
+ gcc_rich_location richloc (location);
+ richloc.add_fixit_misspelled_id (location, suggestion);
+ error_at_rich_loc (&richloc,
+"%qE does not name a type; did you mean %qs?",
+id, suggestion);
+   }
+  else
+   error_at (location, "%qE does not name a type", id);


It should be possible to encapsulate all this suggestion logic very deep in 
diagnostics.c and replace all the above with something similar to:


const char *suggestion = NULL;
if (TREE_CODE (id) == IDENTIFIER_NODE)
suggestion = lookup_name_fuzzy (id, FUZZY_LOOKUP_TYPENAME);

error_with_suggestion(location, suggestion, "%qE does not name a type",
  "%qE does not name a type; did you mean %qs?", id);

Perhaps with a bit more effort, even make the language-specific printers handle 
the task of looking for the suggestion, replacing the above with something like:


error_with_suggestion(location, FUZZY_LOOKUP_TYPENAME,
  "%qE does not name a type",
  "%qE does not name a type; did you mean %qs?", id);



diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c
index 7aab658..49f7f11 100644
--- a/gcc/diagnostic-show-locus.c
+++ b/gcc/diagnostic-show-locus.c
@@ -1280,9 +1280,18 @@ diagnostic_show_locus (diagnostic_context * context,
  {
pp_newline (context->printer);

-  if (!context->show_caret
-  || diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
-  || diagnostic_location (diagnostic, 0) == context->last_location)
+  /* Do nothing if source-printing has been disabled.  */
+  if (!context->show_caret)
+return;
+
+  /* Don't attempt to print source for UNKNOWN_LOCATION and for builtins.  */
+  if (diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION)
+return;
+
+  /* Don't print the same source location twice in a row, unless we have
+ fix-it hints.  */
+  if (diagnostic_location (diagnostic, 0) == context->last_location
+  && diagnostic->richloc->get_num_fixit_hints () == 0)
  return;

context->last_location = diagnostic_location (diagnostic, 0);


This seems independent of the suggestion stuff and could be committed 
separately.


--- a/gcc/spellcheck-tree.c
+++ b/gcc/spellcheck-tree.c
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
  #include "coretypes.h"
  #include "tm.h"
  #include "tree.h"
+#include "cpplib.h"


You make a language-independent file depend on cpplib.h. Wouldn't it be better 
to move c-specific stuff to a new c-family/c-spellcheck.c ?


Cheers,

Manuel.


Fix testsuite errors in debug mode

2016-07-02 Thread François Dumont
Some line numbers had to be adapted following a recent fix in 
debug/array.


lexicographical_compare/debug/irreflexive_neg.cc is failing since 
irreflexive check has been removed.


2016-07-02  François Dumont  

* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: 
Adjust

dg-error line numbers.
* testsuite/23_containers/array/tuple_interface/
tuple_element_debug_neg.cc: Likewise.
* testsuite/25_algorithms/lexicographical_compare/debug/
irreflexive_neg.cc: Remove.

François

Index: testsuite/23_containers/array/tuple_interface/get_debug_neg.cc
===
--- testsuite/23_containers/array/tuple_interface/get_debug_neg.cc	(revision 237944)
+++ testsuite/23_containers/array/tuple_interface/get_debug_neg.cc	(working copy)
@@ -28,6 +28,6 @@
 int n2 = std::get<1>(std::move(a));
 int n3 = std::get<1>(ca);
 
-// { dg-error "static assertion failed" "" { target *-*-* } 274 }
-// { dg-error "static assertion failed" "" { target *-*-* } 283 }
-// { dg-error "static assertion failed" "" { target *-*-* } 291 }
+// { dg-error "static assertion failed" "" { target *-*-* } 273 }
+// { dg-error "static assertion failed" "" { target *-*-* } 282 }
+// { dg-error "static assertion failed" "" { target *-*-* } 290 }
Index: testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc
===
--- testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc	(revision 237944)
+++ testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc	(working copy)
@@ -23,4 +23,4 @@
 
 typedef std::tuple_element<1, std::array>::type type;
 
-// { dg-error "static assertion failed" "" { target *-*-* } 309 }
+// { dg-error "static assertion failed" "" { target *-*-* } 308 }
Index: testsuite/25_algorithms/lexicographical_compare/debug/irreflexive_neg.cc
===
--- testsuite/25_algorithms/lexicographical_compare/debug/irreflexive_neg.cc	(revision 237944)
+++ testsuite/25_algorithms/lexicographical_compare/debug/irreflexive_neg.cc	(nonexistent)
@@ -1,70 +0,0 @@
-// Copyright (C) 2015-2016 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// .
-//
-// { dg-options "-std=gnu++11" }
-// { dg-require-debug-mode "" }
-// { dg-do run { xfail *-*-* } }
-
-#include 
-#include 
-
-struct A
-{
-  A(int i) : _i(i)
-  { }
-
-  int _i;
-};
-
-bool
-operator<(A a, int i)
-{ return a._i < i; }
-
-bool
-operator<(int i, A a)
-{ return i < a._i; }
-
-void test01()
-{
-  bool test __attribute__((unused)) = true;
-
-  A as[] { 0, 1, 2, 3 };
-  int is[] { 0, 1, 2, 3 };
-  VERIFY( !std::lexicographical_compare(as, as + 4, is, is + 4) );
-}
-
-bool
-bad_lower(int lhs, int rhs)
-{
-  if (lhs == 0)
-return true;
-
-  return lhs < rhs;
-}
-
-void test02()
-{
-  int is[] { 0, 1, 2, 3 };
-  std::lexicographical_compare(is, is + 4, is, is + 4, bad_lower);
-}
-
-int main()
-{
-  test01();
-  test02();
-  return 0;
-}