[PATCH] D26882: Refactor how FunctionDecl handles constexpr:

2016-11-22 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.



Comment at: include/clang/AST/Decl.h:1915
+IsConstexprSpecified = IC;
+IsConstexpr = IC;
+  }

hubert.reinterpretcast wrote:
> How is the `inline` property transmitted here? Why does the 
> `setImplicitlyConstexpr` function need to call `setImplicitlyInline`?
`inline` isn't //really// transmitted here. When we create a `FunctionDecl` in 
`CreateNewFunctionDecl` we //could// use this rather than passing `isConstexpr` 
as a parameter to the constructor. `setImplicitlyConstexpr` is intended to be 
used downstream such as in `ActOnFunctionDeclarator` or 
`CheckExplicitlyDefaultedSpecialMember`.



Comment at: include/clang/AST/Decl.h:1919
+  /// Flag that this function as implicitly constexpr
+  /// C++11 [dcl.constexpr]p2: constexpr functions and constexpr constructors
+  /// are implicitly inline functions (7.1.2).

hubert.reinterpretcast wrote:
> The quote does not seem to be pertinent here. Maybe have it a few lines down?
Sorry, can you point to where you're thinking below?



Comment at: include/clang/AST/Decl.h:1923
+IsConstexpr = IC;
+setImplicitlyInline();
+  }

hubert.reinterpretcast wrote:
> I am quite sure this is not the right thing to do when `IC` is `false`.
Good point. I //could// do `if (IC) setImplicitlyInline();`, but that doesn't 
seem great with these smaller functions. Any suggestions by you or @rsmith 
would be great!



Comment at: lib/Sema/SemaDecl.cpp:8085
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
   // implicity defined to be a constexpr declaration (implicitly inline)
+  NewFD->setImplicitlyConstexpr(true);

hubert.reinterpretcast wrote:
> The parenthetical here seems to be no longer needed.
I'll remove it.



Comment at: lib/Sema/SemaDecl.cpp:9107
   << FixItHint::CreateRemoval(DS.getConstexprSpecLoc());
-FD->setConstexpr(false);
+FD->setImplicitlyConstexpr(false);
   }

hubert.reinterpretcast wrote:
> This reads wrong to me. I get that the idea is that the function should not 
> be semantically considered `constexpr`, but the choice of 
> `setImplicitlyConstexpr` seems odd.
Hmm, I'm not sure if we should  keep around `setConstexpr` to handle cases 
either... Do you or @rsmith have any opinion?



Comment at: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp:21
+static_assert(FCSizeOfU4(), "");
+static_assert(FCSizeOfU4(), "size of argument not equal to expected 
(4)"); // expected-error {{static_assert failed "size of argument not equal to 
expected (4)"}}
+

hubert.reinterpretcast wrote:
> This does not strike me as being very portable (I may be mistaken about how 
> `clang -cc1` works though). I think it would be much safer to use `char [8]` 
> here (and in general for the size matching).
> 
Yeah, good point. I'll fix this.


https://reviews.llvm.org/D26882



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247194 - [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-09-09 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Wed Sep  9 16:48:31 2015
New Revision: 247194

URL: http://llvm.org/viewvc/llvm-project?rev=247194&view=rev
Log:
[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

Added:
cfe/trunk/test/CXX/concepts-ts/
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=247194&r1=247193&r2=247194&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep  9 16:48:31 
2015
@@ -1980,6 +1980,9 @@ def err_var_concept_not_initialized : Er
   "variable concept declaration must be initialized">;
 def err_function_concept_exception_spec : Error<
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_specifiers : Error<
+  "%select{variable|function}0 concept cannot be declared "
+  "'%select{thread_local|inline|friend|constexpr}1'">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=247194&r1=247193&r2=247194&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep  9 16:48:31 2015
@@ -5876,8 +5876,26 @@ Sema::ActOnVariableDeclarator(Scope *S,
 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,
   // 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.

Added: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp?rev=247194&view=auto
==
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp (added)
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp Wed Sep  
9 16:48:31 2015
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error 
{{variable concept cannot be declared 'thread_local'}}
+
+template concept constexp

r247966 - [Concepts] Moving tests to match the corresponding section of the TS

2015-09-17 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Thu Sep 17 21:50:53 2015
New Revision: 247966

URL: http://llvm.org/viewvc/llvm-project?rev=247966&view=rev
Log:
[Concepts] Moving tests to match the corresponding section of the TS

Added:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p1.cpp
  - copied unchanged from r247963, 
cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
Removed:
cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp

Removed: cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp?rev=247965&view=auto
==
--- cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp (removed)
@@ -1,41 +0,0 @@
-// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s
-
-namespace A {
-  template concept bool C1() { return true; }
-
-  template concept bool C2 = true;
-}
-
-template concept bool C3() { return (throw 0, true); }
-static_assert(noexcept(C3()), "function concept should be treated as if 
noexcept(true) specified");
-
-template concept bool D1(); // expected-error {{function concept 
declaration must be a definition}}
-
-struct B {
-  template concept bool D2() { return true; } // expected-error 
{{concept declarations may only appear in namespace scope}}
-};
-
-struct C {
-  template static concept bool D3 = true; // expected-error 
{{concept declarations may only appear in namespace scope}}
-};
-
-concept bool D4() { return true; } // expected-error {{'concept' can only 
appear on the definition of a function template or variable template}}
-
-concept bool D5 = true; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
-
-template
-concept bool D6; // expected-error {{variable concept declaration must be 
initialized}}
-
-template
-concept bool D7() throw(int) { return true; } // expected-error {{function 
concept cannot have exception specification}}
-
-// Tag
-concept class CC1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
-concept struct CS1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
-concept union CU1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
-concept enum CE1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
-template  concept class TCC1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
-template  concept struct TCS1 {}; // expected-error {{'concept' 
can only appear on the definition of a function template or variable template}}
-template  concept union TCU1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
-
-concept bool; // expected-error {{'concept' can only appear on the definition 
of a function template or variable template}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D13357: [Concepts] Add diagnostic; specializations of variable and function concepts

2015-10-01 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, 
faisalv, fraggamuffin.
nwilson added a subscriber: cfe-commits.

http://reviews.llvm.org/D13357

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p7.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p7.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p7.cpp
@@ -0,0 +1,16 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{variable concept cannot be explicitly instantiated}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{variable concept cannot be partially specialized}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{variable concept cannot be explicitly specialized}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{function concept cannot be explicitly instantiated}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{function concept cannot be explicitly specialized}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7588,6 +7588,14 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation, [...] of a concept definition.
+  if (D.getDeclSpec().isConceptSpecified() && R->isFunctionType()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_decl_specialized)
+  << 1 << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
@@ -7659,6 +7667,14 @@
 return true;
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation, [...] of a concept definition.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_decl_specialized)
+  << 0 << 0;
+return true;
+  }
+
   // Translate the parser's template argument list into our AST format.
   TemplateArgumentListInfo TemplateArgs =
   makeTemplateArgumentListInfo(*this, *D.getName().TemplateId);
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5898,6 +5898,21 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  //  an explicit specialization, or a partial specialization of a concept
+  // definition
+  if (IsVariableTemplateSpecialization && !IsPartialSpecialization) {
+Diag(NewVD->getLocation(), diag::err_concept_decl_specialized)
+  << 0 << 1;
+NewVD->setInvalidDecl(true);
+  }
+
+  if (IsVariableTemplateSpecialization && IsPartialSpecialization) {
+Diag(NewVD->getLocation(), diag::err_concept_decl_specialized)
+  << 0 << 2;
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7544,6 +7559,9 @@
 }
 
 if (isConcept) {
+  // This is a function concept
+  NewFD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7595,6 +7613,14 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  // an explicit specialization, [...] of a concept definition.
+  if (isFunctionTemplateSpecialization) {
+Diag(NewFD->getLocation(), diag::err_concept_decl_specialized)
+  << 1 << 1;
+NewFD->setInvalidDecl();
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7858,8 +7884,8 @@
  TemplateArgs);
 
   HasExplicitTemplateArgs = true;
-
-  if (NewFD->isInvalidDecl()) {
+
+  if (NewFD->isInvalidDecl() && !NewFD->isConcept()) {
 HasExplicitTemplateArgs = false;
   } else if (FunctionTemplate) {
 // Function template with explicit template arguments.
Index: include/clang/Basic/DiagnosticSemaKinds.td
==

Re: [PATCH] D11859: Generating vptr assume loads

2015-08-10 Thread Nathan Wilson via cfe-commits
nwilson added a subscriber: nwilson.


Comment at: lib/CodeGen/CGClass.cpp:1862
@@ +1861,3 @@
+if (CGM.getCXXABI().canInitializeVPtr(vptr.VTableClass, 
vptr.Base.getBase(),
+ vptr.NearestVBase))
+  EmitVTableAssumptionLoad(vptr, This);

Looks like another formatting/tab issue here.


Comment at: lib/CodeGen/CGClass.cpp:2155
@@ +2154,3 @@
+if (CGM.getCXXABI().canInitializeVPtr(Vptr.VTableClass, 
Vptr.Base.getBase(),
+ Vptr.NearestVBase))
+  InitializeVTablePointer(Vptr);

Looks like the same formatting/tab as above.

This is what I've done when using clang-format, maybe it will fix the issues 
you've had:
./clang-format -style=llvm -lines="N:M"  > tmp && cp tmp 


(Just don't include the less than and greater around the FileToFormat.)



http://reviews.llvm.org/D11859



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11859: Generating vptr assume loads

2015-08-10 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: lib/CodeGen/CGClass.cpp:2155
@@ +2154,3 @@
+if (CGM.getCXXABI().canInitializeVPtr(Vptr.VTableClass, 
Vptr.Base.getBase(),
+ Vptr.NearestVBase))
+  InitializeVTablePointer(Vptr);

djasper wrote:
> nwilson wrote:
> > Looks like the same formatting/tab as above.
> > 
> > This is what I've done when using clang-format, maybe it will fix the 
> > issues you've had:
> > ./clang-format -style=llvm -lines="N:M"  > tmp && cp tmp 
> > 
> > 
> > (Just don't include the less than and greater around the FileToFormat.)
> > 
> You shouldn't need to do this by "hand". There is clang-format-diff.py / 
> git-clang-format for that.
Good to know. Thanks!


http://reviews.llvm.org/D11859



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11916: [CONCEPTS] Add diagnostic; invalid tag when concept specified

2015-08-11 Thread Nathan Wilson via cfe-commits
On Tue, Aug 11, 2015 at 8:54 AM, Aaron Ballman 
wrote:

> On Mon, Aug 10, 2015 at 3:00 PM, Nathan Wilson 
> wrote:
> > nwilson created this revision.
> > nwilson added reviewers: rsmith, hubert.reinterpretcast, fraggamuffin,
> faisalv, aaron.ballman.
> > nwilson added a subscriber: cfe-commits.
> >
> > Adding check to emit diagnostic for invalid tag when concept is
> specified and associated tests.
> >
> > http://reviews.llvm.org/D11916
> >
> > Files:
> >   include/clang/Basic/DiagnosticSemaKinds.td
> >   lib/Sema/SemaDecl.cpp
> >   test/SemaCXX/cxx-concept-declaration.cpp
> >
> > Index: test/SemaCXX/cxx-concept-declaration.cpp
> > ===
> > --- test/SemaCXX/cxx-concept-declaration.cpp
> > +++ test/SemaCXX/cxx-concept-declaration.cpp
> > @@ -23,3 +23,13 @@
> >  template
> >  concept bool D6; // expected-error {{variable concept declaration must
> be initialized}}
> >
> > +// Tag
> > +concept class CC1 {}; // expected-error {{class cannot be marked
> concept}}
> > +concept struct CS1 {}; // expected-error {{struct cannot be marked
> concept}}
> > +concept union CU1 {}; // expected-error {{union cannot be marked
> concept}}
> > +concept enum CE1 {}; // expected-error {{enum cannot be marked concept}}
> > +template  concept class TCC1 {}; // expected-error {{class
> cannot be marked concept}}
> > +template  concept struct TCS1 {}; // expected-error
> {{struct cannot be marked concept}}
> > +template  concept union TCU1 {}; // expected-error {{union
> cannot be marked concept}}
> > +
> > +extern concept bool ExtC; // expected-error {{'concept' can only appear
> on the definition of a function template or variable template}}
> > Index: lib/Sema/SemaDecl.cpp
> > ===
> > --- lib/Sema/SemaDecl.cpp
> > +++ lib/Sema/SemaDecl.cpp
> > @@ -3662,6 +3662,19 @@
> >  return TagD;
> >}
> >
> > +  if (DS.isConceptSpecified()) {
> > +// C++ Concepts TS [dcl.spec.concept]p1: A concept definition
> refers to
> > +// either a function concept and its definition or a variable
> concept and
> > +// its initializer.
> > +if (Tag)
> > +  Diag(DS.getConceptSpecLoc(), diag::err_concept_tag)
> > +  << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType());
> > +else
> > +  Diag(DS.getConceptSpecLoc(), diag::err_concept_decl_non_template);
> > +// Don't emit warnings after this error.
> > +return TagD;
> > +  }
>
> I'm not certain I understand why we need two different diagnostics for
> this case. I think err_concept_decl_non_template is sufficiently clear
> for both.
>
> ~Aaron
>

This was based on how constexpr handles these checks.

Perhaps someone can correct me if I'm wrong, but I believe the idea is that
when the `struct` tag exists, for example, we think the user meant to
declare a `struct` and not the start of a `concept` declaration. So, the
`concept` specifier would be erroneous and we try give a more helpful
diagnostic.

I would need to add/fix the test case for this, but I tend to think the
declaration such as `concept bool;` could be the users intention to try to
create a `concept` declaration which is where
the err_concept_decl_non_template comes in.


>
> > +
> >DiagnoseFunctionSpecifiers(DS);
> >
> >if (DS.isFriendSpecified()) {
> > Index: include/clang/Basic/DiagnosticSemaKinds.td
> > ===
> > --- include/clang/Basic/DiagnosticSemaKinds.td
> > +++ include/clang/Basic/DiagnosticSemaKinds.td
> > @@ -1973,6 +1973,8 @@
> >"function concept declaration must be a definition">;
> >  def err_var_concept_not_initialized : Error<
> >"variable concept declaration must be initialized">;
> > +def err_concept_tag : Error<
> > +  "%select{class|struct|interface|union|enum}0 cannot be marked
> concept">;
> >
> >  // C++11 char16_t/char32_t
> >  def warn_cxx98_compat_unicode_type : Warning<
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11916: [CONCEPTS] Add diagnostic; invalid tag when concept specified

2015-08-11 Thread Nathan Wilson via cfe-commits
Okay, I'll make the change.

Hmm, do you guys have any suggestions as far as renaming
err_concept_decl_non_template?
How about err_concept_specifier_non_template?

We'd have to keep in mind that err_concept_decl_non_template is also used
outside of this check, i.e. `concept bool = true`.

On Tue, Aug 11, 2015 at 4:19 PM, Hubert Tong <
hubert.reinterpretc...@gmail.com> wrote:

> From Aaron's description of the user experience, I think the
> err_concept_decl_non_template message text is good (although
> err_concept_decl_non_template might need to be renamed).
>
> -- HT
>
> On Tue, Aug 11, 2015 at 4:01 PM, Aaron Ballman 
> wrote:
>
>> On Tue, Aug 11, 2015 at 3:36 PM, Nathan Wilson 
>> wrote:
>> >
>> >
>> > On Tue, Aug 11, 2015 at 8:54 AM, Aaron Ballman > >
>> > wrote:
>> >>
>> >> On Mon, Aug 10, 2015 at 3:00 PM, Nathan Wilson 
>> >> wrote:
>> >> > nwilson created this revision.
>> >> > nwilson added reviewers: rsmith, hubert.reinterpretcast,
>> fraggamuffin,
>> >> > faisalv, aaron.ballman.
>> >> > nwilson added a subscriber: cfe-commits.
>> >> >
>> >> > Adding check to emit diagnostic for invalid tag when concept is
>> >> > specified and associated tests.
>> >> >
>> >> > http://reviews.llvm.org/D11916
>> >> >
>> >> > Files:
>> >> >   include/clang/Basic/DiagnosticSemaKinds.td
>> >> >   lib/Sema/SemaDecl.cpp
>> >> >   test/SemaCXX/cxx-concept-declaration.cpp
>> >> >
>> >> > Index: test/SemaCXX/cxx-concept-declaration.cpp
>> >> > ===
>> >> > --- test/SemaCXX/cxx-concept-declaration.cpp
>> >> > +++ test/SemaCXX/cxx-concept-declaration.cpp
>> >> > @@ -23,3 +23,13 @@
>> >> >  template
>> >> >  concept bool D6; // expected-error {{variable concept declaration
>> must
>> >> > be initialized}}
>> >> >
>> >> > +// Tag
>> >> > +concept class CC1 {}; // expected-error {{class cannot be marked
>> >> > concept}}
>> >> > +concept struct CS1 {}; // expected-error {{struct cannot be marked
>> >> > concept}}
>> >> > +concept union CU1 {}; // expected-error {{union cannot be marked
>> >> > concept}}
>> >> > +concept enum CE1 {}; // expected-error {{enum cannot be marked
>> >> > concept}}
>> >> > +template  concept class TCC1 {}; // expected-error
>> {{class
>> >> > cannot be marked concept}}
>> >> > +template  concept struct TCS1 {}; // expected-error
>> >> > {{struct cannot be marked concept}}
>> >> > +template  concept union TCU1 {}; // expected-error
>> {{union
>> >> > cannot be marked concept}}
>> >> > +
>> >> > +extern concept bool ExtC; // expected-error {{'concept' can only
>> appear
>> >> > on the definition of a function template or variable template}}
>> >> > Index: lib/Sema/SemaDecl.cpp
>> >> > ===
>> >> > --- lib/Sema/SemaDecl.cpp
>> >> > +++ lib/Sema/SemaDecl.cpp
>> >> > @@ -3662,6 +3662,19 @@
>> >> >  return TagD;
>> >> >}
>> >> >
>> >> > +  if (DS.isConceptSpecified()) {
>> >> > +// C++ Concepts TS [dcl.spec.concept]p1: A concept definition
>> >> > refers to
>> >> > +// either a function concept and its definition or a variable
>> >> > concept and
>> >> > +// its initializer.
>> >> > +if (Tag)
>> >> > +  Diag(DS.getConceptSpecLoc(), diag::err_concept_tag)
>> >> > +  << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType());
>> >> > +else
>> >> > +  Diag(DS.getConceptSpecLoc(),
>> >> > diag::err_concept_decl_non_template);
>> >> > +// Don't emit warnings after this error.
>> >> > +return TagD;
>> >> > +  }
>> >>
>> >> I'm not certain I understand why we need two different diagnostics for
>> >> this case. I think err_concept_decl_non_template is sufficiently clear
>> >> for both.
>> >>
>> >> ~Aaron
>> >
>> >
>> > This was based on how constexpr handles these checks.
>> >
>> > Perhaps someone can correct me if I'm wrong, but I believe the idea is
>> that
>> > when the `struct` tag exists, for example, we think the user meant to
>> > declare a `struct` and not the start of a `concept` declaration. So, the
>> > `concept` specifier would be erroneous and we try give a more helpful
>> > diagnostic.
>>
>> It could just be me, but I don't find the new diagnostic particularly
>> helpful. "foo cannot be marked concept" tells me why I have an error
>> but does not tell me what to do about it. "'concept' can only appear
>> on the definition of a function template or variable template" tells
>> me what I need to do to not have the error in the first place, as well
>> as why I have the error.
>>
>> However, others may have differing opinions on the subject.
>>
>> ~Aaron
>>
>> >
>> > I would need to add/fix the test case for this, but I tend to think the
>> > declaration such as `concept bool;` could be the users intention to try
>> to
>> > create a `concept` declaration which is where the
>> > err_concept_decl_non_template comes in.
>> >
>> >>
>> >>
>> >> > +
>> >> >DiagnoseFunctionSpecifiers(DS);
>> >> >
>> >> >if (DS.isFriendSpecified()) {
>> >

Re: [PATCH] D11916: [CONCEPTS] Add diagnostic; invalid tag when concept specified

2015-08-11 Thread Nathan Wilson via cfe-commits
On Tue, Aug 11, 2015 at 4:54 PM, Richard Smith 
wrote:

> On Tue, Aug 11, 2015 at 2:46 PM, Nathan Wilson 
> wrote:
>
>> Okay, I'll make the change.
>>
>> Hmm, do you guys have any suggestions as far as renaming 
>> err_concept_decl_non_template?
>> How about err_concept_specifier_non_template?
>>
>
> Maybe err_concept_wrong_decl_kind?
>

I'd be okay with that.

Is okay to have two different tags with the same text?

We'd use err_concept_decl_non_template in HandleDeclarator when we
encounter a non-template when `concept` is specified, and we could use
err_concept_wrong_decl_kind
for the checks in this Patch.


>
>
>> We'd have to keep in mind that err_concept_decl_non_template is also
>> used outside of this check, i.e. `concept bool = true`.
>>
>>
>> On Tue, Aug 11, 2015 at 4:19 PM, Hubert Tong <
>> hubert.reinterpretc...@gmail.com> wrote:
>>
>>> From Aaron's description of the user experience, I think the
>>> err_concept_decl_non_template message text is good (although
>>> err_concept_decl_non_template might need to be renamed).
>>>
>>> -- HT
>>>
>>> On Tue, Aug 11, 2015 at 4:01 PM, Aaron Ballman 
>>> wrote:
>>>
 On Tue, Aug 11, 2015 at 3:36 PM, Nathan Wilson 
 wrote:
 >
 >
 > On Tue, Aug 11, 2015 at 8:54 AM, Aaron Ballman <
 aaron.ball...@gmail.com>
 > wrote:
 >>
 >> On Mon, Aug 10, 2015 at 3:00 PM, Nathan Wilson 
 >> wrote:
 >> > nwilson created this revision.
 >> > nwilson added reviewers: rsmith, hubert.reinterpretcast,
 fraggamuffin,
 >> > faisalv, aaron.ballman.
 >> > nwilson added a subscriber: cfe-commits.
 >> >
 >> > Adding check to emit diagnostic for invalid tag when concept is
 >> > specified and associated tests.
 >> >
 >> > http://reviews.llvm.org/D11916
 >> >
 >> > Files:
 >> >   include/clang/Basic/DiagnosticSemaKinds.td
 >> >   lib/Sema/SemaDecl.cpp
 >> >   test/SemaCXX/cxx-concept-declaration.cpp
 >> >
 >> > Index: test/SemaCXX/cxx-concept-declaration.cpp
 >> > ===
 >> > --- test/SemaCXX/cxx-concept-declaration.cpp
 >> > +++ test/SemaCXX/cxx-concept-declaration.cpp
 >> > @@ -23,3 +23,13 @@
 >> >  template
 >> >  concept bool D6; // expected-error {{variable concept declaration
 must
 >> > be initialized}}
 >> >
 >> > +// Tag
 >> > +concept class CC1 {}; // expected-error {{class cannot be marked
 >> > concept}}
 >> > +concept struct CS1 {}; // expected-error {{struct cannot be marked
 >> > concept}}
 >> > +concept union CU1 {}; // expected-error {{union cannot be marked
 >> > concept}}
 >> > +concept enum CE1 {}; // expected-error {{enum cannot be marked
 >> > concept}}
 >> > +template  concept class TCC1 {}; // expected-error
 {{class
 >> > cannot be marked concept}}
 >> > +template  concept struct TCS1 {}; // expected-error
 >> > {{struct cannot be marked concept}}
 >> > +template  concept union TCU1 {}; // expected-error
 {{union
 >> > cannot be marked concept}}
 >> > +
 >> > +extern concept bool ExtC; // expected-error {{'concept' can only
 appear
 >> > on the definition of a function template or variable template}}
 >> > Index: lib/Sema/SemaDecl.cpp
 >> > ===
 >> > --- lib/Sema/SemaDecl.cpp
 >> > +++ lib/Sema/SemaDecl.cpp
 >> > @@ -3662,6 +3662,19 @@
 >> >  return TagD;
 >> >}
 >> >
 >> > +  if (DS.isConceptSpecified()) {
 >> > +// C++ Concepts TS [dcl.spec.concept]p1: A concept definition
 >> > refers to
 >> > +// either a function concept and its definition or a variable
 >> > concept and
 >> > +// its initializer.
 >> > +if (Tag)
 >> > +  Diag(DS.getConceptSpecLoc(), diag::err_concept_tag)
 >> > +  << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType());
 >> > +else
 >> > +  Diag(DS.getConceptSpecLoc(),
 >> > diag::err_concept_decl_non_template);
 >> > +// Don't emit warnings after this error.
 >> > +return TagD;
 >> > +  }
 >>
 >> I'm not certain I understand why we need two different diagnostics
 for
 >> this case. I think err_concept_decl_non_template is sufficiently
 clear
 >> for both.
 >>
 >> ~Aaron
 >
 >
 > This was based on how constexpr handles these checks.
 >
 > Perhaps someone can correct me if I'm wrong, but I believe the idea
 is that
 > when the `struct` tag exists, for example, we think the user meant to
 > declare a `struct` and not the start of a `concept` declaration. So,
 the
 > `concept` specifier would be erroneous and we try give a more helpful
 > diagnostic.

 It could just be me, but I don't find the new diagnostic particularly
 helpful. "foo cannot be marked concept" tells me wh

Re: [PATCH] D11916: [CONCEPTS] Add diagnostic; invalid tag when concept specified

2015-08-11 Thread Nathan Wilson via cfe-commits
On Tue, Aug 11, 2015 at 5:46 PM, Richard Smith 
wrote:

> On Tue, Aug 11, 2015 at 3:35 PM, Nathan Wilson 
> wrote:
>
>>
>>
>> On Tue, Aug 11, 2015 at 4:54 PM, Richard Smith 
>> wrote:
>>
>>> On Tue, Aug 11, 2015 at 2:46 PM, Nathan Wilson 
>>> wrote:
>>>
 Okay, I'll make the change.

 Hmm, do you guys have any suggestions as far as renaming 
 err_concept_decl_non_template?
 How about err_concept_specifier_non_template?

>>>
>>> Maybe err_concept_wrong_decl_kind?
>>>
>>
>> I'd be okay with that.
>>
>> Is okay to have two different tags with the same text?
>>
>> We'd use err_concept_decl_non_template in HandleDeclarator when we
>> encounter a non-template when `concept` is specified, and we could use 
>> err_concept_wrong_decl_kind
>> for the checks in this Patch.
>>
>
> Is there any reason to duplicate this rather than reusing the same
> diagnostic?
>

Well, I originally thought that the former was a bit more descriptive.
Nonetheless, I'd be fine with err_concept_wrong_decl_kind.


>
>
>> We'd have to keep in mind that err_concept_decl_non_template is also
 used outside of this check, i.e. `concept bool = true`.


 On Tue, Aug 11, 2015 at 4:19 PM, Hubert Tong <
 hubert.reinterpretc...@gmail.com> wrote:

> From Aaron's description of the user experience, I think the
> err_concept_decl_non_template message text is good (although
> err_concept_decl_non_template might need to be renamed).
>
> -- HT
>
> On Tue, Aug 11, 2015 at 4:01 PM, Aaron Ballman <
> aaron.ball...@gmail.com> wrote:
>
>> On Tue, Aug 11, 2015 at 3:36 PM, Nathan Wilson 
>> wrote:
>> >
>> >
>> > On Tue, Aug 11, 2015 at 8:54 AM, Aaron Ballman <
>> aaron.ball...@gmail.com>
>> > wrote:
>> >>
>> >> On Mon, Aug 10, 2015 at 3:00 PM, Nathan Wilson <
>> nwilso...@gmail.com>
>> >> wrote:
>> >> > nwilson created this revision.
>> >> > nwilson added reviewers: rsmith, hubert.reinterpretcast,
>> fraggamuffin,
>> >> > faisalv, aaron.ballman.
>> >> > nwilson added a subscriber: cfe-commits.
>> >> >
>> >> > Adding check to emit diagnostic for invalid tag when concept is
>> >> > specified and associated tests.
>> >> >
>> >> > http://reviews.llvm.org/D11916
>> >> >
>> >> > Files:
>> >> >   include/clang/Basic/DiagnosticSemaKinds.td
>> >> >   lib/Sema/SemaDecl.cpp
>> >> >   test/SemaCXX/cxx-concept-declaration.cpp
>> >> >
>> >> > Index: test/SemaCXX/cxx-concept-declaration.cpp
>> >> >
>> ===
>> >> > --- test/SemaCXX/cxx-concept-declaration.cpp
>> >> > +++ test/SemaCXX/cxx-concept-declaration.cpp
>> >> > @@ -23,3 +23,13 @@
>> >> >  template
>> >> >  concept bool D6; // expected-error {{variable concept
>> declaration must
>> >> > be initialized}}
>> >> >
>> >> > +// Tag
>> >> > +concept class CC1 {}; // expected-error {{class cannot be marked
>> >> > concept}}
>> >> > +concept struct CS1 {}; // expected-error {{struct cannot be
>> marked
>> >> > concept}}
>> >> > +concept union CU1 {}; // expected-error {{union cannot be marked
>> >> > concept}}
>> >> > +concept enum CE1 {}; // expected-error {{enum cannot be marked
>> >> > concept}}
>> >> > +template  concept class TCC1 {}; // expected-error
>> {{class
>> >> > cannot be marked concept}}
>> >> > +template  concept struct TCS1 {}; // expected-error
>> >> > {{struct cannot be marked concept}}
>> >> > +template  concept union TCU1 {}; // expected-error
>> {{union
>> >> > cannot be marked concept}}
>> >> > +
>> >> > +extern concept bool ExtC; // expected-error {{'concept' can
>> only appear
>> >> > on the definition of a function template or variable template}}
>> >> > Index: lib/Sema/SemaDecl.cpp
>> >> >
>> ===
>> >> > --- lib/Sema/SemaDecl.cpp
>> >> > +++ lib/Sema/SemaDecl.cpp
>> >> > @@ -3662,6 +3662,19 @@
>> >> >  return TagD;
>> >> >}
>> >> >
>> >> > +  if (DS.isConceptSpecified()) {
>> >> > +// C++ Concepts TS [dcl.spec.concept]p1: A concept
>> definition
>> >> > refers to
>> >> > +// either a function concept and its definition or a
>> variable
>> >> > concept and
>> >> > +// its initializer.
>> >> > +if (Tag)
>> >> > +  Diag(DS.getConceptSpecLoc(), diag::err_concept_tag)
>> >> > +  << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType());
>> >> > +else
>> >> > +  Diag(DS.getConceptSpecLoc(),
>> >> > diag::err_concept_decl_non_template);
>> >> > +// Don't emit warnings after this error.
>> >> > +return TagD;
>> >> > +  }
>> >>
>> >> I'm not certain I understand why we need two different diagnostics
>> for
>>

Re: [PATCH] D11928: Small fixup

2015-08-11 Thread Nathan Wilson via cfe-commits
nwilson added a subscriber: nwilson.
nwilson added a comment.

Hi Piotr,

Would you mind renaming the title of the Patch since the title will be
committed as such?

Thanks!


http://reviews.llvm.org/D11928



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11916: [CONCEPTS] Add diagnostic; invalid tag when concept specified

2015-08-12 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 31957.
nwilson added a comment.

Addressing comments which were discussed on the mailing list - Apply the same 
text when diagnosing a free standing declaration as suggested by Aaron. Replace 
diagnostic identifier err_concept_decl_non_template with 
err_concept_wrong_decl_kind as suggested by Hubert and Richard.  Fix tests 
corresponding to the changes.


http://reviews.llvm.org/D11916

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/cxx-concept-declaration.cpp

Index: test/SemaCXX/cxx-concept-declaration.cpp
===
--- test/SemaCXX/cxx-concept-declaration.cpp
+++ test/SemaCXX/cxx-concept-declaration.cpp
@@ -23,3 +23,13 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be 
initialized}}
 
+// Tag
+concept class CC1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept struct CS1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept union CU1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept enum CE1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+template  concept class TCC1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+template  concept struct TCS1 {}; // expected-error {{'concept' 
can only appear on the definition of a function template or variable template}}
+template  concept union TCU1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+
+concept bool; // expected-error {{'concept' can only appear on the definition 
of a function template or variable template}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3662,6 +3662,14 @@
 return TagD;
   }
 
+  if (DS.isConceptSpecified()) {
+// C++ Concepts TS [dcl.spec.concept]p1: A concept definition refers to
+// either a function concept and its definition or a variable concept and
+// its initializer.
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
+return TagD;
+  }
+
   DiagnoseFunctionSpecifiers(DS);
 
   if (DS.isFriendSpecified()) {
@@ -4865,7 +4873,7 @@
 // template, declared in namespace scope
 if (!TemplateParamLists.size()) {
   Diag(D.getDeclSpec().getConceptSpecLoc(),
-   diag::err_concept_decl_non_template);
+   diag:: err_concept_wrong_decl_kind);
   return nullptr;
 }
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1965,7 +1965,7 @@
   "use __attribute__((visibility(\"hidden\"))) attribute instead">;
 
 // C++ Concepts TS
-def err_concept_decl_non_template : Error<
+def err_concept_wrong_decl_kind : Error<
   "'concept' can only appear on the definition of a function template or 
variable template">;
 def err_concept_decls_may_only_appear_in_namespace_scope : Error<
   "concept declarations may only appear in namespace scope">;


Index: test/SemaCXX/cxx-concept-declaration.cpp
===
--- test/SemaCXX/cxx-concept-declaration.cpp
+++ test/SemaCXX/cxx-concept-declaration.cpp
@@ -23,3 +23,13 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+// Tag
+concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept union CU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept enum CE1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+template  concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+template  concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+template  concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: lib/Sema/SemaDecl.cpp
=

Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-14 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Ping


http://reviews.llvm.org/D11789



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r245123 - [CONCEPTS] Add diagnostic; invalid tag when concept specified

2015-08-14 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Fri Aug 14 18:19:32 2015
New Revision: 245123

URL: http://llvm.org/viewvc/llvm-project?rev=245123&view=rev
Log:
[CONCEPTS] Add diagnostic; invalid tag when concept specified

Summary: Adding check to emit diagnostic for invalid tag when concept is 
specified and associated tests.

Reviewers: rsmith, hubert.reinterpretcast, fraggamuffin, faisalv, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

Differential Revision: http://reviews.llvm.org/D11916

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=245123&r1=245122&r2=245123&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 14 18:19:32 
2015
@@ -1969,7 +1969,7 @@ def note_private_extern : Note<
   "use __attribute__((visibility(\"hidden\"))) attribute instead">;
 
 // C++ Concepts TS
-def err_concept_decl_non_template : Error<
+def err_concept_wrong_decl_kind : Error<
   "'concept' can only appear on the definition of a function template or 
variable template">;
 def err_concept_decls_may_only_appear_in_namespace_scope : Error<
   "concept declarations may only appear in namespace scope">;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=245123&r1=245122&r2=245123&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 14 18:19:32 2015
@@ -3662,6 +3662,14 @@ Decl *Sema::ParsedFreeStandingDeclSpec(S
 return TagD;
   }
 
+  if (DS.isConceptSpecified()) {
+// C++ Concepts TS [dcl.spec.concept]p1: A concept definition refers to
+// either a function concept and its definition or a variable concept and
+// its initializer.
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
+return TagD;
+  }
+
   DiagnoseFunctionSpecifiers(DS);
 
   if (DS.isFriendSpecified()) {
@@ -4865,7 +4873,7 @@ NamedDecl *Sema::HandleDeclarator(Scope
 // template, declared in namespace scope
 if (!TemplateParamLists.size()) {
   Diag(D.getDeclSpec().getConceptSpecLoc(),
-   diag::err_concept_decl_non_template);
+   diag:: err_concept_wrong_decl_kind);
   return nullptr;
 }
 

Modified: cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp?rev=245123&r1=245122&r2=245123&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp Fri Aug 14 18:19:32 2015
@@ -23,3 +23,13 @@ concept bool D5 = true; // expected-erro
 template
 concept bool D6; // expected-error {{variable concept declaration must be 
initialized}}
 
+// Tag
+concept class CC1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept struct CS1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept union CU1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept enum CE1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+template  concept class TCC1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+template  concept struct TCS1 {}; // expected-error {{'concept' 
can only appear on the definition of a function template or variable template}}
+template  concept union TCU1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+
+concept bool; // expected-error {{'concept' can only appear on the definition 
of a function template or variable template}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11916: [CONCEPTS] Add diagnostic; invalid tag when concept specified

2015-08-14 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL245123: [CONCEPTS] Add diagnostic; invalid tag when concept 
specified (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D11916?vs=31957&id=32200#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11916

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1969,7 +1969,7 @@
   "use __attribute__((visibility(\"hidden\"))) attribute instead">;
 
 // C++ Concepts TS
-def err_concept_decl_non_template : Error<
+def err_concept_wrong_decl_kind : Error<
   "'concept' can only appear on the definition of a function template or 
variable template">;
 def err_concept_decls_may_only_appear_in_namespace_scope : Error<
   "concept declarations may only appear in namespace scope">;
Index: cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
===
--- cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
+++ cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
@@ -23,3 +23,13 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be 
initialized}}
 
+// Tag
+concept class CC1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept struct CS1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept union CU1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+concept enum CE1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+template  concept class TCC1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+template  concept struct TCS1 {}; // expected-error {{'concept' 
can only appear on the definition of a function template or variable template}}
+template  concept union TCU1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+
+concept bool; // expected-error {{'concept' can only appear on the definition 
of a function template or variable template}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -3662,6 +3662,14 @@
 return TagD;
   }
 
+  if (DS.isConceptSpecified()) {
+// C++ Concepts TS [dcl.spec.concept]p1: A concept definition refers to
+// either a function concept and its definition or a variable concept and
+// its initializer.
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
+return TagD;
+  }
+
   DiagnoseFunctionSpecifiers(DS);
 
   if (DS.isFriendSpecified()) {
@@ -4865,7 +4873,7 @@
 // template, declared in namespace scope
 if (!TemplateParamLists.size()) {
   Diag(D.getDeclSpec().getConceptSpecLoc(),
-   diag::err_concept_decl_non_template);
+   diag:: err_concept_wrong_decl_kind);
   return nullptr;
 }
 


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1969,7 +1969,7 @@
   "use __attribute__((visibility(\"hidden\"))) attribute instead">;
 
 // C++ Concepts TS
-def err_concept_decl_non_template : Error<
+def err_concept_wrong_decl_kind : Error<
   "'concept' can only appear on the definition of a function template or variable template">;
 def err_concept_decls_may_only_appear_in_namespace_scope : Error<
   "concept declarations may only appear in namespace scope">;
Index: cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
===
--- cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
+++ cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
@@ -23,3 +23,13 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+// Tag
+concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept union CU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+concept enum CE1 {}; // expected-error {{'concept' can only appear

Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-15 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 32228.
nwilson added a comment.

Patch addressing comments; fix comment/documentation wording, scoping of 
diagnostic and setting invalid declaration, and fix test.

I also modified the location of the diagnostic indicating an exception 
specification is not allowed to point to the function declarator in order to 
handle a range having an invalid begin location.

The 80 column limit was overrun in SemaType.cpp, so clang format has been run 
on the problematic lines in the file.


http://reviews.llvm.org/D11789

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaCXX/cxx-concept-declaration.cpp

Index: test/SemaCXX/cxx-concept-declaration.cpp
===
--- test/SemaCXX/cxx-concept-declaration.cpp
+++ test/SemaCXX/cxx-concept-declaration.cpp
@@ -1,11 +1,14 @@
-// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s
 
 namespace A {
   template concept bool C1() { return true; }
 
   template concept bool C2 = true;
 }
 
+template concept bool C3() { return (throw 0, true); }
+static_assert(noexcept(C3()), "function concept should be treated as if noexcept(true) specified");
+
 template concept bool D1(); // expected-error {{function concept declaration must be a definition}}
 
 struct B {
@@ -23,6 +26,9 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+template
+concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}}
+
 // Tag
 concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -700,7 +700,7 @@
   /*VolatileQualifierLoc=*/NoLoc,
   /*RestrictQualifierLoc=*/NoLoc,
   /*MutableLoc=*/NoLoc, EST_None,
-  /*ESpecLoc=*/NoLoc,
+  /*ESpecRange=*/SourceRange(),
   /*Exceptions=*/nullptr,
   /*ExceptionRanges=*/nullptr,
   /*NumExceptions=*/0,
@@ -3833,9 +3833,10 @@
   // Exception specs are not allowed in typedefs. Complain, but add it
   // anyway.
   if (IsTypedefName && FTI.getExceptionSpecType())
-S.Diag(FTI.getExceptionSpecLoc(), diag::err_exception_spec_in_typedef)
-  << (D.getContext() == Declarator::AliasDeclContext ||
-  D.getContext() == Declarator::AliasTemplateContext);
+S.Diag(FTI.getExceptionSpecLocBeg(),
+   diag::err_exception_spec_in_typedef)
+<< (D.getContext() == Declarator::AliasDeclContext ||
+D.getContext() == Declarator::AliasTemplateContext);
 
   // If we see "T var();" or "T var(T());" at block scope, it is probably
   // an attempt to initialize a variable, not a function declaration.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7466,6 +7466,22 @@
 NewFD->setInvalidDecl();
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: [...] A function concept shall
+  // have no exception-specification and is treated as if it were specified
+  // with noexcept(true) (15.4). [...]
+  if (const FunctionProtoType *FPT = R->getAs()) {
+if (FPT->hasExceptionSpec()) {
+  SourceRange Range;
+  if (D.isFunctionDeclarator())
+Range = D.getFunctionTypeInfo().getExceptionSpecRange();
+  Diag(NewFD->getLocation(), diag::err_function_concept_exception_spec)
+  << FixItHint::CreateRemoval(Range);
+  NewFD->setInvalidDecl();
+} else {
+  Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
+}
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
   // implicity defined to be a constexpr declaration (implicitly inline)
   NewFD->setImplicitlyInline();
@@ -11099,7 +5,7 @@
  /*RestrictQualifierLoc=*/NoLoc,
  /*MutableLoc=*/NoLoc,
  EST_None,
- /*ESpecLoc=*/NoLoc,
+ /*ESpecRange=*/SourceRange(),
  /*Exceptions=*/nullptr,
  /*ExceptionRanges=*/nullptr,
  

Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Ping


http://reviews.llvm.org/D11789



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 33093.

http://reviews.llvm.org/D11789

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaCXX/cxx-concept-declaration.cpp

Index: test/SemaCXX/cxx-concept-declaration.cpp
===
--- test/SemaCXX/cxx-concept-declaration.cpp
+++ test/SemaCXX/cxx-concept-declaration.cpp
@@ -1,11 +1,14 @@
-// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s
 
 namespace A {
   template concept bool C1() { return true; }
 
   template concept bool C2 = true;
 }
 
+template concept bool C3() { return (throw 0, true); }
+static_assert(noexcept(C3()), "function concept should be treated as if noexcept(true) specified");
+
 template concept bool D1(); // expected-error {{function concept declaration must be a definition}}
 
 struct B {
@@ -23,6 +26,9 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+template
+concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}}
+
 // Tag
 concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -700,7 +700,7 @@
   /*VolatileQualifierLoc=*/NoLoc,
   /*RestrictQualifierLoc=*/NoLoc,
   /*MutableLoc=*/NoLoc, EST_None,
-  /*ESpecLoc=*/NoLoc,
+  /*ESpecRange=*/SourceRange(),
   /*Exceptions=*/nullptr,
   /*ExceptionRanges=*/nullptr,
   /*NumExceptions=*/0,
@@ -3833,9 +3833,10 @@
   // Exception specs are not allowed in typedefs. Complain, but add it
   // anyway.
   if (IsTypedefName && FTI.getExceptionSpecType())
-S.Diag(FTI.getExceptionSpecLoc(), diag::err_exception_spec_in_typedef)
-  << (D.getContext() == Declarator::AliasDeclContext ||
-  D.getContext() == Declarator::AliasTemplateContext);
+S.Diag(FTI.getExceptionSpecLocBeg(),
+   diag::err_exception_spec_in_typedef)
+<< (D.getContext() == Declarator::AliasDeclContext ||
+D.getContext() == Declarator::AliasTemplateContext);
 
   // If we see "T var();" or "T var(T());" at block scope, it is probably
   // an attempt to initialize a variable, not a function declaration.
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7476,6 +7476,22 @@
 NewFD->setInvalidDecl();
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: [...] A function concept shall
+  // have no exception-specification and is treated as if it were specified
+  // with noexcept(true) (15.4). [...]
+  if (const FunctionProtoType *FPT = R->getAs()) {
+if (FPT->hasExceptionSpec()) {
+  SourceRange Range;
+  if (D.isFunctionDeclarator())
+Range = D.getFunctionTypeInfo().getExceptionSpecRange();
+  Diag(NewFD->getLocation(), diag::err_function_concept_exception_spec)
+  << FixItHint::CreateRemoval(Range);
+  NewFD->setInvalidDecl();
+} else {
+  Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
+}
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
   // implicity defined to be a constexpr declaration (implicitly inline)
   NewFD->setImplicitlyInline();
@@ -11123,7 +11139,7 @@
  /*RestrictQualifierLoc=*/NoLoc,
  /*MutableLoc=*/NoLoc,
  EST_None,
- /*ESpecLoc=*/NoLoc,
+ /*ESpecRange=*/SourceRange(),
  /*Exceptions=*/nullptr,
  /*ExceptionRanges=*/nullptr,
  /*NumExceptions=*/0,
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -177,7 +177,7 @@
  SourceLocation MutableLoc,
  ExceptionSpecificationType
  ESpecType,
- SourceLocation

Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL246005: Modify DeclaratorChuck::getFunction to be passed an 
Exception Specification… (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D11789?vs=33093&id=33177#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11789

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/DeclSpec.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/lib/Sema/DeclSpec.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1977,6 +1977,8 @@
   "function concept declaration must be a definition">;
 def err_var_concept_not_initialized : Error<
   "variable concept declaration must be initialized">;
+def err_function_concept_exception_spec : Error<
+  "function concept cannot have exception specification">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<
Index: cfe/trunk/include/clang/Sema/DeclSpec.h
===
--- cfe/trunk/include/clang/Sema/DeclSpec.h
+++ cfe/trunk/include/clang/Sema/DeclSpec.h
@@ -1255,8 +1255,11 @@
 /// any.
 unsigned MutableLoc;
 
-/// \brief The location of the keyword introducing the spec, if any.
-unsigned ExceptionSpecLoc;
+/// \brief The beginning location of the exception specification, if any.
+unsigned ExceptionSpecLocBeg;
+
+/// \brief The end location of the exception specification, if any.
+unsigned ExceptionSpecLocEnd;
 
 /// Params - This is a pointer to a new[]'d array of ParamInfo objects that
 /// describe the parameters specified by this function declarator.  null if
@@ -1323,8 +1326,16 @@
   return SourceLocation::getFromRawEncoding(RParenLoc);
 }
 
-SourceLocation getExceptionSpecLoc() const {
-  return SourceLocation::getFromRawEncoding(ExceptionSpecLoc);
+SourceLocation getExceptionSpecLocBeg() const {
+  return SourceLocation::getFromRawEncoding(ExceptionSpecLocBeg);
+}
+
+SourceLocation getExceptionSpecLocEnd() const {
+  return SourceLocation::getFromRawEncoding(ExceptionSpecLocEnd);
+}
+
+SourceRange getExceptionSpecRange() const {
+  return SourceRange(getExceptionSpecLocBeg(), getExceptionSpecLocEnd());
 }
 
 /// \brief Retrieve the location of the ref-qualifier, if any.
@@ -1496,7 +1507,7 @@
  SourceLocation RestrictQualifierLoc,
  SourceLocation MutableLoc,
  ExceptionSpecificationType ESpecType,
- SourceLocation ESpecLoc,
+ SourceRange ESpecRange,
  ParsedType *Exceptions,
  SourceRange *ExceptionRanges,
  unsigned NumExceptions,
Index: cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
===
--- cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
+++ cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp
@@ -1,11 +1,14 @@
-// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s
 
 namespace A {
   template concept bool C1() { return true; }
 
   template concept bool C2 = true;
 }
 
+template concept bool C3() { return (throw 0, true); }
+static_assert(noexcept(C3()), "function concept should be treated as if noexcept(true) specified");
+
 template concept bool D1(); // expected-error {{function concept declaration must be a definition}}
 
 struct B {
@@ -23,6 +26,9 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+template
+concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}}
+
 // Tag
 concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -700,7 +700,7 @@
   /*VolatileQualifierLoc=*/NoLoc,
   /*RestrictQualifierLoc=*/NoLoc,
   /*MutableLoc=*/NoLoc, EST_None,
-  /*ESpecLoc=*/NoLoc,
+  /*ESpecRange=*/SourceR

r246005 - Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-25 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Tue Aug 25 23:19:36 2015
New Revision: 246005

URL: http://llvm.org/viewvc/llvm-project?rev=246005&view=rev
Log:
Modify DeclaratorChuck::getFunction to be passed an Exception Specification 
SourceRange

Summary:
- Store the exception specification range's begin and end SourceLocation in 
DeclaratorChuck::FunctionTypeInfo. These SourceLocations can be used in a 
FixItHint Range.
- Add diagnostic; function concept having an exception specification.


Reviewers: hubert.reinterpretcast, fraggamuffin, faisalv, aaron.ballman, rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11789

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/cxx-concept-declaration.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=246005&r1=246004&r2=246005&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Aug 25 23:19:36 
2015
@@ -1977,6 +1977,8 @@ def err_function_concept_not_defined : E
   "function concept declaration must be a definition">;
 def err_var_concept_not_initialized : Error<
   "variable concept declaration must be initialized">;
+def err_function_concept_exception_spec : Error<
+  "function concept cannot have exception specification">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=246005&r1=246004&r2=246005&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Tue Aug 25 23:19:36 2015
@@ -1255,8 +1255,11 @@ struct DeclaratorChunk {
 /// any.
 unsigned MutableLoc;
 
-/// \brief The location of the keyword introducing the spec, if any.
-unsigned ExceptionSpecLoc;
+/// \brief The beginning location of the exception specification, if any.
+unsigned ExceptionSpecLocBeg;
+
+/// \brief The end location of the exception specification, if any.
+unsigned ExceptionSpecLocEnd;
 
 /// Params - This is a pointer to a new[]'d array of ParamInfo objects that
 /// describe the parameters specified by this function declarator.  null if
@@ -1323,8 +1326,16 @@ struct DeclaratorChunk {
   return SourceLocation::getFromRawEncoding(RParenLoc);
 }
 
-SourceLocation getExceptionSpecLoc() const {
-  return SourceLocation::getFromRawEncoding(ExceptionSpecLoc);
+SourceLocation getExceptionSpecLocBeg() const {
+  return SourceLocation::getFromRawEncoding(ExceptionSpecLocBeg);
+}
+
+SourceLocation getExceptionSpecLocEnd() const {
+  return SourceLocation::getFromRawEncoding(ExceptionSpecLocEnd);
+}
+
+SourceRange getExceptionSpecRange() const {
+  return SourceRange(getExceptionSpecLocBeg(), getExceptionSpecLocEnd());
 }
 
 /// \brief Retrieve the location of the ref-qualifier, if any.
@@ -1496,7 +1507,7 @@ struct DeclaratorChunk {
  SourceLocation RestrictQualifierLoc,
  SourceLocation MutableLoc,
  ExceptionSpecificationType ESpecType,
- SourceLocation ESpecLoc,
+ SourceRange ESpecRange,
  ParsedType *Exceptions,
  SourceRange *ExceptionRanges,
  unsigned NumExceptions,

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=246005&r1=246004&r2=246005&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Aug 25 23:19:36 2015
@@ -5620,7 +5620,7 @@ void Parser::ParseFunctionDeclarator(Dec
  VolatileQualifierLoc,
  RestrictQualifierLoc,
  /*MutableLoc=*/SourceLocation(),
- ESpecType, ESpecRange.getBegin(),
+ ESpecType, ESpecRange,
  DynamicExceptions.data(),

[PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-08-28 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, 
faisalv, fraggamuffin.
nwilson added a subscriber: cfe-commits.

Diagnose variable and function concept declarations when an invalid specifier 
appears

http://reviews.llvm.org/D12435

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
@@ -0,0 +1,9 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error 
{{variable concept cannot be declared with thread_local specified}}
+
+template concept constexpr bool VCC = true; // expected-error 
{{variable concept cannot be declared with constexpr specified}}
+
+template concept constexpr bool FCC() { return true; } // 
expected-error {{function concept cannot be declared with constexpr specified}}
+
+template concept inline bool FCI() { return true; } // 
expected-error {{function concept cannot be declared with inline specified}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5871,8 +5871,26 @@
 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_sepcifiers)
+<< 0 << 0;
+NewVD->setInvalidDecl(true);
+  }
+
+  if (D.getDeclSpec().isConstexprSpecified()) {
+Diag(D.getDeclSpec().getConstexprSpecLoc(),
+ diag::err_concept_decl_invalid_sepcifiers)
+<< 0 << 1;
+NewVD->setInvalidDecl(true);
+  }
+}
   }
 
   // Set the lexical context. If the declarator has a C++ scope specifier, the
@@ -7497,6 +7515,23 @@
   // 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 (isConstexpr) {
+Diag(D.getDeclSpec().getConstexprSpecLoc(),
+ diag::err_concept_decl_invalid_sepcifiers)
+<< 1 << 1;
+NewFD->setInvalidDecl(true);
+  }
+
+  if (isInline) {
+Diag(D.getDeclSpec().getInlineSpecLoc(),
+ diag::err_concept_decl_invalid_sepcifiers)
+<< 1 << 2;
+NewFD->setInvalidDecl(true);
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1979,6 +1979,9 @@
   "variable concept declaration must be initialized">;
 def err_function_concept_exception_spec : Error<
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_sepcifiers : Error<
+  "%select{variable|function}0 concept cannot be declared with "
+  "%select{thread_local|constexpr|inline}1 specified">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
@@ -0,0 +1,9 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error {{variable concept cannot be declared with thread_local specified}}
+
+template concept constexpr bool VCC = true; // expected-error {{variable concept cannot be declared with constexpr specified}}
+
+template concept constexpr bool FCC() { return true; } // expected-error {{function concept cannot be declared with constexpr specified}}
+
+template concept inline bool FCI() { return true; } // expected-error {{function concept cannot be declared with inline specified}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5871,8 +5871,26 @@
 if (D.getDeclSpec().is

Re: [PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-08-28 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1982
@@ -1981,1 +1981,3 @@
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_sepcifiers : Error<
+  "%select{variable|function}0 concept cannot be declared with "

hubert.reinterpretcast wrote:
> The wording seems unwieldy. There are a number of messages of the form:
> 
> > [ ... ] cannot be declared ''
> 
> Perhaps something along those lines would work here?
> 
> btw, there's a typo in the message identifier.
I'll fix the typo. Thanks. I can change the wording as well; I don't feel too 
strongly about it unless someone has a different opinion. Are you okay with the 
second select?

So, it would be:
"%select{variable|function}0 concept cannot be declared 
%select{thread_local|constexpr|inline}1"


http://reviews.llvm.org/D12435



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-08-31 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 33587.
nwilson added a comment.

Change the wording of diagnostic message and quote the invalid specifier. Add 
'friend' as an invalid specifier and diagnose function concepts when 'friend' 
is specified. Reorder the list of invalid specifiers and corresponding checks 
in the code to match the TS.


http://reviews.llvm.org/D12435

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error 
{{variable concept cannot be declared 'thread_local'}}
+
+template concept constexpr bool VCC = true; // expected-error 
{{variable concept cannot be declared 'constexpr'}}
+
+template concept inline bool FCI() { return true; } // 
expected-error {{function concept cannot be declared 'inline'}}
+
+struct X {
+  template concept friend bool FCF() { return true; } // 
expected-error {{function concept cannot be declared 'friend'}}
+};
+
+template concept constexpr bool FCC() { return true; } // 
expected-error {{function concept cannot be declared 'constexpr'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5871,8 +5871,26 @@
 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
@@ -7497,6 +7515,30 @@
   // 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.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1979,6 +1979,9 @@
   "variable concept declaration must be initialized">;
 def err_function_concept_exception_spec : Error<
   "function concept cannot have exception specification">;
+def err_concept_decl_invalid_specifiers : Error<
+  "%select{variable|function}0 concept cannot be declared "
+  "'%select{thread_local|inline|friend|constexpr}1'">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/p2.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template concept thread_local bool VCTL = true; // expected-error {{variable concept cannot be declared 'thread_local'}}
+
+template concept constexpr bool VCC = true; // expected-error {{variable concept cannot be declared 'constexpr'}}
+
+template concept inline bool FCI() { return true; } // expected-error {{function concept cannot be declared 'inline'}}
+
+struct

Re: [PATCH] D12435: [Concepts] Add diagnostic; invalid specifier on function or variable concept declaration

2015-09-04 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Ping


http://reviews.llvm.org/D12435



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r249934 - [Concepts] Fixing Concepts TS directory structure; NFC

2015-10-09 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Fri Oct  9 21:17:39 2015
New Revision: 249934

URL: http://llvm.org/viewvc/llvm-project?rev=249934&view=rev
Log:
[Concepts] Fixing Concepts TS directory structure; NFC

Added:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/
  - copied from r249932, 
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/
Removed:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.concept/

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Add diagnostic; specializations of variable and function concepts

2015-10-12 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 37099.
nwilson added a comment.

Moving tests to the correct file.
Modifying the diagnostic id and message so it's more applicable to the checks 
in this Patch. Update the quoted sections of the standard as well.
Use ternary operator for Partial Specialization check.
Add missing period in comment.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -39,3 +39,20 @@
 template  concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7597,6 +7597,17 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope. A concept definition refers to either a
+  // function concept and its definition or a variable concept and its
+  // initializer.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag:: err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5898,6 +5898,17 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7544,6 +7555,9 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  NewFD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7595,6 +7609,16 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+NewFD->setInvalidDecl();
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7858,8 +7882,8 @@
  TemplateArgs);
 
  

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-10-12 Thread Nathan Wilson via cfe-commits
nwilson marked 2 inline comments as done.


Comment at: lib/Sema/SemaDecl.cpp:7886
@@ -7863,1 +7885,3 @@
+
+  if (NewFD->isInvalidDecl() && !NewFD->isConcept()) {
 HasExplicitTemplateArgs = false;

Maybe there could be a problem further down if we think there aren't explicit 
template args and there really are. We could do a check similar to the isFriend 
check in the same block below like this:

else if (isConcept && isFunctionTemplateSpecialization) {
  HasExplicitTemplateArgs = true;
}

But it seems like that's essentially the same thing. 




http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-10-15 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 37529.
nwilson added a comment.

Addressing Richard's other comment regarding the FunctionDecl being declared a 
concept check. Also, remove setting the FunctionDecl being Invalid in the 
Specialization check since the downstream parts of Clang should look at the 
primary template.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -39,3 +39,20 @@
 template  concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7597,6 +7597,17 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope. A concept definition refers to either a
+  // function concept and its definition or a variable concept and its
+  // initializer.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag:: err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5898,6 +5898,17 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7544,6 +7555,9 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  NewFD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7595,6 +7609,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7858,7 +7881,7 @@
  TemplateArgs);
 
   HasExplicitTemplateArgs = true;
-
+
 

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-10-22 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/Decl.h:1577
@@ -1576,2 +1576,3 @@
   bool IsConstexpr : 1;
+  bool IsConcept : 1;
 

faisalv wrote:
> My inclination would have been to add this bit to FunctionTemplateDecl, 
> instead of to every FunctionDecl - since not every kind of FunctionDecl can 
> be a concept ...  My first instinct would have been to add an enum to 
> TemplateKind, and then forward isConcept() to check if we are a template and 
> if so, through it, if concept is specified?  
> 
> But I suppose that adds more complexity, and you trade space for speed - For 
> my own edification, could I ask you or Richard to comment on the cons of that 
> approach - and why the current approach is preferred? (i.e. simplicity over 
> complexity or space over time etc.)
Sorry for the slow reply. Yeah, I thought it was a little more straightforward 
having isConcept as a member function of FunctionDecl (and the bit). It also 
seemed that we'd be okay in terms of size since 17 bits are already being used 
here and adding one more wouldn't go over a byte boundary. Maybe Richard has 
other thoughts though?


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-11-02 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 39030.
nwilson added a comment.

Updating to r251898


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -39,3 +39,20 @@
 template  concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7597,6 +7597,17 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope. A concept definition refers to either a
+  // function concept and its definition or a variable concept and its
+  // initializer.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag:: err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5898,6 +5898,17 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7544,6 +7555,9 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  NewFD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7595,6 +7609,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7858,7 +7881,7 @@
  TemplateArgs);
 
   HasExplicitTemplateArgs = true;
-
+
   if (NewFD->isInvalidDecl()) {
 HasExplicitTemplateArgs = false;
   } else if (FunctionTemplate) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-11-02 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:5909
@@ +5908,3 @@
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+NewVD->setInvalidDecl(true);

Hmm, I'd lean toward leaving it as is until the wording is sorted out. I don't 
feel too strongly either way though.


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14316: [Concepts] Add diagnostics which fall under [dcl.spec.concept]p1

2015-11-03 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, faisalv.
nwilson added a subscriber: cfe-commits.

Diagnose when the 'concept' specifier is used on a typedef or function 
parameter.

http://reviews.llvm.org/D14316

Files:
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -37,5 +37,7 @@
 template  concept class TCC1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
 template  concept struct TCS1 {}; // expected-error {{'concept' 
can only appear on the definition of a function template or variable template}}
 template  concept union TCU1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+typedef concept int CI; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+void fpc(concept int i) {} // expected-error {{'concept' can only appear on 
the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition 
of a function template or variable template}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5119,6 +5119,9 @@
   if (D.getDeclSpec().isConstexprSpecified())
 Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 1;
+  if (D.getDeclSpec().isConceptSpecified())
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_wrong_decl_kind);
 
   if (D.getName().Kind != UnqualifiedId::IK_Identifier) {
 Diag(D.getName().StartLocation, diag::err_typedef_not_identifier)
@@ -10277,6 +10280,8 @@
   if (DS.isConstexprSpecified())
 Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 0;
+  if (DS.isConceptSpecified())
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
 
   DiagnoseFunctionSpecifiers(DS);
 


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -37,5 +37,7 @@
 template  concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 template  concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 template  concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+typedef concept int CI; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5119,6 +5119,9 @@
   if (D.getDeclSpec().isConstexprSpecified())
 Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 1;
+  if (D.getDeclSpec().isConceptSpecified())
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_wrong_decl_kind);
 
   if (D.getName().Kind != UnqualifiedId::IK_Identifier) {
 Diag(D.getName().StartLocation, diag::err_typedef_not_identifier)
@@ -10277,6 +10280,8 @@
   if (DS.isConstexprSpecified())
 Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 0;
+  if (DS.isConceptSpecified())
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
 
   DiagnoseFunctionSpecifiers(DS);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252061 - [Concepts] Add diagnostics which fall under [dcl.spec.concept]p1

2015-11-04 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Wed Nov  4 12:18:35 2015
New Revision: 252061

URL: http://llvm.org/viewvc/llvm-project?rev=252061&view=rev
Log:
[Concepts] Add diagnostics which fall under [dcl.spec.concept]p1

Summary: Diagnose when the 'concept' specifier is used on a typedef or function 
parameter.

Reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, faisalv

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D14316

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=252061&r1=252060&r2=252061&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov  4 12:18:35 2015
@@ -5119,6 +5119,9 @@ Sema::ActOnTypedefDeclarator(Scope* S, D
   if (D.getDeclSpec().isConstexprSpecified())
 Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 1;
+  if (D.getDeclSpec().isConceptSpecified())
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_wrong_decl_kind);
 
   if (D.getName().Kind != UnqualifiedId::IK_Identifier) {
 Diag(D.getName().StartLocation, diag::err_typedef_not_identifier)
@@ -10277,6 +10280,8 @@ Decl *Sema::ActOnParamDeclarator(Scope *
   if (DS.isConstexprSpecified())
 Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 0;
+  if (DS.isConceptSpecified())
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
 
   DiagnoseFunctionSpecifiers(DS);
 

Modified: 
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp?rev=252061&r1=252060&r2=252061&view=diff
==
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp 
(original)
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp Wed 
Nov  4 12:18:35 2015
@@ -37,5 +37,7 @@ concept enum CE1 {}; // expected-error {
 template  concept class TCC1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
 template  concept struct TCS1 {}; // expected-error {{'concept' 
can only appear on the definition of a function template or variable template}}
 template  concept union TCU1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+typedef concept int CI; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+void fpc(concept int i) {} // expected-error {{'concept' can only appear on 
the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition 
of a function template or variable template}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14316: [Concepts] Add diagnostics which fall under [dcl.spec.concept]p1

2015-11-04 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252061: [Concepts] Add diagnostics which fall under 
[dcl.spec.concept]p1 (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D14316?vs=39151&id=39215#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14316

Files:
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -37,5 +37,7 @@
 template  concept class TCC1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
 template  concept struct TCS1 {}; // expected-error {{'concept' 
can only appear on the definition of a function template or variable template}}
 template  concept union TCU1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+typedef concept int CI; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+void fpc(concept int i) {} // expected-error {{'concept' can only appear on 
the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition 
of a function template or variable template}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -5119,6 +5119,9 @@
   if (D.getDeclSpec().isConstexprSpecified())
 Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 1;
+  if (D.getDeclSpec().isConceptSpecified())
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_wrong_decl_kind);
 
   if (D.getName().Kind != UnqualifiedId::IK_Identifier) {
 Diag(D.getName().StartLocation, diag::err_typedef_not_identifier)
@@ -10277,6 +10280,8 @@
   if (DS.isConstexprSpecified())
 Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 0;
+  if (DS.isConceptSpecified())
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
 
   DiagnoseFunctionSpecifiers(DS);
 


Index: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -37,5 +37,7 @@
 template  concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 template  concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 template  concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+typedef concept int CI; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -5119,6 +5119,9 @@
   if (D.getDeclSpec().isConstexprSpecified())
 Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 1;
+  if (D.getDeclSpec().isConceptSpecified())
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_wrong_decl_kind);
 
   if (D.getName().Kind != UnqualifiedId::IK_Identifier) {
 Diag(D.getName().StartLocation, diag::err_typedef_not_identifier)
@@ -10277,6 +10280,8 @@
   if (DS.isConstexprSpecified())
 Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 0;
+  if (DS.isConceptSpecified())
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
 
   DiagnoseFunctionSpecifiers(DS);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14352: Add diagnostics which fall under [dcl.spec.concept]p5

2015-11-04 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, faisalv, hubert.reinterpretcast, aaron.ballman.
nwilson added a subscriber: cfe-commits.

Diagnose when a function concept declaration has parameter(s)

http://reviews.llvm.org/D14352

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,7 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function 
concept cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// — The declaration’s parameter list shall be equivalent to an empty
+//   parameter list.
+if (FPT->getNumParams() > 0)
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,7 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function concept cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// — The declaration’s parameter list shall be equivalent to an empty
+//   parameter list.
+if (FPT->getNumParams() > 0)
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14352: Add diagnostics which fall under [dcl.spec.concept]p5

2015-11-04 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 39314.
nwilson added a comment.

- Cover variadic arguments in check for no params.
- Add tests to cover variadic arguments.


http://reviews.llvm.org/D14352

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept 
cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// — The declaration’s parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// — The declaration’s parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14352: Add diagnostics which fall under [dcl.spec.concept]p5

2015-11-05 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 39386.
nwilson added a comment.

- replace hyphen and apostrophe with equivalent ASCII characters


http://reviews.llvm.org/D14352

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept 
cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// - The declaration's parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7569,6 +7569,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// - The declaration's parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1990,6 +1990,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252827 - Add diagnostics which fall under [dcl.spec.concept]p5

2015-11-11 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Wed Nov 11 17:53:35 2015
New Revision: 252827

URL: http://llvm.org/viewvc/llvm-project?rev=252827&view=rev
Log:
Add diagnostics which fall under [dcl.spec.concept]p5

Summary: Diagnose when a function concept declaration has parameter(s)

Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D14352

Added:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=252827&r1=252826&r2=252827&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 11 17:53:35 
2015
@@ -1994,6 +1994,8 @@ def err_function_concept_exception_spec
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=252827&r1=252826&r2=252827&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 11 17:53:35 2015
@@ -7607,6 +7607,13 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// - The declaration's parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is

Added: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp?rev=252827&view=auto
==
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp 
(added)
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp Wed 
Nov 11 17:53:35 2015
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept 
cannot have any parameters}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14352: Add diagnostics which fall under [dcl.spec.concept]p5

2015-11-11 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252827: Add diagnostics which fall under 
[dcl.spec.concept]p5 (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D14352?vs=39386&id=39986#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14352

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1994,6 +1994,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<
Index: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function 
concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept 
cannot have any parameters}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -7607,6 +7607,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// - The declaration's parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1994,6 +1994,8 @@
 def err_concept_decl_invalid_specifiers : Error<
   "%select{variable|function}0 concept cannot be declared "
   "'%select{thread_local|inline|friend|constexpr}1'">;
+def err_function_concept_with_params : Error<
+  "function concept cannot have any parameters">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<
Index: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -0,0 +1,13 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool fcpv(void) { return true; }
+
+template
+concept bool fcpi(int i = 0) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept bool fcpp(Ts... ts) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -7607,6 +7607,13 @@
 } else {
   Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
 }
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// - The declaration's parameter list shall be equivalent to an empty
+//   parameter list.
+if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+  Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252855 - [Sema] Remove unnecessary parens in check using logical or; NFC.

2015-11-11 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Wed Nov 11 22:25:03 2015
New Revision: 252855

URL: http://llvm.org/viewvc/llvm-project?rev=252855&view=rev
Log:
[Sema] Remove unnecessary parens in check using logical or; NFC.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=252855&r1=252854&r2=252855&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 11 22:25:03 2015
@@ -7612,7 +7612,7 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 // following restrictions:
 // - The declaration's parameter list shall be equivalent to an empty
 //   parameter list.
-if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
+if (FPT->getNumParams() > 0 || FPT->isVariadic())
   Diag(NewFD->getLocation(), diag::err_function_concept_with_params);
   }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r252827 - Add diagnostics which fall under [dcl.spec.concept]p5

2015-11-11 Thread Nathan Wilson via cfe-commits
On Wed, Nov 11, 2015 at 6:59 PM, Richard Smith 
wrote:

> On Wed, Nov 11, 2015 at 3:53 PM, Nathan Wilson via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: nwilson
>> Date: Wed Nov 11 17:53:35 2015
>> New Revision: 252827
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=252827&view=rev
>> Log:
>> Add diagnostics which fall under [dcl.spec.concept]p5
>>
>> Summary: Diagnose when a function concept declaration has parameter(s)
>>
>> Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D14352
>>
>> Added:
>>
>> cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=252827&r1=252826&r2=252827&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 11
>> 17:53:35 2015
>> @@ -1994,6 +1994,8 @@ def err_function_concept_exception_spec
>>  def err_concept_decl_invalid_specifiers : Error<
>>"%select{variable|function}0 concept cannot be declared "
>>"'%select{thread_local|inline|friend|constexpr}1'">;
>> +def err_function_concept_with_params : Error<
>> +  "function concept cannot have any parameters">;
>>
>>  // C++11 char16_t/char32_t
>>  def warn_cxx98_compat_unicode_type : Warning<
>>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=252827&r1=252826&r2=252827&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Nov 11 17:53:35 2015
>> @@ -7607,6 +7607,13 @@ Sema::ActOnFunctionDeclarator(Scope *S,
>>  } else {
>>Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
>>  }
>> +
>> +// C++ Concepts TS [dcl.spec.concept]p5: A function concept has
>> the
>> +// following restrictions:
>> +// - The declaration's parameter list shall be equivalent to an
>> empty
>> +//   parameter list.
>> +if ((FPT->getNumParams() > 0) || (FPT->isVariadic()))
>>
>
> You don't need parens around either of these conditions.
>

Okay. Thanks. I removed them in r252855.


>
>
>> +  Diag(NewFD->getLocation(),
>> diag::err_function_concept_with_params);
>>}
>>
>>// C++ Concepts TS [dcl.spec.concept]p2: Every concept definition
>> is
>>
>> Added:
>> cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp?rev=252827&view=auto
>>
>> ==
>> ---
>> cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
>> (added)
>> +++
>> cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp Wed
>> Nov 11 17:53:35 2015
>> @@ -0,0 +1,13 @@
>> +// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
>> +
>> +template
>> +concept bool fcpv(void) { return true; }
>> +
>> +template
>> +concept bool fcpi(int i = 0) { return true; } // expected-error
>> {{function concept cannot have any parameters}}
>> +
>> +template
>> +concept bool fcpp(Ts... ts) { return true; } // expected-error
>> {{function concept cannot have any parameters}}
>> +
>> +template
>> +concept bool fcpva(...) { return true; } // expected-error {{function
>> concept cannot have any parameters}}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-06 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 31488.
nwilson added a comment.

Updated Patch based on comments; fix diagnostic spacing and phrasing, add 
getExceptionSpecRange, check FunctionTypeInfo exists, use PartialDiagnostic, 
add static_assert test for function concept being treated as noexcept(true)


http://reviews.llvm.org/D11789

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/DeclSpec.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaCXX/cxx-concept-declaration.cpp

Index: test/SemaCXX/cxx-concept-declaration.cpp
===
--- test/SemaCXX/cxx-concept-declaration.cpp
+++ test/SemaCXX/cxx-concept-declaration.cpp
@@ -6,6 +6,9 @@
   template concept bool C2 = true;
 }
 
+template concept bool C3() { return true; }
+static_assert(noexcept(C3()), "function concept should be treated as if noexcept(true) specified");
+
 template concept bool D1(); // expected-error {{function concept declaration must be a definition}}
 
 struct B {
@@ -23,3 +26,5 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+template
+concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -700,7 +700,7 @@
   /*VolatileQualifierLoc=*/NoLoc,
   /*RestrictQualifierLoc=*/NoLoc,
   /*MutableLoc=*/NoLoc, EST_None,
-  /*ESpecLoc=*/NoLoc,
+  /*ESpecRange=*/SourceRange(),
   /*Exceptions=*/nullptr,
   /*ExceptionRanges=*/nullptr,
   /*NumExceptions=*/0,
@@ -3833,7 +3833,7 @@
   // Exception specs are not allowed in typedefs. Complain, but add it
   // anyway.
   if (IsTypedefName && FTI.getExceptionSpecType())
-S.Diag(FTI.getExceptionSpecLoc(), diag::err_exception_spec_in_typedef)
+S.Diag(FTI.getExceptionSpecLocBeg(), diag::err_exception_spec_in_typedef)
   << (D.getContext() == Declarator::AliasDeclContext ||
   D.getContext() == Declarator::AliasTemplateContext);
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7442,6 +7442,25 @@
 NewFD->setInvalidDecl();
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: [...] A function concept shall
+  // have no exception-specification and is treated as if it were specified
+  // with noexcept(true) (15.4). [...]
+  if (const FunctionProtoType *FPT = R->getAs()) {
+SourceRange Range;
+if (FPT->hasExceptionSpec() && D.isFunctionDeclarator()) {
+  Range = D.getFunctionTypeInfo().getExceptionSpecRange();
+  PartialDiagnostic PD =
+  PDiag(diag::err_function_concept_exception_spec);
+  if (Range.isValid()) {
+PD << FixItHint::CreateRemoval(Range);
+  }
+  Diag(NewFD->getLocation(), PD);
+  NewFD->setInvalidDecl();
+} else {
+  Context.adjustExceptionSpec(NewFD, EST_BasicNoexcept);
+}
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p2: Every concept definition is
   // implicity defined to be a constexpr declaration (implicitly inline)
   NewFD->setImplicitlyInline();
@@ -11075,7 +11094,7 @@
  /*RestrictQualifierLoc=*/NoLoc,
  /*MutableLoc=*/NoLoc,
  EST_None,
- /*ESpecLoc=*/NoLoc,
+ /*ESpecRange=*/SourceRange(),
  /*Exceptions=*/nullptr,
  /*ExceptionRanges=*/nullptr,
  /*NumExceptions=*/0,
Index: lib/Sema/DeclSpec.cpp
===
--- lib/Sema/DeclSpec.cpp
+++ lib/Sema/DeclSpec.cpp
@@ -177,7 +177,7 @@
  SourceLocation MutableLoc,
  ExceptionSpecificationType
  ESpecType,
- SourceLocation ESpecLoc,
+ SourceRange ESpecRange,
  ParsedType *Exceptions,
  SourceRange *ExceptionRanges,
  unsigned NumExceptions,
@@ -212,7 +212,8 @@
   I.Fun.RestrictQualifierLoc= RestrictQualifierLoc.getRawEncoding();
   I.Fun.MutableLoc  = MutableLoc.getRawEncoding();
   I.F

Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-06 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:7454-7456
@@ +7453,5 @@
+  PDiag(diag::err_function_concept_exception_spec);
+  if (Range.isValid()) {
+PD << FixItHint::CreateRemoval(Range);
+  }
+  Diag(NewFD->getLocation(), PD);

rsmith wrote:
> You don't need this `if`; a `FixItHint` with an invalid range has no effect.
Ahhh, okay. I misunderstood the original comment about an empty SourceRange 
apparently.

I'll go back to using Diagnostic rather than PartialDiagnostic as well.




http://reviews.llvm.org/D11789



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D11789: Modify DeclaratorChuck::getFunction to be passed an Exception Specification SourceRange

2015-08-06 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/Sema/DeclSpec.h:1262
@@ -1260,1 +1261,3 @@
+/// \brief The end location of the exception specifier, if any.
+unsigned ExceptionSpecLocEnd;
 

Please let me know if there is still an issue with the wording here.


http://reviews.llvm.org/D11789



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D11916: [CONCEPTS] Add diagnostic; invalid tag when concept specified

2015-08-10 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, hubert.reinterpretcast, fraggamuffin, faisalv, 
aaron.ballman.
nwilson added a subscriber: cfe-commits.

Adding check to emit diagnostic for invalid tag when concept is specified and 
associated tests.

http://reviews.llvm.org/D11916

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/cxx-concept-declaration.cpp

Index: test/SemaCXX/cxx-concept-declaration.cpp
===
--- test/SemaCXX/cxx-concept-declaration.cpp
+++ test/SemaCXX/cxx-concept-declaration.cpp
@@ -23,3 +23,13 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be 
initialized}}
 
+// Tag
+concept class CC1 {}; // expected-error {{class cannot be marked concept}}
+concept struct CS1 {}; // expected-error {{struct cannot be marked concept}}
+concept union CU1 {}; // expected-error {{union cannot be marked concept}}
+concept enum CE1 {}; // expected-error {{enum cannot be marked concept}}
+template  concept class TCC1 {}; // expected-error {{class cannot 
be marked concept}}
+template  concept struct TCS1 {}; // expected-error {{struct 
cannot be marked concept}}
+template  concept union TCU1 {}; // expected-error {{union cannot 
be marked concept}}
+
+extern concept bool ExtC; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3662,6 +3662,19 @@
 return TagD;
   }
 
+  if (DS.isConceptSpecified()) {
+// C++ Concepts TS [dcl.spec.concept]p1: A concept definition refers to
+// either a function concept and its definition or a variable concept and
+// its initializer.
+if (Tag)
+  Diag(DS.getConceptSpecLoc(), diag::err_concept_tag)
+  << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType());
+else
+  Diag(DS.getConceptSpecLoc(), diag::err_concept_decl_non_template);
+// Don't emit warnings after this error.
+return TagD;
+  }
+
   DiagnoseFunctionSpecifiers(DS);
 
   if (DS.isFriendSpecified()) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1973,6 +1973,8 @@
   "function concept declaration must be a definition">;
 def err_var_concept_not_initialized : Error<
   "variable concept declaration must be initialized">;
+def err_concept_tag : Error<
+  "%select{class|struct|interface|union|enum}0 cannot be marked concept">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/SemaCXX/cxx-concept-declaration.cpp
===
--- test/SemaCXX/cxx-concept-declaration.cpp
+++ test/SemaCXX/cxx-concept-declaration.cpp
@@ -23,3 +23,13 @@
 template
 concept bool D6; // expected-error {{variable concept declaration must be initialized}}
 
+// Tag
+concept class CC1 {}; // expected-error {{class cannot be marked concept}}
+concept struct CS1 {}; // expected-error {{struct cannot be marked concept}}
+concept union CU1 {}; // expected-error {{union cannot be marked concept}}
+concept enum CE1 {}; // expected-error {{enum cannot be marked concept}}
+template  concept class TCC1 {}; // expected-error {{class cannot be marked concept}}
+template  concept struct TCS1 {}; // expected-error {{struct cannot be marked concept}}
+template  concept union TCU1 {}; // expected-error {{union cannot be marked concept}}
+
+extern concept bool ExtC; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -3662,6 +3662,19 @@
 return TagD;
   }
 
+  if (DS.isConceptSpecified()) {
+// C++ Concepts TS [dcl.spec.concept]p1: A concept definition refers to
+// either a function concept and its definition or a variable concept and
+// its initializer.
+if (Tag)
+  Diag(DS.getConceptSpecLoc(), diag::err_concept_tag)
+  << GetDiagnosticTypeSpecifierID(DS.getTypeSpecType());
+else
+  Diag(DS.getConceptSpecLoc(), diag::err_concept_decl_non_template);
+// Don't emit warnings after this error.
+return TagD;
+  }
+
   DiagnoseFunctionSpecifiers(DS);
 
   if (DS.isFriendSpecified()) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -1973,6 +1973,8 @@
   "function concept declaration must be a definition">;
 def err_var_concept_not_initialized : Error<
   "variable concept declara

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 46588.
nwilson added a comment.

- Fix a couple of comments to reflect the Patch.
- Clang-format the changes in this Patch.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template  concept bool VCEI{ true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool VCPS{ true };
+template  concept bool VCPS{ true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template  concept bool VCES{ true };
+template <> concept bool VCES{ true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template  concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool FCES() { return true; }
+template <> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7673,6 +7673,15 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6002,6 +6002,16 @@
 NewVD->setInvalidDecl(true);
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+<< (IsPartialSpecialization ? 2 : 1);
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
   // following restrictions:
   // - The declared type shall have the type bool.
@@ -7667,6 +7677,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7733,6 +7747,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7994,9 +8017,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   HasExplicitTemplateArgs = true;
-
+
  

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Nathan Wilson via cfe-commits
nwilson marked 5 inline comments as done.
nwilson added a comment.

Marking some comments Done which were fixed in previous updates.


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-01 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:374
@@ +373,3 @@
+  bool isConcept() const { return TemplatedDecl.getInt(); }
+  void setConcept(bool IC) { TemplatedDecl.setInt(true); }
+

rsmith wrote:
> I would prefer to not have a setter at all, but if it's awkward to pass this 
> flag into the constructor, then a setter is fine (and I don't mind whether or 
> not it takes a parameter). We should definitely not take a parameter and 
> ignore it though.
Ah, gotcha. Yeah, it seemed somewhat awkward to me to pass the flag all the way 
through. As a note it would be VarTemplateDecl -> RedeclarableTemplateDecl -> 
TemplateDecl. Also, RedeclarableTemplateDecl also currently currently takes 7 
parameters. 

If you feel strongly, I can move it to the constructor. Otherwise, I'll take 
the parameter out of the setter as both you and Hubert have pointed out the 
property will not need to set to false.


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-03 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 46854.
nwilson added a comment.

- This update removes the parameter in `TemplateDecl::setConcept` since there 
isn't a need to mark a concept false.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template  concept bool VCEI{ true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool VCPS{ true };
+template  concept bool VCPS{ true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template  concept bool VCES{ true };
+template <> concept bool VCES{ true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template  concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool FCES() { return true; }
+template <> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7673,6 +7673,15 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6002,6 +6002,16 @@
 NewVD->setInvalidDecl(true);
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+<< (IsPartialSpecialization ? 2 : 1);
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
   // following restrictions:
   // - The declared type shall have the type bool.
@@ -7667,6 +7677,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept();
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7733,6 +7747,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7994,9 +8017,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   HasExplicitTemplateA

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-03 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 46863.
nwilson added a comment.

- Address Hubert's comments about the quoted section of the TS.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template  concept bool VCEI{ true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool VCPS{ true };
+template  concept bool VCPS{ true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template  concept bool VCES{ true };
+template <> concept bool VCES{ true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template  concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template  concept bool FCES() { return true; }
+template <> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7673,6 +7673,15 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6002,6 +6002,15 @@
 NewVD->setInvalidDecl(true);
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable
+  // template, declared in namespace scope.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+<< (IsPartialSpecialization ? 2 : 1);
+  }
+
   // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
   // following restrictions:
   // - The declared type shall have the type bool.
@@ -7667,6 +7676,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept();
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7733,6 +7746,14 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable
+  // template, declared in namespace scope.
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7994,9 +8015,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   HasExplicitTemplateArgs = true;
-
+
   if (NewFD->isInvalidDecl()) {
 HasExplicitTemplateArgs = false;
   } else if (FunctionTemplate) {
Index: include/clang/Basic/DiagnosticSemaKinds.td

Re: r259862 - [CMake] Improve the clang order-file generation workflow

2016-02-04 Thread Nathan Wilson via cfe-commits
I'm using gold and it seems like it's been fixed for me.

On Thu, Feb 4, 2016 at 10:33 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This build might be using gold, I don't recall how that machine is
> configured. I won't be able to test the fix until tomorrow, hopefully the
> bits will give you enough.
> On 4 Feb 2016 7:07 p.m., "Chris Bieneman"  wrote:
>
>> Actually r259871 includes the code to cleanup the “bad” order file…
>>
>> -Chris
>>
>> On Feb 4, 2016, at 7:02 PM, Chris Bieneman  wrote:
>>
>> I pushed a speculative fix for this in r259870. I’m unable to reproduce
>> locally. There are a few bots that hit the same issue, so I’m watching them.
>>
>> -Chris
>>
>> On Feb 4, 2016, at 6:44 PM, Chris Bieneman via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> What linker are you using and on what OS? I’m looking at this now, and
>> will revert if I can’t find a solution.
>>
>> -Chris
>>
>> On Feb 4, 2016, at 6:38 PM, Richard Smith  wrote:
>>
>> This is causing my links to fail with:
>>
>> FAILED: : && /usr/local/google/home/richardsmith/bin/clang++
>> -fcolor-diagnostics -std=c++11 -stdlib=libc++ -fPIC
>> -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings
>> -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long
>> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor
>> -std=c++11 -fcolor-diagnostics -fno-common -Woverloaded-virtual
>> -Wno-nested-anon-types -g  -Wl,-allow-shlib-undefined
>> -Wl,--export-dynamic
>> tools/clang/tools/driver/CMakeFiles/clang.dir/driver.cpp.o
>> tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o
>> tools/clang/tools/driver/CMakeFiles/clang.dir/cc1as_main.cpp.o  -o
>> bin/clang-3.8  lib/libLLVMAArch64CodeGen.a lib/libLLVMAArch64AsmPrinter.a
>> lib/libLLVMAArch64AsmParser.a lib/libLLVMAArch64Desc.a
>> lib/libLLVMAArch64Info.a lib/libLLVMAArch64Disassembler.a
>> lib/libLLVMAMDGPUCodeGen.a lib/libLLVMAMDGPUAsmPrinter.a
>> lib/libLLVMAMDGPUAsmParser.a lib/libLLVMAMDGPUDesc.a
>> lib/libLLVMAMDGPUInfo.a lib/libLLVMARMCodeGen.a lib/libLLVMARMAsmPrinter.a
>> lib/libLLVMARMAsmParser.a lib/libLLVMARMDesc.a lib/libLLVMARMInfo.a
>> lib/libLLVMARMDisassembler.a lib/libLLVMBPFCodeGen.a
>> lib/libLLVMBPFAsmPrinter.a lib/libLLVMBPFDesc.a lib/libLLVMBPFInfo.a
>> lib/libLLVMCppBackendCodeGen.a lib/libLLVMCppBackendInfo.a
>> lib/libLLVMHexagonCodeGen.a lib/libLLVMHexagonAsmParser.a
>> lib/libLLVMHexagonDesc.a lib/libLLVMHexagonInfo.a
>> lib/libLLVMHexagonDisassembler.a lib/libLLVMMipsCodeGen.a
>> lib/libLLVMMipsAsmPrinter.a lib/libLLVMMipsAsmParser.a
>> lib/libLLVMMipsDesc.a lib/libLLVMMipsInfo.a lib/libLLVMMipsDisassembler.a
>> lib/libLLVMMSP430CodeGen.a lib/libLLVMMSP430AsmPrinter.a
>> lib/libLLVMMSP430Desc.a lib/libLLVMMSP430Info.a lib/libLLVMNVPTXCodeGen.a
>> lib/libLLVMNVPTXAsmPrinter.a lib/libLLVMNVPTXDesc.a lib/libLLVMNVPTXInfo.a
>> lib/libLLVMPowerPCCodeGen.a lib/libLLVMPowerPCAsmPrinter.a
>> lib/libLLVMPowerPCAsmParser.a lib/libLLVMPowerPCDesc.a
>> lib/libLLVMPowerPCInfo.a lib/libLLVMPowerPCDisassembler.a
>> lib/libLLVMSparcCodeGen.a lib/libLLVMSparcAsmPrinter.a
>> lib/libLLVMSparcAsmParser.a lib/libLLVMSparcDesc.a lib/libLLVMSparcInfo.a
>> lib/libLLVMSparcDisassembler.a lib/libLLVMSystemZCodeGen.a
>> lib/libLLVMSystemZAsmPrinter.a lib/libLLVMSystemZAsmParser.a
>> lib/libLLVMSystemZDesc.a lib/libLLVMSystemZInfo.a
>> lib/libLLVMSystemZDisassembler.a lib/libLLVMX86CodeGen.a
>> lib/libLLVMX86AsmPrinter.a lib/libLLVMX86AsmParser.a lib/libLLVMX86Desc.a
>> lib/libLLVMX86Info.a lib/libLLVMX86Disassembler.a lib/libLLVMXCoreCodeGen.a
>> lib/libLLVMXCoreAsmPrinter.a lib/libLLVMXCoreDesc.a lib/libLLVMXCoreInfo.a
>> lib/libLLVMXCoreDisassembler.a lib/libLLVMAnalysis.a lib/libLLVMCodeGen.a
>> lib/libLLVMCore.a lib/libLLVMipo.a lib/libLLVMInstCombine.a
>> lib/libLLVMInstrumentation.a lib/libLLVMMC.a lib/libLLVMMCParser.a
>> lib/libLLVMObjCARCOpts.a lib/libLLVMOption.a lib/libLLVMScalarOpts.a
>> lib/libLLVMSupport.a lib/libLLVMTransformUtils.a lib/libLLVMVectorize.a
>> lib/libclangBasic.a lib/libclangCodeGen.a lib/libclangDriver.a
>> lib/libclangFrontend.a lib/libclangFrontendTool.a
>> -Wl,-order_file,/usr/local/google/home/richardsmith/clang-8/build/tools/clang/clang.order
>> lib/libLLVMAArch64Desc.a lib/libLLVMAArch64AsmPrinter.a
>> lib/libLLVMAArch64Info.a lib/libLLVMAArch64Utils.a
>> lib/libLLVMAMDGPUAsmPrinter.a lib/libLLVMAMDGPUUtils.a lib/libLLVMARMDesc.a
>> lib/libLLVMARMAsmPrinter.a lib/libLLVMARMInfo.a lib/libLLVMBPFAsmPrinter.a
>> lib/libLLVMHexagonDesc.a lib/libLLVMHexagonInfo.a
>> lib/libLLVMMipsAsmPrinter.a lib/libLLVMMipsInfo.a
>> lib/libLLVMMSP430AsmPrinter.a lib/libLLVMNVPTXAsmPrinter.a
>> lib/libLLVMPowerPCAsmPrinter.a lib/libLLVMPowerPCInfo.a
>> lib/libLLVMSparcAsmPrinter.a lib/libLLVMSparcInfo.a
>> lib/libLLVMSystemZDesc.a lib/libLLVMSystemZAsmPrinter.a
>> lib/libLLVMSystemZInfo.a lib/libLLVMX86AsmPrinter.a lib/libLLVMX86Utils.a
>> lib/libLLVMX86Info.a lib/libLLVMXCoreAsmPrinter.a 

r260074 - [Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p1 by

2016-02-07 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Sun Feb  7 23:34:00 2016
New Revision: 260074

URL: http://llvm.org/viewvc/llvm-project?rev=260074&view=rev
Log:
[Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p1 by
diagnosing when 'concept' is specified on a function or template
specialization.

Since a concept can only be applied to a function or variable template,
the concept bit is stored in TemplateDecl as a PointerIntPair.

Reviewers: rsmith, faisalv, aaron.ballman, hubert.reinterpretcast

Differential Revision: http://reviews.llvm.org/D13357

Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=260074&r1=260073&r2=260074&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Sun Feb  7 23:34:00 2016
@@ -332,24 +332,23 @@ class TemplateDecl : public NamedDecl {
   void anchor() override;
 protected:
   // This is probably never used.
-  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
-   DeclarationName Name)
-: NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),
-  TemplateParams(nullptr) {}
+  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName 
Name)
+  : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr, false),
+TemplateParams(nullptr) {}
 
   // Construct a template decl with the given name and parameters.
   // Used when there is not templated element (tt-params).
-  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
-   DeclarationName Name, TemplateParameterList *Params)
-: NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),
-  TemplateParams(Params) {}
+  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName 
Name,
+   TemplateParameterList *Params)
+  : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr, false),
+TemplateParams(Params) {}
 
   // Construct a template decl with name, parameters, and templated element.
-  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
-   DeclarationName Name, TemplateParameterList *Params,
-   NamedDecl *Decl)
-: NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl),
-  TemplateParams(Params) { }
+  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName 
Name,
+   TemplateParameterList *Params, NamedDecl *Decl)
+  : NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl, false),
+TemplateParams(Params) {}
+
 public:
   /// Get the list of template parameters
   TemplateParameterList *getTemplateParameters() const {
@@ -357,7 +356,7 @@ public:
   }
 
   /// Get the underlying, templated declaration.
-  NamedDecl *getTemplatedDecl() const { return TemplatedDecl; }
+  NamedDecl *getTemplatedDecl() const { return TemplatedDecl.getPointer(); }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -367,20 +366,30 @@ public:
 
   SourceRange getSourceRange() const override LLVM_READONLY {
 return SourceRange(TemplateParams->getTemplateLoc(),
-   TemplatedDecl->getSourceRange().getEnd());
+   TemplatedDecl.getPointer()->getSourceRange().getEnd());
   }
 
+  /// Whether this is a (C++ Concepts TS) function or variable concept.
+  bool isConcept() const { return TemplatedDecl.getInt(); }
+  void setConcept() { TemplatedDecl.setInt(true); }
+
 protected:
-  NamedDecl *TemplatedDecl;
+  /// \brief The named declaration from which this template was instantiated.
+  /// (or null).
+  ///
+  /// The boolean value will be true to indicate that this template
+  /// (function or variable) is a concept.
+  llvm::PointerIntPair TemplatedDecl;
+
   TemplateParameterList* TemplateParams;
 
 public:
   /// \brief Initialize the underlying templated declaration and
   /// template parameters.
   void init(NamedDecl *templatedDecl, TemplateParameterList* templateParams) {
-assert(!TemplatedDecl && "TemplatedDecl already set!");
+assert(!TemplatedDecl.getPointer() && "TemplatedDecl already set!");
 assert(!TemplateParams && "TemplateParams already set!");
-TemplatedDecl = templatedDecl;
+TemplatedDecl.setPointer(templatedDecl);
 TemplateParams = templateParams;
   }
 };
@@ -889,7 +898,7 @@ public:
 
   /// Get the underlying function declaration of the template.
   FunctionDecl *getTemplatedDecl() const {
-return static_cast(TemplatedDecl);
+return static_cast(TemplatedDecl.getPointer());
   }
 
   /// Returns whether this template declaration defines the primary
@@ -1982,7 

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-02-07 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL260074: [Concepts] Implement a portion of Concepts 
TS[dcl.spec.concept]p1 by (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D13357?vs=46863&id=47160#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13357

Files:
  cfe/trunk/include/clang/AST/DeclTemplate.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: cfe/trunk/include/clang/AST/DeclTemplate.h
===
--- cfe/trunk/include/clang/AST/DeclTemplate.h
+++ cfe/trunk/include/clang/AST/DeclTemplate.h
@@ -332,32 +332,31 @@
   void anchor() override;
 protected:
   // This is probably never used.
-  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
-   DeclarationName Name)
-: NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),
-  TemplateParams(nullptr) {}
+  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name)
+  : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr, false),
+TemplateParams(nullptr) {}
 
   // Construct a template decl with the given name and parameters.
   // Used when there is not templated element (tt-params).
-  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
-   DeclarationName Name, TemplateParameterList *Params)
-: NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),
-  TemplateParams(Params) {}
+  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name,
+   TemplateParameterList *Params)
+  : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr, false),
+TemplateParams(Params) {}
 
   // Construct a template decl with name, parameters, and templated element.
-  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
-   DeclarationName Name, TemplateParameterList *Params,
-   NamedDecl *Decl)
-: NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl),
-  TemplateParams(Params) { }
+  TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name,
+   TemplateParameterList *Params, NamedDecl *Decl)
+  : NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl, false),
+TemplateParams(Params) {}
+
 public:
   /// Get the list of template parameters
   TemplateParameterList *getTemplateParameters() const {
 return TemplateParams;
   }
 
   /// Get the underlying, templated declaration.
-  NamedDecl *getTemplatedDecl() const { return TemplatedDecl; }
+  NamedDecl *getTemplatedDecl() const { return TemplatedDecl.getPointer(); }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -367,20 +366,30 @@
 
   SourceRange getSourceRange() const override LLVM_READONLY {
 return SourceRange(TemplateParams->getTemplateLoc(),
-   TemplatedDecl->getSourceRange().getEnd());
+   TemplatedDecl.getPointer()->getSourceRange().getEnd());
   }
 
+  /// Whether this is a (C++ Concepts TS) function or variable concept.
+  bool isConcept() const { return TemplatedDecl.getInt(); }
+  void setConcept() { TemplatedDecl.setInt(true); }
+
 protected:
-  NamedDecl *TemplatedDecl;
+  /// \brief The named declaration from which this template was instantiated.
+  /// (or null).
+  ///
+  /// The boolean value will be true to indicate that this template
+  /// (function or variable) is a concept.
+  llvm::PointerIntPair TemplatedDecl;
+
   TemplateParameterList* TemplateParams;
 
 public:
   /// \brief Initialize the underlying templated declaration and
   /// template parameters.
   void init(NamedDecl *templatedDecl, TemplateParameterList* templateParams) {
-assert(!TemplatedDecl && "TemplatedDecl already set!");
+assert(!TemplatedDecl.getPointer() && "TemplatedDecl already set!");
 assert(!TemplateParams && "TemplateParams already set!");
-TemplatedDecl = templatedDecl;
+TemplatedDecl.setPointer(templatedDecl);
 TemplateParams = templateParams;
   }
 };
@@ -889,7 +898,7 @@
 
   /// Get the underlying function declaration of the template.
   FunctionDecl *getTemplatedDecl() const {
-return static_cast(TemplatedDecl);
+return static_cast(TemplatedDecl.getPointer());
   }
 
   /// Returns whether this template declaration defines the primary
@@ -1982,7 +1991,7 @@
 
   /// \brief Get the underlying class declarations of the template.
   CXXRecordDecl *getTemplatedDecl() const {
-return static_cast(TemplatedDecl);
+return static_cast(TemplatedDecl.getPointer());
   }
 
   /// \brief Returns whether this template declaration defines the primary
@@ -2245,7 +2254,7 @@
 public:
   /// Get the underlying function declaration of the template.
   TypeAliasDecl *getTemplatedDecl() const {
-return static

r260155 - [Concepts] Remove the IsConcept bit and associated member functions from VarDecl

2016-02-08 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Mon Feb  8 16:02:50 2016
New Revision: 260155

URL: http://llvm.org/viewvc/llvm-project?rev=260155&view=rev
Log:
[Concepts] Remove the IsConcept bit and associated member functions from VarDecl
because the information is now stored in TemplateDecl.

Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=260155&r1=260154&r2=260155&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Feb  8 16:02:50 2016
@@ -816,9 +816,6 @@ protected:
 /// \brief Whether this variable is (C++0x) constexpr.
 unsigned IsConstexpr : 1;
 
-/// \brief Whether this variable is a (C++ Concepts TS) concept.
-unsigned IsConcept : 1;
-
 /// \brief Whether this variable is the implicit variable for a lambda
 /// init-capture.
 unsigned IsInitCapture : 1;
@@ -1194,15 +1191,6 @@ public:
 NonParmVarDeclBits.IsConstexpr = IC;
   }
 
-  /// Whether this variable is (C++ Concepts TS) concept.
-  bool isConcept() const {
-return isa(this) ? false : NonParmVarDeclBits.IsConcept;
-  }
-  void setConcept(bool IC) {
-assert(!isa(this));
-NonParmVarDeclBits.IsConcept = IC;
-  }
-
   /// Whether this variable is the implicit variable for a lambda init-capture.
   bool isInitCapture() const {
 return isa(this) ? false : NonParmVarDeclBits.IsInitCapture;

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=260155&r1=260154&r2=260155&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Feb  8 16:02:50 2016
@@ -5983,7 +5983,8 @@ Sema::ActOnVariableDeclarator(Scope *S,
   NewVD->setConstexpr(true);
 
 if (D.getDeclSpec().isConceptSpecified()) {
-  NewVD->setConcept(true);
+  if (VarTemplateDecl *VTD = NewVD->getDescribedVarTemplate())
+VTD->setConcept();
 
   // C++ Concepts TS [dcl.spec.concept]p2: A concept definition shall not
   // be declared with the thread_local, inline, friend, or constexpr
@@ -9760,10 +9761,12 @@ void Sema::ActOnUninitializedDecl(Decl *
 // 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;
+if (VarTemplateDecl *VTD = Var->getDescribedVarTemplate()) {
+  if (VTD->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


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18221: [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

2016-04-08 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 53103.
nwilson added a comment.

- Address Aaron's comments by putting comments next to the magic numbers


http://reviews.llvm.org/D18221

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
@@ -0,0 +1,18 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template  concept bool FCEI() { return true; } // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}}
+template bool FCEI(); // expected-error {{function concept cannot be explicitly instantiated}}
+extern template bool FCEI(); // expected-error {{function concept cannot be explicitly instantiated}}
+
+template  concept bool FCES() { return true; } // expected-note {{previous declaration is here}}
+template <> bool FCES() { return true; } // expected-error {{function concept cannot be explicitly specialized}}
+
+template  concept bool VC { true }; // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}}
+template bool VC; // expected-error {{variable concept cannot be explicitly instantiated}}
+extern template bool VC; // expected-error {{variable concept cannot be explicitly instantiated}}
+
+template  concept bool VCES { true }; // expected-note {{previous declaration is here}}
+template <> bool VCES { true }; // expected-error {{variable concept cannot be explicitly specialized}}
+
+template  concept bool VCPS { true }; // expected-note {{previous declaration is here}}
+template  bool VCPS { true }; // expected-error {{variable concept cannot be partially specialized}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6920,6 +6920,15 @@
   // Ignore access information;  it doesn't figure into redeclaration checking.
   FunctionDecl *Specialization = cast(*Result);
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  // an explicit specialization (14.8.3) [...] of a concept definition.
+  if (Specialization->getPrimaryTemplate()->isConcept()) {
+Diag(FD->getLocation(), diag::err_concept_specialized)
+<< 0 /*function*/ << 1 /*explicitly specialized*/;
+Diag(Specialization->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   FunctionTemplateSpecializationInfo *SpecInfo
 = Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
@@ -7774,6 +7783,15 @@
 return true;
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (PrevTemplate->isConcept()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized)
+<< 1 /*variable*/ << 0 /*explicitly instantiated*/;
+Diag(PrevTemplate->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   // Translate the parser's template argument list into our AST format.
   TemplateArgumentListInfo TemplateArgs =
   makeTemplateArgumentListInfo(*this, *D.getName().TemplateId);
@@ -7988,6 +8006,16 @@
  diag::ext_explicit_instantiation_without_qualified_id)
 << Specialization << D.getCXXScopeSpec().getRange();
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (FunTmpl && FunTmpl->isConcept() &&
+  !D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized)
+<< 0 /*function*/ << 0 /*explicitly instantiated*/;
+Diag(FunTmpl->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   CheckExplicitInstantiationScope(*this,
FunTmpl? (NamedDecl *)FunTmpl
   : Specialization->getInstantiatedFromMemberFunction(),
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6285,6 +6285,25 @@
 if (!IsVariableTemplateSpecialization)
   D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous));
 
+// C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+// an explicit specialization (14.8.3) or a partial specialization of a
+// concept definition.
+if (IsVariableTemplateSpecialization &&
+!D.getDeclSpec().isConceptSpecified() && !Previous.empty() &&
+Previous.isSingleResult()) {
+  NamedDecl *PreviousDecl = Previous.getFoundDecl();
+  if

r265868 - [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

2016-04-08 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Fri Apr  8 21:55:27 2016
New Revision: 265868

URL: http://llvm.org/viewvc/llvm-project?rev=265868&view=rev
Log:
[Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

Summary: A program shall not declare an explicit instantiation (14.8.2), an 
explicit specialization (14.8.3), or a partial specialization of a concept 
definition.

Reviewers: rsmith, hubert.reinterpretcast, faisalv, aaron.ballman

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D18221

Added:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=265868&r1=265867&r2=265868&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr  8 21:55:27 
2016
@@ -2098,6 +2098,9 @@ def err_variable_concept_bool_decl : Err
 def err_concept_specified_specialization : Error<
   "'concept' cannot be applied on an "
   "%select{explicit instantiation|explicit specialization|partial 
specialization}0">;
+def err_concept_specialized : Error<
+  "%select{function|variable}0 concept cannot be "
+  "%select{explicitly instantiated|explicitly specialized|partially 
specialized}1">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=265868&r1=265867&r2=265868&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Apr  8 21:55:27 2016
@@ -6285,6 +6285,25 @@ Sema::ActOnVariableDeclarator(Scope *S,
 if (!IsVariableTemplateSpecialization)
   D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous));
 
+// C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+// an explicit specialization (14.8.3) or a partial specialization of a
+// concept definition.
+if (IsVariableTemplateSpecialization &&
+!D.getDeclSpec().isConceptSpecified() && !Previous.empty() &&
+Previous.isSingleResult()) {
+  NamedDecl *PreviousDecl = Previous.getFoundDecl();
+  if (VarTemplateDecl *VarTmpl = dyn_cast(PreviousDecl)) {
+if (VarTmpl->isConcept()) {
+  Diag(NewVD->getLocation(), diag::err_concept_specialized)
+  << 1/*variable*/
+  << (IsPartialSpecialization ? 2 /*partially specialized*/
+  : 1 /*explicitly specialized*/);
+  Diag(VarTmpl->getLocation(), diag::note_previous_declaration);
+  NewVD->setInvalidDecl();
+}
+  }
+}
+
 if (NewTemplate) {
   VarTemplateDecl *PrevVarTemplate =
   NewVD->getPreviousDecl()
@@ -7823,6 +7842,8 @@ Sema::ActOnFunctionDeclarator(Scope *S,
   if (isFunctionTemplateSpecialization) {
 Diag(D.getDeclSpec().getConceptSpecLoc(),
  diag::err_concept_specified_specialization) << 1;
+NewFD->setInvalidDecl(true);
+return NewFD;
   }
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=265868&r1=265867&r2=265868&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Apr  8 21:55:27 2016
@@ -6920,6 +6920,15 @@ bool Sema::CheckFunctionTemplateSpeciali
   // Ignore access information;  it doesn't figure into redeclaration checking.
   FunctionDecl *Specialization = cast(*Result);
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  // an explicit specialization (14.8.3) [...] of a concept definition.
+  if (Specialization->getPrimaryTemplate()->isConcept()) {
+Diag(FD->getLocation(), diag::err_concept_specialized)
+<< 0 /*function*/ << 1 /*explicitly specialized*/;
+Diag(Specialization->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   FunctionTemplateSpecializationInfo *SpecInfo
 = Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
@@ -7774,6 +7783,15 @@ DeclResult Sema::ActOnExplicitInstantiat
 return true;
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (PrevTemplate->isConcept()) {
+Diag(D.getIdentifi

Re: [PATCH] D18221: [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

2016-04-08 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL265868: [Concepts] Implement subsection [dcl.spec.concept]p7 
of the Concepts TS (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D18221?vs=53103&id=53110#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18221

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp

Index: cfe/trunk/lib/Sema/SemaTemplate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp
@@ -6920,6 +6920,15 @@
   // Ignore access information;  it doesn't figure into redeclaration checking.
   FunctionDecl *Specialization = cast(*Result);
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  // an explicit specialization (14.8.3) [...] of a concept definition.
+  if (Specialization->getPrimaryTemplate()->isConcept()) {
+Diag(FD->getLocation(), diag::err_concept_specialized)
+<< 0 /*function*/ << 1 /*explicitly specialized*/;
+Diag(Specialization->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   FunctionTemplateSpecializationInfo *SpecInfo
 = Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
@@ -7774,6 +7783,15 @@
 return true;
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (PrevTemplate->isConcept()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized)
+<< 1 /*variable*/ << 0 /*explicitly instantiated*/;
+Diag(PrevTemplate->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   // Translate the parser's template argument list into our AST format.
   TemplateArgumentListInfo TemplateArgs =
   makeTemplateArgumentListInfo(*this, *D.getName().TemplateId);
@@ -7988,6 +8006,16 @@
  diag::ext_explicit_instantiation_without_qualified_id)
 << Specialization << D.getCXXScopeSpec().getRange();
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (FunTmpl && FunTmpl->isConcept() &&
+  !D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized)
+<< 0 /*function*/ << 0 /*explicitly instantiated*/;
+Diag(FunTmpl->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   CheckExplicitInstantiationScope(*this,
FunTmpl? (NamedDecl *)FunTmpl
   : Specialization->getInstantiatedFromMemberFunction(),
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6285,6 +6285,25 @@
 if (!IsVariableTemplateSpecialization)
   D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous));
 
+// C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+// an explicit specialization (14.8.3) or a partial specialization of a
+// concept definition.
+if (IsVariableTemplateSpecialization &&
+!D.getDeclSpec().isConceptSpecified() && !Previous.empty() &&
+Previous.isSingleResult()) {
+  NamedDecl *PreviousDecl = Previous.getFoundDecl();
+  if (VarTemplateDecl *VarTmpl = dyn_cast(PreviousDecl)) {
+if (VarTmpl->isConcept()) {
+  Diag(NewVD->getLocation(), diag::err_concept_specialized)
+  << 1/*variable*/
+  << (IsPartialSpecialization ? 2 /*partially specialized*/
+  : 1 /*explicitly specialized*/);
+  Diag(VarTmpl->getLocation(), diag::note_previous_declaration);
+  NewVD->setInvalidDecl();
+}
+  }
+}
+
 if (NewTemplate) {
   VarTemplateDecl *PrevVarTemplate =
   NewVD->getPreviousDecl()
@@ -7823,6 +7842,8 @@
   if (isFunctionTemplateSpecialization) {
 Diag(D.getDeclSpec().getConceptSpecLoc(),
  diag::err_concept_specified_specialization) << 1;
+NewFD->setInvalidDecl(true);
+return NewFD;
   }
 }
 
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2098,6 +2098,9 @@
 def err_concept_specified_specialization : Error<
   "'concept' cannot be applied on an "
   "%select{explicit instantiation|explicit specialization|partial specialization}0">;
+d

Re: [PATCH] D18221: [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

2016-03-19 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:7837
@@ -7819,1 +7836,3 @@
+NewFD->setInvalidDecl(true);
+return NewFD;
   }

Please let me know if there are thoughts about better error recovery here. I 
did this because we don't have the specifier information when checking an 
explicit specialization. So, we still diagnose for the explication 
specialization (one of the checks in this patch), when `concept` is specified, 
e.g.:
template concept bool C() { return true; }
template <> concept bool C() { return true; }

Would it be okay to pass `Declarator` to 
Sema::CheckFunctionTemplateSpecialization?


http://reviews.llvm.org/D18221



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D18221: [Concepts] Implement subsection [dcl.spec.concept]p7 of the Concepts TS

2016-03-19 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, hubert.reinterpretcast, faisalv, aaron.ballman.
nwilson added a subscriber: cfe-commits.

A program shall not declare an explicit instantiation (14.8.2), an explicit 
specialization (14.8.3), or a partial specialization of a concept definition.

http://reviews.llvm.org/D18221

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp
@@ -0,0 +1,18 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template  concept bool FCEI() { return true; } // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}}
+template bool FCEI(); // expected-error {{function concept cannot be explicitly instantiated}}
+extern template bool FCEI(); // expected-error {{function concept cannot be explicitly instantiated}}
+
+template  concept bool FCES() { return true; } // expected-note {{previous declaration is here}}
+template <> bool FCES() { return true; } // expected-error {{function concept cannot be explicitly specialized}}
+
+template  concept bool VC { true }; // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}}
+template bool VC; // expected-error {{variable concept cannot be explicitly instantiated}}
+extern template bool VC; // expected-error {{variable concept cannot be explicitly instantiated}}
+
+template  concept bool VCES { true }; // expected-note {{previous declaration is here}}
+template <> bool VCES { true }; // expected-error {{variable concept cannot be explicitly specialized}}
+
+template  concept bool VCPS { true }; // expected-note {{previous declaration is here}}
+template  bool VCPS { true }; // expected-error {{variable concept cannot be partially specialized}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -6920,6 +6920,14 @@
   // Ignore access information;  it doesn't figure into redeclaration checking.
   FunctionDecl *Specialization = cast(*Result);
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+  // an explicit specialization (14.8.3) [...] of a concept definition.
+  if (Specialization->getPrimaryTemplate()->isConcept()) {
+Diag(FD->getLocation(), diag::err_concept_specialized) << 0 << 1;
+Diag(Specialization->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   FunctionTemplateSpecializationInfo *SpecInfo
 = Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
@@ -7768,6 +7776,14 @@
 return true;
   }
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (PrevTemplate->isConcept()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized) << 1 << 0;
+Diag(PrevTemplate->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   // Translate the parser's template argument list into our AST format.
   TemplateArgumentListInfo TemplateArgs =
   makeTemplateArgumentListInfo(*this, *D.getName().TemplateId);
@@ -7982,6 +7998,15 @@
  diag::ext_explicit_instantiation_without_qualified_id)
 << Specialization << D.getCXXScopeSpec().getRange();
 
+  // C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare an
+  // explicit instantiation (14.8.2) [...] of a concept definition.
+  if (FunTmpl && FunTmpl->isConcept() &&
+  !D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getIdentifierLoc(), diag::err_concept_specialized) << 0 << 0;
+Diag(FunTmpl->getLocation(), diag::note_previous_declaration);
+return true;
+  }
+
   CheckExplicitInstantiationScope(*this,
FunTmpl? (NamedDecl *)FunTmpl
   : Specialization->getInstantiatedFromMemberFunction(),
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6282,6 +6282,23 @@
 if (!IsVariableTemplateSpecialization)
   D.setRedeclaration(CheckVariableDeclaration(NewVD, Previous));
 
+// C++ Concepts TS [dcl.spec.concept]p7: A program shall not declare [...]
+// an explicit specialization (14.8.3) or a partial specialization of a
+// concept definition.
+if (IsVariableTemplateSpecialization &&
+!D.getDeclSpec().isConceptSpecified() && !Previous.empty() &&
+Previous.isSingleResult()) {
+  NamedDecl *PreviousDecl = Previous.getFoundDecl()

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-01-07 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Ping. Now that the holidays are over-ish, as Aaron said in one of his Patches.


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

In http://reviews.llvm.org/D15421#326144, @rsmith wrote:

> Bikeshedding on the name a bit... how about `__type_pack_element`?


Hmm, I kind of felt like having `nth` in there implied we're indexing into 
something... What about `__nth_pack_element`?


http://reviews.llvm.org/D15421



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Nathan Wilson via cfe-commits
On Wed, Jan 13, 2016 at 4:52 PM, Richard Smith 
wrote:

> On Wed, Jan 13, 2016 at 2:31 PM, Nathan Wilson 
> wrote:
>
>> nwilson added a comment.
>>
>> In http://reviews.llvm.org/D15421#326144, @rsmith wrote:
>>
>> > Bikeshedding on the name a bit... how about `__type_pack_element`?
>>
>> Hmm, I kind of felt like having `nth` in there implied we're indexing
>> into something... What about `__nth_pack_element`?
>
>
> Conversely, std::nth_element doesn't do indexing, and std::tuple_element
> does.
>

Yeah, I was trying to combine them, but maybe that's misleading.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16163: [Concepts] Diagnose when return type of a function concept or declaration type of a variable concept is not bool.

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, faisalv, hubert.reinterpretcast, aaron.ballman.
nwilson added a subscriber: cfe-commits.

Adding checks and diagnostics which fall under Concepts TS[dcl.spec.concept]p5:
function concepts are required to have 'bool' return type. 
Adding checks and  diagnostics which fall under Concepts TS[dcl.spec.concept]p6:
variable concepts are required to have 'bool' declaration type.

Remove a test in Parser which caused a regression due to the new checks.

http://reviews.llvm.org/D16163

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
  test/Parser/cxx-concept-declaration.cpp

Index: test/Parser/cxx-concept-declaration.cpp
===
--- test/Parser/cxx-concept-declaration.cpp
+++ test/Parser/cxx-concept-declaration.cpp
@@ -13,9 +13,6 @@
 template
 A::Boolean concept C3(!0);
 
-template
-concept auto C4(void) -> bool { return true; }
-
 constexpr int One = 1;
 
 template 
Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
@@ -0,0 +1,22 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool vc { true };
+
+template
+struct B { typedef bool Boolean; };
+
+template
+B::Boolean concept vctb(!0);
+
+template
+concept int vcti { 5 }; // expected-error {{declared type of variable concept must be 'bool'}}
+
+template
+concept float vctf { 5.5 }; // expected-error {{declared type of variable concept must be 'bool'}}
+
+template
+concept auto vcta { true }; // expected-error {{declared type of variable concept must be 'bool'}}
+
+template
+concept decltype(auto) vctd { true }; // expected-error {{declared type of variable concept must be 'bool'}}
Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -11,3 +11,15 @@
 
 template
 concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}}
+
+template
+concept int fcrti() { return 5; } // expected-error {{declared return type of function concept must be 'bool'}}
+
+template
+concept float fcrtf() { return 5.5; } // expected-error {{declared return type of function concept must be 'bool'}}
+
+template
+concept auto fcrta(void) -> bool { return true; } // expected-error {{declared return type of function concept must be 'bool'}}
+
+template
+concept decltype(auto) fcrtd(void) { return true; } // expected-error {{declared return type of function concept must be 'bool'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5986,6 +5986,17 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
+  // following restrictions:
+  // - The declared type shall have the type bool.
+  if (!R->isBooleanType()) {
+SourceRange Range = D.getDeclSpec().getTypeSpecTypeLoc();
+Diag(D.getIdentifierLoc(), diag::err_variable_concept_bool_decl)
+<< (Range.isValid() ? FixItHint::CreateReplacement(Range, "bool")
+: FixItHint());
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7668,6 +7679,18 @@
 
 // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
 // following restrictions:
+// - The declared return type shall have the type bool.
+if (!FPT->getReturnType()->isBooleanType() ||
+D.getDeclSpec().containsPlaceholderType()) {
+  SourceRange Range = NewFD->getReturnTypeSourceRange();
+  Diag(D.getIdentifierLoc(), diag::err_function_concept_bool_ret)
+  << (Range.isValid() ? FixItHint::CreateReplacement(Range, "bool")
+  : FixItHint());
+  NewFD->setInvalidDecl();
+}
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
 // - The declaration's parameter list shall be equivalent to an empty
 //   parameter list.
 if (FPT->getNumParams() > 0 || FPT->isVariadic())
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2067,6 +2067,10 @@
   "'%select{thread_local|inline|friend|constexpr}1'">;
 def err_function_concept_with_param

Re: [PATCH] D16163: [Concepts] Diagnose when return type of a function concept or declaration type of a variable concept is not bool.

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Please let me know if the subject or summary of this Patch is ambiguous.


http://reviews.llvm.org/D16163



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:375
@@ +374,3 @@
+  bool isConcept() const { return TemplatedDecl.getInt(); }
+  void setConcept(bool IC) { TemplatedDecl.setInt(true); }
+

hubert.reinterpretcast wrote:
> The parameter is now unused and should be removed.
Hmm, I think I should actually use that parameter since it's a bug as is (and 
would still be if I removed the parameter). I'll plan on doing that unless 
there is another thought about this.


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2016-01-13 Thread Nathan Wilson via cfe-commits
On Wed, Jan 13, 2016 at 6:48 PM, Richard Smith 
wrote:

> On Wed, Jan 13, 2016 at 3:41 PM, Arthur O'Dwyer via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Following Louis' suggestion, how about __pack_nth?
>>
>
> Maybe just __pack_element, to mirror its intended use to implement things
> like tuple_element? (I'm not completely happy about using this general name
> for something that only works for packs of types, but given that this
> template produces a type, it's probably the best we can do.)
>

That seems fine to me. I do feel like a name for something else will be
shoehorned in later as well though.

Louis - what do you think?


>
>
>> On Wed, Jan 13, 2016 at 3:16 PM, Nathan Wilson via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>>
>>> On Wed, Jan 13, 2016 at 4:52 PM, Richard Smith 
>>> wrote:
>>>
>>>> On Wed, Jan 13, 2016 at 2:31 PM, Nathan Wilson 
>>>> wrote:
>>>>
>>>>> nwilson added a comment.
>>>>>
>>>>> In http://reviews.llvm.org/D15421#326144, @rsmith wrote:
>>>>>
>>>>> > Bikeshedding on the name a bit... how about `__type_pack_element`?
>>>>>
>>>>> Hmm, I kind of felt like having `nth` in there implied we're indexing
>>>>> into something... What about `__nth_pack_element`?
>>>>
>>>>
>>>> Conversely, std::nth_element doesn't do indexing, and
>>>> std::tuple_element does.
>>>>
>>>
>>> Yeah, I was trying to combine them, but maybe that's misleading.
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-01-13 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:377
@@ -376,3 +376,3 @@
   NamedDecl *TemplatedDecl;
   TemplateParameterList* TemplateParams;
 

I can't seem to follow the link properly, but I'm assuming it's supposed to be 
where Richard is asking about whether we need a setter. I thought he meant 
whether we needed the setter function at all. Perhaps I misunderstood though.

But it seems to be the convention to give a boolean (or some other type of 
param) to a setter. I'd be fine either way though because as you said, there 
isn't a need to set the property to false. As a point of reference 
RedeclarableTemplateDecl::setMemberSpecialization doesn't take any params 
either.


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16163: [Concepts] Diagnose when return type of a function concept or declaration type of a variable concept is not bool.

2016-01-20 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 45453.
nwilson added a comment.

- Take qualifiers into account.
- Check `VarDecl` is valid when checking declaration type to account for 
`constexpr` being specified. Is there any opinion on a better way to handle 
this? I *could* check for both diagnostics in the test...
- Remove erroneous check for `auto` (containsPlaceholderType) and associated 
function concept test.
- Removed the use of Diagnostic Range because we'd need to enumerate over the 
various qualifiers.


http://reviews.llvm.org/D16163

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
@@ -0,0 +1,25 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool vc { true };
+
+template
+struct B { typedef bool Boolean; };
+
+template
+B::Boolean concept vctb(!0);
+
+template
+concept const bool vctc { true }; // expected-error {{declared type of 
variable concept must be 'bool'}}
+
+template
+concept int vcti { 5 }; // expected-error {{declared type of variable concept 
must be 'bool'}}
+
+template
+concept float vctf { 5.5 }; // expected-error {{declared type of variable 
concept must be 'bool'}}
+
+template
+concept auto vcta { true }; // expected-error {{declared type of variable 
concept must be 'bool'}}
+
+template
+concept decltype(auto) vctd { true }; // expected-error {{declared type of 
variable concept must be 'bool'}}
Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -11,3 +11,15 @@
 
 template
 concept bool fcpva(...) { return true; } // expected-error {{function concept 
cannot have any parameters}}
+
+template
+concept const bool fcrtc() { return true; } // expected-error {{declared 
return type of function concept must be 'bool'}}
+
+template
+concept int fcrti() { return 5; } // expected-error {{declared return type of 
function concept must be 'bool'}}
+
+template
+concept float fcrtf() { return 5.5; } // expected-error {{declared return type 
of function concept must be 'bool'}}
+
+template
+concept decltype(auto) fcrtd(void) { return true; } // expected-error 
{{declared return type of function concept must be 'bool'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5986,6 +5986,15 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
+  // following restrictions:
+  // - The declared type shall have the type bool.
+  if (!Context.hasSameType(NewVD->getType(), Context.BoolTy) &&
+  !NewVD->isInvalidDecl()) {
+Diag(D.getIdentifierLoc(), diag::err_variable_concept_bool_decl);
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7668,6 +7677,14 @@
 
 // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
 // following restrictions:
+// - The declared return type shall have the type bool.
+if (!Context.hasSameType(FPT->getReturnType(), Context.BoolTy)) {
+  Diag(D.getIdentifierLoc(), diag::err_function_concept_bool_ret);
+  NewFD->setInvalidDecl();
+}
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
 // - The declaration's parameter list shall be equivalent to an empty
 //   parameter list.
 if (FPT->getNumParams() > 0 || FPT->isVariadic())
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2074,6 +2074,10 @@
   "'%select{thread_local|inline|friend|constexpr}1'">;
 def err_function_concept_with_params : Error<
   "function concept cannot have any parameters">;
+def err_function_concept_bool_ret : Error<
+  "declared return type of function concept must be 'bool'">;
+def err_variable_concept_bool_decl : Error<
+  "declared type of variable concept must be 'bool'">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
@@ -0,0 +1,25 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c+

Re: [PATCH] D16163: [Concepts] Diagnose when return type of a function concept or declaration type of a variable concept is not bool.

2016-01-20 Thread Nathan Wilson via cfe-commits
nwilson marked an inline comment as done.


Comment at: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp:22
@@ +21,3 @@
+template
+concept float fcrtf() { return 5.5; } // expected-error {{declared return type 
of function concept must be 'bool'}}
+

The erroneous test which Hubert was referring to has been removed.


http://reviews.llvm.org/D16163



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2016-01-26 Thread Nathan Wilson via cfe-commits
nwilson added a comment.

Ping.

@rsmith - would you also mind clarifying the comment regarding `setConcept(bool 
IC)` at to whether it should exist at all or simply not have any params?


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r259159 - [Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p5 and p6:

2016-01-28 Thread Nathan Wilson via cfe-commits
Author: nwilson
Date: Thu Jan 28 22:43:59 2016
New Revision: 259159

URL: http://llvm.org/viewvc/llvm-project?rev=259159&view=rev
Log:
[Concepts] Implement a portion of Concepts TS[dcl.spec.concept]p5 and p6:
Diagnose if the return type of a function concept or declaration type of a
variable concept is not bool.

Reviewers: hubert.reinterpretcast

Differential Revision: http://reviews.llvm.org/D16163

Added:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=259159&r1=259158&r2=259159&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 28 22:43:59 
2016
@@ -2074,6 +2074,10 @@ def err_concept_decl_invalid_specifiers
   "'%select{thread_local|inline|friend|constexpr}1'">;
 def err_function_concept_with_params : Error<
   "function concept cannot have any parameters">;
+def err_function_concept_bool_ret : Error<
+  "declared return type of function concept must be 'bool'">;
+def err_variable_concept_bool_decl : Error<
+  "declared type of variable concept must be 'bool'">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=259159&r1=259158&r2=259159&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jan 28 22:43:59 2016
@@ -6001,6 +6001,15 @@ Sema::ActOnVariableDeclarator(Scope *S,
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
+  // following restrictions:
+  // - The declared type shall have the type bool.
+  if (!Context.hasSameType(NewVD->getType(), Context.BoolTy) &&
+  !NewVD->isInvalidDecl()) {
+Diag(D.getIdentifierLoc(), diag::err_variable_concept_bool_decl);
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7682,6 +7691,14 @@ Sema::ActOnFunctionDeclarator(Scope *S,
 }
 
 // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
+// - The declared return type shall have the type bool.
+if (!Context.hasSameType(FPT->getReturnType(), Context.BoolTy)) {
+  Diag(D.getIdentifierLoc(), diag::err_function_concept_bool_ret);
+  NewFD->setInvalidDecl();
+}
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
 // following restrictions:
 // - The declaration's parameter list shall be equivalent to an empty
 //   parameter list.

Modified: 
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp?rev=259159&r1=259158&r2=259159&view=diff
==
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp 
(original)
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp Thu 
Jan 28 22:43:59 2016
@@ -11,3 +11,15 @@ concept bool fcpp(Ts... ts) { return tru
 
 template
 concept bool fcpva(...) { return true; } // expected-error {{function concept 
cannot have any parameters}}
+
+template
+concept const bool fcrtc() { return true; } // expected-error {{declared 
return type of function concept must be 'bool'}}
+
+template
+concept int fcrti() { return 5; } // expected-error {{declared return type of 
function concept must be 'bool'}}
+
+template
+concept float fcrtf() { return 5.5; } // expected-error {{declared return type 
of function concept must be 'bool'}}
+
+template
+concept decltype(auto) fcrtd(void) { return true; } // expected-error 
{{declared return type of function concept must be 'bool'}}

Added: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp?rev=259159&view=auto
==
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp 
(added)
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp Thu 
Jan 28 22:43:59 2016
@@ -0,0 +1,25 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool vc { true };
+
+templa

Re: [PATCH] D16163: [Concepts] Diagnose when return type of a function concept or declaration type of a variable concept is not bool.

2016-01-28 Thread Nathan Wilson via cfe-commits
This revision was automatically updated to reflect the committed changes.
nwilson marked an inline comment as done.
Closed by commit rL259159: [Concepts] Implement a portion of Concepts 
TS[dcl.spec.concept]p5 and p6: (authored by nwilson).

Changed prior to commit:
  http://reviews.llvm.org/D16163?vs=45453&id=46345#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16163

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
  cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp

Index: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
===
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
@@ -0,0 +1,25 @@
+// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
+
+template
+concept bool vc { true };
+
+template
+struct B { typedef bool Boolean; };
+
+template
+B::Boolean concept vctb(!0);
+
+template
+concept const bool vctc { true }; // expected-error {{declared type of 
variable concept must be 'bool'}}
+
+template
+concept int vcti { 5 }; // expected-error {{declared type of variable concept 
must be 'bool'}}
+
+template
+concept float vctf { 5.5 }; // expected-error {{declared type of variable 
concept must be 'bool'}}
+
+template
+concept auto vcta { true }; // expected-error {{declared type of variable 
concept must be 'bool'}}
+
+template
+concept decltype(auto) vctd { true }; // expected-error {{declared type of 
variable concept must be 'bool'}}
Index: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
===
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp
@@ -11,3 +11,15 @@
 
 template
 concept bool fcpva(...) { return true; } // expected-error {{function concept 
cannot have any parameters}}
+
+template
+concept const bool fcrtc() { return true; } // expected-error {{declared 
return type of function concept must be 'bool'}}
+
+template
+concept int fcrti() { return 5; } // expected-error {{declared return type of 
function concept must be 'bool'}}
+
+template
+concept float fcrtf() { return 5.5; } // expected-error {{declared return type 
of function concept must be 'bool'}}
+
+template
+concept decltype(auto) fcrtd(void) { return true; } // expected-error 
{{declared return type of function concept must be 'bool'}}
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -6001,6 +6001,15 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p6: A variable concept has the
+  // following restrictions:
+  // - The declared type shall have the type bool.
+  if (!Context.hasSameType(NewVD->getType(), Context.BoolTy) &&
+  !NewVD->isInvalidDecl()) {
+Diag(D.getIdentifierLoc(), diag::err_variable_concept_bool_decl);
+NewVD->setInvalidDecl(true);
+  }
 }
   }
 
@@ -7683,6 +7692,14 @@
 
 // C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
 // following restrictions:
+// - The declared return type shall have the type bool.
+if (!Context.hasSameType(FPT->getReturnType(), Context.BoolTy)) {
+  Diag(D.getIdentifierLoc(), diag::err_function_concept_bool_ret);
+  NewFD->setInvalidDecl();
+}
+
+// C++ Concepts TS [dcl.spec.concept]p5: A function concept has the
+// following restrictions:
 // - The declaration's parameter list shall be equivalent to an empty
 //   parameter list.
 if (FPT->getNumParams() > 0 || FPT->isVariadic())
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2074,6 +2074,10 @@
   "'%select{thread_local|inline|friend|constexpr}1'">;
 def err_function_concept_with_params : Error<
   "function concept cannot have any parameters">;
+def err_function_concept_bool_ret : Error<
+  "declared return type of function concept must be 'bool'">;
+def err_variable_concept_bool_decl : Error<
+  "declared type of variable concept must be 'bool'">;
 
 // C++11 char16_t/char32_t
 def warn_cxx98_compat_unicode_type : Warning<


Index: cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
===
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp
+++ cfe/trunk/test

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-11-12 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 40105.
nwilson added a comment.

- Remove marking a variable concept invalid when specialized since we'll only 
look at the primary template downstream. This removal let's us use the same 
recovery path as before when 'concept' is specified on a non-template.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7654,6 +7654,17 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope. A concept definition refers to either a
+  // function concept and its definition or a variable concept and its
+  // initializer.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag:: err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5932,6 +5932,16 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+  }
 }
   }
 
@@ -7578,6 +7588,9 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  NewFD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7636,6 +7649,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7897,9 +7919,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
  

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-11-18 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2003
@@ +2002,3 @@
+def err_concept_specified_specialization : Error<
+  "%'concept' cannot be applied on an "
+  "%select{explicit instantiation|explicit specialization|partial 
specialization}0">;

aaron.ballman wrote:
> Is this an extraneous %?
Good catch. I'll remove it when making the commit.


Comment at: lib/Sema/SemaDecl.cpp:7659
@@ +7658,3 @@
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }

hubert.reinterpretcast wrote:
> I don't think the declaration should still be marked as a concept in this 
> case.
Hmm, Richard - did you have any thoughts about this? IIRC, we might be okay 
here by only looking at the concept flag of the primary template.


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-11-30 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:7659
@@ +7658,3 @@
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }

rsmith wrote:
> hubert.reinterpretcast wrote:
> > nwilson wrote:
> > > hubert.reinterpretcast wrote:
> > > > I don't think the declaration should still be marked as a concept in 
> > > > this case.
> > > Hmm, Richard - did you have any thoughts about this? IIRC, we might be 
> > > okay here by only looking at the concept flag of the primary template.
> > A consideration:
> > When processing the body associated with the specialization, should the 
> > requirements for a function concept body be checked?
> I think the `concept` flag logically belongs on the template declaration 
> rather than on the templated declaration; moving it there would make this 
> question irrelevant =)
Sorry for the slow reply.

Okay. That makes sense. So, we'd be okay putting the IsConcept bit (and the 
associated member functions) in TemplateDecl then?

You'd be okay with the extra byte used?


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-11-30 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 41441.
nwilson added a comment.

Updating to r254337


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7665,6 +7665,17 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope. A concept definition refers to either a
+  // function concept and its definition or a variable concept and its
+  // initializer.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag:: err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5943,6 +5943,16 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+  }
 }
   }
 
@@ -7600,6 +7610,9 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  NewFD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7658,6 +7671,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7919,9 +7941,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   HasExplicitTemplateArgs = true;
-
+
   if (NewFD->isInvalidDecl()) {
 HasExplicitTemplateArgs = false;
   } else if (FunctionTemplate) {
Index: include/clang/Basic/DiagnosticSemaKind

Re: [PATCH] D15421: [Feature] Add a builtin for indexing into parameter packs

2015-12-10 Thread Nathan Wilson via cfe-commits
Hi Louis,

It would probably be useful to get the lines of context as well by doing a
full diff as describer here: http://llvm.org/docs/Phabricator.html#id3

For example, git diff -U99 



On Thu, Dec 10, 2015 at 11:32 AM, Louis Dionne via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> ldionne created this revision.
> ldionne added a reviewer: majnemer.
> ldionne added a subscriber: cfe-commits.
>
> This patch adds a `__nth_element` builtin that allows fetching the n-th
> type of a parameter pack with very little compile-time overhead. The patch
> was inspired by r252036 and r252115 by David Majnemer, which add a similar
> `__make_integer_seq` builtin for efficiently creating a
> `std::integer_sequence`.
>
> http://reviews.llvm.org/D15421
>
> Files:
>   include/clang/AST/ASTContext.h
>   include/clang/AST/DeclTemplate.h
>   include/clang/Basic/Builtins.h
>   include/clang/Basic/DiagnosticSemaKinds.td
>   include/clang/Serialization/ASTBitCodes.h
>   lib/AST/ASTContext.cpp
>   lib/AST/DeclTemplate.cpp
>   lib/Lex/PPMacroExpansion.cpp
>   lib/Sema/SemaLookup.cpp
>   lib/Sema/SemaTemplate.cpp
>   lib/Serialization/ASTReader.cpp
>   lib/Serialization/ASTWriter.cpp
>   test/PCH/nth-element.cpp
>   test/SemaCXX/nth_element.cpp
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-12-16 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 43072.
nwilson added a comment.

- Move IsConcept bit and associated member functions from FunctionDecl to 
FunctionTemplateDecl.
- Set the IsConcept flag using getDescribedFunctionTemplate.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7667,6 +7667,17 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope. A concept definition refers to either a
+  // function concept and its definition or a variable concept and its
+  // initializer.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag:: err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5988,6 +5988,16 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+  }
 }
   }
 
@@ -7645,6 +7655,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7703,6 +7717,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7964,9 +7987,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  Templat

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-12-22 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 43469.
nwilson added a comment.

Updating to r256247


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7667,6 +7667,17 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope. A concept definition refers to either a
+  // function concept and its definition or a variable concept and its
+  // initializer.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag:: err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5988,6 +5988,16 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+  }
 }
   }
 
@@ -7645,6 +7655,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7703,6 +7717,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7964,9 +7987,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   HasExplicitTemplateArgs = true;
-
+
   if (NewFD->isInvalidDecl()) {
 HasExplicitTemplateArgs = fal

Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-12-27 Thread Nathan Wilson via cfe-commits
nwilson added inline comments.


Comment at: include/clang/AST/DeclTemplate.h:836
@@ -835,2 +835,3 @@
 
+  bool IsConcept : 1;
 protected:

rsmith wrote:
> This might make more sense on `TemplateDecl`, since we also want this flag 
> for `VarTemplateDecl`s. In any case, please use some existing spare bit for 
> this rather than making all `FunctionTemplateDecl`s 8 bytes larger by putting 
> it here.
@rsmith - Yeah, I originally thought to put it in TemplateDecl but reconsidered 
since ClassTemplateDecls would get it as well . However, I guess by making 
TemplateDecl::TemplatedDecl an IntPointerPair that concern is irrelevant.

@faisalv - Thanks for the info and suggestion! This helped with Richard's 
suggestion (below). FYI - It looks like that IntPointerPair, 
InstantiatedFromMember, is for explicit specializations, and the pointer to 
CommonBase (Common) is null for a function concept's primary template 
declaration. 



Comment at: include/clang/AST/DeclTemplate.h:986
@@ +985,3 @@
+  bool isConcept() const { return IsConcept; }
+  void setConcept(bool IC) { IsConcept = IC; }
+

rsmith wrote:
> Do we need a setter for this? (Can it change after the decl is constructed?)
The setter is used below when we see that `concept` is specified on the 
declaration. So, it wouldn't be initialized (or set)  to true when the decl is 
constructed.  Or, do you have a different opinion on where to set `IsConcept` 
to true such as how `IsConstExpr` is initialized in FunctionDecls being passed 
as a param in the constructor? 


Comment at: lib/Sema/SemaDecl.cpp:7727
@@ +7726,3 @@
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }

Thanks for the suggestion. I'll go with TemplatedDecl and see what you guys 
think.


http://reviews.llvm.org/D13357



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13357: [Concepts] Diagnose when 'concept' is specified on a specialization

2015-12-27 Thread Nathan Wilson via cfe-commits
nwilson updated this revision to Diff 43670.
nwilson added a comment.

- Store the IsConcept boolean flag in TemplateDecl by making TemplatedDecl an 
IntPointerPair, and move the associated member functions into TemplateDecl.
- Remove unnecessary quoted comment.
- Remove an extra space where the diagnostic is used.


http://reviews.llvm.org/D13357

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -41,3 +41,20 @@
 void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+
+template concept bool VCEI { true };
+template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool VCEI; // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool VCPS { true };
+template concept bool VCPS { true }; // expected-error {{'concept' cannot be applied on an partial specialization}}
+
+template concept bool VCES { true };
+template<> concept bool VCES { true }; // expected-error {{'concept' cannot be applied on an explicit specialization}}
+
+template concept bool FCEI() { return true; }
+template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+extern template concept bool FCEI(); // expected-error {{'concept' cannot be applied on an explicit instantiation}}
+
+template concept bool FCES() { return true; }
+template<> concept bool FCES() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7668,6 +7668,15 @@
 Diag(D.getDeclSpec().getConstexprSpecLoc(),
  diag::err_explicit_instantiation_constexpr);
 
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template or variable template,
+  // declared in namespace scope.
+  if (D.getDeclSpec().isConceptSpecified()) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 0;
+return true;
+  }
+
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5988,6 +5988,16 @@
 << 0 << 3;
 NewVD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a [...] variable template, declared
+  // in namespace scope. [...] A concept definition refers to [...] a
+  // variable concept and its initializer.
+  if (IsVariableTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization)
+  << (IsPartialSpecialization ? 2 : 1);
+  }
 }
   }
 
@@ -7645,6 +7655,10 @@
 }
 
 if (isConcept) {
+  // This is a function concept.
+  if (FunctionTemplateDecl *FTD = NewFD->getDescribedFunctionTemplate())
+FTD->setConcept(true);
+
   // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
   // applied only to the definition of a function template [...]
   if (!D.isFunctionDefinition()) {
@@ -7703,6 +7717,15 @@
 << 1 << 3;
 NewFD->setInvalidDecl(true);
   }
+
+  // C++ Concepts TS [dcl.spec.concept]p1: The concept specifier shall be
+  // applied only to the definition of a function template [...], declared
+  // in namespace scope. [...] A concept definition refers to either a
+  // function concept and its definition [...].
+  if (isFunctionTemplateSpecialization) {
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_specified_specialization) << 1;
+  }
 }
 
 // If __module_private__ was specified, mark the function accordingly.
@@ -7964,9 +7987,9 @@
  TemplateId->NumArgs);
   translateTemplateArguments(TemplateArgsPtr,
  TemplateArgs);
-
+
   HasExplicitTemplateAr