If I remember correctly, clang's strategy for handling language linkage in
C is to pretend that C has language linkage and say that everything has C
language linkage.

If that is the case, the attached patch is probably the correct fix.

Cheers,
Rafael
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index bd0e503..bdca18a 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1853,8 +1853,10 @@ static bool isDeclExternC(const T &D) {
   // language linkage or no language linkage.
   const DeclContext *DC = D.getDeclContext();
   if (DC->isRecord()) {
-    assert(D.getASTContext().getLangOpts().CPlusPlus);
-    return false;
+    if (D.getASTContext().getLangOpts().CPlusPlus)
+      return false;
+    else
+      return true;
   }
 
   return D.getLanguageLinkage() == CLanguageLinkage;
diff --git a/test/Sema/pr22849.c b/test/Sema/pr22849.c
new file mode 100644
index 0000000..179bbfe
--- /dev/null
+++ b/test/Sema/pr22849.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only  %s
+
+// We used to crash on this.
+
+void f() {
+  union {
+    typeof
+           (
+             (
+               {
+                 unsigned long __ptr;
+                 (int *)(0);
+               }
+             )
+           )
+    __val;
+  };
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to