What you have there is a variety of nightshade (Solanum). It’s the evil, weedy, toxic cousin of the common tomato. Look at the leaves—see how closely they resemble tomato leaves? I can’t tell which variety without seeing the plant close-up, and since I don’t know where you’re located, I can’t research common nightshades in your area. This is a link to an article about nightshade plant varieties in the US—however, as plants, and weeds in particular, don’t honor international borders, chances are you will find your plant described in the article. http://ucanr.edu/sites/Weed_Management/files/138785.pdf
Nightshade is considered to be toxic to both animals and humans, if ingested. They contain Atropine and Solanine (very poisonous, even in small amounts), mostly in the mostly in the leaves and un-ripened berries. If it’s in your garden, you’ll want to get rid of it.