summaryrefslogtreecommitdiff
path: root/cc/compiler.go
diff options
context:
space:
mode:
author Christopher Parsons <cparsons@google.com> 2021-11-30 15:50:31 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-11-30 15:50:31 +0000
commit93c3cb69bcd726c18f14f94b0831d4550dccdca7 (patch)
tree589c51608bb25f0615166708eac04b0d0ece5398 /cc/compiler.go
parent8a4981617f4e7bc480abe678d7f5b0548c76b5c9 (diff)
parent79bd2b7761198f38a5d50af1ad7eca972d688717 (diff)
Merge "bp2build implementation for c_std"
Diffstat (limited to 'cc/compiler.go')
-rw-r--r--cc/compiler.go27
1 files changed, 17 insertions, 10 deletions
diff --git a/cc/compiler.go b/cc/compiler.go
index ffe8b2e36..2e62b0002 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -304,11 +304,24 @@ func parseCppStd(cppStdPtr *string) string {
cppStd := String(cppStdPtr)
switch cppStd {
case "":
- cppStd = config.CppStdVersion
+ return config.CppStdVersion
case "experimental":
- cppStd = config.ExperimentalCppStdVersion
+ return config.ExperimentalCppStdVersion
+ default:
+ return cppStd
+ }
+}
+
+func parseCStd(cStdPtr *string) string {
+ cStd := String(cStdPtr)
+ switch cStd {
+ case "":
+ return config.CStdVersion
+ case "experimental":
+ return config.ExperimentalCStdVersion
+ default:
+ return cStd
}
- return cppStd
}
// Create a Flags struct that collects the compile flags from global values,
@@ -479,13 +492,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.Global.CommonFlags = append(flags.Global.CommonFlags, tc.ToolchainCflags())
- cStd := config.CStdVersion
- if String(compiler.Properties.C_std) == "experimental" {
- cStd = config.ExperimentalCStdVersion
- } else if String(compiler.Properties.C_std) != "" {
- cStd = String(compiler.Properties.C_std)
- }
-
+ cStd := parseCStd(compiler.Properties.C_std)
cppStd := parseCppStd(compiler.Properties.Cpp_std)
cStd, cppStd = maybeReplaceGnuToC(compiler.Properties.Gnu_extensions, cStd, cppStd)