summaryrefslogtreecommitdiffstats
path: root/source/d/gcc/patches/PR100101.2efbbba16a0630fac8cadcd6d9e0ffaabfadb79f.patch
blob: 51ee459fd9ba27833b663a542f42cdbbaa94859c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From 2efbbba16a0630fac8cadcd6d9e0ffaabfadb79f Mon Sep 17 00:00:00 2001
From: Jason Merrill <jason@redhat.com>
Date: Thu, 15 Apr 2021 13:38:54 -0400
Subject: [PATCH] c++: noexcept error recursion [PR100101]

Here instantiating the noexcept-specifier for bar<void>() means
instantiating A<void>::value, which complains about the conversion from 0 to
int* in the default argument of foo.  Since my patch for PR99583, printing
the error context involves looking at C<void>::type, which again wants to
instantiate A<void>::value, which breaks.  For now at least, let's break
this recursion by avoiding looking into the noexcept-specifier in
find_typenames, and limit that to just the uses_parameter_packs case that
PR99583 cares about.

gcc/cp/ChangeLog:

	PR c++/100101
	PR c++/99583
	* pt.c (find_parameter_packs_r) [FUNCTION_TYPE]: Walk into
	TYPE_RAISES_EXCEPTIONS here.

gcc/testsuite/ChangeLog:

	PR c++/100101
	* g++.dg/cpp0x/noexcept67.C: New test.
---
 gcc/cp/pt.c                             | 11 +++++++++++
 gcc/testsuite/g++.dg/cpp0x/noexcept67.C | 26 +++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept67.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0f119a55272..2190f83882a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3890,6 +3890,10 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
     (struct find_parameter_pack_data*)data;
   bool parameter_pack_p = false;
 
+#define WALK_SUBTREE(NODE)				\
+  cp_walk_tree (&(NODE), &find_parameter_packs_r,	\
+		ppd, ppd->visited)			\
+
   /* Don't look through typedefs; we are interested in whether a
      parameter pack is actually written in the expression/type we're
      looking at, not the target type.  */
@@ -4070,10 +4074,17 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
 			ppd, ppd->visited);
       return NULL_TREE;
 
+    case FUNCTION_TYPE:
+    case METHOD_TYPE:
+      WALK_SUBTREE (TYPE_RAISES_EXCEPTIONS (t));
+      break;
+
     default:
       return NULL_TREE;
     }
 
+#undef WALK_SUBTREE
+
   return NULL_TREE;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept67.C b/gcc/testsuite/g++.dg/cpp0x/noexcept67.C
new file mode 100644
index 00000000000..7f061034323
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept67.C
@@ -0,0 +1,26 @@
+// PR c++/100101
+// { dg-do compile { target c++11 } }
+
+template <typename T> struct A
+{
+    template <typename U> static char foo(U*, int* = 0);
+    static const bool value = sizeof(foo(static_cast<T*>(nullptr))) > 0;
+};
+
+template <bool b> struct B
+{
+    static const bool value = b;
+};
+
+template <typename T> struct C
+{
+    typedef B<A<T>::value> type;
+};
+
+template <typename T>
+void bar() noexcept(A<T>::value && C<T>::type::value) {}
+
+void baz()
+{
+  bar<void>();
+}
-- 
2.27.0