aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2001-12-26 20:33:37 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2001-12-26 20:33:37 +0000
commit7d8e83691e11570c5d570fd8bdd3f4f2f3f615fa (patch)
tree327a74509523451ad1fded75dc53f475e71f67d5 /gcc
parent8a723db2df8ea2a336691f2c3288a642bc8b0063 (diff)
downloadgcc-7d8e83691e11570c5d570fd8bdd3f4f2f3f615fa.zip
gcc-7d8e83691e11570c5d570fd8bdd3f4f2f3f615fa.tar.gz
gcc-7d8e83691e11570c5d570fd8bdd3f4f2f3f615fa.tar.bz2
re PR c++/196 (problem with: namespace N { class N {...}; })
cp: PR c++/196 * cp/parse.y (bad_parm): Better diagnostic when given a SCOPE_REF. testsuite: * g++.dg/eh/ctor1.C: New test. * g++.dg/other/error2.C: New test. From-SVN: r48317
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/parse.y15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/eh/ctor1.C42
-rw-r--r--gcc/testsuite/g++.dg/other/error2.C14
5 files changed, 76 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 529a362..fc7a609 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2001-12-26 Nathan Sidwell <nathan@codesourcery.com>
+
+ PR c++/196
+ * cp/parse.y (bad_parm): Better diagnostic when given a SCOPE_REF.
+
2001-12-24 Nathan Sidwell <nathan@codesourcery.com>
PR c++/160
diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y
index ccc3ede..7339fe3 100644
--- a/gcc/cp/parse.y
+++ b/gcc/cp/parse.y
@@ -3766,11 +3766,16 @@ bad_parm:
}
| notype_declarator
{
- error ("type specifier omitted for parameter");
- if (TREE_CODE ($$) == SCOPE_REF
- && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
- || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM))
- error (" perhaps you want `typename %E' to make it a type", $$);
+ if (TREE_CODE ($$) == SCOPE_REF)
+ {
+ if (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
+ || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM)
+ error ("`%E' is not a type, use `typename %E' to make it one", $$);
+ else
+ error ("no type `%D' in `%T'", TREE_OPERAND ($$, 1), TREE_OPERAND ($$, 0));
+ }
+ else
+ error ("type specifier omitted for parameter `%E'", $$);
$$ = build_tree_list (integer_type_node, $$);
}
;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a022e89..698296b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2001-12-26 Nathan Sidwell <nathan@codesourcery.com>
+
+ * g++.dg/eh/ctor1.C: New test.
+ * g++.dg/other/error2.C: New test.
+
2001-12-24 Nathan Sidwell <nathan@codesourcery.com>
* g++.dg/other/init2.C: New test.
diff --git a/gcc/testsuite/g++.dg/eh/ctor1.C b/gcc/testsuite/g++.dg/eh/ctor1.C
new file mode 100644
index 0000000..43b735f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/ctor1.C
@@ -0,0 +1,42 @@
+// { dg-do run }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com>
+
+// PR 411
+
+bool was_f_in_Bar_destroyed=false;
+
+struct Foo
+{
+ ~Foo()
+ {
+ was_f_in_Bar_destroyed=true;
+ }
+};
+
+struct Bar
+{
+ ~Bar()
+ {
+ throw 1;
+ }
+
+ Foo f;
+};
+
+int main()
+{
+ try
+ {
+ Bar f;
+ }
+ catch(int i)
+ {
+ if(was_f_in_Bar_destroyed)
+ {
+ return 0;
+ }
+ }
+ return 1;
+}
diff --git a/gcc/testsuite/g++.dg/other/error2.C b/gcc/testsuite/g++.dg/other/error2.C
new file mode 100644
index 0000000..9910ada
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/error2.C
@@ -0,0 +1,14 @@
+// { dg-do compile }
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@nathan@codesourcery.com>
+
+// PR 196. Misleading diagnostic
+
+namespace N
+{
+ class B { friend void operator>>(int, class B); };
+ class N { friend void operator>>(int,class N); };
+}
+void N::operator>>(int, N::B) // { dg-error "no type `B' in `N::N'" "" }
+{ } // { dg-error "" "" }