[cfe-commits] r104789 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/Basic/Targets.cpp lib/Sema/SemaAttr.cpp test/Parser/pragma-options.c test/Sema/pragma-align-mac68k-unsupported.c
Daniel Dunbar
daniel at zuster.org
Wed May 26 17:35:16 PDT 2010
Author: ddunbar
Date: Wed May 26 19:35:16 2010
New Revision: 104789
URL: http://llvm.org/viewvc/llvm-project?rev=104789&view=rev
Log:
Sema: Reject '#pragma options align=mac68k' everywhere except i386-apple-darwin.
Added:
cfe/trunk/test/Sema/pragma-align-mac68k-unsupported.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp
cfe/trunk/test/Parser/pragma-options.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=104789&r1=104788&r2=104789&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed May 26 19:35:16 2010
@@ -240,6 +240,8 @@
"unsupported alignment option in '#pragma options align'">;
def warn_pragma_options_align_reset_failed : Warning<
"#pragma options align=reset failed: %0">;
+def err_pragma_options_align_mac68k_target_unsupported : Error<
+ "mac68k alignment pragma is not supported on this target">;
def warn_pragma_pack_invalid_alignment : Warning<
"expected #pragma pack parameter to be '1', '2', '4', '8', or '16'">;
// Follow the MSVC implementation.
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=104789&r1=104788&r2=104789&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed May 26 19:35:16 2010
@@ -58,6 +58,8 @@
const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
unsigned char RegParmMax, SSERegParmMax;
+ unsigned HasAlignMac68kSupport : 1;
+
// TargetInfo Constructor. Default initializes all fields.
TargetInfo(const std::string &T);
@@ -210,6 +212,12 @@
return UseBitFieldTypeAlignment;
}
+ /// hasAlignMac68kSupport - Check whether this target support '#pragma options
+ /// align=mac68k'.
+ bool hasAlignMac68kSupport() const {
+ return HasAlignMac68kSupport;
+ }
+
/// getTypeName - Return the user string for the specified integer type enum.
/// For example, SignedShort -> "short".
static const char *getTypeName(IntType T);
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=104789&r1=104788&r2=104789&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Wed May 26 19:35:16 2010
@@ -52,6 +52,7 @@
DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
"i64:64:64-f32:32:32-f64:64:64-n32";
UserLabelPrefix = "_";
+ HasAlignMac68kSupport = false;
}
// Out of line virtual dtor for TargetInfo.
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=104789&r1=104788&r2=104789&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed May 26 19:35:16 2010
@@ -1138,6 +1138,7 @@
DescriptionString = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
"i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-"
"a0:0:64-f80:128:128-n8:16:32";
+ HasAlignMac68kSupport = true;
}
};
Modified: cfe/trunk/lib/Sema/SemaAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaAttr.cpp?rev=104789&r1=104788&r2=104789&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaAttr.cpp Wed May 26 19:35:16 2010
@@ -15,6 +15,8 @@
#include "Sema.h"
#include "Lookup.h"
#include "clang/AST/Expr.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Lex/Preprocessor.h"
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -122,6 +124,18 @@
Context->setAlignment(0);
break;
+ case POAK_Mac68k:
+ // Check if the target supports this.
+ if (!PP.getTargetInfo().hasAlignMac68kSupport()) {
+ Diag(PragmaLoc, diag::err_pragma_options_align_mac68k_target_unsupported);
+ return;
+ } else {
+ // Otherwise, just warn about it for now.
+ Diag(PragmaLoc, diag::warn_pragma_options_align_unsupported_option)
+ << KindLoc;
+ }
+ break;
+
default:
Diag(PragmaLoc, diag::warn_pragma_options_align_unsupported_option)
<< KindLoc;
Modified: cfe/trunk/test/Parser/pragma-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/pragma-options.c?rev=104789&r1=104788&r2=104789&view=diff
==============================================================================
--- cfe/trunk/test/Parser/pragma-options.c (original)
+++ cfe/trunk/test/Parser/pragma-options.c Wed May 26 19:35:16 2010
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s
/* expected-warning {{expected 'align' following '#pragma options'}} */ #pragma options
/* expected-warning {{expected '=' following '#pragma options align'}} */ #pragma options align
Added: cfe/trunk/test/Sema/pragma-align-mac68k-unsupported.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pragma-align-mac68k-unsupported.c?rev=104789&view=auto
==============================================================================
--- cfe/trunk/test/Sema/pragma-align-mac68k-unsupported.c (added)
+++ cfe/trunk/test/Sema/pragma-align-mac68k-unsupported.c Wed May 26 19:35:16 2010
@@ -0,0 +1,4 @@
+// RUN: %clang-cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang-cc1 -triple i386-pc-linux-gnu -fsyntax-only -verify %s
+
+/* expected-error {{mac68k alignment pragma is not supported}} */ #pragma options align=mac68k
More information about the cfe-commits
mailing list