Commit 760b18ad by Dodji Seketeli Committed by Dodji Seketeli

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

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

	PR c++/31754
	* cp-tree.h (struct cp_decl_specifier_seq): add a location field. It
	carries the location of the primary type.
	* parser.c (cp_parser_check_type_definition): update documentation.
	(cp_parser_check_for_definition_in_return_type,
	cp_parser_check_for_invalid_template_id,
	cp_parser_set_decl_spec_type,
	cp_parser_check_for_definition_in_return_type,
	cp_parser_diagnose_invalid_type_name,
	cp_parser_new_expression, cp_parser_explicit_instantiation,
	cp_parser_type_specifier, cp_parser_simple_type_specifier,
	cp_parser_omp_for_loop, cp_parser_pragma): use location in error messages.

From-SVN: r137721
parent ab220355
2008-07-11 Dodji Seketeli <dseketel@redhat.com>
2008-07-11 Dodji Seketeli <dseketel@redhat.com>
PR c++/31754
* cp-tree.h (struct cp_decl_specifier_seq): add a location field. It
carries the location of the primary type.
* parser.c (cp_parser_check_type_definition): update documentation.
(cp_parser_check_for_definition_in_return_type,
cp_parser_check_for_invalid_template_id,
cp_parser_set_decl_spec_type,
cp_parser_check_for_definition_in_return_type,
cp_parser_diagnose_invalid_type_name,
cp_parser_new_expression, cp_parser_explicit_instantiation,
cp_parser_type_specifier, cp_parser_simple_type_specifier,
cp_parser_omp_for_loop, cp_parser_pragma): use location in error messages.
2008-06-30 Dodji Seketeli <dseketel@redhat.com>
PR c++/31754
* pt.c, semantic.c:
......
......@@ -3927,6 +3927,9 @@ typedef struct cp_decl_specifier_seq {
reflected here. This field will be a TYPE, unless a typedef-name
was used, in which case it will be a TYPE_DECL. */
tree type;
/* The location of the primary type. Mainly used for error
reporting. */
location_t type_location;
/* The attributes, if any, provided with the specifier sequence. */
tree attributes;
/* If non-NULL, a built-in type that the user attempted to redefine
......
2008-07-11 Dodji Seketeli <dseketel@redhat.com>
* g++.dg/parse/constructor1.C, g++.dg/parse/error*.C: update these
* g++.dg/other/semicolon.C: Tighten this test, making it column aware.
* g++.dg/parse/error15.C: update this because of more accurate column
numbers in error reporting.
* g++.old-deja/g++.brendan/crash16.C: Tighten the test, making it
column aware.
* g++.old-deja/g++.law/ctors5.C: Likewise.
* g++.old-deja/g++.other/crash25.C: Likewise.
2008-06-30 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.
......
// PR c++/18368
// Origin: Chris Lattner <sabre@nondot.org>
// { dg-do compile }
// { dg-options "-fshow-column" }
struct A
{
struct B { int i; }
void foo(); // { dg-error "two or more|return type" }
}; // { dg-error "semicolon is missing" "" { target *-*-* } 8 }
struct B { int i; } // { dg-error "3: error: new types may not be defined in a return type|note: \\(perhaps a semicolon is missing" }
void foo(); // { dg-error "12: error: two or more|return type" }
};
......@@ -10,28 +10,28 @@ namespace N
int K;
}
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" }
N::A f2; // { dg-error "1: error: invalid use of template-name 'N::A' without an argument list" }
N::INVALID f3; // { dg-error "1: error: 'INVALID' in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "1: error: 'INVALID' in class 'N::C' does not name a type" }
N::K f6; // { dg-error "1: 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 "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" }
N::A f2; // { dg-error "3: error: invalid use of template-name 'N::A' without an argument list" }
N::INVALID f3; // { dg-error "3: error: 'INVALID' in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "3: error: 'INVALID' in class 'N::C' does not name a type" }
N::K f6; // { dg-error "3: 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 "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" }
N::A f2; // { dg-error "3: error: invalid use of template-name 'N::A' without an argument list" }
N::INVALID f3; // { dg-error "3: error: 'INVALID' in namespace 'N' does not name a type" }
N::C::INVALID f4; // { dg-error "3: error: 'INVALID' in class 'N::C' does not name a type" }
N::K f6; // { dg-error "3: 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-do compile }
// { dg-options "-fshow-column" }
// GROUPS passed old-abort
class Graph {
class Graph { // { dg-error "1: error: new types|1: note: \\(perhaps" }
public:
unsigned char N;
Graph(void) {} // { dg-error "previously defined here" }
Graph(void) {} // { dg-error "17: error: 'Graph" }
}
Graph::Graph(void) // { dg-error "return type|redefinition|semicolon" }
Graph::Graph(void) // { dg-error "18: error: return type|18: error: redefinition" }
{ N = 10;
}
// { dg-do assemble }
// { dg-options "-fshow-column" }
// GROUPS passed constructors
// ctors file
// Subject: bug in handling static const object of the enclosing class
// Date: Tue, 1 Sep 92 10:38:44 EDT
class X
{ // { dg-error "X::X" } implicit constructor
{ // { dg-error "1: note: X::X\\(const X&\\)" } implicit constructor
private:
int x;
public:
......@@ -13,21 +14,21 @@ class X
X( int );
};
class Y
class Y // { dg-error "1: error: new types may not be defined in a return type|1: note: \\(perhaps a semicolon is missing after the definition of 'Y'\\)" }
{
private:
X xx;
public:
Y();
}
X::X( int xi ) // { dg-error "return type|X::X|semicolon" }
X::X( int xi ) // { dg-error "14: error: return type specification for constructor invalid|14: note: candidates are: X::X\\(int\\)" }
{
x = xi;
}
const X X::x0( 0 );
Y::Y() // { dg-error "no match" }
Y::Y() // { dg-error "6: error: no matching function for call to 'X::X\\(\\)'" }
{
xx = X::x0;
}
// { dg-do assemble }
// { dg-options "-fshow-column" }
// Origin: Jakub Jelinek <jakub@redhat.com>
class X {
class X { // { dg-error "1: error: new types may not be defined in a return type|1: note: \\(perhaps a semicolon is missing after the definition of 'X'\\)" }
public:
X();
virtual ~X();
}
X::x() // { dg-error "return type|member function|semicolon" }
X::x() // { dg-error "6: error: no 'X X::x\\(\\)' member function declared in class 'X'" }
{
}
X::~x() // { dg-error "expected class-name" }
X::~x() // { dg-error "6: error: expected class-name before '\\(' token" }
{
}
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