]> granicus.if.org Git - clang/commitdiff
Implement -fgnu89-inline. Fixes PR10041.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 2 Jun 2011 16:13:27 +0000 (16:13 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 2 Jun 2011 16:13:27 +0000 (16:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132460 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1Options.td
include/clang/Driver/Options.td
lib/AST/Decl.cpp
lib/Driver/Tools.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Sema/SemaDecl.cpp
test/CodeGen/extern-inline.c

index 62e4c3f98f998f9ed053b6897753722cc08d1f7b..155ecae5798a0bfc1ff3bb24f63803d6cef824de 100644 (file)
@@ -423,6 +423,8 @@ def fno_assume_sane_operator_new : Flag<"-fno-assume-sane-operator-new">,
   HelpText<"Don't assume that C++'s global operator new can't alias any pointer">;
 def fgnu_keywords : Flag<"-fgnu-keywords">,
   HelpText<"Allow GNU-extension keywords regardless of language standard">;
+def fgnu89_inline : Flag<"-fgnu89-inline">,
+  HelpText<"Use the gnu89 inline semantics">;
 def fno_gnu_keywords : Flag<"-fno-gnu-keywords">,
   HelpText<"Disallow GNU-extension keywords regardless of language standard">;
 def fdollars_in_identifiers : Flag<"-fdollars-in-identifiers">,
index 5260c71d6a6f2193468eb1d4362344971807aaf6..2cba46c65021c59fe0e7407c7898b0d69ae33f68 100644 (file)
@@ -299,6 +299,7 @@ def fno_for_scope : Flag<"-fno-for-scope">, Group<f_Group>;
 
 def ffreestanding : Flag<"-ffreestanding">, Group<f_Group>;
 def fgnu_keywords : Flag<"-fgnu-keywords">, Group<f_Group>;
+def fgnu89_inline : Flag<"-fgnu89-inline">, Group<f_Group>;
 def fgnu_runtime : Flag<"-fgnu-runtime">, Group<f_Group>;
 def fheinous_gnu_extensions : Flag<"-fheinous-gnu-extensions">;
 def filelist : Separate<"-filelist">, Flags<[LinkerInput]>;
index 81d976f4e83a00f315dcbac6d53eaafd7bc8af6a..1cad64e055bf857995294c1a8fbf54272691329d 100644 (file)
@@ -1743,7 +1743,7 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
   assert(isInlined() && "Function must be inline");
   ASTContext &Context = getASTContext();
   
-  if (!Context.getLangOptions().C99 || hasAttr<GNUInlineAttr>()) {
+  if (Context.getLangOptions().GNUInline || hasAttr<GNUInlineAttr>()) {
     // If it's not the case that both 'inline' and 'extern' are
     // specified on the definition, then this inline definition is
     // externally visible.
index eff5942599082457860bb42d9a76ecfd00db7c01..fbc5109207ceb97c3b38ea47722588a3f44f6d0d 100644 (file)
@@ -1712,6 +1712,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
                                options::OPT_fno_gnu_keywords))
     A->render(Args, CmdArgs);
 
+  if (Arg *A = Args.getLastArg(options::OPT_fgnu89_inline))
+    CmdArgs.push_back("-fgnu89-inline");
+
   // -fnext-runtime defaults to on Darwin and when rewriting Objective-C, and is
   // -the -cc1 default.
   bool NeXTRuntimeIsDefault =
index d1de31b95c6b5ac9bbbef14cc43c6e78121ed94c..b8b5011bbfa939abd593f574d706ab55ca3b293d 100644 (file)
@@ -1477,6 +1477,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   if (Args.hasArg(OPT_fno_operator_names))
     Opts.CXXOperatorNames = 0;
 
+  if (Args.hasArg(OPT_fgnu89_inline))
+    Opts.GNUInline = 1;
+
   if (Args.hasArg(OPT_fobjc_gc_only))
     Opts.setGCMode(LangOptions::GCOnly);
   else if (Args.hasArg(OPT_fobjc_gc))
index f5b642191c6b4c1e6b2acfc90d45f6d692b28a8c..d77bda7676a9f6f55ee45007f074816a5c7d2015 100644 (file)
@@ -1527,7 +1527,7 @@ Sema::CXXSpecialMember Sema::getSpecialMember(const CXXMethodDecl *MD) {
 /// GNU89 mode.
 static bool canRedefineFunction(const FunctionDecl *FD,
                                 const LangOptions& LangOpts) {
-  return (LangOpts.GNUMode && !LangOpts.C99 && !LangOpts.CPlusPlus &&
+  return (LangOpts.GNUInline && !LangOpts.CPlusPlus &&
           FD->isInlineSpecified() &&
           FD->getStorageClass() == SC_Extern);
 }
index 60f6d034bf1fda0cb22f5c92aced2ea28222fe2e..e3df9968bfd2de9ff9015faa96546d7ed0a202bd 100644 (file)
@@ -1,4 +1,5 @@
 // RUN: %clang -S -emit-llvm -std=gnu89 -o - %s | FileCheck %s
+// RUN: %clang -S -emit-llvm -fgnu89-inline -o - %s | FileCheck %s
 // PR5253
 
 // If an extern inline function is redefined, functions should call the