diff options
author | Nathan Wilson <nwilson20@gmail.com> | 2015-09-09 21:48:31 +0000 |
---|---|---|
committer | Nathan Wilson <nwilson20@gmail.com> | 2015-09-09 21:48:31 +0000 |
commit | 085b9ff6e257bb961f2f2edbb62a5e33c8a2cc3a (patch) | |
tree | c83e5e7cefdf2472702c775154e089a0e2b653cb /clang/lib/Sema/SemaDecl.cpp | |
parent | 51c63e3b3003eb4c324ff8ec7a46d0da539a623b (diff) | |
download | bcm5719-llvm-085b9ff6e257bb961f2f2edbb62a5e33c8a2cc3a.tar.gz bcm5719-llvm-085b9ff6e257bb961f2f2edbb62a5e33c8a2cc3a.zip |
[Concepts] Add diagnostic; invalid specifier on function or variable concept declaration
Summary: Diagnose variable and function concept declarations when an invalid specifier appears
Reviewers: rsmith, aaron.ballman, faisalv, fraggamuffin, hubert.reinterpretcast
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D12435
llvm-svn: 247194
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index acff354f70e..c55c07efb77 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5876,8 +5876,26 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (D.getDeclSpec().isConstexprSpecified()) NewVD->setConstexpr(true); - if (D.getDeclSpec().isConceptSpecified()) + if (D.getDeclSpec().isConceptSpecified()) { NewVD->setConcept(true); + + // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not + // be declared with the thread_local, inline, friend, or constexpr + // specifiers, [...] + if (D.getDeclSpec().getThreadStorageClassSpec() == TSCS_thread_local) { + Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), + diag::err_concept_decl_invalid_specifiers) + << 0 << 0; + NewVD->setInvalidDecl(true); + } + + if (D.getDeclSpec().isConstexprSpecified()) { + Diag(D.getDeclSpec().getConstexprSpecLoc(), + diag::err_concept_decl_invalid_specifiers) + << 0 << 3; + NewVD->setInvalidDecl(true); + } + } } // Set the lexical context. If the declarator has a C++ scope specifier, the @@ -7502,6 +7520,30 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is // implicity defined to be a constexpr declaration (implicitly inline) NewFD->setImplicitlyInline(); + + // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not + // be declared with the thread_local, inline, friend, or constexpr + // specifiers, [...] + if (isInline) { + Diag(D.getDeclSpec().getInlineSpecLoc(), + diag::err_concept_decl_invalid_specifiers) + << 1 << 1; + NewFD->setInvalidDecl(true); + } + + if (isFriend) { + Diag(D.getDeclSpec().getFriendSpecLoc(), + diag::err_concept_decl_invalid_specifiers) + << 1 << 2; + NewFD->setInvalidDecl(true); + } + + if (isConstexpr) { + Diag(D.getDeclSpec().getConstexprSpecLoc(), + diag::err_concept_decl_invalid_specifiers) + << 1 << 3; + NewFD->setInvalidDecl(true); + } } // If __module_private__ was specified, mark the function accordingly. |