[PATCH] Warn on duplicate function specifier
Reid Kleckner
rnk at google.com
Fri Oct 25 13:36:15 PDT 2013
================
Comment at: lib/Parse/ParseDecl.cpp:2770
@@ -2769,3 +2769,3 @@
case tok::kw___forceinline: {
- isInvalid = DS.setFunctionSpecInline(Loc);
+ isInvalid = DS.setFunctionSpecInline(Loc, PrevSpec, DiagID);
IdentifierInfo *AttrName = Tok.getIdentifierInfo();
----------------
Richard Smith wrote:
> Do we really want a diagnostic for combining `inline` with `__forceinline`? That combination doesn't seem unreasonable to me.
MSVC does something unreasonable like this:
void __forceinline inline foo() {} // expected-warning {{C4141: 'inline' : used more than once}}
void inline __forceinline bar() {} // nothing
Clang **requires** users to apply inline in conjunction with always_inline, which leads users to write code like this to make all compilers happy:
#ifdef _MSC_VER
# define PORT_ALWAS_INLINE __forceline
#else
# define PORT_ALWAYS_INLINE __attribute__((always_inline))
#endif
void inline PORT_ALWAYS_INLINE foo() {}
We *definitely* shouldn't warn on that regardless of the ifdef taken.
http://llvm-reviews.chandlerc.com/D2025
More information about the cfe-commits
mailing list