DR 176 permissiveness
DR 176 permissiveness 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. From-SVN: r154354
This commit is contained in:
parent
2fc9ae768b
commit
98fba7f7af
11 changed files with 63 additions and 4 deletions
|
@ -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>
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
16
gcc/cp/pt.c
16
gcc/cp/pt.c
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
15
gcc/testsuite/g++.dg/ext/injected-ttp.C
Normal file
15
gcc/testsuite/g++.dg/ext/injected-ttp.C
Normal file
|
@ -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" }
|
||||
};
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue