summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorgiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-06 10:51:08 +0000
committergiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-06 10:51:08 +0000
commitf551ed05aad420487fd64f761a4c6d16b0acf1c3 (patch)
tree6857372bf97f5126f821d5886fbb5d1a6937ccf1 /gcc/cp
parent726dac643fcf746d36c85158cdff2c5f321b3f42 (diff)
downloadgcc-f551ed05aad420487fd64f761a4c6d16b0acf1c3.tar.gz
PR c++/3671
* pt.c (convert_nontype_argument): Disallow conversions between different enumeration types. PR c++/3671 * g++.dg/template/spec14.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84150 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c9
2 files changed, 14 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ff63da14f45..f6982704c2e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2004-07-06 Giovanni Bajo <giovannibajo@gcc.gnu.org>
+
+ PR c++/3671
+ * pt.c (convert_nontype_argument): Disallow conversions between
+ different enumeration types.
+
2004-07-06 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (BINFO_MARKED): Remove.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9ecec9878de..0a43edead93 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3323,7 +3323,14 @@ convert_nontype_argument (tree type, tree expr)
conversions (_conv.integral_) are applied. */
if (!INTEGRAL_TYPE_P (expr_type))
return error_mark_node;
-
+
+ /* [conv.integral] does not allow conversions between two different
+ enumeration types. */
+ if (TREE_CODE (type) == ENUMERAL_TYPE
+ && TREE_CODE (expr_type) == ENUMERAL_TYPE
+ && !same_type_ignoring_top_level_qualifiers_p (type, expr_type))
+ return error_mark_node;
+
/* It's safe to call digest_init in this case; we know we're
just converting one integral constant expression to another. */
expr = digest_init (type, expr, (tree*) 0);