On Mon, Apr 1, 2013 at 2:55 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>If this is never legal, why can't we warn about this in the template declaration?</div></div></blockquote><div><br></div><div>What do you mean by "this"?</div><div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>And, why isn't this legal? You can have "enum E : T" directly in a class template [temp.mem.enum], as well as class members [temp.mem.class].</div>
<div><br></div><div>I assume both of these questions have good answers; I'm just curious.</div><span class="HOEnZb"><font color="#888888"><div>Jordan</div></font></span><div><div class="h5"><div><br></div><br><div><div>
On Apr 1, 2013, at 14:43 , Richard Smith <<a href="mailto:richard-llvm@metafoo.co.uk" target="_blank">richard-llvm@metafoo.co.uk</a>> wrote:</div><br><blockquote type="cite"><div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Author: rsmith<br>Date: Mon Apr  1 16:43:41 2013<br>New Revision: 178502<br><br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project?rev=178502&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=178502&view=rev</a><br>
Log:<br>PR15633: Note that we are EnteringContext when parsing the nested name<br>specifier for an enumeration. Also fix a crash-on-invalid if a non-dependent<br>name specifier is used to declare an enum template.<br><br>
Modified:<br>   cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td<br>   cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td<br>   cfe/trunk/lib/Parse/ParseDecl.cpp<br>   cfe/trunk/lib/Sema/SemaDecl.cpp<br>   cfe/trunk/test/SemaCXX/enum-scoped.cpp<br>
<br>Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=178502&r1=178501&r2=178502&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=178502&r1=178501&r2=178502&view=diff</a><br>
==============================================================================<br>--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)<br>+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Mon Apr  1 16:43:41 2013<br>
@@ -77,6 +77,7 @@ def note_decl_hiding_tag_type : Note<<br>  "%1 %0 is hidden by a non-type declaration of %0 here">;<br>def err_attribute_not_type_attr : Error<<br>  "%0 attribute cannot be applied to types">;<br>
+def err_enum_template : Error<"enumeration cannot be a template">;<br><br>// Sema && Lex<br>def ext_c99_longlong : Extension<<br><br>Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td<br>
URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=178502&r1=178501&r2=178502&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=178502&r1=178501&r2=178502&view=diff</a><br>
==============================================================================<br>--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)<br>+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Apr  1 16:43:41 2013<br>
@@ -556,7 +556,6 @@ def err_explicit_instantiation_with_defi<br>    "explicit template instantiation cannot have a definition; if this "<br>    "definition is meant to be an explicit specialization, add '<>' after the "<br>
    "'template' keyword">;<br>-def err_enum_template : Error<"enumeration cannot be a template">;<br>def err_explicit_instantiation_enum : Error<<br>    "enumerations cannot be explicitly instantiated">;<br>
def err_expected_template_parameter : Error<"expected template parameter">;<br><br>Modified: cfe/trunk/lib/Parse/ParseDecl.cpp<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=178502&r1=178501&r2=178502&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=178502&r1=178501&r2=178502&view=diff</a><br>
==============================================================================<br>--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)<br>+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Apr  1 16:43:41 2013<br>@@ -3262,7 +3262,7 @@ void Parser::ParseEnumSpecifier(SourceLo<br>
    ColonProtectionRAIIObject X(*this, AllowFixedUnderlyingType);<br><br>    if (ParseOptionalCXXScopeSpecifier(SS, ParsedType(),<br>-                                       /*EnteringContext=*/false))<br>+                                       /*EnteringContext=*/true))<br>
      return;<br><br>    if (SS.isSet() && Tok.isNot(tok::identifier)) {<br><br>Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=178502&r1=178501&r2=178502&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=178502&r1=178501&r2=178502&view=diff</a><br>
==============================================================================<br>--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Apr  1 16:43:41 2013<br>@@ -9387,6 +9387,11 @@ Decl *Sema::ActOnTag(Scope *S, unsigned<br>
                                                    TUK == TUK_Friend,<br>                                                    isExplicitSpecialization,<br>                                                    Invalid)) {<br>
+      if (Kind == TTK_Enum) {<br>+        Diag(KWLoc, diag::err_enum_template);<br>+        return 0;<br>+      }<br>+<br>      if (TemplateParams->size() > 0) {<br>        // This is a declaration or definition of a class template (which may<br>
        // be a member of another template).<br><br>Modified: cfe/trunk/test/SemaCXX/enum-scoped.cpp<br>URL:<span> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-scoped.cpp?rev=178502&r1=178501&r2=178502&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-scoped.cpp?rev=178502&r1=178501&r2=178502&view=diff</a><br>
==============================================================================<br>--- cfe/trunk/test/SemaCXX/enum-scoped.cpp (original)<br>+++ cfe/trunk/test/SemaCXX/enum-scoped.cpp Mon Apr  1 16:43:41 2013<br>@@ -252,3 +252,17 @@ namespace pr13128 {<br>
    enum class E { C };<br>  };<br>}<br>+<br>+namespace PR15633 {<br>+  template<typename T> struct A {<br>+    struct B {<br>+      enum class E : T;<br>+      enum class E2 : T;<br>+    };<br>+  };<br>+  template<typename T> enum class A<T>::B::E { e };<br>
+  template class A<int>;<br>+<br>+  struct B { enum class E; };<br>+  template<typename T> enum class B::E { e }; // expected-error {{enumeration cannot be a template}}<br>+}<br><br><br>_______________________________________________<br>
cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></div>
</blockquote></div><br></div></div></div></blockquote></div><br>