+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>
Implement P1152R4: Deprecating some uses of volatile.
extern bool cp_missing_noreturn_ok_p (tree);
extern bool is_direct_enum_init (tree, tree);
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 next_initializable_field (tree);
extern tree fndecl_declared_return_type (tree);
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;
}
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;
}
/* 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);
+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>
PR tree-optimization/91568
// { 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 }
// { dg-do compile }
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 "'auto' parameter not permitted in this context" "" { target c++17 } .-2 }
};
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 }
{
}
// { 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 }
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()
{
// 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 }
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 "" }
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 "" }