From: Paolo Carlini <paolo.carlini@oracle.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Jason Merrill <jason@redhat.com>
Subject: [C++ Patch] Add location_t parameter to grokvardecl
Date: Mon, 10 Dec 2018 10:24:00 -0000 [thread overview]
Message-ID: <9208064d-b9a0-66bf-416d-b89f975febb4@oracle.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 432 bytes --]
Hi,
the other day I noticed that we weren't getting right the first location
of pr53037-4.C, for a variable, whereas the next one, for a function,
was Ok. Indeed, we were passing a location only to grokfndecl. In other
terms, I found a good empirical reason to move the declaration of the
local loc = declarator ? declarator->id_loc : input_location further up
;) Tested x86_64-linux.
Thanks, Paolo.
//////////////////////
[-- Attachment #2: CL_grokbitfield4 --]
[-- Type: text/plain, Size: 375 bytes --]
/cp
2018-12-10 Paolo Carlini <paolo.carlini@oracle.com>
* decl2.c (grokvardecl): Add location_t parameter and use it
in build_lang_decl_loc and build_decl calls.
(grokdeclarator): Move up loc declaration and use it in the
grokvardecl call too.
/testsuite
2018-12-10 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/pr53037-4.C: Test the first two locations too.
[-- Attachment #3: patch_grokbitfield4 --]
[-- Type: text/plain, Size: 3745 bytes --]
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 266943)
+++ cp/decl.c (working copy)
@@ -68,7 +68,7 @@ static int decl_jump_unsafe (tree);
static void require_complete_types_for_parms (tree);
static tree grok_reference_init (tree, tree, tree, int);
static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *,
- int, int, int, bool, int, tree);
+ int, int, int, bool, int, tree, location_t);
static void check_static_variable_definition (tree, tree);
static void record_unknown_type (tree, const char *);
static tree builtin_function_1 (tree, tree, bool);
@@ -9282,7 +9282,8 @@ grokvardecl (tree type,
int inlinep,
bool conceptp,
int template_count,
- tree scope)
+ tree scope,
+ location_t location)
{
tree decl;
tree explicit_scope;
@@ -9318,9 +9319,9 @@ grokvardecl (tree type,
/* Similarly for explicit specializations. */
|| (orig_declarator
&& TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR)))
- decl = build_lang_decl (VAR_DECL, name, type);
+ decl = build_lang_decl_loc (location, VAR_DECL, name, type);
else
- decl = build_decl (input_location, VAR_DECL, name, type);
+ decl = build_decl (location, VAR_DECL, name, type);
if (explicit_scope && TREE_CODE (explicit_scope) == NAMESPACE_DECL)
set_decl_namespace (decl, explicit_scope, 0);
@@ -12200,6 +12201,7 @@ grokdeclarator (const cp_declarator *declarator,
{
tree decl = NULL_TREE;
+ location_t loc = declarator ? declarator->id_loc : input_location;
if (decl_context == PARM)
{
@@ -12216,13 +12218,13 @@ grokdeclarator (const cp_declarator *declarator,
if (!staticp && !friendp && TREE_CODE (type) != METHOD_TYPE)
if (tree auto_node = type_uses_auto (type))
{
- location_t loc = declspecs->locations[ds_type_spec];
+ location_t tloc = declspecs->locations[ds_type_spec];
if (CLASS_PLACEHOLDER_TEMPLATE (auto_node))
- error_at (loc, "invalid use of template-name %qE without an "
+ error_at (tloc, "invalid use of template-name %qE without an "
"argument list",
CLASS_PLACEHOLDER_TEMPLATE (auto_node));
else
- error_at (loc, "non-static data member declared with "
+ error_at (tloc, "non-static data member declared with "
"placeholder %qT", auto_node);
type = error_mark_node;
}
@@ -12487,7 +12489,6 @@ grokdeclarator (const cp_declarator *declarator,
if (decl == NULL_TREE)
{
- location_t loc = declarator ? declarator->id_loc : input_location;
if (staticp)
{
/* C++ allows static class members. All other work
@@ -12704,7 +12705,8 @@ grokdeclarator (const cp_declarator *declarator,
inlinep,
concept_p,
template_count,
- ctype ? ctype : in_namespace);
+ ctype ? ctype : in_namespace,
+ loc);
if (decl == NULL_TREE)
return error_mark_node;
Index: testsuite/g++.dg/pr53037-4.C
===================================================================
--- testsuite/g++.dg/pr53037-4.C (revision 266943)
+++ testsuite/g++.dg/pr53037-4.C (working copy)
@@ -2,11 +2,11 @@
/* { dg-do compile } */
/* { dg-options "-O0" } */
-int foo1 __attribute__((warn_if_not_aligned(8))); /* { dg-error "'warn_if_not_aligned' may not be specified for 'foo1'" } */
+int foo1 __attribute__((warn_if_not_aligned(8))); /* { dg-error "5:'warn_if_not_aligned' may not be specified for 'foo1'" } */
__attribute__((warn_if_not_aligned(8)))
void
-foo2 (void) /* { dg-error "'warn_if_not_aligned' may not be specified for 'void foo2\\(\\)'" } */
+foo2 (void) /* { dg-error "1:'warn_if_not_aligned' may not be specified for 'void foo2\\(\\)'" } */
{
}
next reply other threads:[~2018-12-10 10:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 10:24 Paolo Carlini [this message]
2018-12-11 15:50 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9208064d-b9a0-66bf-416d-b89f975febb4@oracle.com \
--to=paolo.carlini@oracle.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).