From: Mark Mitchell Date: Tue, 2 Mar 2004 05:47:18 +0000 (+0000) Subject: re PR c++/14369 (errenous reject of well-formed code) X-Git-Tag: releases/gcc-4.0.0~9702 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b7be7b5977ab22f02fc2d1360249b7e08bd5c36;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 21b0172d2c41..e4f770280775 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-03-01 Mark Mitchell + + 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 PR c++/14369 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8f9a7bdc4c43..7dbbdc082d75 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 b2df61fec54e..42e02ae50e84 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-03-01 Mark Mitchell + + PR c++/14369 + * g++.dg/template/cond4.C: New test. + 2004-03-01 Mark Mitchell PR c++/14360 diff --git a/gcc/testsuite/g++.dg/template/cond4.C b/gcc/testsuite/g++.dg/template/cond4.C new file mode 100644 index 000000000000..35416ba798fd --- /dev/null +++ b/gcc/testsuite/g++.dg/template/cond4.C @@ -0,0 +1,20 @@ +// PR c++/14369 + +struct A { }; + +template +struct X : A { + const A* bar() const + { return this; } + + const A& foo() const; +}; + +template +const A& X::foo() const +{ + const A* t = bar(); + return *(t ? t : throw 0); +} + +