-
Notifications
You must be signed in to change notification settings - Fork 79
Only allow the Checked C extension flag for C. #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Checked C extension is not supported for C++. Make sure driver | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably low priority, but we could also add a test case for a .c file that is forced to be compiled as C++ using command-line options. That's a pattern I've certainly seen before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added test cases forcing files to be compiled as different file types than the file extension specifies, with the Checked C extension flag enabled:
|
||
// 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() {} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<int> p) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this end up being fatal? Or just a warning? Or will it just not enable the Checked C Extensions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ends up being fatal.