[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2024-07-24 Thread jason at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=115897
   Assignee|jason at gcc dot gnu.org   |unassigned at gcc dot 
gnu.org

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2024-01-04 Thread rsandifo at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

Richard Sandiford  changed:

   What|Removed |Added

 CC||rsandifo at gcc dot gnu.org

--- Comment #11 from Richard Sandiford  ---
FWIW, the following adaption of the original testcase still fails on trunk, but
is accepted by Clang:

template 
struct D {
using t = int __attribute__((vector_size(N * sizeof(int;
t v;
int f1() { return this->v[N-1]; }
int f2() { return v[N-1]; }
};

int main(int ac, char**)
{
  D<> d = { { ac } };
  return d.f1() + d.f2();
}

Same with a typedef instead of "using".  But that's probably just another
instance of PR88600/PR58855.

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2021-05-04 Thread ncm at cantrip dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

--- Comment #10 from ncm at cantrip dot org ---
(In reply to ncm from comment #9)
> This bug appears not to manifest in g++-8, 9, and 10.
Of the three code samples in comment 4, the first and 
third fail to compile because N is undefined. What 
code was intended there? It seems like we should check
the corrected versions of those before declaring this 
fixed.

The code sample in example 3 still reports failings in
g++-10.2.

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2021-05-04 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

Richard Biener  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2020-11-10 Thread ncm at cantrip dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

--- Comment #9 from ncm at cantrip dot org ---
This bug appears not to manifest in g++-8, 9, and 10.

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2016-09-28 Thread dje at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

David Edelsohn  changed:

   What|Removed |Added

 CC||dje at gcc dot gnu.org

--- Comment #8 from David Edelsohn  ---
The new vector32.C and vector32a.C testcases fail on AIX:

src/gcc/testsuite/g++.dg/ext/vector32.C: In function 'int main()':
src/gcc/testsuite/g++.dg/ext/vector32.C:18:1: internal compiler error: in get,
at cgraph.h:395

gcc_checking_assert (TREE_CODE (decl) == FUNCTION_DECL
 || (TREE_CODE (decl) == VAR_DECL
 && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)
 || in_lto_p)));

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2016-09-05 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

Jason Merrill  changed:

   What|Removed |Added

 Status|RESOLVED|NEW
 Resolution|FIXED   |---
   Target Milestone|7.0 |---

--- Comment #7 from Jason Merrill  ---
The patch didn't fix the last testcase in comment 4.

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2016-08-09 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org
   Target Milestone|--- |7.0

--- Comment #5 from Jason Merrill  ---
Fixed for GCC 7.

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2016-08-09 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

--- Comment #6 from Jason Merrill  ---
Author: jason
Date: Tue Aug  9 22:03:07 2016
New Revision: 239309

URL: https://gcc.gnu.org/viewcvs?rev=239309&root=gcc&view=rev
Log:
PR c++/68703 - bogus error with dependent vector length

gcc/c-family/
* c-common.c (c_common_attribute_table): vector_size affects type
identity.
gcc/cp/
* decl2.c (any_dependent_type_attributes_p): New.
* pt.c (dependent_type_p_r, type_dependent_expression_p): Check it.
* semantics.c (finish_id_expression): Check it.
* typeck.c (finish_class_member_access_expr): Check it.

Added:
trunk/gcc/testsuite/g++.dg/ext/vector32.C
trunk/gcc/testsuite/g++.dg/ext/vector32a.C
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/cp-tree.h
trunk/gcc/cp/decl2.c
trunk/gcc/cp/pt.c
trunk/gcc/cp/semantics.c
trunk/gcc/cp/typeck.c

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2016-08-08 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

--- Comment #4 from Jakub Jelinek  ---
Not really sure if this is about dependent type or not, because the following
fails too:
template 
struct D {
  V v;
  int f1 () { return this->v[N-1]; }
  int f2 () { return v[N-1]; }
};

int
main ()
{
  typedef int V1 __attribute__((vector_size (4 * sizeof (int;
  typedef int V2 __attribute__((vector_size (8 * sizeof (int;
  D a = { { 0, 1, 2, 3 } };
  D b = { { 0, 1, 2, 3, 4, 5, 6, 7 } };
  if (a.f1 () != 3 || a.f2 () != 3
  || b.f1 () != 7 || b.f2 () != 7)
__builtin_abort ();
}

I've tried:
--- pt.c.jj42016-08-06 12:11:45.0 +0200
+++ pt.c (TREE_C2016-08-08 20:03:33.217898449 +0200
@@ -22687,6 +22687,11 @@ dependent_type_p_r (tree type)D (expression, 0));
  if   (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (scope)
 return true;_CODE (expression) == OFFSET_REF)
{
+  /* Types with dependent vector_size attribute are dependent.  */, 0)))
+  tree a = lookup_attribute ("vector_size", TYPE_ATTRIBUTES (type));
+  if (a && ATTR_IS_DEPENDENT (a))D (expression, 1);
+return true;ntifier_p (expression))
+   return false;
   /* Other types are non-dependent.  */
   return false;EF with non-null TREE_TYPE is always non-dependent.  */
 }
@@ -23166,6 +23171,18 @@ type_dependent_expression_p (tree expres
   if (TREE_CODE (expression) == EXPR_PACK_EXPANSION)
 return true;

+  /* Decls where the type is going to have dependent vector_size attribute
+ are dependent.  */
+  if (VAR_P (expression)
+  || TREE_CODE (expression) == PARM_DECL
+  || TREE_CODE (expression) == RESULT_DECL
+  || TREE_CODE (expression) == FIELD_DECL)
+{
+  tree a = lookup_attribute ("vector_size", DECL_ATTRIBUTES (expression));
+  if (a && ATTR_IS_DEPENDENT (a))
+   return true;
+}
+
   if (TREE_TYPE (expression) == unknown_type_node)
 {
   if (TREE_CODE (expression) == ADDR_EXPR)

so far but it didn't make any difference, neither on
template 
struct D {
  int v __attribute__((vector_size (N * sizeof (int;
  int f1 () { return this->v[N-1]; }
  int f2 () { return v[N-1]; }
};

int
main ()
{
  D<4> a = { { 0, 1, 2, 3 } };
  D<8> b = { { 0, 1, 2, 3, 4, 5, 6, 7 } };
  if (a.f1 () != 3 || a.f2 () != 3
  || b.f1 () != 7 || b.f2 () != 7)
__builtin_abort ();
}

nor on
template 
struct D {
  typedef int V __attribute__((vector_size (N * sizeof (int;
  V v;
  int f1 () { return this->v[N-1]; }
  int f2 () { return v[N-1]; }
};

int
main ()
{
  D<4> a = { { 0, 1, 2, 3 } };
  D<8> b = { { 0, 1, 2, 3, 4, 5, 6, 7 } };
  if (a.f1 () != 3 || a.f2 () != 3
  || b.f1 () != 7 || b.f2 () != 7)
__builtin_abort ();
}

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2016-08-08 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

Martin Sebor  changed:

   What|Removed |Added

 CC||msebor at gcc dot gnu.org

--- Comment #3 from Martin Sebor  ---
This problem isn't limited to attribute vector_size but affects attribute
aligned as well, to an even greater extent:  While G++ makes it possible to
overload functions on the former, it rejects overloads on the latter (it seems
to "lose" the attribute from a type).  The manual doesn't make it clear which
is intended, leading to confusion such as in bug 71463 where users don't know
whether to expect an attribute to affect the type of an object or in what
contexts (__typeof__, decltype, template parameters, etc.)

$ (cat y.C && set -x && for a in aligned vector_size; do
/build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -DX=$a -S -Wall
-Wextra y.C; done)
typedef int X16 __attribute__ ((X (16)));
typedef int X32 __attribute__ ((X (32)));

int f (X16*);
void f (X32*);

int g16 ()
{
  X16 x; 
  return f (&x);
}

void g32 ()
{
  X32 x;
  return f (&x);
}

template 
auto h ()
{
  int x __attribute__ ((X (N)));
  return f (&x);
}

+ for a in aligned vector_size
+ /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B
/home/msebor/build/gcc-trunk-svn/gcc -DX=aligned -S -Wall -Wextra y.C
y.C:5:6: error: ambiguating new declaration of ‘void f(X32*)’
 void f (X32*);
  ^
y.C:4:5: note: old declaration ‘int f(X16*)’
 int f (X16*);
 ^
y.C: In function ‘void g32()’:
y.C:16:15: error: return-statement with a value, in function returning 'void'
[-fpermissive]
   return f (&x);
   ^
+ for a in aligned vector_size
+ /home/msebor/build/gcc-trunk-svn/gcc/xgcc -B
/home/msebor/build/gcc-trunk-svn/gcc -DX=vector_size -S -Wall -Wextra y.C
y.C: In function ‘auto h()’:
y.C:23:15: error: no matching function for call to ‘f(int*)’
   return f (&x);
   ^
y.C:4:5: note: candidate: int f(X16*)
 int f (X16*);
 ^
y.C:4:5: note:   no known conversion for argument 1 from ‘int*’ to ‘X16* {aka
__vector(4) int*}’
y.C:5:6: note: candidate: void f(X32*)
 void f (X32*);
  ^
y.C:5:6: note:   no known conversion for argument 1 from ‘int*’ to ‘X32* {aka
__vector(8) int*}’

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2016-08-04 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-08-05
 Ever confirmed|0   |1
  Known to fail||6.1.0

--- Comment #2 from Andrew Pinski  ---
Confirmed.  The type of v should have been declared a dependent type but is
not.

[Bug c++/68703] __attribute__((vector_size(N))) template member confusion

2015-12-07 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68703

Richard Biener  changed:

   What|Removed |Added

   Keywords||rejects-valid

--- Comment #1 from Richard Biener  ---
Looks like v is not properly detected as dependent?