===================================================================
@@ -5974,8 +5974,9 @@ extern tree build_vtbl_address (t
extern void cxx_dup_lang_specific_decl (tree);
extern void yyungetc (int, int);
-extern tree unqualified_name_lookup_error (tree);
-extern tree unqualified_fn_lookup_error (tree);
+extern tree unqualified_name_lookup_error (tree,
+ location_t = UNKNOWN_LOCATION);
+extern tree unqualified_fn_lookup_error (cp_expr);
extern tree build_lang_decl (enum tree_code, tree, tree);
extern tree build_lang_decl_loc (location_t, enum tree_code, tree, tree);
extern void retrofit_lang_decl (tree);
===================================================================
@@ -443,19 +443,22 @@ handle_pragma_java_exceptions (cpp_reader* /*dfile
IDENTIFIER_NODE) failed. Returns the ERROR_MARK_NODE. */
tree
-unqualified_name_lookup_error (tree name)
+unqualified_name_lookup_error (tree name, location_t loc)
{
+ if (loc == UNKNOWN_LOCATION)
+ loc = location_of (name);
+
if (IDENTIFIER_OPNAME_P (name))
{
if (name != ansi_opname (ERROR_MARK))
- error ("%qD not defined", name);
+ error_at (loc, "%qD not defined", name);
}
else
{
if (!objc_diagnose_private_ivar (name))
{
- error ("%qD was not declared in this scope", name);
- suggest_alternatives_for (location_of (name), name);
+ error_at (loc, "%qD was not declared in this scope", name);
+ suggest_alternatives_for (loc, name);
}
/* Prevent repeated error messages by creating a VAR_DECL with
this NAME in the innermost block scope. */
@@ -462,8 +465,7 @@ tree
if (local_bindings_p ())
{
tree decl;
- decl = build_decl (input_location,
- VAR_DECL, name, error_mark_node);
+ decl = build_decl (loc, VAR_DECL, name, error_mark_node);
DECL_CONTEXT (decl) = current_function_decl;
push_local_binding (name, decl, 0);
/* Mark the variable as used so that we do not get warnings
@@ -475,13 +477,18 @@ tree
return error_mark_node;
}
-/* Like unqualified_name_lookup_error, but NAME is an unqualified-id
- used as a function. Returns an appropriate expression for
- NAME. */
+/* Like unqualified_name_lookup_error, but NAME_EXPR is an unqualified-id
+ NAME, encapsulated with its location in a CP_EXPR, used as a function.
+ Returns an appropriate expression for NAME. */
tree
-unqualified_fn_lookup_error (tree name)
+unqualified_fn_lookup_error (cp_expr name_expr)
{
+ tree name = name_expr.get_value ();
+ location_t loc = name_expr.get_location ();
+ if (loc == UNKNOWN_LOCATION)
+ loc = input_location;
+
if (processing_template_decl)
{
/* In a template, it is invalid to write "f()" or "f(3)" if no
@@ -494,7 +501,7 @@ tree
Note that we have the exact wording of the following message in
the manual (trouble.texi, node "Name lookup"), so they need to
be kept in synch. */
- permerror (input_location, "there are no arguments to %qD that depend on a template "
+ permerror (loc, "there are no arguments to %qD that depend on a template "
"parameter, so a declaration of %qD must be available",
name, name);
@@ -503,7 +510,7 @@ tree
static bool hint;
if (!hint)
{
- inform (input_location, "(if you use %<-fpermissive%>, G++ will accept your "
+ inform (loc, "(if you use %<-fpermissive%>, G++ will accept your "
"code, but allowing the use of an undeclared name is "
"deprecated)");
hint = true;
@@ -512,7 +519,7 @@ tree
return name;
}
- return unqualified_name_lookup_error (name);
+ return unqualified_name_lookup_error (name, loc);
}
/* Wrapper around build_lang_decl_loc(). Should gradually move to
===================================================================
@@ -2210,6 +2210,7 @@ perform_koenig_lookup (cp_expr fn, vec<tree, va_gc
tree functions = NULL_TREE;
tree tmpl_args = NULL_TREE;
bool template_id = false;
+ location_t loc = fn.get_location ();
if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
{
@@ -2245,7 +2246,7 @@ perform_koenig_lookup (cp_expr fn, vec<tree, va_gc
{
/* The unqualified name could not be resolved. */
if (complain)
- fn = unqualified_fn_lookup_error (identifier);
+ fn = unqualified_fn_lookup_error (cp_expr (identifier, loc));
else
fn = identifier;
}
===================================================================
@@ -24,7 +24,7 @@ struct X { } x;
int main() {
// f(0); // OK
f(nt); // { dg-error "cannot call" }
- f(x); // { dg-error "not declared" }
+ f(x); // { dg-error "3:'f' was not declared" }
S<int> si;
si == si; // OK
===================================================================
@@ -8,6 +8,6 @@ struct string { string(std::initializer_list<char>
void f() {
auto y =
{
- string(Equation()) // { dg-error "not declared" }
+ string(Equation()) // { dg-error "12:'Equation' was not declared" }
}; // { dg-error "unable to deduce" }
}
===================================================================
@@ -3,6 +3,6 @@
void
foo()
{
- float x = operator"" _F(); // { dg-error "was not declared in this scope" }
+ float x = operator"" _F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" }
float y = 0_F; // { dg-error "unable to find numeric literal operator" }
}
===================================================================
@@ -2,14 +2,14 @@
// Check that undeclared literal operator calls and literals give appropriate errors.
-int i = operator"" _Bar('x'); // { dg-error "was not declared in this scope" }
+int i = operator"" _Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
int j = 'x'_Bar; // { dg-error "unable to find character literal operator|with|argument" }
-int ii = operator"" _BarCharStr("Howdy, Pardner!"); // { dg-error "was not declared in this scope" }
+int ii = operator"" _BarCharStr("Howdy, Pardner!"); // { dg-error "10:'operator\"\"_BarCharStr' was not declared in this scope" }
int jj = "Howdy, Pardner!"_BarCharStr; // { dg-error "unable to find string literal operator|Possible missing length argument" }
-unsigned long long iULL = operator"" _BarULL(666ULL); // { dg-error "was not declared in this scope" }
+unsigned long long iULL = operator"" _BarULL(666ULL); // { dg-error "27:'operator\"\"_BarULL' was not declared in this scope" }
unsigned long long jULL = 666_BarULL; // { dg-error "unable to find numeric literal operator" }
-long double iLD = operator"" _BarLD(666.0L); // { dg-error "was not declared in this scope" }
+long double iLD = operator"" _BarLD(666.0L); // { dg-error "19:'operator\"\"_BarLD' was not declared in this scope" }
long double jLD = 666.0_BarLD; // { dg-error "unable to find numeric literal operator" }
===================================================================
@@ -7,7 +7,7 @@ class Foo
int operator"" _Bar(char32_t); // { dg-error "must be a non-member function" }
};
-int i = operator"" _Bar(U'x'); // { dg-error "was not declared in this scope" }
+int i = operator"" _Bar(U'x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
int j = U'x'_Bar; // { dg-error "unable to find character literal operator" }
int
===================================================================
@@ -9,6 +9,6 @@ extern "C" int printf(char*, ...); // { dg-message
}
void foo() {
- printf("abc"); // { dg-error "not declared" }
+ printf("abc"); // { dg-error "3:'printf' was not declared" }
// { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 12 }
}
===================================================================
@@ -6,5 +6,5 @@ void foo()
{
friend void bar(); // { dg-error "without prior declaration" }
};
- bar(); // { dg-error "not declared" }
+ bar(); // { dg-error "3:'bar' was not declared" }
}
===================================================================
@@ -11,7 +11,7 @@ int main()
struct S { friend void g(); friend void h(S); };
struct T { friend void g(); friend void h(T); };
void i() {
- g(); // { dg-error "not declared" }
+ g(); // { dg-error "3:'g' was not declared" }
S s;
h(s);
T t;
===================================================================
@@ -9,5 +9,5 @@ class X;
void foo() {
X x(1); // { dg-error "incomplete type" "" }
- bar(x); // { dg-error "not declared" "" }
+ bar(x); // { dg-error "3:'bar' was not declared" "" }
}
===================================================================
@@ -31,12 +31,12 @@ void g (N::A *a, M::B *b, O::C *c)
{
One (a); // ok
One (a, b); // ok
- One (b); // { dg-error "not declared" }
+ One (b); // { dg-error "3:'One' was not declared" }
// { dg-message "suggested alternatives" "suggested alternative for One" { target *-*-* } 34 }
Two (c); // ok
Two (a, c); // ok
- Two (a); // { dg-error "not declared" }
+ Two (a); // { dg-error "3:'Two' was not declared" }
// { dg-message "suggested alternatives" "suggested alternative for Two" { target *-*-* } 39 }
Two (a, a); // error masked by earlier error
Two (b); // error masked by earlier error
@@ -44,6 +44,6 @@ void g (N::A *a, M::B *b, O::C *c)
Three (b); // ok
Three (a, b); // ok
- Three (a); // { dg-error "not declared" }
+ Three (a); // { dg-error "3:'Three' was not declared" }
// { dg-message "suggested alternatives" "suggested alternative for Three" { target *-*-* } 47 }
}
===================================================================
@@ -1,5 +1,5 @@
// Copyroght (C) 2003 Free Software Foundation
// Origin: PR/12832, Jonathan Wakely <redi@gcc.gnu.org>
-void f() { g(); } // { dg-error "not declared" "" }
+void f() { g(); } // { dg-error "12:'g' was not declared" "" }
void g() { }
===================================================================
@@ -13,7 +13,7 @@ void g ()
{
B *bp;
N::A *ap;
- f (bp); // { dg-error "not declared" }
+ f (bp); // { dg-error "3:'f' was not declared" }
// { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 16 }
f (ap);
}
===================================================================
@@ -0,0 +1,6 @@
+// PR c++/71238
+
+int main()
+{
+ int x=myFunc(3234); // { dg-error "11:'myFunc' was not declared" }
+}
===================================================================
@@ -3,5 +3,5 @@
struct A
{
template<int> template<typename T> friend void foo(T) {} // { dg-error "parameter" }
- void bar() { foo(0); } // { dg-error "foo" }
+ void bar() { foo(0); } // { dg-error "16:'foo' was not declared" }
};
===================================================================
@@ -15,7 +15,7 @@ int
main ()
{
f(1);
- g(1); // { dg-error "'g' was not declared in this scope" }
+ g(1); // { dg-error "3:'g' was not declared in this scope" }
g(S());
h(1);
}
===================================================================
@@ -7,7 +7,7 @@
int f (int n)
{
int bar (int n) { return n++; } // { dg-error "a function-definition is not allowed here" }
- return bar (n); // { dg-error "was not declared in this scope" }
+ return bar (n); // { dg-error "12:'bar' was not declared in this scope" }
}
int g (int i)
===================================================================
@@ -5,5 +5,5 @@ int main ()
{
// We should not see an "unused" warning about "whatever" on the
// next line.
- return whatever (); // { dg-error "declared" }
+ return whatever (); // { dg-error "10:'whatever' was not declared" }
}
===================================================================
@@ -10,7 +10,7 @@
void global_function_0 ()
{
- global_function_1 (); /* { dg-error "" } */
+ global_function_1 (); /* { dg-error "3:'global_function_1' was not declared" } */
}
int main () { return 0; }
===================================================================
@@ -6,5 +6,5 @@ template <class T> class A;
int main()
{
A<int> *p;
- undef1();// { dg-error "" }
+ undef1();// { dg-error "3:'undef1' was not declared" }
}
===================================================================
@@ -5,7 +5,7 @@ struct Y
struct X
{
int A;
- int Y::X::* foo () { undef1(1); return &Y::X::A; }// { dg-error "" } foo().*
+ int Y::X::* foo () { undef1(1); return &Y::X::A; }// { dg-error "28:'undef1' was not declared" } foo().*
int bar () { return A; }
};
};
@@ -12,24 +12,24 @@ struct Y
int Y::X::* foo ()
{
- undef2(1);// { dg-error "" } foo().*
+ undef2(1);// { dg-error "3:'undef2' was not declared" } foo().*
return &Y::X::A;
}
int Y::X::* (* foo2 ())()
{
- undef3(1);// { dg-error "" } foo().*
+ undef3(1);// { dg-error "3:'undef3' was not declared" } foo().*
return foo;
}
int (Y::X::* bar2 ()) ()
{
- undef4(1);// { dg-error "" } foo\(\).*
+ undef4(1);// { dg-error "3:'undef4' was not declared" } foo\(\).*
return Y::X::bar;// { dg-error "" } foo\(\).*
}
int Y::X::* (Y::X::* foo3 ())()
{
- undef5(1);// { dg-error "" } foo().*
+ undef5(1);// { dg-error "3:'undef5' was not declared" } foo().*
return Y::X::foo;// { dg-error "" } foo().*
}
===================================================================
@@ -37,7 +37,7 @@ int foo (int a = (**bar) (s))
int foo2 (int (*a)(int) = &foo)
{
- undef4 (1); // { dg-error "" } implicit declaration
+ undef4 (1); // { dg-error "4:'undef4' was not declared" } implicit declaration
return 1;
}
@@ -55,7 +55,7 @@ bar2 baz (X::Y y) // { dg-error "" } in th
X::Y f; // { dg-error "" } in this context
bar2 wa [5];
wa[0] = baz(f);
- undef2 (1); // { dg-error "" } implicit declaration
+ undef2 (1); // { dg-error "3:'undef2' was not declared" } implicit declaration
} // { dg-warning "no return statement" }
int ninny ()
@@ -70,5 +70,5 @@ int ninny ()
int darg (char X::*p)
{
- undef3 (1); // { dg-error "" } implicit declaration
+ undef3 (1); // { dg-error "4:'undef3' was not declared" } implicit declaration
} // { dg-warning "no return statement" }
===================================================================
@@ -6,5 +6,5 @@ void f ()
};
}
void h () {
- g (); // { dg-error "" } no g in scope
+ g (); // { dg-error "3:'g' was not declared" } no g in scope
}
===================================================================
@@ -31,6 +31,6 @@ int main() {
Base b;
Derived d;
d.noticeThisFunction(&b);
- printf("gpptest run\n");// { dg-error "" } .*
+ printf("gpptest run\n");// { dg-error "5:'printf' was not declared" } .*
}
===================================================================
@@ -14,6 +14,6 @@ void g()
foo(new X); // ok -- DR 218 says that we find the global
// foo variable first, and therefore do not
// perform argument-dependent lookup.
- bar(new X); // { dg-error "not declared" }
+ bar(new X); // { dg-error "3:'bar' was not declared" }
// { dg-message "suggested alternative" "suggested alternative" { target *-*-* } 17 }
}
===================================================================
@@ -9,7 +9,7 @@ struct S
inline void f()
{
static S s;
- atexit (0); // { dg-error "" } implicit declaration
+ atexit (0); // { dg-error "3:'atexit' was not declared" } implicit declaration
}
===================================================================
@@ -12,5 +12,5 @@ int
main()
{
C<char*> c;
- char* p = Z(c.O); //{ dg-error "" } ambiguous c.O
+ char* p = Z(c.O); //{ dg-error "13:'Z' was not declared" } ambiguous c.O
}