summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/AST/Expr.h8
-rw-r--r--clang/include/clang/Basic/LangOptions.h35
-rw-r--r--clang/include/clang/Basic/TokenKinds.def5
-rw-r--r--clang/include/clang/Parse/Parser.h4
-rw-r--r--clang/include/clang/Sema/Sema.h4
5 files changed, 50 insertions, 6 deletions
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 0a457d6b97a..474b796ea63 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3269,7 +3269,7 @@ private:
// This is only meaningful for operations on floating point types and 0
// otherwise.
- unsigned FPFeatures : 2;
+ unsigned FPFeatures : 3;
SourceLocation OpLoc;
enum { LHS, RHS, END_EXPR };
@@ -3448,6 +3448,12 @@ public:
return FPOptions(FPFeatures).allowFPContractWithinStatement();
}
+ // Get the FENV_ACCESS status of this operator. Only meaningful for
+ // operations on floating point types.
+ bool isFEnvAccessOn() const {
+ return FPOptions(FPFeatures).allowFEnvAccess();
+ }
+
protected:
BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
ExprValueKind VK, ExprObjectKind OK,
diff --git a/clang/include/clang/Basic/LangOptions.h b/clang/include/clang/Basic/LangOptions.h
index a1396f84352..a7a5105fdfb 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -137,6 +137,14 @@ public:
FPC_Fast
};
+ // TODO: merge FEnvAccessModeKind and FPContractModeKind
+ enum FEnvAccessModeKind {
+ FEA_Off,
+
+ FEA_On
+ };
+
+
public:
/// Set of enabled sanitizers.
SanitizerSet Sanitize;
@@ -262,14 +270,19 @@ public:
/// Floating point control options
class FPOptions {
public:
- FPOptions() : fp_contract(LangOptions::FPC_Off) {}
+ FPOptions() : fp_contract(LangOptions::FPC_Off),
+ fenv_access(LangOptions::FEA_Off) {}
// Used for serializing.
explicit FPOptions(unsigned I)
- : fp_contract(static_cast<LangOptions::FPContractModeKind>(I)) {}
+ : fp_contract(static_cast<LangOptions::FPContractModeKind>(I & 3)),
+ fenv_access(static_cast<LangOptions::FEnvAccessModeKind>((I >> 2) & 1))
+ {}
explicit FPOptions(const LangOptions &LangOpts)
- : fp_contract(LangOpts.getDefaultFPContractMode()) {}
+ : fp_contract(LangOpts.getDefaultFPContractMode()),
+ fenv_access(LangOptions::FEA_Off) {}
+ // FIXME: Use getDefaultFEnvAccessMode() when available.
bool allowFPContractWithinStatement() const {
return fp_contract == LangOptions::FPC_On;
@@ -289,12 +302,24 @@ public:
void setDisallowFPContract() { fp_contract = LangOptions::FPC_Off; }
+ bool allowFEnvAccess() const {
+ return fenv_access == LangOptions::FEA_On;
+ }
+
+ void setAllowFEnvAccess() {
+ fenv_access = LangOptions::FEA_On;
+ }
+
+ void setDisallowFEnvAccess() { fenv_access = LangOptions::FEA_Off; }
+
/// Used to serialize this.
- unsigned getInt() const { return fp_contract; }
+ unsigned getInt() const { return fp_contract | (fenv_access << 2); }
private:
- /// Adjust BinaryOperator::FPFeatures to match the bit-field size of this.
+ /// Adjust BinaryOperator::FPFeatures to match the total bit-field size
+ /// of these two.
unsigned fp_contract : 2;
+ unsigned fenv_access : 1;
};
/// Describes the kind of translation unit being processed.
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 30cb022f1cb..caea67adba4 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -780,6 +780,11 @@ ANNOTATION(pragma_redefine_extname)
// handles them.
ANNOTATION(pragma_fp_contract)
+// Annotation for #pragma STDC FENV_ACCESS
+// The lexer produces these so that they only take effect when the parser
+// handles them.
+ANNOTATION(pragma_fenv_access)
+
// Annotation for #pragma pointers_to_members...
// The lexer produces these so that they only take effect when the parser
// handles them.
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index 1d6849cd5b4..32874ee44ff 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -670,6 +670,10 @@ private:
void HandlePragmaFPContract();
/// Handle the annotation token produced for
+ /// #pragma STDC FENV_ACCESS...
+ void HandlePragmaFEnvAccess();
+
+ /// \brief Handle the annotation token produced for
/// #pragma clang fp ...
void HandlePragmaFP();
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b3d1c96bdfc..aa6e4b7cfe8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -8434,6 +8434,10 @@ public:
/// \#pragma clang fp contract
void ActOnPragmaFPContract(LangOptions::FPContractModeKind FPC);
+ /// ActOnPragmaFenvAccess - Called on well formed
+ /// \#pragma STDC FENV_ACCESS
+ void ActOnPragmaFEnvAccess(LangOptions::FEnvAccessModeKind FPC);
+
/// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
/// a the record decl, to handle '\#pragma pack' and '\#pragma options align'.
void AddAlignmentAttributesForRecord(RecordDecl *RD);
OpenPOWER on IntegriCloud