From: Nico Weber Date: Thu, 30 Aug 2012 02:08:31 +0000 (+0000) Subject: Reland r160052: Default to -std=c++11 on Windows. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=50f88b99c60c2ed31b339cd8bd484766cc9e916b;p=clang Reland r160052: Default to -std=c++11 on Windows. Also update the tests that rely on c++98 to explicitly mention that. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162890 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index c113406670..3c46e34ac7 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2141,8 +2141,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // eventually we want to do all the standard defaulting here instead of // splitting it between the driver and clang -cc1. if (!types::isCXX(InputType)) - Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, - "-std=", /*Joined=*/true); + Args.AddAllArgsTranslated(CmdArgs, options::OPT_std_default_EQ, + "-std=", /*Joined=*/true); + else if (getToolChain().getTriple().getOS() == llvm::Triple::Win32) + CmdArgs.push_back("-std=c++11"); + Args.AddLastArg(CmdArgs, options::OPT_trigraphs); } diff --git a/test/Index/complete-cxx-inline-methods.cpp b/test/Index/complete-cxx-inline-methods.cpp index d441972dd6..ee359f75e4 100644 --- a/test/Index/complete-cxx-inline-methods.cpp +++ b/test/Index/complete-cxx-inline-methods.cpp @@ -23,8 +23,8 @@ private: }; } -// RUN: c-index-test -code-completion-at=%s:4:9 %s | FileCheck %s -// RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck %s +// RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s +// RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s // CHECK: CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34) // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75) // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35) diff --git a/test/Index/recursive-cxx-member-calls.cpp b/test/Index/recursive-cxx-member-calls.cpp index 9b93872ee0..501dc2954f 100644 --- a/test/Index/recursive-cxx-member-calls.cpp +++ b/test/Index/recursive-cxx-member-calls.cpp @@ -1523,7 +1523,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK-tokens: Punctuation: ";" [185:31 - 185:32] CompoundStmt= // CHECK-tokens: Punctuation: "}" [186:1 - 186:2] CompoundStmt= -// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s +// RUN: c-index-test -test-load-source all %s -std=c++98 2>&1 | FileCheck %s // CHECK: 1:27: TypedefDecl=__darwin_size_t:1:27 (Definition) Extent=[1:1 - 1:42] // CHECK: 2:25: TypedefDecl=size_t:2:25 (Definition) Extent=[2:1 - 2:31] // CHECK: 2:9: TypeRef=__darwin_size_t:1:27 Extent=[2:9 - 2:24] diff --git a/test/SemaTemplate/inject-templated-friend-post.cpp b/test/SemaTemplate/inject-templated-friend-post.cpp index 39c445ca0f..c86f718bb5 100644 --- a/test/SemaTemplate/inject-templated-friend-post.cpp +++ b/test/SemaTemplate/inject-templated-friend-post.cpp @@ -1,7 +1,7 @@ -// RUN: %clang %s -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" -// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" -// RUN: %clang %s -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" -// RUN: %clang %s -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang %s -std=c++98 -S -emit-llvm -o - | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DPROTOTYPE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" +// RUN: %clang %s -std=c++98 -S -emit-llvm -o - -DPROTOTYPE -DINSTANTIATE | grep -e "define linkonce_odr.*_ZlsR11std_ostreamRK8StreamerI3FooE" // RUN: %clang_cc1 %s -DREDEFINE -verify // RUN: %clang_cc1 %s -DPROTOTYPE -DREDEFINE -verify // PR8007: friend function not instantiated, reordered version. diff --git a/unittests/AST/DeclPrinterTest.cpp b/unittests/AST/DeclPrinterTest.cpp index c99550af22..2800df4caf 100644 --- a/unittests/AST/DeclPrinterTest.cpp +++ b/unittests/AST/DeclPrinterTest.cpp @@ -73,6 +73,8 @@ bool runToolOnCode(clang::FrontendAction *ToolAction, const Twine &Code, std::vector ArgVector; ArgVector.push_back("clang-tool"); ArgVector.push_back("-fsyntax-only"); + // operator delete (void*) grows a "noexcept" in c++11. + ArgVector.push_back("-std=c++98"); ArgVector.push_back(FileNameRef.data()); for (unsigned i = 0, e = ClangArgs.size(); i != e; ++i) ArgVector.push_back(ClangArgs[i]); diff --git a/unittests/ASTMatchers/ASTMatchersTest.h b/unittests/ASTMatchers/ASTMatchersTest.h index 64816f5d60..6d872e8ea9 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.h +++ b/unittests/ASTMatchers/ASTMatchersTest.h @@ -18,7 +18,7 @@ namespace clang { namespace ast_matchers { using clang::tooling::newFrontendActionFactory; -using clang::tooling::runToolOnCode; +using clang::tooling::runToolOnCodeWithArgs; using clang::tooling::FrontendActionFactory; class BoundNodesCallback { @@ -56,7 +56,9 @@ testing::AssertionResult matchesConditionally(const std::string &Code, MatchFinder Finder; Finder.addMatcher(AMatcher, new VerifyMatch(0, &Found)); OwningPtr Factory(newFrontendActionFactory(&Finder)); - if (!runToolOnCode(Factory->create(), Code)) { + // Some tests use typeof, which is a gnu extension. + std::vector Args(1, "-std=gnu++98"); + if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) { return testing::AssertionFailure() << "Parsing error in \"" << Code << "\""; } if (!Found && ExpectMatch) { @@ -91,7 +93,9 @@ matchAndVerifyResultConditionally(const std::string &Code, const T &AMatcher, Finder.addMatcher( AMatcher, new VerifyMatch(FindResultVerifier, &VerifiedResult)); OwningPtr Factory(newFrontendActionFactory(&Finder)); - if (!runToolOnCode(Factory->create(), Code)) { + // Some tests use typeof, which is a gnu extension. + std::vector Args(1, "-std=gnu++98"); + if (!runToolOnCodeWithArgs(Factory->create(), Code, Args)) { return testing::AssertionFailure() << "Parsing error in \"" << Code << "\""; } if (!VerifiedResult && ExpectResult) {