From 4eb8255191896120db49604760daa1234abd86b9 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Thu, 28 Mar 2019 21:20:18 +0000 Subject: [PATCH] PR c++/81506 - Invalid declaration with decltype accepted testsuite/ChangeLog: * g++.dg/cpp0x/decltype-pr81506.C: New test. From-SVN: r270006 --- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/cpp0x/decltype-pr81506.C | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/decltype-pr81506.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9a496ec58f4..e0832a910c2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-28 Martin Sebor + + PR c++/81506 + * g++.dg/cpp0x/decltype-pr81506.C: New test. + 2019-03-28 Marek Polacek 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 index 00000000000..ecf762eb75a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype-pr81506.C @@ -0,0 +1,28 @@ +// PR c++/81506 - Invalid declaration with decltype accepted +// { dg-do compile } +// + +#if __cplusplus < 201103L +# define decltype __typeof__ +#endif + +template +struct A +{ + A () { + decltype (this); // { dg-error "declaration does not declare anything" } + } +}; + +A<0> a; + +template +struct B +{ + B () { + __typeof__ (this); // { dg-error "declaration does not declare anything" } + } +}; + +B b; + -- 2.30.2