diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-14 21:06:05 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-14 21:06:05 +0000 |
commit | f244cd7e54753caf6edb76df430dea2f43bb82a8 (patch) | |
tree | 324ff9e2d2c9d79dfac6ec8d20b7d39595ecaa80 | |
parent | 3573c0c0b44a1ac8f76a00af1bc75e94ca03d704 (diff) |
Add a test case for -ffreestanding that redefines malloc.
Warn that complex numbers are an extension in a freestanding C99
implementation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64568 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.def | 3 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 5 | ||||
-rw-r--r-- | test/Sema/implicit-builtin-freestanding.c | 4 | ||||
-rw-r--r-- | test/Sema/warn-freestanding-complex.c | 4 |
4 files changed, 15 insertions, 1 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.def b/include/clang/Basic/DiagnosticSemaKinds.def index 95d7001ed9..570b711e07 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.def +++ b/include/clang/Basic/DiagnosticSemaKinds.def @@ -876,6 +876,9 @@ DIAG(ext_integer_complement_complex, EXTENSION, DIAG(error_nosetter_property_assignment, ERROR, "setter method is needed to assign to object using property" " assignment syntax") +DIAG(ext_freestanding_complex, EXTENSION, + "complex numbers are an extension in a freestanding C99 implementation") + // Obj-c expressions DIAG(warn_class_method_not_found, WARNING, diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index e898782f31..00bfb13561 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -170,8 +170,11 @@ QualType Sema::ConvertDeclSpecToType(const DeclSpec &DS) { } // Handle complex types. - if (DS.getTypeSpecComplex() == DeclSpec::TSC_complex) + if (DS.getTypeSpecComplex() == DeclSpec::TSC_complex) { + if (getLangOptions().Freestanding) + Diag(DS.getTypeSpecComplexLoc(), diag::ext_freestanding_complex); Result = Context.getComplexType(Result); + } assert(DS.getTypeSpecComplex() != DeclSpec::TSC_imaginary && "FIXME: imaginary types not supported yet!"); diff --git a/test/Sema/implicit-builtin-freestanding.c b/test/Sema/implicit-builtin-freestanding.c new file mode 100644 index 0000000000..f36aa09b5f --- /dev/null +++ b/test/Sema/implicit-builtin-freestanding.c @@ -0,0 +1,4 @@ +// RUN: clang -fsyntax-only -verify -ffreestanding %s + +int malloc(int a) { return a; } + diff --git a/test/Sema/warn-freestanding-complex.c b/test/Sema/warn-freestanding-complex.c new file mode 100644 index 0000000000..aa59b955c9 --- /dev/null +++ b/test/Sema/warn-freestanding-complex.c @@ -0,0 +1,4 @@ +// RUN: clang -fsyntax-only -ffreestanding -pedantic -verify %s + +void foo(float _Complex c) { // expected-warning{{complex numbers are an extension in a freestanding C99 implementation}} +} |