diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-15 19:49:33 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-15 19:49:33 +0000 |
commit | 8215802edb074187f98ef45a4d1b5eefa58286b4 (patch) | |
tree | 926a7708203d24fbbb6e3f7f99596c230ab2c51e /gcc/cp/semantics.c | |
parent | 964ec9cd8bd2896d0fd242db33bc7eeba8e4e62f (diff) | |
download | gcc-8215802edb074187f98ef45a4d1b5eefa58286b4.tar.gz |
/cp
2011-10-15 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50732
* semantics.c (finish_trait_expr): Do not try to instantiate the
the base type of an __is_base_of trait.
(check_trait_type): Return a tree; use complete_type_or_else.
/testsuite
2011-10-15 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50732
* g++.dg/ext/is_base_of_incomplete.C: New.
* g++.dg/ext/is_base_of_diagnostic.C: Adjust dg-errors.
* g++.dg/ext/unary_trait_incomplete.C: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180048 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7d37fa3e2c1..1efe57907b0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5210,23 +5210,20 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) } } -/* Returns true if TYPE is a complete type, an array of unknown bound, - or (possibly cv-qualified) void, returns false otherwise. */ +/* If TYPE is an array of unknown bound, or (possibly cv-qualified) + void, or a complete type, returns it, otherwise NULL_TREE. */ -static bool +static tree check_trait_type (tree type) { - if (COMPLETE_TYPE_P (type)) - return true; - if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type) && COMPLETE_TYPE_P (TREE_TYPE (type))) - return true; + return type; if (VOID_TYPE_P (type)) - return true; + return type; - return false; + return complete_type_or_else (strip_array_types (type), NULL_TREE); } /* Process a trait expression. */ @@ -5276,10 +5273,6 @@ finish_trait_expr (cp_trait_kind kind, tree type1, tree type2) return trait_expr; } - complete_type (type1); - if (type2) - complete_type (type2); - switch (kind) { case CPTK_HAS_NOTHROW_ASSIGN: @@ -5298,20 +5291,15 @@ finish_trait_expr (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_STD_LAYOUT: case CPTK_IS_TRIVIAL: if (!check_trait_type (type1)) - { - error ("incomplete type %qT not allowed", type1); - return error_mark_node; - } + return error_mark_node; break; case CPTK_IS_BASE_OF: if (NON_UNION_CLASS_TYPE_P (type1) && NON_UNION_CLASS_TYPE_P (type2) && !same_type_ignoring_top_level_qualifiers_p (type1, type2) - && !COMPLETE_TYPE_P (type2)) - { - error ("incomplete type %qT not allowed", type2); - return error_mark_node; - } + && !complete_type_or_else (type2, NULL_TREE)) + /* We already issued an error. */ + return error_mark_node; break; case CPTK_IS_CLASS: |