OSDN Git Service

DR 176 permissiveness
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Nov 2009 03:12:07 +0000 (03:12 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Nov 2009 03:12:07 +0000 (03:12 +0000)
gcc/
* dwarf2out.c (get_context_die): Take TYPE_MAIN_VARIANT.
gcc/cp/
* class.c (build_self_reference): Call set_underlying_type.
* decl.c (check_elaborated_type_specifier): Don't complain about
injected-class-name.
(type_is_deprecated): Use TYPE_MAIN_VARIANT.
* pt.c (convert_template_argument): Handle injected-class-name used
as template template argument.
* typeck2.c (abstract_virtuals_error): Use TYPE_MAIN_VARIANT.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154354 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/decl.c
gcc/cp/pt.c
gcc/cp/typeck2.c
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/injected-ttp.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.pt/niklas01a.C
gcc/testsuite/g++.old-deja/g++.pt/ttp41.C

index 8f64624..b6cf53a 100644 (file)
@@ -1,3 +1,7 @@
+2009-11-19  Jason Merrill  <jason@redhat.com>
+
+       * dwarf2out.c (get_context_die): Take TYPE_MAIN_VARIANT.
+
 2009-11-19  Basile Starynkevitch  <basile@starynkevitch.net>
             Rafael Avila de Espindola  <espindola@google.com>
 
index 6a30b67..c25d360 100644 (file)
@@ -1,5 +1,14 @@
 2009-11-19  Jason Merrill  <jason@redhat.com>
 
+       DR 176 permissiveness
+       * class.c (build_self_reference): Call set_underlying_type.
+       * decl.c (check_elaborated_type_specifier): Don't complain about
+       injected-class-name.
+       (type_is_deprecated): Use TYPE_MAIN_VARIANT.
+       * pt.c (convert_template_argument): Handle injected-class-name used
+       as template template argument.
+       * typeck2.c (abstract_virtuals_error): Use TYPE_MAIN_VARIANT.
+
        PR c++/561
        * decl.c (static_fn_type): Split out...
        (revert_static_member_fn): ...from here.
index 3cf15fb..38eb73f 100644 (file)
@@ -6513,6 +6513,7 @@ build_self_reference (void)
   DECL_CONTEXT (value) = current_class_type;
   DECL_ARTIFICIAL (value) = 1;
   SET_DECL_SELF_REFERENCE_P (value);
+  set_underlying_type (value);
 
   if (processing_template_decl)
     value = push_template_decl (value);
index 29e32c8..7f5a688 100644 (file)
@@ -9787,6 +9787,10 @@ type_is_deprecated (tree type)
       && TREE_DEPRECATED (TYPE_NAME (type)))
     return type;
 
+  /* Do warn about using typedefs to a deprecated class.  */
+  if (TAGGED_TYPE_P (type) && type != TYPE_MAIN_VARIANT (type))
+    return type_is_deprecated (TYPE_MAIN_VARIANT (type));
+
   code = TREE_CODE (type);
 
   if (code == POINTER_TYPE || code == REFERENCE_TYPE
@@ -10608,6 +10612,7 @@ check_elaborated_type_specifier (enum tag_types tag_code,
      elaborated type specifier is the implicit typedef created when
      the type is declared.  */
   else if (!DECL_IMPLICIT_TYPEDEF_P (decl)
+          && !DECL_SELF_REFERENCE_P (decl)
           && tag_code != typename_type)
     {
       error ("using typedef-name %qD after %qs", decl, tag_name (tag_code));
index 9c82e3c..c3b0f0e 100644 (file)
@@ -5370,6 +5370,22 @@ convert_template_argument (tree parm,
   if (TREE_CODE (arg) == TYPE_PACK_EXPANSION)
     arg = PACK_EXPANSION_PATTERN (arg);
 
+  /* Deal with an injected-class-name used as a template template arg.  */
+  if (requires_tmpl_type && CLASS_TYPE_P (arg))
+    {
+      tree t = maybe_get_template_decl_from_type_decl (TYPE_NAME (arg));
+      if (TREE_CODE (t) == TEMPLATE_DECL)
+       {
+         if (complain & tf_warning_or_error)
+           pedwarn (input_location, OPT_pedantic, "injected-class-name %qD"
+                    " used as template template argument", TYPE_NAME (arg));
+         else if (flag_pedantic_errors)
+           t = arg;
+
+         arg = t;
+       }
+    }
+
   is_tmpl_type = 
     ((TREE_CODE (arg) == TEMPLATE_DECL
       && TREE_CODE (DECL_TEMPLATE_RESULT (arg)) == TYPE_DECL)
index 6cb1152..a296caa 100644 (file)
@@ -236,6 +236,7 @@ abstract_virtuals_error (tree decl, tree type)
      be abstract.  */
   if (!CLASS_TYPE_P (type))
     return 0;
+  type = TYPE_MAIN_VARIANT (type);
 
   /* If the type is incomplete, we register it within a hash table,
      so that we can check again once it is completed. This makes sense
index 3db2092..0394114 100644 (file)
@@ -19089,7 +19089,7 @@ get_context_die (tree context)
     {
       /* Find die that represents this context.  */
       if (TYPE_P (context))
-       return force_type_die (context);
+       return force_type_die (TYPE_MAIN_VARIANT (context));
       else
        return force_decl_die (context);
     }
index 0a42693..5a56a9c 100644 (file)
@@ -1,3 +1,10 @@
+2009-11-19  Jason Merrill  <jason@redhat.com>
+
+       DR 176 permissiveness
+       * g++.dg/ext/injected-ttp.C: New.
+       * g++.old-deja/g++.pt/niklas01a.C: Adjust.
+       * g++.old-deja/g++.pt/ttp41.C: Adjust.
+
 2009-11-19  Andy Hutchinson  <hutchinsonandy@gcc.gnu.org>
 
        * gcc.c-torture/compile/pr40204.c: Test only for int32 target.
diff --git a/gcc/testsuite/g++.dg/ext/injected-ttp.C b/gcc/testsuite/g++.dg/ext/injected-ttp.C
new file mode 100644 (file)
index 0000000..405bee8
--- /dev/null
@@ -0,0 +1,15 @@
+// Test for doing the right thing with injected-class-name used as template
+// type argument.  This is an extension from DR 176.
+
+// { dg-options "-pedantic" }
+
+template <class T>
+struct A { };
+
+template <template <class> class TTP>
+struct B { };
+
+struct C: A<int>
+{
+  B<A> b;                      // { dg-warning "injected-class-name" }
+};
index 7fe07a2..eec11ab 100644 (file)
@@ -2,7 +2,7 @@
 // { dg-options "-fshow-column" }
 
 struct A { // { dg-error "" } forward declaration
-  friend struct B : A {                // { dg-error "invalid use of incomplete type 'struct A'" }
+  friend struct B : A {                // { dg-error "invalid use of incomplete type 'struct A" }
     int x;
   };   // { dg-error "class definition may not be declared a friend" ""  { target *-*-* } { 5 } }
   int y;
index b260961..564294e 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do compile }
+// { dg-options "" }
 template<template<class> class D,class E> class C
 {
        public:
@@ -13,8 +14,8 @@ template<class T> class D
 
 template<class T> int D<T>::f()
 {
-       C<D,D> c;       // { dg-error "" }
-       return c.g();   // { dg-error "" }
+       C<D,D> c;
+       return c.g();
 }
 
 int main()