aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/cp-tree.h8
-rw-r--r--gcc/cp/pt.c2
-rw-r--r--gcc/cp/semantics.c3
-rw-r--r--gcc/cp/tree.c1
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/template/qualified-id4.C20
7 files changed, 39 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ac7eddd..5cfdfbf 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,13 @@
2011-07-01 Jason Merrill <jason@redhat.com>
+ PR c++/48593
+ * pt.c (tsubst_qualified_id): Check PTRMEM_OK_P.
+ * tree.c (build_qualified_name): Set PTRMEM_OK_P.
+ * semantics.c (finish_parenthesized_expr): Clear PTRMEM_OK_P on
+ SCOPE_REF, too.
+ * cp-tree.h (PTRMEM_OK_P): Apply to SCOPE_REF, too.
+ (QUALIFIED_NAME_IS_TEMPLATE): Switch to lang flag 1.
+
PR c++/48883
PR c++/49609
* pt.c (resolve_nondeduced_context): Call mark_used.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index ef25c97..357295c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -53,7 +53,7 @@ c-common.h, not after.
TREE_INDIRECT_USING (in NAMESPACE_DECL).
CLEANUP_P (in TRY_BLOCK)
AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR)
- PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF)
+ PTRMEM_OK_P (in ADDR_EXPR, OFFSET_REF, SCOPE_REF)
PAREN_STRING_LITERAL (in STRING_CST)
DECL_PRETTY_FUNCTION_P (in VAR_DECL)
KOENIG_LOOKUP_P (in CALL_EXPR)
@@ -62,7 +62,6 @@ c-common.h, not after.
STMT_EXPR_NO_SCOPE (in STMT_EXPR)
BIND_EXPR_TRY_BLOCK (in BIND_EXPR)
TYPENAME_IS_ENUM_P (in TYPENAME_TYPE)
- QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF)
OMP_FOR_GIMPLIFYING_P (in OMP_FOR)
BASELINK_QUALIFIED_P (in BASELINK)
TARGET_EXPR_IMPLICIT_P (in TARGET_EXPR)
@@ -86,6 +85,7 @@ c-common.h, not after.
LAMBDA_EXPR_MUTABLE_P (in LAMBDA_EXPR)
DECLTYPE_FOR_LAMBDA_RETURN (in DECLTYPE_TYPE)
DECL_FINAL_P (in FUNCTION_DECL)
+ QUALIFIED_NAME_IS_TEMPLATE (in SCOPE_REF)
2: IDENTIFIER_OPNAME_P (in IDENTIFIER_NODE)
ICS_THIS_FLAG (in _CONV)
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
@@ -3354,7 +3354,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
/* Indicates when overload resolution may resolve to a pointer to
member function. [expr.unary.op]/3 */
#define PTRMEM_OK_P(NODE) \
- TREE_LANG_FLAG_0 (TREE_CHECK2 ((NODE), ADDR_EXPR, OFFSET_REF))
+ TREE_LANG_FLAG_0 (TREE_CHECK3 ((NODE), ADDR_EXPR, OFFSET_REF, SCOPE_REF))
/* Get the POINTER_TYPE to the METHOD_TYPE associated with this
pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true,
@@ -3801,7 +3801,7 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
/* True for a SCOPE_REF iff the "template" keyword was used to
indicate that the qualified name denotes a template. */
#define QUALIFIED_NAME_IS_TEMPLATE(NODE) \
- (TREE_LANG_FLAG_0 (SCOPE_REF_CHECK (NODE)))
+ (TREE_LANG_FLAG_1 (SCOPE_REF_CHECK (NODE)))
/* True for an OMP_ATOMIC that has dependent parameters. These are stored
as an expr in operand 1, and integer_zero_node in operand 0. */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 947e19e..5743159 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11344,7 +11344,7 @@ tsubst_qualified_id (tree qualified_id, tree args,
expr = (adjust_result_of_qualified_name_lookup
(expr, scope, current_class_type));
expr = (finish_qualified_id_expr
- (scope, expr, done, address_p,
+ (scope, expr, done, address_p && PTRMEM_OK_P (qualified_id),
QUALIFIED_NAME_IS_TEMPLATE (qualified_id),
/*template_arg_p=*/false));
}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index a704aa3..e29705c 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1504,7 +1504,8 @@ finish_parenthesized_expr (tree expr)
/* This inhibits warnings in c_common_truthvalue_conversion. */
TREE_NO_WARNING (expr) = 1;
- if (TREE_CODE (expr) == OFFSET_REF)
+ if (TREE_CODE (expr) == OFFSET_REF
+ || TREE_CODE (expr) == SCOPE_REF)
/* [expr.unary.op]/3 The qualified id of a pointer-to-member must not be
enclosed in parentheses. */
PTRMEM_OK_P (expr) = 0;
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 678c7ef..dcd85e4 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1411,6 +1411,7 @@ build_qualified_name (tree type, tree scope, tree name, bool template_p)
return error_mark_node;
t = build2 (SCOPE_REF, type, scope, name);
QUALIFIED_NAME_IS_TEMPLATE (t) = template_p;
+ PTRMEM_OK_P (t) = true;
if (type)
t = convert_from_reference (t);
return t;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 903e0fb..a201db2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2011-07-01 Jason Merrill <jason@redhat.com>
+ PR c++/48593
+ * g++.dg/template/qualified-id4.C: New.
+
PR c++/48883
* g++.dg/template/explicit-args4.C: New.
diff --git a/gcc/testsuite/g++.dg/template/qualified-id4.C b/gcc/testsuite/g++.dg/template/qualified-id4.C
new file mode 100644
index 0000000..0d97cb8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/qualified-id4.C
@@ -0,0 +1,20 @@
+// PR c++/48593
+
+template <typename T> struct foo
+{
+ T data;
+};
+
+template<typename T> struct bar: public foo<T>
+{
+ void some_func()
+ {
+ T* ptr = &(foo<T>::data);
+ }
+};
+
+int main()
+{
+ bar<int>().some_func();
+}
+