aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>2004-06-01 15:51:56 +0000
committerJason Merrill <jason@gcc.gnu.org>2004-06-01 11:51:56 -0400
commit43daf8ffa83f013ccc2a7db8845375df73f5556b (patch)
tree2def6dd5f3df50ec9750e71c7af3a314f0c66c12 /gcc
parent7a3ea2011be31e937186df05335f665a8a983028 (diff)
downloadgcc-43daf8ffa83f013ccc2a7db8845375df73f5556b.zip
gcc-43daf8ffa83f013ccc2a7db8845375df73f5556b.tar.gz
gcc-43daf8ffa83f013ccc2a7db8845375df73f5556b.tar.bz2
re PR c++/13092 (Accepts invalid pointer-to-member conversion)
PR c++/13092 * init.c (build_offset_ref): Build SCOPE_REF with non-null TREE_TYPE for non-dependent names. * pt.c (type_dependent_expression_p): Handle SCOPE_REF with unknown_type_node as its TREE_TYPE. * cxx-pretty_print.c (pp_cxx_unqualified_id): Handle BASELINK. * error.c (dump_decl) <SCOPE_REF case>: Use pp_expression. (dump_expr) <SCOPE_REF case>: Likewise. From-SVN: r82551
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/call.c10
-rw-r--r--gcc/cp/cxx-pretty-print.c4
-rw-r--r--gcc/cp/error.c8
-rw-r--r--gcc/cp/init.c10
-rw-r--r--gcc/cp/pt.c36
6 files changed, 51 insertions, 28 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7229ffc..22277be 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,14 @@
+2004-06-01 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/13092
+ * init.c (build_offset_ref): Build SCOPE_REF with non-null
+ TREE_TYPE for non-dependent names.
+ * pt.c (type_dependent_expression_p): Handle SCOPE_REF with
+ unknown_type_node as its TREE_TYPE.
+ * cxx-pretty_print.c (pp_cxx_unqualified_id): Handle BASELINK.
+ * error.c (dump_decl) <SCOPE_REF case>: Use pp_expression.
+ (dump_expr) <SCOPE_REF case>: Likewise.
+
2004-06-01 Richard Henderson <rth@redhat.com>
Andrew Pinski <pinskia@physics.uc.edu>
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index ecace2d..185c037 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -4326,18 +4326,20 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
}
/* Build a call to __builtin_trap which can be used as an expression of
- type TYPE. */
+ type TYPE. This looks like *(__builtin_trap(), (TYPE*)NULL). */
static tree
call_builtin_trap (tree type)
{
tree fn = implicit_built_in_decls[BUILT_IN_TRAP];
+ tree t;
my_friendly_assert (fn != NULL, 20030927);
fn = build_call (fn, NULL_TREE);
- fn = build (COMPOUND_EXPR, type, fn, error_mark_node);
- fn = force_target_expr (type, fn);
- return fn;
+ t = convert (build_pointer_type (type), null_node);
+ t = build (COMPOUND_EXPR, TREE_TYPE (t), fn, t);
+ t = build_indirect_ref (t, NULL);
+ return t;
}
/* ARG is being passed to a varargs function. Perform any conversions
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index c5e667d..328ece0 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -180,6 +180,10 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
pp_cxx_template_id (pp, t);
break;
+ case BASELINK:
+ pp_cxx_unqualified_id (pp, BASELINK_FUNCTIONS (t));
+ break;
+
case RECORD_TYPE:
case UNION_TYPE:
case ENUMERAL_TYPE:
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 6e18650..faa2bfb 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -771,9 +771,7 @@ dump_decl (tree t, int flags)
break;
case SCOPE_REF:
- dump_decl (TREE_OPERAND (t, 0), flags & ~TFF_DECL_SPECIFIERS);
- pp_colon_colon (cxx_pp);
- dump_decl (TREE_OPERAND (t, 1), flags);
+ pp_expression (cxx_pp, t);
break;
case ARRAY_REF:
@@ -1699,9 +1697,7 @@ dump_expr (tree t, int flags)
break;
case SCOPE_REF:
- dump_type (TREE_OPERAND (t, 0), flags);
- pp_colon_colon (cxx_pp);
- dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
+ pp_expression (cxx_pp, t);
break;
case CAST_EXPR:
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 1c00356..5f0872e 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1368,7 +1368,7 @@ build_offset_ref (tree type, tree name, bool address_p)
if (TREE_CODE (name) == TEMPLATE_DECL)
return name;
- if (processing_template_decl || uses_template_parms (type))
+ if (dependent_type_p (type) || type_dependent_expression_p (name))
return build_min_nt (SCOPE_REF, type, name);
if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
@@ -1450,6 +1450,14 @@ build_offset_ref (tree type, tree name, bool address_p)
return error_mark_node;
}
+ if (processing_template_decl)
+ {
+ if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
+ return build_min (SCOPE_REF, TREE_TYPE (member), type, orig_name);
+ else
+ return build_min (SCOPE_REF, TREE_TYPE (member), type, name);
+ }
+
if (TREE_CODE (member) == TYPE_DECL)
{
TREE_USED (member) = 1;
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cbe4bd9..824e8bf 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11932,22 +11932,6 @@ type_dependent_expression_p (tree expression)
return dependent_type_p (type);
}
- if (TREE_CODE (expression) == SCOPE_REF
- && dependent_scope_ref_p (expression,
- type_dependent_expression_p))
- return true;
-
- if (TREE_CODE (expression) == FUNCTION_DECL
- && DECL_LANG_SPECIFIC (expression)
- && DECL_TEMPLATE_INFO (expression)
- && (any_dependent_template_arguments_p
- (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (expression)))))
- return true;
-
- if (TREE_CODE (expression) == TEMPLATE_DECL
- && !DECL_TEMPLATE_TEMPLATE_PARM_P (expression))
- return false;
-
if (TREE_TYPE (expression) == unknown_type_node)
{
if (TREE_CODE (expression) == ADDR_EXPR)
@@ -11961,7 +11945,9 @@ type_dependent_expression_p (tree expression)
if (TREE_CODE (expression) == IDENTIFIER_NODE)
return false;
}
-
+ if (TREE_CODE (expression) == SCOPE_REF)
+ return false;
+
if (TREE_CODE (expression) == BASELINK)
expression = BASELINK_FUNCTIONS (expression);
if (TREE_CODE (expression) == TEMPLATE_ID_EXPR)
@@ -11984,6 +11970,22 @@ type_dependent_expression_p (tree expression)
abort ();
}
+ if (TREE_CODE (expression) == SCOPE_REF
+ && dependent_scope_ref_p (expression,
+ type_dependent_expression_p))
+ return true;
+
+ if (TREE_CODE (expression) == FUNCTION_DECL
+ && DECL_LANG_SPECIFIC (expression)
+ && DECL_TEMPLATE_INFO (expression)
+ && (any_dependent_template_arguments_p
+ (INNERMOST_TEMPLATE_ARGS (DECL_TI_ARGS (expression)))))
+ return true;
+
+ if (TREE_CODE (expression) == TEMPLATE_DECL
+ && !DECL_TEMPLATE_TEMPLATE_PARM_P (expression))
+ return false;
+
return (dependent_type_p (TREE_TYPE (expression)));
}