diff mbox

Various small C++ PATCHes

Message ID 4CC84898.1050601@redhat.com
State New
Headers show

Commit Message

Jason Merrill Oct. 27, 2010, 3:43 p.m. UTC
1) check_narrowing only makes sense on a scalar value; we shouldn't 
invoke it on an initializer-list nested within another one.

2) We have an optimization to discard an empty STATEMENT_LIST when 
merging it with an enclosing one, but that doesn't work when it's 
wrapped inside a BIND_EXPR.  If the list is empty and the BIND_EXPR 
isn't somehow special (i.e. representing a try block or the outermost 
braces of a function) we can discard the BIND_EXPR to allow the 
optimization.

3) build_cplus_new, given a CONSTRUCTOR argument, ought to wrap it in a 
TARGET_EXPR.  This isn't actually used by the constexpr code; it was 
used briefly for a while when I was trying to expand constexpr calls 
immediately when formed, but that turned out to be a dead end.  Still, 
this seems like the right behavior for build_cplus_new.

4) THROW_EXPR ought to have EXPR_LOCATION set, for use in diagnostics 
(such as the non-constant-expression diagnostic).

Tested x86_64-pc-linux-gnu, applied to trunk.
diff mbox

Patch

commit 0dab78fa5a4af873756f9896032114164c6a30cc
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Oct 26 18:31:04 2010 -0400

    	* except.c (build_throw): Set EXPR_LOCATION.

diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index b917664..cf8a210 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -648,7 +648,9 @@  build_throw (tree exp)
     {
       if (cfun)
 	current_function_returns_abnormally = 1;
-      return build_min (THROW_EXPR, void_type_node, exp);
+      exp = build_min (THROW_EXPR, void_type_node, exp);
+      SET_EXPR_LOCATION (exp, input_location);
+      return exp;
     }
 
   if (exp == null_node)
@@ -834,6 +836,7 @@  build_throw (tree exp)
     }
 
   exp = build1 (THROW_EXPR, void_type_node, exp);
+  SET_EXPR_LOCATION (exp, input_location);
 
   return exp;
 }