summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-02 12:47:26 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-02 12:47:26 +0000
commit9babf6c8ca4a829dcb9377a2cb8671ac6b51fd80 (patch)
treeeb0baacc25269fa28738355eb686446377997055 /gcc
parent4a5feece4e5b04bfc028bcf2ec9d8ec15c7a785a (diff)
downloadgcc-9babf6c8ca4a829dcb9377a2cb8671ac6b51fd80.tar.gz
cp:
PR c++/5123 * typeck.c (build_component_ref): Cope with a TEMPLATE_ID_EXPR. (build_x_function_call): Cope with a COMPONENT_REF containing a TEMPLATE_ID_EXPR. testsuite: * g++.dg/other/component1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48469 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/typeck.c33
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/other/component1.C29
4 files changed, 64 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 145f5bea273..ef4c0ddf60d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/5123
+ * typeck.c (build_component_ref): Cope with a TEMPLATE_ID_EXPR.
+ (build_x_function_call): Cope with a COMPONENT_REF containing a
+ TEMPLATE_ID_EXPR.
+
+2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+
PR c++/5213
* pt.c (convert_template_argument): Be more careful determining
when RECORD_TYPE templates are or are not templates.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9fdd168343c..b939de70447 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2030,7 +2030,7 @@ build_component_ref (datum, component, basetype_path, protect)
basetype_path, protect));
case TEMPLATE_DECL:
- error ("invalid use of %D", datum);
+ error ("invalid use of `%D'", datum);
datum = error_mark_node;
break;
@@ -2114,7 +2114,10 @@ build_component_ref (datum, component, basetype_path, protect)
else
{
tree name = component;
- if (TREE_CODE (component) == VAR_DECL)
+
+ if (TREE_CODE (component) == TEMPLATE_ID_EXPR)
+ name = TREE_OPERAND (component, 0);
+ else if (TREE_CODE (component) == VAR_DECL)
name = DECL_NAME (component);
if (TREE_CODE (component) == NAMESPACE_DECL)
/* Source is in error, but produce a sensible diagnostic. */
@@ -2162,8 +2165,14 @@ build_component_ref (datum, component, basetype_path, protect)
}
}
+ fndecls = TREE_VALUE (fndecls);
+
+ if (TREE_CODE (component) == TEMPLATE_ID_EXPR)
+ fndecls = build_nt (TEMPLATE_ID_EXPR,
+ fndecls, TREE_OPERAND (component, 1));
+
ref = build (COMPONENT_REF, unknown_type_node,
- datum, TREE_VALUE (fndecls));
+ datum, fndecls);
return ref;
}
@@ -2699,12 +2708,22 @@ build_x_function_call (function, params, decl)
/* Undo what we did in build_component_ref. */
decl = TREE_OPERAND (function, 0);
function = TREE_OPERAND (function, 1);
- function = DECL_NAME (OVL_CURRENT (function));
- if (template_id)
+ if (TREE_CODE (function) == TEMPLATE_ID_EXPR)
+ {
+ my_friendly_assert (!template_id, 20011228);
+
+ template_id = function;
+ }
+ else
{
- TREE_OPERAND (template_id, 0) = function;
- function = template_id;
+ function = DECL_NAME (OVL_CURRENT (function));
+
+ if (template_id)
+ {
+ TREE_OPERAND (template_id, 0) = function;
+ function = template_id;
+ }
}
return build_method_call (decl, function, params,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fc18102da11..dac37bd7936 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2002-01-02 Nathan Sidwell <nathan@codesourcery.com>
+ * g++.dg/other/component1.C: New test.
+
* g++.dg/template/ttp3.C: New test.
* g++.dg/template/friend2.C: New test.
diff --git a/gcc/testsuite/g++.dg/other/component1.C b/gcc/testsuite/g++.dg/other/component1.C
new file mode 100644
index 00000000000..3041a23193f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/component1.C
@@ -0,0 +1,29 @@
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 28 Dec 2001 <nathan@codesourcery.com>
+
+// PR 5123. ICE
+
+struct C {
+ template<class T> void f(T);
+ void g ();
+ void g (int);
+};
+
+void Foo () {
+ C c;
+
+ (c.g) ();
+ (c.f) (1);
+
+ (c.f<int>) (2);
+
+ c.g; // { dg-error "statement cannot resolve" "" }
+ c.f; // { dg-error "statement cannot resolve" "" }
+ c.f<int>; // { dg-error "statement cannot resolve" "" }
+
+ c.g == 1; // { dg-error "invalid use of" "" }
+ c.f == 1; // { dg-error "invalid use of" "" }
+ c.f<int> == 1; // { dg-error "invalid use of" "" }
+};