[cfe-commits] r64568 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.def lib/Sema/SemaType.cpp test/Sema/implicit-builtin-freestanding.c test/Sema/warn-freestanding-complex.c

Douglas Gregor dgregor at apple.com
Sat Feb 14 13:06:05 PST 2009


Author: dgregor
Date: Sat Feb 14 15:06:05 2009
New Revision: 64568

URL: http://llvm.org/viewvc/llvm-project?rev=64568&view=rev
Log:
Add a test case for -ffreestanding that redefines malloc.

Warn that complex numbers are an extension in a freestanding C99
implementation.

Added:
    cfe/trunk/test/Sema/implicit-builtin-freestanding.c
    cfe/trunk/test/Sema/warn-freestanding-complex.c
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
    cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def?rev=64568&r1=64567&r2=64568&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def Sat Feb 14 15:06:05 2009
@@ -876,6 +876,9 @@
 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,

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=64568&r1=64567&r2=64568&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Sat Feb 14 15:06:05 2009
@@ -170,8 +170,11 @@
   }
   
   // 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!");

Added: cfe/trunk/test/Sema/implicit-builtin-freestanding.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/implicit-builtin-freestanding.c?rev=64568&view=auto

==============================================================================
--- cfe/trunk/test/Sema/implicit-builtin-freestanding.c (added)
+++ cfe/trunk/test/Sema/implicit-builtin-freestanding.c Sat Feb 14 15:06:05 2009
@@ -0,0 +1,4 @@
+// RUN: clang -fsyntax-only -verify -ffreestanding %s
+
+int malloc(int a) { return a; }
+

Added: cfe/trunk/test/Sema/warn-freestanding-complex.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-freestanding-complex.c?rev=64568&view=auto

==============================================================================
--- cfe/trunk/test/Sema/warn-freestanding-complex.c (added)
+++ cfe/trunk/test/Sema/warn-freestanding-complex.c Sat Feb 14 15:06:05 2009
@@ -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}}
+}





More information about the cfe-commits mailing list