re PR c++/31754 (Improve column number accuracy in error messages)

2008-07-11 Dodji Seketeli <dseketel@redhat.com>

	PR c++/31754
	* pt.c, semantic.c:
	* semantic.c (qualified_name_lookup_error, finish_id_expression):
	add a location_t parameter so that
	error message can have a more accurate location.
	* cp-tree.h: updated prototype
	* pt.c (tsubst_qualified_id): use location in error messages.
	* parser.c (cp_parser_postfix_expression,
	cp_parser_objc_statement, cp_parser_trait_expr,
	cp_parser_token_is_class_key,
	cp_parser_uncommitted_to_tentative_parse_p,
	cp_parser_check_for_invalid_template_id, cp_parser_is_string_literal,
	cp_parser_error, cp_parser_name_lookup_error,
	cp_parser_simulate_error, cp_parser_check_decl_spec,
	cp_parser_check_decl_spec, cp_parser_non_integral_constant_expression,
	cp_parser_diagnose_invalid_type_name,
	cp_parser_parse_and_diagnose_invalid_type_name,
	cp_parser_require_pragma_eol, cp_parser_make_typename_type,
	cp_parser_string_literal, cp_parser_primary_expression,
	cp_parser_primary_expression, cp_parser_unqualified_id,
	cp_parser_nested_name_specifier_opt, cp_parser_postfix_expression,
	cp_parser_postfix_dot_deref_expression, cp_parser_new_expression,
	cp_parser_direct_new_declarator, cp_parser_builtin_offsetof,
	cp_parser_label_for_labeled_statement, cp_parser_statement_seq_opt,
	cp_parser_jump_statement, cp_parser_block_declaration,
	cp_parser_simple_declaration, cp_parser_decl_specifier_seq,
	cp_parser_function_specifier_opt, cp_parser_decltype,
	cp_parser_mem_initializer_list, cp_parser_mem_initializer,
	cp_parser_mem_initializer_id, cp_parser_template_parameter,
	cp_parser_type_parameter, cp_parser_template_id, cp_parser_template_name,
	cp_parser_template_argument): likewise.

From-SVN: r137716
This commit is contained in:
Dodji Seketeli 2008-07-11 12:54:22 +00:00 committed by Dodji Seketeli
parent 941a9479d0
commit 2b7a3abf6e
41 changed files with 697 additions and 348 deletions

View File

@ -1,3 +1,37 @@
2008-07-11 Dodji Seketeli <dseketel@redhat.com>
PR c++/31754
* pt.c, semantic.c:
* semantic.c (qualified_name_lookup_error, finish_id_expression):
add a location_t parameter so that
error message can have a more accurate location.
* cp-tree.h: updated prototype
* pt.c (tsubst_qualified_id): use location in error messages.
* parser.c (cp_parser_postfix_expression,
cp_parser_objc_statement, cp_parser_trait_expr,
cp_parser_token_is_class_key,
cp_parser_uncommitted_to_tentative_parse_p,
cp_parser_check_for_invalid_template_id, cp_parser_is_string_literal,
cp_parser_error, cp_parser_name_lookup_error,
cp_parser_simulate_error, cp_parser_check_decl_spec,
cp_parser_check_decl_spec, cp_parser_non_integral_constant_expression,
cp_parser_diagnose_invalid_type_name,
cp_parser_parse_and_diagnose_invalid_type_name,
cp_parser_require_pragma_eol, cp_parser_make_typename_type,
cp_parser_string_literal, cp_parser_primary_expression,
cp_parser_primary_expression, cp_parser_unqualified_id,
cp_parser_nested_name_specifier_opt, cp_parser_postfix_expression,
cp_parser_postfix_dot_deref_expression, cp_parser_new_expression,
cp_parser_direct_new_declarator, cp_parser_builtin_offsetof,
cp_parser_label_for_labeled_statement, cp_parser_statement_seq_opt,
cp_parser_jump_statement, cp_parser_block_declaration,
cp_parser_simple_declaration, cp_parser_decl_specifier_seq,
cp_parser_function_specifier_opt, cp_parser_decltype,
cp_parser_mem_initializer_list, cp_parser_mem_initializer,
cp_parser_mem_initializer_id, cp_parser_template_parameter,
cp_parser_type_parameter, cp_parser_template_id, cp_parser_template_name,
cp_parser_template_argument): likewise.
2008-07-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/36760

View File

@ -4653,13 +4653,15 @@ extern void finish_template_decl (tree);
extern tree finish_template_type (tree, tree, int);
extern tree finish_base_specifier (tree, tree, bool);
extern void finish_member_declaration (tree);
extern void qualified_name_lookup_error (tree, tree, tree);
extern void qualified_name_lookup_error (tree, tree, tree,
location_t);
extern void check_template_keyword (tree);
extern tree finish_id_expression (tree, tree, tree,
cp_id_kind *,
bool, bool, bool *,
bool, bool, bool, bool,
const char **);
const char **,
location_t);
extern tree finish_typeof (tree);
extern tree finish_offsetof (tree);
extern void finish_decl_cleanup (tree, tree);

File diff suppressed because it is too large Load Diff

View File

@ -9743,7 +9743,7 @@ tsubst_qualified_id (tree qualified_id, tree args,
if (complain & tf_error)
qualified_name_lookup_error (scope,
TREE_OPERAND (qualified_id, 1),
expr);
expr, input_location);
return error_mark_node;
}
@ -9752,7 +9752,7 @@ tsubst_qualified_id (tree qualified_id, tree args,
if (expr == error_mark_node && complain & tf_error)
qualified_name_lookup_error (scope, TREE_OPERAND (qualified_id, 1),
expr);
expr, input_location);
else if (TYPE_P (scope))
{
expr = (adjust_result_of_qualified_name_lookup
@ -10484,7 +10484,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
/*is_type_p=*/false,
/*complain=*/false);
if (decl == error_mark_node || TREE_CODE (decl) == TREE_LIST)
qualified_name_lookup_error (scope, name, decl);
qualified_name_lookup_error (scope, name, decl, input_location);
else
do_local_using_decl (decl, scope, name);
}
@ -10931,7 +10931,8 @@ tsubst_copy_and_build (tree t,
/*done=*/true,
/*address_p=*/false,
/*template_arg_p=*/false,
&error_msg);
&error_msg,
input_location);
if (error_msg)
error (error_msg);
if (!function_p && TREE_CODE (decl) == IDENTIFIER_NODE)
@ -11460,7 +11461,8 @@ tsubst_copy_and_build (tree t,
}
else
{
qualified_name_lookup_error (object_type, tmpl, member);
qualified_name_lookup_error (object_type, tmpl, member,
input_location);
return error_mark_node;
}
}

View File

@ -2502,29 +2502,33 @@ finish_base_specifier (tree base, tree access, bool virtual_p)
}
/* Issue a diagnostic that NAME cannot be found in SCOPE. DECL is
what we found when we tried to do the lookup. */
what we found when we tried to do the lookup.
LOCATION is the location of the NAME identifier;
The location is used in the error message*/
void
qualified_name_lookup_error (tree scope, tree name, tree decl)
qualified_name_lookup_error (tree scope, tree name,
tree decl, location_t location)
{
if (scope == error_mark_node)
; /* We already complained. */
else if (TYPE_P (scope))
{
if (!COMPLETE_TYPE_P (scope))
error ("incomplete type %qT used in nested name specifier", scope);
error ("%Hincomplete type %qT used in nested name specifier",
&location, scope);
else if (TREE_CODE (decl) == TREE_LIST)
{
error ("reference to %<%T::%D%> is ambiguous", scope, name);
error ("%Hreference to %<%T::%D%> is ambiguous", &location, scope, name);
print_candidates (decl);
}
else
error ("%qD is not a member of %qT", name, scope);
error ("%H%qD is not a member of %qT", &location, name, scope);
}
else if (scope != global_namespace)
error ("%qD is not a member of %qD", name, scope);
error ("%H%qD is not a member of %qD", &location, name, scope);
else
error ("%<::%D%> has not been declared", name);
error ("%H%<::%D%> has not been declared", &location, name);
}
/* If FNS is a member function, a set of member functions, or a
@ -2589,7 +2593,6 @@ baselink_for_fns (tree fns)
the use of "this" explicit.
Upon return, *IDK will be filled in appropriately. */
tree
finish_id_expression (tree id_expression,
tree decl,
@ -2602,7 +2605,8 @@ finish_id_expression (tree id_expression,
bool done,
bool address_p,
bool template_arg_p,
const char **error_msg)
const char **error_msg,
location_t location)
{
/* Initialize the output parameters. */
*idk = CP_ID_KIND_NONE;
@ -2632,7 +2636,7 @@ finish_id_expression (tree id_expression,
/* If the qualifying type is non-dependent (and the name
does not name a conversion operator to a dependent
type), issue an error. */
qualified_name_lookup_error (scope, id_expression, decl);
qualified_name_lookup_error (scope, id_expression, decl, location);
return error_mark_node;
}
else if (!scope)

View File

@ -1,3 +1,10 @@
2008-07-11 Dodji Seketeli <dseketel@redhat.com>
* g++.dg/parse/constructor1.C, g++.dg/parse/error*.C: update these
tests to make them catch column number regressions. Make these tests
run with the -fshow-column option.
* g++.dg/parse/error-column.C: new column number test.
2008-07-11 Richard Guenther <rguenther@suse.de>
PR tree-optimization/36765

View File

@ -1,4 +1,7 @@
// { dg-do compile }
// { dg-options "-fshow-column" }
ACE_Process_Descriptor::ACE_Process_Descriptor () : // { dg-error "" }
process_ (0)
process_ (0) // { dg-error "3: error: only constructors take base initializers" }
{
}

View File

@ -0,0 +1,9 @@
// { dg-do compile }
// Make sure column information is correctly shown in error reporting
// { dg-options "-fshow-column" }
void foo ()
{
cout << "blah"; // { dg-error "3: error: 'cout'" }
}

View File

@ -1,6 +1,7 @@
// { dg-options "-fshow-column" }
struct INCOMPLETE;
template <int> struct X {
static INCOMPLETE value;
};
template <> INCOMPLETE X<1>::value = 0; // { dg-error "" }
template <> INCOMPLETE X<1>::value = 0; // { dg-error "30: error: variable 'INCOMPLETE X<1>::value' has initializer but incomplete type" }

View File

@ -1,5 +1,5 @@
// PR c++/3478
// { dg-options "" }
// { dg-options "-fshow-column" }
template <typename> struct A
{
@ -11,5 +11,9 @@ template <typename T> void foo()
enum A<void>::E e1;
typename A<T>::E e2;
enum A<T>::E e3;
enum typename A<T>::E e4; // { dg-error "" }
enum typename A<T>::E e4;
}
// Here, columns nums are not very accurate either. Still acceptable though
// { dg-error "30: error: invalid type in declaration before ';' token" "" { target *-*-* } { 14 } }
// { dg-error "30: error: two or more data types in declaration of 'e4'" "" { target *-*-* } { 14 } }

View File

@ -1,4 +1,5 @@
// { dg-do compile }
// { dg-options "-fshow-column" }"
// Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
// Try to find out when the digraph '<:' is used as a mistake, and parse it
// correctly to avoid cascaded errors.
@ -15,16 +16,16 @@ struct Foo
};
void method(void) {
typename Foo<::B>::template Nested<::B> n; // { dg-error "cannot begin|alternate spelling" }
typename Foo<::B>::template Nested<::B> n; // { dg-error "17: error: '<::' cannot begin|17: note: '<:' is an alternate spelling|39: error: '<::' cannot begin|39: note: '<:' is an alternate" }
n.template Nested<B>::method();
n.template Nested<::B>::method(); // { dg-error "cannot begin|alternate spelling" }
n.template Nested<::B>::method(); // { dg-error "22: error: '<::' cannot begin|22: note: '<:' is an alternate" }
Nested<B>::method();
Nested<::B>::method(); // { dg-error "cannot begin|alternate spelling" }
Nested<::B>::method(); // { dg-error "11: error: '<::' cannot begin|11: note: '<:' is an alternate" }
}
};
template <int N> struct Foo2 {};
template struct Foo2<::B>; // { dg-error "cannot begin|alternate spelling|type/value mismatch|expected a constant" }
template struct Foo2<::B>; // { dg-error "21: error: '<::' cannot begin|21: note: '<:' is an alternate|25: error: type/value mismatch|25: error: expected a constant" }
int value = 0;
@ -32,22 +33,28 @@ void func(void)
{
Foo<::B> f; // { dg-error "cannot begin|alternate spelling" }
f.Foo<B>::method();
f.Foo<::B>::method(); // { dg-error "cannot begin|alternate spelling" }
f.Foo<::B>::method(); // { dg-error "8: error|8: note" }
// Check cases where we the token sequence is the correct one, but there
// was no digraph or whitespaces in the middle, so we should not emit
// the special error message.
Foo<: :B> k2; // { dg-bogus "cannot begin|alternate spelling" "smart error should not be triggered here" }
Foo[:B> k1; // { dg-bogus "cannot begin|alternate spelling" "smart error should not be triggered here" }
// { dg-error "" "" { target *-*-* } 40 }
// { dg-error "" "" { target *-*-* } 41 }
// { dg-error "6: error: missing template arguments before" "" { target *-*-* } { 41 } }
// { dg-error "9: error: expected primary-expression before ':' token" "" { target *-*-* } 41 }
// { dg-error "9: error: expected '\]' before ':' token" "" { target *-*-* } 41 }
// { dg-error "9: error: expected ';' before ':' token" "" { target *-*-* } 41 }
// { dg-error "6: error: missing template arguments before" "" { target *-*-* } 42 }
// { dg-error "7: error: expected primary-expression before ':' token" "" { target *-*-* } 42 }
// { dg-error "7: error: expected '\]' before ':' token" "" { target *-*-* } 42 }
// { dg-error "7: error: expected ';' before ':' token" "" { target *-*-* } 42 }
//
int Foo[2];
Foo[::value] = 0;
}
template struct Foo<::B>; // { dg-error "cannot begin|alternate spelling" }
template struct Foo<::B>; // { dg-error "20: error: '<::' cannot begin|20: note: '<:' is an alternate" }
// On the first error message, an additional note about the use of
// -fpermissive should be present
// { dg-error "-fpermissive" "-fpermissive" { target *-*-* } 18 }
// { dg-error "17: note: \\(if you use '-fpermissive' G\\+\\+ will accept your code\\)" "-fpermissive" { target *-*-* } 19 }

View File

@ -1,7 +1,7 @@
// { dg-do compile }
// Origin: Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
// Make sure the error about '<:' can be turned into a warning
// { dg-options "-fpermissive" }
// { dg-options "-fpermissive -fshow-column" }
struct B;
@ -9,4 +9,5 @@ template <class A>
struct Foo {};
Foo<::B> foo; // { dg-bogus "error" "error in place of warning" }
// { dg-error "" "" { target *-*-* } 11 }
// { dg-error "4: warning: '<::' cannot begin a template-argument list" "warning <::" { target *-*-* } 11 }
// { dg-error "4: note: '<:' is an alternate spelling for '.'. Insert whitespace between '<' and '::'" "note <:" { target *-*-* } 11 }

View File

@ -1,13 +1,14 @@
// { dg-options "-fshow-column" }
// PR c++/13975
public: // { dg-error "" }
public: // { dg-error "1: error: expected unqualified-id before 'public'" }
int i;
protected: // { dg-error "" }
protected: // { dg-error "1: error: expected unqualified-id before 'protected'" }
int j;
private: // { dg-error "" }
private: // { dg-error "1: error: expected unqualified-id before 'private'" }
int k;

View File

@ -1,3 +1,4 @@
// { dg-options "-fshow-column" }
// PR c++/13970
struct X
@ -18,5 +19,5 @@ struct X
Zinc<int>( //);
// }
}; // { dg-error "" }
}; // { dg-error "2: error: expected '.' at end of input|1: error: expected primary-expression before '.' token|1: error: expected ';' before '.' token|1: error: expected unqualified-id at end of input" }

View File

@ -1,5 +1,6 @@
// { dg-do compile }
// Contributed by Volker Reichelt <reichelt at gcc dot gnu dot org>
// { dg-options "-fshow-column" }
// PR c++/14008: Improve diagnostic on invalid types in declarators.
namespace N
@ -9,29 +10,29 @@ namespace N
int K;
}
N::A f2; // { dg-error "without an argument list" }
N::INVALID f3; // { dg-error "in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "in class 'N::C' does not name a type" }
N::K f6; // { dg-error "in namespace 'N' does not name a type" }
typename N::A f7; // { dg-error "without an argument list|outside of template" }
N::A f2; // { dg-error "4: error: invalid use of template-name 'N::A' without an argument list" }
N::INVALID f3; // { dg-error "4: error: 'INVALID' in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "7: error: 'INVALID' in class 'N::C' does not name a type" }
N::K f6; // { dg-error "4: error: 'K' in namespace 'N' does not name a type" }
typename N::A f7; // { dg-error "1: error: using 'typename' outside of template|13: error: invalid use of template-name 'N::A' without an argument list|17: error: invalid type in declaration before ';' token" }
struct B
{
N::A f2; // { dg-error "without an argument list" }
N::INVALID f3; // { dg-error "in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "in class 'N::C' does not name a type" }
N::K f6; // { dg-error "in namespace 'N' does not name a type" }
typename N::A f7; // { dg-error "without an argument list|outside of template" }
N::A f2; // { dg-error "6: error: invalid use of template-name 'N::A' without an argument list" }
N::INVALID f3; // { dg-error "6: error: 'INVALID' in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "9: error: 'INVALID' in class 'N::C' does not name a type" }
N::K f6; // { dg-error "6: error: 'K' in namespace 'N' does not name a type" }
typename N::A f7; // { dg-error "3: error: using 'typename' outside of template|15: error: invalid use of template-name 'N::A' without an argument list" }
};
template <int>
struct C
{
N::A f2; // { dg-error "without an argument list" }
N::INVALID f3; // { dg-error "in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "in class 'N::C' does not name a type" }
N::K f6; // { dg-error "in namespace 'N' does not name a type" }
typename N::A f7; // { dg-error "without an argument list" }
N::A f2; // { dg-error "6: error: invalid use of template-name 'N::A' without an argument list" }
N::INVALID f3; // { dg-error "6: error: 'INVALID' in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "9: error: 'INVALID' in class 'N::C' does not name a type" }
N::K f6; // { dg-error "6: error: 'K' in namespace 'N' does not name a type" }
typename N::A f7; // { dg-error "15: error: invalid use of template-name 'N::A' without an argument list" }
};
// { dg-bogus "" "bogus excess errors in declaration" { xfail *-*-* } 16 }
// { dg-bogus "bogus excess errors in declaration" "bogus excess errors in declaration" { xfail *-*-* } 17 }

View File

@ -1,8 +1,9 @@
// { dg-options "-fshow-column" }
// PR c++/16964
struct A
{
struct B {}; // { dg-error "previous" }
struct B {}; // { dg-error "12: error: previous definition of 'struct A::B'" }
};
struct A::B{}; // { dg-error "redefinition" }
struct A::B{}; // { dg-error "11: error: redefinition of 'struct A::B'" }

View File

@ -1,8 +1,9 @@
// { dg-options "-fshow-column" }
// PR c++/16965
template <typename T> struct B {
static int Bar(T); // { dg-error "" }
static int Bar(T); // { dg-error "19: error: candidates are: |19: error: " }
};
struct D : B<int>, B<char> {};
int i2 = D::Bar(2); // { dg-error "" }
int i2 = D::Bar(2); // { dg-error "13: error: reference to 'Bar' is ambiguous|10: error: reference to 'Bar' is ambiguous" }

View File

@ -1,7 +1,8 @@
// { dg-options "-fshow-column" }
// PR c++/16002
void f()
{
double Q *= 5.0; // { dg-error "initializer" }
double Q *= 5.0; // { dg-error "12: error: expected initializer before '..' token" }
}

View File

@ -1,7 +1,8 @@
// { dg-options "-fshow-column -fmessage-length=0 -ansi -pedantic-errors -Wno-long-long " }
// PR C++/17867
struct A
{ // { dg-error "candidate" }
{ // { dg-error "1: note: candidates are:" }
A(int);
};
@ -9,5 +10,5 @@ const A& foo();
void bar()
{
foo()=A(0); // { dg-error "A" }
foo()=A(0); // { dg-error "12: error: no match for 'operator='" }
}

View File

@ -1,4 +1,5 @@
// { dg-do compile }
// { dg-options "-fshow-column" }
// Properly print CALL_EXPRs while dumping expressions
double g;
@ -7,4 +8,8 @@ int func(double);
template <int>
struct Foo {};
Foo<func(g)> f; // { dg-error "" "func(g)" }
Foo<func(g)> f; // { dg-error "5: error: 'int func.double.' cannot appear in a constant-expression" "" { target *-*-* } { 11 } }
// { dg-error "10: error: 'g' cannot appear in a constant-expression" "" { target *-*-* } { 11 } }
// { dg-error "11: error: a function call cannot appear in a constant-expression" "" { target *-*-* } { 11 } }
// { dg-error "12: error: template argument 1 is invalid" "" { target *-*-* } { 11 } }
// { dg-error "15: error: invalid type in declaration before ';' token" "" { target *-*-* } { 11 } }

View File

@ -1,3 +1,4 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/17821
struct A {
@ -11,7 +12,7 @@ struct C {
};
int main() {
C c;
A(c.p.i); // { dg-error "member.*non-class" }
A(c.p.i); // { dg-error "9: error: request for member 'i' in 'c.C::p', which is of non-class type 'B" }
return 0;
}

View File

@ -1,5 +1,5 @@
// PR c++/17393
// { dg-options "-Wall" }
// { dg-options "-Wall -fshow-column" }
struct A { };
@ -7,6 +7,6 @@ void foo()
{
// Check that we do not complain about an unused
// compiler-generated variable.
A& = a; // { dg-error "token|declarator|not declared" }
A& = a; // { dg-error "6: error: expected unqualified-id before '=' token|8: error: 'a' was not declared in this scope" }
}

View File

@ -1,5 +1,6 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/15786
struct A {
void foo(bar* p); /* { dg-error "declared" } */
void foo(bar* p); /* { dg-error "12: error: 'bar' has not been declared" } */
};

View File

@ -1,7 +1,9 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/19149
struct QChar {
QChar( char c );
QChar( const QChar& c );
static const ; // { dg-error "" }
//following column number is not accurate enough but will make it for now
static const ; // { dg-error "10: error: declaration does not declare anything" }
};

View File

@ -1,7 +1,8 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/19395
struct A {
typedef int ::X; // { dg-error "" }
typedef int ::X; // { dg-error "17: error: typedef name may not be a nested-name-specifier" }
};

View File

@ -1,4 +1,5 @@
// { dg-do compile }
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// Origin: Steven Bosscher <steven at gcc dot gnu dot org>
// PR c++/17401: ICE with invalid pure specifier
@ -8,10 +9,10 @@
class foo
{
virtual void bar1 () = 0;
virtual void bar2 () = __null; // { dg-error "invalid pure specifier" }
virtual void bar3 () = 4; // { dg-error "invalid pure specifier" }
virtual void bar4 () = A::f; // { dg-error "invalid pure specifier" }
virtual void bar5 () = 0l; // { dg-error "invalid pure specifier" }
virtual void bar6 () = 00; // { dg-error "invalid pure specifier" }
virtual void bar7 () = 0x0; // { dg-error "invalid pure specifier" }
virtual void bar2 () = __null; // { dg-error "32: error: invalid pure specifier" }
virtual void bar3 () = 4; // { dg-error "27: error: invalid pure specifier" }
virtual void bar4 () = A::f; // { dg-error "27: error: invalid pure specifier" }
virtual void bar5 () = 0l; // { dg-error "28: error: invalid pure specifier" }
virtual void bar6 () = 00; // { dg-error "28: error: invalid pure specifier" }
virtual void bar7 () = 0x0; // { dg-error "29: error: invalid pure specifier" }
};

View File

@ -1,12 +1,12 @@
// PR c++/20148
// { dg-options "" }
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
void foo()
{
if (({int c[2];})) ; // { dg-error "\{\.\.\.\}" }
if (({int c[2];})) ; // { dg-error "7: error: ISO C.. forbids|20: error: could not convert" }
}
void bar()
{
if (({})); // { dg-error "\{\.\.\.\}" }
if (({})); // { dg-error "7: error: ISO C.. forbids|11: error: could not convert" }
}

View File

@ -1,7 +1,8 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/20152
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "previous definition" }
struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "previous definition" }
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "" }
struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "" }
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "24: error: previous definition of 'struct KrSelectionMode'" }
struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "52: error: previous definition of 'struct KrKDESelectionMode'" }
struct KrSelectionMode { virtual void init() = 0; }; // { dg-error "8: error: redefinition of 'struct KrSelectionMode'" }
struct KrKDESelectionMode : public KrSelectionMode { void init() { } }; // { dg-error "8: error: redefinition of 'struct KrKDESelectionMode'" }
KrKDESelectionMode krKDESelectionMode;

View File

@ -1,10 +1,11 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/21908
struct virt { virt () {} virt (int i) {} };
struct der : public virtual virt { // { dg-error "der" }
der (int i) : virt(i) {} // { dg-error "der" }
struct der : public virtual virt { // { dg-error "34: note: der::der" }
der (int i) : virt(i) {} // { dg-error "13: note: candidates are: der" }
};
struct top : public der {
// { dg-error "der\\(\\)" "" { target *-*-* } 9 }
top () {} // { dg-bogus "der\\(const" }
};
// { dg-error "10: error: no matching function for call to 'der" "" { target *-*-* } 9 }

View File

@ -1,3 +1,4 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/25637
struct A {
@ -6,7 +7,7 @@ struct A {
void operator delete(void *);
};
struct B {
friend void A::foo() {} // { dg-error "define" }
friend void A::operator delete(void*) {} // { dg-error "define" }
friend A::A() {} // { dg-error "define" }
friend void A::foo() {} // { dg-error "22: error: cannot define member function 'A::foo' within 'B'" }
friend void A::operator delete(void*) {} // { dg-error "39: error: cannot define member function 'A::operator delete' within 'B'" }
friend A::A() {} // { dg-error "15: error: cannot define member function 'A::A' within 'B'" }
};

View File

@ -1,6 +1,19 @@
// { dg-options "-fshow-column" }
// PR c++/10779
static void InstantiateConstraint(const float&, unsigned,
void(*AddFunction)(const TYPE&,bool&, // { dg-error "" }
void(*AddFunction)(const TYPE&,bool&,
char*, char*,
unsigned*)); // { dg-error "" }
unsigned*));
// { dg-error "64: error: expected ',' or '...' before '&' token" "" { target *-*-* } { 5 } }
/// in the coming test, the column information is broken as it points to
// the end of the declaration instead of pointing to the begining of the
// 'TYPE' identifier. This is due to the warning being generated by the
// declaration groking code (gcc/cp/decl.c) and not the parser. So in that
// code, the exact token location information is lost as the declaration
// groking code manipulates TREEs only. The token location used is then
// the global one that is not accurate enough. Anyway, let's say it is
// good enough for now, until we find a way to propagate token location to
// code paths that manipulate TREEs only.
// { dg-error "64: error: ISO C\\+\\+ forbids declaration of 'TYPE' with no type" "" { target *-*-* } { 7 } }

View File

@ -1,5 +1,6 @@
// PR c++/30854
// { dg-do compile }
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
struct A
{
@ -7,5 +8,5 @@ struct A
A(int);
};
A a = -A(); // { dg-error "no match for.*operator-.*in.*-A\\(\\)" }
A b = -A(5); // { dg-error "no match for.*operator-.*in.*-A\\(5\\)" }
A a = -A(); // { dg-error "10: error: no match for.*operator-.*in.*-A\\(\\)" }
A b = -A(5); // { dg-error "11: error: no match for.*operator-.*in.*-A\\(5\\)" }

View File

@ -1,10 +1,12 @@
// { dg-options "-fshow-column -ansi -pedantic-errors -Wno-long-long" }
// PR c++/32190
template<typename T> class foo{ };
int main() {
foo<int> i;
foo<foo<int> j; // { dg-error "template argument" }
// this column number is not accurate yet, but that will make it for now.
foo<foo<int> j; // { dg-error "18: error: template argument 1 is invalid" }
int k;
int l;
foo<int> m;

View File

@ -1,7 +1,10 @@
// PR c++/12160
// { dg-options "-fshow-column" }
struct X {
virtual void f(int,
itn, // { dg-error "declared" }
struct X {
virtual void f(int,
itn,
int);
};
};
// { dg-error "4: error: 'itn' has not been declared" "" { target *-*-* } { 6 } }

View File

@ -1,4 +1,19 @@
// PR c++/13269
// { dg-options "-fshow-column" }
class Foo { int foo() return 0; } }; // { dg-error "" }
class Foo { int foo() return 0; } };
// { dg-error "30: error: expected identifier before numeric constant" "" { target *-*-* } { 4 } }
// { dg-error "23: error: named return values are no longer supported" "" { target *-*-* } { 4 } }
// the column number info of this error output is still wrong because the error
// message has been generated by cp_parser_error() which does not
// necessarily allow accurate column number display. At some point, we will
// need make cp_parser_error() report more accurate column numbers.
// { dg-error "30: error: expected '\{' at end of input" "" { target *-*-* } { 4 } }
// { dg-error "35: error: expected unqualified-id before '\}' token" "" {target *-*-* } { 4 } }
// { dg-error "35: error: expected declaration before '\}' token" "" {target *-*-* } { 4 } }

View File

@ -1,6 +1,11 @@
// PR c++/10603
// { dg-options "-fshow-column" }
int f(int not) { // { dg-error "!" }
return 1-not; // { dg-error "" }
int f(int not) {
return 1-not;
}
// { dg-error "11: error: expected ',' or '...' before '!' token" "" { target *-*-* } { 4 } }
// { dg-error "15: error: expected primary\\-expression before ';' token" "" { target *-*-* } { 5 } }

View File

@ -1,4 +1,7 @@
// PR c++/12827
// { dg-options "-fshow-column" }
void f(int x
int y); // { dg-error "," }
int y);
// { dg-error "8: error: expected ',' or '...' before 'int'" "" { target *-*-* } { 5 } }

View File

@ -1,4 +1,10 @@
// PR c++/13438
// { dg-options "-fshow-column" }
struct A { friend typename struct B; }; // { dg-error "" }
struct A { friend typename struct B; };
// { dg-error "19: error: using 'typename' outside of template" "" { target *-*-* } { 4 } }
// { dg-error "28: error: expected nested-name-specifier before 'struct'" "" { target *-*-* } { 4 } }
// { dg-error "35: error: multiple types in one declaration" "" { target *-*-* } { 4 } }
// { dg-error "12: error: friend declaration does not name a class or function" "" { target *-*-* } { 4 } }

View File

@ -1,5 +1,9 @@
// PR c++/12613
// { dg-options "" }
// { dg-options "-fshow-column" }
enum { FOO = 1, BAR = 2 };
int a[] = { FOO: 1, BAR: 2 }; // { dg-error "" }
int a[] = { FOO: 1, BAR: 2 };
// the following 2 column locations are still not accurate enough
// { dg-error "28: error: name 'FOO' used in a GNU-style designated initializer for an array" "" { target *-*-* } { 5 } }
// { dg-error "28: error: name 'BAR' used in a GNU-style designated initializer for an array" "" { target *-*-* } { 5 } }

View File

@ -1,8 +1,9 @@
// { dg-do assemble }
// { dg-options "-fshow-column" }
struct A { // { dg-error "" } forward declaration
friend struct B : A { // { dg-error "" }
friend struct B : A { // { dg-error "invalid use of incomplete type 'struct A'" }
int x;
}; // { dg-error "" } class definition cannot be a friend
}; // { dg-error "class definition may not be declared a friend" "" { target *-*-* } { 5 } }
int y;
};

View File

@ -273,7 +273,6 @@ proc g++_target_compile { source dest type options } {
}
lappend options "additional_flags=[libio_include_flags]"
lappend options "additional_flags=-fno-show-column"
lappend options "compiler=$GXX_UNDER_TEST"
set options [concat $gpp_compile_options $options]