2015-01-06 Jason Merrill <jason@redhat.com>
+ PR c++/64455
+ * pt.c (type_dependent_expression_p): Handle variable templates.
+ * constexpr.c (potential_constant_expression_1): Use it.
+
PR c++/64487
* semantics.c (finish_offsetof): Handle templates here.
* parser.c (cp_parser_builtin_offsetof): Not here.
|| !CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (t))
|| !DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (t))
&& !var_in_constexpr_fn (t)
- && !dependent_type_p (TREE_TYPE (t)))
+ && !type_dependent_expression_p (t))
{
if (flags & tf_error)
non_const_var_error (t);
&& DECL_INITIAL (expression))
return true;
+ /* A variable template specialization is type-dependent if it has any
+ dependent template arguments. */
+ if (VAR_P (expression)
+ && DECL_LANG_SPECIFIC (expression)
+ && DECL_TEMPLATE_INFO (expression)
+ && variable_template_p (DECL_TI_TEMPLATE (expression)))
+ return any_dependent_template_arguments_p (DECL_TI_ARGS (expression));
+
if (TREE_TYPE (expression) == unknown_type_node)
{
if (TREE_CODE (expression) == ADDR_EXPR)
--- /dev/null
+// PR c++/64455
+// { dg-do compile { target c++14 } }
+
+template<typename Type>
+constexpr bool IsType = true;
+
+template <bool b, class T> struct Test
+{
+};
+
+template <class T>
+struct Test<true, T>
+{
+ typedef T type;
+};
+
+template<class T>
+struct X {
+ typedef typename Test<IsType<T>,T>::type type;
+};
+
+int main()
+{
+ X<int>::type t;
+}