fix Issue 6538 - ICE(mangle.c) Invalid template constraints
fix Issue 9361 - Nasty bug and/or error message for template constaints using this

Add test cases