diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-19 21:31:25 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-19 21:31:25 +0000 |
commit | c81ca09830a95e532206dfaeeb12c25315c6fb1a (patch) | |
tree | 2be966074a81ebbf4a9bc22bb059dec44e6f125f | |
parent | 777346e7490cf4bed6ba6567760c5760a716f102 (diff) | |
download | bcm5719-llvm-c81ca09830a95e532206dfaeeb12c25315c6fb1a.tar.gz bcm5719-llvm-c81ca09830a95e532206dfaeeb12c25315c6fb1a.zip |
Disable the "'extern' variable has an initializer" warning in C++,
since it makes sense there to have const extern variables. Fixes
PR6495.
llvm-svn: 101818
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 3 | ||||
-rw-r--r-- | clang/test/SemaCXX/storage-class.cpp | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 182a85aee80..045b3e8c381 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3818,7 +3818,8 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) { } } } else if (VDecl->isFileVarDecl()) { - if (VDecl->getStorageClass() == VarDecl::Extern) + if (VDecl->getStorageClass() == VarDecl::Extern && + !getLangOptions().CPlusPlus) Diag(VDecl->getLocation(), diag::warn_extern_init); if (!VDecl->isInvalidDecl()) { InitializationSequence InitSeq(*this, Entity, Kind, &Init, 1); diff --git a/clang/test/SemaCXX/storage-class.cpp b/clang/test/SemaCXX/storage-class.cpp new file mode 100644 index 00000000000..a31e67be7e4 --- /dev/null +++ b/clang/test/SemaCXX/storage-class.cpp @@ -0,0 +1,2 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +extern const int PR6495 = 42; |