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:
parent
f7272c8a03
commit
4f602147b6
@ -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
|
||||
|
@ -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" }
|
||||
}
|
||||
|
@ -4,5 +4,5 @@
|
||||
template<typename T> void foo()
|
||||
{
|
||||
T x[=]; // { dg-error "expected" }
|
||||
[&x]{};
|
||||
[&x]{}; // { dg-prune-output "not declared" }
|
||||
}
|
||||
|
@ -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" }
|
||||
|
@ -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;
|
||||
|
@ -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" }
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user