summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2016-07-14 22:22:58 +0000
committerPaul Robinson <paul.robinson@sony.com>2016-07-14 22:22:58 +0000
commit4e0ff9c46b13bc89b00c1e8d3886c7bdd792d3a0 (patch)
tree24492d60be7c5f1f0c294d568a75fff96723c76a
parent31795c7576b4f329e82dfe97f6730fa40022b0c2 (diff)
downloadbcm5719-llvm-4e0ff9c46b13bc89b00c1e8d3886c7bdd792d3a0.tar.gz
bcm5719-llvm-4e0ff9c46b13bc89b00c1e8d3886c7bdd792d3a0.zip
C does not have inline variables.
Add a few missing tests for related C++ diagnostics. Differential Revision: http://reviews.llvm.org/D22113 llvm-svn: 275493
-rw-r--r--clang/lib/Sema/SemaDecl.cpp5
-rw-r--r--clang/test/Sema/inline.c2
-rw-r--r--clang/test/SemaCXX/inline.cpp13
3 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c0ccbbf6241..cedd21476c9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6178,7 +6178,10 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC,
}
if (D.getDeclSpec().isInlineSpecified()) {
- if (CurContext->isFunctionOrMethod()) {
+ if (!getLangOpts().CPlusPlus) {
+ Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_inline_non_function)
+ << 0;
+ } else if (CurContext->isFunctionOrMethod()) {
// 'inline' is not allowed on block scope variable declaration.
Diag(D.getDeclSpec().getInlineSpecLoc(),
diag::err_inline_declaration_block_scope) << Name
diff --git a/clang/test/Sema/inline.c b/clang/test/Sema/inline.c
index 33b25206d72..eced058f8dd 100644
--- a/clang/test/Sema/inline.c
+++ b/clang/test/Sema/inline.c
@@ -49,7 +49,7 @@ inline int useConst () {
#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}}
diff --git a/clang/test/SemaCXX/inline.cpp b/clang/test/SemaCXX/inline.cpp
index e569300faf7..b20bc18d0a3 100644
--- a/clang/test/SemaCXX/inline.cpp
+++ b/clang/test/SemaCXX/inline.cpp
@@ -1,5 +1,18 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s -Wc++98-c++11-c++14-compat
// Check that we don't allow illegal uses of inline
// (checking C++-only constructs here)
struct c {inline int a;}; // expected-error{{'inline' can only appear on functions}}
+
+void localVar() {
+ inline int a; // expected-error{{inline declaration of 'a' not allowed in block scope}}
+}
+
+// Check that we warn appropriately.
+#if __cplusplus <= 201402L
+inline int a; // expected-warning{{inline variables are a C++1z extension}}
+#else
+inline int a; // expected-warning{{inline variables are incompatible with C++ standards before C++1z}}
+#endif
OpenPOWER on IntegriCloud