aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2025-03-05 06:41:00 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2025-03-05 06:41:00 +0100
commit1853b02d8c127740055242123db2d32cf9476ea9 (patch)
tree48f01be5ef7ec54f6da846d1ea1afa2c915a9091 /gcc/testsuite/g++.dg/cpp0x
parent4856292f7a680ec478e7607f1b71781996d7d542 (diff)
downloadgcc-1853b02d8c127740055242123db2d32cf9476ea9.zip
gcc-1853b02d8c127740055242123db2d32cf9476ea9.tar.gz
gcc-1853b02d8c127740055242123db2d32cf9476ea9.tar.bz2
c++: Apply/diagnose attributes when instatiating ARRAY/POINTER/REFERENCE_TYPE [PR118787]
The following testcase IMO in violation of the P2552R3 paper doesn't pedwarn on alignas applying to dependent types or alignas with dependent argument. tsubst was just ignoring TYPE_ATTRIBUTES. The following patch fixes it for the POINTER/REFERENCE_TYPE and ARRAY_TYPE cases, but perhaps we need to do the same also for other types (INTEGER_TYPE/REAL_TYPE and the like). I guess I'll need to construct more testcases. 2025-03-05 Jakub Jelinek <jakub@redhat.com> PR c++/118787 * pt.cc (tsubst) <case ARRAY_TYPE>: Use return t; only if it doesn't have any TYPE_ATTRIBUTES. Call apply_late_template_attributes. <case POINTER_TYPE, case REFERENCE_TYPE>: Likewise. Formatting fix. * g++.dg/cpp0x/alignas22.C: New test.
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/alignas22.C23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas22.C b/gcc/testsuite/g++.dg/cpp0x/alignas22.C
new file mode 100644
index 0000000..e792977
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alignas22.C
@@ -0,0 +1,23 @@
+// PR c++/118787
+// { dg-do compile { target c++11 } }
+// { dg-options "-pedantic" }
+
+template <typename T, int N>
+void foo (T & alignas (N)); // { dg-warning "'alignas' on a type other than class" }
+template <typename T, int N>
+void bar (T (&)[N] alignas (N)); // { dg-warning "'alignas' on a type other than class" }
+template <typename T, int N>
+using U = T * alignas (N); // { dg-warning "'alignas' on a type other than class" }
+template <typename T, int N>
+using V = T[N] alignas (N); // { dg-warning "'alignas' on a type other than class" }
+
+void
+baz ()
+{
+ int x alignas (4) = 0;
+ foo <int, 4> (x);
+ int y alignas (4) [4];
+ bar <int, 4> (y);
+ U <int, 4> u;
+ V <int, 4> v;
+}