This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Empty vector::push_back()?


On Mon, Feb 25, 2002 at 08:59:10PM -0800, Benjamin Kosnik wrote:
> > I guess, for future releases, it might be interesting to investigate
> > Phil's suggestion of "instructing the compiler about diagnostics".
> 
> It's an interesting idea, but I cannot find Phil's email in the web 
> archive. 
> 
> Is this an automated way of doing things like the deprecated warning?

Somewhere I still have the script(1) log from when I first worked it up.
Hang on a minute.

*half an hour later*

Gah, my filing system stinks.  Okay, it's appended below; it's only my old
generalized diagnostic that I tossed around back when we were too busy.
The attribute name choice of 'warning' and the requirement of -pedantic
were entirely arbitrary choices of mine at the time.

What I'd really like is to use Gaby's gcc/diagnostic.def approach,
and permit the user to set the diagnostic level, e.g.,

  __attribute__((__talkback__(DK_NOTE,"this works better with green")))

Or maybe just hardcode it to use DK_NOTE instead of producing a warning.

Phil
====================================================================

50% cat test_attr.cc

// save some typing in the following test case
#define GX    __attribute__ ((__warning__("This is a GNU extension")))


// apparently the syntax doesn't work like this... annoying.
// extern void specialfunc() GX {;}
extern void specialfunc() GX;
void specialfunc() { }

struct special_class { } GX ;

struct normal_class
{
    void normal_memfn() {;}
    void special_memfn() GX;
};
void normal_class::special_memfn() {;}

typedef normal_class*  weird_typedef GX ;


int main()
{
    specialfunc();                            // should warn

    special_class  x;                         // should warn
    special_class  *y = new special_class;    // should warn

    weird_typedef  huh;                       // should warn

    normal_class   n;                         // should not warn
    n.normal_memfn();                         // should not warn
    n.special_memfn();                        // should warn

    normal_class   *p = new normal_class;     // should not warn
    p->normal_memfn();                        // should not warn
    p->special_memfn();                       // should warn
}

51% g++ -pedantic test_attr.cc
test_attr.cc: In function `int main()':
test_attr.cc:8: warning: `void specialfunc()': This is a GNU extension
test_attr.cc:26: warning: `special_class x': This is a GNU extension
test_attr.cc:27: warning: `special_class*y': This is a GNU extension
test_attr.cc:17: warning: `void normal_class::special_memfn()': This is a GNU
   extension
test_attr.cc:17: warning: `void normal_class::special_memfn()': This is a GNU
   extension
52%



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]