Regardless of the issue, a teacher should not be dealing with the student on this, because it's such a subjective thing. This is something for the principal or assistant principal to do. The teacher does not have authority.
That being said, so what if your daughter is gorgeous (and she is!)? She is not to blame for horny teenage boys staring at her. She could be in head to toe sweats and they'd be staring at her. And I completely agree with you that interrupting her test to ask her to stay after was completely inappropriate. No doubt it threw off her concentration and affected her grade. What kid can keep calm after being told they've done something wrong while they were just sitting there, working?
Sounds like a meeting with the principal and the teacher might be in order, if at the very least to get the principal to spell out very clearly what is and isn't acceptable in the dress code.
I have a bunch of thoughts about this.
1) Have you talked to R explicitly about the bad social narrative the teachers are falling into and trying to teach her? Sometimes you cannot help the irrational bullshit other adults inflict upon your children, but you can subvert them by explaining why they are acting the way they are, why that's bullshit, and why it's a choice to go along with it in service of a greater good (or that sometimes it's not worth going along with it).
2) I suspect teachers and administrators are not going to necessarily understand why they are being assholes in this instance. Note: it's not just girls in clothing that is too "revealing." They also take issue with kids who dye their hair exotic colors, have lots of piercings, belong to other religions that demand specific clothes, wear curlers in their hair. Anything "abnormal" is supposedly "distracting." I think it would be vastly more productive to get away from the notion that there is a "normal" and "acceptable" so that kids would be immune to this stuff, but I'm not making public school rules. They also inflict these rules on teachers, by the way. I just wrote a recommendation for a student teacher and one of the categories they ask me to comment on is "appearance." Super.
3) To that end, you'll probably gain more traction arguing about the consistency of the rules and asking that if teachers feel there is an issue they do it in a way that doesn't single out, shame, or embarrass girls.
4) I'm sure this was just rhetorical question asked out of frustration, but the rules are set up the way they are because we live in a patriarchy and we like to argue that a girl is "asking for it" if she wears a short skirt (as if women are never harassed, attacked, or raped in countries where they were full length outfits and veils). Public schools are an institution. They uphold dominant values.
5) My general approach is that I can't change their behavior immediately, I can just change my reaction to it and frame the issue and what the subtext is for my child.
6) All this said, it might be that my thoughts and advice aren't what's needed but instead a hearty THAT FUCKING SUCKS. Which I offer you. As that's complete bullshit.
My school had a hard-core dress code, but it wasn't very subjective. Teachers enforced it, but there wasn't much room for picking on kids. Skirts no shorter than 1 inch above the knee, no shorts, ever. No t-shirts, except for school shirts on the day of sport event. No sweats or athletic wear and nothing sleeveless, period.
ETA - I think when dress codes are vague and inconsistent, it makes it too easy for teachers and admins to say these crazy-ass things, because there seems to be no other reason why kids can't wear item X. A well-written dress code might fix that.
Telling her that she's "distracting the boys" is just out of bounds. If she's got something on that's out of dress code, that's not a huge deal, and a gentle reminder will do. But the dress code needs to be clear and enforcement needs to not be a girl's introduction to slut-shaming. I'd meet with the principal and get this ironed out.
Depends on how many enemies you feel like making and how much you want to fight this particular battle, because it absolutely *is* 100% subjective. I would, politely, let the teachers know that so long as she is within the letter of the dress code, then it isn't their business how she dresses and if the boys can't control themselves, then that is their problem. And I would repeat that to the teachers, principal, other parents, whoever, over and over again. And until that dress code is enforced 100% across the board, then they need to lay off your kid who isn't behaving disruptively or inappropriately. But honestly, I don't know that there isn't very much you *can* do other than support your kid and document every single instance of harassment by teachers and administrators at the school, because that shit is absolutely harassment, so that if it does come to it, you have records that your kid is being singled out.
But I feel for her. I was built that way as a teenager too--skinny, really tall (with most of my height in the legs), small chested, and a tiny waist. It didn't matter what I wore, it was always way shorter on me than on the other girls. Always. Every skirt/dress was a mini and every pair of shorts were short shorts. And I got to hear about it all the time, because it was "distracting for the boys" and "inappropriate for school," even if I was wearing exactly the same outfit as half the other girls in school. And it doesn't end just because I'm now a bit chubby and an adult. When A was a baby, I was doing a long term sub job at the fancy high school in town and I got reprimanded by the principal because my boobs were distracting to the boys in my class. I was breastfeeding and they were huge and, while I was always pretty careful about cleavage and such, I did wear tight-ish sweaters and button down tops with camisoles underneath. I asked her flat out if she thought I should just leave the boobs at home and come to work without them, because of course I'd be willing to do that. Or if maybe I should continue on and act professionally, and let the boys learn to deal with their hormones like the almost grown-ups they were. She shut up, but, needless to say (because of that and some other personality conflicts), I did not have my contract renewed at that school.
Are bandanas "gang signs?"
Well, the say the number one thing that "bully proofs" children/teens is support and love from family/friends so I think that's the number one most awesome thing to do.
Also a chance to bust out that "Mean Girls' quote: "Boo you whore!" :)
I think it's great you're backing her up. And those teachers...WTF?