[cfe-commits] r166383 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseStmt.cpp test/CodeGen/fp-contract-pragma.cpp test/Parser/pragma-fp-contract.c
Dmitri Gribenko
gribozavr at gmail.com
Sun Oct 21 02:37:41 PDT 2012
Hi Lang,
On Sun, Oct 21, 2012 at 4:10 AM, Lang Hames <lhames at gmail.com> wrote:
> Author: lhames
> Date: Sat Oct 20 20:10:01 2012
> New Revision: 166383
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166383&view=rev
> Log:
> When used in a compound expression FP_CONTRACT should proceed all explicit
> declarations and statements. Emit an error if the FP_CONTRACT is used
> later in a compound statement.
>
> Added:
> cfe/trunk/test/Parser/pragma-fp-contract.c
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> cfe/trunk/lib/Parse/ParseStmt.cpp
> cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=166383&r1=166382&r2=166383&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Sat Oct 20 20:10:01 2012
> @@ -729,6 +729,10 @@
> "expected '#pragma unused' argument to be a variable name">;
> def warn_pragma_unused_expected_punc : Warning<
> "expected ')' or ',' in '#pragma unused'">;
> +// - #pragam fp_contract
Typo 'pragam'.
> +def err_pragma_fp_contract_scope : Error<
> + "'#pragma fp_contract' should only appear at file scope or at the start of a "
> + "compound expression">;
>
> // OpenCL Section 6.8.g
> def err_not_opencl_storage_class_specifier : Error<
>
> Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=166383&r1=166382&r2=166383&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
> +++ cfe/trunk/lib/Parse/ParseStmt.cpp Sat Oct 20 20:10:01 2012
> @@ -280,9 +280,10 @@
> return StmtEmpty();
>
> case tok::annot_pragma_fp_contract:
> - ProhibitAttributes(Attrs);
> - HandlePragmaFPContract();
> - return StmtEmpty();
> + Diag(Tok, diag::err_pragma_fp_contract_scope);
> + ConsumeToken();
> + return StmtError();
> +
>
> case tok::annot_pragma_opencl_extension:
> ProhibitAttributes(Attrs);
> @@ -728,6 +729,10 @@
>
> StmtVector Stmts;
>
> + // Parse FP_CONTRACT if present.
> + if (Tok.is(tok::annot_pragma_fp_contract))
> + HandlePragmaFPContract();
> +
> // "__label__ X, Y, Z;" is the GNU "Local Label" extension. These are
> // only allowed at the start of a compound stmt regardless of the language.
> while (Tok.is(tok::kw___label__)) {
>
> Modified: cfe/trunk/test/CodeGen/fp-contract-pragma.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fp-contract-pragma.cpp?rev=166383&r1=166382&r2=166383&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGen/fp-contract-pragma.cpp (original)
> +++ cfe/trunk/test/CodeGen/fp-contract-pragma.cpp Sat Oct 20 20:10:01 2012
> @@ -39,7 +39,6 @@
> float method(float a, float b, float c) {
> #pragma STDC FP_CONTRACT ON
> return a * b + c;
> - #pragma STDC FP_CONTRACT OFF
> }
> };
>
>
> Added: cfe/trunk/test/Parser/pragma-fp-contract.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/pragma-fp-contract.c?rev=166383&view=auto
> ==============================================================================
> --- cfe/trunk/test/Parser/pragma-fp-contract.c (added)
> +++ cfe/trunk/test/Parser/pragma-fp-contract.c Sat Oct 20 20:10:01 2012
> @@ -0,0 +1,6 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify %s
> +
> +void f1(void) {
> + int x = 0;
> +/* expected-error {{'#pragma fp_contract' should only appear at file scope or at the start of a compound expression}} */ #pragma STDC FP_CONTRACT ON
It might be cleaner to use expected-error at +1 and move the message to
the previous line.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
More information about the cfe-commits
mailing list