[cfe-commits] r40789 - in /cfe/trunk: clang.xcodeproj/project.pbxproj test/Parser/builtin_types_compatible.c

Steve Naroff snaroff at apple.com
Fri Aug 3 11:38:22 PDT 2007


Author: snaroff
Date: Fri Aug  3 13:38:22 2007
New Revision: 40789

URL: http://llvm.org/viewvc/llvm-project?rev=40789&view=rev
Log:

Add a test case to validate code gen for typeof/builtin_types_compatible.

This test case currently generates the following unexpected warnings (when compared with gcc).

[dylan:clang/test/Parser] admin% ../../../../Debug/bin/clang -parse-ast-check builtin_types_compatible.c
Warnings seen but not expected:
  Line 28: expression result unused
  Line 29: expression result unused
  Line 30: expression result unused
  Line 31: expression result unused
  Line 32: expression result unused
  Line 33: expression result unused


Added:
    cfe/trunk/test/Parser/builtin_types_compatible.c
Modified:
    cfe/trunk/clang.xcodeproj/project.pbxproj

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=40789&r1=40788&r2=40789&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Fri Aug  3 13:38:22 2007
@@ -196,7 +196,7 @@
 		1A869AA70BA21ABA008DA07A /* LiteralSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LiteralSupport.cpp; sourceTree = "<group>"; };
 		84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeList.cpp; path = Parse/AttributeList.cpp; sourceTree = "<group>"; };
 		84D9A88B0C1A581300AC7ABC /* AttributeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AttributeList.h; path = clang/Parse/AttributeList.h; sourceTree = "<group>"; };
-		8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
+		8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
 		DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = "<group>"; };
 		DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = Parse/ParseExprCXX.cpp; sourceTree = "<group>"; };
 		DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };

Added: cfe/trunk/test/Parser/builtin_types_compatible.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/builtin_types_compatible.c?rev=40789&view=auto

==============================================================================
--- cfe/trunk/test/Parser/builtin_types_compatible.c (added)
+++ cfe/trunk/test/Parser/builtin_types_compatible.c Fri Aug  3 13:38:22 2007
@@ -0,0 +1,35 @@
+// RUN: clang -parse-ast-check
+
+extern void funcInt(int);
+extern void funcFloat(float);
+extern void funcDouble(double);
+// figure out why "char *" doesn't work (with gcc, nothing to do with clang)
+//extern void funcCharPtr(char *);
+
+#define func(expr) \
+  ({ \
+    typeof(expr) tmp; \
+    if (__builtin_types_compatible_p(typeof(expr), int)) funcInt(tmp); \
+    else if (__builtin_types_compatible_p(typeof(expr), float)) funcFloat(tmp); \
+    else if (__builtin_types_compatible_p(typeof(expr), double)) funcDouble(tmp); \
+  })
+#define func_choose(expr) \
+  __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), int), funcInt(expr), \
+    __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), float), funcFloat(expr), \
+      __builtin_choose_expr(__builtin_types_compatible_p(typeof(expr), double), funcDouble(expr), \
+  (void)0)))
+
+static void test()
+{
+  int a;
+  float b;
+  double d;
+
+  func(a);
+  func(b);
+  func(d);
+  func_choose(a);
+  func_choose(b);
+  func_choose(d);
+}
+





More information about the cfe-commits mailing list