aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/clang_flags_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'compiler_wrapper/clang_flags_test.go')
-rw-r--r--compiler_wrapper/clang_flags_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/compiler_wrapper/clang_flags_test.go b/compiler_wrapper/clang_flags_test.go
index 08e8a8dc..8b3f5a24 100644
--- a/compiler_wrapper/clang_flags_test.go
+++ b/compiler_wrapper/clang_flags_test.go
@@ -33,6 +33,36 @@ func TestClangBasename(t *testing.T) {
})
}
+func TestAppendCppFlags(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ ctx.cfg.cppFlags = append(ctx.cfg.cppFlags, "cppOnlyFlag")
+ // C++ only flags are disabled on clang.
+ clangCmd := ctx.must(callCompiler(ctx, ctx.cfg,
+ ctx.newCommand("./x86_64-cros-linux-gnu-clang", mainCc)))
+ if err := verifyArgCount(clangCmd, 0, "cppOnlyFlag"); err != nil {
+ t.Error(err)
+ }
+ // C++ only flags are enabled on clang++.
+ clangPlusPlusCmd := ctx.must(callCompiler(ctx, ctx.cfg,
+ ctx.newCommand("./x86_64-cros-linux-gnu-clang++", mainCc)))
+ if err := verifyArgCount(clangPlusPlusCmd, 1, "cppOnlyFlag"); err != nil {
+ t.Error(err)
+ }
+ // C++ only flags are disabled with -x.
+ clangPlusPlusWithXCmd := ctx.must(callCompiler(ctx, ctx.cfg,
+ ctx.newCommand("./x86_64-cros-linux-gnu-clang++", "-x", "c", mainCc)))
+ if err := verifyArgCount(clangPlusPlusWithXCmd, 0, "cppOnlyFlag"); err != nil {
+ t.Error(err)
+ }
+ // C++ only flags are disabled with " - " .
+ clangPlusPlusWithStdin := ctx.must(callCompiler(ctx, ctx.cfg,
+ ctx.newCommand("./x86_64-cros-linux-gnu-clang++", "-", mainCc)))
+ if err := verifyArgCount(clangPlusPlusWithStdin, 0, "cppOnlyFlag"); err != nil {
+ t.Error(err)
+ }
+ })
+}
+
func TestClangPathGivenClangEnv(t *testing.T) {
withTestContext(t, func(ctx *testContext) {
ctx.env = []string{"CLANG=/a/b/clang"}
@@ -310,3 +340,18 @@ func TestClangLinkerPathRelativeToRootDir(t *testing.T) {
}
})
}
+
+func TestFilterUnsupportedFlags(t *testing.T) {
+ withTestContext(t, func(ctx *testContext) {
+ cmd := ctx.must(callCompiler(ctx, ctx.cfg,
+ ctx.newCommand(clangX86_64, "-Xcompiler", mainCc)))
+ if err := verifyArgCount(cmd, 0, "-Xcompiler"); err != nil {
+ t.Error(err)
+ }
+ cmd = ctx.must(callCompiler(ctx, ctx.cfg,
+ ctx.newCommand(clangX86_64, "-avoid-version", mainCc)))
+ if err := verifyArgCount(cmd, 0, "-avoid-version"); err != nil {
+ t.Error(err)
+ }
+ })
+}