Hi! I've noticed 3 spots in the C++ FE test just DECL_BUILT_IN and then immediately compare DECL_FUNCTION_CODE against BUILT_IN_* constants. That is only meaningful for BUILT_IN_NORMAL, while DECL_BUILT_IN macro is DECL_BUILT_IN_CLASS != NOT_BUILT_IN, so it also e.g. includes BUILT_IN_MD. If people are unlucky enough, their BUILT_IN_MD builtins might have the same DECL_FUNCTION_CODE and would be mishandled.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2016-06-15 Jakub Jelinek <ja...@redhat.com> * tree.c (builtin_valid_in_constant_expr_p): Test for DECL_BUILT_IN_CLASS equal to BUILT_IN_NORMAL instead of just DECL_BUILT_IN. (bot_manip): Likewise. * call.c (magic_varargs_p): Likewise. --- gcc/cp/tree.c.jj 2016-06-15 09:17:22.000000000 +0200 +++ gcc/cp/tree.c 2016-06-15 17:02:50.794984463 +0200 @@ -341,7 +341,8 @@ cp_stabilize_reference (tree ref) bool builtin_valid_in_constant_expr_p (const_tree decl) { - if (!(TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))) + if (!(TREE_CODE (decl) == FUNCTION_DECL + && DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)) /* Not a built-in. */ return false; switch (DECL_FUNCTION_CODE (decl)) @@ -2536,7 +2537,7 @@ bot_manip (tree* tp, int* walk_subtrees, /* builtin_LINE and builtin_FILE get the location where the default argument is expanded, not where the call was written. */ tree callee = get_callee_fndecl (*tp); - if (callee && DECL_BUILT_IN (callee)) + if (callee && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL) switch (DECL_FUNCTION_CODE (callee)) { case BUILT_IN_FILE: --- gcc/cp/call.c.jj 2016-06-15 09:17:22.000000000 +0200 +++ gcc/cp/call.c 2016-06-15 17:06:57.097793446 +0200 @@ -7140,7 +7141,7 @@ magic_varargs_p (tree fn) if (flag_cilkplus && is_cilkplus_reduce_builtin (fn) != BUILT_IN_NONE) return 2; - if (DECL_BUILT_IN (fn)) + if (DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL) switch (DECL_FUNCTION_CODE (fn)) { case BUILT_IN_CLASSIFY_TYPE: Jakub