From: Paolo Carlini Date: Thu, 29 Aug 2019 09:01:26 +0000 (+0000) Subject: decl.c (check_var_type): Add location_t parameter and use it. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c3bad34748071038343f8b88a30128faee7c5c0c;p=gcc.git decl.c (check_var_type): Add location_t parameter and use it. /cp 2019-08-29 Paolo Carlini * decl.c (check_var_type): Add location_t parameter and use it. (grokdeclarator): Adjust call. * pt.c (tsubst_decl): Likewise. * cp-tree.h: Adjust declaration. /testsuite 2019-08-29 Paolo Carlini * g++.dg/spellcheck-typenames.C: Adjust expected locations. * g++.dg/cpp0x/pr84676.C: Check locations. * g++.dg/other/pr88187.C: Likewise. * g++.dg/parse/crash13.C: Likewise. * g++.dg/parse/crash46.C: Likewise. * g++.dg/parse/template28.C: Likewise. * g++.dg/parse/typename4.C: Likewise. From-SVN: r275025 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 818d32b29d3..37de3d91870 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-08-29 Paolo Carlini + + * decl.c (check_var_type): Add location_t parameter and use it. + (grokdeclarator): Adjust call. + * pt.c (tsubst_decl): Likewise. + * cp-tree.h: Adjust declaration. + 2019-08-28 Marek Polacek Implement P1152R4: Deprecating some uses of volatile. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 0e514d5cc22..3c69e54c885 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -6478,7 +6478,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); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2aef330455f..3497874cb81 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10298,19 +10298,20 @@ check_special_function_return_type (special_function_kind sfk, 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; } @@ -12470,7 +12471,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; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 54d36f91ddc..13d3db9a0f7 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13894,8 +13894,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) /* 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)) { tree ve = DECL_VALUE_EXPR (t); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a4f36e167c..a051dda738e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2019-08-29 Paolo Carlini + + * g++.dg/spellcheck-typenames.C: Adjust expected locations. + * g++.dg/cpp0x/pr84676.C: Check locations. + * g++.dg/other/pr88187.C: Likewise. + * g++.dg/parse/crash13.C: Likewise. + * g++.dg/parse/crash46.C: Likewise. + * g++.dg/parse/template28.C: Likewise. + * g++.dg/parse/typename4.C: Likewise. + 2019-08-29 Richard Biener PR tree-optimization/91568 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr84676.C b/gcc/testsuite/g++.dg/cpp0x/pr84676.C index 94d86716649..0bd8cc00c2c 100644 --- a/gcc/testsuite/g++.dg/cpp0x/pr84676.C +++ b/gcc/testsuite/g++.dg/cpp0x/pr84676.C @@ -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 } diff --git a/gcc/testsuite/g++.dg/other/pr88187.C b/gcc/testsuite/g++.dg/other/pr88187.C index 17c14f4e552..ebdafddc634 100644 --- a/gcc/testsuite/g++.dg/other/pr88187.C +++ b/gcc/testsuite/g++.dg/other/pr88187.C @@ -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 } diff --git a/gcc/testsuite/g++.dg/parse/crash13.C b/gcc/testsuite/g++.dg/parse/crash13.C index 3c298ec8ede..ab6401133cb 100644 --- a/gcc/testsuite/g++.dg/parse/crash13.C +++ b/gcc/testsuite/g++.dg/parse/crash13.C @@ -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 } { } diff --git a/gcc/testsuite/g++.dg/parse/crash46.C b/gcc/testsuite/g++.dg/parse/crash46.C index 0ae22480fde..cb60ad2683e 100644 --- a/gcc/testsuite/g++.dg/parse/crash46.C +++ b/gcc/testsuite/g++.dg/parse/crash46.C @@ -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 } diff --git a/gcc/testsuite/g++.dg/parse/template28.C b/gcc/testsuite/g++.dg/parse/template28.C index 6868bc85285..bfd8af17b67 100644 --- a/gcc/testsuite/g++.dg/parse/template28.C +++ b/gcc/testsuite/g++.dg/parse/template28.C @@ -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() { diff --git a/gcc/testsuite/g++.dg/parse/typename4.C b/gcc/testsuite/g++.dg/parse/typename4.C index 529889df60c..94ab98f45ff 100644 --- a/gcc/testsuite/g++.dg/parse/typename4.C +++ b/gcc/testsuite/g++.dg/parse/typename4.C @@ -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 } diff --git a/gcc/testsuite/g++.dg/spellcheck-typenames.C b/gcc/testsuite/g++.dg/spellcheck-typenames.C index 25d3f1dcefd..6adf724a3b7 100644 --- a/gcc/testsuite/g++.dg/spellcheck-typenames.C +++ b/gcc/testsuite/g++.dg/spellcheck-typenames.C @@ -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_2 (singed char e); // { dg-error "21: variable or field 'test_2' decla 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 "" }