]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/14369 (errenous reject of well-formed code)
authorMark Mitchell <mark@codesourcery.com>
Tue, 2 Mar 2004 05:47:18 +0000 (05:47 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 2 Mar 2004 05:47:18 +0000 (05:47 +0000)
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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/cond4.C [new file with mode: 0644]

index 21b0172d2c4158fb1891e51cf74f92a2cce732fa..e4f770280775ccbd593c6d1abd15b5a2847d0f64 100644 (file)
@@ -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
index 8f9a7bdc4c431af25ccd272e953052bcb36d216f..7dbbdc082d75d9ccfdde6fba4497c6b0293eb987 100644 (file)
@@ -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,
index b2df61fec54e7238ad36986f392da7544f75a6e0..42e02ae50e8417ad5b8fbbd436313f506e6a1865 100644 (file)
@@ -1,3 +1,8 @@
+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
diff --git a/gcc/testsuite/g++.dg/template/cond4.C b/gcc/testsuite/g++.dg/template/cond4.C
new file mode 100644 (file)
index 0000000..35416ba
--- /dev/null
@@ -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);
+}
+
+
This page took 0.152914 seconds and 5 git commands to generate.