Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 "Simplified" Exception Specification
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Juggernaut
New Member

Sweden
6 Posts

Posted - Nov 26 2004 :  06:39:57 AM  Show Profile
As we all know, exception specification in c++ is pretty useless due to that it's runtime check only. How about a feature that will parse function bodies for functions with commented specification, and point out if they aren't caught (in those cases where it is simply to find out)
Ex:
void foo(); //throw(FileNotFound)
void foo2();
void bar(); //throw(SomeOtherException)
struct cFoo {
cFoo() //throw()
{}
~cFoo() //throw()
{}
void CopyFile //throw(FileNotFound)
{ }
}
int main() {
CFoo
return 0;
}
void bar() //throw(SomeOtherException)
{
throw SomeOtherException
}
void foo() //throw(FileNotFound)
{
/*
Parsing the comment //throw(<...>) on the Bar() declaration,
tells it can throw a SomeOtherException exception.
Bar() below is not surrounded with try/catch(SomeOtherException&),
so we should mark that function as potentially unsafe.
*/
Bar();
/*
The code below catches all exceptions so we are safe
*/
try { Bar(); } catch(...) { }
cFoo Obj;
Obj.CopyFile(); //safe because the ES matches (or less restrictive)
}

This would be a great feature, and even greater if one could use a "parse function" that parses through all the code, and list code that doesn't handle exceptions specified in those commented out exception lists, sort of a pre-compile warning feature :)...
This would give us the ES advantages in compile time (i.e. warning messages for exception that isn't caught, for those ESs that can be determined, others should be ignored so we don't get a zillion warnings for code that doesn't use ES ), but not the ES drawbacks of runtime checking (because we actually comment out the ES, so we don't get the unknown exception which in turn could terminate the app).

feline
Whole Tomato Software

United Kingdom
19024 Posts

Posted - Dec 01 2004 :  5:25:37 PM  Show Profile
the VAX parser isnt as cleaver as the compiler, since it is designed for a different job. this is really a bit outside of the scope of VAX.

would lint do this? a quick google finds: http://www.gimpel.com/
i have heard that lint is a fairly standard UNIX program, so it should be possible to find a GNU type version.

zen is the art of being at one with the two'ness
Go to Top of Page

Juggernaut
New Member

Sweden
6 Posts

Posted - Dec 01 2004 :  5:54:01 PM  Show Profile
Yeah Lint seems to be able to do the trick... To bad the price tag was so high... Thanks for the tip! :)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000