PR c++/81506 - Invalid declaration with decltype accepted
authorMartin Sebor <msebor@redhat.com>
Thu, 28 Mar 2019 21:20:18 +0000 (21:20 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Thu, 28 Mar 2019 21:20:18 +0000 (15:20 -0600)
testsuite/ChangeLog:
* g++.dg/cpp0x/decltype-pr81506.C: New test.

From-SVN: r270006

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype-pr81506.C [new file with mode: 0644]

index 9a496ec58f4a8abd906c99ded74ef2f575c7c425..e0832a910c28e2cc9104c9820f290e8818c8473b 100644 (file)
@@ -1,3 +1,8 @@
+2019-03-28  Martin Sebor  <msebor@redhat.com>
+
+       PR c++/81506
+       * g++.dg/cpp0x/decltype-pr81506.C: New test.
+
 2019-03-28  Marek Polacek  <polacek@redhat.com>
 
        PR c++/89612 - ICE with member friend template with noexcept.
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-pr81506.C b/gcc/testsuite/g++.dg/cpp0x/decltype-pr81506.C
new file mode 100644 (file)
index 0000000..ecf762e
--- /dev/null
@@ -0,0 +1,28 @@
+// PR c++/81506 - Invalid declaration with decltype accepted
+// { dg-do compile }
+//
+
+#if __cplusplus < 201103L
+# define decltype __typeof__
+#endif
+
+template <int>
+struct A
+{
+  A () {
+    decltype (this);     // { dg-error "declaration does not declare anything" }
+  }
+};
+
+A<0> a;
+
+template <class>
+struct B
+{
+  B () {
+    __typeof__ (this);   // { dg-error "declaration does not declare anything" }
+  }
+};
+
+B<int> b;
+