diff options
author | Nathan Wilson <nwilson20@gmail.com> | 2015-08-03 14:25:45 +0000 |
---|---|---|
committer | Nathan Wilson <nwilson20@gmail.com> | 2015-08-03 14:25:45 +0000 |
commit | 8567a000b9a554ff6eed3dc31af60b37e041e5f8 (patch) | |
tree | dd05dd38485c3858ccaac06e8f819f250cf81f86 /clang/lib/Sema/SemaDecl.cpp | |
parent | 1becccb10f8a09863a0aaf9a136cce24512d7824 (diff) | |
download | bcm5719-llvm-8567a000b9a554ff6eed3dc31af60b37e041e5f8.tar.gz bcm5719-llvm-8567a000b9a554ff6eed3dc31af60b37e041e5f8.zip |
[CONCEPTS] Add concept to VarDecl and diagnostic for uninitialized variable concept
Summary: Add IsConcept bit to VarDecl::NonParmVarDeclBitfields and associated isConcept/setConcept member functions. Set IsConcept to true when 'concept' specifier is in variable declaration. Create diagnostic when variable concept is not initialized.
Reviewers: fraggamuffin, hubert.reinterpretcast, faisalv, aaron.ballman, rsmith
Subscribers: aemerson, cfe-commits
Differential Revision: http://reviews.llvm.org/D11600
llvm-svn: 243876
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 9f499de0843..962610c1ce5 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5855,6 +5855,9 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, if (D.getDeclSpec().isConstexprSpecified()) NewVD->setConstexpr(true); + + if (D.getDeclSpec().isConceptSpecified()) + NewVD->setConcept(true); } // Set the lexical context. If the declarator has a C++ scope specifier, the @@ -9407,6 +9410,15 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl, return; } + // C++ Concepts TS [dcl.spec.concept]p1: [...] A variable template + // definition having the concept specifier is called a variable concept. A + // concept definition refers to [...] a variable concept and its initializer. + if (Var->isConcept()) { + Diag(Var->getLocation(), diag::err_var_concept_not_initialized); + Var->setInvalidDecl(); + return; + } + // OpenCL v1.1 s6.5.3: variables declared in the constant address space must // be initialized. if (!Var->isInvalidDecl() && |