public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/34351]  New: Please get us the "volatile register" warning back
@ 2007-12-05 19:32 j at uriah dot heep dot sax dot de
  2007-12-09  2:06 ` [Bug c/34351] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: j at uriah dot heep dot sax dot de @ 2007-12-05 19:32 UTC (permalink / raw)
  To: gcc-bugs

Microcontroller programmers tend to fall into the trap of trying to
bind a variable to a CPU register, and declare it "volatile" so they
could e.g. use it to communicate between the main context and an ISR.

Previous GCC versions issued a warning:

volatile register variables don't work as you might wish

This warning has been removed without making volatile register variables
work the way an innocent programmer would assume.

Please re-enable that warning at least for -Wall and/or -Wextra.


-- 
           Summary: Please get us the "volatile register" warning back
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: j at uriah dot heep dot sax dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34351


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/34351] Please get us the "volatile register" warning back
  2007-12-05 19:32 [Bug c/34351] New: Please get us the "volatile register" warning back j at uriah dot heep dot sax dot de
@ 2007-12-09  2:06 ` pinskia at gcc dot gnu dot org
  2007-12-09  7:37 ` j at uriah dot heep dot sax dot de
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-12-09  2:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-12-09 02:06 -------
use -Wvolatile-register-var


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34351


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/34351] Please get us the "volatile register" warning back
  2007-12-05 19:32 [Bug c/34351] New: Please get us the "volatile register" warning back j at uriah dot heep dot sax dot de
  2007-12-09  2:06 ` [Bug c/34351] " pinskia at gcc dot gnu dot org
@ 2007-12-09  7:37 ` j at uriah dot heep dot sax dot de
  2007-12-13 13:04 ` manu at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: j at uriah dot heep dot sax dot de @ 2007-12-09  7:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from j at uriah dot heep dot sax dot de  2007-12-09 07:37 -------
> use -Wvolatile-register-var

Could we have that at least as part of one of the "standard"
warning switch combinations, either -Wall or -Wextra?  I
remember a statement from the developer who introduced the
change that he wouldn't mind if it were enabled by -Wall.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34351


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/34351] Please get us the "volatile register" warning back
  2007-12-05 19:32 [Bug c/34351] New: Please get us the "volatile register" warning back j at uriah dot heep dot sax dot de
  2007-12-09  2:06 ` [Bug c/34351] " pinskia at gcc dot gnu dot org
  2007-12-09  7:37 ` j at uriah dot heep dot sax dot de
@ 2007-12-13 13:04 ` manu at gcc dot gnu dot org
  2008-02-26 14:05 ` manu at gcc dot gnu dot org
  2008-02-26 14:07 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-12-13 13:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from manu at gcc dot gnu dot org  2007-12-13 13:03 -------
Moreover, the option is defined in common.opt when it is C/C++ specific.

Untested patch:

Index: gcc/common.opt
===================================================================
--- gcc/common.opt      (revision 130605)
+++ gcc/common.opt      (working copy)
@@ -213,10 +213,6 @@
 Common Var(warn_unused_variable) Warning
 Warn when a variable is unused

-Wvolatile-register-var
-Common Var(warn_register_var) Warning
-Warn when a register variable is declared volatile
-
 Wcoverage-mismatch
 Common RejectNegative Var(warn_coverage_mismatch) Warning
 Warn instead of error in case profiles in -fprofile-use do not match
Index: gcc/c.opt
===================================================================
--- gcc/c.opt   (revision 130605)
+++ gcc/c.opt   (working copy)
@@ -465,6 +465,10 @@
 C ObjC C++ ObjC++ Var(warn_vla) Init(-1) Warning
 Warn if a variable length array is used

+Wvolatile-register-var
+C ObjC C++ ObjC++ Var(warn_volatile_register_var) Warning
+Warn when a register variable is declared volatile
+
 Wwrite-strings
 C ObjC C++ ObjC++ Var(warn_write_strings) Warning
 In C++, nonzero means warn about deprecated conversion from string literals to
`char *'.  In C, similar warning, except that the conversion is of course not
deprecated by the ISO C standard.
Index: gcc/c-opts.c
===================================================================
--- gcc/c-opts.c        (revision 130605)
+++ gcc/c-opts.c        (working copy)
@@ -405,6 +405,7 @@
       warn_address = value;
       warn_strict_overflow = value;
       warn_array_bounds = value;
+      warn_volatile_register_var = value;

       /* Only warn about unknown pragmas that are not in system
         headers.  */
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi (revision 130605)
+++ gcc/doc/invoke.texi (working copy)
@@ -2656,6 +2656,7 @@
 -Wunused-label     @gol
 -Wunused-value     @gol
 -Wunused-variable  @gol
+-Wvolatile-register-var @gol
 }

 Note that some warning flags are not implied by @option{-Wall}.  Some of
@@ -3902,7 +3903,8 @@
 @opindex Wno-volatile-register-var
 Warn if a register variable is declared volatile.  The volatile
 modifier does not inhibit all optimizations that may eliminate reads
-and/or writes to register variables.
+and/or writes to register variables.  This warning is enabled by
+@option{-Wall}.

 @item -Wdisabled-optimization
 @opindex Wdisabled-optimization


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-12-13 13:03:53
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34351


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/34351] Please get us the "volatile register" warning back
  2007-12-05 19:32 [Bug c/34351] New: Please get us the "volatile register" warning back j at uriah dot heep dot sax dot de
                   ` (2 preceding siblings ...)
  2007-12-13 13:04 ` manu at gcc dot gnu dot org
@ 2008-02-26 14:05 ` manu at gcc dot gnu dot org
  2008-02-26 14:07 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-02-26 14:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from manu at gcc dot gnu dot org  2008-02-26 14:04 -------
Subject: Bug 34351

Author: manu
Date: Tue Feb 26 14:04:09 2008
New Revision: 132675

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132675
Log:
2008-02-26  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR 34351
        * doc/invoke.texi (-Wall): Add -Wvolatile-register-var.
        * c-opts.c (c_common_handle_option): Wall enables
        Wvolatile-register-var.
        * common.opt: Move Wvolatile-register-var to...
        * c.opt: ...here.
testsuite/
        * gcc.dg/pr34351.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/pr34351.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-opts.c
    trunk/gcc/c.opt
    trunk/gcc/common.opt
    trunk/gcc/doc/invoke.texi
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34351


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/34351] Please get us the "volatile register" warning back
  2007-12-05 19:32 [Bug c/34351] New: Please get us the "volatile register" warning back j at uriah dot heep dot sax dot de
                   ` (3 preceding siblings ...)
  2008-02-26 14:05 ` manu at gcc dot gnu dot org
@ 2008-02-26 14:07 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-02-26 14:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2008-02-26 14:06 -------
Fixed in 4.4.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34351


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-26 14:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-05 19:32 [Bug c/34351] New: Please get us the "volatile register" warning back j at uriah dot heep dot sax dot de
2007-12-09  2:06 ` [Bug c/34351] " pinskia at gcc dot gnu dot org
2007-12-09  7:37 ` j at uriah dot heep dot sax dot de
2007-12-13 13:04 ` manu at gcc dot gnu dot org
2008-02-26 14:05 ` manu at gcc dot gnu dot org
2008-02-26 14:07 ` manu at gcc dot gnu dot org

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).