[PATCH,c++] fix bogus complaints about translation_unit_decl in error messages
Nathan Froyd
froydnj@codesourcery.com
Thu Dec 9 15:33:00 GMT 2010
When we're pretty-printing things in error messages, we now get confused
by the new TRANSLATION_UNIT_DECLs added this release cycle:
g++.old-deja/g++.other/overload11.C:86:13: error: no context to resolve type of '#'translation_unit_decl' not supported by dump_decl#<declaration error>::ovl'
g++.old-deja/g++.other/overload11.C:87:14: error: no context to resolve type of '&#'translation_unit_decl' not supported by dump_decl#<declaration error>::ovl'
g++.old-deja/g++.other/overload11.C:89:19: error: no context to resolve type of '#'translation_unit_decl' not supported by dump_decl#<declaration error>::ovl'
g++.old-deja/g++.other/overload11.C:90:20: error: no context to resolve type of '&#'translation_unit_decl' not supported by dump_decl#<declaration error>::ovl'
g++.dg/parse/friend5.C:6:19: error: 'void foo()' is already defined in class '#'translation_unit_decl' not supported by dump_type#<type error>'
g++.dg/lookup/java1.C:67:11: error: '#'translation_unit_decl' not supported by dump_decl#<declaration error>::_Jv_Throw' should never be overloaded
The patch below silences this checking DECL_FILE_SCOPE_P in appropriate
places. I suppose it'd be nice to have testsuite logic to assert that
we never complain about unsupported things in the tree dumpers...
Tested on x86_64-unknown-linux-gnu. OK to commit?
-Nathan
* decl.c (grokmethod): Check DECL_FILE_SCOPE_P.
* error.c (dump_decl) [OVERLOAD]: Check DECL_FILE_SCOPE_P.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b72b588..5735d4e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13098,7 +13098,7 @@ grokmethod (cp_decl_specifier_seq *declspecs,
if (DECL_IN_AGGR_P (fndecl))
{
- if (DECL_CONTEXT (fndecl)
+ if (!DECL_FILE_SCOPE_P (fndecl)
&& TREE_CODE (DECL_CONTEXT (fndecl)) != NAMESPACE_DECL)
error ("%qD is already defined in class %qT", fndecl,
DECL_CONTEXT (fndecl));
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 4fb47dc..f45f1c2 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1027,12 +1027,13 @@ dump_decl (tree t, int flags)
dump_type (DECL_CONTEXT (t), flags);
pp_cxx_colon_colon (cxx_pp);
}
- else if (DECL_CONTEXT (t))
+ else if (DECL_FILE_SCOPE_P (t))
+ dump_decl (DECL_NAME (t), flags);
+ else
{
dump_decl (DECL_CONTEXT (t), flags);
pp_cxx_colon_colon (cxx_pp);
}
- dump_decl (DECL_NAME (t), flags);
break;
}
More information about the Gcc-patches
mailing list