aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-03-02 05:47:18 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-03-02 05:47:18 +0000
commit9b7be7b5977ab22f02fc2d1360249b7e08bd5c36 (patch)
treed6ff29c0acb044467d8da305f300ded7914a30e3 /gcc
parentfdf89bf57ced4684503675d29089cbd893fcf85c (diff)
downloadgcc-9b7be7b5977ab22f02fc2d1360249b7e08bd5c36.zip
gcc-9b7be7b5977ab22f02fc2d1360249b7e08bd5c36.tar.gz
gcc-9b7be7b5977ab22f02fc2d1360249b7e08bd5c36.tar.bz2
re PR c++/14369 (errenous reject of well-formed code)
PR c++/14369 * pt.c (build_non_dependent_expr): Do not create a NON_DEPENDENT_EXPR for a THROW_EXPR. PR c++/14369 * g++.dg/template/cond4.C: New test. From-SVN: r78746
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/cond4.C20
4 files changed, 38 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 21b0172..e4f7702 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-01 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/14369
+ * pt.c (build_non_dependent_expr): Do not create a
+ NON_DEPENDENT_EXPR for a THROW_EXPR.
+
2004-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR c++/14369
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8f9a7bd..7dbbdc0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12113,6 +12113,13 @@ build_non_dependent_expr (tree expr)
reason to create a new node. */
if (TREE_CODE (expr) == INTEGER_CST || TREE_CODE (expr) == REAL_CST)
return expr;
+ /* Preserve THROW_EXPRs -- all throw-expressions have type "void".
+ There is at least one place where we want to know that a
+ particular expression is a throw-expression: when checking a ?:
+ expression, there are special rules if the second or third
+ argument is a throw-expresion. */
+ if (TREE_CODE (expr) == THROW_EXPR)
+ return expr;
if (TREE_CODE (expr) == COND_EXPR)
return build (COND_EXPR,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b2df61f..42e02ae 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2004-03-01 Mark Mitchell <mark@codesourcery.com>
+ PR c++/14369
+ * g++.dg/template/cond4.C: New test.
+
+2004-03-01 Mark Mitchell <mark@codesourcery.com>
+
PR c++/14360
* g++.old-deja/g++.ns/koenig5.C: Remove some error markers.
diff --git a/gcc/testsuite/g++.dg/template/cond4.C b/gcc/testsuite/g++.dg/template/cond4.C
new file mode 100644
index 0000000..35416ba
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/cond4.C
@@ -0,0 +1,20 @@
+// PR c++/14369
+
+struct A { };
+
+template<class T>
+struct X : A {
+ const A* bar() const
+ { return this; }
+
+ const A& foo() const;
+};
+
+template<class T>
+const A& X<T>::foo() const
+{
+ const A* t = bar();
+ return *(t ? t : throw 0);
+}
+
+