Patchwork C++ PATCH for c++/48617 (wrong error with decltype as template type argument)

login
register
mail settings
Submitter Jason Merrill
Date May 23, 2011, 2:54 p.m.
Message ID <4DDA753E.3040809@redhat.com>
Download mbox | patch
Permalink /patch/96965/
State New
Headers show

Comments

Jason Merrill - May 23, 2011, 2:54 p.m.
Just a missing case.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit 047661c30a4c6174fc8b994fcdd3eb344d10609c
Author: Jason Merrill <jason@redhat.com>
Date:   Sun May 22 15:06:19 2011 -0400

    	PR c++/48617
    	* pt.c (invalid_nontype_parm_type_p): Allow DECLTYPE_TYPE.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d72596f..380b21e 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18089,6 +18089,8 @@  invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain)
     return 0;
   else if (TREE_CODE (type) == TYPENAME_TYPE)
     return 0;
+  else if (TREE_CODE (type) == DECLTYPE_TYPE)
+    return 0;
 
   if (complain & tf_error)
     error ("%q#T is not a valid type for a template constant parameter", type);
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype27.C b/gcc/testsuite/g++.dg/cpp0x/decltype27.C
new file mode 100644
index 0000000..cb962ad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype27.C
@@ -0,0 +1,9 @@ 
+// PR c++/48617
+// { dg-options -std=c++0x }
+
+template<class T, decltype(T())> // #
+struct A {};
+
+A<int, 0> a;
+
+int main() {}