diff options
author | Ian Lance Taylor <iant@google.com> | 2009-05-16 06:54:11 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2009-05-16 06:54:11 +0000 |
commit | 7e5487a214d591ab394310fa2f8840c42b745ee7 (patch) | |
tree | 76d192436d10f2e90d4474a52e7b7f2156c2a5e7 /gcc/c-decl.c | |
parent | 7d47ae1d6491907d3f6c5c870bb83dceac1551c4 (diff) | |
download | gcc-7e5487a214d591ab394310fa2f8840c42b745ee7.zip gcc-7e5487a214d591ab394310fa2f8840c42b745ee7.tar.gz gcc-7e5487a214d591ab394310fa2f8840c42b745ee7.tar.bz2 |
alias.c (struct alias_set_entry_d): Rename from struct alias_set_entry.
gcc/ChangeLog:
* alias.c (struct alias_set_entry_d): Rename from struct
alias_set_entry. Change all uses.
* except.c (struct call_site_record_d): Rename from struct
call_site_record. Change all uses.
* except.h (struct eh_region_d): Rename from struct eh_region.
Change all uses.
* gcse.c (struct hash_table_d): Rename from struct hash_table.
Change all uses.
* graphite.c (struct ivtype_map_elt_d): Rename fromstruct
ivtype_map_elt. Change all uses.
(struct rename_map_elt_d): Rename fromstruct rename_map_elt.
Change all uses.
(struct ifsese_d): Rename fromstruct ifsese. Change all uses.
* graphite.h (struct name_tree_d): Rename from struct name_tree.
Change all uses.
(struct sese_d): Rename from struct sese. Change all uses.
* omega.h (struct eqn_d): Rename from struct eqn. Change all
uses.
(struct omega_pb_d): Rename from struct omega_pb. Change all
uses.
* optabs.h (struct optab_d): Rename from struct optab. Change all
uses.
(struct convert_optab_d): Rename from struct convert_optab.
Change all uses.
* tree-pass.h (struct ipa_opt_pass_d): Rename fromstruct
ipa_opt_pass. Change all uses.
* tree-predcom.c (struct dref_d): Rename from struct dref. Change
all uses.
* c-decl.c (pushtag): If -Wc++-compat, warn if the tag is already
defined as a typedef.
(grokdeclarator): If -Wc++-compat, warn if a typedef is already
defined as a tag.
gcc/cp/ChangeLog:
* cp-tree.h (enum cp_lvalue_kind_flags): Rename from
cp_lvalue_kind. Change all uses.
(enum base_access_flags): Rename from enum base_access. Change
all uses.
* parser.c (enum cp_parser_flags): Remove enum tag.
gcc/testsuite/ChangeLog:
* gcc.dg/Wcxx-compat-10.c: New testcase.
libcpp/ChangeLog:
* include/cpplib.h (enum cpp_builtin_type): Rename from enum
builtin_type. Change all uses.
From-SVN: r147605
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index a9929c1..0c05b24 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1114,6 +1114,27 @@ pushtag (tree name, tree type, location_t loc) /* An approximation for now, so we can tell this is a function-scope tag. This will be updated in pop_scope. */ TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type)); + + if (warn_cxx_compat && name != NULL_TREE) + { + struct c_binding *b = I_SYMBOL_BINDING (name); + + if (b != NULL + && b->decl != NULL_TREE + && TREE_CODE (b->decl) == TYPE_DECL + && (B_IN_CURRENT_SCOPE (b) + || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) + && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl)) + != TYPE_MAIN_VARIANT (type))) + { + warning_at (loc, OPT_Wc___compat, + ("using %qD as both a typedef and a tag is " + "invalid in C++"), + b->decl); + if (b->locus != UNKNOWN_LOCATION) + inform (b->locus, "originally defined here"); + } + } } /* Subroutine of compare_decls. Allow harmless mismatches in return @@ -4961,6 +4982,26 @@ grokdeclarator (const struct c_declarator *declarator, C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1; if (declspecs->inline_p) pedwarn (input_location, 0,"typedef %q+D declared %<inline%>", decl); + + if (warn_cxx_compat && declarator->u.id != NULL_TREE) + { + struct c_binding *b = I_TAG_BINDING (declarator->u.id); + + if (b != NULL + && b->decl != NULL_TREE + && (B_IN_CURRENT_SCOPE (b) + || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) + && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type)) + { + warning_at (declarator->id_loc, OPT_Wc___compat, + ("using %qD as both a typedef and a tag is " + "invalid in C++"), + decl); + if (b->locus != UNKNOWN_LOCATION) + inform (b->locus, "originally defined here"); + } + } + return decl; } |