We used to print errors, but since r236221 this compiles fine. clang++ also compiles it without errors.
Tested on x86_64-linux, applying to trunk. 2019-05-14 Marek Polacek <pola...@redhat.com> PR c++/68918 * g++.dg/cpp0x/decltype71.C: New test. diff --git gcc/testsuite/g++.dg/cpp0x/decltype71.C gcc/testsuite/g++.dg/cpp0x/decltype71.C new file mode 100644 index 00000000000..24c3abfba49 --- /dev/null +++ gcc/testsuite/g++.dg/cpp0x/decltype71.C @@ -0,0 +1,25 @@ +// PR c++/68918 +// { dg-do compile { target c++11 } } + +struct foo { + static void a() {} + + auto b() const -> decltype( this->a() ) + {} + + template<typename X> + auto c() -> decltype( this->a() ) + {} + + template<typename X> + auto d() const -> decltype( a() ) + {} + + template<typename X> + auto e() const -> decltype( this->a() ) + {} +}; + +int main() +{ +}