From 93aa462d4e86df64f9d9952fdbd5b0825ce55703 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Tue, 23 Mar 1999 16:13:44 +0000 Subject: [PATCH] pt.c (convert_nontype_argument): Don't create things that aren't PTRMEM_CSTs when... * pt.c (convert_nontype_argument): Don't create things that aren't PTRMEM_CSTs when applying a qualification conversion to a PTRMEM_CST. From-SVN: r25929 --- gcc/cp/ChangeLog | 6 +++++ gcc/cp/pt.c | 26 +++++++++++++++++---- gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C | 21 +++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e189f6db7b2..3bac892ca8e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1999-03-23 Mark Mitchell + + * pt.c (convert_nontype_argument): Don't create things that aren't + PTRMEM_CSTs when applying a qualification conversion to a + PTRMEM_CST. + 1999-03-23 Mark Mitchell * Makefile.in (OBJS): Don't mention hash.o. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 38e317c5468..aa8c9e99c10 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -2703,10 +2703,28 @@ convert_nontype_argument (type, expr) tree type_pointed_to = TREE_TYPE (type); if (TYPE_PTRMEM_P (type)) - /* For a non-type template-parameter of type pointer to data - member, qualification conversions (_conv.qual_) are - applied. */ - return perform_qualification_conversions (type, expr); + { + tree e; + + /* For a non-type template-parameter of type pointer to data + member, qualification conversions (_conv.qual_) are + applied. */ + e = perform_qualification_conversions (type, expr); + if (TREE_CODE (e) == NOP_EXPR) + { + /* The call to perform_qualification_conversions will + insert a NOP_EXPR over EXPR to do express + conversion, if necessary. But, that will confuse + us if we use this (converted) template parameter to + instantiate another template; then the thing will + not look like a valid template argument. So, just + make a new constant, of the appropriate type. */ + e = make_node (PTRMEM_CST); + TREE_TYPE (e) = type; + PTRMEM_CST_MEMBER (e) = PTRMEM_CST_MEMBER (expr); + } + return e; + } else if (TREE_CODE (type_pointed_to) == FUNCTION_TYPE) { /* For a non-type template-parameter of type pointer to diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C new file mode 100644 index 00000000000..4c010560843 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.pt/ptrmem7.C @@ -0,0 +1,21 @@ +// Build don't link: +// Origin: Jason Merrill + +struct A +{ + A() : x(123) { } + int x; +}; +A a; + +template +struct B +{ + static int g() { return a.*PX; } +}; + + +int main(int argc, char *argv[]) +{ + int n = B<&A::x>::g(); +} -- 2.30.2