===================================================================
@@ -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;
}
}
===================================================================
@@ -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;
}
===================================================================
@@ -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" }
+};
===================================================================
@@ -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();
};