Patchwork C++ PATCHes for c++/45923 (constexpr diagnostics)

login
register
mail settings
Submitter Jason Merrill
Date June 29, 2011, 2:34 p.m.
Message ID <4E0B37E1.3050108@redhat.com>
Download mbox | patch
Permalink /patch/102612/
State New
Headers show

Comments

Jason Merrill - June 29, 2011, 2:34 p.m.
In C++0x when an expression fails to satisfy the requirements of a 
constant expression it can be hard to figure out why; previously the 
compiler would just say that a particular class or function was not 
literal or constexpr without explaining why.  This patch improves 
diagnostics by having the compiler recursively explain why classes are 
not literal or functions not constexpr.

The second patch updates the rules for what classes can be literal, 
adding aggregates.  I've left in trivial default constructors for now 
even though it was dropped from the FDIS.

The third patch is necessary to avoid some testsuite failures from 
complaints about non-literal temporaries if we do eventually drop 
trivial default constructors.

The last patch tweaks the similar function maybe_explain_implicit_delete 
to use a pointer set instead of a hash table, since we were only using 
it as a set anyway.

Tested x86_64-pc-linux-gnu, applying to trunk.

Patch

commit f232088231360150e73f7506cb37a696447d23e8
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jun 27 16:30:02 2011 -0400

    	* method.c (maybe_explain_implicit_delete): Use pointer_set
    	instead of htab.

diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index de43a38..ec1c502 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1320,21 +1320,17 @@  maybe_explain_implicit_delete (tree decl)
   if (DECL_DEFAULTED_FN (decl))
     {
       /* Not marked GTY; it doesn't need to be GC'd or written to PCH.  */
-      static htab_t explained_htab;
-      void **slot;
+      static struct pointer_set_t *explained;
 
       special_function_kind sfk;
       location_t loc;
       bool informed;
       tree ctype;
 
-      if (!explained_htab)
-	explained_htab = htab_create (37, htab_hash_pointer,
-				      htab_eq_pointer, NULL);
-      slot = htab_find_slot (explained_htab, decl, INSERT);
-      if (*slot)
+      if (!explained)
+	explained = pointer_set_create ();
+      if (pointer_set_insert (explained, decl))
 	return true;
-      *slot = decl;
 
       sfk = special_function_p (decl);
       ctype = DECL_CONTEXT (decl);