c++: vector compound literal [PR105187]
authorJason Merrill <jason@redhat.com>
Thu, 7 Apr 2022 00:04:21 +0000 (20:04 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 7 Apr 2022 01:27:27 +0000 (21:27 -0400)
My cleanup in r12-296 cleared TREE_HAS_CONSTRUCTOR on digested class
initializers, but we leave it set for vectors, since we can't wrap them in
TARGET_EXPR.

PR c++/105187

gcc/cp/ChangeLog:

* typeck2.cc (store_init_value): Allow TREE_HAS_CONSTRUCTOR for
vectors.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/20050113-1.c: Moved to...
* c-c++-common/torture/20050113-1.c: ...here.

gcc/cp/typeck2.cc
gcc/testsuite/c-c++-common/torture/20050113-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/20050113-1.c [deleted file]

index cebe6acf4870361d4d1312c3977d53bdc9b8471b..23ed81ec0631e26ff7036a2f6d9fc4e65ed8f6af 100644 (file)
@@ -922,6 +922,7 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
      here it should have been digested into an actual value for the type.  */
   gcc_checking_assert (TREE_CODE (value) != CONSTRUCTOR
                       || processing_template_decl
+                      || TREE_CODE (type) == VECTOR_TYPE
                       || !TREE_HAS_CONSTRUCTOR (value));
 
   /* If the initializer is not a constant, fill in DECL_INITIAL with
diff --git a/gcc/testsuite/c-c++-common/torture/20050113-1.c b/gcc/testsuite/c-c++-common/torture/20050113-1.c
new file mode 100644 (file)
index 0000000..6e36ed6
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR c/17297 */
+
+typedef float V2SF __attribute__ ((vector_size (8)));
+
+int test0 (V2SF, V2SF);
+
+int
+main (void)
+{
+  V2SF a = (V2SF) {1.0f/0.0f - 1.0f/0.0f, 1.0f/0.0f - 1.0f/0.0f};
+  V2SF b = (V2SF) {567.345, 1984.0};
+  int i;
+
+  i = test0 (a, b);
+  return i;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/20050113-1.c b/gcc/testsuite/gcc.c-torture/compile/20050113-1.c
deleted file mode 100644 (file)
index 6e36ed6..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/* PR c/17297 */
-
-typedef float V2SF __attribute__ ((vector_size (8)));
-
-int test0 (V2SF, V2SF);
-
-int
-main (void)
-{
-  V2SF a = (V2SF) {1.0f/0.0f - 1.0f/0.0f, 1.0f/0.0f - 1.0f/0.0f};
-  V2SF b = (V2SF) {567.345, 1984.0};
-  int i;
-
-  i = test0 (a, b);
-  return i;
-}