]> git.tdb.fi Git - builder.git/blobdiff - source/gnuarchiver.cpp
Use dynamic_cast to reference when incorrect type is not acceptable
[builder.git] / source / gnuarchiver.cpp
index 742278de668653f17895abab2e6d003fc9698e16..f802031f0ee8ea83d12eba4da1019dcb9d2e7142 100644 (file)
@@ -28,12 +28,7 @@ Target *GnuArchiver::create_target(const list<Target *> &sources, const string &
 
        list<ObjectFile *> objs;
        for(Target *s: sources)
-       {
-               if(ObjectFile *obj = dynamic_cast<ObjectFile *>(s))
-                       objs.push_back(obj);
-               else
-                       throw invalid_argument("GnuArchiver::create_target");
-       }
+               objs.push_back(&dynamic_cast<ObjectFile &>(*s));
 
        const Component &comp = *objs.front()->get_component();
        StaticLibrary *lib = new StaticLibrary(builder, comp, objs);