summaryrefslogtreecommitdiffstats
path: root/gcc
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-03 23:43:35 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-03 23:43:35 +0000
commita7eb08eda3dbddddfce1a048df0ac0b09420940a (patch)
tree69e4a662d2162898470b7ba451b541230b34c6a8 /gcc
parentf99eba1984e245cd414f78e0abffa469fce31e7d (diff)
downloadppe42-gcc-a7eb08eda3dbddddfce1a048df0ac0b09420940a.tar.gz
ppe42-gcc-a7eb08eda3dbddddfce1a048df0ac0b09420940a.zip
PR c++/5104
* typeck.c (comptypes) [FUNCTION_TYPE]: Don't compare exception specifiers. [METHOD_TYPE]: Use same code as FUNCTION_TYPE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51821 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/typeck.c23
-rw-r--r--gcc/testsuite/g++.dg/eh/spec4.C17
3 files changed, 27 insertions, 20 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 50dfde814f1..15e12d6858c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2002-04-04 Jason Merrill <jason@redhat.com>
+
+ PR c++/5104
+ * typeck.c (comptypes) [FUNCTION_TYPE]: Don't compare exception
+ specifiers.
+ [METHOD_TYPE]: Use same code as FUNCTION_TYPE.
+
2002-04-03 Richard Henderson <rth@redhat.com>
* cp-lang.c (cxx_warn_unused_global_decl): New.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index d379809b81e..7596d297f4a 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -763,7 +763,7 @@ comp_except_types (a, b, exact)
}
/* Return 1 if TYPE1 and TYPE2 are equivalent exception specifiers.
- If EXACT is 0, T2 can be a subset of T1 (according to 15.4/7),
+ If EXACT is 0, T2 can be stricter than T1 (according to 15.4/7),
otherwise it must be exact. Exception lists are unordered, but
we've already filtered out duplicates. Most lists will be in order,
we should try to make use of that. */
@@ -786,7 +786,7 @@ comp_except_specs (t1, t2, exact)
return t2 != NULL_TREE && !TREE_VALUE (t2);
if (t2 == NULL_TREE) /* T2 is ... */
return 0;
- if (TREE_VALUE(t1) && !TREE_VALUE (t2)) /* T2 is EMPTY, T1 is not */
+ if (TREE_VALUE (t1) && !TREE_VALUE (t2)) /* T2 is EMPTY, T1 is not */
return !exact;
/* Neither set is ... or EMPTY, make sure each part of T2 is in T1.
@@ -987,20 +987,6 @@ comptypes (t1, t2, strict)
&& comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict));
break;
- case METHOD_TYPE:
- if (! comp_except_specs (TYPE_RAISES_EXCEPTIONS (t1),
- TYPE_RAISES_EXCEPTIONS (t2), 1))
- return 0;
-
- /* This case is anti-symmetrical!
- One can pass a base member (or member function)
- to something expecting a derived member (or member function),
- but not vice-versa! */
-
- val = (comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict)
- && compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2)));
- break;
-
case POINTER_TYPE:
case REFERENCE_TYPE:
t1 = TREE_TYPE (t1);
@@ -1015,11 +1001,8 @@ comptypes (t1, t2, strict)
goto look_hard;
break;
+ case METHOD_TYPE:
case FUNCTION_TYPE:
- if (! comp_except_specs (TYPE_RAISES_EXCEPTIONS (t1),
- TYPE_RAISES_EXCEPTIONS (t2), 1))
- return 0;
-
val = ((TREE_TYPE (t1) == TREE_TYPE (t2)
|| comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict))
&& compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2)));
diff --git a/gcc/testsuite/g++.dg/eh/spec4.C b/gcc/testsuite/g++.dg/eh/spec4.C
new file mode 100644
index 00000000000..a41605f5637
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/spec4.C
@@ -0,0 +1,17 @@
+// PR c++/5104
+// Test that a function with a throw spec is a valid template argument.
+
+#include <exception>
+
+typedef void (*HandlerFunction)();
+typedef HandlerFunction (*SetHandlerFunction)(HandlerFunction);
+
+template <SetHandlerFunction set_function>
+class HandlerStack {
+public:
+ static void defaultHandler();
+};
+
+typedef HandlerStack<std::set_terminate> Terminate;
+
+template<> void Terminate::defaultHandler() {};
OpenPOWER on IntegriCloud