commit 9b53d24ba67dae7b803edbb8d2e46e2600cb41fb
Author: Jason Merrill <jason@redhat.com>
Date: Fri Jul 2 23:48:32 2010 -0400
PR c++/44778
* init.c (build_offset_ref): If scope isn't dependent,
don't exit early. Look at TYPE_MAIN_VARIANT.
* pt.c (tsubst_copy) [OFFSET_REF]: Do substitution.
@@ -1507,18 +1507,9 @@ build_offset_ref (tree type, tree member, bool address_p)
if (TREE_CODE (member) == TEMPLATE_DECL)
return member;
- if (dependent_type_p (type) || type_dependent_expression_p (member))
- {
- tree ref, mem_type = NULL_TREE;
- if (!dependent_scope_p (type))
- mem_type = TREE_TYPE (member);
- ref = build_qualified_name (mem_type, type, member,
+ if (dependent_scope_p (type) || type_dependent_expression_p (member))
+ return build_qualified_name (NULL_TREE, type, member,
/*template_p=*/false);
- /* Undo convert_from_reference. */
- if (TREE_CODE (ref) == INDIRECT_REF)
- ref = TREE_OPERAND (ref, 0);
- return ref;
- }
gcc_assert (TYPE_P (type));
if (! is_class_type (type, 1))
@@ -1528,6 +1519,7 @@ build_offset_ref (tree type, tree member, bool address_p)
/* Callers should call mark_used before this point. */
gcc_assert (!DECL_P (member) || TREE_USED (member));
+ type = TYPE_MAIN_VARIANT (type);
if (!COMPLETE_OR_OPEN_TYPE_P (complete_type (type)))
{
error ("incomplete type %qT does not have member %qD", type, member);
@@ -11309,8 +11309,13 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
gcc_unreachable ();
case OFFSET_REF:
- mark_used (TREE_OPERAND (t, 1));
- return t;
+ r = build2
+ (code, tsubst (TREE_TYPE (t), args, complain, in_decl),
+ tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl),
+ tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl));
+ PTRMEM_OK_P (r) = PTRMEM_OK_P (t);
+ mark_used (TREE_OPERAND (r, 1));
+ return r;
case EXPR_PACK_EXPANSION:
error ("invalid use of pack expansion expression");
@@ -7,4 +7,4 @@ template<int> struct A
~A() { &A::i; } // { dg-error "reference" }
};
-A<0> a; // { dg-message "instantiated" }
+A<0> a;
new file mode 100644
@@ -0,0 +1,29 @@
+// PR c++/44778
+
+enum Healpix_Ordering_Scheme { RING, NEST };
+
+class Healpix_Base
+ {
+ protected:
+ Healpix_Ordering_Scheme scheme_;
+ int nest2ring (int pix) const;
+ int ring2nest (int pix) const;
+
+ typedef int (Healpix_Base::*swapfunc)(int pix) const;
+ };
+
+template<typename T> class Healpix_Map: public Healpix_Base
+ {
+ public:
+ void Import_nograde (const Healpix_Map<T> &orig)
+ {
+ swapfunc swapper = (scheme_ == NEST) ?
+ &Healpix_Map::ring2nest : &Healpix_Map::nest2ring;
+ }
+ };
+
+int main()
+ {
+ Healpix_Map<double> a,b;
+ a.Import_nograde(b);
+ }