[PATCH] Warn on duplicate function specifier

Richard Smith richard at metafoo.co.uk
Tue Nov 12 11:37:31 PST 2013


  LGTM with some minor changes.


================
Comment at: include/clang/Sema/DeclSpec.h:538-539
@@ -534,3 +537,4 @@
   // function-specifier
-  bool isInlineSpecified() const { return FS_inline_specified; }
-  SourceLocation getInlineSpecLoc() const { return FS_inlineLoc; }
+  bool isInlineSpecified() const { return FS_inline_specified |
+                                          FS_forceinline_specified; }
+  SourceLocation getInlineSpecLoc() const {
----------------
Please be consistent with the formatting elsewhere in Clang and LLVM: only put a function body on the same line as the function declaration if the whole function body fits on one line.

================
Comment at: lib/Sema/DeclSpec.cpp:742
@@ -741,4 +741,3 @@
                            unsigned &DiagID, const LangOptions &Lang) {
-  // Duplicates are permitted in C99, but are not permitted in C++. However,
-  // since this is likely not what the user intended, we will always warn.  We
-  // do not need to set the qualifier's location since we already have it.
+  // Duplicates are permitted in C99 and C11, but are not permitted in C89 or
+  // C++.  However, since this is likely not what the user intended, we will
----------------
"C99 onwards"

================
Comment at: lib/Sema/DeclSpec.cpp:748
@@ -746,3 +747,3 @@
     bool IsExtension = true;
-    if (Lang.C99)
+    if (Lang.C99 || Lang.C11)
       IsExtension = false;
----------------
This is unnecessary: C99 is always set when C11 is. Please revert this change.

================
Comment at: test/Parser/MicrosoftExtensions.c:34-36
@@ +33,5 @@
+
+// Both inline and __forceinline is OK.
+inline void __forceinline pr8264() {
+}
+// But duplicate __forceinline causes warning.
----------------
Also test the other way around here (`__forceinline inline`)?


http://llvm-reviews.chandlerc.com/D2025

BRANCH
  pr8264

ARCANIST PROJECT
  clang



More information about the cfe-commits mailing list