* [C++ Patch] Fix three locations
@ 2019-01-09 15:47 Paolo Carlini
2019-01-10 21:38 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2019-01-09 15:47 UTC (permalink / raw)
To: gcc-patches; +Cc: Jason Merrill
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
Hi,
three additional fixes along the usual lines. In the grokdeclarator
changes I'm not touching the actual printing of the name, but another
option would be using %qD and decl here too, thus, for cases like
parse/crash43.C, where everything lives inside a namespace, we would
print 'N::i'. instead of simply 'i'. Tested x86_64-linux, plus I checked
by hand with a cross-compiler the dllimport bit.
Thanks, Paolo.
////////////////////////
[-- Attachment #2: CL_locs_22 --]
[-- Type: text/plain, Size: 323 bytes --]
/cp
2019-01-09 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (start_decl): Improve error location.
(grokdeclarator): Likewise, improve two locations.
/testsuite
2019-01-09 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/diagnostic/extern-initialized.C: New.
* g++.dg/ext/dllimport-initialized.C: Likewise.
[-- Attachment #3: patch_locs_22 --]
[-- Type: text/plain, Size: 2127 bytes --]
Index: cp/decl.c
===================================================================
--- cp/decl.c (revision 267756)
+++ cp/decl.c (working copy)
@@ -5096,7 +5096,8 @@ start_decl (const cp_declarator *declarator,
a definition. */
if (initialized && DECL_DLLIMPORT_P (decl))
{
- error ("definition of %q#D is marked %<dllimport%>", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "definition of %q#D is marked %<dllimport%>", decl);
DECL_DLLIMPORT_P (decl) = 0;
}
@@ -12791,11 +12792,13 @@ grokdeclarator (const cp_declarator *declarator,
/* It's common practice (and completely valid) to have a const
be initialized and declared extern. */
if (!(type_quals & TYPE_QUAL_CONST))
- warning (0, "%qs initialized and declared %<extern%>", name);
+ warning_at (DECL_SOURCE_LOCATION (decl), 0,
+ "%qs initialized and declared %<extern%>", name);
}
else
{
- error ("%qs has both %<extern%> and initializer", name);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qs has both %<extern%> and initializer", name);
return error_mark_node;
}
}
Index: testsuite/g++.dg/diagnostic/extern-initialized.C
===================================================================
--- testsuite/g++.dg/diagnostic/extern-initialized.C (nonexistent)
+++ testsuite/g++.dg/diagnostic/extern-initialized.C (working copy)
@@ -0,0 +1,6 @@
+extern int i __attribute__((unused)) = 0; // { dg-warning "12:.i. initialized and declared .extern." }
+
+void foo()
+{
+ extern int i __attribute__((unused)) = 0; // { dg-error "14:.i. has both .extern. and initializer" }
+}
Index: testsuite/g++.dg/ext/dllimport-initialized.C
===================================================================
--- testsuite/g++.dg/ext/dllimport-initialized.C (nonexistent)
+++ testsuite/g++.dg/ext/dllimport-initialized.C (working copy)
@@ -0,0 +1,3 @@
+// { dg-do compile { target i?86-*-cygwin* i?86-*-mingw* x86_64-*-mingw* } }
+
+__attribute__((dllimport)) int i __attribute__((unused)) = 0; // { dg-error "32:definition of .int i. is marked .dllimport." }
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C++ Patch] Fix three locations
2019-01-09 15:47 [C++ Patch] Fix three locations Paolo Carlini
@ 2019-01-10 21:38 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2019-01-10 21:38 UTC (permalink / raw)
To: Paolo Carlini, gcc-patches
On 1/9/19 10:46 AM, Paolo Carlini wrote:
> Hi,
>
> three additional fixes along the usual lines. In the grokdeclarator
> changes I'm not touching the actual printing of the name, but another
> option would be using %qD and decl here too, thus, for cases like
> parse/crash43.C, where everything lives inside a namespace, we would
> print 'N::i'. instead of simply 'i'. Tested x86_64-linux, plus I checked
> by hand with a cross-compiler the dllimport bit.
>
> Thanks, Paolo.
>
> ////////////////////////
>
OK.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-10 21:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-09 15:47 [C++ Patch] Fix three locations Paolo Carlini
2019-01-10 21:38 ` Jason Merrill
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).