diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-06 11:44:10 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-06 11:44:10 +0000 |
commit | 2588691a6960362abb1258b59a3b75403d15806d (patch) | |
tree | 660c7069eebdf51a1b75f2439e5b439439f562b4 /clang/lib/Sema/SemaDecl.cpp | |
parent | efcc6da97d75673b9394e89b7c0f1db01a0026dd (diff) | |
download | bcm5719-llvm-2588691a6960362abb1258b59a3b75403d15806d.tar.gz bcm5719-llvm-2588691a6960362abb1258b59a3b75403d15806d.zip |
Diagnose the use of "inline" on block-scope function declarations in
C++, from Andrea Nall!
llvm-svn: 110439
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 96839a54213..f7e7928bbb0 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3232,6 +3232,17 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, } } + // C++ [dcl.fct.spec]p3: + // The inline specifier shall not appear on a block scope function declaration. + if (isInline && !NewFD->isInvalidDecl() && getLangOptions().CPlusPlus) { + if (CurContext->isFunctionOrMethod()) { + // 'inline' is not allowed on block scope function declaration. + Diag(D.getDeclSpec().getInlineSpecLoc(), + diag::err_inline_declaration_block_scope) << Name + << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc()); + } + } + // C++ [dcl.fct.spec]p6: // The explicit specifier shall be used only in the declaration of a // constructor or conversion function within its class definition; see 12.3.1 |