aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-06 11:44:10 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-06 11:44:10 +0000
commited328c6129152f66771c3bed338a2e6e13e4e230 (patch)
treedfcae614419d1d78f16b948935554cb3a68a41e9 /lib/Sema/SemaDecl.cpp
parent2d490f2d8a9a093e6e36b07b70993ae739cad803 (diff)
Diagnose the use of "inline" on block-scope function declarations in
C++, from Andrea Nall! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 96839a5421..f7e7928bbb 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/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