diff options
author | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2025-09-02 15:58:26 -0700 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2025-09-02 15:58:26 -0700 |
commit | 071b4126c613881f4cb25b4e5c39032964827f88 (patch) | |
tree | 7ed805786566918630d1d617b1ed8f7310f5fd8e /libcpp/expr.cc | |
parent | 845d23f3ea08ba873197c275a8857eee7edad996 (diff) | |
parent | caa1c2f42691d68af4d894a5c3e700ecd2dba080 (diff) | |
download | gcc-devel/gfortran-test.zip gcc-devel/gfortran-test.tar.gz gcc-devel/gfortran-test.tar.bz2 |
Merge branch 'master' into gfortran-testdevel/gfortran-test
Diffstat (limited to 'libcpp/expr.cc')
-rw-r--r-- | libcpp/expr.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libcpp/expr.cc b/libcpp/expr.cc index 7bb57a3..910848d 100644 --- a/libcpp/expr.cc +++ b/libcpp/expr.cc @@ -1460,6 +1460,7 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir, location_t virtual_location = 0; pfile->state.skip_eval = 0; + pfile->state.comma_ok = 0; /* Set up detection of #if ! defined(). */ pfile->mi_ind_cmacro = 0; @@ -1521,6 +1522,10 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir, lex_count--; continue; + case CPP_OPEN_PAREN: + pfile->state.comma_ok++; + break; + default: if ((int) op.op <= (int) CPP_EQ || (int) op.op >= (int) CPP_PLUS_EQ) SYNTAX_ERROR2_AT (op.loc, @@ -1574,13 +1579,16 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir, case CPP_CLOSE_PAREN: if (pfile->state.in_directive == 3 && top == pfile->op_stack) goto embed_done; + pfile->state.comma_ok--; continue; case CPP_OR_OR: if (!num_zerop (top->value)) pfile->state.skip_eval++; break; - case CPP_AND_AND: case CPP_QUERY: + pfile->state.comma_ok++; + /* FALLTHRU */ + case CPP_AND_AND: if (num_zerop (top->value)) pfile->state.skip_eval++; break; @@ -1592,6 +1600,8 @@ _cpp_parse_expr (cpp_reader *pfile, const char *dir, pfile->state.skip_eval++; else pfile->state.skip_eval--; + pfile->state.comma_ok--; + break; default: break; } @@ -2209,8 +2219,10 @@ num_binary_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op) /* Comma. */ default: /* case CPP_COMMA: */ - if (CPP_PEDANTIC (pfile) && (!CPP_OPTION (pfile, c99) - || !pfile->state.skip_eval)) + if (CPP_PEDANTIC (pfile) + && (CPP_OPTION (pfile, cplusplus) + ? !pfile->state.comma_ok + : (!CPP_OPTION (pfile, c99) || !pfile->state.skip_eval))) cpp_pedwarning (pfile, CPP_W_PEDANTIC, "comma operator in operand of #%s", pfile->state.in_directive == 3 |