aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-11-13 09:40:32 -0500
committerJason Merrill <jason@gcc.gnu.org>2009-11-13 09:40:32 -0500
commita38f55dbfdae98511d6e8cf3e6c1cb0e06bb89a6 (patch)
tree0de9d180e2d9bde4f6f881b0541a92561b41be33 /gcc/cp
parentab11c13ff3e5507db92f789582b6f4e2a70569f3 (diff)
downloadgcc-a38f55dbfdae98511d6e8cf3e6c1cb0e06bb89a6.zip
gcc-a38f55dbfdae98511d6e8cf3e6c1cb0e06bb89a6.tar.gz
gcc-a38f55dbfdae98511d6e8cf3e6c1cb0e06bb89a6.tar.bz2
re PR c++/35075 (ICE with references in templates)
PR c++/35075 * pt.c (convert_nontype_argument): Give helpful error about reference variable argument to reference template parameter. From-SVN: r154151
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/pt.c21
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b148d23..d4c44a5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2009-11-13 Jason Merrill <jason@redhat.com>
+ PR c++/35075
+ * pt.c (convert_nontype_argument): Give helpful error about
+ reference variable argument to reference template parameter.
+
PR c++/21008, DR 515
* semantics.c (finish_non_static_data_member): Don't check
derivation in a template.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 85d9fff..c799368 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4927,6 +4927,27 @@ convert_nontype_argument (tree type, tree expr)
shall be one of: [...]
-- the address of an object or function with external linkage. */
+ if (TREE_CODE (expr) == INDIRECT_REF
+ && TYPE_REF_OBJ_P (TREE_TYPE (TREE_OPERAND (expr, 0))))
+ {
+ expr = TREE_OPERAND (expr, 0);
+ if (DECL_P (expr))
+ {
+ error ("%q#D is not a valid template argument for type %qT "
+ "because a reference variable does not have a constant "
+ "address", expr, type);
+ return NULL_TREE;
+ }
+ }
+
+ if (!DECL_P (expr))
+ {
+ error ("%qE is not a valid template argument for type %qT "
+ "because it is not an object with external linkage",
+ expr, type);
+ return NULL_TREE;
+ }
+
if (!DECL_EXTERNAL_LINKAGE_P (expr))
{
error ("%qE is not a valid template argument for type %qT "