decl.c (start_decl): Improve error location.
/cp 2019-01-15 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (start_decl): Improve error location. * decl2.c (grokfield): Likewise. /testsuite 2019-01-15 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/diagnostic/typedef-initialized.C: New. /cp 2019-01-15 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (grokdeclarator): Move further up the location_t loc declaration and use the location when building a TYPE_DECL for a typedef name. * decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in the error about an ill-formed bit-field as typedef. /testsuite 2019-01-15 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/diagnostic/bitfld3.C: New. From-SVN: r267932
This commit is contained in:
parent
93aa3c4aca
commit
079a66801b
6 changed files with 42 additions and 6 deletions
|
@ -1,3 +1,16 @@
|
|||
2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* decl.c (start_decl): Improve error location.
|
||||
* decl2.c (grokfield): Likewise.
|
||||
|
||||
2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* decl.c (grokdeclarator): Move further up the location_t loc
|
||||
declaration and use the location when building a TYPE_DECL for
|
||||
a typedef name.
|
||||
* decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in the error
|
||||
about an ill-formed bit-field as typedef.
|
||||
|
||||
2019-01-14 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
PR c++/88830 - ICE with abstract class.
|
||||
|
|
|
@ -5059,7 +5059,8 @@ start_decl (const cp_declarator *declarator,
|
|||
if (initialized
|
||||
&& TREE_CODE (decl) == TYPE_DECL)
|
||||
{
|
||||
error ("typedef %qD is initialized (use decltype instead)", decl);
|
||||
error_at (DECL_SOURCE_LOCATION (decl),
|
||||
"typedef %qD is initialized (use decltype instead)", decl);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
|
@ -11935,6 +11936,8 @@ grokdeclarator (const cp_declarator *declarator,
|
|||
}
|
||||
}
|
||||
|
||||
location_t loc = declarator ? declarator->id_loc : input_location;
|
||||
|
||||
/* If this is declaring a typedef name, return a TYPE_DECL. */
|
||||
if (typedef_p && decl_context != TYPENAME)
|
||||
{
|
||||
|
@ -11980,9 +11983,9 @@ grokdeclarator (const cp_declarator *declarator,
|
|||
}
|
||||
|
||||
if (decl_context == FIELD)
|
||||
decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
|
||||
decl = build_lang_decl_loc (loc, TYPE_DECL, unqualified_id, type);
|
||||
else
|
||||
decl = build_decl (input_location, TYPE_DECL, unqualified_id, type);
|
||||
decl = build_decl (loc, TYPE_DECL, unqualified_id, type);
|
||||
|
||||
if (decl_context != FIELD)
|
||||
{
|
||||
|
@ -12223,7 +12226,6 @@ grokdeclarator (const cp_declarator *declarator,
|
|||
|
||||
{
|
||||
tree decl = NULL_TREE;
|
||||
location_t loc = declarator ? declarator->id_loc : input_location;
|
||||
|
||||
if (decl_context == PARM)
|
||||
{
|
||||
|
|
|
@ -820,7 +820,8 @@ grokfield (const cp_declarator *declarator,
|
|||
|
||||
if (TREE_CODE (value) == TYPE_DECL && init)
|
||||
{
|
||||
error ("typedef %qD is initialized (use decltype instead)", value);
|
||||
error_at (cp_expr_loc_or_loc (init, DECL_SOURCE_LOCATION (value)),
|
||||
"typedef %qD is initialized (use decltype instead)", value);
|
||||
init = NULL_TREE;
|
||||
}
|
||||
|
||||
|
@ -1038,7 +1039,8 @@ grokbitfield (const cp_declarator *declarator,
|
|||
|
||||
if (TREE_CODE (value) == TYPE_DECL)
|
||||
{
|
||||
error ("cannot declare %qD to be a bit-field type", value);
|
||||
error_at (DECL_SOURCE_LOCATION (value),
|
||||
"cannot declare %qD to be a bit-field type", value);
|
||||
return NULL_TREE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* g++.dg/diagnostic/typedef-initialized.C: New.
|
||||
|
||||
2019-01-15 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* g++.dg/diagnostic/bitfld3.C: New.
|
||||
|
||||
2019-01-15 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR tree-optimization/88775
|
||||
|
|
5
gcc/testsuite/g++.dg/diagnostic/bitfld3.C
Normal file
5
gcc/testsuite/g++.dg/diagnostic/bitfld3.C
Normal file
|
@ -0,0 +1,5 @@
|
|||
struct S
|
||||
{
|
||||
typedef int i : 3; // { dg-error "15:cannot declare .i." }
|
||||
typedef int : 3; // { dg-error "cannot declare" }
|
||||
};
|
6
gcc/testsuite/g++.dg/diagnostic/typedef-initialized.C
Normal file
6
gcc/testsuite/g++.dg/diagnostic/typedef-initialized.C
Normal file
|
@ -0,0 +1,6 @@
|
|||
struct S
|
||||
{
|
||||
typedef int i __attribute__((unused)) = 1; // { dg-error "15:typedef .i. is initialized" }
|
||||
};
|
||||
|
||||
typedef int i __attribute__((unused)) = 1; // { dg-error "13:typedef .i. is initialized" }
|
Loading…
Add table
Reference in a new issue