From 7e5487a214d591ab394310fa2f8840c42b745ee7 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 16 May 2009 06:54:11 +0000 Subject: 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 --- gcc/c-decl.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'gcc/c-decl.c') 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 %", 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; } -- cgit v1.1