Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 274945) +++ cp/cp-tree.h (working copy) @@ -6469,7 +6469,7 @@ extern tree cxx_comdat_group (tree); extern bool cp_missing_noreturn_ok_p (tree); extern bool is_direct_enum_init (tree, tree); extern void initialize_artificial_var (tree, vec *); -extern tree check_var_type (tree, tree); +extern tree check_var_type (tree, tree, location_t); extern tree reshape_init (tree, tree, tsubst_flags_t); extern tree next_initializable_field (tree); extern tree fndecl_declared_return_type (tree); Index: cp/decl.c =================================================================== --- cp/decl.c (revision 274945) +++ cp/decl.c (working copy) @@ -10278,19 +10278,20 @@ check_special_function_return_type (special_functi error-recovery purposes. */ tree -check_var_type (tree identifier, tree type) +check_var_type (tree identifier, tree type, location_t loc) { if (VOID_TYPE_P (type)) { if (!identifier) - error ("unnamed variable or field declared void"); + error_at (loc, "unnamed variable or field declared void"); else if (identifier_p (identifier)) { gcc_assert (!IDENTIFIER_ANY_OP_P (identifier)); - error ("variable or field %qE declared void", identifier); + error_at (loc, "variable or field %qE declared void", + identifier); } else - error ("variable or field declared void"); + error_at (loc, "variable or field declared void"); type = error_mark_node; } @@ -12407,7 +12408,7 @@ grokdeclarator (const cp_declarator *declarator, error message later. */ if (decl_context != PARM) { - type = check_var_type (unqualified_id, type); + type = check_var_type (unqualified_id, type, id_loc); if (type == error_mark_node) return error_mark_node; } Index: cp/pt.c =================================================================== --- cp/pt.c (revision 274945) +++ cp/pt.c (working copy) @@ -13894,7 +13895,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t com /* Wait until cp_finish_decl to set this again, to handle circular dependency (template/instantiate6.C). */ DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (r) = 0; - type = check_var_type (DECL_NAME (r), type); + type = check_var_type (DECL_NAME (r), type, + DECL_SOURCE_LOCATION (r)); if (DECL_HAS_VALUE_EXPR_P (t)) { Index: testsuite/g++.dg/cpp0x/pr84676.C =================================================================== --- testsuite/g++.dg/cpp0x/pr84676.C (revision 274945) +++ testsuite/g++.dg/cpp0x/pr84676.C (working copy) @@ -1,4 +1,5 @@ // { dg-do compile { target c++11 } } int a; -void b(__attribute__((c([](int *) {} (a == (0 = auto)))))); // { dg-error "" } +void b(__attribute__((c([](int *) {} (a == (0 = auto)))))); // { dg-error "6:variable or field .b. declared void" } +// { dg-error "expected" "" { target c++11 } .-1 } Index: testsuite/g++.dg/other/pr88187.C =================================================================== --- testsuite/g++.dg/other/pr88187.C (revision 274945) +++ testsuite/g++.dg/other/pr88187.C (working copy) @@ -2,6 +2,6 @@ // { dg-do compile } template struct A; -void f (A ()); // { dg-error "variable or field 'f' declared void" "" { target c++14_down } } +void f (A ()); // { dg-error "6:variable or field 'f' declared void" "" { target c++14_down } } // { dg-error "missing template arguments before '\\(' token" "" { target c++14_down } .-1 } // { dg-error "'auto' parameter not permitted in this context" "" { target c++17 } .-2 } Index: testsuite/g++.dg/parse/crash13.C =================================================================== --- testsuite/g++.dg/parse/crash13.C (revision 274945) +++ testsuite/g++.dg/parse/crash13.C (working copy) @@ -12,7 +12,8 @@ struct A }; template -void func(A::B* ) // { dg-error "variable|template|expression" } +void func(A::B* ) // { dg-error "6:variable or field .func. declared void" } +// { dg-error "expected" "" { target *-*-* } .-1 } { } Index: testsuite/g++.dg/parse/crash46.C =================================================================== --- testsuite/g++.dg/parse/crash46.C (revision 274945) +++ testsuite/g++.dg/parse/crash46.C (working copy) @@ -2,17 +2,17 @@ // { dg-do compile } void -foo (_Decimal32) // { dg-error "declared void" "declared" } +foo (_Decimal32) // { dg-error "1:variable or field .foo. declared void" "declared" } { } // { dg-error "was not declared" "not" { target *-*-* } 5 } void -bar (_Bool) // { dg-error "declared void" "declared" } +bar (_Bool) // { dg-error "1:variable or field .bar. declared void" "declared" } { } // { dg-error "was not declared" "not" { target *-*-* } 10 } void -baz (_Fract) // { dg-error "declared void" "declared" } +baz (_Fract) // { dg-error "1:variable or field .baz. declared void" "declared" } { } // { dg-error "was not declared" "not" { target *-*-* } 15 } Index: testsuite/g++.dg/parse/template28.C =================================================================== --- testsuite/g++.dg/parse/template28.C (revision 274945) +++ testsuite/g++.dg/parse/template28.C (working copy) @@ -2,7 +2,8 @@ template struct A {}; -template void foo(A=A()) {} // { dg-error "" } +template void foo(A=A()) {} // { dg-error "24:variable or field .foo. declared void" } +// { dg-error "template" "" { target *-*-* } .-1 } void bar() { Index: testsuite/g++.dg/parse/typename4.C =================================================================== --- testsuite/g++.dg/parse/typename4.C (revision 274945) +++ testsuite/g++.dg/parse/typename4.C (working copy) @@ -4,4 +4,5 @@ // PR c++/9364: ICE processing typename with name error. -void find(typename int&); // { dg-error "typename|void|expected" } +void find(typename int&); // { dg-error "6:variable or field .find. declared void" } +// { dg-error "expected" "" { target *-*-* } .-1 } Index: testsuite/g++.dg/spellcheck-typenames.C =================================================================== --- testsuite/g++.dg/spellcheck-typenames.C (revision 274945) +++ testsuite/g++.dg/spellcheck-typenames.C (working copy) @@ -4,10 +4,10 @@ void test_1 (signed char e); /* PR c/70339. */ -void test_2 (singed char e); // { dg-error "21: variable or field 'test_2' declared void" } +void test_2 (singed char e); // { dg-error "6: variable or field 'test_2' declared void" } /* { dg-begin-multiline-output "" } void test_2 (singed char e); - ^~~~ + ^~~~~~ { dg-end-multiline-output "" } */ // { dg-message "14: 'singed' was not declared in this scope; did you mean 'signed'\\?" "" { target *-*-* } 7 } /* { dg-begin-multiline-output "" } @@ -16,10 +16,10 @@ void test_1 (signed char e); signed { dg-end-multiline-output "" } */ -void test_3 (car e); // { dg-error "14: variable or field 'test_3' declared void" } +void test_3 (car e); // { dg-error "6: variable or field 'test_3' declared void" } /* { dg-begin-multiline-output "" } void test_3 (car e); - ^~~ + ^~~~~~ { dg-end-multiline-output "" } */ // { dg-message "14: 'car' was not declared in this scope; did you mean 'char'\\?" "" { target *-*-* } 19 } /* { dg-begin-multiline-output "" }