diff mbox

Various small C++ PATCHes

Message ID 4CC84AC9.2090107@redhat.com
State New
Headers show

Commit Message

Jason Merrill Oct. 27, 2010, 3:52 p.m. UTC
And a couple more:

1) 8.5.4 says that the type of a temporary created to bind to a 
reference has the underlying type of the reference, not the type of the 
initializer expression (which can be a different cv-variant).

2) The pretty-printing code should emit constexpr.

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

Patch

commit b4e4b080e2c6bfdb766de455b8b0db160b44ab54
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Oct 26 18:30:55 2010 -0400

    	* error.c (dump_simple_decl): Print constexpr.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 588cbe8..9ad2b93 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -867,6 +867,9 @@  dump_simple_decl (tree t, tree type, int flags)
 {
   if (flags & TFF_DECL_SPECIFIERS)
     {
+      if (TREE_CODE (t) == VAR_DECL
+	  && DECL_DECLARED_CONSTEXPR_P (t))
+	pp_cxx_ws_string (cxx_pp, "constexpr");
       dump_type_prefix (type, flags & ~TFF_UNQUALIFIED_NAME);
       pp_maybe_space (cxx_pp);
     }
@@ -1306,12 +1309,16 @@  dump_function_decl (tree t, int flags)
   else if (TREE_CODE (fntype) == METHOD_TYPE)
     cname = TREE_TYPE (TREE_VALUE (parmtypes));
 
-  if (!(flags & TFF_DECL_SPECIFIERS))
-    /* OK */;
-  else if (DECL_STATIC_FUNCTION_P (t))
-    pp_cxx_ws_string (cxx_pp, "static");
-  else if (DECL_VIRTUAL_P (t))
-    pp_cxx_ws_string (cxx_pp, "virtual");
+  if (flags & TFF_DECL_SPECIFIERS)
+    {
+      if (DECL_STATIC_FUNCTION_P (t))
+	pp_cxx_ws_string (cxx_pp, "static");
+      else if (DECL_VIRTUAL_P (t))
+	pp_cxx_ws_string (cxx_pp, "virtual");
+
+      if (DECL_DECLARED_CONSTEXPR_P (STRIP_TEMPLATE (t)))
+	pp_cxx_ws_string (cxx_pp, "constexpr");
+    }
 
   /* Print the return type?  */
   if (show_return)