aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@gcc.gnu.org>2005-01-04 17:41:36 -0800
committerAndrew Pinski <pinskia@gcc.gnu.org>2005-01-04 17:41:36 -0800
commitf8f5c4b3aa71b9bcc430d514129294ccacf93626 (patch)
treed86e96d66b105812b84c3711957b1431c1222576 /gcc/c-decl.c
parent8d0cf6032ba0a5e01330379a98067b1f7a50dd2f (diff)
downloadgcc-f8f5c4b3aa71b9bcc430d514129294ccacf93626.zip
gcc-f8f5c4b3aa71b9bcc430d514129294ccacf93626.tar.gz
gcc-f8f5c4b3aa71b9bcc430d514129294ccacf93626.tar.bz2
re PR c/19152 (IMA and external inline don't get along)
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. From-SVN: r92918
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c53
1 files changed, 42 insertions, 11 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 047ef59..6673927 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