[PATCH] D22113: C does not have inline variables

Paul Robinson via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 7 14:33:16 PDT 2016


probinson created this revision.
probinson added a reviewer: rsmith.
probinson added a subscriber: cfe-commits.

We have a C test that now gets a warning about a C++1z extension, which seems inappropriate.


http://reviews.llvm.org/D22113

Files:
  lib/Sema/SemaDecl.cpp
  test/Sema/inline.c

Index: test/Sema/inline.c
===================================================================
--- test/Sema/inline.c
+++ test/Sema/inline.c
@@ -49,7 +49,7 @@
 #include "inline.c"
 
 // Check that we don't allow illegal uses of inline
-inline int a; // expected-warning{{inline variables are a C++1z extension}}
+inline int a; // expected-error{{'inline' can only appear on functions}}
 typedef inline int b; // expected-error{{'inline' can only appear on functions}}
 int d(inline int a); // expected-error{{'inline' can only appear on functions}}
 
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6186,6 +6186,9 @@
       Diag(D.getDeclSpec().getInlineSpecLoc(),
            diag::err_inline_declaration_block_scope) << Name
         << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
+    } else if (!getLangOpts().CPlusPlus) {
+      Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+          << 0;
     } else {
       Diag(D.getDeclSpec().getInlineSpecLoc(),
            getLangOpts().CPlusPlus1z ? diag::warn_cxx14_compat_inline_variable


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22113.63137.patch
Type: text/x-patch
Size: 1187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160707/08c01b6e/attachment.bin>


More information about the cfe-commits mailing list