]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix PR c++/69091 (ICE with operator overload having 'auto' return type)
authorPatrick Palka <ppalka@gcc.gnu.org>
Sat, 16 Jan 2016 02:37:09 +0000 (02:37 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Sat, 16 Jan 2016 02:37:09 +0000 (02:37 +0000)
gcc/cp/ChangeLog:

PR c++/69091
* pt.c (type_dependent_expression_p): For a function template
specialization, a type is dependent iff any of its template
arguments are.

gcc/testsuite/ChangeLog:

PR c++/69091
* g++.dg/template/pr69091.C: New test.

From-SVN: r232463

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/pr69091.C [new file with mode: 0644]

index 91b92a8b82cf28d48da6b55e53f0ebb4cd3d0290..6b7e81b0733778f56ddb2ef26341057d109fcec2 100644 (file)
@@ -1,3 +1,10 @@
+2016-01-16  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/69091
+       * pt.c (type_dependent_expression_p): For a function template
+       specialization, a type is dependent iff any of its template
+       arguments are.
+
 2016-01-16  Patrick Palka  <ppalka@gcc.gnu.org>
 
        * cp-array-notation.c (cp_expand_cond_array_notations): Return
index edec774a0c963a8bfe50f6e64cd6b9f0aa1bcfb1..403c5ac0bea813d7cc8c28b2362aac4aa5f8744d 100644 (file)
@@ -22759,12 +22759,12 @@ type_dependent_expression_p (tree expression)
              || dependent_scope_p (scope));
     }
 
+  /* A function template specialization is type-dependent if it has any
+     dependent template arguments.  */
   if (TREE_CODE (expression) == FUNCTION_DECL
       && DECL_LANG_SPECIFIC (expression)
-      && DECL_TEMPLATE_INFO (expression)
-      && (any_dependent_template_arguments_p
-         (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (expression)))))
-    return true;
+      && DECL_TEMPLATE_INFO (expression))
+    return any_dependent_template_arguments_p (DECL_TI_ARGS (expression));
 
   if (TREE_CODE (expression) == TEMPLATE_DECL
       && !DECL_TEMPLATE_TEMPLATE_PARM_P (expression))
index e21aad44ca6b131a43f4ce356cbf11cef2fdbc36..82810dd6aeb383a4f068ca124c601c3590f39439 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-16  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/69091
+       * g++.dg/template/pr69091.C: New test.
+
 2016-01-16  Patrick Palka  <ppalka@gcc.gnu.org>
 
        * c-c++-common/cilk-plus/AN/an-if.c: Check that the original
diff --git a/gcc/testsuite/g++.dg/template/pr69091.C b/gcc/testsuite/g++.dg/template/pr69091.C
new file mode 100644 (file)
index 0000000..ec7bb25
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/69091
+// { dg-do compile { target c++14 } }
+
+template <class ValueType, ValueType>
+struct Option {};
+
+template <class ValueType, ValueType Value, class OptionsRhs>
+auto operator|(Option<ValueType, Value>, OptionsRhs) {
+  return Value;
+}
+
+enum canine_t { no, yes };
+Option<canine_t, no> cat;
+Option<canine_t, yes> dog;
+
+template <class T>
+void f(T) {
+  cat | dog;
+}
+
+struct A {};
+int main() {
+  f(A{});
+  return 0;
+}