The term used is canine cognitive dysfunction syndrome, or CDS.
A dog staring at the wall or a dog staring at nothing are symptoms of this disorder.
Dogs suffering from dementia may forget their house training.
The dog may want to go outdoors to relieve himself, but then seem to forget why he is there.