In D&D 5e, a location is effectively a space in a place or a point on a map, as opposed to constituting a discrete object (a location can be a point in midair, for instance). They are defined relative to the plane of travel which that location occupies, such as a particular position on the deck of a ship, or in a cave somewhere on an oblate spheroid. In specific cases, a location might be defined relative to an object or creature, but mechanically speaking, each location is a space, not necessarily what's in the space.
By RAW, attacks can target a creature, object, or location:
(emphasis mine)
Making an Attack (PHB p193)
Whether you're striking with a melee weapon, firing a weapon at range, or making an attack roll as part of a spell, an attack has a simple structure.
- Choose a target. Pick a target within your attack's range: a creature, an object, or a location.
Attacks targeting an object (including doors & walls) are well established, including the AC & HP of objects of varying material.
(Some magical structures are given damage ratings; one spell even gives its effect a standard stone AC & HP, while measuring wall area destroyed by the inch.)
Attacking objects (whether discrete objects or structures) seems pretty well covered, with multiple examples, & even things like Adamantine weapons that deal critical damage to objects on a hit.
Attacking creatures is of course the main focus of the game, so there's no shortage of examples for that.
However, even though the rules state that a location can be targeted by an attack... I haven't found any attack that would be relevant to a location!
The only Spell Attacks that aren't specifically limited to targeting creatures & objects, are Magic Stone, Flame Blade, Acid Arrow, Scorching Ray, & Mordenkainen's Sword, & based on their wording, none of those attack rolls appear to accomplish anything when targeting a location (unless a creature in a location could be hit by a spell attack targeting that location)...
Note that specific thrown items such as a Bomb, Dynamite stick, & other items with effects that target a location, use an Action, not an Attack roll; throwing a Bomb does not entail an Attack roll.
For whatever reason, throwing a Net at a location to hit a creature in that location, is disputed (see the mess I made of this question), although as @Jason_c_o has noted in their suggested answer below, the 5e OpenSRD mentions targeting a location in order to hit an unseen creature. (I guess whether that'a a good Answer is for voters to decide.)
I've been looking through magical items & weapons & features, & found absolutely nothing else that would target a location with an attack.
The only thing I could think of was using an item ≥10ft across to attack multiple creatures in an area, but it seems there's just no RAW to support that.
When an effect applies to creatures or objects within an area, that effect's description defines the terms of its location & extent, and specifies what creatures or objects within the area can be affected and how. There are so many area effects, but none of them involve an attack roll that would target a location!
What are some use cases for attack rolls that target a location?
IE: What is an example of a situation wherein there is mechanical reason to target a location with an attack roll, & what are its use cases?