[Ada] Consistently use explicit Entity_Id type instead of alias
[gcc.git] / libcpp / expr.c
index 317faf50208e853a26746424b9b894d26926813d..2ba7726d61c4679edca4270eb5d1d4e02cf566be 100644 (file)
@@ -64,8 +64,6 @@ static unsigned int interpret_float_suffix (cpp_reader *, const uchar *, size_t)
 static unsigned int interpret_int_suffix (cpp_reader *, const uchar *, size_t);
 static void check_promotion (cpp_reader *, const struct op *);
 
-static cpp_num parse_has_include (cpp_reader *, enum include_type);
-
 /* Token type abuse to create unary plus and minus operators.  */
 #define CPP_UPLUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 1))
 #define CPP_UMINUS ((enum cpp_ttype) (CPP_LAST_CPP_OP + 2))
@@ -814,14 +812,21 @@ cpp_classify_number (cpp_reader *pfile, const cpp_token *token,
   if ((result & CPP_N_IMAGINARY) && CPP_PEDANTIC (pfile))
     cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
                         "imaginary constants are a GCC extension");
-  if (radix == 2
-      && !CPP_OPTION (pfile, binary_constants)
-      && CPP_PEDANTIC (pfile))
-    cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
-                        CPP_OPTION (pfile, cplusplus)
-                        ? N_("binary constants are a C++14 feature "
-                             "or GCC extension")
-                        : N_("binary constants are a GCC extension"));
+  if (radix == 2)
+    {
+      if (!CPP_OPTION (pfile, binary_constants)
+         && CPP_PEDANTIC (pfile))
+       cpp_error_with_line (pfile, CPP_DL_PEDWARN, virtual_location, 0,
+                            CPP_OPTION (pfile, cplusplus)
+                            ? N_("binary constants are a C++14 feature "
+                                 "or GCC extension")
+                            : N_("binary constants are a C2X feature "
+                                 "or GCC extension"));
+      else if (CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) > 0)
+       cpp_warning_with_line (pfile, CPP_W_C11_C2X_COMPAT,
+                              virtual_location, 0,
+                              "binary constants are a C2X feature");
+    }
 
   if (radix == 10)
     result |= CPP_N_DECIMAL;
@@ -1063,6 +1068,7 @@ parse_defined (cpp_reader *pfile)
        }
     }
 
+  bool is_defined = false;
   if (node)
     {
       if ((pfile->context != initial_context
@@ -1070,9 +1076,11 @@ parse_defined (cpp_reader *pfile)
          && CPP_OPTION (pfile, warn_expansion_to_defined))
         cpp_pedwarning (pfile, CPP_W_EXPANSION_TO_DEFINED,
                        "this use of \"defined\" may not be portable");
-
+      is_defined = _cpp_defined_macro_p (node);
+      if (!_cpp_maybe_notify_macro_use (pfile, node, token->src_loc))
+       /* It wasn't a macro after all.  */
+       is_defined = false;
       _cpp_mark_macro_used (node);
-      _cpp_maybe_notify_macro_use (pfile, node);
 
       /* A possible controlling macro of the form #if !defined ().
         _cpp_parse_expr checks there was no other junk on the line.  */
@@ -1088,8 +1096,7 @@ parse_defined (cpp_reader *pfile)
   result.unsignedp = false;
   result.high = 0;
   result.overflow = false;
-  result.low = (node && cpp_macro_p (node)
-               && !(node->flags & NODE_CONDITIONAL));
+  result.low = is_defined;
   return result;
 }
 
@@ -1160,10 +1167,6 @@ eval_token (cpp_reader *pfile, const cpp_token *token,
     case CPP_NAME:
       if (token->val.node.node == pfile->spec_nodes.n_defined)
        return parse_defined (pfile);
-      else if (token->val.node.node == pfile->spec_nodes.n__has_include__)
-       return parse_has_include (pfile, IT_INCLUDE);
-      else if (token->val.node.node == pfile->spec_nodes.n__has_include_next__)
-       return parse_has_include (pfile, IT_INCLUDE_NEXT);
       else if (CPP_OPTION (pfile, cplusplus)
               && (token->val.node.node == pfile->spec_nodes.n_true
                   || token->val.node.node == pfile->spec_nodes.n_false))
@@ -2190,61 +2193,3 @@ num_div_op (cpp_reader *pfile, cpp_num lhs, cpp_num rhs, enum cpp_ttype op,
   return lhs;
 }
 
-/* Handle meeting "__has_include__" in a preprocessor expression.  */
-static cpp_num
-parse_has_include (cpp_reader *pfile, enum include_type type)
-{
-  cpp_num result;
-
-  result.unsignedp = false;
-  result.high = 0;
-  result.overflow = false;
-  result.low = 0;
-
-  pfile->state.in__has_include__++;
-
-  const cpp_token *token = cpp_get_token (pfile);
-  bool paren = token->type == CPP_OPEN_PAREN;
-  if (paren)
-    token = cpp_get_token (pfile);
-
-  bool bracket = token->type != CPP_STRING;
-  cpp_hashnode *node = NULL;
-  char *fname = NULL;
-  if (token->type == CPP_STRING || token->type == CPP_HEADER_NAME)
-    {
-      fname = XNEWVEC (char, token->val.str.len - 1);
-      memcpy (fname, token->val.str.text + 1, token->val.str.len - 2);
-      fname[token->val.str.len - 2] = '\0';
-      node = token->val.node.node;
-    }
-  else if (token->type == CPP_LESS)
-    fname = _cpp_bracket_include (pfile);
-  else
-    cpp_error (pfile, CPP_DL_ERROR,
-              "operator \"__has_include__\" requires a header string");
-
-  if (fname)
-    {
-      /* Do not do the lookup if we're skipping, that's unnecessary
-        IO.  */
-      if (!pfile->state.skip_eval
-         && _cpp_has_header (pfile, fname, bracket, type))
-       result.low = 1;
-
-      XDELETEVEC (fname);
-    }
-
-  if (paren && !SEEN_EOL () && cpp_get_token (pfile)->type != CPP_CLOSE_PAREN)
-    cpp_error (pfile, CPP_DL_ERROR,
-              "missing ')' after \"__has_include__\"");
-
-  /* A possible controlling macro of the form #if !__has_include__ ().
-     _cpp_parse_expr checks there was no other junk on the line.  */
-  if (node)
-    pfile->mi_ind_cmacro = node;
-
-  pfile->state.in__has_include__--;
-
-  return result;
-}