]> granicus.if.org Git - clang/commitdiff
Don't crash when codegen'ing an empty redecl of a function in C99 mode, when
authorNick Lewycky <nicholas@mxc.ca>
Mon, 18 Jul 2011 07:11:55 +0000 (07:11 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Mon, 18 Jul 2011 07:11:55 +0000 (07:11 +0000)
neither was inline. Fixes bug introduced in r135377.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135380 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Decl.cpp
test/CodeGen/inline.c

index d0c285186b05628794faa919cf4de4823f6314aa..b7884e04cb70bb126555a5156fdabdf99e40dfac 100644 (file)
@@ -1782,9 +1782,10 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
     return false;
   if (getLinkage() != ExternalLinkage || isInlineSpecified())
     return false;
-  const FunctionDecl *InlineDefinition = 0;
-  if (hasBody(InlineDefinition))
-    return InlineDefinition->isInlineDefinitionExternallyVisible();
+  const FunctionDecl *Definition = 0;
+  if (hasBody(Definition))
+    return Definition->isInlined() &&
+           Definition->isInlineDefinitionExternallyVisible();
   return false;
 }
 
index cbc428cc22ab9137db45a0f465fe16295e4aa164..2f6bd72dab544d8c76168531582d53a76fc3c363 100644 (file)
@@ -91,3 +91,9 @@ void test_test5() { test5(); }
 
 __inline int test6() { return 0; }
 extern int test6();
+
+
+// No PR#, but this once crashed clang in C99 mode due to buggy extern inline
+// redeclaration detection.
+void test7() { }
+void test7();