aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-01-11 11:37:15 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-01-11 11:37:15 +0000
commit98979fe0b06dbc0c776d5f040762aab17add4914 (patch)
tree7243d726adb1938bef7f3076e9b815f9ef78794e
parentb37bf5bdb3fb6f648e103c35df5a05165277956d (diff)
downloadgcc-98979fe0b06dbc0c776d5f040762aab17add4914.zip
gcc-98979fe0b06dbc0c776d5f040762aab17add4914.tar.gz
gcc-98979fe0b06dbc0c776d5f040762aab17add4914.tar.bz2
decl.c (grokparms): Unobfuscate and get correct diagnostic for parameters with pointers to arrays...
cp: * decl.c (grokparms): Unobfuscate and get correct diagnostic for parameters with pointers to arrays of unknown bound. From-SVN: r38901
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c21
2 files changed, 19 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 31d2d12..526424f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2001-01-11 Nathan Sidwell <nathan@codesourcery.com>
+ * decl.c (grokparms): Unobfuscate and get correct diagnostic for
+ parameters with pointers to arrays of unknown bound.
+
+2001-01-11 Nathan Sidwell <nathan@codesourcery.com>
+
* parse.y (template_parm_header, template_spec_header): New
reductions. Split out from ...
(template_header): ... here. Use them.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index dfe69ac..66a285c6 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11907,15 +11907,22 @@ grokparms (first_parm)
{
/* [dcl.fct]/6, parameter types cannot contain pointers
(references) to arrays of unknown bound. */
- tree t = type;
-
- while (POINTER_TYPE_P (t)
- || (TREE_CODE (t) == ARRAY_TYPE
- && TYPE_DOMAIN (t) != NULL_TREE))
- t = TREE_TYPE (t);
+ tree t = TREE_TYPE (type);
+ int ptr = TYPE_PTR_P (type);
+
+ while (1)
+ {
+ if (TYPE_PTR_P (t))
+ ptr = 1;
+ else if (TREE_CODE (t) != ARRAY_TYPE)
+ break;
+ else if (!TYPE_DOMAIN (t))
+ break;
+ t = TREE_TYPE (t);
+ }
if (TREE_CODE (t) == ARRAY_TYPE)
cp_error ("parameter `%D' includes %s to array of unknown bound `%T'",
- decl, TYPE_PTR_P (type) ? "pointer" : "reference", t);
+ decl, ptr ? "pointer" : "reference", t);
}
DECL_ARG_TYPE (decl) = TREE_TYPE (decl);