My logical programmer brain made me write "had had made" in a sentence like
John talked about a spare key that he had had made and which turned out not to work when he actually needed it.
My language sense lodged a protest but could not pinpoint any actual fault, apart from suggesting the use of more human-digestible constructs like "a spare key that he had arranged to be made".
And so my logical programmer brain - which is hung up on precision and formal semantics by way of occupational hazard - still needs to know if the "had had made" construct is grammatically correct. Can you help?
Note: the crux is that "a spare key that he had made" (only one "had") would imply that John made the key himself, instead of having someone else make it.