diff mbox

[c++-concepts] constraint association

Message ID CANq5SyvuxARzW6xn3gfGt_OUPLMt68PpqGzYgBjiC6wJCG+9zA@mail.gmail.com
State New
Headers show

Commit Message

Andrew Sutton June 28, 2014, 2:57 p.m. UTC
After merging from trunk this morning, I discovered that
DECL_SIZE_UNIT is now being used to store lists of specializations. I
had been using that to store template constraints. Oops.

This patch moves constraints outside the usual tree structures into an
association maintained in a hash table. It also lays the framework for
allowing constraints to be associated with any _*DECL node (templates,
functions, variables, types, etc).

Changelog below; committed as 212103.

2014-06-28  Andrew Sutton  <andrew.n.sutton@gmail.com>
        * gcc/cp/cp-tree.h (DECL_CONSTRAINTS): Remove this macro; use
        get_constraints instead.
        (set_constraints): new.
        * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Use
        get_constraints.
        * gcc/cp/pt.c (get_specialization_constraints): Use get_constraints.
        (build_template_decl): Use get_constraints.
        (process_partial_specialization): Use get_constraints.
        (add_inherited_template_parms): Use get_constraints.
        (redeclare_class_template): Use get_constraints.
        (is_compatible_template_arg): Use get_constraints.
        (tsubst_friend_class): Use get_constraints.
        (tsubst_decl): Uset get_constraints.
        * gcc/cp/semantics.c (finish_template_template_parm): Use
        get_constraints.
        (fixup_template_type): Use get_constraints.
        * gcc/cp/constraint.cc (constraints): New global association
        of declarations to constraints.
        (get_constraints): Return the associated constraints from the
        hash table.
        (set_constraints): New. Associate constraints with a declaration.
        (check_template_constraints): Use get_constraints.
        (equivalently_constrained): Use get_constraints.
        (more_constrained): Use get_constraints.
        (diagnose_constraints): Use get_constraints.
        * gcc/testsuite/g++.dg/concepts/partial-spec.C: New.

Andrew
diff mbox

Patch

Index: gcc/testsuite/g++.dg/concepts/partial-spec.C
===================================================================
--- gcc/testsuite/g++.dg/concepts/partial-spec.C	(revision 0)
+++ gcc/testsuite/g++.dg/concepts/partial-spec.C	(revision 0)
@@ -0,0 +1,15 @@ 
+// { dg-options "-std=c++1z" }
+
+// Check that constraints don't break unconstrained partial
+// specializations. 
+
+template<typename T>
+  struct S { };
+
+template<typename T>
+  struct S<T*> { };
+
+template<>
+  struct S<int> { };
+
+int main() { }