diff mbox

[C++] PR 58568

Message ID 52535FEE.2010408@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 8, 2013, 1:29 a.m. UTC
Hi,

this ICE on invalid 4.8/4.9 Regression is very easy to fix: just add a 
check for error_mark_node on the return of xref_tag (I'm also removing a 
redundant one a few lines below). This brings us to the same error 
message we get when there are no lambdas involved, eg for the existing 
template/crash27.C:

template<int> struct A
{
template<int N> int A<N>::i;
};

error: type ‘A<N>’ is not derived from type ‘A<<anonymous> >’

which I find quite confusing, in general. Thus, besides the 
error_mark_node change, I'm also proposing to tweak a bit the error 
message in grokdeclarator to the more general wording which we already 
use a few lines above (apparently EDG also uses something similar in 
such cases):

error: invalid use of qualified-name ‘A<N>::i’

If I examine all the testcases we have got in the testsuite sensitive to 
this diagnostic (template/crash27.C, g++.mike/misc9.C, 
g++.other/decl5.C) I don't get the impression that explicitly talking 
about derivation ever adds much, if anything.

Tested x86_64-linux.

Thanks,
Paolo.

/////////////////
/cp
2013-10-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58568
	* lambda.c (begin_lambda_type): Check return value of xref_tag
	for error_mark_node; tidy.
	* decl.c (grokdeclarator): Tweak error message.

/testsuite
2013-10-08  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/58568
	* g++.dg/cpp0x/lambda/lambda-ice10.C: New.
	* g++.old-deja/g++.mike/misc9.C: Adjust.

Comments

Jason Merrill Oct. 8, 2013, 4:25 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 203255)
+++ cp/decl.c	(working copy)
@@ -8774,8 +8774,8 @@  grokdeclarator (const cp_declarator *declarator,
 			     && !uniquely_derived_from_p (ctype,
 							  current_class_type))
 		      {
-			error ("type %qT is not derived from type %qT",
-			       ctype, current_class_type);
+			error ("invalid use of qualified-name %<%T::%D%>",
+			       qualifying_scope, decl);
 			return error_mark_node;
 		      }
 		  }
Index: cp/lambda.c
===================================================================
--- cp/lambda.c	(revision 203255)
+++ cp/lambda.c	(working copy)
@@ -138,6 +138,8 @@  begin_lambda_type (tree lambda)
                      name,
                      /*scope=*/ts_lambda,
                      /*template_header_p=*/false);
+    if (type == error_mark_node)
+      return error_mark_node;
   }
 
   /* Designate it as a struct so that we can use aggregate initialization.  */
@@ -152,8 +154,6 @@  begin_lambda_type (tree lambda)
 
   /* Start the class.  */
   type = begin_class_definition (type);
-  if (type == error_mark_node)
-    return error_mark_node;
 
   return type;
 }
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C	(working copy)
@@ -0,0 +1,8 @@ 
+// PR c++/58568
+// { dg-do compile { target c++11 } }
+
+template<int> struct A
+{
+  static const int i;
+  template<int N> const int A<N>::i = []{ return 0; }(); // { dg-error "invalid use" }
+};
Index: testsuite/g++.old-deja/g++.mike/misc9.C
===================================================================
--- testsuite/g++.old-deja/g++.mike/misc9.C	(revision 203255)
+++ testsuite/g++.old-deja/g++.mike/misc9.C	(working copy)
@@ -8,6 +8,6 @@  class bee {
 
 class foo {
  public:
-  int bee::bar;		// { dg-error "not derived" } you cannot do this
+  int bee::bar;		// { dg-error "invalid use" } you cannot do this
     int me();
 };