c++: Improve error recovery for =.

In a template we were happily embedding error_mark_node in a MODOP_EXPR,
leading to confusion later.

gcc/cp/ChangeLog:

	* typeck.c (build_x_modify_expr): Handle error_mark_node arguments.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/lambda/lambda-ice30.C: Adjust.
	* g++.dg/cpp0x/lambda/lambda-ice31.C: Adjust.
	* g++.dg/ext/fixed1.C: Adjust.
	* g++.dg/template/crash107.C: Adjust.
	* g++.dg/template/error35.C: Adjust.
	* g++.dg/template/sizeof-template-argument.C: Adjust.
This commit is contained in:
Jason Merrill 2020-05-21 10:27:11 -04:00
parent f7272c8a03
commit 4f602147b6
7 changed files with 13 additions and 8 deletions

View File

@ -8768,6 +8768,9 @@ build_x_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
tree overload = NULL_TREE;
tree op = build_nt (modifycode, NULL_TREE, NULL_TREE);
if (lhs == error_mark_node || rhs == error_mark_node)
return cp_expr (error_mark_node, loc);
if (processing_template_decl)
{
if (modifycode == NOP_EXPR

View File

@ -3,11 +3,11 @@
template<int> void foo()
{
int x[=]; // { dg-error "expected" }
int x[=]; // { dg-error "" }
[&x]{};
}
void bar()
{
foo<0>();
foo<0>(); // { dg-prune-output "not declared" }
}

View File

@ -4,5 +4,5 @@
template<typename T> void foo()
{
T x[=]; // { dg-error "expected" }
[&x]{};
[&x]{}; // { dg-prune-output "not declared" }
}

View File

@ -6,3 +6,5 @@ template<int> struct A {};
template<typename> struct B : A<sizeof(0=0r)> {}; // { dg-error "not supported" }
template<typename> struct C : A<sizeof(0=0r)> {}; // { dg-error "not supported" }
// { dg-prune-output "template argument" }

View File

@ -10,9 +10,9 @@ template<typename FP_> struct Vec { // { dg-message "note" "" { target c++17_dow
X = y*rhs.z() - z*rhs.y(); // { dg-error "not declared|no member" }
}
Vec& operator^(Vec& rhs) {
return Vec(*this)^=rhs; // { dg-message "required" }
return Vec(*this)^=rhs;
}
};
Vec<double> v(3,4,12); // { dg-error "no matching|too many initializers" }
Vec<double> V(12,4,3); // { dg-error "no matching|too many initializers" }
Vec<double> c = v^V; // { dg-message "required" }
Vec<double> c = v^V;

View File

@ -1,3 +1,3 @@
// PR c++/33494
template<int> void foo(int(*f=0)()); // { dg-error "declared void|scope|erroneous-expression" }
template<int> void foo(int(*f=0)()); // { dg-error "declared void|scope|cannot be used as a function" }

View File

@ -3,9 +3,9 @@
template<int> struct A {};
template<typename> struct B : A <sizeof(=)> {}; /* { dg-error "expected primary-expression" } */
template<typename> struct B : A <sizeof(=)> {}; /* { dg-error "" } */
template<typename> struct C : A <sizeof(=)> {}; /* { dg-error "expected primary-expression" } */
template<typename> struct C : A <sizeof(=)> {}; /* { dg-error "" } */
int a;