]> gcc.gnu.org Git - gcc.git/commitdiff
c++: Add testcase for DR 2604
authorJakub Jelinek <jakub@redhat.com>
Tue, 15 Nov 2022 06:57:42 +0000 (07:57 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 15 Nov 2022 06:57:42 +0000 (07:57 +0100)
As the following testcase shows, I think we don't inherit template's
attributes into specializations.

2022-11-15  Jakub Jelinek  <jakub@redhat.com>

* g++.dg/DRs/dr2604.C: New test.

gcc/testsuite/g++.dg/DRs/dr2604.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/DRs/dr2604.C b/gcc/testsuite/g++.dg/DRs/dr2604.C
new file mode 100644 (file)
index 0000000..64bdf5d
--- /dev/null
@@ -0,0 +1,53 @@
+// DR 2604 - Attributes for an explicit specialization.
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-parameter" }
+
+template<typename>
+[[noreturn]] void
+foo ([[maybe_unused]] int i)
+{
+  for (;;);
+}
+
+template<>
+void
+foo<int> (int i)       // { dg-warning "unused parameter 'i'" }
+{
+}
+
+template<typename>
+void
+bar (int i)            // { dg-warning "unused parameter 'i'" }
+{
+}
+
+template<>
+[[noreturn]] void
+bar<int> ([[maybe_unused]] int i)
+{
+  for (;;);
+}
+
+[[noreturn]] void
+baz ()
+{
+  foo<long> (0);
+}
+
+[[noreturn]] void
+qux ()
+{
+  foo<int> (0);
+}                      // { dg-warning "'noreturn' function does return" }
+
+[[noreturn]] void
+garply ()
+{
+  bar<long> (0);
+}                      // { dg-warning "'noreturn' function does return" }
+
+[[noreturn]] void
+corge ()
+{
+  bar<int> (0);
+}
This page took 0.05847 seconds and 5 git commands to generate.