diff options
author | pinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-05 01:41:36 +0000 |
---|---|---|
committer | pinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-01-05 01:41:36 +0000 |
commit | 67be63e60f12049d0b2105a14a94be485b7bfdb4 (patch) | |
tree | d86e96d66b105812b84c3711957b1431c1222576 /gcc/c-decl.c | |
parent | 7136e4be023379c81e73d8b55e7f613769f05ec8 (diff) | |
download | gcc-67be63e60f12049d0b2105a14a94be485b7bfdb4.tar.gz |
2005-01-04 Andrew Pinski <pinskia@physics.uc.edu>
PR c/19152
* c-decl.c (diagnose_mismatched_decls): Accept "extern inline" declared
after the full declaration if the are in two different TUs.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92918 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 047ef5905cb..6673927eab6 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1116,6 +1116,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, tree newtype, oldtype; bool pedwarned = false; bool warned = false; + bool retval = true; /* If we have error_mark_node for either decl or type, just discard the previous decl - we're in an error cascade already. */ @@ -1266,17 +1267,47 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, if (DECL_INITIAL (newdecl)) { - if (DECL_INITIAL (olddecl) - && !(DECL_DECLARED_INLINE_P (olddecl) - && DECL_EXTERNAL (olddecl) - && !(DECL_DECLARED_INLINE_P (newdecl) - && DECL_EXTERNAL (newdecl) - && same_translation_unit_p (olddecl, newdecl)))) + if (DECL_INITIAL (olddecl)) { - error ("%Jredefinition of %qD", newdecl, newdecl); - locate_old_decl (olddecl, error); - return false; - } + /* If both decls have extern inline and are in the same TU, + reject the new decl. */ + if (DECL_DECLARED_INLINE_P (olddecl) + && DECL_EXTERNAL (olddecl) + && DECL_DECLARED_INLINE_P (newdecl) + && DECL_EXTERNAL (newdecl) + && same_translation_unit_p (newdecl, olddecl)) + { + error ("%Jredefinition of %qD", newdecl, newdecl); + locate_old_decl (olddecl, error); + return false; + } + /* If both decls have not extern inline, reject the new decl. */ + if (!DECL_DECLARED_INLINE_P (olddecl) + && !DECL_EXTERNAL (olddecl) + && !DECL_DECLARED_INLINE_P (newdecl) + && !DECL_EXTERNAL (newdecl)) + { + error ("%Jredefinition of %qD", newdecl, newdecl); + locate_old_decl (olddecl, error); + return false; + } + /* If the new decl is declared as extern inline, error if they are + in the same TU, otherwise retain the old decl. */ + if (!DECL_DECLARED_INLINE_P (olddecl) + && !DECL_EXTERNAL (olddecl) + && DECL_DECLARED_INLINE_P (newdecl) + && DECL_EXTERNAL (newdecl)) + { + if (same_translation_unit_p (newdecl, olddecl)) + { + error ("%Jredefinition of %qD", newdecl, newdecl); + locate_old_decl (olddecl, error); + return false; + } + else + retval = false; + } + } } /* If we have a prototype after an old-style function definition, the argument types must be checked specially. */ @@ -1518,7 +1549,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, if (warned || pedwarned) locate_old_decl (olddecl, pedwarned ? pedwarn : warning); - return true; + return retval; } /* Subroutine of duplicate_decls. NEWDECL has been found to be |