[PATCH] D51426: [Sema] Prohibit function-scope compound literals with address spaces.

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 30 01:15:39 PDT 2018


rjmccall added inline comments.


================
Comment at: lib/Sema/SemaExpr.cpp:5745
+    // C99 6.5.2.5p6: Function scope compound literals must have automatic
+    // storage which generally excludes address space-qualified ones.
+    Diag(LParenLoc, diag::err_compound_literal_with_address_space)
----------------
ebevhan wrote:
> rjmccall wrote:
> > Usually when we mention a standard section like this, it's a prelude to a quote.  If you're just paraphrasing, I think we can trust people to find the right standard section.
> Hm, alright. I figured it was better to both provide the exact section and also include a summary here so you don't have to look it up.
> 
> Should I change it or is it good anyway?
It's fine to include a reference to the standard.  The way you've done it here makes it look like a quote at first glance, which it isn't.  You should just say "See C99 6.5.2.5p6" if you think that's an important citation to make.

In this case, though, I don't think it's a particularly valuable citation.  Remember that this code is in the middle of a function dedicated to the rules of section 6.5.2.5, so unless you're actually quoting the text because there's some important subtlety, I think you can assume general familiarity (and/or that the reader has the standard open).  There *is* a better citation, though: the Embedded C spec explicitly says:

  If the compound literal occurs inside the body of a function, the type name shall not be qualified by an address-space qualifier.

I'd cite it with a title like "Embedded C modifications to C99 6.5.2.5".

By the way, LLVM code style leaves a space between `if` and the opening parenthesis of the condition.


Repository:
  rC Clang

https://reviews.llvm.org/D51426





More information about the cfe-commits mailing list