aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-10-12 18:07:43 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-10-12 18:07:43 +0000
commit3ce5fa4fa606357251b653f66fbef96fdfcbea2f (patch)
tree942011e89513616498985f2c0177369f00dd00a6 /gcc
parent51b15ede491940fcc66789e704474a67387ae705 (diff)
downloadgcc-3ce5fa4fa606357251b653f66fbef96fdfcbea2f.zip
gcc-3ce5fa4fa606357251b653f66fbef96fdfcbea2f.tar.gz
gcc-3ce5fa4fa606357251b653f66fbef96fdfcbea2f.tar.bz2
re PR c++/23797 (ICE on typename outside template)
cp: PR c++/23797 * parser.c (cp_parser_functional_cast): Cope when TYPE is not a TYPE_DECL. Use dependent_type_p to check type. * pt.c (uses_template_parms_p): Use dependent_type_p for a TYPE_DECL. (type_dependent_expression_p): Assert we've not been given a TYPE_DECL. testsuite: PR c++/23797 * g++.dg/other/typename8.C: New. From-SVN: r105312
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/parser.c7
-rw-r--r--gcc/cp/pt.c4
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/parse/typename8.C9
5 files changed, 29 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a94a3fb..d6dad42 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,13 @@
2005-10-12 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/23797
+ * parser.c (cp_parser_functional_cast): Cope when TYPE is not a
+ TYPE_DECL. Use dependent_type_p to check type.
+ * pt.c (uses_template_parms_p): Use dependent_type_p for a
+ TYPE_DECL.
+ (type_dependent_expression_p): Assert we've not been given a
+ TYPE_DECL.
+
PR c++/21117
* decl.c (check_function_type): Correctly overwrite incomplete
return type with void type.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 6d7d3c8..469cc73 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -3956,6 +3956,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p)
/* Consume the `typename' token. */
cp_lexer_consume_token (parser->lexer);
+
/* Look for the optional `::' operator. */
cp_parser_global_scope_opt (parser,
/*current_scope_valid_p=*/false);
@@ -15355,8 +15356,10 @@ cp_parser_functional_cast (cp_parser* parser, tree type)
cast = build_functional_cast (type, expression_list);
/* [expr.const]/1: In an integral constant expression "only type
conversions to integral or enumeration type can be used". */
- if (cast != error_mark_node && !type_dependent_expression_p (type)
- && !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (type)))
+ if (TREE_CODE (type) == TYPE_DECL)
+ type = TREE_TYPE (type);
+ if (cast != error_mark_node && !dependent_type_p (type)
+ && !INTEGRAL_OR_ENUMERATION_TYPE_P (type))
{
if (cp_parser_non_integral_constant_expression
(parser, "a call to a constructor"))
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a5a7c1e..020d819 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4982,6 +4982,8 @@ uses_template_parms (tree t)
else if (TREE_CODE (t) == TREE_LIST)
dependent_p = (uses_template_parms (TREE_VALUE (t))
|| uses_template_parms (TREE_CHAIN (t)));
+ else if (TREE_CODE (t) == TYPE_DECL)
+ dependent_p = dependent_type_p (TREE_TYPE (t));
else if (DECL_P (t)
|| EXPR_P (t)
|| TREE_CODE (t) == TEMPLATE_PARM_INDEX
@@ -12442,6 +12444,8 @@ type_dependent_expression_p (tree expression)
return false;
}
+ gcc_assert (TREE_CODE (expression) != TYPE_DECL);
+
return (dependent_type_p (TREE_TYPE (expression)));
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d5eac84..1f416b6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2005-10-12 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/23797
+ * g++.dg/other/typename8.C: New.
+
PR c++/21117
* g++.dg/other/return1.C: New.
diff --git a/gcc/testsuite/g++.dg/parse/typename8.C b/gcc/testsuite/g++.dg/parse/typename8.C
new file mode 100644
index 0000000..413e954
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/typename8.C
@@ -0,0 +1,9 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 12 Oct 2005 <nathan@codesourcery.com>
+
+// PR 23797:ICE
+// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
+
+struct A { typedef int X; };
+
+int i = typename A::X();