aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Sutton <andrew.n.sutton@gmail.com>2014-08-13 14:16:48 +0000
committerAndrew Sutton <asutton@gcc.gnu.org>2014-08-13 14:16:48 +0000
commita3fea1ef37cded943ca50c3f38d74916e24373ee (patch)
tree277f6ee6031ce428f5dd352a6634008808e64eb1
parent429e4fdebf1aa0b14a39ac03c71becfd8d0d5f56 (diff)
downloadgcc-a3fea1ef37cded943ca50c3f38d74916e24373ee.zip
gcc-a3fea1ef37cded943ca50c3f38d74916e24373ee.tar.gz
gcc-a3fea1ef37cded943ca50c3f38d74916e24373ee.tar.bz2
pt.c (lookup_template_variable): Make dependent variable templates have unknown type.
2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com> * pt.c (lookup_template_variable): Make dependent variable templates have unknown type. From-SVN: r213910
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c13
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/var-templ6.C12
3 files changed, 28 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9d24958..0889ea6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
+
+ * pt.c (lookup_template_variable): Make dependent variable templates
+ have unknown type.
+
2014-08-13 Paolo Carlini <paolo.carlini@oracle.com>
* parser.c (cp_parser_elaborated_type_specifier): Handle
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 90b2720..be16ca8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -7965,13 +7965,22 @@ lookup_template_class (tree d1, tree arglist, tree in_decl, tree context,
return ret;
}
-/* Return a TEMPLATE_ID_EXPR for the given variable template and ARGLIST. */
+/* Return a TEMPLATE_ID_EXPR for the given variable template and ARGLIST.
+ If the ARGLIST refers to any template parameters, the type of the
+ expression is the unknown_type_node since the template-id could
+ refer to an explicit or partial specialization. */
tree
lookup_template_variable (tree templ, tree arglist)
{
- return build2 (TEMPLATE_ID_EXPR, TREE_TYPE (templ), templ, arglist);
+ tree type;
+ if (uses_template_parms (arglist))
+ type = unknown_type_node;
+ else
+ type = TREE_TYPE (templ);
+ return build2 (TEMPLATE_ID_EXPR, type, templ, arglist);
}
+
struct pair_fn_data
{
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ6.C b/gcc/testsuite/g++.dg/cpp1y/var-templ6.C
new file mode 100644
index 0000000..2125d6c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ6.C
@@ -0,0 +1,12 @@
+// { dg-options "-std=c++1y" }
+
+template<typename T>
+ constexpr bool Class = __is_class(T);
+
+template<typename T>
+ constexpr bool Test = Class<T>;
+
+struct S { };
+
+static_assert(!Test<int>, "");
+static_assert(Test<S>, "");