Using decltype as the scope of a declaration is ill-formed like using
a template parameter, so we just need to add the case.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 8e3fc6fef25c9ccddea0097216bf2989e10d9cb5
Author: Jason Merrill <ja...@redhat.com>
Date:   Thu Jul 14 12:34:28 2016 -0400

        PR c++/71511 - ICE on decltype scope in declaration.
    
        * typeck2.c (cxx_incomplete_type_diagnostic): Handle DECLTYPE_TYPE.

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index b1206c0..b9dc56d 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -537,6 +537,7 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree 
value,
       break;
 
     case TYPENAME_TYPE:
+    case DECLTYPE_TYPE:
       emit_diagnostic (diag_kind, loc, 0,
                       "invalid use of dependent type %qT", type);
       break;
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype65.C 
b/gcc/testsuite/g++.dg/cpp0x/decltype65.C
new file mode 100644
index 0000000..85f635a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype65.C
@@ -0,0 +1,11 @@
+// PR c++/71511
+// { dg-do compile { target c++11 } }
+
+template < typename T > 
+class A 
+{   
+  static int i;   
+};
+
+//okay: template < typename T > int A <T>::i = 100;
+template < typename T > int decltype (A < T > ())::i = 100; // { dg-error 
"decltype" }

Reply via email to