* Re: PR middle-end/18160
[not found] ` <jehdohgh9z.fsf@sykes.suse.de>
@ 2004-10-27 8:26 ` Adam Nemet
2004-10-27 9:52 ` Joseph S. Myers
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Adam Nemet @ 2004-10-27 8:26 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Richard Henderson, gcc, gcc-patches
Andreas Schwab writes:
> Adam Nemet <anemet@lnxw.com> writes:
>> Should this be turned into an error too?
> It violates a constraint in the standard.
Thanks for all the comments. Here is the patch to turn the testcase
into an error. It was regression tested on i686-pc-linux-gnu.
Is it OK to apply?
Adam
2004-10-26 Adam Nemet <anemet@lnxw.com>
PR middle-end/18160
* c-typeck.c (c_mark_addressable): Issue error if address of a
register variable is taken.
2004-10-26 Adam Nemet <anemet@lnxw.com>
PR middle-end/18160
* gcc.dg/pr18160.c: New test.
* gcc.dg/pr18160-1.c: New test.
* gcc.dg/asm-7.c: Taking the address of a register variable is an
error now.
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.392
diff -c -p -r1.392 c-typeck.c
*** c-typeck.c 17 Oct 2004 22:01:19 -0000 1.392
--- c-typeck.c 27 Oct 2004 06:23:14 -0000
*************** c_mark_addressable (tree exp)
*** 2856,2869 ****
else if (C_DECL_REGISTER (x))
{
if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
! {
! error ("address of global register variable %qs requested",
! IDENTIFIER_POINTER (DECL_NAME (x)));
! return false;
! }
!
! pedwarn ("address of register variable %qs requested",
IDENTIFIER_POINTER (DECL_NAME (x)));
}
/* drops in */
--- 2856,2867 ----
else if (C_DECL_REGISTER (x))
{
if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
! error ("address of global register variable %qs requested",
! IDENTIFIER_POINTER (DECL_NAME (x)));
! else
! error ("address of register variable %qs requested",
IDENTIFIER_POINTER (DECL_NAME (x)));
+ return false;
}
/* drops in */
Index: testsuite/gcc.dg/pr18160-1.c
===================================================================
RCS file: testsuite/gcc.dg/pr18160-1.c
diff -N testsuite/gcc.dg/pr18160-1.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/pr18160-1.c 27 Oct 2004 06:23:14 -0000
***************
*** 0 ****
--- 1,14 ----
+ /* PR/18160 */
+
+ /* { dg-do compile } */
+
+ /* This should yield an error even without -pedantic. */
+ /* { dg-options "-ansi" } */
+
+ void g(int *);
+
+ void f(void)
+ {
+ register int x;
+ g(&x); /* { dg-error "address of register variable" } */
+ }
Index: testsuite/gcc.dg/pr18160.c
===================================================================
RCS file: testsuite/gcc.dg/pr18160.c
diff -N testsuite/gcc.dg/pr18160.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/pr18160.c 27 Oct 2004 06:23:14 -0000
***************
*** 0 ****
--- 1,14 ----
+ /* PR/18160 */
+
+ /* { dg-do compile { target i?86-*-* } } */
+
+ /* This should yield an error even without -pedantic. */
+ /* { dg-options "-ansi" } */
+
+ void g(int *);
+
+ void f(void)
+ {
+ register int x __asm ("eax");
+ g(&x); /* { dg-error "address of register variable" } */
+ }
Index: testsuite/gcc.dg/asm-7.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/asm-7.c,v
retrieving revision 1.4
diff -c -p -r1.4 asm-7.c
*** testsuite/gcc.dg/asm-7.c 13 May 2004 06:40:49 -0000 1.4
--- testsuite/gcc.dg/asm-7.c 27 Oct 2004 06:23:14 -0000
*************** void test(void)
*** 9,15 ****
static int m;
int *p;
! __asm__ ("" : : "m"(r)); /* { dg-warning "address of register" } */
__asm__ ("" : : "m"(i));
__asm__ ("" : : "m"(m));
__asm__ ("" : : "m"(0)); /* { dg-error "" } */
--- 9,15 ----
static int m;
int *p;
! __asm__ ("" : : "m"(r)); /* { dg-error "" } */
__asm__ ("" : : "m"(i));
__asm__ ("" : : "m"(m));
__asm__ ("" : : "m"(0)); /* { dg-error "" } */
*************** void test(void)
*** 22,28 ****
__asm__ ("" : : "g"(0));
__asm__ ("" : : "g"(i+1));
! __asm__ ("" : "=m"(r2)); /* { dg-warning "address of register" } */
__asm__ ("" : "=m"(i));
__asm__ ("" : "=m"(m));
}
--- 22,28 ----
__asm__ ("" : : "g"(0));
__asm__ ("" : : "g"(i+1));
! __asm__ ("" : "=m"(r2)); /* { dg-error "" } */
__asm__ ("" : "=m"(i));
__asm__ ("" : "=m"(m));
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR middle-end/18160
2004-10-27 8:26 ` PR middle-end/18160 Adam Nemet
@ 2004-10-27 9:52 ` Joseph S. Myers
2004-10-27 9:57 ` Eric Botcazou
2004-10-27 16:53 ` Richard Henderson
2004-10-27 17:35 ` Giovanni Bajo
2 siblings, 1 reply; 7+ messages in thread
From: Joseph S. Myers @ 2004-10-27 9:52 UTC (permalink / raw)
To: Adam Nemet; +Cc: Andreas Schwab, Richard Henderson, gcc, gcc-patches
On Tue, 26 Oct 2004, Adam Nemet wrote:
> * gcc.dg/pr18160.c: New test.
> * gcc.dg/pr18160-1.c: New test.
You should use pr18160-1.c, pr18160-2.c unless there's some specific
reason not to do so. When adding just a single testcase for a problem, it
should normally include the -1 suffix - in case future related tests
arise.
> + g(&x); /* { dg-error "address of register variable" } */
dg-error does not test that something is a hard error, for now you need to
include the "error: " prefix in the tested message explicitly.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR middle-end/18160
2004-10-27 9:52 ` Joseph S. Myers
@ 2004-10-27 9:57 ` Eric Botcazou
2004-10-27 22:57 ` Adam Nemet
0 siblings, 1 reply; 7+ messages in thread
From: Eric Botcazou @ 2004-10-27 9:57 UTC (permalink / raw)
To: gcc
Cc: Joseph S. Myers, Adam Nemet, Andreas Schwab, Richard Henderson,
gcc-patches
> You should use pr18160-1.c, pr18160-2.c unless there's some specific
> reason not to do so. When adding just a single testcase for a problem, it
> should normally include the -1 suffix - in case future related tests
> arise.
IMHO register-var-1.c, register-var-2.c would be even better.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR middle-end/18160
2004-10-27 8:26 ` PR middle-end/18160 Adam Nemet
2004-10-27 9:52 ` Joseph S. Myers
@ 2004-10-27 16:53 ` Richard Henderson
2004-10-27 17:35 ` Giovanni Bajo
2 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2004-10-27 16:53 UTC (permalink / raw)
To: Adam Nemet; +Cc: Andreas Schwab, gcc, gcc-patches
On Tue, Oct 26, 2004 at 11:49:41PM -0700, Adam Nemet wrote:
> ! error ("address of global register variable %qs requested",
> ! IDENTIFIER_POINTER (DECL_NAME (x)));
Should use "%qD" and "x" instead of pulling out IDENTIFIER_POINTER.
Otherwise ok.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR middle-end/18160
2004-10-27 8:26 ` PR middle-end/18160 Adam Nemet
2004-10-27 9:52 ` Joseph S. Myers
2004-10-27 16:53 ` Richard Henderson
@ 2004-10-27 17:35 ` Giovanni Bajo
2 siblings, 0 replies; 7+ messages in thread
From: Giovanni Bajo @ 2004-10-27 17:35 UTC (permalink / raw)
To: Adam Nemet; +Cc: gcc-patches
Adam Nemet wrote:
> Andreas Schwab writes:
>> Adam Nemet <anemet@lnxw.com> writes:
>>> Should this be turned into an error too?
>> It violates a constraint in the standard.
>
> Thanks for all the comments. Here is the patch to turn the testcase
> into an error. It was regression tested on i686-pc-linux-gnu.
Would you please document this in http://gcc.gnu.org/gcc-4.0/changes.html? I
can see us getting bogus bug reports about this if we do not.
Giovanni Bajo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR middle-end/18160
2004-10-27 9:57 ` Eric Botcazou
@ 2004-10-27 22:57 ` Adam Nemet
2004-10-27 23:00 ` Richard Henderson
0 siblings, 1 reply; 7+ messages in thread
From: Adam Nemet @ 2004-10-27 22:57 UTC (permalink / raw)
To: Eric Botcazou
Cc: gcc, Joseph S. Myers, Andreas Schwab, Richard Henderson,
gcc-patches, giovannibajo
The updated patch addresses the comments I received.
Let me know if it is still OK to commit. I retested the patch. I
will update changes.html in a separate patch.
Adam
2004-10-27 Adam Nemet <anemet@lnxw.com>
PR middle-end/18160
* c-typeck.c (c_mark_addressable): Issue error if address of a
register variable is taken. Use "%qD" to print DECL_NAME.
2004-10-27 Adam Nemet <anemet@lnxw.com>
PR middle-end/18160
* gcc.dg/register-var-1.c: New test.
* gcc.dg/register-var-2.c: New test.
* gcc.dg/asm-7.c: Taking the address of a register variable is an
error now.
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.392
diff -c -p -r1.392 c-typeck.c
*** c-typeck.c 17 Oct 2004 22:01:19 -0000 1.392
--- c-typeck.c 27 Oct 2004 19:23:16 -0000
*************** c_mark_addressable (tree exp)
*** 2818,2825 ****
case COMPONENT_REF:
if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
{
! error ("cannot take address of bit-field %qs",
! IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (x, 1))));
return false;
}
--- 2818,2825 ----
case COMPONENT_REF:
if (DECL_C_BIT_FIELD (TREE_OPERAND (x, 1)))
{
! error
! ("cannot take address of bit-field %qD", TREE_OPERAND (x, 1));
return false;
}
*************** c_mark_addressable (tree exp)
*** 2846,2869 ****
{
if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
{
! error ("global register variable %qs used in nested function",
! IDENTIFIER_POINTER (DECL_NAME (x)));
return false;
}
! pedwarn ("register variable %qs used in nested function",
! IDENTIFIER_POINTER (DECL_NAME (x)));
}
else if (C_DECL_REGISTER (x))
{
if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
! {
! error ("address of global register variable %qs requested",
! IDENTIFIER_POINTER (DECL_NAME (x)));
! return false;
! }
!
! pedwarn ("address of register variable %qs requested",
! IDENTIFIER_POINTER (DECL_NAME (x)));
}
/* drops in */
--- 2846,2864 ----
{
if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
{
! error
! ("global register variable %qD used in nested function", x);
return false;
}
! pedwarn ("register variable %qD used in nested function", x);
}
else if (C_DECL_REGISTER (x))
{
if (TREE_PUBLIC (x) || TREE_STATIC (x) || DECL_EXTERNAL (x))
! error ("address of global register variable %qD requested", x);
! else
! error ("address of register variable %qD requested", x);
! return false;
}
/* drops in */
Index: testsuite/gcc.dg/register-var-1.c
===================================================================
RCS file: testsuite/gcc.dg/register-var-1.c
diff -N testsuite/gcc.dg/register-var-1.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/register-var-1.c 27 Oct 2004 19:23:16 -0000
***************
*** 0 ****
--- 1,14 ----
+ /* PR/18160 */
+
+ /* { dg-do compile { target i?86-*-* } } */
+
+ /* This should yield an error even without -pedantic. */
+ /* { dg-options "-ansi" } */
+
+ void g(int *);
+
+ void f(void)
+ {
+ register int x __asm ("eax");
+ g(&x); /* { dg-error "error: address of register variable" } */
+ }
Index: testsuite/gcc.dg/register-var-2.c
===================================================================
RCS file: testsuite/gcc.dg/register-var-2.c
diff -N testsuite/gcc.dg/register-var-2.c
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/register-var-2.c 27 Oct 2004 19:23:16 -0000
***************
*** 0 ****
--- 1,14 ----
+ /* PR/18160 */
+
+ /* { dg-do compile } */
+
+ /* This should yield an error even without -pedantic. */
+ /* { dg-options "-ansi" } */
+
+ void g(int *);
+
+ void f(void)
+ {
+ register int x;
+ g(&x); /* { dg-error "error: address of register variable" } */
+ }
Index: testsuite/gcc.dg/asm-7.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/asm-7.c,v
retrieving revision 1.4
diff -c -p -r1.4 asm-7.c
*** testsuite/gcc.dg/asm-7.c 13 May 2004 06:40:49 -0000 1.4
--- testsuite/gcc.dg/asm-7.c 27 Oct 2004 19:23:16 -0000
*************** void test(void)
*** 9,15 ****
static int m;
int *p;
! __asm__ ("" : : "m"(r)); /* { dg-warning "address of register" } */
__asm__ ("" : : "m"(i));
__asm__ ("" : : "m"(m));
__asm__ ("" : : "m"(0)); /* { dg-error "" } */
--- 9,15 ----
static int m;
int *p;
! __asm__ ("" : : "m"(r)); /* { dg-error "" } */
__asm__ ("" : : "m"(i));
__asm__ ("" : : "m"(m));
__asm__ ("" : : "m"(0)); /* { dg-error "" } */
*************** void test(void)
*** 22,28 ****
__asm__ ("" : : "g"(0));
__asm__ ("" : : "g"(i+1));
! __asm__ ("" : "=m"(r2)); /* { dg-warning "address of register" } */
__asm__ ("" : "=m"(i));
__asm__ ("" : "=m"(m));
}
--- 22,28 ----
__asm__ ("" : : "g"(0));
__asm__ ("" : : "g"(i+1));
! __asm__ ("" : "=m"(r2)); /* { dg-error "" } */
__asm__ ("" : "=m"(i));
__asm__ ("" : "=m"(m));
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: PR middle-end/18160
2004-10-27 22:57 ` Adam Nemet
@ 2004-10-27 23:00 ` Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2004-10-27 23:00 UTC (permalink / raw)
To: Adam Nemet
Cc: Eric Botcazou, gcc, Joseph S. Myers, Andreas Schwab, gcc-patches,
giovannibajo
On Wed, Oct 27, 2004 at 03:54:44PM -0700, Adam Nemet wrote:
> PR middle-end/18160
> * c-typeck.c (c_mark_addressable): Issue error if address of a
> register variable is taken. Use "%qD" to print DECL_NAME.
Ok.
r~
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-10-27 22:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <16766.43717.959860.195034@anemet1.lynx.com>
[not found] ` <20041026195203.GA15086@redhat.com>
[not found] ` <16766.46685.198957.191723@anemet1.lynx.com>
[not found] ` <20041026202657.GA15269@redhat.com>
[not found] ` <16766.54682.82730.11990@anemet1.lynx.com>
[not found] ` <20041026224419.GA15592@redhat.com>
[not found] ` <16766.57917.483995.480374@anemet1.lynx.com>
[not found] ` <jehdohgh9z.fsf@sykes.suse.de>
2004-10-27 8:26 ` PR middle-end/18160 Adam Nemet
2004-10-27 9:52 ` Joseph S. Myers
2004-10-27 9:57 ` Eric Botcazou
2004-10-27 22:57 ` Adam Nemet
2004-10-27 23:00 ` Richard Henderson
2004-10-27 16:53 ` Richard Henderson
2004-10-27 17:35 ` Giovanni Bajo
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).