diff --git a/docs/checkedc/Test-Baselines.md b/docs/checkedc/Test-Baselines.md index 2816b1569823..88e3e4a4cda4 100644 --- a/docs/checkedc/Test-Baselines.md +++ b/docs/checkedc/Test-Baselines.md @@ -1,6 +1,6 @@ # Test base lines -## Current baseline +## Testing baseline for the base line branch Here is the current baseline for testing just clang with the x86 target (using the check-clang project) @@ -52,7 +52,14 @@ Here is the current base line for testing LLVM + clang on all targets (check-all Unexpected Failures: 6 ``` +## Differences in test results between branches + +The master branch in the checkedc-clang repo has additional tests for +Checked C. It is expected that the master branch will have more +`Expected Passes` than the baseline branch. + ## In-progress baseline updates -This section records the test results for an in-progress update to latest sources in the baseline branch. It is currently empty because -no update is in-progress. +This section records the test results for an in-progress update to latest +sources in the baseline branch. It is currently empty because no update +is in-progress. diff --git a/docs/checkedc/Testing.md b/docs/checkedc/Testing.md index 47d110431892..afafa0b4a8f7 100644 --- a/docs/checkedc/Testing.md +++ b/docs/checkedc/Testing.md @@ -5,7 +5,9 @@ target to the build system for running the test suite: check-checkedc. The Checked C version of clang/LLVM should pass the same tests as the baseline version of clang/LLVM (in the baseline branch) and the Checked C specific tests. The testing -results for the baseline branch are recorded in [testing baselines](Test-Baselines.md) +results for the baseline branch are recorded in [testing baselines](Test-Baselines.md). +A developer should confirm that no new unexpected failures occur as a result of a change +before committing a change. When testing a change, the testing should be sufficient for the type of change. For changes to parsing and typechecking, it is usually sufficient to pass the Checked C and clang tests. @@ -49,8 +51,9 @@ The clang-specific documentation on running tests appears to be out-of-date, so llvm-lit d:\autobahn1\llvm\tools\clang\test ## Test baselines -We have observed a few tests fail on Windows on a clean LLVM/clang enlistment that don't seem to fail on the buildbots. -We have not tracked down the source of the failures. For now, we are using [testing baselines](Test-Baselines.md) to exclude these -tests. LLVM/clang have an optimistic check-in policy, so it is possible that a few tests may fail in the -main-line repos when we update to the latest sources. - +We have observed a few tests fail unexpectedly on Windows on a clean LLVM/clang +enlistment. These tests don't seem to fail on the buildbots. We have not +tracked down the source of the failures. For now, we are using +[testing baselines](Test-Baselines.md) to exclude these tests. LLVM/clang has +an optimistic check-in policy, so it is possible that a few tests may fail in +the main-line repos when we update to the latest sources. diff --git a/docs/checkedc/Update-to-latest-LLVM-sources.md b/docs/checkedc/Update-to-latest-LLVM-sources.md index 08e1ad6c0c2c..66304852de55 100644 --- a/docs/checkedc/Update-to-latest-LLVM-sources.md +++ b/docs/checkedc/Update-to-latest-LLVM-sources.md @@ -44,12 +44,12 @@ Then do ## Update the baseline branch on Github -You will then need to build and run tests to establish test baselines. Assuming that the tests results are good, you can push them to your personal -Github forks: +You will then need to build and run tests to establish test baselines. Assuming that the tests results are good, +you can push them to your personal Github forks: git push origin baseline -You can then issue a pull request to pull the changes into the mainline change. +You can then issue pull requests to pull the changes into the Microsift Github repos. ## Update the master branch. @@ -58,6 +58,12 @@ After you have updated the baseline branch, you can update the master branch. Ch git checkout master git merge baseline -Then set up the build system and compile. Fix any issues that you encounter. Then run tests. Once you are passing the same -testing as the baseline branch, push this up to personal Github fork and issue a pull request. +Set up the build system and compile. Fix any issues that you encounter. +Then run tests. We have added tests for Checked C to the clang master branch, so these additional tests need to be taken +into account during testing. Make sure the code passes the following tests: + +- The same tests as the baseline branch, _plus_ the Checked C specific tests for clang in the master branch. +- The Checked C languages tests for the Checked C project. + +Once the tests are passing, push the changes up to a personal Github fork and issue a pull request. diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 779bbc34a289..a46533ea8ccc 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1701,7 +1701,28 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.PascalStrings = Args.hasArg(OPT_fpascal_strings); Opts.VtorDispMode = getLastArgIntValue(Args, OPT_vtordisp_mode_EQ, 1, Diags); Opts.Borland = Args.hasArg(OPT_fborland_extensions); - Opts.CheckedC = Args.hasArg(OPT_fcheckedc_extension); + if (Args.hasArg(OPT_fcheckedc_extension)) { + std::string disallowed; + if (Opts.CUDA) + disallowed = "CUDA"; + else if (Opts.OpenCL) + disallowed = "OpenCL"; + else if (Opts.ObjC1 || Opts.ObjC2) { + if (Opts.CPlusPlus) + disallowed = "Objective C/C++"; + else + disallowed = "Objective C"; + } + else if (Opts.CPlusPlus) { + disallowed = "C++"; + } + + if (disallowed.size() > 0) { + Diags.Report(diag::err_drv_argument_not_allowed_with) << + "-fcheckedc-extension" << disallowed; + } else + Opts.CheckedC = true; + } Opts.WritableStrings = Args.hasArg(OPT_fwritable_strings); Opts.ConstStrings = Args.hasFlag(OPT_fconst_strings, OPT_fno_const_strings, Opts.ConstStrings); diff --git a/test/Driver/checkedc-notsupported.cl b/test/Driver/checkedc-notsupported.cl new file mode 100644 index 000000000000..964589285fb0 --- /dev/null +++ b/test/Driver/checkedc-notsupported.cl @@ -0,0 +1,14 @@ +// Checked C extension is not supported for OpenCL. Make sure driver +// rejects the flag. +// +// RUN: not %clang -fcheckedc-extension %s 2>&1 | FileCheck %s +// CHECK: error: invalid argument '-fcheckedc-extension' not allowed with 'OpenCL' +// +// Have clang compile this file as a C file. +// RUN: %clang -c -fcheckedc-extension -x c %s +// +// Have clang-cl compile this file as a C file. +// RUN: %clang_cl -c -Xclang -fcheckedc-extension /TC %s + +extern void f() {} + diff --git a/test/Driver/checkedc-notsupported.cpp b/test/Driver/checkedc-notsupported.cpp new file mode 100644 index 000000000000..16af4b5f31b2 --- /dev/null +++ b/test/Driver/checkedc-notsupported.cpp @@ -0,0 +1,15 @@ +// Checked C extension is not supported for C++. Make sure driver +// rejects the flag. +// +// RUN: not %clang -fcheckedc-extension %s 2>&1 | FileCheck %s +// CHECK: error: invalid argument '-fcheckedc-extension' not allowed with 'C++' +// +// Have clang compile this file as a C file. +// RUN: %clang -c -fcheckedc-extension -x c %s +// +// Have clang-cl compile this file as a C file. +// RUN: %clang_cl -c -Xclang -fcheckedc-extension /TC %s + +extern void f() {} + + diff --git a/test/Driver/checkedc-notsupported.cu b/test/Driver/checkedc-notsupported.cu new file mode 100644 index 000000000000..7a73f0872fe9 --- /dev/null +++ b/test/Driver/checkedc-notsupported.cu @@ -0,0 +1,15 @@ +// Checked C extension is not supported for CUDA. Make sure driver +// rejects the flag. +// +// RUN: not %clang -fcheckedc-extension %s 2>&1 | FileCheck %s +// CHECK: error: invalid argument '-fcheckedc-extension' not allowed with 'CUDA' +// +// Have clang compile this file as a C file. +// RUN: %clang -c -fcheckedc-extension -x c %s +// +// Have clang-cl compile this file as a C file. +// RUN: %clang_cl -c -Xclang -fcheckedc-extension /TC %s + +extern void f() {} + + diff --git a/test/Driver/checkedc-notsupported.m b/test/Driver/checkedc-notsupported.m new file mode 100644 index 000000000000..85e3ce03a4a1 --- /dev/null +++ b/test/Driver/checkedc-notsupported.m @@ -0,0 +1,15 @@ +// Checked C extension is not supported for Objective C. Make sure driver +// rejects the flag. +// +// RUN: not %clang -fcheckedc-extension %s 2>&1 | FileCheck %s +// CHECK: error: invalid argument '-fcheckedc-extension' not allowed with 'Objective C' +// +// Have clang compile this file as a C file. +// RUN: %clang -c -fcheckedc-extension -x c %s +// +// Have clang-cl compile this file as a C file. +// RUN: %clang_cl -c -Xclang -fcheckedc-extension /TC %s + +extern void f() {} + + diff --git a/test/Driver/checkedc-supported.c b/test/Driver/checkedc-supported.c new file mode 100644 index 000000000000..ea7a69b1713a --- /dev/null +++ b/test/Driver/checkedc-supported.c @@ -0,0 +1,35 @@ +// Checked C extension is supported for C. Make sure driver +// accepts the flag for C and rejects it when the file is +// compiled as another language. +// +// RUN: %clang -c -fcheckedc-extension %s +// RUN: %clang_cl -c -Xclang -fcheckedc-extension %s +// +// Have clang compile this file as C++ file. +// RUN: not %clang -c -fcheckedc-extension -x c++ %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=check-cpp +// check-cpp: error: invalid argument '-fcheckedc-extension' not allowed with 'C++' +// +// Have clang-cl compile this file as a C++ file. +// RUN: not %clang_cl -c -Xclang -fcheckedc-extension /TP %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=clcheck-cpp +// clcheck-cpp: error: invalid argument '-fcheckedc-extension' not allowed with 'C++' +// +// RUN: not %clang -c -fcheckedc-extension -x cuda %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=check-cuda +// check-cuda: error: invalid argument '-fcheckedc-extension' not allowed with 'CUDA' +// +// RUN: not %clang -c -fcheckedc-extension -x cl %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=check-opencl +// check-opencl: error: invalid argument '-fcheckedc-extension' not allowed with 'OpenCL' +// +// RUN: not %clang -c -fcheckedc-extension -x objective-c %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=check-objc +// check-objc: error: invalid argument '-fcheckedc-extension' not allowed with 'Objective C' +// +// RUN: not %clang -c -fcheckedc-extension -x objective-c++ %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=check-objcpp +// check-objcpp: error: invalid argument '-fcheckedc-extension' not allowed with 'Objective C/C++' + + +extern void f(ptr p) {}