Commit 03b8c9bf by Jason Merrill Committed by Jason Merrill

pt.c (tsubst_default_argument): Indicate where the default argument is being instantiated for.

	* pt.c (tsubst_default_argument): Indicate where the default
	argument is being instantiated for.
	(tsubst_expr): Restore previous location.
	(tsubst_copy_and_build): Set and restore location.
	* call.c (build_new_method_call_1): Remember location of call.
	* semantics.c (finish_call_expr): Here too.
	* parser.c (cp_parser_omp_for_loop): Remember the location of the
	increment expression.

From-SVN: r190662
parent b21deb04
2012-08-24 Jason Merrill <jason@redhat.com> 2012-08-24 Jason Merrill <jason@redhat.com>
* pt.c (tsubst_default_argument): Indicate where the default
argument is being instantiated for.
(tsubst_expr): Restore previous location.
(tsubst_copy_and_build): Set and restore location.
* call.c (build_new_method_call_1): Remember location of call.
* semantics.c (finish_call_expr): Here too.
* parser.c (cp_parser_omp_for_loop): Remember the location of the
increment expression.
* pt.c (resolve_overloaded_unification): Use coerce_template_parms * pt.c (resolve_overloaded_unification): Use coerce_template_parms
instead of get_bindings. instead of get_bindings.
(resolve_nondeduced_context): Likewise. (resolve_nondeduced_context): Likewise.
......
...@@ -7537,6 +7537,7 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args, ...@@ -7537,6 +7537,7 @@ build_new_method_call_1 (tree instance, tree fns, VEC(tree,gc) **args,
build_min (COMPONENT_REF, TREE_TYPE (CALL_EXPR_FN (call)), build_min (COMPONENT_REF, TREE_TYPE (CALL_EXPR_FN (call)),
orig_instance, orig_fns, NULL_TREE), orig_instance, orig_fns, NULL_TREE),
orig_args)); orig_args));
SET_EXPR_LOCATION (call, input_location);
call = convert_from_reference (call); call = convert_from_reference (call);
if (cast_to_void) if (cast_to_void)
call = build_nop (void_type_node, call); call = build_nop (void_type_node, call);
......
...@@ -26603,6 +26603,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses) ...@@ -26603,6 +26603,8 @@ cp_parser_omp_for_loop (cp_parser *parser, tree clauses, tree *par_clauses)
incr = cp_parser_omp_for_incr (parser, real_decl); incr = cp_parser_omp_for_incr (parser, real_decl);
else else
incr = cp_parser_expression (parser, false, NULL); incr = cp_parser_expression (parser, false, NULL);
if (CAN_HAVE_LOCATION_P (incr) && !EXPR_HAS_LOCATION (incr))
SET_EXPR_LOCATION (incr, input_location);
} }
if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
......
...@@ -2062,6 +2062,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, ...@@ -2062,6 +2062,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual,
&& type_dependent_expression_p (current_class_ref))) && type_dependent_expression_p (current_class_ref)))
{ {
result = build_nt_call_vec (fn, *args); result = build_nt_call_vec (fn, *args);
SET_EXPR_LOCATION (result, EXPR_LOC_OR_HERE (fn));
KOENIG_LOOKUP_P (result) = koenig_p; KOENIG_LOOKUP_P (result) = koenig_p;
if (cfun) if (cfun)
{ {
......
...@@ -8,8 +8,8 @@ template <class F, int N> ...@@ -8,8 +8,8 @@ template <class F, int N>
void ft (F f, typename enable_if<N!=0, int>::type) {} void ft (F f, typename enable_if<N!=0, int>::type) {}
template< class F, int N > template< class F, int N >
decltype(ft<F, N-1> (F(), 0)) decltype(ft<F, N-1> (F(), 0)) // { dg-error "depth" }
ft (F f, typename enable_if<N==0, int>::type) {} // { dg-error "depth" } ft (F f, typename enable_if<N==0, int>::type) {}
int main() { int main() {
ft<struct a*, 2> (0, 0); // { dg-message "from here" } ft<struct a*, 2> (0, 0); // { dg-message "from here" }
......
...@@ -9,8 +9,8 @@ typename enable_if<x==0,int>::type ...@@ -9,8 +9,8 @@ typename enable_if<x==0,int>::type
ft() {} ft() {}
template<class F, int N> template<class F, int N>
decltype (ft<F> (F())) decltype (ft<F> (F())) // { dg-error "depth" }
ft() {} // { dg-error "depth" } ft() {}
int main() { int main() {
ft<struct a*, 0>(); // { dg-error "no match|wrong number" } ft<struct a*, 0>(); // { dg-error "no match|wrong number" }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// { dg-options -std=c++0x } // { dg-options -std=c++0x }
template <typename T> template <typename T>
auto make_array(const T& il) -> // { dg-error "not declared" } auto make_array(const T& il) ->
decltype(make_array(il)) decltype(make_array(il)) // { dg-error "not declared" }
{ } { }
int main() int main()
......
...@@ -24,3 +24,5 @@ int main() ...@@ -24,3 +24,5 @@ int main()
{ {
g({1}); // { dg-warning "deduc" } g({1}); // { dg-warning "deduc" }
} }
// { dg-prune-output "-fno-deduce-init-list" }
...@@ -10,15 +10,15 @@ template <class T> decltype(g1(T())) f1() ...@@ -10,15 +10,15 @@ template <class T> decltype(g1(T())) f1()
{ return g1(T()); } { return g1(T()); }
int i1 = f1<int>(); // OK, g1(int) was declared before the first f1 int i1 = f1<int>(); // OK, g1(int) was declared before the first f1
template <class T> decltype(g2(T())) f2(); template <class T> decltype(g2(T())) f2(); // { dg-error "g2. was not declared" }
int g2(int); int g2(int);
template <class T> decltype(g2(T())) f2() // { dg-error "g2. was not declared" } template <class T> decltype(g2(T())) f2()
{ return g2(T()); } { return g2(T()); }
int i2 = f2<int>(); // { dg-error "no match" } int i2 = f2<int>(); // { dg-error "no match" }
int g3(); int g3();
template <class T> decltype(g3(T())) f3(); template <class T> decltype(g3(T())) f3(); // { dg-error "too many arguments" }
int g3(int); int g3(int);
template <class T> decltype(g3(T())) f3() // { dg-error "too many arguments" } template <class T> decltype(g3(T())) f3()
{ return g3(T()); } { return g3(T()); }
int i3 = f3<int>(); // { dg-error "no match" } int i3 = f3<int>(); // { dg-error "no match" }
...@@ -19,8 +19,8 @@ struct Bind ...@@ -19,8 +19,8 @@ struct Bind
R f(); R f();
template<typename R template<typename R
= decltype( val<const F>()( ) )> = decltype( val<const F>()( ) )> // { dg-error "no match" }
R f() const; // { dg-error "no match" } R f() const;
}; };
int main() int main()
......
...@@ -8,7 +8,7 @@ template <typename T> ...@@ -8,7 +8,7 @@ template <typename T>
void void
f1 (void) f1 (void)
{ {
#pragma omp for // { dg-error "forbids incrementing a pointer of type" } #pragma omp for
for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" } for (void *q = (void *)p; q < (void *) (p + 4); q++) // { dg-error "forbids incrementing a pointer of type" }
; ;
} }
......
// PR c++/5247 // PR c++/5247
template<typename T> template<typename T>
int foo (T t, int = foo(T())); int foo (T t, int = foo(T())); // { dg-error "recursive" }
struct A { }; struct A { };
int main() int main()
{ {
foo(A()); // { dg-error "default argument" } foo(A()); // { dg-message "default argument" }
} }
...@@ -26,7 +26,7 @@ template<bool> struct S { ...@@ -26,7 +26,7 @@ template<bool> struct S {
S(unsigned int = BBB::foo()->AAA::get()); /* { dg-error "is not a base of" } */ S(unsigned int = BBB::foo()->AAA::get()); /* { dg-error "is not a base of" } */
}; };
template<bool> struct SS { template<bool> struct SS {
SS(unsigned int = BBB::foo()->get()); SS(unsigned int = BBB::foo()->get()); /* { dg-error "within this context" } */
}; };
void bar() void bar()
...@@ -38,5 +38,5 @@ void bar() ...@@ -38,5 +38,5 @@ void bar()
i.C::foo<0>(); /* { dg-error "which is of non-class type" } */ i.C::foo<0>(); /* { dg-error "which is of non-class type" } */
S<false> s; /* { dg-error "default argument" } */ S<false> s; /* { dg-error "default argument" } */
SS<false> ss; /* { dg-error "within this context" } */ SS<false> ss;
} }
// PR c++/50861 // PR c++/50861
template<class T> struct A {A(int b=k(0));}; // { dg-error "arguments" } template<class T> struct A {A(int b=k(0));}; // { dg-error "parameter|arguments" }
void f(int k){A<int> a;} // // { dg-error "parameter|declared" } void f(int k){A<int> a;} // // { dg-error "declared" }
// { dg-message "note" "note" { target *-*-* } 3 } // { dg-message "note" "note" { target *-*-* } 3 }
// PR c++/34397 // PR c++/34397
template<typename T, int = T()[0]> struct A // { dg-error "subscripted|template" } template<typename T, int = T()[0]> struct A // { dg-error "subscripted" }
{ {
typedef A<T> B; typedef A<T> B;
}; };
A<int> a; // { dg-error "declaration" } A<int> a; // { dg-error "declaration" }
// { dg-prune-output "template argument 2 is invalid" }
...@@ -30,10 +30,10 @@ void test01() ...@@ -30,10 +30,10 @@ void test01()
{ {
const int dummy = 0; const int dummy = 0;
std::bind(&inc, _1)(0); // { dg-error "no match" } std::bind(&inc, _1)(0); // { dg-error "no match" }
// { dg-error "rvalue|const" "" { target *-*-* } 1206 } // { dg-error "rvalue|const" "" { target *-*-* } 1207 }
// { dg-error "rvalue|const" "" { target *-*-* } 1219 } // { dg-error "rvalue|const" "" { target *-*-* } 1221 }
// { dg-error "rvalue|const" "" { target *-*-* } 1233 } // { dg-error "rvalue|const" "" { target *-*-* } 1235 }
// { dg-error "rvalue|const" "" { target *-*-* } 1247 } // { dg-error "rvalue|const" "" { target *-*-* } 1249 }
std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" } std::bind(&inc, std::ref(dummy))(); // { dg-error "no match" }
} }
......
...@@ -51,5 +51,5 @@ test04() ...@@ -51,5 +51,5 @@ test04()
// { dg-error "required from here" "" { target *-*-* } 46 } // { dg-error "required from here" "" { target *-*-* } 46 }
// { dg-error "denominator cannot be zero" "" { target *-*-* } 265 } // { dg-error "denominator cannot be zero" "" { target *-*-* } 265 }
// { dg-error "out of range" "" { target *-*-* } 266 } // { dg-error "out of range" "" { target *-*-* } 266 }
// { dg-error "overflow in constant expression" "" { target *-*-* } 62 } // { dg-error "overflow in constant expression" "" { target *-*-* } 61 }
// { dg-prune-output "not a member" } // { dg-prune-output "not a member" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment