On Jun 2, 2011, at 9:13 AM, Rafael Espindola wrote: > Author: rafael > Date: Thu Jun 2 11:13:27 2011 > New Revision: 132460 > > URL: http://llvm.org/viewvc/llvm-project?rev=132460&view=rev > Log: > Implement -fgnu89-inline. Fixes PR10041. > > Modified: > cfe/trunk/include/clang/Driver/CC1Options.td > cfe/trunk/include/clang/Driver/Options.td > cfe/trunk/lib/AST/Decl.cpp > cfe/trunk/lib/Driver/Tools.cpp > cfe/trunk/lib/Frontend/CompilerInvocation.cpp > cfe/trunk/lib/Sema/SemaDecl.cpp > cfe/trunk/test/CodeGen/extern-inline.c > > Modified: cfe/trunk/include/clang/Driver/CC1Options.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=132460&r1=132459&r2=132460&view=diff > ============================================================================== > --- cfe/trunk/include/clang/Driver/CC1Options.td (original) > +++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Jun 2 11:13:27 2011 > @@ -423,6 +423,8 @@ > 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">, > > Modified: cfe/trunk/include/clang/Driver/Options.td > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=132460&r1=132459&r2=132460&view=diff > ============================================================================== > --- cfe/trunk/include/clang/Driver/Options.td (original) > +++ cfe/trunk/include/clang/Driver/Options.td Thu Jun 2 11:13:27 2011 > @@ -299,6 +299,7 @@ > > 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]>;
We should probably also have -fno-gnu89-inline? > Modified: cfe/trunk/lib/AST/Decl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=132460&r1=132459&r2=132460&view=diff > ============================================================================== > --- cfe/trunk/lib/AST/Decl.cpp (original) > +++ cfe/trunk/lib/AST/Decl.cpp Thu Jun 2 11:13:27 2011 > @@ -1743,7 +1743,7 @@ > 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. > > Modified: cfe/trunk/lib/Driver/Tools.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=132460&r1=132459&r2=132460&view=diff > ============================================================================== > --- cfe/trunk/lib/Driver/Tools.cpp (original) > +++ cfe/trunk/lib/Driver/Tools.cpp Thu Jun 2 11:13:27 2011 > @@ -1712,6 +1712,9 @@ > 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 = > > Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=132460&r1=132459&r2=132460&view=diff > ============================================================================== > --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) > +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jun 2 11:13:27 2011 > @@ -1477,6 +1477,9 @@ > 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)) > > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=132460&r1=132459&r2=132460&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jun 2 11:13:27 2011 > @@ -1527,7 +1527,7 @@ > /// 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); > } > > Modified: cfe/trunk/test/CodeGen/extern-inline.c > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/extern-inline.c?rev=132460&r1=132459&r2=132460&view=diff > ============================================================================== > --- cfe/trunk/test/CodeGen/extern-inline.c (original) > +++ cfe/trunk/test/CodeGen/extern-inline.c Thu Jun 2 11:13:27 2011 > @@ -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 > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
