diff options
author | Anders Carlsson <andersca@mac.com> | 2010-01-24 16:49:46 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-01-24 16:49:46 +0000 |
commit | 77babdb99a99cfe4095d81b72e4bfd304e65ebc7 (patch) | |
tree | ec33ca0b9b8ccf95955f48be40cf8d1877890d85 /clang/lib/Sema/SemaDecl.cpp | |
parent | 20a2c618f296331beb0bd98a7baaca433d1c33f2 (diff) | |
download | bcm5719-llvm-77babdb99a99cfe4095d81b72e4bfd304e65ebc7.tar.gz bcm5719-llvm-77babdb99a99cfe4095d81b72e4bfd304e65ebc7.zip |
Implement [dcl.fct.spec]p6.
llvm-svn: 94365
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index fbe02894ace..938c41efbe6 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2783,6 +2783,28 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, } } + // 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 + // and 12.3.2. + if (isExplicit && !NewFD->isInvalidDecl()) { + if (!CurContext->isRecord()) { + // 'explicit' was specified outside of the class. + Diag(D.getDeclSpec().getExplicitSpecLoc(), + diag::err_explicit_out_of_class) + << CodeModificationHint::CreateRemoval( + D.getDeclSpec().getExplicitSpecLoc()); + } else if (!isa<CXXConstructorDecl>(NewFD) && + !isa<CXXConversionDecl>(NewFD)) { + // 'explicit' was specified on a function that wasn't a constructor + // or conversion function. + Diag(D.getDeclSpec().getExplicitSpecLoc(), + diag::err_explicit_non_ctor_or_conv_function) + << CodeModificationHint::CreateRemoval( + D.getDeclSpec().getExplicitSpecLoc()); + } + } + // Filter out previous declarations that don't match the scope. FilterLookupForScope(*this, Previous, DC, S, NewFD->hasLinkage()); |