Commit c3bad347 by Paolo Carlini Committed by Paolo Carlini

decl.c (check_var_type): Add location_t parameter and use it.

/cp
2019-08-29  Paolo Carlini  <paolo.carlini@oracle.com>

	* 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  <paolo.carlini@oracle.com>

	* 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
parent f48e4da3
2019-08-29 Paolo Carlini <paolo.carlini@oracle.com>
* 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 <polacek@redhat.com> 2019-08-28 Marek Polacek <polacek@redhat.com>
Implement P1152R4: Deprecating some uses of volatile. Implement P1152R4: Deprecating some uses of volatile.
......
...@@ -6478,7 +6478,7 @@ extern tree cxx_comdat_group (tree); ...@@ -6478,7 +6478,7 @@ extern tree cxx_comdat_group (tree);
extern bool cp_missing_noreturn_ok_p (tree); extern bool cp_missing_noreturn_ok_p (tree);
extern bool is_direct_enum_init (tree, tree); extern bool is_direct_enum_init (tree, tree);
extern void initialize_artificial_var (tree, vec<constructor_elt, va_gc> *); extern void initialize_artificial_var (tree, vec<constructor_elt, va_gc> *);
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 reshape_init (tree, tree, tsubst_flags_t);
extern tree next_initializable_field (tree); extern tree next_initializable_field (tree);
extern tree fndecl_declared_return_type (tree); extern tree fndecl_declared_return_type (tree);
......
...@@ -10298,19 +10298,20 @@ check_special_function_return_type (special_function_kind sfk, ...@@ -10298,19 +10298,20 @@ check_special_function_return_type (special_function_kind sfk,
error-recovery purposes. */ error-recovery purposes. */
tree tree
check_var_type (tree identifier, tree type) check_var_type (tree identifier, tree type, location_t loc)
{ {
if (VOID_TYPE_P (type)) if (VOID_TYPE_P (type))
{ {
if (!identifier) if (!identifier)
error ("unnamed variable or field declared void"); error_at (loc, "unnamed variable or field declared void");
else if (identifier_p (identifier)) else if (identifier_p (identifier))
{ {
gcc_assert (!IDENTIFIER_ANY_OP_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 else
error ("variable or field declared void"); error_at (loc, "variable or field declared void");
type = error_mark_node; type = error_mark_node;
} }
...@@ -12470,7 +12471,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -12470,7 +12471,7 @@ grokdeclarator (const cp_declarator *declarator,
error message later. */ error message later. */
if (decl_context != PARM) 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) if (type == error_mark_node)
return error_mark_node; return error_mark_node;
} }
......
...@@ -13894,8 +13894,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) ...@@ -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 /* Wait until cp_finish_decl to set this again, to handle
circular dependency (template/instantiate6.C). */ circular dependency (template/instantiate6.C). */
DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (r) = 0; 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)) if (DECL_HAS_VALUE_EXPR_P (t))
{ {
tree ve = DECL_VALUE_EXPR (t); tree ve = DECL_VALUE_EXPR (t);
......
2019-08-29 Paolo Carlini <paolo.carlini@oracle.com>
* 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 <rguenther@suse.de> 2019-08-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/91568 PR tree-optimization/91568
......
// { dg-do compile { target c++11 } } // { dg-do compile { target c++11 } }
int a; 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 }
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
// { dg-do compile } // { dg-do compile }
template <int> struct A; template <int> 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 "missing template arguments before '\\(' token" "" { target c++14_down } .-1 }
// { dg-error "'auto' parameter not permitted in this context" "" { target c++17 } .-2 } // { dg-error "'auto' parameter not permitted in this context" "" { target c++17 } .-2 }
...@@ -12,7 +12,8 @@ struct A ...@@ -12,7 +12,8 @@ struct A
}; };
template <typename T> template <typename T>
void func(A<T>::B* ) // { dg-error "variable|template|expression" } void func(A<T>::B* ) // { dg-error "6:variable or field .func. declared void" }
// { dg-error "expected" "" { target *-*-* } .-1 }
{ {
} }
......
...@@ -2,17 +2,17 @@ ...@@ -2,17 +2,17 @@
// { dg-do compile } // { dg-do compile }
void 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 } // { dg-error "was not declared" "not" { target *-*-* } 5 }
void 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 } // { dg-error "was not declared" "not" { target *-*-* } 10 }
void 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 } // { dg-error "was not declared" "not" { target *-*-* } 15 }
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
template<class> struct A {}; template<class> struct A {};
template<class T> void foo(A<T>=A<T>()) {} // { dg-error "" } template<class T> void foo(A<T>=A<T>()) {} // { dg-error "24:variable or field .foo. declared void" }
// { dg-error "template" "" { target *-*-* } .-1 }
void bar() void bar()
{ {
......
...@@ -4,4 +4,5 @@ ...@@ -4,4 +4,5 @@
// PR c++/9364: ICE processing typename with name error. // 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 }
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
void test_1 (signed char e); void test_1 (signed char e);
/* PR c/70339. */ /* 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 "" } /* { dg-begin-multiline-output "" }
void test_2 (singed char e); void test_2 (singed char e);
^~~~ ^~~~~~
{ dg-end-multiline-output "" } */ { dg-end-multiline-output "" } */
// { dg-message "14: 'singed' was not declared in this scope; did you mean 'signed'\\?" "" { target *-*-* } 7 } // { dg-message "14: 'singed' was not declared in this scope; did you mean 'signed'\\?" "" { target *-*-* } 7 }
/* { dg-begin-multiline-output "" } /* { dg-begin-multiline-output "" }
...@@ -16,10 +16,10 @@ void test_2 (singed char e); // { dg-error "21: variable or field 'test_2' decla ...@@ -16,10 +16,10 @@ void test_2 (singed char e); // { dg-error "21: variable or field 'test_2' decla
signed signed
{ dg-end-multiline-output "" } */ { 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 "" } /* { dg-begin-multiline-output "" }
void test_3 (car e); void test_3 (car e);
^~~ ^~~~~~
{ dg-end-multiline-output "" } */ { dg-end-multiline-output "" } */
// { dg-message "14: 'car' was not declared in this scope; did you mean 'char'\\?" "" { target *-*-* } 19 } // { dg-message "14: 'car' was not declared in this scope; did you mean 'char'\\?" "" { target *-*-* } 19 }
/* { dg-begin-multiline-output "" } /* { dg-begin-multiline-output "" }
......
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